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: "i64toi32" 17 isa: 18 title: Integer truncations and extensions. 19 description: > 20 Perform specified integer extension or truncations of accumulator. 21 Truncations discard all but N lowest-order bits, where N is the bit size of destination type. 22 exceptions: 23 - x_none 24 commands: 25 - file-name: "op_none" 26 isa: 27 instructions: 28 - sig: i64toi32 29 acc: inout:i64->i32 30 prefix: cast 31 format: [pref_op_none] 32 code-template: | 33 # 34 ldai.64 %s 35 i64toi32 36 movi v0, %s 37 jne v0, set_failure 38 ldai 0 39 jmp fall_through 40 set_failure: 41 ldai 1 42 fall_through: 43 description: Check i64toi32 with various values. 44 tags: ['tsan'] 45 cases: 46 - values: 47 - "0" 48 - "0" 49 - values: 50 - "-1" 51 - "-1" 52 - values: 53 - "0x1111111122222222" 54 - "0x22222222" 55 - values: 56 - "0x7fffffffffffffff" 57 - "-1" 58 - values: 59 - "0xBBCCDDEE00000001" 60 - "1" 61 - file-name: "type" 62 isa: 63 instructions: 64 - sig: i64toi32 65 acc: inout:i64->i32 66 prefix: cast 67 format: [pref_op_none] 68 verification: 69 - acc_type 70 bugid: ["964", "1653", "2107"] 71 tags: ["verifier"] 72 description: | 73 Check `i64toi32` with incorrect accumulator type. 74 Load different values (objects, strings, types, 64-bit floating point values, 32-bit integer values) and invokes `i64toi32`. 75 Return 0 to indicate that negative test failed, because this line is unreachable and code will not be executed after verification error. 76 runner-options: ['verifier-failure', 'verifier-config'] 77 header-template: [] 78 code-template: | 79 # 80 .record B {} 81 .record panda.String <external> 82 .record panda.Object <external> 83 .function i32 main() { 84 %s 85 i64toi32 86 check-type: exit-positive 87 cases: 88 - values: 89 - ldai 0 90 - values: 91 - fldai 0 92 - values: 93 - fldai.64 0 94 - values: 95 - lda.type B 96 - values: 97 - lda.type B[] 98 - values: 99 - lda.type panda.String 100 - values: 101 - lda.str "string" 102 - values: 103 - lda.type panda.Object 104 - values: 105 - | 106 # 107 movi v0, 10 108 newarr v0, v0, i32[] 109 lda.obj v0 110 - values: 111 - lda.null 112 113 - file-name: uninitialized_regs 114 isa: 115 instructions: 116 - sig: i64toi32 117 acc: inout:i64->i32 118 prefix: cast 119 format: [pref_op_none] 120 description: Check 'i64toi32' with uninitialized accumulator. 121 tags: ['verifier'] 122 runner-options: ['verifier-failure', 'verifier-config'] 123 code-template: | 124 # 125 i64toi32 126 check-type: exit-positive 127