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: "fmovi"
17    isa:
18      title: Move immediate-to-register
19      description: >
20        Move integer immediate into a register. For short formats immediate is sign extended to operand size.
21      exceptions:
22        - x_none
23      verification:
24        - none
25    commands:
26      - file-name: "imm_p"
27        isa:
28          instructions:
29            - sig: fmovi v:out:f32, imm:f32
30              acc: none
31              prefix: f32
32              format: [pref_op_v_8_imm_32]
33        check-type: no-check
34        code-template: |
35          #
36              fldai %s
37              fmovi v0, %s
38              fcmpg v0
39        description: Check fmovi with various positive values (f32 values, HEX literals).
40        tags: ['tsan', 'irtoc_ignore']
41        cases:
42          - values:
43              - "0.0"
44              - "0.0"
45          - values:
46              - "0.1"
47              - "0.1"
48          - values:
49              - "1.0"
50              - "1"
51          - values:
52              - "12345678.90987654"
53              - "12345678.90987654"
54          - values:
55              - "3.141592653589793"
56              - "3.141592653589793"
57          - values:
58              - "3.1415e+003"
59              - "0x45445800"
60          - values:
61              - "1.797693134862315e308"
62              - "0x7f800000"
63          - values:
64              - "1.401298464324817e-45"
65              - "0x00000001"
66          - values:
67              - "3.402823466385288e+38"
68              - "0x7f7fffff"
69          - values:
70              - "0x12345678"
71              - "5.690456613903523e-28"
72          - values:
73              - "0"
74              - "0x00000000"
75          - values:
76              - "1"
77              - "0x3f800000"
78          - values:
79              - "9223372036854775807"
80              - "0x5f000000"
81          - values:
82              - "0.55"
83              - "0x3f0ccccd"
84
85
86      - file-name: "imm_n"
87        isa:
88          instructions:
89            - sig: fmovi v:out:f32, imm:f32
90              acc: none
91              prefix: f32
92              format: [pref_op_v_8_imm_32]
93        tags: ['irtoc_ignore']
94        code-template: |
95          #   test - check binary representation of FP literals
96              fmovi v0, %s
97              fldai %s
98              fcmpg v0
99        description: Check fmovi with various negative values (f32 values, HEX literals).
100        check-type: no-check
101        cases:
102          - values:
103              - "-0"
104              - "0x80000000"
105          - values:
106              - "-0.0"
107              - "0x80000000"
108          - values:
109              - "-0x0"
110              - "0x80000000"
111          - values:
112              - "-1"
113              - "0xbf800000"
114          - values:
115              - "-1.0"
116              - "0xbf800000"
117          - values:
118              - "-0x1"
119              - "0xbf800000"
120          - values:
121              - "-0x7FFFFFFF"
122              - "0xcf000000"
123          - values:
124              - "-0.1"
125              - "0xbdcccccd"
126          - values:
127              - "-12345678.90987654"
128              - "0xcb3c614f"
129          - values:
130              - "-3.141592653589793"
131              - "0xc0490fdb"
132          - values:
133              - "-1.40129846432481e-45"
134              - "0x80000001"
135          - values:
136              - "-3.40282346638528e+38"
137              - "0xff7fffff"
138          - values:
139              - "-0.55"
140              - "0xbf0ccccd"
141
142
143      - file-name: "err"
144        isa:
145          instructions:
146            - sig: fmovi v:out:f32, imm:f32
147              acc: none
148              prefix: f32
149              format: [pref_op_v_8_imm_32]
150        code-template: |
151          #
152          .record panda.Object <external>
153          .function i32 main() {
154              fmovi %s
155        check-type: exit-positive
156        header-template: []
157        runner-options: [compile-failure]
158        description: Check fmovi with various incorrect f32 literals.
159        cases:
160          - values:
161              - ''
162          - values:
163              - a0, 0.1
164          - values:
165              - v0, 1e
166          - values:
167              - v0, -1e
168          - values:
169              - v0, 1e1e1
170          - values:
171              - v0, -1e1e1
172          - values:
173              - v0, "1.0"
174          - values:
175              - v0, panda.Object
176          - values:
177              - v0, 1.1, v2
178          - values:
179              - v256, 1.1
180          - values:
181              - v32767, 0.0
182          - values:
183              - v65535, 0.0
184
185
186      - file-name: "range"
187        isa:
188          instructions:
189            - sig: fmovi v:out:f32, imm:f32
190              acc: none
191              prefix: f32
192              format: [pref_op_v_8_imm_32]
193        code-template: |
194          #
195              fmovi v0, %s
196        check-type: exit-positive
197        runner-options: [compile-only]
198        cases:
199          - values:
200              - "+2e-324"
201          - values:
202              - "-2e-324"
203          - values:
204              - "1.8e328"
205            bugid: ["1132"]
206          - values:
207              - "-1.8e328"
208            bugid: ["1132"]
209
210
211      - file-name: "range_val"
212        isa:
213          instructions:
214            - sig: fmovi v:out:f32, imm:f32
215              acc: none
216              prefix: f32
217              format: [pref_op_v_8_imm_32]
218        check-type: no-check
219        tags: ['irtoc_ignore']
220        code-template: |
221          #   test - check binary representation of FP literals
222              fmovi v0, %s
223              fldai %s
224              fcmpg v0
225        cases:
226          - values:
227              - "+2e-46"
228              - "0"
229          - values:
230              - "-2e-46"
231              - "-0.0"
232          - values:
233              - "1.8e46"
234              - "0x7f800000"
235            bugid: ["1132"]
236          - values:
237              - "-1.8e46"
238              - "0xff800000"
239            bugid: ["1132"]
240
241
242      - file-name: "vd_8"
243        isa:
244          instructions:
245            - sig: fmovi v:out:f32, imm:f32
246              acc: none
247              prefix: f32
248              format: [pref_op_v_8_imm_32]
249        tags: ['irtoc_ignore']
250        check-type: no-check
251        code-template: |
252          #
253              fldai 1
254              fmovi %s, 1
255              fcmpl %s
256        cases:
257          - values:
258              - v1
259              - v1
260          - values:
261              - v15
262              - v15
263          - values:
264              - v16
265              - v16
266          - values:
267              - v255
268              - v255
269