18#ifndef CLANG_LIB_CIR_DIALECT_TRANSFORMS_CIRABICLASSIFIER_H
19#define CLANG_LIB_CIR_DIALECT_TRANSFORMS_CIRABICLASSIFIER_H
21#include "mlir/ABI/ABIRewriteContext.h"
22#include "mlir/ABI/ABITypeMapper.h"
23#include "mlir/IR/BuiltinOps.h"
24#include "mlir/IR/Diagnostics.h"
25#include "mlir/Interfaces/DataLayoutInterfaces.h"
26#include "mlir/Support/LogicalResult.h"
30#include "llvm/ABI/FunctionInfo.h"
31#include "llvm/ABI/TargetInfo.h"
32#include "llvm/ADT/STLFunctionalExtras.h"
33#include "llvm/ADT/StringRef.h"
34#include "llvm/IR/CallingConv.h"
70 virtual mlir::FailureOr<mlir::abi::FunctionClassification>
77 virtual mlir::FailureOr<mlir::abi::FunctionClassification>
82 virtual mlir::FailureOr<mlir::abi::FunctionClassification>
87 virtual mlir::FailureOr<mlir::abi::ArgClassification>
99 mlir::FailureOr<mlir::abi::FunctionClassification>
107 mlir::FailureOr<mlir::abi::FunctionClassification>
109 cir::FuncOp callee)
override;
116 mlir::FailureOr<mlir::abi::FunctionClassification>
125 virtual const llvm::abi::TargetInfo &
130 mlir::FailureOr<mlir::abi::ArgClassification>
132 llvm::function_ref<mlir::InFlightDiagnostic()> emitError);
134 const mlir::DataLayout &
dl;
142 mlir::FailureOr<mlir::abi::FunctionClassification>
143 classifySignature(mlir::Type retCIR, mlir::TypeRange inputs,
144 llvm::abi::RequiredArgs required,
145 const llvm::abi::TargetInfo &targetInfo,
146 llvm::CallingConv::ID callConv,
147 llvm::function_ref<mlir::InFlightDiagnostic()> emitError);
151 mlir::FailureOr<mlir::abi::FunctionClassification>
153 const llvm::abi::TargetInfo &targetInfo,
154 llvm::CallingConv::ID callConv);
159std::unique_ptr<CIRABIClassifier>
164std::unique_ptr<CIRABIClassifier>
166 llvm::StringRef attrName);
169std::unique_ptr<CIRABIClassifier>
174std::unique_ptr<CIRABIClassifier>
178std::unique_ptr<CIRABIClassifier>
189std::unique_ptr<CIRABIClassifier>
191 const llvm::abi::AArch64ABIOptions &opts);
cir::CIRDataLayout cirDataLayout
mlir::FailureOr< mlir::abi::FunctionClassification > classifyIndirectCall(cir::CIRCallOpInterface call) override
A callee resolved at run time carries no features of its own, so the call is classified at the featur...
mlir::FailureOr< mlir::abi::FunctionClassification > classifyFunction(cir::FuncOp func) override
Classify a cir.func using the LLVM ABI library.
CIRABIClassifierCommon(const mlir::DataLayout &dl, mlir::ModuleOp modOp)
const mlir::DataLayout & dl
mlir::FailureOr< mlir::abi::ArgClassification > classifyVarArgType(mlir::Type ty, const llvm::abi::TargetInfo &targetInfo, llvm::function_ref< mlir::InFlightDiagnostic()> emitError)
Classify ty, the type fetched by a cir.va_arg, as an unnamed argument with every argument register fr...
mlir::FailureOr< mlir::abi::FunctionClassification > classifyVariadicCall(cir::CIRCallOpInterface call, cir::FuncOp callee) override
The call is classified at the callee's features, not the caller's, because the pass rewrites the defi...
virtual const llvm::abi::TargetInfo & getTargetInfo(cir::FuncOp featureSource)=0
The library classifier for a function whose recorded target features may refine the ABI rules.
mlir::abi::ABITypeMapper typeMapper
Produces the classification CallConvLowering rewrites a signature from.
virtual mlir::FailureOr< mlir::abi::ArgClassification > classifyVAArg(cir::VAArgOp vaArg)=0
Classify the type fetched by vaArg as an unnamed argument with a full register budget.
virtual mlir::FailureOr< mlir::abi::FunctionClassification > classifyFunction(cir::FuncOp func)=0
Classify func's declared signature.
virtual mlir::FailureOr< mlir::abi::FunctionClassification > classifyIndirectCall(cir::CIRCallOpInterface call)=0
Classify call, whose callee is resolved at run time, from the signature its callee pointer points to.
virtual ~CIRABIClassifier()=default
virtual mlir::FailureOr< mlir::abi::FunctionClassification > classifyVariadicCall(cir::CIRCallOpInterface call, cir::FuncOp callee)=0
Classify a direct call to the variadic function callee that passes arguments through the ellipsis.
std::unique_ptr< CIRABIClassifier > createAMDGPUABIClassifier(const mlir::DataLayout &dl, mlir::ModuleOp modOp)
The AMDGPU classifier.
std::unique_ptr< CIRABIClassifier > createX86_64ABIClassifier(const mlir::DataLayout &dl, mlir::ModuleOp modOp, const ABIClassifierOptions &options)
The x86_64 System V classifier.
llvm::CallingConv::ID convertCallingConv(cir::CallingConv cc)
Map a CIR calling convention to the llvm::CallingConv the ABI classifier uses.
std::unique_ptr< CIRABIClassifier > createSPIRVABIClassifier(const mlir::DataLayout &dl, mlir::ModuleOp modOp)
The SPIR-V classifier.
std::unique_ptr< CIRABIClassifier > createAArch64ABIClassifier(const mlir::DataLayout &dl, mlir::ModuleOp modOp, const llvm::abi::AArch64ABIOptions &opts)
The AArch64 classifier, covering AAPCS64 and DarwinPCS, which classifies with opts.
std::unique_ptr< CIRABIClassifier > createInjectedABIClassifier(const mlir::DataLayout &dl, llvm::StringRef attrName)
A classifier that reads each function's classification from the DictionaryAttr named attrName.
std::unique_ptr< CIRABIClassifier > createTestTargetABIClassifier(const mlir::DataLayout &dl)
The MLIR test ABI target's classifier, whose predictable rules approximate x86_64 SysV.
llvm::abi::AArch64ABIOptions getAArch64ABIOptions(mlir::ModuleOp modOp)
The AArch64 classifier, covering AAPCS64 and DarwinPCS.
The target-specific settings a classifier needs beyond what it can read from the module.
bool allowsX86TargetAttrAvx
Whether a function's own recorded target features may raise its x86_64 AVX level above x86AvxAbiLevel...
llvm::abi::X86ABICompatInfo x86AbiCompat
The x86_64 flags whose value depends on the target and the requested ABI compatibility version.
llvm::abi::X86AVXABILevel x86AvxAbiLevel
The AVX level the x86_64 classifier sizes a native vector at.