20#include "llvm/ADT/StringExtras.h"
21#include "llvm/ADT/Twine.h"
22#include "llvm/IR/Type.h"
23#include "llvm/Support/raw_ostream.h"
26using namespace CodeGen;
29 raw_ostream &OS = llvm::errs();
30 OS <<
"(ABIArgInfo Kind=";
62 OS <<
"CoerceAndExpand Type=";
70 : Info(
std::move(Info)) {}
116 return llvm::CallingConv::SPIR_KERNEL;
120 llvm::PointerType *T,
QualType QT)
const {
121 return llvm::ConstantPointerNull::get(T);
128 "Address space agnostic languages only");
134 LangAS DestAddr, llvm::Type *DestTy,
bool isNonNull)
const {
137 if (
auto *
C = dyn_cast<llvm::Constant>(Src))
141 Src, DestTy, Src->hasName() ? Src->getName() +
".ascast" :
"");
147 llvm::Type *DestTy)
const {
150 return llvm::ConstantExpr::getPointerCast(Src, DestTy);
156 llvm::AtomicOrdering Ordering,
157 llvm::LLVMContext &Ctx)
const {
158 return Ctx.getOrInsertSyncScopeID(
"");
163 if (llvm::Function *Fn = dyn_cast_or_null<llvm::Function>(GV)) {
165 Fn->addFnAttr(
"stack-probe-size",
168 Fn->addFnAttr(
"no-stack-arg-probe");
178 CodeGenFunction &CGF, llvm::Function *Invoke, llvm::Type *BlockTy)
const {
179 auto *InvokeFT = Invoke->getFunctionType();
181 std::string Name = Invoke->getName().str() +
"_kernel";
182 auto *FT = llvm::FunctionType::get(llvm::Type::getVoidTy(
C),
183 InvokeFT->params(),
false);
184 auto *F = llvm::Function::Create(FT, llvm::GlobalValue::ExternalLinkage, Name,
186 llvm::CallingConv::ID KernelCC =
188 F->setCallingConv(KernelCC);
190 llvm::AttrBuilder KernelAttrs(
C);
194 F->addFnAttrs(KernelAttrs);
196 auto IP = CGF.
Builder.saveIP();
197 auto *BB = llvm::BasicBlock::Create(
C,
"entry", F);
199 Builder.SetInsertPoint(BB);
201 llvm::CallInst *Call = Builder.CreateCall(Invoke, Args);
202 Call->setCallingConv(Invoke->getCallingConv());
204 Builder.CreateRetVoid();
205 Builder.restoreIP(IP);
217std::unique_ptr<TargetCodeGenInfo>
219 return std::make_unique<DefaultTargetCodeGenInfo>(CGM.
getTypes());
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
unsigned getInAllocaFieldIndex() const
bool getIndirectByVal() const
llvm::StructType * getCoerceAndExpandType() const
bool getIndirectRealign() const
unsigned getIndirectAddrSpace() const
@ Extend
Extend - Valid only for integer argument types.
@ Ignore
Ignore - Ignore the argument (treat as void).
@ IndirectAliased
IndirectAliased - Similar to Indirect, but the pointer may be to an object that is otherwise referenc...
@ Expand
Expand - Only valid for aggregate argument types.
@ InAlloca
InAlloca - Pass the argument directly using the LLVM inalloca attribute.
@ Indirect
Indirect - Pass the argument indirectly via a hidden pointer with the specified alignment (0 indicate...
@ CoerceAndExpand
CoerceAndExpand - Only valid for aggregate argument types.
@ Direct
Direct - Pass the argument directly using the normal converted LLVM type, or by coercing to another s...
llvm::Type * getCoerceToType() const
CharUnits getIndirectAlign() const
Address CreatePointerBitCastOrAddrSpaceCast(Address Addr, llvm::Type *Ty, llvm::Type *ElementTy, const llvm::Twine &Name="")
CallArgList - Type for representing both the value and type of arguments in a call.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
CodeGenTypes & getTypes() const
llvm::LLVMContext & getLLVMContext()
This class organizes the cross-function state that is used while generating LLVM code.
llvm::Module & getModule() const
const LangOptions & getLangOpts() const
CodeGenTypes & getTypes()
const CodeGenOptions & getCodeGenOpts() const
void addDefaultFunctionDefinitionAttributes(llvm::AttrBuilder &attrs)
Like the overload taking a Function &, but intended specifically for frontends that want to build on ...
This class organizes the cross-module state that is used while lowering AST types to LLVM types.
unsigned ClangCallConvToLLVMCallConv(CallingConv CC)
Convert clang calling convention to LLVM callilng convention.
DefaultABIInfo - The default implementation for ABI specific details.
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
virtual unsigned getSizeOfUnwindException() const
Determines the size of struct _Unwind_Exception on this platform, in 8-bit units.
virtual void getDependentLibraryOption(llvm::StringRef Lib, llvm::SmallString< 24 > &Opt) const
Gets the linker options necessary to link a dependent library on this platform.
virtual llvm::SyncScope::ID getLLVMSyncScopeID(const LangOptions &LangOpts, SyncScope Scope, llvm::AtomicOrdering Ordering, llvm::LLVMContext &Ctx) const
Get the syncscope used in LLVM IR.
virtual unsigned getOpenCLKernelCallingConv() const
Get LLVM calling convention for OpenCL kernel.
virtual LangAS getGlobalVarAddressSpace(CodeGenModule &CGM, const VarDecl *D) const
Get target favored AST address space of a global variable for languages other than OpenCL and CUDA.
virtual llvm::Value * performAddrSpaceCast(CodeGen::CodeGenFunction &CGF, llvm::Value *V, LangAS SrcAddr, LangAS DestAddr, llvm::Type *DestTy, bool IsNonNull=false) const
Perform address space cast of an expression of pointer type.
void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const
virtual llvm::Constant * getNullPointer(const CodeGen::CodeGenModule &CGM, llvm::PointerType *T, QualType QT) const
Get target specific null pointer.
TargetCodeGenInfo(std::unique_ptr< ABIInfo > Info)
virtual llvm::Value * createEnqueuedBlockKernel(CodeGenFunction &CGF, llvm::Function *BlockInvokeFunc, llvm::Type *BlockTy) const
Create an OpenCL kernel for an enqueued block.
virtual ~TargetCodeGenInfo()
virtual bool isNoProtoCallVariadic(const CodeGen::CallArgList &args, const FunctionNoProtoType *fnType) const
Determine whether a call to an unprototyped functions under the given calling convention should use t...
Decl - This represents one declaration (or definition), e.g.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A (possibly-)qualified type.
LangAS getAddressSpace() const
Return the address space of this type.
Scope - A scope is a transient data structure that is used while parsing the program.
Represents a variable declaration or definition.
std::unique_ptr< TargetCodeGenInfo > createDefaultTargetCodeGenInfo(CodeGenModule &CGM)
@ C
Languages that the frontend can parse and compile.
LangAS
Defines the address space values used by the address space qualifier of QualType.
SyncScope
Defines synch scope values used internally by clang.