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 xor_not_i32(i32 a0, i32 a1) <static> {
15b1994897Sopenharmony_ci    ldai -1
16b1994897Sopenharmony_ci    xor2 a0
17b1994897Sopenharmony_ci    xor2 a1
18b1994897Sopenharmony_ci    return
19b1994897Sopenharmony_ci}
20b1994897Sopenharmony_ci
21b1994897Sopenharmony_ci.function i64 xor_not_i64(i64 a0, i64 a1) <static> {
22b1994897Sopenharmony_ci    ldai.64 -1
23b1994897Sopenharmony_ci    xor2.64 a0
24b1994897Sopenharmony_ci    xor2.64 a1
25b1994897Sopenharmony_ci    return.64
26b1994897Sopenharmony_ci}
27b1994897Sopenharmony_ci
28b1994897Sopenharmony_ci.function i32 and_not_i32(i32 a0, i32 a1) <static> {
29b1994897Sopenharmony_ci    ldai -1
30b1994897Sopenharmony_ci    xor2 a0
31b1994897Sopenharmony_ci    and2 a1
32b1994897Sopenharmony_ci    return
33b1994897Sopenharmony_ci}
34b1994897Sopenharmony_ci
35b1994897Sopenharmony_ci.function i64 and_not_i64(i64 a0, i64 a1) <static> {
36b1994897Sopenharmony_ci    ldai.64 -1
37b1994897Sopenharmony_ci    xor2.64 a0
38b1994897Sopenharmony_ci    and2.64 a1
39b1994897Sopenharmony_ci    return.64
40b1994897Sopenharmony_ci}
41b1994897Sopenharmony_ci
42b1994897Sopenharmony_ci.function i32 or_not_i32(i32 a0, i32 a1) <static> {
43b1994897Sopenharmony_ci    ldai -1
44b1994897Sopenharmony_ci    xor2 a0
45b1994897Sopenharmony_ci    or2 a1
46b1994897Sopenharmony_ci    return
47b1994897Sopenharmony_ci}
48b1994897Sopenharmony_ci
49b1994897Sopenharmony_ci.function i64 or_not_i64(i64 a0, i64 a1) <static> {
50b1994897Sopenharmony_ci    ldai.64 -1
51b1994897Sopenharmony_ci    xor2.64 a0
52b1994897Sopenharmony_ci    or2.64 a1
53b1994897Sopenharmony_ci    return.64
54b1994897Sopenharmony_ci}
55b1994897Sopenharmony_ci
56b1994897Sopenharmony_ci.function i32 main() {
57b1994897Sopenharmony_ci    movi v0, 0x00ff00ff
58b1994897Sopenharmony_ci    movi v1, 0x00ff00ff
59b1994897Sopenharmony_ci    call.short xor_not_i32, v0, v1
60b1994897Sopenharmony_ci    movi v0, -1
61b1994897Sopenharmony_ci    jne v0, exit_error_0
62b1994897Sopenharmony_ci    movi v0, 0xffff0000
63b1994897Sopenharmony_ci    movi v1, 0x12345678
64b1994897Sopenharmony_ci    call.short and_not_i32, v0, v1
65b1994897Sopenharmony_ci    movi v0, 0x5678
66b1994897Sopenharmony_ci    jne v0, exit_error_1
67b1994897Sopenharmony_ci    movi v0, 0xff00ff00
68b1994897Sopenharmony_ci    movi v1, 0x0ff00ff0
69b1994897Sopenharmony_ci    call.short or_not_i32, v0, v1
70b1994897Sopenharmony_ci    movi v0, 0x0fff0fff
71b1994897Sopenharmony_ci    jne v0, exit_error_2
72b1994897Sopenharmony_ci    movi.64 v0, 0x00ff00ff00ff00ff
73b1994897Sopenharmony_ci    movi.64 v1, 0x00ff00ff00ff00ff
74b1994897Sopenharmony_ci    call.short xor_not_i64, v0, v1
75b1994897Sopenharmony_ci    movi.64 v0, -1
76b1994897Sopenharmony_ci    cmp.64 v0
77b1994897Sopenharmony_ci    jnez exit_error_3
78b1994897Sopenharmony_ci    movi.64 v0, 0xffff0000ffff0000
79b1994897Sopenharmony_ci    movi.64 v1, 0x1234567887654321
80b1994897Sopenharmony_ci    call.short and_not_i64, v0, v1
81b1994897Sopenharmony_ci    movi.64 v0, 0x567800004321
82b1994897Sopenharmony_ci    cmp.64 v0
83b1994897Sopenharmony_ci    jnez exit_error_4
84b1994897Sopenharmony_ci    movi.64 v0, 0xff00ff00ff00ff00
85b1994897Sopenharmony_ci    movi.64 v1, 0x0ff00ff00ff00ff0
86b1994897Sopenharmony_ci    call.short or_not_i64, v0, v1
87b1994897Sopenharmony_ci    movi.64 v0, 0x0fff0fff0fff0fff
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