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"
29#include "llvm/ABI/FunctionInfo.h"
30#include "llvm/ABI/TargetInfo.h"
31#include "llvm/ADT/STLFunctionalExtras.h"
32#include "llvm/ADT/StringRef.h"
33#include "llvm/IR/CallingConv.h"
69 virtual mlir::FailureOr<mlir::abi::FunctionClassification>
76 virtual mlir::FailureOr<mlir::abi::FunctionClassification>
81 virtual mlir::FailureOr<mlir::abi::FunctionClassification>
86 virtual mlir::FailureOr<mlir::abi::ArgClassification>
98 mlir::FailureOr<mlir::abi::FunctionClassification>
106 mlir::FailureOr<mlir::abi::FunctionClassification>
108 cir::FuncOp callee)
override;
115 mlir::FailureOr<mlir::abi::FunctionClassification>
124 virtual const llvm::abi::TargetInfo &
129 mlir::FailureOr<mlir::abi::ArgClassification>
131 llvm::function_ref<mlir::InFlightDiagnostic()> emitError);
133 const mlir::DataLayout &
dl;
140 mlir::FailureOr<mlir::abi::FunctionClassification>
141 classifySignature(mlir::Type retCIR, mlir::TypeRange inputs,
142 llvm::abi::RequiredArgs required,
143 const llvm::abi::TargetInfo &targetInfo,
144 llvm::CallingConv::ID callConv,
145 llvm::function_ref<mlir::InFlightDiagnostic()> emitError);
149 mlir::FailureOr<mlir::abi::FunctionClassification>
151 const llvm::abi::TargetInfo &targetInfo,
152 llvm::CallingConv::ID callConv);
157std::unique_ptr<CIRABIClassifier>
162std::unique_ptr<CIRABIClassifier>
164 llvm::StringRef attrName);
167std::unique_ptr<CIRABIClassifier>
172std::unique_ptr<CIRABIClassifier>
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 > 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.
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.