llvm.org GIT mirror llvm / 5e5c5f8
Rename "fpaccuracy" metadata to the more generic "fpmath". That's because I'm thinking of generalizing it to be able to specify other freedoms beyond accuracy (such as that NaN's don't have to be respected). I'd like the 3.1 release (the first one with this metadata) to have the more generic name already rather than having to auto-upgrade it in 3.2. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154744 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan Sands 8 years ago
6 changed file(s) with 47 addition(s) and 47 deletion(s). Raw diff Collapse all Expand all
102102
  • Metadata Nodes and Metadata Strings
  • 103103
    104104
  • 'tbaa' Metadata
  • 105
  • 'fpaccuracy' Metadata
  • 105
  • 'fpmath' Metadata
  • 106106
  • 'range' Metadata
  • 107107
    108108
    29992999
    30003000
    30013001

    3002 'fpaccuracy' Metadata
    3002 'fpmath' Metadata
    30033003
    30043004
    30053005
    30063006
    3007

    fpaccuracy metadata may be attached to any instruction of floating

    3008 point type. It expresses the maximum relative error allowed in the result
    3009 of that instruction, in ULPs, thus potentially allowing the compiler to use
    3010 a more efficient but less accurate method of computing it.
    3007

    fpmath metadata may be attached to any instruction of floating point

    3008 type. It can be used to express the maximum acceptable relative error in the
    3009 result of that instruction, in ULPs, thus potentially allowing the compiler
    3010 to use a more efficient but less accurate method of computing it.
    30113011 ULP is defined as follows:

    30123012
    30133013
    4141 MD_dbg = 0, // "dbg"
    4242 MD_tbaa = 1, // "tbaa"
    4343 MD_prof = 2, // "prof"
    44 MD_fpaccuracy = 3, // "fpaccuracy"
    44 MD_fpmath = 3, // "fpmath"
    4545 MD_range = 4 // "range"
    4646 };
    4747
    4343 unsigned ProfID = getMDKindID("prof");
    4444 assert(ProfID == MD_prof && "prof kind id drifted"); (void)ProfID;
    4545
    46 // Create the 'fpaccuracy' metadata kind.
    47 unsigned FPAccuracyID = getMDKindID("fpaccuracy");
    48 assert(FPAccuracyID == MD_fpaccuracy && "fpaccuracy kind id drifted");
    46 // Create the 'fpmath' metadata kind.
    47 unsigned FPAccuracyID = getMDKindID("fpmath");
    48 assert(FPAccuracyID == MD_fpmath && "fpmath kind id drifted");
    4949 (void)FPAccuracyID;
    5050
    5151 // Create the 'range' metadata kind.
    16521652 }
    16531653 }
    16541654
    1655 if (MDNode *MD = I.getMetadata(LLVMContext::MD_fpaccuracy)) {
    1655 if (MDNode *MD = I.getMetadata(LLVMContext::MD_fpmath)) {
    16561656 Assert1(I.getType()->isFPOrFPVectorTy(),
    1657 "fpaccuracy requires a floating point result!", &I);
    1658 Assert1(MD->getNumOperands() == 1, "fpaccuracy takes one operand!", &I);
    1657 "fpmath requires a floating point result!", &I);
    1658 Assert1(MD->getNumOperands() == 1, "fpmath takes one operand!", &I);
    16591659 ConstantFP *Op = dyn_cast_or_null(MD->getOperand(0));
    1660 Assert1(Op, "fpaccuracy ULPs not a floating point number!", &I);
    1660 Assert1(Op, "fpmath ULPs not a floating point number!", &I);
    16611661 APFloat ULPs = Op->getValueAPF();
    16621662 Assert1(ULPs.isNormal() || ULPs.isZero(),
    1663 "fpaccuracy ULPs not a normal number!", &I);
    1664 Assert1(!ULPs.isNegative(), "fpaccuracy ULPs is negative!", &I);
    1663 "fpmath ULPs not a normal number!", &I);
    1664 Assert1(!ULPs.isNegative(), "fpmath ULPs is negative!", &I);
    16651665 }
    16661666
    16671667 MDNode *MD = I.getMetadata(LLVMContext::MD_range);
    +0
    -31
    test/Verifier/fpaccuracy.ll less more
    None ; RUN: not llvm-as < %s |& FileCheck %s
    1
    2 define void @foo(i32 %i, float %f, <2 x float> %g) {
    3 %s = add i32 %i, %i, !fpaccuracy !0
    4 ; CHECK: fpaccuracy requires a floating point result!
    5 %t = fadd float %f, %f, !fpaccuracy !1
    6 ; CHECK: fpaccuracy takes one operand!
    7 %u = fadd float %f, %f, !fpaccuracy !2
    8 ; CHECK: fpaccuracy takes one operand!
    9 %v = fadd float %f, %f, !fpaccuracy !3
    10 ; CHECK: fpaccuracy ULPs not a floating point number!
    11 %w = fadd float %f, %f, !fpaccuracy !0
    12 ; Above line is correct.
    13 %w2 = fadd <2 x float> %g, %g, !fpaccuracy !0
    14 ; Above line is correct.
    15 %x = fadd float %f, %f, !fpaccuracy !4
    16 ; CHECK: fpaccuracy ULPs is negative!
    17 %y = fadd float %f, %f, !fpaccuracy !5
    18 ; CHECK: fpaccuracy ULPs is negative!
    19 %z = fadd float %f, %f, !fpaccuracy !6
    20 ; CHECK: fpaccuracy ULPs not a normal number!
    21 ret void
    22 }
    23
    24 !0 = metadata !{ float 1.0 }
    25 !1 = metadata !{ }
    26 !2 = metadata !{ float 1.0, float 1.0 }
    27 !3 = metadata !{ i32 1 }
    28 !4 = metadata !{ float -1.0 }
    29 !5 = metadata !{ float -0.0 }
    30 !6 = metadata !{ float 0x7FFFFFFF00000000 }
    0 ; RUN: not llvm-as < %s |& FileCheck %s
    1
    2 define void @foo(i32 %i, float %f, <2 x float> %g) {
    3 %s = add i32 %i, %i, !fpmath !0
    4 ; CHECK: fpmath requires a floating point result!
    5 %t = fadd float %f, %f, !fpmath !1
    6 ; CHECK: fpmath takes one operand!
    7 %u = fadd float %f, %f, !fpmath !2
    8 ; CHECK: fpmath takes one operand!
    9 %v = fadd float %f, %f, !fpmath !3
    10 ; CHECK: fpmath ULPs not a floating point number!
    11 %w = fadd float %f, %f, !fpmath !0
    12 ; Above line is correct.
    13 %w2 = fadd <2 x float> %g, %g, !fpmath !0
    14 ; Above line is correct.
    15 %x = fadd float %f, %f, !fpmath !4
    16 ; CHECK: fpmath ULPs is negative!
    17 %y = fadd float %f, %f, !fpmath !5
    18 ; CHECK: fpmath ULPs is negative!
    19 %z = fadd float %f, %f, !fpmath !6
    20 ; CHECK: fpmath ULPs not a normal number!
    21 ret void
    22 }
    23
    24 !0 = metadata !{ float 1.0 }
    25 !1 = metadata !{ }
    26 !2 = metadata !{ float 1.0, float 1.0 }
    27 !3 = metadata !{ i32 1 }
    28 !4 = metadata !{ float -1.0 }
    29 !5 = metadata !{ float -0.0 }
    30 !6 = metadata !{ float 0x7FFFFFFF00000000 }