21using namespace mlir::abi;
28 X86_64ABIClassifier(
const mlir::DataLayout &dl, mlir::ModuleOp modOp,
29 const ABIClassifierOptions &options)
30 : CIRABIClassifierCommon(dl, modOp), baseAvxLevel(options.x86AvxAbiLevel),
32 abiCompat(options.x86AbiCompat) {}
37 std::optional<ArgClassification> classifyVAArg(cir::VAArgOp vaArg)
override {
38 return classifyVarArgType(
39 vaArg.getType(), getTargetInfo(vaArg->getParentOfType<cir::FuncOp>()),
40 [&]() { return vaArg->emitOpError(); });
46 const llvm::abi::TargetInfo &
47 getTargetInfo(cir::FuncOp featureSource)
override;
52 static constexpr unsigned numAvxLevels =
53 static_cast<unsigned>(llvm::abi::X86AVXABILevel::Last) + 1;
54 std::array<std::unique_ptr<llvm::abi::TargetInfo>, numAvxLevels> targets;
56 llvm::abi::X86AVXABILevel baseAvxLevel;
57 bool allowsTargetAttrAvx;
61 llvm::abi::X86ABICompatInfo abiCompat;
64const llvm::abi::TargetInfo &
65X86_64ABIClassifier::getTargetInfo(cir::FuncOp featureSource) {
66 llvm::abi::X86AVXABILevel level = baseAvxLevel;
67 assert(featureSource &&
"function required for getTargetInfo");
68 if (allowsTargetAttrAvx)
70 assert(
static_cast<unsigned>(level) < numAvxLevels &&
71 "a new X86AVXABILevel must move X86AVXABILevel::Last");
72 std::unique_ptr<llvm::abi::TargetInfo> &slot =
73 targets[
static_cast<unsigned>(level)];
76 llvm::abi::createX86_64TargetInfo(typeMapper.getTypeBuilder(), level,
83std::unique_ptr<CIRABIClassifier>
86 return std::make_unique<X86_64ABIClassifier>(dl, modOp, options);
Classifies through the LLVM ABI Lowering Library.
static bool allowsX86TargetAttrAvx(const llvm::Triple &triple, clang::LangOptions::ClangABI compat)
Whether __attribute__((target(...))) on a function may raise its AVX ABI level above the command line...
llvm::abi::X86AVXABILevel funcAvxLevel(cir::FuncOp func, llvm::abi::X86AVXABILevel base)
The AVX level to classify func at: base, raised if the function's own recorded feature list enables a...
std::unique_ptr< CIRABIClassifier > createX86_64ABIClassifier(const mlir::DataLayout &dl, mlir::ModuleOp modOp, const ABIClassifierOptions &options)
The x86_64 System V classifier.
The target-specific settings a classifier needs beyond what it can read from the module.