• 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 copies 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#       If element size is smaller then 32 bits, it will be zero or sign extended (depending on bytecode)
21#       to i32.
22#     properties:
23#       - acc_read
24#       - acc_write
25#     pseudo: |
26#       if vs == null then
27#         throw NullPointerException
28#       end
29#       if acc < 0 || acc >= len(vs) then
30#         throw ArrayIndexOutOfBoundsException
31#       end
32#       if op == fldarr.32 then
33#         acc = f32tof64(vs[acc])
34#       else if op == ldarr.8 then
35#         acc = i8toi32(vs[acc])
36#       else if op == ldarru.8 then
37#         acc = u8toi32(vs[acc])
38#       else if op == ldarr.16 then
39#         acc = i16toi32(vs[acc])
40#       else if op == ldarru.16 then
41#         acc = u16toi32(vs[acc])
42#       else
43#         acc = vs[acc]
44#       end
45#     instructions:
46#       - sig: ldarru.8 vs
47#         format: [op_vs_8]
48#         type: obj
49#         dtype: i32
50#         etype: u8
51
52# assert that operation ldarru.8 works fine
53.function i32 main() {
54    movi v0, 10
55    newarr v1, v0, u8[]
56    movi v2, 0
57    ldai 250
58    starr.8 v1, v2
59    ldai 0
60    ldarru.8 v1
61    u32toi64
62    sta.64 v0
63    ldai.64 250
64    cmp.64 v0
65    jnez exit_failure
66    ldai 0
67    return
68exit_failure:
69    ldai 1
70    return
71}
72