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
14definitions: []
15tests:
16  - file-name: ldai
17    isa:
18      title: Load accumulator from immediate
19      description: >
20        Load immediate into accumulator. For short formats immediate is sign extended to operand size.
21      exceptions:
22        - x_none
23      verification:
24        - none
25    commands:
26      - file-name: pos
27        isa:
28          instructions:
29            - sig: ldai imm:i32
30              acc: out:i32
31              format: [op_imm_8, op_imm_16, op_imm_32]
32        description: Check ldai with various positive values.
33        check-type: none
34        code-template: |
35          #
36              ldai %s
37              movi v0, %s
38              jne v0, set_failure
39              ldai 0
40              return
41          set_failure:
42              ldai 1
43              return
44        tags: ['tsan']
45        cases:
46          - values:
47              - '0'
48              - '0'
49          - values:
50              - '1'
51              - '1'
52          - values:
53              - '255'
54              - '255'
55          - values:
56              - '65535'
57              - '0xFFFF'
58          - values:
59              - '0x12345678'
60              - '0x12345678'
61          - values:
62              - '0xFFFFFFFF'
63              - '-1'
64          - values:
65              - '2147483647'
66              - '2147483647'
67          - values:
68              - '2147483648'
69              - '2147483648'
70          - values:
71              - '0.0'
72              - '0'
73            runner-options: [compile-failure]
74            description: Check ldai with incorrect positive values (float).
75          - values:
76              - '1.1'
77              - '1'
78            runner-options: [compile-failure]
79            description: Check ldai with incorrect positive values (float).
80
81      - file-name: neg
82        isa:
83          instructions:
84            - sig: ldai imm:i32
85              acc: out:i32
86              format: [op_imm_8, op_imm_16, op_imm_32]
87        check-type: none
88        code-template: |
89          #
90              ldai %s
91              movi v0, %s
92              jne v0, set_failure
93              ldai 0
94              return
95          set_failure:
96              ldai 1
97              return
98        description: Check ldai with various negative values.
99        cases:
100          - values:
101              - '-0'
102              - '0'
103          - values:
104              - '-1'
105              - '-1'
106          - values:
107              - '-255'
108              - '-255'
109          - values:
110              - '-65535'
111              - '-0xFFFF'
112          - values:
113              - '-0x12345678'
114              - '-0x12345678'
115          - values:
116              - '-0xFFFFFFFF'
117              - '1'
118          - values:
119              - '-2147483647'
120              - '-2147483647'
121          - values:
122              - '-2147483648'
123              - '-2147483648'
124          - values:
125              - '-2147483649'
126              - '0x7FFFFFFF'
127          - values:
128              - '-2147483648'
129              - '0x80000000'
130          - values:
131              - '-0.0'
132              - '0'
133            runner-options: [compile-failure]
134            description: Check ldai with incorrect negative values (float).
135          - values:
136              - '-1.1'
137              - '-1'
138            runner-options: [compile-failure]
139            description: Check ldai with incorrect negative values (float).
140
141