• 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# The following comment until the empty line must be a valid YAML document
15# containing exact copy of ISA specification assertions relevant to this test.
16#---
17#   - title: Load from array
18#     description: >
19#       Load an element from array using accumulator as an index and puts it into accumulator.
20#     instructions:
21#       - sig: fldarr.64 vs
22#         format: [op_vs_8]
23#         type: obj
24#         dtype: f64
25#         etype: f64
26#         properties: [acc_read, acc_write, float]
27#   - title: Store to array
28#     description: >
29#       Store accumulator content into array slot pointed by index.
30#     instructions:
31#       - sig: fstarr.64 vs1, vs2
32#         format: [op_vs1_4_vs2_4]
33#         type: f64
34#         dtype: none
35#         etype: f64
36#         properties: [acc_read, float]
37
38#assert that operations with array of f64 works fine
39#i64 i;
40#for(i=0; i<7; i++) array[i]=(double)i;
41#for(i=6; i>=0; i--) assert_eq((double)i, array[i]);
42
43.function i32 main(){
44    movi v0, 7
45    newarr v1, v0, f64[]
46    movi v2, 0
47    ldai 0
48loop:
49    jeq v0, loop_exit
50    i32tof64
51    fstarr.64 v1, v2
52    inci v2, 1
53    lda v2
54    jmp loop
55loop_exit:
56    subi 1
57    sta v2
58loop2:
59    jltz loop2_exit
60    lda v2
61    i32tof64
62    sta.64 v3
63    lda v2
64    fldarr.64 v1
65    fsub2.64 v3
66    sta.64 v3
67    call.short abs, v3, v3
68    sta.64 v3
69    fldai.64 1e-13
70    fcmpl.64 v3
71    jlez exit_failure
72    inci v2, -1
73    lda v2
74    jmp loop2
75loop2_exit:
76    ldai 0
77    return
78exit_failure:
79    ldai 1
80    return
81}
82
83.function f64 abs(f64 a0){
84    fldai.64 0.0
85    fcmpl.64 a0
86    jlez label
87    lda.64 a0
88    fneg.64
89    return.64
90label:
91    lda.64 a0
92    return.64
93}
94
95