• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2024 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 maddv_i32(i32 a0, i32 a1, i32 a2) {
16    mulv a0, a1
17    addv a0, a2
18    lda a0
19    return
20}
21
22# a * b + c
23.function i64 maddv_i64(i64 a0, i64 a1, i64 a2) {
24    lda.64 a1
25    mul2v.64 v0, a0
26    lda.64 a2
27    add2v.64 v0, v0
28    lda.64 v0
29    return.64
30}
31
32.function i32 main() {
33    movi v0, 10
34    movi v1, 1000
35    movi v2, -56
36    call maddv_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 maddv_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