• 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: "u32tou8"
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 unsigned integer, the value is zero-extended to destination type.
22      exceptions:
23        - x_none
24    commands:
25      - file-name: "op_none"
26        isa:
27          instructions:
28            - sig: u32tou8
29              acc: inout:u32->u8
30              prefix: cast
31              format: [pref_op_none]
32        code-template: |
33          #
34              ldai %s
35              u32tou8
36              movi v0, %s
37              ucmp v0
38        description: Check u32tou8 with various values.
39        tags: ['tsan', 'irtoc_ignore']
40        cases:
41          - values:
42              - "0"
43              - "0"
44          - values:
45              - "0xffffffff"
46              - "0xff"
47          - values:
48              - "0x12345678"
49              - "0x78"
50          - values:
51              - "4294967295"
52              - "0xff"
53      - file-name: "type"
54        isa:
55          instructions:
56            - sig: u32tou8
57              acc: inout:u32->u8
58              prefix: cast
59              format: [pref_op_none]
60          verification:
61              - acc_type
62        bugid: ["964", "1653"]
63        tags: ["verifier"]
64        description: |
65          Check `u32tou8` with incorrect accumulator type.
66          Load different values (objects, strings, types, 64-bit floating point values, 64-bit integer values) and invokes `u32tou8`.
67          Return 0 to indicate that negative test failed, because this line is unreachable and code will not be executed after verification error.
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                u32tou8
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: u32tou8
109              acc: inout:u32->u8
110              prefix: cast
111              format: [pref_op_none]
112        description: Check 'u32tou8' with uninitialized accumulator.
113        tags: ['verifier']
114        runner-options: ['verifier-failure', 'verifier-config']
115        code-template: |
116            #
117                u32tou8
118        check-type: exit-positive
119