1b1994897Sopenharmony_ci# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
2b1994897Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3b1994897Sopenharmony_ci# you may not use this file except in compliance with the License.
4b1994897Sopenharmony_ci# You may obtain a copy of the License at
5b1994897Sopenharmony_ci#
6b1994897Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0
7b1994897Sopenharmony_ci#
8b1994897Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9b1994897Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10b1994897Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11b1994897Sopenharmony_ci# See the License for the specific language governing permissions and
12b1994897Sopenharmony_ci# limitations under the License.
13b1994897Sopenharmony_ci
14b1994897Sopenharmony_ci.function i32 neg_shl_i32(i32 a0) {
15b1994897Sopenharmony_ci  movi v0, 21
16b1994897Sopenharmony_ci  lda a0
17b1994897Sopenharmony_ci  shl2 v0
18b1994897Sopenharmony_ci  neg
19b1994897Sopenharmony_ci  return
20b1994897Sopenharmony_ci}
21b1994897Sopenharmony_ci
22b1994897Sopenharmony_ci.function i32 neg_shr_i32(i32 a0) {
23b1994897Sopenharmony_ci  movi v0, 21
24b1994897Sopenharmony_ci  lda a0
25b1994897Sopenharmony_ci  shr2 v0
26b1994897Sopenharmony_ci  neg
27b1994897Sopenharmony_ci  return
28b1994897Sopenharmony_ci}
29b1994897Sopenharmony_ci
30b1994897Sopenharmony_ci.function i32 neg_ashr_i32(i32 a0) {
31b1994897Sopenharmony_ci  movi v0, 21
32b1994897Sopenharmony_ci  lda a0
33b1994897Sopenharmony_ci  ashr2 v0
34b1994897Sopenharmony_ci  neg
35b1994897Sopenharmony_ci  return
36b1994897Sopenharmony_ci}
37b1994897Sopenharmony_ci
38b1994897Sopenharmony_ci.function i64 neg_shl_i64(i64 a0) {
39b1994897Sopenharmony_ci  movi.64 v0, 42
40b1994897Sopenharmony_ci  lda.64 a0
41b1994897Sopenharmony_ci  shl2.64 v0
42b1994897Sopenharmony_ci  neg.64
43b1994897Sopenharmony_ci  return.64
44b1994897Sopenharmony_ci}
45b1994897Sopenharmony_ci
46b1994897Sopenharmony_ci.function i64 neg_shr_i64(i64 a0) {
47b1994897Sopenharmony_ci  movi.64 v0, 42
48b1994897Sopenharmony_ci  lda.64 a0
49b1994897Sopenharmony_ci  shr2.64 v0
50b1994897Sopenharmony_ci  neg.64
51b1994897Sopenharmony_ci  return.64
52b1994897Sopenharmony_ci}
53b1994897Sopenharmony_ci
54b1994897Sopenharmony_ci.function i64 neg_ashr_i64(i64 a0) {
55b1994897Sopenharmony_ci  movi.64 v0, 42
56b1994897Sopenharmony_ci  lda.64 a0
57b1994897Sopenharmony_ci  ashr2.64 v0
58b1994897Sopenharmony_ci  neg.64
59b1994897Sopenharmony_ci  return.64
60b1994897Sopenharmony_ci}
61b1994897Sopenharmony_ci
62b1994897Sopenharmony_ci.function i32 main() {
63b1994897Sopenharmony_ci  movi v0, -1
64b1994897Sopenharmony_ci  call.short neg_shl_i32, v0, v0
65b1994897Sopenharmony_ci  movi v0, 0x200000
66b1994897Sopenharmony_ci  jne v0, exit_error_0
67b1994897Sopenharmony_ci  movi v0, 0x200000
68b1994897Sopenharmony_ci  call.short neg_shr_i32, v0, v0
69b1994897Sopenharmony_ci  movi v0, -1
70b1994897Sopenharmony_ci  jne v0, exit_error_1
71b1994897Sopenharmony_ci  movi v0, -2
72b1994897Sopenharmony_ci  call.short neg_ashr_i32, v0, v0
73b1994897Sopenharmony_ci  movi v0, 1
74b1994897Sopenharmony_ci  jne v0, exit_error_2
75b1994897Sopenharmony_ci  movi.64 v0, -1
76b1994897Sopenharmony_ci  call.short neg_shl_i64, v0, v0
77b1994897Sopenharmony_ci  movi.64 v0, 0x40000000000
78b1994897Sopenharmony_ci  cmp.64 v0
79b1994897Sopenharmony_ci  jnez exit_error_3
80b1994897Sopenharmony_ci  movi.64 v0, 0x40000000000
81b1994897Sopenharmony_ci  call.short neg_shr_i64, v0, v0
82b1994897Sopenharmony_ci  movi.64 v0, -1
83b1994897Sopenharmony_ci  cmp.64 v0
84b1994897Sopenharmony_ci  jnez exit_error_4
85b1994897Sopenharmony_ci  movi.64 v0, -2
86b1994897Sopenharmony_ci  call.short neg_ashr_i64, v0, v0
87b1994897Sopenharmony_ci  movi.64 v0, 1
88b1994897Sopenharmony_ci  cmp.64 v0
89b1994897Sopenharmony_ci  jnez exit_error_5
90b1994897Sopenharmony_ci  ldai 0
91b1994897Sopenharmony_ci  return
92b1994897Sopenharmony_ciexit_error_0:
93b1994897Sopenharmony_ci  ldai 1
94b1994897Sopenharmony_ci  return
95b1994897Sopenharmony_ciexit_error_1:
96b1994897Sopenharmony_ci  ldai 2
97b1994897Sopenharmony_ci  return
98b1994897Sopenharmony_ciexit_error_2:
99b1994897Sopenharmony_ci  ldai 3
100b1994897Sopenharmony_ci  return
101b1994897Sopenharmony_ciexit_error_3:
102b1994897Sopenharmony_ci  ldai 4
103b1994897Sopenharmony_ci  return
104b1994897Sopenharmony_ciexit_error_4:
105b1994897Sopenharmony_ci  ldai 5
106b1994897Sopenharmony_ci  return
107b1994897Sopenharmony_ciexit_error_5:
108b1994897Sopenharmony_ci  ldai 6
109b1994897Sopenharmony_ci  return
110b1994897Sopenharmony_ci}
111