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