|
clang 24.0.0git
|
#include "CIRABIClassifier.h"#include "TargetLowering/CIRABIRewriteContext.h"#include "mlir/ABI/Targets/Test/TestTarget.h"#include "clang/CIR/Dialect/IR/CIRDialect.h"#include "clang/CIR/MissingFeatures.h"#include "llvm/ABI/Types.h"#include "llvm/ADT/TypeSwitch.h"#include "llvm/Support/MathExtras.h"Go to the source code of this file.
Functions | |
| static bool | recordCanPassInRegs (ModuleOp modOp, cir::RecordType recTy) |
| Whether a struct's declared argument-passing kind (from the module's record-layout metadata) allows it to be passed in registers. | |
| static bool | recordIsTransparentUnion (ModuleOp modOp, cir::RecordType recTy) |
| static bool | mayReachSseUp (mlir::Type ty, const DataLayout &dl) |
| Whether the classifier could give this type the SSEUP class, looking through arrays and records at the types they hold. | |
| static bool | sseUpCoerceSizeUnsupported (uint64_t recordBits, llvm::ArrayRef< mlir::Type > members, const DataLayout &dl) |
| Whether the record's size has no SSEUP coerce. | |
| static bool | memberIsEmptyRecord (mlir::Type ty) |
| Whether a member is an empty record, looking through arrays, since an array of empty records supplies no bytes either. | |
| static llvm::Align | recordDeclaredAlign (ModuleOp modOp, cir::RecordType recTy, const DataLayout &dl) |
| A record's declared alignment, which the ABI uses for the byval and sret alignment of an indirect argument. | |
| static llvm::Align | recordUnadjustedAlign (ModuleOp modOp, cir::RecordType recTy, const DataLayout &dl) |
| A record's unadjusted alignment, the alignment its members give it before an alignment attribute on the record raises it. | |
| static bool | isSupportedType (mlir::Type ty, const DataLayout &dl) |
| The CIR types the bridge handles. | |
| static mlir::Type | abiTypeToCIR (const llvm::abi::Type *ty, MLIRContext *ctx) |
| Convert an llvm::abi::Type coercion type back to a CIR type. | |
| static mlir::Type | unwrapLongDoubleVectorElement (mlir::Type ty) |
Returns ty with a LongDoubleType vector element replaced by its underlying format, which is the element abiTypeToCIR builds for the same float. | |
| static const llvm::abi::Type * | mapCIRType (mlir::Type type, mlir::abi::ABITypeMapper &typeMapper, const DataLayout &dl, ModuleOp modOp) |
| Map a CIR type to an llvm::abi::Type. | |
| static bool | coerceKeepsScalarValue (mlir::Type origTy, const llvm::abi::Type *coercedAbiTy) |
Whether coercedAbiTy holds the same value as the scalar origTy: an integer of the same width, a float with the same semantics, or a pointer. | |
| static mlir::FailureOr< ArgClassification > | convertDirectArgInfo (const llvm::abi::ArgInfo &info, MLIRContext *ctx, mlir::Type origTy) |
| Convert a Direct llvm::abi::ArgInfo. | |
| static mlir::FailureOr< ArgClassification > | convertABIArgInfo (const llvm::abi::ArgInfo &info, MLIRContext *ctx, mlir::Type origTy) |
| Convert an llvm::abi::ArgInfo into the ArgClassification consumed by CIRABIRewriteContext. | |
| static llvm::abi::RequiredArgs | requiredArgs (cir::FuncType fnTy) |
Where fnTy's declared parameters end and its ellipsis arguments begin. | |
| static mlir::FailureOr< FunctionClassification > | withReturnVoidness (mlir::FailureOr< FunctionClassification > fc, mlir::Type returnType) |
Record on fc whether returnType is CIR's void. | |
| static mlir::FailureOr< FunctionClassification > | classifyFunction (cir::FuncOp func, const DataLayout &dl, cir::CallConvTarget target, StringRef classificationAttrName) |
Classify func using whichever driver mode is configured. | |
|
static |
Convert an llvm::abi::Type coercion type back to a CIR type.
Definition at line 261 of file CIRABIClassifier.cpp.
References abiTypeToCIR(), cir::RecordType::getAllDataKinds(), and cir::getFloatingPointType().
Referenced by abiTypeToCIR(), convertABIArgInfo(), and convertDirectArgInfo().
|
static |
Classify func using whichever driver mode is configured.
Returns failure and emits an error on the function if classification fails (e.g. injection-driver mode but the function is missing the attribute, or the attribute is malformed).
Definition at line 870 of file CIRABIClassifier.cpp.
References cir::Test, and withReturnVoidness().
|
static |
Whether coercedAbiTy holds the same value as the scalar origTy: an integer of the same width, a float with the same semantics, or a pointer.
Used only in an assert in convertDirectArgInfo.
Definition at line 532 of file CIRABIClassifier.cpp.
Referenced by convertDirectArgInfo().
|
static |
Convert an llvm::abi::ArgInfo into the ArgClassification consumed by CIRABIRewriteContext.
Returns failure when the classifier picks a coercion this bridge cannot represent, which the caller reports as NYI.
Definition at line 652 of file CIRABIClassifier.cpp.
References abiTypeToCIR(), and convertDirectArgInfo().
Referenced by clang::CodeGen::CodeGenModule::computeABIInfoUsingLib().
|
static |
Convert a Direct llvm::abi::ArgInfo.
A null coercedType in the result means the value is passed unchanged in its own type. Otherwise the rewriter converts the value to coercedType, and when that is a struct and canFlatten is set, passes each field of the struct as a separate argument.
Definition at line 556 of file CIRABIClassifier.cpp.
References abiTypeToCIR(), coerceKeepsScalarValue(), and unwrapLongDoubleVectorElement().
Referenced by convertABIArgInfo().
|
static |
The CIR types the bridge handles.
Scalars: an integer up to 128 bits (including __int128), a _BitInt of any width, pointer, vtable pointer, bool, void, or any floating-point type. Aggregates: a complete struct or union whose members are all themselves supported, or an array of a supported element type. Also a _Complex, or a fixed-width vector, of a supported element type. Everything else is reported NYI at the reject() choke point in classifySignature.
Definition at line 135 of file CIRABIClassifier.cpp.
References cir::MissingFeatures::addressSpace(), isSupportedType(), kind, memberIsEmptyRecord(), and sseUpCoerceSizeUnsupported().
Referenced by isSupportedType().
|
static |
Map a CIR type to an llvm::abi::Type.
classifySignature pre-filters the signature, so only the scalar and struct/array types handled here can reach this function.
Definition at line 330 of file CIRABIClassifier.cpp.
References cir::MissingFeatures::addressSpace(), cir::RecordType::getElementOffset(), cir::RecordType::getMemberKinds(), cir::RecordType::getMembers(), cir::RecordType::isEmptyForABI(), cir::RecordType::isUnion(), kind, mapCIRType(), memberIsEmptyRecord(), recordCanPassInRegs(), recordDeclaredAlign(), recordIsTransparentUnion(), and recordUnadjustedAlign().
Referenced by mapCIRType().
|
static |
Whether the classifier could give this type the SSEUP class, looking through arrays and records at the types they hold.
Definition at line 59 of file CIRABIClassifier.cpp.
References mayReachSseUp().
Referenced by mayReachSseUp(), and sseUpCoerceSizeUnsupported().
|
static |
Whether a member is an empty record, looking through arrays, since an array of empty records supplies no bytes either.
Definition at line 95 of file CIRABIClassifier.cpp.
Referenced by isSupportedType(), and mapCIRType().
|
static |
Whether a struct's declared argument-passing kind (from the module's record-layout metadata) allows it to be passed in registers.
A record with no layout entry (e.g. an anonymous struct) has no C++ non-trivial reason to be forced to memory, so it defaults to can-pass-in-registers.
Definition at line 45 of file CIRABIClassifier.cpp.
References cir::RecordType::getName(), and cir::tryGetRecordLayout().
Referenced by mapCIRType().
|
static |
A record's declared alignment, which the ABI uses for the byval and sret alignment of an indirect argument.
DataLayout derives alignment from the members, so it cannot see __attribute__((aligned(N))). The declared value comes from the module's record-layout metadata instead. CIRGen emits an entry for every record it names, so the computed fallback only serves hand-written CIR.
Definition at line 108 of file CIRABIClassifier.cpp.
References cir::RecordType::getName(), and cir::tryGetRecordLayout().
Referenced by mapCIRType().
|
static |
Definition at line 52 of file CIRABIClassifier.cpp.
References cir::RecordType::getName(), and cir::tryGetRecordLayout().
Referenced by mapCIRType().
|
static |
A record's unadjusted alignment, the alignment its members give it before an alignment attribute on the record raises it.
Like the declared alignment, it comes from the module's record-layout metadata, and the computed fallback only serves hand-written CIR.
Definition at line 120 of file CIRABIClassifier.cpp.
References cir::RecordType::getName(), and cir::tryGetRecordLayout().
Referenced by mapCIRType().
|
static |
Where fnTy's declared parameters end and its ellipsis arguments begin.
Definition at line 683 of file CIRABIClassifier.cpp.
Referenced by cir::CIRABIClassifierCommon::classifyFunction(), and cir::CIRABIClassifierCommon::classifyIndirectCall().
|
static |
Whether the record's size has no SSEUP coerce.
That coerce is a vector as wide as the record, so only 128, 256 and 512 bits have one. A record past 512 bits classifies memory before any coerce is asked for.
Definition at line 82 of file CIRABIClassifier.cpp.
References mayReachSseUp().
Referenced by isSupportedType().
|
static |
Returns ty with a LongDoubleType vector element replaced by its underlying format, which is the element abiTypeToCIR builds for the same float.
Definition at line 317 of file CIRABIClassifier.cpp.
Referenced by convertDirectArgInfo().
|
static |
Record on fc whether returnType is CIR's void.
classifySignature answers this itself, but the other two drivers cannot: the test target is dialect-neutral and has no notion of CIR's void, and the classification-attr schema carries no return type at all. Both route through here so a classification always reaches needsRewrite paired with the return type it was built from.
Definition at line 858 of file CIRABIClassifier.cpp.
Referenced by classifyFunction().