• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 neg_shl_i32(i32 a0) {
15  movi v0, 21
16  lda a0
17  shl2 v0
18  neg
19  return
20}
21
22.function i32 neg_shr_i32(i32 a0) {
23  movi v0, 21
24  lda a0
25  shr2 v0
26  neg
27  return
28}
29
30.function i32 neg_ashr_i32(i32 a0) {
31  movi v0, 21
32  lda a0
33  ashr2 v0
34  neg
35  return
36}
37
38.function i64 neg_shl_i64(i64 a0) {
39  movi.64 v0, 42
40  lda.64 a0
41  shl2.64 v0
42  neg.64
43  return.64
44}
45
46.function i64 neg_shr_i64(i64 a0) {
47  movi.64 v0, 42
48  lda.64 a0
49  shr2.64 v0
50  neg.64
51  return.64
52}
53
54.function i64 neg_ashr_i64(i64 a0) {
55  movi.64 v0, 42
56  lda.64 a0
57  ashr2.64 v0
58  neg.64
59  return.64
60}
61
62.function i32 main() {
63  movi v0, -1
64  call.short neg_shl_i32, v0, v0
65  movi v0, 0x200000
66  jne v0, exit_error_0
67  movi v0, 0x200000
68  call.short neg_shr_i32, v0, v0
69  movi v0, -1
70  jne v0, exit_error_1
71  movi v0, -2
72  call.short neg_ashr_i32, v0, v0
73  movi v0, 1
74  jne v0, exit_error_2
75  movi.64 v0, -1
76  call.short neg_shl_i64, v0, v0
77  movi.64 v0, 0x40000000000
78  cmp.64 v0
79  jnez exit_error_3
80  movi.64 v0, 0x40000000000
81  call.short neg_shr_i64, v0, v0
82  movi.64 v0, -1
83  cmp.64 v0
84  jnez exit_error_4
85  movi.64 v0, -2
86  call.short neg_ashr_i64, v0, v0
87  movi.64 v0, 1
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