X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=unittests%2FVMCore%2FInstructionsTest.cpp;h=4cadc36f8f0c266a09a031e843c9cf2605be5d97;hb=b21d9aebba7e45ddcbce61dd501000049cefb335;hp=218a9a08c4397a244532bd4bc547da00988a9781;hpb=1608769abeb1430dc34f31ffac0d9850f99ae36a;p=oota-llvm.git diff --git a/unittests/VMCore/InstructionsTest.cpp b/unittests/VMCore/InstructionsTest.cpp index 218a9a08c43..4cadc36f8f0 100644 --- a/unittests/VMCore/InstructionsTest.cpp +++ b/unittests/VMCore/InstructionsTest.cpp @@ -7,14 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Instructions.h" #include "llvm/BasicBlock.h" #include "llvm/Constants.h" +#include "llvm/DataLayout.h" #include "llvm/DerivedTypes.h" +#include "llvm/IRBuilder.h" +#include "llvm/Instructions.h" #include "llvm/LLVMContext.h" +#include "llvm/MDBuilder.h" +#include "llvm/Operator.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Analysis/ValueTracking.h" -#include "llvm/Target/TargetData.h" #include "gtest/gtest.h" namespace llvm { @@ -180,7 +183,7 @@ TEST(InstructionsTest, VectorGep) { EXPECT_NE(S3, Gep3); int64_t Offset; - TargetData TD("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3" + DataLayout TD("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3" "2:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80" ":128:128-n8:16:32:64-S128"); // Make sure we don't crash @@ -226,5 +229,19 @@ TEST(InstructionsTest, VectorGep) { delete PtrVecB; } +TEST(InstructionsTest, FPMathOperator) { + LLVMContext &Context = getGlobalContext(); + IRBuilder<> Builder(Context); + MDBuilder MDHelper(Context); + Instruction *I = Builder.CreatePHI(Builder.getDoubleTy(), 0); + MDNode *MD1 = MDHelper.createFPMath(1.0); + Value *V1 = Builder.CreateFAdd(I, I, "", MD1); + EXPECT_TRUE(isa(V1)); + FPMathOperator *O1 = cast(V1); + EXPECT_EQ(O1->getFPAccuracy(), 1.0); + delete V1; + delete I; +} + } // end anonymous namespace } // end namespace llvm