• 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#
15# Checked tests for ConstArray.
16#
17
18#! CHECKER      Split ConstArray
19#! RUN          force_jit: true, options: "--compiler-regex=_GLOBAL::main  --compiler-unfold-const-array-max-size=2", entry: "_GLOBAL::main"
20#! EVENT        /Compilation,.*main.*/
21#! METHOD       "_GLOBAL::main"
22#! PASS_AFTER   "IrBuilder"
23#! INST         "LoadConstArray"
24#! INST_NEXT    "NewArray"
25#! INST_NEXT    "FillConstArray"
26#! INST_NOT     "StoreArray"
27
28#! CHECKER      Fill ConstArray
29#! RUN          force_jit: true, options: "--compiler-regex=_GLOBAL::main  --compiler-unfold-const-array-max-size=4", entry: "_GLOBAL::main"
30#! EVENT        /Compilation,.*main.*/
31#! METHOD       "_GLOBAL::main"
32#! PASS_AFTER   "IrBuilder"
33#! INST         "NewArray"
34#! INST_NEXT    "StoreArray"
35#! INST_NOT     "FillConstArray"
36#! INST_NOT     "LoadConstArray"
37
38#! CHECKER      Split ConstArray AOT
39#! RUN_PAOC     options: "--compiler-regex=_GLOBAL::main  --compiler-unfold-const-array-max-size=2"
40#! RUN          entry: "_GLOBAL::main"
41
42#! CHECKER      Fill ConstArray AOT
43#! RUN_PAOC     options: "--compiler-regex=_GLOBAL::main  --compiler-unfold-const-array-max-size=4"
44#! RUN          entry: "_GLOBAL::main"
45
46.record panda.String <external>
47
48.array array0 panda.String 3 { "a" "ab" "abc"}
49.array array1 u1 3 { 0 1 0}
50.array array2 i32 3 { 2 3 4}
51.array array3 f32 3 { 5.0 6.0 7.0 }
52
53.function i32 main() {
54    lda.const v0, array0
55    lda.const v1, array1
56    lda.const v2, array2
57    lda.const v3, array3
58    ldai 0x0
59    ldarru.8 v1
60    movi v5, 0x0
61    jne v5, loop_error_1
62    ldai 0x1
63    ldarru.8 v1
64    movi v5, 0x1
65    jne v5, loop_error_2
66    ldai 0x2
67    ldarru.8 v1
68    movi v5, 0x0
69    jne v5, loop_error_3
70    ldai 0x0
71    ldarr v2
72    movi v5, 0x2
73    jne v5, loop_error_4
74    ldai 0x1
75    ldarr v2
76    movi v5, 0x3
77    jne v5, loop_error_5
78    ldai 0x2
79    ldarr v2
80    movi v5, 0x4
81    jne v5, loop_error_6
82    ldai 0x0
83    fldarr.32 v3
84    fmovi v5, 5.0
85    fsub2 v5
86    sta v5
87    call.short abs, v5, v5
88    sta v5
89    fldai 1e-6
90    fcmpl v5
91    jlez loop_error_7
92    ldai 0x1
93    fldarr.32 v3
94    fmovi v5, 6.0
95    fsub2 v5
96    sta v5
97    call.short abs, v5, v5
98    sta v5
99    fldai 1e-6
100    fcmpl v5
101    jlez loop_error_8
102    ldai 0x2
103    fldarr.32 v3
104    fmovi v5, 7.0
105    fsub2 v5
106    sta v5
107    call.short abs, v5, v5
108    sta v5
109    fldai 1e-6
110    fcmpl v5
111    jlez loop_error_9
112    ldai 0x0
113    return
114loop_error_1:
115    ldai 0x1
116    return
117loop_error_2:
118    ldai 0x2
119    return
120loop_error_3:
121    ldai 0x3
122    return
123loop_error_4:
124    ldai 0x4
125    return
126loop_error_5:
127    ldai 0x5
128    return
129loop_error_6:
130    ldai 0x6
131    return
132loop_error_7:
133    ldai 0x7
134    return
135loop_error_8:
136    ldai 0x8
137    return
138loop_error_9:
139    ldai 0x9
140    return
141}
142
143.function f32 abs(f32 a0){
144    fldai 0.0
145    fcmpl a0
146    jlez label
147    lda a0
148    fneg
149    return
150label:
151    lda a0
152    return
153}