# Copyright (c) 2021-2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. definitions: [] tests: - file-name: "i32tou1" isa: title: Conversions from integer types to u1 description: > Conversion from integer types to u1 obeys the following rules. If converted integer is not equal to zero, the result is 1. Otherwise the result is 0. exceptions: - x_none commands: - file-name: "op_none" isa: instructions: - sig: i32tou1 acc: inout:i32->u1 prefix: cast format: [pref_op_none] code-template: | # ldai %s i32tou1 movi v0, %s ucmp v0 description: Check i32tou1 with various values. tags: ['tsan'] cases: - values: ["0", "0"] - values: ["1", "1"] - values: ["-1", "1"] - values: ["0x7FFFFFFF", "1"] - values: ["-0x7FFFFFFF", "1"] - values: ["0x80000000", "1"] - values: ["-0x80000000", "1"] - values: ["0xFFFFFFFF", "1"] - values: ["-0xFFFFFFFF", "1"] - values: ["0xf0f0f0f0", "1"] - values: ["0x7f0f0f0f", "1"] - file-name: "type" isa: instructions: - sig: i32tou1 acc: inout:i32->u1 prefix: cast format: [pref_op_none] verification: - acc_type description: | Check `i32tou1` with incorrect accumulator type. Load different values (objects, strings, types, 64-bit floating point values, 64-bit integer values) and invokes `i32tou1`. Return 0 to indicate that negative test failed, because this line is unreachable and code will not be executed after verification error. bugid: ["964", "1653"] tags: ["verifier"] runner-options: ['verifier-failure', 'verifier-config'] header-template: [] code-template: | # .record B {} .record panda.String .record panda.Object .function i32 main() { %s i32tou1 check-type: exit-positive cases: - values: - ldai.64 0 - values: - fldai 0 - values: - fldai.64 0 - values: - lda.type B - values: - lda.type B[] - values: - lda.type panda.String - values: - lda.str "string" - values: - lda.type panda.Object - values: - | # movi v0, 10 newarr v0, v0, i32[] lda.obj v0 - values: - lda.null - file-name: uninitialized_regs isa: instructions: - sig: i32tou1 acc: inout:i32->u1 prefix: cast format: [pref_op_none] description: Check 'i32tou1' with uninitialized accumulator. tags: ['verifier'] runner-options: ['verifier-failure', 'verifier-config'] code-template: | # i32tou1 check-type: exit-positive