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 14.function i32 xor_not_i32(i32 a0, i32 a1) <static> { 15 ldai -1 16 xor2 a0 17 xor2 a1 18 return 19} 20 21.function i64 xor_not_i64(i64 a0, i64 a1) <static> { 22 ldai.64 -1 23 xor2.64 a0 24 xor2.64 a1 25 return.64 26} 27 28.function i32 and_not_i32(i32 a0, i32 a1) <static> { 29 ldai -1 30 xor2 a0 31 and2 a1 32 return 33} 34 35.function i64 and_not_i64(i64 a0, i64 a1) <static> { 36 ldai.64 -1 37 xor2.64 a0 38 and2.64 a1 39 return.64 40} 41 42.function i32 or_not_i32(i32 a0, i32 a1) <static> { 43 ldai -1 44 xor2 a0 45 or2 a1 46 return 47} 48 49.function i64 or_not_i64(i64 a0, i64 a1) <static> { 50 ldai.64 -1 51 xor2.64 a0 52 or2.64 a1 53 return.64 54} 55 56.function i32 main() { 57 movi v0, 0x00ff00ff 58 movi v1, 0x00ff00ff 59 call.short xor_not_i32, v0, v1 60 movi v0, -1 61 jne v0, exit_error_0 62 movi v0, 0xffff0000 63 movi v1, 0x12345678 64 call.short and_not_i32, v0, v1 65 movi v0, 0x5678 66 jne v0, exit_error_1 67 movi v0, 0xff00ff00 68 movi v1, 0x0ff00ff0 69 call.short or_not_i32, v0, v1 70 movi v0, 0x0fff0fff 71 jne v0, exit_error_2 72 movi.64 v0, 0x00ff00ff00ff00ff 73 movi.64 v1, 0x00ff00ff00ff00ff 74 call.short xor_not_i64, v0, v1 75 movi.64 v0, -1 76 cmp.64 v0 77 jnez exit_error_3 78 movi.64 v0, 0xffff0000ffff0000 79 movi.64 v1, 0x1234567887654321 80 call.short and_not_i64, v0, v1 81 movi.64 v0, 0x567800004321 82 cmp.64 v0 83 jnez exit_error_4 84 movi.64 v0, 0xff00ff00ff00ff00 85 movi.64 v1, 0x0ff00ff00ff00ff0 86 call.short or_not_i64, v0, v1 87 movi.64 v0, 0x0fff0fff0fff0fff 88 cmp.64 v0 89 jnez exit_error_5 90 ldai 0 91 return 92exit_error_0: 93 ldai 1 94 return 95exit_error_1: 96 ldai 2 97 return 98exit_error_2: 99 ldai 3 100 return 101exit_error_3: 102 ldai 4 103 return 104exit_error_4: 105 ldai 5 106 return 107exit_error_5: 108 ldai 6 109 return 110} 111