1# Copyright (c) 2021 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: "i32tou1" 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: i32tou1 30 acc: inout:i32->u1 31 prefix: cast 32 format: [pref_op_none] 33 code-template: | 34 # 35 ldai %s 36 i32tou1 37 movi v0, %s 38 ucmp v0 39 description: Check i32tou1 with various values. 40 tags: ['tsan'] 41 cases: 42 - values: ["0", "0"] 43 - values: ["1", "1"] 44 - values: ["-1", "1"] 45 - values: ["0x7FFFFFFF", "1"] 46 - values: ["-0x7FFFFFFF", "1"] 47 - values: ["0x80000000", "1"] 48 - values: ["-0x80000000", "1"] 49 - values: ["0xFFFFFFFF", "1"] 50 - values: ["-0xFFFFFFFF", "1"] 51 - values: ["0xf0f0f0f0", "1"] 52 - values: ["0x7f0f0f0f", "1"] 53 54 - file-name: "type" 55 isa: 56 instructions: 57 - sig: i32tou1 58 acc: inout:i32->u1 59 prefix: cast 60 format: [pref_op_none] 61 verification: 62 - acc_type 63 description: | 64 Check `i32tou1` with incorrect accumulator type. 65 Load different values (objects, strings, types, 64-bit floating point values, 64-bit integer values) and invokes `i32tou1`. 66 Return 0 to indicate that negative test failed, because this line is unreachable and code will not be executed after verification error. 67 bugid: ["964", "1653"] 68 tags: ["verifier"] 69 runner-options: ['verifier-failure', 'verifier-debug-config'] 70 header-template: [] 71 code-template: | 72 # 73 .record B {} 74 .record panda.String <external> 75 .record panda.Object <external> 76 .function i32 main() { 77 %s 78 i32tou1 79 check-type: exit-positive 80 cases: 81 - values: 82 - ldai.64 0 83 - values: 84 - fldai.64 0 85 - values: 86 - lda.type B 87 - values: 88 - lda.type B[] 89 - values: 90 - lda.type panda.String 91 - values: 92 - lda.str "string" 93 - values: 94 - lda.type panda.Object 95 - values: 96 - | 97 # 98 movi v0, 10 99 newarr v0, v0, i32[] 100 lda.obj v0 101 - values: 102 - lda.null 103 104 - file-name: uninitialized_regs 105 isa: 106 instructions: 107 - sig: i32tou1 108 acc: inout:i32->u1 109 prefix: cast 110 format: [pref_op_none] 111 description: Check i32tou1 with uninitialized accumulator. 112 tags: ['verifier'] 113 runner-options: ['verifier-failure', 'verifier-debug-config'] 114 header-template: [] 115 code-template: | 116 # 117 .function i32 main() { 118 i32tou1 119 check-type: exit-positive 120