• 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
14definitions: []
15tests:
16  - file-name: "i32tou8"
17    isa:
18      title: Integer truncations and extensions.
19      description: >
20        Perform specified integer extension or truncations of accumulator.
21        If extension bytecode treats its source as signed integer, the value is sign-extended to destination type.
22      exceptions:
23        - x_none
24    commands:
25      - file-name: "op_none"
26        isa:
27          instructions:
28            - sig: i32tou8
29              acc: inout:i32->u8
30              prefix: cast
31              format: [pref_op_none]
32        code-template: |
33          #
34              ldai %s
35              i32tou8
36              movi v0, %s
37              ucmp v0
38        description: Check i32tou8 with various values.
39        tags: ['tsan']
40        cases:
41          - values: ["0", "0"]
42          - values: ["1", "1"]
43          - values: ["-1", "0x00000000000000FF"]
44          - values: ["0x7FFFFFFF", "0x00000000000000FF"]
45          - values: ["-0x7FFFFFFF", "1"]
46          - values: ["0x80000000", "0"]
47          - values: ["-0x80000000", "0"]
48          - values: ["0xFFFFFFFF", "0x00000000000000FF"]
49          - values: ["-0xFFFFFFFF", "1"]
50          - values: ["0xf0f0f0f0", "0x00000000000000F0"]
51          - values: ["0x7f0f0f0f", "0x000000000000000F"]
52
53      - file-name: "type"
54        isa:
55          instructions:
56            - sig: i32tou8
57              acc: inout:i32->u8
58              prefix: cast
59              format: [pref_op_none]
60          verification:
61              - acc_type
62        description: |
63          Check `i32tou8` with incorrect accumulator type.
64          Load different values (objects, strings, types, 64-bit floating point values, 64-bit integer values) and invokes `i32tou8`.
65          Return 0 to indicate that negative test failed, because this line is unreachable and code will not be executed after verification error.
66        bugid: ["964", "1653"]
67        tags: ["verifier"]
68        runner-options: ['verifier-failure', 'verifier-config']
69        header-template: []
70        code-template: |
71            #
72            .record B {}
73            .record panda.String <external>
74            .record panda.Object <external>
75            .function i32 main() {
76                %s
77                i32tou8
78        check-type: exit-positive
79        cases:
80            - values:
81                - ldai.64 0
82            - values:
83                - fldai 0
84            - values:
85                - fldai.64 0
86            - values:
87                - lda.type B
88            - values:
89                - lda.type B[]
90            - values:
91                - lda.type panda.String
92            - values:
93                - lda.str "string"
94            - values:
95                - lda.type panda.Object
96            - values:
97                - |
98                  #
99                      movi v0, 10
100                      newarr v0, v0, i32[]
101                      lda.obj v0
102            - values:
103                - lda.null
104
105      - file-name: uninitialized_regs
106        isa:
107          instructions:
108            - sig: i32tou8
109              acc: inout:i32->u8
110              prefix: cast
111              format: [pref_op_none]
112        description: Check 'i32tou8' with uninitialized accumulator.
113        tags: ['verifier']
114        runner-options: ['verifier-failure', 'verifier-config']
115        code-template: |
116            #
117                i32tou8
118        check-type: exit-positive
119