• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 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# - (a * b)
15.function i32 mneg_i32_0(i32 a0, i32 a1) {
16    mul a0, a1
17    neg
18    return
19}
20
21# (-a) * b
22.function i32 mneg_i32_1(i32 a0, i32 a1) {
23    lda a0
24    neg
25    mul2 a1
26    return
27}
28
29# - (a * b)
30.function i64 mneg_i64_0(i64 a0, i64 a1) {
31    lda.64 a0
32    mul2.64 a1
33    neg.64
34    return.64
35}
36
37# (-a) * b
38.function i64 mneg_i64_1(i64 a0, i64 a1) {
39    lda.64 a0
40    neg.64
41    mul2.64 a1
42    return.64
43}
44
45# (a * b)
46.function f64 mneg_f64_0(f64 a0, f64 a1) {
47    lda.64 a0
48    fmul2.64 a1
49    fneg.64
50    return.64
51}
52
53# (-a) * b
54.function f64 mneg_f64_1(f64 a0, f64 a1) {
55    lda.64 a0
56    fneg.64
57    fmul2.64 a1
58    return.64
59}
60
61.function u1 main() {
62    movi v0, 10
63    movi v1, 12
64    call.short mneg_i32_0, v0, v1
65    sta v0
66    ldai -120
67    jne v0, exit_error_0
68    movi v0, 10
69    movi v1, 12
70    call.short mneg_i32_1, v0, v1
71    sta v0
72    ldai -120
73    jne v0, exit_error_1
74    movi.64 v0, 1
75    movi.64 v1, 2
76    call.short mneg_i64_0, v0, v1
77    sta.64 v0
78    ldai.64 -2
79    cmp.64 v0
80    jnez exit_error_2
81    movi.64 v0, 1
82    movi.64 v1, 2
83    call.short mneg_i64_1, v0, v1
84    sta.64 v0
85    ldai.64 -2
86    cmp.64 v0
87    jnez exit_error_3
88    fmovi.64 v0, 0.5
89    fmovi.64 v1, 1.0
90    call.short mneg_f64_0, v0, v1
91    fmovi.64 v0, -0.5
92    fcmpl.64 v0
93    jnez exit_error_4
94    fmovi.64 v0, 0.5
95    fmovi.64 v1, 1.0
96    call.short mneg_f64_1, v0, v1
97    fmovi.64 v0, -0.5
98    fcmpl.64 v0
99    jnez exit_error_5
100    ldai 0
101    return
102exit_error_0:
103    ldai 1
104    return
105exit_error_1:
106    ldai 2
107    return
108exit_error_2:
109    ldai 3
110    return
111exit_error_3:
112    ldai 4
113    return
114exit_error_4:
115    ldai 5
116    return
117exit_error_5:
118    ldai 6
119    return
120}
121