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