# 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: "fsub2.64" 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: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] description: Any operation with NaN results to NaN value. check-type: check-acc-nan-f64 tags: ['irtoc_ignore'] code-template: | # fldai.64 %s fmovi.64 v0, *s fsub2.64 v0 description: > Check fsub2.64 results in NaN when acc or v0 is NaN template-cases: - values: # NaN - "0x7ff8000000000000" - values: # NaN representation - "0xFFFFFFFFFFFFFFFF" - values: - "0" exclude: [hasval] - values: - "-0.0" exclude: [hasval] - values: - "1" exclude: [hasval] - values: - "-1" exclude: [hasval] - values: # +Inf - "0x7ff0000000000000" exclude: [hasval] - values: # -Inf - "0xfff0000000000000" exclude: [hasval] - values: # +max - "0x7fefffffffffffff" exclude: [hasval] - values: # -max - "0xffefffffffffffff" exclude: [hasval] - values: # +min - "0x0000000000000001" exclude: [hasval] - values: # -min - "0x8000000000000001" exclude: [hasval] - values: - "3.14159265358979323846" exclude: [hasval] - values: - "1234567890987654321" exclude: [hasval] cases: - values: # NaN - "0x7ff8000000000000" - values: # NaN - "0xFFFFFFFFFFFFFFFF" - values: - "0" id: hasval - values: - "-0.0" id: hasval - values: - "1" id: hasval - values: - "-1" id: hasval - values: # +Inf - "0x7ff0000000000000" id: hasval - values: # -Inf - "0xfff0000000000000" id: hasval - values: # +max - "0x7fefffffffffffff" id: hasval - values: # -max - "0xffefffffffffffff" id: hasval - values: # +min - "0x0000000000000001" id: hasval - values: # -min - "0x8000000000000001" id: hasval - values: - "3.14159265358979323846" id: hasval - values: - "1234567890987654321" id: hasval - file-name: "op_vs_8_pinf" isa: instructions: - sig: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] description: > The sum of two infinities of the same sign or the difference of two infinities of opposite sign is infinity. The sign of result matches the sign of accumulator value. The sum or the difference of infinity and any finite value is infinity. The sign of result matches the sign of infinity. check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai.64 0x7ff0000000000000 # +Inf fmovi.64 v0, %s # Sub of +Inf and value fsub2.64 v0 fmovi.64 v1, %s fcmpg.64 v1 description: Check fsub2.64 with positive Inf and various values (NaN, Inf, min, max, numbers). cases: - values: # -Inf - "0xfff0000000000000" - "0x7ff0000000000000" - values: - "0" - "0x7ff0000000000000" - values: - "-0.0" - "0x7ff0000000000000" - values: - "1" - "0x7ff0000000000000" - values: - "-1" - "0x7ff0000000000000" - values: # +max - "0x7fefffffffffffff" - "0x7ff0000000000000" - values: # -max - "0xffefffffffffffff" - "0x7ff0000000000000" - values: # +min - "0x0000000000000001" - "0x7ff0000000000000" - values: # -min - "0x8000000000000001" - "0x7ff0000000000000" - values: - "3.14159265358979323846" - "0x7ff0000000000000" - values: - "1234567890987654321" - "0x7ff0000000000000" - file-name: "op_vs_8_ninf" isa: instructions: - sig: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] description: > The sum of two infinities of the same sign or the difference of two infinities of opposite sign is infinity. The sign of result matches the sign of accumulator value. The sum or the difference of infinity and any finite value is infinity. The sign of result matches the sign of infinity. check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai.64 0xfff0000000000000 # -Inf fmovi.64 v0, %s # Sub of -Inf and value fsub2.64 v0 fmovi.64 v1, %s fcmpg.64 v1 description: Check fsub2.64 with negative Inf and various values (NaN, Inf, min, max, numbers). cases: - values: # +Inf - "0x7ff0000000000000" # -Inf - "0xfff0000000000000" - values: - "0" # -Inf - "0xfff0000000000000" - values: - "-0.0" # -Inf - "0xfff0000000000000" - values: - "1" # -Inf - "0xfff0000000000000" - values: - "-1" # -Inf - "0xfff0000000000000" - values: # +max - "0x7fefffffffffffff" # -Inf - "0xfff0000000000000" - values: # -max - "0xffefffffffffffff" # -Inf - "0xfff0000000000000" - values: # +min - "0x0000000000000001" # -Inf - "0xfff0000000000000" - values: # -min - "0x8000000000000001" # -Inf - "0xfff0000000000000" - values: - "3.14159265358979323846" # -Inf - "0xfff0000000000000" - values: - "1234567890987654321" # -Inf - "0xfff0000000000000" - file-name: "op_vs_8_inf_nan" isa: instructions: - sig: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] description: > The sum of opposite infinities or the difference of the same sign infinities is NaN. check-type: check-acc-nan-f64 tags: ['irtoc_ignore'] code-template: | # fldai.64 %s fmovi.64 v0, %s # Sub of same sign Inf-s fsub2.64 v0 description: > Check fsub2.64 with (-Inf, -Inf) and (+Inf, +Inf) is NaN. cases: - values: - "0x7ff0000000000000" - "0x7ff0000000000000" - values: - "0xfff0000000000000" - "0xfff0000000000000" - file-name: "op_vs_8_pzero" isa: instructions: - sig: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] description: > The sum or the difference of infinity and any finite value is infinity. The sign of result matches the sign of infinity. The sum or the difference of zeros is zero. Exceptions are the sum of two negative zeros and the difference of negative and positive zero - the result is negative zero. check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai.64 0.0 # fmovi.64 v0, %s # Sub of +0.0 and value fsub2.64 v0 fmovi.64 v1, %s fcmpg.64 v1 description: Check fsub2.64 with positive zero and various values (NaN, Inf, min, max, numbers). cases: - values: - "0" - "0" - values: - "-0.0" - "0" - values: - "1" - "-1" - values: - "-1" - "1" - values: # +Inf - "0x7ff0000000000000" - "0xfff0000000000000" - values: # -Inf - "0xfff0000000000000" # +Inf - "0x7ff0000000000000" - values: # +max - "0x7fefffffffffffff" # -max - "0xffefffffffffffff" - values: # -max - "0xffefffffffffffff" # +max - "0x7fefffffffffffff" - values: # +min - "0x0000000000000001" - "0x8000000000000001" - values: # -min - "0x8000000000000001" - "0x0000000000000001" - values: - "3.14159265358979323846" - "-3.14159265358979323846" - values: - "-3.14159265358979323846" - "3.14159265358979323846" - file-name: "op_vs_8_nzero" isa: instructions: - sig: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] description: > The sum or the difference of infinity and any finite value is infinity. The sign of result matches the sign of infinity. The sum or the difference of zeros is zero. Exceptions are the sum of two negative zeros and the difference of negative and positive zero - the result is negative zero. check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai.64 -0.0 # fmovi.64 v0, %s # Sub of -0.0 and value fsub2.64 v0 fmovi.64 v1, %s fcmpg.64 v1 description: Check fsub2.64 with negative zero and various values (NaN, Inf, min, max, numbers). cases: # Commented because there is no direct way to compare 0.0 and -0.0 # - case-template: | # # # fldai.64 -0.0 # # fmovi.64 v0, +0.0 # # Sub of -0.0 and +0.0 should be -0.0 # fsub2.64 v0 # fmovi.64 v1, -0.0 # fcmpg.64 v1 # compare as binary values, due to +0.0 == -0.0, but 0x8000000000000000 != 0x0000000000000000 - values: - "0" - "0" - values: - "-0.0" - "0" - values: - "1" - "-1" - values: - "-1" - "1" - values: # +Inf - "0x7ff0000000000000" - "0xfff0000000000000" - values: # -Inf - "0xfff0000000000000" # +Inf - "0x7ff0000000000000" - values: # +max - "0x7fefffffffffffff" # -max - "0xffefffffffffffff" - values: # -max - "0xffefffffffffffff" # +max - "0x7fefffffffffffff" - values: # +min - "0x0000000000000001" - "0x8000000000000001" - values: # -min - "0x8000000000000001" - "0x0000000000000001" - values: - "3.14159265358979323846" - "-3.14159265358979323846" - values: - "-3.14159265358979323846" - "3.14159265358979323846" - file-name: "op_vs_8_pone" isa: instructions: - sig: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] description: > The sum or the difference of infinity and any finite value is infinity. The sign of result matches the sign of infinity. check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai.64 1.0 # fmovi.64 v0, %s # Sub of 1.0 and value fsub2.64 v0 fmovi.64 v1, %s fcmpg.64 v1 description: Check fsub2.64 with +1 and various values (NaN, Inf, min, max, numbers). cases: - values: - "0" - "1" - values: - "-0.0" - "1" - values: - "1" - "0" - values: - "-1" - "2" - values: # +Inf - "0x7ff0000000000000" - "0xFFF0000000000000" - values: # -Inf - "0xfff0000000000000" # +Inf - "0x7FF0000000000000" - values: # +max - "0x7fefffffffffffff" - "0xFFEFFFFFFFFFFFFF" - values: # -max - "0xFFEFFFFFFFFFFFFF" # +max - "0x7FEFFFFFFFFFFFFF" - values: # +min - "0x0000000000000001" - "1" - values: # -min - "0x8000000000000001" - "1" - values: - "3.14159265358979323846" - "-2.141592653589793" - values: - "-3.14159265358979323846" - "4.14159265358979323846" - values: - "1234567890.987654321" - "-1234567889.9876542" - file-name: "op_vs_8_none" isa: instructions: - sig: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] description: > The sum or the difference of infinity and any finite value is infinity. The sign of result matches the sign of infinity. check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai.64 -1.0 # fmovi.64 v0, %s # Sub of -1.0 and value fsub2.64 v0 fmovi.64 v1, %s fcmpg.64 v1 description: Check fsub2.64 with -1 and various values (NaN, Inf, min, max, numbers). cases: - values: - "0" - "-1" - values: - "-0.0" - "-1" - values: - "1" - "-2" - values: - "-1" - "0" - values: # +Inf - "0x7ff0000000000000" - "0xfff0000000000000" - values: # -Inf - "0xfff0000000000000" # -Inf - "0x7FF0000000000000" - values: # +max - "0x7fefffffffffffff" - "0xFFEFFFFFFFFFFFFF" - values: # -max - "0xFFEFFFFFFFFFFFFF" - "0x7FEFFFFFFFFFFFFF" - values: # +min - "0x0000000000000001" - "-1" - values: # -min - "0x8000000000000001" - "-1" - values: - "3.14159265358979323846" - "-4.14159265358979323846" - values: - "-3.14159265358979323846" - "2.14159265358979323846" - values: - "1234567890.987654321" - "-1234567891.9876542" - file-name: "op_vs_8" isa: instructions: - sig: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] description: > The sum or the difference of zeros is zero. Exceptions are the sum of two negative zeros and the difference of negative and positive zero - the result is negative zero. check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai.64 %s # fmovi.64 v0, %s # Sub of -1.0 and value fsub2.64 v0 fmovi.64 v1, %s fcmpg.64 v1 description: Check fsub2.64 with various values. cases: - values: - "0.0" - "0.0" - "0.0" - values: - "0.0" - "-0.0" - "0.0" - values: - "-0.0" - "0.0" - "0.0" - values: - "-0.0" - "-0.0" - "0.0" - values: - "1.0" - "-1.0" - "2.0" - values: - "1.0" - "1.0" - "0.0" - values: - "-1.0" - "1.0" - "-2.0" - values: - "1.0e100" - "1.0e100" - "0.0" - values: - "1.0e100" - "-1.0e100" - "2.0e100" - values: - "1.0e+100" - "1.0e-100" - "1.0e+100" - values: - "-1.0e100" - "1.0e100" - "-2.0e100" - values: - "-1.0e-100" - "1.0e-100" - "-2.0e-100" - values: - "-1.0e+100" - "-1.0e-100" - "-1.0e+100" - values: - "3.14159265358979323846" - "-3.14159265358979323846" - "6.283185307179586" - values: - "3.14159265358979323846e200" - "-3.14159265358979323846e200" - "6.283185307179587e200" # - values: # # TODO add test cases for maximal and minimal FP value in decimal scientific literal - file-name: "op_vs_8_max" isa: instructions: - sig: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] check-type: check-positive tags: ['irtoc_ignore'] code-template: | # fldai.64 %s fmovi.64 v0, %s # Sub of two values fsub2.64 v0 fmovi.64 v1, %s fcmpg.64 v1 description: Check fsub2.64 with various max values. cases: - values: # +max - "0x7fefffffffffffff" # +max - "0x7fefffffffffffff" - "0" - values: # -max - "0xFFEFFFFFFFFFFFFF" # -max - "0xFFEFFFFFFFFFFFFF" - "0" - values: # +max - "0x7fefffffffffffff" # -max - "0xFFEFFFFFFFFFFFFF" # +Inf - "0x7ff0000000000000" - values: # +max - "0x7fefffffffffffff" - "1" # +max - "0x7fefffffffffffff" - values: # +max - "0x7fefffffffffffff" - "-1" # +max - "0x7fefffffffffffff" - values: # -max - "0xFFEFFFFFFFFFFFFF" - "1" # -max - "0xFFEFFFFFFFFFFFFF" - values: # -max - "0xFFEFFFFFFFFFFFFF" - "-1" # -max - "0xFFEFFFFFFFFFFFFF" - file-name: "incorrect_reg" isa: instructions: - sig: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] check-type: none runner-options: [compile-failure] description: Check fsub2.64 with incorrect register numbers. code-template: | # fsub2.64 %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: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] check-type: none runner-options: [compile-only] description: Check fsub2.64 with correct register numbers. code-template: | # fsub2.64 %s cases: - values: [v0] - values: [v16] - values: [v128] - values: [v255] - file-name: "calc" isa: instructions: - sig: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] check-type: check-positive code-template: | # fldai.64 %s # fmovi.64 v0, %s fsub2.64 v0 fmovi.64 v1, %s fcmpg.64 v1 description: Check fsub2.64 with various values. tags: ['tsan', 'irtoc_ignore'] cases: - values: - "-0.05673353446563578" - "0.4165127778130051" - "-0.4732463122786409" - values: - "-0.2607618506052821" - "0.0750908448423836" - "-0.3358526954476657" - values: - "-0.13674848473769208" - "-0.37436759865021485" - "0.23761911391252277" - values: - "0.12866094924106286" - "0.4168653788046697" - "-0.2882044295636068" - values: - "0.37966868911751406" - "0.4990010036832817" - "-0.11933231456576765" - values: - "0.18564113444569652" - "0.21971091949324728" - "-0.03406978504755076" - values: - "0.4065300094565073" - "0.11364008159171668" - "0.2928899278647906" - values: - "-0.1010416144789762" - "-0.11197993505013781" - "0.01093832057116162" - values: - "0.3251595799516377" - "-0.09596574355268472" - "0.4211253235043224" - values: - "0.23107785598444763" - "-0.2677659750461253" - "0.49884383103057295" - values: - "2.2049776702532387e-20" - "-8.69113551313747e-21" - "3.0740912215669856e-20" - values: - "2.4603309829023933e10" - "-3.531811165213039e9" - "2.8135120994236973e10" - values: - "3.76992083887569e67" - "4.90327629307566e67" - "-1.1333554541999702e67" - values: - "-4.120943556081973e-97" - "4.725011085672193e-97" - "-8.845954641754166e-97" - values: - "-1.27679146268046e52" - "-4.561463650315357e52" - "3.284672187634897e52" - values: - "2.650888284901465e34" - "7.5105380484769e34" - "-4.859649763575435e34" - values: - "1.651217057264739e43" - "-2.0157034930418428e42" - "1.8527874065689232e43" - values: - "-1.7009917118749317e40" - "7.921976453192359e39" - "-2.4931893571941675e40" - values: - "-2.6073128733459994e80" - "-3.133709440359744e79" - "-2.293941929310025e80" - values: - "-1.644446855906727e-73" - "4.45120026009637e-73" - "-6.095647116003097e-73" - file-name: "type" isa: instructions: - sig: fsub2.64 v:in:f64 acc: inout:f64 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 fsub2.64 v0 check-type: exit-positive description: Check 'fsub2.64' with incorrect register and accumulator type. template-cases: - values: - movi v0, 0 - values: - movi.64 v0, 0 - values: - fmovi v0, 0 bugid: ['7315'] - values: - fmovi.64 v0, 0 exclude: [val] - 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 bugid: ['7315'] - values: - fldai.64 0 id: val - values: - | # lda.type A - values: - | # lda.type A[] - values: - | # lda.type panda.String - values: - | # lda.str "string" - values: - | # movi v1, 10 newarr v1, v1, f64[] lda.obj v1 - values: - lda.null - file-name: uninitialized_regs isa: instructions: - sig: fsub2.64 v:in:f64 acc: inout:f64 format: [op_v_8] description: Check 'fsub2.64' with uninitialized register and accumulator. tags: ['verifier'] runner-options: ['verifier-failure', 'verifier-config'] code-template: | # %s *s fsub2.64 %s check-type: exit-positive template-cases: - values: - '' - v0 - values: - fmovi.64 v0, 0 - v0 exclude: [init] - values: - '' - v7 - values: - '' - v15 - values: - fmovi.64 v15, 0 - v15 exclude: [init] - values: - '' - v128 - values: - fmovi.64 v128, 0 - v128 exclude: [init] - values: - '' - v255 - values: - fmovi.64 v255, 0 - v255 exclude: [init] cases: - values: - '' - values: - fldai.64 0 id: init