[llvm-commits] [llvm] r167111 - in /llvm/trunk: include/llvm/IRBuilder.h unittests/VMCore/IRBuilderTest.cpp
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Wed Oct 31 02:50:01 PDT 2012
Author: eugenis
Date: Wed Oct 31 04:50:01 2012
New Revision: 167111
URL: http://llvm.org/viewvc/llvm-project?rev=167111&view=rev
Log:
Add IRBuilderBase::getIntPtrTy.
Modified:
llvm/trunk/include/llvm/IRBuilder.h
llvm/trunk/unittests/VMCore/IRBuilderTest.cpp
Modified: llvm/trunk/include/llvm/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IRBuilder.h?rev=167111&r1=167110&r2=167111&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/IRBuilder.h Wed Oct 31 04:50:01 2012
@@ -17,6 +17,7 @@
#include "llvm/Instructions.h"
#include "llvm/BasicBlock.h"
+#include "llvm/DataLayout.h"
#include "llvm/LLVMContext.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
@@ -266,6 +267,10 @@
return Type::getInt8PtrTy(Context, AddrSpace);
}
+ IntegerType* getIntPtrTy(DataLayout *DL, unsigned AddrSpace = 0) {
+ return DL->getIntPtrType(Context, AddrSpace);
+ }
+
//===--------------------------------------------------------------------===//
// Intrinsic creation methods
//===--------------------------------------------------------------------===//
Modified: llvm/trunk/unittests/VMCore/IRBuilderTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/IRBuilderTest.cpp?rev=167111&r1=167110&r2=167111&view=diff
==============================================================================
--- llvm/trunk/unittests/VMCore/IRBuilderTest.cpp (original)
+++ llvm/trunk/unittests/VMCore/IRBuilderTest.cpp Wed Oct 31 04:50:01 2012
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/BasicBlock.h"
+#include "llvm/DataLayout.h"
#include "llvm/Function.h"
#include "llvm/IRBuilder.h"
#include "llvm/IntrinsicInst.h"
@@ -96,4 +97,15 @@
EXPECT_EQ(Weights, TI->getMetadata(LLVMContext::MD_prof));
}
+TEST_F(IRBuilderTest, GetIntTy) {
+ IRBuilder<> Builder(BB);
+ IntegerType *Ty1 = Builder.getInt1Ty();
+ EXPECT_EQ(Ty1, IntegerType::get(getGlobalContext(), 1));
+
+ DataLayout* DL = new DataLayout(M.get());
+ IntegerType *IntPtrTy = Builder.getIntPtrTy(DL);
+ unsigned IntPtrBitSize = DL->getPointerSizeInBits(0);
+ EXPECT_EQ(IntPtrTy, IntegerType::get(getGlobalContext(), IntPtrBitSize));
+}
+
}
More information about the llvm-commits
mailing list