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: lda 17 isa: 18 title: Load accumulator from register 19 description: Moves register content into an accumulator. 20 exceptions: 21 - x_none 22 instructions: 23 - sig: lda v:in:b32 24 acc: out:b32 25 format: [op_v_8] 26 commands: 27 - file-name: op_vd_8 28 description: Check 'lda' moves register content into an accumulator. 29 isa: 30 instructions: 31 - sig: lda v:in:b32 32 acc: out:b32 33 format: [op_v_8] 34 code-template: | 35 # 36 %s 37 ldai 0 38 return 39 err: 40 ldai 1 41 return 42 check-type: none 43 tags: ['tsan'] 44 cases: 45 - values: 46 - "#{[ 47 '0', 48 '1', 49 '0xF', 50 '0xFF', 51 '0xFFF', 52 '0xFFFF', 53 '0xFFFFF', 54 '0xFFFFFF', 55 '0xFFFFFFF', 56 '0xFFFFFFFF', 57 '0x7F', 58 '0x7FF', 59 '0x7FFF', 60 '0x7FFFF', 61 '0x7FFFFF', 62 '0x7FFFFFF', 63 '0x7FFFFFFF', 64 '-1', 65 '-0xF', 66 '-0xFF', 67 '-0xFFF', 68 '-0xFFFF', 69 '-0xFFFFF', 70 '-0xFFFFFF', 71 '-0xFFFFFFF', 72 '-0xFFFFFFFF', 73 '-0x7F', 74 '-0x7FF', 75 '-0x7FFF', 76 '-0x7FFFF', 77 '-0x7FFFFF', 78 '-0x7FFFFFF', 79 '-0x7FFFFFFF' 80 ].map do |s| \" movi v0, #{s}\\n lda v0\\n jne v0, err\\n\" end .join}" 81 82 - file-name: reg 83 isa: 84 instructions: 85 - sig: lda v:in:b32 86 acc: out:b32 87 format: [op_v_8] 88 check-type: none 89 code-template: | 90 # 91 %s 92 ldai 0 93 return 94 err: 95 ldai 1 96 return 97 description: Check 'lda' with valid register numbers. 98 cases: 99 - values: 100 - "#{[*0..255].map do |i| \" movi v#{i}, 0xFEDCBA09\\n lda v#{i}\\n jne v#{i}, err\\n\" end .join}" 101 102 - file-name: reg_err 103 isa: 104 instructions: 105 - sig: lda v:in:b32 106 acc: out:b32 107 format: [op_v_8] 108 check-type: none 109 runner-options: [compile-failure] 110 code-template: | 111 # 112 lda %s 113 ldai 0 114 return 115 description: Check 'lda' with some invalid register numbers. 116 cases: 117 - values: 118 - v256 119 - values: 120 - a0 121 - values: 122 - v32565 123 124 - file-name: type 125 isa: 126 verification: 127 - v1_type 128 description: Check lda with incorrect source register type. Accumulator type is not checked. 129 runner-options: ['verifier-failure', 'verifier-config'] 130 tags: ['verifier'] 131 header-template: [] 132 code-template: | 133 # 134 .record A {} 135 .record B {} 136 .record panda.Object <external> 137 .function i32 main() { 138 *s 139 %s 140 lda v1 141 ldai 0 142 check-type: no-check 143 template-cases: 144 - values: 145 - | 146 # 147 lda.type B 148 - values: 149 - | 150 # 151 lda.type B[] 152 - values: 153 - | 154 # 155 lda.str "string" 156 - values: 157 - | 158 # 159 lda.type panda.Object 160 - values: 161 - | 162 # 163 movi v0, 10 164 newarr v0, v0, i32[] 165 lda.obj v0 166 - values: 167 - lda.null 168 - values: 169 - ldai 0 170 - values: 171 - ldai.64 0 172 - values: 173 - fldai.64 0 174 cases: 175 - values: 176 - | 177 # 178 lda.type A 179 sta.obj v1 180 - values: 181 - | 182 # 183 lda.type A[] 184 sta.obj v1 185 - values: 186 - | 187 # 188 lda.str "string" 189 sta.obj v1 190 - values: 191 - | 192 # 193 lda.type panda.Object 194 sta.obj v1 195 - values: 196 - | 197 # 198 movi v1, 10 199 newarr v1, v1, f64[] 200 - values: 201 - mov.null v1 202 - values: 203 - movi.64 v1, 0 204 - values: 205 - fmovi.64 v1, 0 206 207 - file-name: uninitialized_regs 208 isa: 209 instructions: 210 - sig: lda v:in:b32 211 acc: out:b32 212 format: [op_v_8] 213 description: Check lda with uninitialized registers. 214 tags: ['verifier'] 215 runner-options: ['verifier-failure', 'verifier-config'] 216 header-template: [] 217 code-template: | 218 # 219 .function i32 main() { 220 lda %s 221 ldai 0 222 check-type: no-check 223 cases: 224 - values: 225 - v0 226 - values: 227 - v8 228 - values: 229 - v15 230 - values: 231 - v255 232