11#ifndef PROTEUS_TRANSFORM_LAMBDA_SPECIALIZATION_HPP
12#define PROTEUS_TRANSFORM_LAMBDA_SPECIALIZATION_HPP
14#include <llvm/Demangle/Demangle.h>
15#include <llvm/IR/IRBuilder.h>
16#include <llvm/IR/Instructions.h>
17#include <llvm/Support/Casting.h>
18#include <llvm/Support/Debug.h>
32 return ConstantInt::get(
ArgType,
RC.Value.BoolVal);
34 return ConstantInt::get(
ArgType,
RC.Value.Int8Val);
36 return ConstantInt::get(
ArgType,
RC.Value.Int32Val);
38 return ConstantInt::get(
ArgType,
RC.Value.Int64Val);
40 return ConstantFP::get(
ArgType,
RC.Value.FloatVal);
42 return ConstantFP::get(
ArgType,
RC.Value.DoubleVal);
44 return ConstantFP::get(
ArgType,
RC.Value.LongDoubleVal);
46 auto *
IntC = ConstantInt::get(Type::getInt64Ty(Ctx),
RC.Value.Int64Val);
62 for (
auto &
Arg : RCVec) {
63 if (
Arg.Offset == Offset)
71 for (
auto &
Arg : RCVec) {
78 static auto traceOut(
int Slot,
Constant *
C) {
81 OS <<
"[LambdaSpec] Replacing slot " << Slot <<
" with " << *
C <<
"\n";
88 auto *
Arg = findArgByPos(RCVec, 0);
93 User->replaceAllUsesWith(
C);
103 int Slot =
CI->getZExtValue();
104 Type *
SrcTy =
GEP->getSourceElementType();
106 auto *
Arg =
SrcTy->isStructTy() ? findArgByPos(RCVec, Slot)
107 : findArgByOffset(RCVec, Slot);
117 LI->replaceAllUsesWith(
C);
129 <<
"[LambdaSpec] Function: " << F.getName() <<
" RCVec size "
130 << RCVec.size() <<
"\n");
132 <<
"TransformLambdaSpecialization::transform" <<
"\n");
135 for (
auto &
Arg : RCVec) {
137 <<
"{" <<
Arg.Value.Int64Val <<
", " <<
Arg.Pos <<
" }\n";
145 handleLoad(M,
User, RCVec);
147 handleGEP(M,
GEP,
User, RCVec);
#define PROTEUS_DBG(x)
Definition Debug.h:9
#define PROTEUS_FATAL_ERROR(x)
Definition Error.h:7
static Config & get()
Definition Config.hpp:304
static void trace(llvm::StringRef Msg)
Definition Logger.hpp:30
static llvm::raw_ostream & logs(const std::string &Name)
Definition Logger.hpp:19
Definition BuiltinsCUDA.cpp:4
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
T getRuntimeConstantValue(void *Arg)
Definition CompilerInterfaceRuntimeConstantInfo.h:114
Constant * getConstant(LLVMContext &Ctx, Type *ArgType, const RuntimeConstant &RC)
Definition TransformLambdaSpecialization.hpp:28
Definition CompilerInterfaceTypes.h:72