# Copyright (c) 2021-2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Checked tests for ConstArray. # #! CHECKER Split ConstArray #! RUN force_jit: true, options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=2", entry: "_GLOBAL::main" #! EVENT /Compilation,.*main.*/ #! METHOD "_GLOBAL::main" #! PASS_AFTER "IrBuilder" #! INST "LoadConstArray" #! INST_NEXT "NewArray" #! INST_NEXT "FillConstArray" #! INST_NOT "StoreArray" #! CHECKER Fill ConstArray #! RUN force_jit: true, options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=4", entry: "_GLOBAL::main" #! EVENT /Compilation,.*main.*/ #! METHOD "_GLOBAL::main" #! PASS_AFTER "IrBuilder" #! INST "NewArray" #! INST_NEXT "StoreArray" #! INST_NOT "FillConstArray" #! INST_NOT "LoadConstArray" #! CHECKER Split ConstArray AOT #! RUN_PAOC options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=2" #! RUN entry: "_GLOBAL::main" #! CHECKER Fill ConstArray AOT #! RUN_PAOC options: "--compiler-regex=_GLOBAL::main --compiler-unfold-const-array-max-size=4" #! RUN entry: "_GLOBAL::main" .record panda.String .array array0 panda.String 3 { "a" "ab" "abc"} .array array1 u1 3 { 0 1 0} .array array2 i32 3 { 2 3 4} .array array3 f32 3 { 5.0 6.0 7.0 } .function i32 main() { lda.const v0, array0 lda.const v1, array1 lda.const v2, array2 lda.const v3, array3 ldai 0x0 ldarru.8 v1 movi v5, 0x0 jne v5, loop_error_1 ldai 0x1 ldarru.8 v1 movi v5, 0x1 jne v5, loop_error_2 ldai 0x2 ldarru.8 v1 movi v5, 0x0 jne v5, loop_error_3 ldai 0x0 ldarr v2 movi v5, 0x2 jne v5, loop_error_4 ldai 0x1 ldarr v2 movi v5, 0x3 jne v5, loop_error_5 ldai 0x2 ldarr v2 movi v5, 0x4 jne v5, loop_error_6 ldai 0x0 fldarr.32 v3 fmovi v5, 5.0 fsub2 v5 sta v5 call.short abs, v5, v5 sta v5 fldai 1e-6 fcmpl v5 jlez loop_error_7 ldai 0x1 fldarr.32 v3 fmovi v5, 6.0 fsub2 v5 sta v5 call.short abs, v5, v5 sta v5 fldai 1e-6 fcmpl v5 jlez loop_error_8 ldai 0x2 fldarr.32 v3 fmovi v5, 7.0 fsub2 v5 sta v5 call.short abs, v5, v5 sta v5 fldai 1e-6 fcmpl v5 jlez loop_error_9 ldai 0x0 return loop_error_1: ldai 0x1 return loop_error_2: ldai 0x2 return loop_error_3: ldai 0x3 return loop_error_4: ldai 0x4 return loop_error_5: ldai 0x5 return loop_error_6: ldai 0x6 return loop_error_7: ldai 0x7 return loop_error_8: ldai 0x8 return loop_error_9: ldai 0x9 return } .function f32 abs(f32 a0){ fldai 0.0 fcmpl a0 jlez label lda a0 fneg return label: lda a0 return }