• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 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: "modu2.64"
17    isa:
18      title: Two address integer division and modulo on accumulator
19      description: >
20        Perform integer division or modulo on accumulator and register and store result into accumulator
21      exceptions:
22        - x_arith
23    commands:
24      - file-name: "op_vs_8_zero"
25        isa:
26          instructions:
27            - sig: modu2.64 v:in:u64
28              acc: inout:u64
29              prefix: unsigned
30              format: [pref_op_v_8]
31        code-template: |
32          #
33              ldai.64 0
34              movi.64 v0, %s
35              modu2.64 v0
36              movi.64 v0, 0
37              ucmp.64 v0
38        description: Check modu2.64 with zero and various values.
39        cases:
40          - values:
41              - "0"
42            runner-options: ['run-failure']
43            description: Division by zero causes to exception.
44          - values:
45              - "1"
46          - values:
47              - "-1"
48          - values:
49              - "0x7FFFFFFFFFFFFFFF"
50          - values:
51              - "0x8000000000000000"
52          - values:
53              - "-0x7FFFFFFFFFFFFFFF"
54          - values:
55              - "-0x8000000000000000"
56          - values:
57              - "0xFFFFFFFFFFFFFFFF"
58          - values:
59              - "-0xFFFFFFFFFFFFFFFF"
60
61      - file-name: "op_vs_8_pone"
62        isa:
63          instructions:
64            - sig: modu2.64 v:in:u64
65              acc: inout:u64
66              prefix: unsigned
67              format: [pref_op_v_8]
68        code-template: |
69          #
70              ldai.64 1
71              movi.64 v0, %s
72              modu2.64 v0
73              movi.64 v0, %s
74              ucmp.64 v0
75        description: Check modu2.64 with +1 and various values.
76        cases:
77          - values:
78              - "0"
79              - "0"
80            runner-options: ['run-failure']
81            description: Division by zero causes to exception.
82          - values:
83              - "1"
84              - "0"
85          - values:
86              - "-1"
87              - "1"
88          - values:
89              - "0x7FFFFFFFFFFFFFFF"
90              - "1"
91          - values:
92              - "0x8000000000000000"
93              - "1"
94          - values:
95              - "-0x7FFFFFFFFFFFFFFF"
96              - "1"
97          - values:
98              - "-0x8000000000000000"
99              - "1"
100          - values:
101              - "0xFFFFFFFFFFFFFFFF"
102              - "1"
103          - values:
104              - "-0xFFFFFFFFFFFFFFFF"
105              - "0"
106
107      - file-name: "op_vs_8_none"
108        isa:
109          instructions:
110            - sig: modu2.64 v:in:u64
111              acc: inout:u64
112              prefix: unsigned
113              format: [pref_op_v_8]
114        code-template: |
115          #
116              ldai.64 -1
117              movi.64 v0, %s
118              modu2.64 v0
119              movi.64 v0, %s
120              ucmp.64 v0
121        description: Check modu2.64 with -1 and various values.
122        cases:
123          - values:
124              - "0"
125              - "0"
126            runner-options: ['run-failure']
127            description: Division by zero causes to exception.
128          - values:
129              - "1"
130              - "0"
131          - values:
132              - "-1"
133              - "0"
134          - values:
135              - "0x7FFFFFFFFFFFFFFF"
136              - "1"
137          - values:
138              - "0x8000000000000000"
139              - "0x7FFFFFFFFFFFFFFF"
140          - values:
141              - "-0x7FFFFFFFFFFFFFFF"
142              - "0x7FFFFFFFFFFFFFFE"
143          - values:
144              - "-0x8000000000000000"
145              - "0x7FFFFFFFFFFFFFFF"
146          - values:
147              - "0xFFFFFFFFFFFFFFFF"
148              - "0"
149          - values:
150              - "-0xFFFFFFFFFFFFFFFF"
151              - "0"
152
153      - file-name: "op_vs_8_pmax"
154        isa:
155          instructions:
156            - sig: modu2.64 v:in:u64
157              acc: inout:u64
158              prefix: unsigned
159              format: [pref_op_v_8]
160        code-template: |
161          #
162              ldai.64 0x7FFFFFFFFFFFFFFF
163              movi.64 v0, %s
164              modu2.64 v0
165              movi.64 v0, %s
166              ucmp.64 v0
167        description: Check modu2.64 with +max and various values.
168        cases:
169          - values:
170              - "0"
171              - "0"
172            runner-options: ['run-failure']
173            description: Division by zero causes to exception.
174          - values:
175              - "1"
176              - "0"
177          - values:
178              - "-1"
179              - "0x7FFFFFFFFFFFFFFF"
180          - values:
181              - "0x7FFFFFFFFFFFFFFF"
182              - "0"
183          - values:
184              - "0x8000000000000000"
185              - "0x7FFFFFFFFFFFFFFF"
186          - values:
187              - "-0x7FFFFFFFFFFFFFFF"
188              - "0x7FFFFFFFFFFFFFFF"
189          - values:
190              - "-0x8000000000000000"
191              - "0x7FFFFFFFFFFFFFFF"
192          - values:
193              - "0xFFFFFFFFFFFFFFFF"
194              - "0x7FFFFFFFFFFFFFFF"
195          - values:
196              - "-0xFFFFFFFFFFFFFFFF"
197              - "0"
198
199      - file-name: "op_vs_8_nmax"
200        isa:
201          instructions:
202            - sig: modu2.64 v:in:u64
203              acc: inout:u64
204              prefix: unsigned
205              format: [pref_op_v_8]
206        code-template: |
207          #
208              ldai.64 -0x8000000000000000
209              movi.64 v0, %s
210              modu2.64 v0
211              movi.64 v0, %s
212              ucmp.64 v0
213        description: Check modu2.64 with -max and various values.
214        cases:
215          - values:
216              - "0"
217              - "0x0"
218            runner-options: ['run-failure']
219            description: Division by zero causes to exception.
220          - values:
221              - "1"
222              - "0"
223          - values:
224              - "-1"
225              - "0x8000000000000000"
226          - values:
227              - "0x7FFFFFFFFFFFFFFF"
228              - "1"
229          - values:
230              - "0x8000000000000000"
231              - "0"
232          - values:
233              - "-0x7FFFFFFFFFFFFFFF"
234              - "0x8000000000000000"
235          - values:
236              - "-0x8000000000000000"
237              - "0"
238          - values:
239              - "0xFFFFFFFFFFFFFFFF"
240              - "0x8000000000000000"
241          - values:
242              - "-0xFFFFFFFFFFFFFFFF"
243              - "0"
244
245      - file-name: "vals"
246        isa:
247          instructions:
248            - sig: modu2.64 v:in:u64
249              acc: inout:u64
250              prefix: unsigned
251              format: [pref_op_v_8]
252        code-template: |
253          #
254              ldai.64 %s
255              movi.64 v0, %s
256              modu2.64 v0
257              movi.64 v0, %s
258              ucmp.64 v0
259        description: Check modu2.64 with various values.
260        tags: ['tsan']
261        cases:
262          - values:
263              - "0x1213CCFFB4406DDF"
264              - "0xD6A27FEE4"
265              - "0x3BC7EE533"
266          - values:
267              - "0x21550287DC927049"
268              - "0xA5AFC7DEF"
269              - "0x331A7C60"
270          - values:
271              - "0x59BD31BAE32D2792"
272              - "0xE52C66A1B"
273              - "0x9687A5816"
274          - values:
275              - "0x165CBF524AADA63"
276              - "0xFD6519C36"
277              - "0xA7CB07E7"
278          - values:
279              - "0x9DBBD916509AEA83"
280              - "0x25D0724C8"
281              - "0x2304D13AB"
282          - values:
283              - "0xC230F9B763DA2444"
284              - "0x33986D9FB"
285              - "0x318A3501A"
286          - values:
287              - "0x973164C134871573"
288              - "0x905851462"
289              - "0x47D41C843"
290          - values:
291              - "0x5A0AA5BD67CFBC3C"
292              - "0x3A33CFCD0"
293              - "0x2DCFCC2C"
294          - values:
295              - "0x9E96E63C41A2EC6B"
296              - "0x80B21D9B0"
297              - "0x29A605FAB"
298          - values:
299              - "0x47B214A1354D2806"
300              - "0x965F36821"
301              - "0x557F2C6A4"
302
303      - file-name: "op_v_8_exception"
304        isa:
305          instructions:
306            - sig: modu2.64 v:in:u64
307              acc: inout:u64
308              prefix: unsigned
309              format: [pref_op_v_8]
310        header-template: [ArithmeticException, main]
311        code-template: |
312            #
313                ldai.64 %s
314                movi.64 v0, 0
315            begin:
316                modu2.64 v0
317            end:
318                ldai 1 # Should not reach this line
319                return
320
321            catch_AE:
322                ldai 0 # Expected panda.ArithmeticException
323                return
324
325            catch_all:
326                ldai 1 # Unexpected exception, test failed
327                return
328
329            .catch panda.ArithmeticException, begin, end, catch_AE
330            .catchall begin, end, catch_all
331        check-type: none
332        description: Check `modu2.64` throws ArithmeticException when divides by zero.
333        cases:
334          - values: ["0"]
335          - values: ["1"]
336          - values: ["0x7FFFFFFF"]
337          - values: ["0x80000000"]
338          - values: ["0xFFFFFFFF"]
339          - values: ["0x100000000"]
340          - values: ["0x7FFFFFFFFFFFFFFF"]
341          - values: ["0x8000000000000000"]
342          - values: ["0xFFFFFFFFFFFFFFFF"]
343          - values: ["-1"]
344          - values: ["-0x7FFFFFFF"]
345          - values: ["-0x80000000"]
346          - values: ["-0xFFFFFFFF"]
347          - values: ["-0x100000000"]
348          - values: ["-0x7FFFFFFFFFFFFFFF"]
349          - values: ["-0x8000000000000000"]
350          - values: ["-0xFFFFFFFFFFFFFFFF"]
351
352      - file-name: "regs"
353        isa:
354          instructions:
355            - sig: modu2.64 v:in:u64
356              acc: inout:u64
357              prefix: unsigned
358              format: [pref_op_v_8]
359        runner-options: ['compile-only']
360        code-template: |
361          #
362              modu2.64 %s
363        check-type: none
364        description: Check modu2.64 with various register numbers.
365        cases:
366          - values:
367              - "v255"
368          - values:
369              - "v256"
370            runner-options: ['compile-failure']
371
372      - file-name: "type"
373        isa:
374          instructions:
375            - sig: modu2.64 v:in:u64
376              acc: inout:u64
377              prefix: unsigned
378              format: [pref_op_v_8]
379          verification:
380            - acc_type
381            - v1_type
382        tags: ['verifier']
383        runner-options: ['verifier-failure', 'verifier-debug-config']
384        code-template: |
385          #
386              %s
387              %s
388              modu2.64 v0
389              ldai.64 0
390        check-type: no-check
391        description: Check modu2.64 with incorrect accumulator and register type.
392        cases:
393          - values:
394              - "lda.null"
395              - "movi.64 v0, 0"
396          - values:
397              - "ldai.64 0 "
398              - "mov.null v0"
399          - values:
400              - "lda.null"
401              - "mov.null v0"
402