1# Copyright (c) 2021-2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14definitions: [] 15tests: 16 - file-name: "i64tou1" 17 isa: 18 title: Conversions from integer types to u1 19 description: > 20 Conversion from integer types to u1 obeys the following rules. 21 If converted integer is not equal to zero, the result is 1. 22 Otherwise the result is 0. 23 exceptions: 24 - x_none 25 commands: 26 - file-name: "op_none" 27 isa: 28 instructions: 29 - sig: i64tou1 30 acc: inout:i64->u1 31 prefix: cast 32 format: [pref_op_none] 33 code-template: | 34 # 35 ldai.64 %s 36 i64tou1 37 movi v0, %s 38 jne v0, set_failure 39 ldai 0 40 jmp fall_through 41 set_failure: 42 ldai 1 43 fall_through: 44 description: Check i64tou1 with various values. 45 tags: ['tsan'] 46 cases: 47 - values: 48 - "0" 49 - "0" 50 - values: 51 - "-1" 52 - "1" 53 - values: 54 - "0x1111111122222222" 55 - "1" 56 - values: 57 - "0x7fffffffffffffff" 58 - "1" 59 - values: 60 - "0xBBCCDDEE00000001" 61 - "1" 62 - file-name: "type" 63 isa: 64 instructions: 65 - sig: i64tou1 66 acc: inout:i64->u1 67 prefix: cast 68 format: [pref_op_none] 69 verification: 70 - acc_type 71 bugid: ["964", "1653", "2107"] 72 tags: ["verifier"] 73 description: | 74 Check `i64tou1` with incorrect accumulator type. 75 Load different values (objects, strings, types, 64-bit floating point values, 32-bit integer values) and invokes `i64tou1`. 76 Return 0 to indicate that negative test failed, because this line is unreachable and code will not be executed after verification error. 77 runner-options: ['verifier-failure', 'verifier-config'] 78 header-template: [] 79 code-template: | 80 # 81 .record B {} 82 .record panda.String <external> 83 .record panda.Object <external> 84 .function i32 main() { 85 %s 86 i64tou1 87 check-type: exit-positive 88 cases: 89 - values: 90 - ldai 0 91 - values: 92 - fldai 0 93 - values: 94 - fldai.64 0 95 - values: 96 - lda.type B 97 - values: 98 - lda.type B[] 99 - values: 100 - lda.type panda.String 101 - values: 102 - lda.str "string" 103 - values: 104 - lda.type panda.Object 105 - values: 106 - | 107 # 108 movi v0, 10 109 newarr v0, v0, i32[] 110 lda.obj v0 111 - values: 112 - lda.null 113 114 - file-name: uninitialized_regs 115 isa: 116 instructions: 117 - sig: i64tou1 118 acc: inout:i64->u1 119 prefix: cast 120 format: [pref_op_none] 121 description: Check 'i64tou1' with uninitialized accumulator. 122 tags: ['verifier'] 123 runner-options: ['verifier-failure', 'verifier-config'] 124 code-template: | 125 # 126 i64tou1 127 check-type: exit-positive 128