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# (a0 << 21) ^ ~a1 15.function i32 xor_not_shl_i32(i32 a0, i32 a1) <static> { 16 movi v0, 21 17 lda a0 18 shl2 v0 19 sta v0 20 lda a1 21 not 22 xor2 v0 23 return 24} 25# (a0 >>> 21) ^ ~a1 26.function i32 xor_not_shr_i32(i32 a0, i32 a1) <static> { 27 movi v0, 21 28 lda a0 29 shr2 v0 30 sta v0 31 lda a1 32 not 33 xor2 v0 34 return 35} 36# (a0 >> 21) ^ ~a1 37.function i32 xor_not_ashr_i32(i32 a0, i32 a1) <static> { 38 movi v0, 21 39 lda a0 40 ashr2 v0 41 sta v0 42 lda a1 43 not 44 xor2 v0 45 return 46} 47# a1 ^ ~(a0 << 21) 48.function i32 xor_not_shl_i32_2(i32 a0, i32 a1) <static> { 49 movi v0, 21 50 lda a0 51 shl2 v0 52 not 53 xor2 a1 54 return 55} 56# a1 ^ ~(a0 >>> 21) 57.function i32 xor_not_shr_i32_2(i32 a0, i32 a1) <static> { 58 movi v0, 21 59 lda a0 60 shr2 v0 61 not 62 xor2 a1 63 return 64} 65# a1 ^ ~(a0 >> 21) 66.function i32 xor_not_ashr_i32_2(i32 a0, i32 a1) <static> { 67 movi v0, 21 68 lda a0 69 ashr2 v0 70 not 71 xor2 a1 72 return 73} 74# (a0 << 42) ^ ~a1 75.function i64 xor_not_shl_i64(i64 a0, i64 a1) <static> { 76 movi.64 v0, 42 77 lda.64 a0 78 shl2.64 v0 79 sta.64 v0 80 lda.64 a1 81 not.64 82 xor2.64 v0 83 return.64 84} 85# (a0 >>> 42) ^ ~a1 86.function i64 xor_not_shr_i64(i64 a0, i64 a1) <static> { 87 movi.64 v0, 42 88 lda.64 a0 89 shr2.64 v0 90 sta.64 v0 91 lda.64 a1 92 not.64 93 xor2.64 v0 94 return.64 95} 96# (a0 >> 42) ^ ~a1 97.function i64 xor_not_ashr_i64(i64 a0, i64 a1) <static> { 98 movi.64 v0, 42 99 lda.64 a0 100 ashr2.64 v0 101 sta.64 v0 102 lda.64 a1 103 not.64 104 xor2.64 v0 105 return.64 106} 107# a1 ^ ~(a0 << 42) 108.function i64 xor_not_shl_i64_2(i64 a0, i64 a1) <static> { 109 movi.64 v0, 42 110 lda.64 a0 111 shl2.64 v0 112 not.64 113 xor2.64 a1 114 return.64 115} 116# a1 ^ ~(a0 >>> 42) 117.function i64 xor_not_shr_i64_2(i64 a0, i64 a1) <static> { 118 movi.64 v0, 42 119 lda.64 a0 120 shr2.64 v0 121 not.64 122 xor2.64 a1 123 return.64 124} 125# a1 ^ ~(a0 >> 42) 126.function i64 xor_not_ashr_i64_2(i64 a0, i64 a1) <static> { 127 movi.64 v0, 42 128 lda.64 a0 129 ashr2.64 v0 130 not.64 131 xor2.64 a1 132 return.64 133} 134 135.function i32 main() <static> { 136 movi v0, 21 137 ldai 0x200000 138 shr2 v0 139 sta v0 140 movi v1, -1 141 call.short xor_not_shl_i32, v0, v1 142 movi v0, 0x200000 143 jne v0, exit_error_0 144 movi v0, 21 145 ldai 1 146 shl2 v0 147 sta v0 148 movi v1, -1 149 call.short xor_not_shr_i32, v0, v1 150 movi v0, 1 151 jne v0, exit_error_1 152 movi v0, 21 153 ldai -1 154 shl2 v0 155 sta v0 156 movi v1, -1 157 call.short xor_not_ashr_i32, v0, v1 158 movi v0, -1 159 jne v0, exit_error_2 160 movi v0, 21 161 ldai 0x200000 162 shr2 v0 163 sta v0 164 movi v1, -1 165 call.short xor_not_shl_i32_2, v0, v1 166 movi v0, 0x200000 167 jne v0, exit_error_3 168 movi v0, 21 169 ldai 1 170 shl2 v0 171 sta v0 172 movi v1, -1 173 call.short xor_not_shr_i32_2, v0, v1 174 movi v0, 1 175 jne v0, exit_error_4 176 movi v0, 21 177 ldai -1 178 shl2 v0 179 sta v0 180 movi v1, -1 181 call.short xor_not_ashr_i32_2, v0, v1 182 movi v0, -1 183 jne v0, exit_error_5 184 movi.64 v0, 42 185 ldai.64 0x40000000000 186 shr2.64 v0 187 sta.64 v0 188 movi.64 v1, 0 189 call.short xor_not_shl_i64, v0, v1 190 movi.64 v0, 0xfffffbffffffffff 191 cmp.64 v0 192 jnez exit_error_6 193 movi.64 v0, 42 194 ldai.64 1 195 shl2.64 v0 196 sta.64 v0 197 movi.64 v1, -1 198 call.short xor_not_shr_i64, v0, v1 199 movi.64 v0, 1 200 cmp.64 v0 201 jnez exit_error_7 202 movi.64 v0, 42 203 ldai.64 -1 204 shl2.64 v0 205 sta.64 v0 206 movi.64 v1, -1 207 call.short xor_not_ashr_i64, v0, v1 208 movi.64 v0, -1 209 cmp.64 v0 210 jnez exit_error_8 211 movi.64 v0, 42 212 ldai.64 0x40000000000 213 shr2.64 v0 214 sta.64 v0 215 movi.64 v1, -1 216 call.short xor_not_shl_i64_2, v0, v1 217 movi.64 v0, 0x40000000000 218 cmp.64 v0 219 jnez exit_error_9 220 movi.64 v0, 42 221 ldai.64 1 222 shl2.64 v0 223 sta.64 v0 224 movi.64 v1, -1 225 call.short xor_not_shr_i64_2, v0, v1 226 movi.64 v0, 1 227 cmp.64 v0 228 jnez exit_error_10 229 movi.64 v0, 42 230 ldai.64 -1 231 shl2.64 v0 232 sta.64 v0 233 movi.64 v1, -1 234 call.short xor_not_ashr_i64_2, v0, v1 235 movi.64 v0, -1 236 cmp.64 v0 237 jnez exit_error_11 238 ldai 0 239 return 240exit_error_0: 241 ldai 1 242 return 243exit_error_1: 244 ldai 2 245 return 246exit_error_2: 247 ldai 3 248 return 249exit_error_3: 250 ldai 4 251 return 252exit_error_4: 253 ldai 5 254 return 255exit_error_5: 256 ldai 6 257 return 258exit_error_6: 259 ldai 7 260 return 261exit_error_7: 262 ldai 8 263 return 264exit_error_8: 265 ldai 9 266 return 267exit_error_9: 268 ldai 10 269 return 270exit_error_10: 271 ldai 11 272 return 273exit_error_11: 274 ldai 12 275 return 276} 277