12#include "llvm/IR/Module.h"
20 llvm::StringRef
Str) {
26 return Builder.CreateGlobalStringPtr(
Str,
"", 4);
30 Module *
M = Builder.GetInsertBlock()->getParent()->getParent();
31 const char *Name =
"vprintf";
35 GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
36 FunctionType *Ty = FunctionType::get(
37 Builder.getInt32Ty(), {Builder.getPtrTy(), Builder.getPtrTy()},
false);
38 F = Function::Create(Ty, Linkage, Name,
M);
45 ArrayRef<Value *> Values) {
50 if (Ty->isFloatingPointTy())
53 if (Ty->isIntegerTy())
54 return Ty->getIntegerBitWidth() <= 64;
56 if (isa<PointerType>(Ty))
62static std::tuple<std::string, std::vector<Value *>>
64 std::string FormatString;
65 std::vector<Value *> ValuesToPrint;
67 for (
auto Val : Values) {
68 Type *Ty = Val->getType();
70 if (Ty->isFloatingPointTy()) {
71 if (!Ty->isDoubleTy())
72 Val = Builder.CreateFPExt(Val, Builder.getDoubleTy());
73 }
else if (Ty->isIntegerTy()) {
74 if (Ty->getIntegerBitWidth() < 64)
75 Val = Builder.CreateSExt(Val, Builder.getInt64Ty());
77 assert(Ty->getIntegerBitWidth() &&
78 "Integer types larger 64 bit not supported");
79 }
else if (isa<PointerType>(Ty)) {
80 if (Ty == Builder.getPtrTy(4)) {
81 Val = Builder.CreateGEP(Builder.getInt8Ty(), Val, Builder.getInt64(0));
83 Val = Builder.CreatePtrToInt(Val, Builder.getInt64Ty());
86 llvm_unreachable(
"Unknown type");
91 if (Ty->isFloatingPointTy())
93 else if (Ty->isIntegerTy())
94 FormatString +=
"%ld";
98 ValuesToPrint.push_back(Val);
101 return std::make_tuple(FormatString, ValuesToPrint);
105 ArrayRef<Value *> Values) {
107 std::string FormatString;
108 std::vector<Value *> ValuesToPrint;
110 std::tie(FormatString, ValuesToPrint) =
118 Module *
M = Builder.GetInsertBlock()->getParent()->getParent();
119 const char *Name =
"printf";
123 GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
124 FunctionType *Ty = FunctionType::get(Builder.getInt32Ty(),
true);
125 F = Function::Create(Ty, Linkage, Name,
M);
133 ArrayRef<Value *> Values) {
134 Value *FormatString = Builder.CreateGlobalStringPtr(Format);
135 std::vector<Value *> Arguments;
137 Arguments.push_back(FormatString);
138 Arguments.insert(Arguments.end(), Values.begin(), Values.end());
139 Builder.CreateCall(
getPrintF(Builder), Arguments);
143 Module *
M = Builder.GetInsertBlock()->getParent()->getParent();
144 const char *Name =
"fflush";
148 GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
150 FunctionType::get(Builder.getInt32Ty(), Builder.getPtrTy(),
false);
151 F = Function::Create(Ty, Linkage, Name,
M);
160 Builder.CreateCall(F, Constant::getNullValue(F->arg_begin()->getType()));
polly dump Polly Dump Function
polly dump Polly Dump Module
static std::tuple< std::string, std::vector< Value * > > prepareValuesForPrinting(PollyIRBuilder &Builder, ArrayRef< Value * > Values)
static RegisterPass< ScopPrinterWrapperPass > M("dot-scops", "Polly - Print Scops of function")
This file contains the declaration of the PolyhedralInfo class, which will provide an interface to ex...
@ Value
MemoryKind::Value: Models an llvm::Value.
llvm::IRBuilder< llvm::ConstantFolder, IRInserter > PollyIRBuilder
static void createCPUPrinterT(PollyIRBuilder &Builder, llvm::ArrayRef< llvm::Value * > Values)
Print a list of Values on a CPU.
static void createPrinter(PollyIRBuilder &Builder, std::vector< llvm::Value * > &Values, llvm::Value *Value, Args... args)
Handle Values.
static void createFlush(PollyIRBuilder &Builder)
Call fflush.
static llvm::Function * getPrintF(PollyIRBuilder &Builder)
Get a reference to the 'printf' function.
static void createPrintF(PollyIRBuilder &Builder, std::string Format, llvm::ArrayRef< llvm::Value * > Values)
Call printf.
static llvm::Function * getVPrintF(PollyIRBuilder &Builder)
Get (and possibly insert) a vprintf declaration into the module.
static bool isPrintable(llvm::Type *Ty)
Return whether an llvm::Value of the type Ty is printable for debugging.
static llvm::Value * getPrintableString(PollyIRBuilder &Builder, llvm::StringRef Str)
Generate a constant string into the builder's llvm::Module which can be passed to createCPUPrinter().