# 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: "fdiv2" isa: title: Two address floating-point binary operation on accumulator description: > Perform specified floating-point binary operation on accumulator and register and store result into accumulator. The results of instructions correspond IEEE-754 arithmetic rules. exceptions: - x_none commands: - file-name: "op_vs_8_nan" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] description: Any operation with NaN results to NaN value. check-type: check-acc-nan-f32 tags: ['irtoc_ignore'] code-template: | # fldai %s fmovi v0, *s fdiv2 v0 description: > Check fdiv2 results in NaN when acc or v0 is NaN template-cases: - values: # NaN - "0x7fc00000" - values: # NaN representation - "0xFFFFFFFF" - values: # Positive zero - "0" bugid: ["966", "965"] exclude: [hasval] - values: # Negative zero - "0x80000000" bugid: ["966", "965"] exclude: [hasval] - values: # 1d - "1.0" bugid: ["966", "965"] exclude: [hasval] - values: - "-1" exclude: [hasval] - values: # +Inf - "0x7f800000" exclude: [hasval] - values: # -Inf - "0xff800000" exclude: [hasval] - values: # +max - "0x7f7fffff" exclude: [hasval] - values: # -max - "0xff7fffff" exclude: [hasval] - values: # +min - "0x00000001" exclude: [hasval] - values: # -min - "0x80000001" exclude: [hasval] - values: # Some FP value, 3.14159265358979323846 - "0x40490fdb" exclude: [hasval] - values: # Some FP value - "1234567890" exclude: [hasval] cases: - values: # NaN - "0x7fc00000" - values: # NaN representation - "0xFFFFFFFF" - values: # Positive zero - "0" bugid: ["966", "965"] id: hasval - values: # Negative zero - "0x8000000" bugid: ["966", "965"] id: hasval - values: # 1d - "1.0" bugid: ["966", "965"] id: hasval - values: - "-1" id: hasval - values: # +Inf - "0x7f800000" id: hasval - values: # -Inf - "0xff800000" id: hasval - values: # +max - "0x7f7ffffff" id: hasval - values: # -max - "0xff7ffffff" id: hasval - values: # +min - "0x000000001" id: hasval - values: # -min - "0x800000001" id: hasval - values: # Some FP value, 3.1415927 - "0x40490fdb" id: hasval - values: # Some FP value - "1234567890" id: hasval - file-name: "op_vs_8_pinf" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] description: Division is infinity if any non zero value is divided by zero. check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai 0x7f800000 # +Inf fmovi v0, %s # Div of +Inf and value fdiv2 v0 fmovi v1, %s fcmpg v1 description: Check fdiv2 with positive Inf and various values (NaN, Inf, min, max, numbers). cases: - values: - "0" # Inf - "0x7f800000" bugid: ["966", "965"] - values: # -0.0d - "0x80000000" # -Inf - "0xFF800000" bugid: ["966", "965"] - values: # 1d - "1" # Inf - "0x7f800000" - values: - "-1" # -Inf - "0xFF800000" - values: # +max - "0x7f7fffff" # Inf - "0x7F800000" - values: # -max - "0xff7fffff" # -Inf - "0xFF800000" - values: # +min - "0x00000001" # Inf - "0x7F800000" - values: # -min - "0x80000001" # -Inf - "0xFF800000" - values: # Some FP value, 3.1415927 - "0x40490fdb" # Inf - "0x7F800000" - values: - "1234567890" # Inf - "0x7F800000" - file-name: "op_vs_8_ninf" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] description: Division is infinity if any non zero value is divided by zero. check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai 0xff800000 # -Inf fmovi v0, %s # Div of -Inf and value fdiv2 v0 fmovi v1, %s fcmpg v1 description: Check fdiv2 with negative Inf and various values (NaN, Inf, min, max, numbers). cases: - values: - "0" # -Inf - "0xff800000" bugid: ["966", "965"] - values: # -0.0d - "0x80000000" # +Inf - "0x7F800000" bugid: ["966", "965"] - values: # 1d - "1" # -Inf - "0xff800000" - values: - "-1" # +Inf - "0x7F800000" - values: # +max - "0x7f7fffff" # -Inf - "0xff800000" - values: # -max - "0xff7fffff" # +Inf - "0x7F800000" - values: # +min # - "0x00000001" - "1" # -Inf - "0xff800000" - values: # -min - "0x80000001" # +Inf - "0x7F800000" - values: # Some FP value, 3.14159265358979323846 - "0x40490fdb" # -Inf - "0xff800000" - values: - "1234567890" # -Inf - "0xff800000" - file-name: "op_vs_8_inf_nan" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] description: > Division is NaN if Infinity is divided by Infinity. check-type: check-acc-nan-f32 tags: ['irtoc_ignore'] code-template: | # fldai %s fmovi v0, *s # Div of Inf by Inf fdiv2 v0 description: > Check fdiv2 of Inf by Inf is NaN. template-cases: - values: ["0x7f800000"] - values: ["0xff800000"] cases: - values: ["0x7f800000"] - values: ["0xff800000"] - file-name: "op_vs_8_pzero" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai 0.0 # fmovi v0, %s # Div of +0.0 and value fdiv2 v0 fmovi v1, %s fcmpg v1 description: Check fdiv2 with +0 and various values (NaN, Inf, min, max, numbers). cases: - values: # +Inf - "0x7f800000" - "0" - values: # -Inf - "0xff800000" # -0.0 - "0x80000000" - values: # 1d - "1" - "0" - values: # -1d - "-1" - "-0.0" - values: # +max - "0x7f7fffff" - "0" - values: # -max - "0xff7fffff" # -0.0 - "0x80000000" - values: # +min - "0x00000001" - "0" - values: # -min - "0x80000001" # -0.0 - "0x80000000" - values: # Some FP value, - "3.1415927" - "0" - file-name: "op_vs_8_nzero" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai -0.0 # fmovi v0, %s # Div of -0.0 and value fdiv2 v0 fmovi v1, %s fcmpg v1 description: Check fdiv2 with -0 and various values (NaN, Inf, min, max, numbers). cases: - values: # +Inf - "0x7f800000" # -0.0d - "0x80000000" - values: # -Inf - "0xff800000" - "0" - values: # 1d - "1" - "0" - values: - "-1" - "0" - values: # +max - "0x7f7fffff" - "0" - values: # -max - "0xff7fffff" - "0" - values: # +min - "0x00000001" # -0.0d - "0x80000000" - values: # -min - "0x80000001" - "0" - values: - "3.1415927" - "0" - values: # Some FP value, - "-3.1415927" - "0" - file-name: "op_vs_8_pone" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] description: Division is infinity if any non zero value is divided by zero. check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai 1.0 # fmovi v0, %s # Div of 1.0 and value fdiv2 v0 fmovi v1, %s fcmpg v1 description: Check fdiv2 with +1 and various values (NaN, Inf, min, max, numbers). cases: - values: # +0.0d - "0" # +Inf - "0x7f800000" bugid: ["966", "965"] - values: # -0.0d - "0x80000000" # -Inf - "0xff800000" bugid: ["966", "965"] - values: - "1" - "1" - values: - "-1" - "-1" - values: # +Inf - "0x7f800000" - "0" - values: # -Inf - "0xff800000" # -0.0d - "0x80000000" - values: # +max - "0x7f7fffff" - "0x00200000" - values: # -max - "0xff7fffff" - "0x80200000" - values: # +min - "0x00000001" # +Inf - "0x7F800000" - values: # -min - "0x80000001" # -Inf - "0xFF800000" - values: - "3.1415927" - "0x3ea2f983" - values: - "-3.1415927" - "0xbea2f983" - values: # Some FP value - "1234.9876" - "0x3a5443b5" - file-name: "op_vs_8_none" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] description: Division is infinity if any non zero value is divided by zero. check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai -1.0 # fmovi v0, %s # Div of -1.0 and value fdiv2 v0 fmovi v1, %s fcmpg v1 description: Check fdiv2 with -1 and various values (NaN, Inf, min, max, numbers). cases: - values: # +0.0d - "0" # -Inf - "0xFF800000" bugid: ["966", "965"] - values: # -0.0d - "0x80000000" # +Inf - "0x7F800000" bugid: ["966", "965"] - values: # 1d - "1" - "-1" - values: - "-1" - "1" bugid: ["966", "965"] - values: # +Inf - "0x7f800000" - "0x80000000" - values: # -Inf - "0xFF800000" - "0" - values: # +max - "0x7f7fffff" - "0x80200000" - values: # -max - "0xff7fffff" - "0x00200000" - values: # +min - "0x00000001" # -Inf - "0xFF800000" - values: # -min - "0x80000001" # +Inf - "0x7F800000" - values: # Some FP value, 3.1415927 - "0x40490fdb" - "0xbea2f983" - values: # Some FP value, -3.1415927 - "0xc0490fdb" - "0x3ea2f983" - values: # Some FP value - "1234.9876" - "0xba5443b5" - file-name: "op_vs_8" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai %s # fmovi v0, %s # Div of -1.0 and value fdiv2 v0 fmovi v1, %s fcmpg v1 description: Check fdiv2 with various values. cases: - values: - "1.0" - "-1.0" - "-1.0" - values: - "1.0" - "1.0" - "1.0" - values: - "-1.0" - "1.0" - "-1.0" - values: - "1.0e10" - "1.0e10" - "1.0" - values: - "1.0e10" - "-1.0e10" - "-1.0" - values: - "1.0e+10" - "1.0e-10" - "1.0e+20" - values: - "-1.0e10" - "1.0e10" - "-1.0" - values: - "-1.0e-10" - "1.0e-10" - "-1.0" - values: - "-1.0e+10" - "-1.0e-10" - "1.0e+20" - values: - "3.1415927" - "-3.1415927" - "-1.0" - values: - "3.1415927e10" - "-3.1415927e10" - "-1.0" # - values: # # TODO add test cases for maximal and minimal FP value in decimal scientific literal - file-name: "op_vs_8_max" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai %s fmovi v0, %s # Div of two values fdiv2 v0 fmovi v1, %s fcmpg v1 description: Check fdiv2 with various max values. cases: - values: # +max - "0x7f7fffff" # +max - "0x7f7fffff" - "1" - values: # -max - "0xff7fffff" # -max - "0xff7fffff" - "1" - values: # +max - "0x7f7fffff" # -max - "0xff7fffff" - "-1" - values: # -max - "0xff7fffff" # +max - "0x7f7fffff" - "-1" - values: # +max - "0x7f7fffff" # 1d - "1" # +max - "0x7f7fffff" - values: # +max - "0x7f7fffff" - "-1" # -max - "0xff7fffff" - values: # -max - "0xff7fffff" # 1d - "1" # -max - "0xff7fffff" - values: # -max - "0xff7fffff" - "-1" # +max - "0x7f7fffff" - file-name: "op_vs_8_zeroes_nan" bugid: ["966", "965"] isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] description: Division is NaN if zero is divided by zero. check-type: check-acc-nan-f32 tags: ['irtoc_ignore'] code-template: | # fldai %s # fmovi v0, %s # Div of zero by zero fdiv2 v0 cases: - values: - "0.0" - "0.0" - values: - "0.0" - "-0.0" - values: - "-0.0" - "0.0" - values: - "-0.0" - "-0.0" - file-name: "incorrect_reg" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] check-type: none runner-options: [compile-failure] description: Check fdiv2 with incorrect register numbers. code-template: | # fdiv2 %s cases: - values: [v256] - values: [v65535] - values: [a0] - values: [a255] - values: ['null'] - values: [0] - values: [1.1] - values: ['2.2'] - file-name: "reg_number" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] check-type: none runner-options: [compile-only] description: Check fdiv2 with correct register numbers. code-template: | # fdiv2 %s cases: - values: [v0] - values: [v16] - values: [v128] - values: [v255] - file-name: "calc" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] check-type: check-positive code-template: | # fldai %s # fmovi v0, %s fdiv2 v0 fmovi v1, %s fcmpg v1 description: Check fdiv2 with various values. tags: ['tsan', 'irtoc_ignore'] cases: - values: - "0.2163294" - "-0.3406104" - "-0.63512266" - values: - "0.3657011" - "0.0702997" - "5.202029" - values: - "0.4505041" - "0.2904757" - "1.5509183" - values: - "0.2148952" - "0.3347885" - "0.6418835" - values: - "0.3553113" - "0.4460468" - "0.7965785" - values: - "-0.2411176" - "-0.3790812" - "0.6360579" - values: - "-0.2518421" - "-0.3539177" - "0.71158385" - values: - "0.0714281" - "0.3986848" - "0.17915931" - values: - "-0.0423414" - "-0.3715421" - "0.11396124" - values: - "0.39756609" - "0.10346800" - "3.842406" - values: - "5.6565e-19" - "2751435.14" - "2.0558361e-25" - file-name: "type" isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] verification: - acc_type - v1_type tags: ['verifier'] runner-options: ['verifier-failure', 'verifier-config'] header-template: [] code-template: | # .record A {} .record B {} .record panda.String .record panda.Object .function i32 main() { %s *s fdiv2 v0 check-type: exit-positive description: Check 'fdiv2' with incorrect register and accumulator type. template-cases: - values: - movi v0, 0 - values: - movi.64 v0, 0 - values: - fmovi v0, 0 exclude: [val] - values: - fmovi.64 v0, 0 - values: - | # lda.type B sta.obj v0 - values: - | # lda.type B[] sta.obj v0 - values: - | # lda.type panda.String sta.obj v0 - values: - | # lda.str "string" sta.obj v0 - values: - | # movi v0, 10 newarr v0, v0, i32[] - values: - mov.null v0 cases: - values: - ldai 0 - values: - ldai.64 0 - values: - fldai 0 id: val - values: - fldai.64 0 - values: - | # lda.type A - values: - | # lda.type A[] - values: - | # lda.type panda.String - values: - | # lda.str "string" - values: - | # movi v1, 10 newarr v1, v1, f32[] lda.obj v1 - values: - lda.null - file-name: uninitialized_regs isa: instructions: - sig: fdiv2 v:in:f32 acc: inout:f32 format: [op_v_8] description: Check 'fdiv2' with uninitialized register and accumulator. tags: ['verifier'] runner-options: ['verifier-failure', 'verifier-config'] code-template: | # %s *s fdiv2 %s check-type: exit-positive template-cases: - values: - '' - v0 - values: - fmovi v0, 0 - v0 exclude: [init] - values: - '' - v7 - values: - '' - v15 - values: - fmovi v15, 0 - v15 exclude: [init] - values: - '' - v128 - values: - fmovi v128, 0 - v128 exclude: [init] - values: - '' - v255 - values: - fmovi v255, 0 - v255 exclude: [init] cases: - values: - '' - values: - fldai 0 id: init