summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
diff options
context:
space:
mode:
authorJames Y Knight <jyknight@google.com>2019-01-13 16:09:28 +0000
committerJames Y Knight <jyknight@google.com>2019-01-13 16:09:28 +0000
commitc0044118c8ec4889ff1490179d5d70549cb7621c (patch)
tree603011e7fc7b0e9f30d4446f96262726a0addb37 /llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
parent06e3950561a5cd59b1295ed66071c8a53af8067a (diff)
downloadbcm5719-llvm-c0044118c8ec4889ff1490179d5d70549cb7621c.tar.gz
bcm5719-llvm-c0044118c8ec4889ff1490179d5d70549cb7621c.zip
Remove TypeBuilder.h, and fix the few locations using it.
This shortcut mechanism for creating types was added 10 years ago, but has seen almost no uptake since then, neither internally nor in external projects. The very small number of characters saved by using it does not seem worth the mental overhead of an additional type-creation API, so, delete it. Differential Revision: https://reviews.llvm.org/D56573 llvm-svn: 351020
Diffstat (limited to 'llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h')
-rw-r--r--llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h60
1 files changed, 28 insertions, 32 deletions
diff --git a/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h b/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
index a768920ff47..50a57f141f4 100644
--- a/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
+++ b/llvm/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
@@ -24,7 +24,7 @@
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
-#include "llvm/IR/TypeBuilder.h"
+#include "llvm/IR/Type.h"
#include "llvm/Support/CodeGen.h"
namespace llvm {
@@ -45,11 +45,9 @@ protected:
return M;
}
- template<typename FuncType>
- Function *startFunction(Module *M, StringRef Name) {
- Function *Result = Function::Create(
- TypeBuilder<FuncType, false>::get(Context),
- GlobalValue::ExternalLinkage, Name, M);
+ Function *startFunction(Module *M, FunctionType *FT, StringRef Name) {
+ Function *Result =
+ Function::Create(FT, GlobalValue::ExternalLinkage, Name, M);
BasicBlock *BB = BasicBlock::Create(Context, Name, Result);
Builder.SetInsertPoint(BB);
@@ -63,9 +61,8 @@ protected:
// Inserts a simple function that invokes Callee and takes the same arguments:
// int Caller(...) { return Callee(...); }
- template<typename Signature>
Function *insertSimpleCallFunction(Module *M, Function *Callee) {
- Function *Result = startFunction<Signature>(M, "caller");
+ Function *Result = startFunction(M, Callee->getFunctionType(), "caller");
SmallVector<Value*, 1> CallArgs;
@@ -81,7 +78,8 @@ protected:
// int32_t main() { return X; }
// where X is given by returnCode
Function *insertMainFunction(Module *M, uint32_t returnCode) {
- Function *Result = startFunction<int32_t(void)>(M, "main");
+ Function *Result = startFunction(
+ M, FunctionType::get(Type::getInt32Ty(Context), {}, false), "main");
Value *ReturnVal = ConstantInt::get(Context, APInt(32, returnCode));
endFunctionWithRet(Result, ReturnVal);
@@ -93,7 +91,12 @@ protected:
// int32_t add(int32_t a, int32_t b) { return a + b; }
// in the current module and returns a pointer to it.
Function *insertAddFunction(Module *M, StringRef Name = "add") {
- Function *Result = startFunction<int32_t(int32_t, int32_t)>(M, Name);
+ Function *Result = startFunction(
+ M,
+ FunctionType::get(
+ Type::getInt32Ty(Context),
+ {Type::getInt32Ty(Context), Type::getInt32Ty(Context)}, false),
+ Name);
Function::arg_iterator args = Result->arg_begin();
Value *Arg1 = &*args;
@@ -106,20 +109,10 @@ protected:
}
// Inserts a declaration to a function defined elsewhere
- template <typename FuncType>
- Function *insertExternalReferenceToFunction(Module *M, StringRef Name) {
- Function *Result = Function::Create(
- TypeBuilder<FuncType, false>::get(Context),
- GlobalValue::ExternalLinkage, Name, M);
- return Result;
- }
-
- // Inserts an declaration to a function defined elsewhere
- Function *insertExternalReferenceToFunction(Module *M, StringRef Name,
- FunctionType *FuncTy) {
- Function *Result = Function::Create(FuncTy,
- GlobalValue::ExternalLinkage,
- Name, M);
+ Function *insertExternalReferenceToFunction(Module *M, FunctionType *FTy,
+ StringRef Name) {
+ Function *Result =
+ Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M);
return Result;
}
@@ -136,7 +129,7 @@ protected:
GlobalVariable *insertGlobalInt32(Module *M,
StringRef name,
int32_t InitialValue) {
- Type *GlobalTy = TypeBuilder<types::i<32>, true>::get(Context);
+ Type *GlobalTy = Type::getInt32Ty(Context);
Constant *IV = ConstantInt::get(Context, APInt(32, InitialValue));
GlobalVariable *Global = new GlobalVariable(*M,
GlobalTy,
@@ -160,7 +153,11 @@ protected:
Function *insertAccumulateFunction(Module *M,
Function *Helper = nullptr,
StringRef Name = "accumulate") {
- Function *Result = startFunction<int32_t(int32_t)>(M, Name);
+ Function *Result =
+ startFunction(M,
+ FunctionType::get(Type::getInt32Ty(Context),
+ {Type::getInt32Ty(Context)}, false),
+ Name);
if (!Helper)
Helper = Result;
@@ -225,11 +222,11 @@ protected:
B.reset(createEmptyModule("B"));
Function *FAExtern_in_B = insertExternalReferenceToFunction(B.get(), FA);
- FB = insertSimpleCallFunction<int32_t(int32_t, int32_t)>(B.get(), FAExtern_in_B);
+ FB = insertSimpleCallFunction(B.get(), FAExtern_in_B);
C.reset(createEmptyModule("C"));
Function *FBExtern_in_C = insertExternalReferenceToFunction(C.get(), FB);
- FC = insertSimpleCallFunction<int32_t(int32_t, int32_t)>(C.get(), FBExtern_in_C);
+ FC = insertSimpleCallFunction(C.get(), FBExtern_in_C);
}
// Module A { Function FA },
@@ -253,8 +250,7 @@ protected:
B.reset(createEmptyModule("B"));
Function *FAExtern_in_B = insertExternalReferenceToFunction(B.get(), FA);
- FB = insertSimpleCallFunction<int32_t(int32_t, int32_t)>(B.get(),
- FAExtern_in_B);
+ FB = insertSimpleCallFunction(B.get(), FAExtern_in_B);
}
// Module A { Function FA },
@@ -268,11 +264,11 @@ protected:
B.reset(createEmptyModule("B"));
Function *FAExtern_in_B = insertExternalReferenceToFunction(B.get(), FA);
- FB = insertSimpleCallFunction<int32_t(int32_t, int32_t)>(B.get(), FAExtern_in_B);
+ FB = insertSimpleCallFunction(B.get(), FAExtern_in_B);
C.reset(createEmptyModule("C"));
Function *FAExtern_in_C = insertExternalReferenceToFunction(C.get(), FA);
- FC = insertSimpleCallFunction<int32_t(int32_t, int32_t)>(C.get(), FAExtern_in_C);
+ FC = insertSimpleCallFunction(C.get(), FAExtern_in_C);
}
};
OpenPOWER on IntegriCloud