• 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# a * b + c
15.function i32 madd_i32(i32 a0, i32 a1, i32 a2) {
16    mov v0, a0
17    mov v1, a1
18    mul a0, a1
19    sta v0
20    add v0, a2
21    return
22}
23
24# a * b + c
25.function i64 madd_i64(i64 a0, i64 a1, i64 a2) {
26    lda.64 a1
27    mul2.64 a0
28    add2.64 a2
29    return.64
30}
31
32.function i32 main() {
33    movi v0, 10
34    movi v1, 1000
35    movi v2, -56
36    call madd_i32, v0, v1, v2
37    sta v0
38    ldai 9944
39    jne v0, exit_error_0
40    movi.64 v0, -1
41    movi.64 v1, 123
42    movi.64 v2, 19
43    call madd_i64, v0, v1, v2
44    sta.64 v0
45    ldai.64 -104
46    cmp.64 v0
47    jnez exit_error_1
48    ldai 0
49    return
50exit_error_0:
51    ldai 1
52    return
53exit_error_1:
54    ldai 2
55    return
56}
57