# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
definitions: []
tests:
- file-name: lda
isa:
title: Load accumulator from register
description: Moves register content into an accumulator.
exceptions:
- x_none
instructions:
- sig: lda v:in:b32
acc: out:b32
format: [op_v_8]
commands:
- file-name: op_vd_8
description: Check 'lda' moves register content into an accumulator.
isa:
instructions:
- sig: lda v:in:b32
acc: out:b32
format: [op_v_8]
code-template: |
#
%s
ldai 0
return
err:
ldai 1
return
check-type: none
tags: ['tsan']
cases:
- values:
- "#{[
'0',
'1',
'0xF',
'0xFF',
'0xFFF',
'0xFFFF',
'0xFFFFF',
'0xFFFFFF',
'0xFFFFFFF',
'0xFFFFFFFF',
'0x7F',
'0x7FF',
'0x7FFF',
'0x7FFFF',
'0x7FFFFF',
'0x7FFFFFF',
'0x7FFFFFFF',
'-1',
'-0xF',
'-0xFF',
'-0xFFF',
'-0xFFFF',
'-0xFFFFF',
'-0xFFFFFF',
'-0xFFFFFFF',
'-0xFFFFFFFF',
'-0x7F',
'-0x7FF',
'-0x7FFF',
'-0x7FFFF',
'-0x7FFFFF',
'-0x7FFFFFF',
'-0x7FFFFFFF'
].map do |s| \" movi v0, #{s}\\n lda v0\\n jne v0, err\\n\" end .join}"
- file-name: reg
isa:
instructions:
- sig: lda v:in:b32
acc: out:b32
format: [op_v_8]
check-type: none
code-template: |
#
%s
ldai 0
return
err:
ldai 1
return
description: Check 'lda' with valid register numbers.
cases:
- values:
- "#{[*0..255].map do |i| \" movi v#{i}, 0xFEDCBA09\\n lda v#{i}\\n jne v#{i}, err\\n\" end .join}"
- file-name: reg_err
isa:
instructions:
- sig: lda v:in:b32
acc: out:b32
format: [op_v_8]
check-type: none
runner-options: [compile-failure]
code-template: |
#
lda %s
ldai 0
return
description: Check 'lda' with some invalid register numbers.
cases:
- values:
- v256
- values:
- a0
- values:
- v32565
- file-name: type
isa:
verification:
- v1_type
description: Check lda with incorrect source register type. Accumulator type is not checked.
runner-options: ['verifier-failure', 'verifier-config']
tags: ['verifier']
header-template: []
code-template: |
#
.record A {}
.record B {}
.record panda.Object <external>
.function i32 main() {
*s
%s
lda v1
ldai 0
check-type: no-check
template-cases:
- values:
- |
#
lda.type B
- values:
- |
#
lda.type B[]
- values:
- |
#
lda.str "string"
- values:
- |
#
lda.type panda.Object
- values:
- |
#
movi v0, 10
newarr v0, v0, i32[]
lda.obj v0
- values:
- lda.null
- values:
- ldai 0
- values:
- ldai.64 0
- values:
- fldai.64 0
cases:
- values:
- |
#
lda.type A
sta.obj v1
- values:
- |
#
lda.type A[]
sta.obj v1
- values:
- |
#
lda.str "string"
sta.obj v1
- values:
- |
#
lda.type panda.Object
sta.obj v1
- values:
- |
#
movi v1, 10
newarr v1, v1, f64[]
- values:
- mov.null v1
- values:
- movi.64 v1, 0
- values:
- fmovi.64 v1, 0
- file-name: uninitialized_regs
isa:
instructions:
- sig: lda v:in:b32
acc: out:b32
format: [op_v_8]
description: Check lda with uninitialized registers.
tags: ['verifier']
runner-options: ['verifier-failure', 'verifier-config']
header-template: []
code-template: |
#
.function i32 main() {
lda %s
ldai 0
check-type: no-check
cases:
- values:
- v0
- values:
- v8
- values:
- v15
- values:
- v255