llvm.org GIT mirror llvm / 0ceb855
Add IRBuilderBase::getIntPtrTy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167111 91177308-0d34-0410-b5e6-96231b3b80d8 Evgeniy Stepanov 7 years ago
2 changed file(s) with 17 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1616
1717 #include "llvm/Instructions.h"
1818 #include "llvm/BasicBlock.h"
19 #include "llvm/DataLayout.h"
1920 #include "llvm/LLVMContext.h"
2021 #include "llvm/ADT/ArrayRef.h"
2122 #include "llvm/ADT/StringRef.h"
263264
264265 PointerType *getInt8PtrTy(unsigned AddrSpace = 0) {
265266 return Type::getInt8PtrTy(Context, AddrSpace);
267 }
268
269 IntegerType* getIntPtrTy(DataLayout *DL, unsigned AddrSpace = 0) {
270 return DL->getIntPtrType(Context, AddrSpace);
266271 }
267272
268273 //===--------------------------------------------------------------------===//
77 //===----------------------------------------------------------------------===//
88
99 #include "llvm/BasicBlock.h"
10 #include "llvm/DataLayout.h"
1011 #include "llvm/Function.h"
1112 #include "llvm/IRBuilder.h"
1213 #include "llvm/IntrinsicInst.h"
9596 EXPECT_EQ(Weights, TI->getMetadata(LLVMContext::MD_prof));
9697 }
9798
99 TEST_F(IRBuilderTest, GetIntTy) {
100 IRBuilder<> Builder(BB);
101 IntegerType *Ty1 = Builder.getInt1Ty();
102 EXPECT_EQ(Ty1, IntegerType::get(getGlobalContext(), 1));
103
104 DataLayout* DL = new DataLayout(M.get());
105 IntegerType *IntPtrTy = Builder.getIntPtrTy(DL);
106 unsigned IntPtrBitSize = DL->getPointerSizeInBits(0);
107 EXPECT_EQ(IntPtrTy, IntegerType::get(getGlobalContext(), IntPtrBitSize));
98108 }
109
110 }