• 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// for (int i = 0; i < a1; ++i) {
15//    a0[i] = i;
16// }
17.function i32 fill(i32[] a0, i32 a1) {
18    movi v0, 0
19    ldai 0
20    starr a0, v0
21    jne a1 , test
22    movi v3, 0
23    jmp end_test
24test:
25    movi v3, 1
26end_test:
27    ldai 0
28loop_head:
29    jge a1, loop_exit
30loop_body:
31    starr a0, v0
32    inci v0, 1
33    lda v0
34    jmp loop_head
35
36loop_exit:
37    lda v3
38    return
39}
40
41.function i32 main(){
42    movi v0, 5    #sizeof(array)
43    newarr v1, v0, i32[]
44
45try_begin:
46    movi v0, 5
47    call.short fill, v1, v0
48try_end:
49
50    ldai 0
51    return
52
53catch_block_begin:
54    ldai 1
55    return
56
57.catchall try_begin, try_end, catch_block_begin
58}
59