|
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 | recordHasFlexibleArrayMember (ModuleOp modOp, cir::RecordType recTy) |
| Read from the layout, which also covers a last field that has one. | |
| 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 | recordUnadjustedAlign (ModuleOp modOp, cir::RecordType recTy, const cir::CIRDataLayout &cirDL) |
| 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, const cir::CIRDataLayout &cirDL, 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 253 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 892 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 535 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 669 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. When the classifier names no coerce type, a struct or _Complex that can be flattened is coerced to a struct of its own fields.
Definition at line 561 of file CIRABIClassifier.cpp.
References abiTypeToCIR(), coerceKeepsScalarValue(), cir::RecordType::getAllDataKinds(), 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 128 of file CIRABIClassifier.cpp.
References cir::MissingFeatures::addressSpace(), isSupportedType(), kind, memberIsEmptyRecord(), sseUpCoerceSizeUnsupported(), and uint64_t.
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 322 of file CIRABIClassifier.cpp.
References cir::MissingFeatures::addressSpace(), cir::RecordType::getElementOffset(), cir::RecordType::getMemberKinds(), cir::RecordType::getMembers(), cir::CIRDataLayout::getTypeLanguageAlignment(), cir::RecordType::isEmptyForABI(), cir::RecordType::isUnion(), kind, mapCIRType(), memberIsEmptyRecord(), recordCanPassInRegs(), recordHasFlexibleArrayMember(), recordIsTransparentUnion(), recordUnadjustedAlign(), and uint64_t.
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 66 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 102 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 |
Read from the layout, which also covers a last field that has one.
Definition at line 58 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.
It comes from the module's record-layout metadata, and the computed fallback only serves hand-written CIR.
Definition at line 113 of file CIRABIClassifier.cpp.
References cir::RecordType::getName(), cir::CIRDataLayout::getTypeLanguageAlignment(), and cir::tryGetRecordLayout().
Referenced by mapCIRType().
|
static |
Where fnTy's declared parameters end and its ellipsis arguments begin.
Definition at line 702 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 89 of file CIRABIClassifier.cpp.
References mayReachSseUp(), and uint64_t.
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 309 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 880 of file CIRABIClassifier.cpp.
Referenced by classifyFunction().