# 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.obj isa: title: Load accumulator from register description: Moves register content into an accumulator. exceptions: - x_none commands: - file-name: op_p isa: instructions: - sig: lda.obj v:in:ref acc: out:ref format: [op_v_8] check-type: none code-template: | %s # header .function i32 main() { # Check lda.obj for different type of arguments (empty object, with fields, statics, etc). newobj v0, Object lda.obj v0 jne.obj v0, return_ne_num ldai 0 return return_ne_num: ldai 1 return header-template: [] description: Check lda.obj moves register content into accumulator (references to various type of objects) in PandaAssembly context. cases: - values: - | .record Object { } - values: - | .record Object { i32 fld2 } - values: - | .record Object { i64 fld2 } - values: - | .record Object { u64 fld2 } - values: - | .record Object { i32 fld2 } - values: - | .record Object { i32 fld1 i32 fld2 } - values: - | .record Object { i64 fld1 i64 fld2 } - values: - | .record Object { f64 fld1 f64 fld2 } - values: - | .record Object { f32 fld1 f32 fld2 f64 fld3 f64 fld4 i32 fld5 i32 fld6 i64 fld7 i64 fld8 } - case-template: | # .function i32 main() { # Check lda.obj for string lda.str "" sta.obj v0 lda.obj v0 jne.obj v0, return_ne_num ldai 0 return return_ne_num: ldai 1 return - case-template: | # .record Object {} .function i32 main() { # Check lda.obj for type lda.type Object sta.obj v0 lda.obj v0 jne.obj v0, return_ne_num ldai 0 return return_ne_num: ldai 1 return - file-name: op_j runner-options: [use-pa] isa: instructions: - sig: lda.obj v:in:ref acc: out:ref format: [op_v_8] check-type: none code-template: | .language PandaAssembly %s # header .function i32 main() { # Check lda.obj for different type of arguments (empty object, with fields, statics, etc). %s lda.obj v0 jne.obj v0, return_ne_num ldai 0 return return_ne_num: ldai 1 return header-template: [] description: Check lda.obj moves register content into accumulator (references to various type of objects) in PandaAssembly context. cases: - values: - | .record Obj { } - newobj v0, Obj - values: - | .record Obj { i32 fld2 } - newobj v0, Obj - values: - '' - | lda.str "test string" sta.obj v0 - values: - .record panda.Object - | lda.type panda.Object sta.obj v0 - values: - .record panda.NullPointerException - newobj v0, panda.NullPointerException - file-name: 'null' isa: instructions: - sig: lda.obj v:in:ref acc: out:ref format: [op_v_8] description: Check lda.obj moves register content into accumulator (null reference). check-type: none code-template: | # header .function i32 main() { # Check lda.obj for null lda.null sta.obj v0 lda.obj v0 jne.obj v0, return_ne_num ldai 0 return return_ne_num: ldai 1 return header-template: [] - file-name: op_8 description: Check lda.obj with various register numbers. isa: instructions: - sig: lda.obj v:in:ref acc: out:ref format: [op_v_8] tags: ['tsan'] check-type: none code-template: | .record Object {} # header .function i32 main() { # Check lda.obj with different registers number newobj v0, Object mov.obj %s, v0 lda.obj %s jne.obj v0, return_ne_num ldai 0 return return_ne_num: ldai 1 return header-template: [] cases: - values: [v0, v0] - values: [v7, v7] - values: [v8, v8] - values: [v15, v15] - values: [v16, v16] - values: [v127, v127] - values: [v128, v128] - values: [v255, v255] - values: [v256, v256] runner-options: [compile-failure] description: Check lda.obj with incorrect register number. - file-name: op_8_null isa: instructions: - sig: lda.obj v:in:ref acc: out:ref format: [op_v_8] description: Check lda.obj with various register numbers and null. check-type: none code-template: | # lda.null sta.obj v0 mov.obj %s, v0 lda.obj %s jne.obj v0, return_ne_num ldai 0 return return_ne_num: ldai 1 return cases: - values: [v0, v0] - values: [v7, v7] - values: [v8, v8] - values: [v15, v15] - values: [v16, v16] - values: [v127, v127] - values: [v128, v128] - values: [v255, v255] - values: [v256, v256] runner-options: [compile-failure] description: Check lda.obj with incorrect register number and null. - file-name: op_type tags: ['verifier'] bugid: ['966', '964'] isa: instructions: - sig: lda.obj v:in:ref acc: out:ref format: [op_v_8] verification: - v1_type check-type: none code-template: | # Check lda.obj with wrong type %s lda.obj v0 jne.obj v0, return_ne_num ldai 0 return return_ne_num: ldai 1 return runner-options: ['verifier-failure', 'verifier-config'] description: Check lda.obj with incorrect register type (i32, i64, f32, f64). cases: - values: - movi v0, 0 - values: - movi v0, 123 - values: - movi.64 v0, 0 - values: - movi.64 v0, 123 - values: - fmovi v0, 0 - values: - fmovi v0, 123 - values: - fmovi.64 v0, 0 - values: - fmovi.64 v0, 123 - file-name: err isa: instructions: - sig: lda.obj v:in:ref acc: out:ref format: [op_v_8] code-template: | # Check lda.obj with wrong arguments %s ldai 0 return check-type: none runner-options: [compile-failure] description: Check lda.obj with incorrect values. cases: - values: - lda.obj 1 - values: - lda.obj 1.1 - values: - lda.obj a0 - values: - lda.obj "" - file-name: type_p isa: instructions: - sig: lda.obj v:in:ref acc: out:ref format: [op_v_8] verification: - v1_type description: Check lda.obj with incorrect source register type in PandaAssembly context. Accumulator type is not checked. runner-options: ['verifier-failure', 'verifier-config'] tags: ['verifier'] header-template: [] code-template: | # .record B {} .record panda.String .record panda.Object .function i32 main() { *s %s lda.obj v1 ldai 0 check-type: no-check template-cases: - values: - | # lda.type B - values: - | # lda.type B[] - values: - | # lda.type panda.String - 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: - movi v1, 0 - values: - fmovi v1, 0 - values: - movi.64 v1, 0 - values: - fmovi.64 v1, 0 - file-name: type_j isa: instructions: - sig: lda.obj v:in:ref acc: out:ref format: [op_v_8] verification: - v1_type description: Check lda.obj with incorrect source register type in PandaAssembly context. Accumulator type is not checked. runner-options: ['verifier-failure', 'verifier-config', 'use-pa'] tags: [verifier, pa-verifier] header-template: [] code-template: | .language PandaAssembly # .record B {} .record panda.String .record panda.Object .function i32 main() { *s %s lda.obj v1 ldai 0 check-type: no-check template-cases: - values: - | # lda.type B - values: - | # lda.type B[] - values: - | # lda.type panda.String - 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: - movi v1, 0 - values: - fmovi v1, 0 - values: - movi.64 v1, 0 - values: - fmovi.64 v1, 0 - file-name: uninitialized_regs isa: instructions: - sig: lda.obj v:in:ref acc: out:ref format: [op_v_8] description: Check lda.obj with uninitialized registers. tags: ['verifier'] runner-options: ['verifier-failure', 'verifier-config'] header-template: [] code-template: | # .function i32 main() { lda.obj %s ldai 0 check-type: no-check cases: - values: - v0 - values: - v8 - values: - v15 - values: - v255