# 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. # (a0 << 21) - a1 .function i32 sub_shl_i32(i32 a0, i32 a1) { movi v0, 21 lda a0 shl2 v0 sub2 a1 return } # (a0 >>> 21) - a1 .function i32 sub_shr_i32(i32 a0, i32 a1) { movi v0, 21 lda a0 shr2 v0 sub2 a1 return } # (a0 >> 21) - a1 .function i32 sub_ashr_i32(i32 a0, i32 a1) { movi v0, 21 lda a0 ashr2 v0 sub2 a1 return } # a1 - (a0 << 21) .function i32 sub_shl_i32_2(i32 a0, i32 a1) { movi v0, 21 lda a0 shl2 v0 sta v0 lda a1 sub2 v0 return } # a1 - (a0 >>> 21) .function i32 sub_shr_i32_2(i32 a0, i32 a1) { movi v0, 21 lda a0 shr2 v0 sta v0 lda a1 sub2 v0 return } # a1 - (a0 >> 21) .function i32 sub_ashr_i32_2(i32 a0, i32 a1) { movi v0, 21 lda a0 ashr2 v0 sta v0 lda a1 sub2 v0 return } # (a0 << 42) - a1 .function i64 sub_shl_i64(i64 a0, i64 a1) { movi.64 v0, 42 lda.64 a0 shl2.64 v0 sub2.64 a1 return.64 } # (a0 >>> 42) - a1 .function i64 sub_shr_i64(i64 a0, i64 a1) { movi.64 v0, 42 lda.64 a0 shr2.64 v0 sub2.64 a1 return.64 } # (a0 >> 42) - a1 .function i64 sub_ashr_i64(i64 a0, i64 a1) { movi.64 v0, 42 lda.64 a0 ashr2.64 v0 sub2.64 a1 return.64 } # a1 - (a0 << 42) .function i64 sub_shl_i64_2(i64 a0, i64 a1) { movi.64 v0, 42 lda.64 a0 shl2.64 v0 sta.64 v0 lda.64 a1 sub2.64 v0 return.64 } # a1 - (a0 >>> 42) .function i64 sub_shr_i64_2(i64 a0, i64 a1) { movi.64 v0, 42 lda.64 a0 shr2.64 v0 sta.64 v0 lda.64 a1 sub2.64 v0 return.64 } # a1 - (a0 >> 42) .function i64 sub_ashr_i64_2(i64 a0, i64 a1) { movi.64 v0, 42 lda.64 a0 ashr2.64 v0 sta.64 v0 lda.64 a1 sub2.64 v0 return.64 } .function i32 main() { movi v0, 21 ldai 257949696 shr2 v0 sta v0 movi v1, 321 call.short sub_shl_i32, v0, v1 movi v0, 257949375 jne v0, exit_error_0 movi v0, 21 ldai 123 shl2 v0 sta v0 movi v1, 321 call.short sub_shr_i32, v0, v1 movi v0, -198 jne v0, exit_error_1 movi v0, 21 ldai -1 shl2 v0 sta v0 movi v1, 321 call.short sub_ashr_i32, v0, v1 movi v0, -322 jne v0, exit_error_2 movi v0, 21 ldai 257949696 shr2 v0 sta v0 movi v1, 321 call.short sub_shl_i32_2, v0, v1 movi v0, -257949375 jne v0, exit_error_3 movi v0, 21 ldai 123 shl2 v0 sta v0 movi v1, 321 call.short sub_shr_i32_2, v0, v1 movi v0, 198 jne v0, exit_error_4 movi v0, 21 ldai -1 shl2 v0 sta v0 movi v1, 321 call.short sub_ashr_i32_2, v0, v1 movi v0, 322 jne v0, exit_error_5 movi.64 v0, 42 ldai.64 540959720865792 shr2.64 v0 sta.64 v0 movi.64 v1, 321 call.short sub_shl_i64, v0, v1 movi.64 v0, 540959720865471 cmp.64 v0 jnez exit_error_6 movi.64 v0, 42 ldai.64 123 shl2.64 v0 sta.64 v0 movi.64 v1, 321 call.short sub_shr_i64, v0, v1 movi.64 v0, -198 cmp.64 v0 jnez exit_error_7 movi.64 v0, 42 ldai.64 -1 shl2.64 v0 sta.64 v0 movi.64 v1, 321 call.short sub_ashr_i64, v0, v1 movi.64 v0, -322 cmp.64 v0 jnez exit_error_8 movi.64 v0, 42 ldai.64 540959720865792 shr2.64 v0 sta.64 v0 movi.64 v1, 321 call.short sub_shl_i64_2, v0, v1 movi.64 v0, -540959720865471 cmp.64 v0 jnez exit_error_9 movi.64 v0, 42 ldai.64 123 shl2.64 v0 sta.64 v0 movi.64 v1, 321 call.short sub_shr_i64_2, v0, v1 movi.64 v0, 198 cmp.64 v0 jnez exit_error_10 movi.64 v0, 42 ldai.64 -1 shl2.64 v0 sta.64 v0 movi.64 v1, 321 call.short sub_ashr_i64_2, v0, v1 movi.64 v0, 322 cmp.64 v0 jnez exit_error_11 ldai 0 return exit_error_0: ldai 1 return exit_error_1: ldai 2 return exit_error_2: ldai 3 return exit_error_3: ldai 4 return exit_error_4: ldai 5 return exit_error_5: ldai 6 return exit_error_6: ldai 7 return exit_error_7: ldai 8 return exit_error_8: ldai 9 return exit_error_9: ldai 10 return exit_error_10: ldai 11 return exit_error_11: ldai 12 return }