10#include "TargetInfo.h"
41 Arg.info = classifyArgumentType(Arg.type);
54 std::make_unique<SwiftABIInfo>(CGT,
false);
60 if (
const auto *FD = dyn_cast_or_null<FunctionDecl>(D)) {
61 if (
const auto *
Attr = FD->getAttr<WebAssemblyImportModuleAttr>()) {
62 llvm::Function *Fn = cast<llvm::Function>(GV);
63 llvm::AttrBuilder B(GV->getContext());
64 B.addAttribute(
"wasm-import-module",
Attr->getImportModule());
67 if (
const auto *
Attr = FD->getAttr<WebAssemblyImportNameAttr>()) {
68 llvm::Function *Fn = cast<llvm::Function>(GV);
69 llvm::AttrBuilder B(GV->getContext());
70 B.addAttribute(
"wasm-import-name",
Attr->getImportName());
73 if (
const auto *
Attr = FD->getAttr<WebAssemblyExportNameAttr>()) {
74 llvm::Function *Fn = cast<llvm::Function>(GV);
75 llvm::AttrBuilder B(GV->getContext());
76 B.addAttribute(
"wasm-export-name",
Attr->getExportName());
81 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(D)) {
82 llvm::Function *Fn = cast<llvm::Function>(GV);
83 if (!FD->doesThisDeclarationHaveABody() && !FD->hasPrototype())
84 Fn->addFnAttr(
"no-prototype");
90 return llvm::Type::getWasm_ExternrefTy(
getABIInfo().getVMContext());
94 return llvm::Type::getWasm_FuncrefTy(
getABIInfo().getVMContext());
116 if (Kind == WebAssemblyABIKind::ExperimentalMV) {
119 bool HasBitField =
false;
121 if (
Field->isBitField()) {
132 return defaultInfo.classifyArgumentType(Ty);
149 if (Kind == WebAssemblyABIKind::ExperimentalMV)
155 return defaultInfo.classifyReturnType(RetTy);
169std::unique_ptr<TargetCodeGenInfo>
172 return std::make_unique<WebAssemblyTargetCodeGenInfo>(CGM.
getTypes(), K);
WebAssemblyABIInfo(CodeGen::CodeGenTypes &CGT, WebAssemblyABIKind Kind)
virtual llvm::Type * getWasmFuncrefReferenceType() const override
Return the WebAssembly funcref reference type.
virtual llvm::Type * getWasmExternrefReferenceType() const override
Return the WebAssembly externref reference type.
void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const override
setTargetAttributes - Provides a convenient hook to handle extra target-specific attributes for the g...
WebAssemblyTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, WebAssemblyABIKind K)
Attr - This represents one attribute.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
static ABIArgInfo getIgnore()
static ABIArgInfo getExpand()
static ABIArgInfo getDirect(llvm::Type *T=nullptr, unsigned Offset=0, llvm::Type *Padding=nullptr, bool CanBeFlattened=true, unsigned Align=0)
ABIInfo - Target specific hooks for defining how a type should be passed or returned from functions.
CodeGen::CodeGenTypes & CGT
CodeGen::CGCXXABI & getCXXABI() const
ASTContext & getContext() const
CodeGen::ABIArgInfo getNaturalAlignIndirect(QualType Ty, bool ByVal=true, bool Realign=false, llvm::Type *Padding=nullptr) const
A convenience method to return an indirect ABIArgInfo with an expected alignment equal to the ABI ali...
@ RAA_DirectInMemory
Pass it on the stack using its defined layout.
CGFunctionInfo - Class to encapsulate the information about a function definition.
ABIArgInfo & getReturnInfo()
CanQualType getReturnType() const
MutableArrayRef< ArgInfo > arguments()
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
CodeGenTypes & getTypes()
This class organizes the cross-module state that is used while lowering AST types to LLVM types.
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
DefaultABIInfo - The default implementation for ABI specific details.
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
std::unique_ptr< SwiftABIInfo > SwiftInfo
const T & getABIInfo() const
virtual void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M) const
setTargetAttributes - Provides a convenient hook to handle extra target-specific attributes for the g...
Decl - This represents one declaration (or definition), e.g.
A (possibly-)qualified type.
field_range fields() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
The base class of the type hierarchy.
const T * getAs() const
Member-template getAs<specific type>'.
CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT, CGCXXABI &CXXABI)
std::unique_ptr< TargetCodeGenInfo > createWebAssemblyTargetCodeGenInfo(CodeGenModule &CGM, WebAssemblyABIKind K)
Address emitVoidPtrVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType ValueTy, bool IsIndirect, TypeInfoChars ValueInfo, CharUnits SlotSizeAndAlign, bool AllowHigherAlign, bool ForceRightAdjust=false)
Emit va_arg for a platform using the common void* representation, where arguments are simply emitted ...
bool isAggregateTypeForABI(QualType T)
const Type * isSingleElementStruct(QualType T, ASTContext &Context)
isSingleElementStruct - Determine if a structure is a "single element struct", i.e.
QualType useFirstFieldIfTransparentUnion(QualType Ty)
Pass transparent unions as if they were the type of the first element.
bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays, bool AsIfNoUniqueAddr=false)
isEmptyRecord - Return true iff a structure contains only empty fields.