11#ifndef PROTEUS_TRANSFORM_ARGUMENT_SPECIALIZATION_HPP
12#define PROTEUS_TRANSFORM_ARGUMENT_SPECIALIZATION_HPP
14#include <llvm/IR/IRBuilder.h>
15#include <llvm/Support/Debug.h>
31 T *
TypedPtr =
reinterpret_cast<T *
>(
RC.ArrInfo.Blob.get());
32 if (
RC.ArrInfo.NumElts <= 0)
34 std::to_string(
RC.ArrInfo.NumElts));
42 switch (
RC.ArrInfo.EltType) {
48 return ConstantDataArray::get(M.getContext(),
51 return ConstantDataArray::get(M.getContext(),
66 switch (
RC.ArrInfo.EltType) {
68 return ConstantDataVector::get(M.getContext(),
71 return ConstantDataVector::get(M.getContext(),
74 return ConstantDataVector::get(M.getContext(),
79 return ConstantDataVector::get(M.getContext(),
90 auto &Ctx = M.getContext();
101 C = ConstantInt::get(
ArgType,
RC.Value.BoolVal);
105 C = ConstantInt::get(
ArgType,
RC.Value.Int8Val);
109 C = ConstantInt::get(
ArgType,
RC.Value.Int32Val);
113 C = ConstantInt::get(
ArgType,
RC.Value.Int64Val);
118 C = ConstantFP::get(
ArgType,
RC.Value.FloatVal);
122 C = ConstantFP::get(
ArgType,
RC.Value.DoubleVal);
129 C = ConstantFP::get(
ArgType,
RC.Value.LongDoubleVal);
133 auto *
IntC = ConstantInt::get(Type::getInt64Ty(Ctx),
RC.Value.Int64Val);
141 M,
CDA->getType(),
true, GlobalValue::PrivateLinkage,
CDA);
148 C = createConstantDataArray(M,
RC);
152 C = createConstantDataVector(M,
RC);
157 StringRef{
reinterpret_cast<const char *
>(
RC.ObjInfo.Blob.get()),
158 static_cast<size_t>(
RC.ObjInfo.Size)},
159 RC.ObjInfo.Size, Type::getInt8Ty(M.getContext()));
162 M,
CDA->getType(),
true, GlobalValue::PrivateLinkage,
CDA);
165 C = ConstantExpr::getPointerBitCastOrAddrSpaceCast(
GV,
ArgType);
180 OS <<
"[ArgSpec] Replaced Function " << F.getName() <<
" ArgNo "
181 <<
ArgNo <<
" with value " << *
C->stripPointerCasts() <<
"\n";
189 Arg->replaceAllUsesWith(
C);
#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
@ ARRAY
Definition CompilerInterfaceTypes.h:33
@ VECTOR
Definition CompilerInterfaceTypes.h:32
@ INT32
Definition CompilerInterfaceTypes.h:25
@ INT64
Definition CompilerInterfaceTypes.h:26
@ FLOAT
Definition CompilerInterfaceTypes.h:27
@ STATIC_ARRAY
Definition CompilerInterfaceTypes.h:31
@ LONG_DOUBLE
Definition CompilerInterfaceTypes.h:29
@ INT8
Definition CompilerInterfaceTypes.h:24
@ BOOL
Definition CompilerInterfaceTypes.h:23
@ OBJECT
Definition CompilerInterfaceTypes.h:34
@ PTR
Definition CompilerInterfaceTypes.h:30
@ DOUBLE
Definition CompilerInterfaceTypes.h:28
T getRuntimeConstantValue(void *Arg)
Definition CompilerInterfaceRuntimeConstantInfo.h:114
std::string toString(CodegenOption Option)
Definition Config.hpp:26
Definition CompilerInterfaceTypes.h:72