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: "i32toi8" 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 signed integer, the value is sign-extended to destination type. 22 exceptions: 23 - x_none 24 commands: 25 - file-name: "op_none" 26 isa: 27 instructions: 28 - sig: i32toi8 29 acc: inout:i32->i8 30 prefix: cast 31 format: [pref_op_none] 32 code-template: | 33 # 34 ldai %s 35 i32toi8 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 i32toi8 with various values. 44 tags: ['tsan'] 45 cases: 46 - values: ["0", "0"] 47 - values: ["1", "1"] 48 - values: ["-1", "-1"] 49 - values: ["0x7FFFFFFF", "0xFFFFFFFFFFFFFFFF"] 50 - values: ["-0x7FFFFFFF", "1"] 51 - values: ["0x80000000", "0"] 52 - values: ["-0x80000000", "0"] 53 - values: ["0xFFFFFFFF", "0xFFFFFFFFFFFFFFFF"] 54 - values: ["-0xFFFFFFFF", "-0xFFFFFFFFFFFFFFFF"] 55 - values: ["0xf0f0f0f0", "0xFFFFFFFFFFFFFFF0"] 56 - values: ["0x7f0f0f0f", "0x000000000000000F"] 57 58 - file-name: "type" 59 isa: 60 instructions: 61 - sig: i32toi8 62 acc: inout:i32->i8 63 prefix: cast 64 format: [pref_op_none] 65 verification: 66 - acc_type 67 description: | 68 Check `i32toi8` with incorrect accumulator type. 69 Load different values (objects, strings, types, 64-bit floating point values, 64-bit integer values) and invokes `i32toi8`. 70 Return 0 to indicate that negative test failed, because this line is unreachable and code will not be executed after verification error. 71 bugid: ["964", "1653"] 72 tags: ["verifier"] 73 runner-options: ['verifier-failure', 'verifier-debug-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 i32toi8 83 check-type: exit-positive 84 cases: 85 - values: 86 - ldai.64 0 87 - values: 88 - fldai.64 0 89 - values: 90 - lda.type B 91 - values: 92 - lda.type B[] 93 - values: 94 - lda.type panda.String 95 - values: 96 - lda.str "string" 97 - values: 98 - lda.type panda.Object 99 - values: 100 - | 101 # 102 movi v0, 10 103 newarr v0, v0, i32[] 104 lda.obj v0 105 - values: 106 - lda.null 107 108 - file-name: uninitialized_regs 109 isa: 110 instructions: 111 - sig: i32toi8 112 acc: inout:i32->i8 113 prefix: cast 114 format: [pref_op_none] 115 description: Check i32toi8 with uninitialized accumulator. 116 tags: ['verifier'] 117 runner-options: ['verifier-failure', 'verifier-debug-config'] 118 header-template: [] 119 code-template: | 120 # 121 .function i32 main() { 122 i32toi8 123 check-type: exit-positive 124