11#ifndef PROTEUS_TRANSFORM_LAMBDA_SPECIALIZATION_HPP
12#define PROTEUS_TRANSFORM_LAMBDA_SPECIALIZATION_HPP
18#include <llvm/Demangle/Demangle.h>
19#include <llvm/IR/IRBuilder.h>
20#include <llvm/IR/Instructions.h>
21#include <llvm/IR/Module.h>
22#include <llvm/Support/Casting.h>
23#include <llvm/Support/Debug.h>
33 return ConstantInt::get(
ArgType,
RC.Value.BoolVal);
35 return ConstantInt::get(
ArgType,
RC.Value.Int8Val);
37 return ConstantInt::get(
ArgType,
RC.Value.Int32Val);
39 return ConstantInt::get(
ArgType,
RC.Value.Int64Val);
41 return ConstantFP::get(
ArgType,
RC.Value.FloatVal);
43 return ConstantFP::get(
ArgType,
RC.Value.DoubleVal);
45 return ConstantFP::get(
ArgType,
RC.Value.LongDoubleVal);
47 auto *
IntC = ConstantInt::get(Type::getInt64Ty(Ctx),
RC.Value.Int64Val);
63 for (
auto &
Arg : RCVec) {
64 if (
Arg.Offset == Offset)
72 for (
auto &
Arg : RCVec) {
79 static auto traceOut(
int Slot,
Constant *
C) {
82 OS <<
"[LambdaSpec] Replacing slot " << Slot <<
" with " << *
C <<
"\n";
89 auto *
Arg = findArgByPos(RCVec, 0);
94 User->replaceAllUsesWith(
C);
104 int Slot =
CI->getZExtValue();
105 Type *
SrcTy =
GEP->getSourceElementType();
107 auto *
Arg =
SrcTy->isStructTy() ? findArgByPos(RCVec, Slot)
108 : findArgByOffset(RCVec, Slot);
118 LI->replaceAllUsesWith(
C);
130 <<
"[LambdaSpec] Function: " << F.getName() <<
" RCVec size "
131 << RCVec.size() <<
"\n");
133 <<
"TransformLambdaSpecialization::transform" <<
"\n");
136 for (
auto &
Arg : RCVec) {
138 <<
"{" <<
Arg.Value.Int64Val <<
", " <<
Arg.Pos <<
" }\n";
146 handleLoad(M,
User, RCVec);
148 handleGEP(M,
GEP,
User, RCVec);
#define PROTEUS_DBG(x)
Definition Debug.h:9
static Config & get()
Definition Config.hpp:300
static void trace(llvm::StringRef Msg)
Definition Logger.hpp:30
static llvm::raw_ostream & logs(const std::string &Name)
Definition Logger.hpp:19
Definition ObjectCacheChain.cpp:26
static int Pos
Definition JitInterface.hpp:105
@ INT32
Definition CompilerInterfaceTypes.h:25
@ INT64
Definition CompilerInterfaceTypes.h:26
@ FLOAT
Definition CompilerInterfaceTypes.h:27
@ LONG_DOUBLE
Definition CompilerInterfaceTypes.h:29
@ INT8
Definition CompilerInterfaceTypes.h:24
@ BOOL
Definition CompilerInterfaceTypes.h:23
@ PTR
Definition CompilerInterfaceTypes.h:30
@ DOUBLE
Definition CompilerInterfaceTypes.h:28
void reportFatalError(const llvm::Twine &Reason, const char *FILE, unsigned Line)
Definition Error.cpp:14
T getRuntimeConstantValue(void *Arg)
Definition CompilerInterfaceRuntimeConstantInfo.h:113
Constant * getConstant(LLVMContext &Ctx, Type *ArgType, const RuntimeConstant &RC)
Definition TransformLambdaSpecialization.hpp:29
Definition CompilerInterfaceTypes.h:72