13#include "mlir/IR/BuiltinOps.h"
14#include "mlir/Pass/PassManager.h"
19#include "llvm/Support/TimeProfiler.h"
20#include "llvm/TargetParser/Triple.h"
27 if (triple.getArch() == llvm::Triple::x86_64)
36 return llvm::abi::X86AVXABILevel::AVX512;
38 return llvm::abi::X86AVXABILevel::AVX;
39 return llvm::abi::X86AVXABILevel::None;
48 clang::LangOptions::ClangABI::Ver23;
56static llvm::abi::ABICompatInfo
61 llvm::abi::ABICompatInfo abiCompat;
62 abiCompat.HonorsRevision98 = !triple.isOSDarwin();
63 abiCompat.ClassifyIntegerMMXAsSSE =
64 compat > clang::LangOptions::ClangABI::Ver3_8 && !triple.isOSDarwin() &&
65 !triple.isPS() && !triple.isOSFreeBSD();
66 abiCompat.PassInt128VectorsInMem =
67 compat > clang::LangOptions::ClangABI::Ver9 &&
68 (triple.isOSLinux() || triple.isOSNetBSD());
69 abiCompat.ReturnCXXRecordGreaterThan128InMem =
70 compat > clang::LangOptions::ClangABI::Ver20 && !triple.isPS();
71 abiCompat.Clang11Compat =
72 compat <= clang::LangOptions::ClangABI::Ver11 || triple.isPS();
79 bool enableIdiomRecognizer,
bool enableCIRSimplify,
80 bool enableLibOpt, llvm::StringRef libOptOptions,
81 bool enableCallConvLowering) {
83 llvm::TimeTraceScope scope(
"CIR To CIR Passes");
85 mlir::PassManager pm(&mlirContext);
88 if (enableCIRSimplify)
91 if (enableIdiomRecognizer)
96 auto errorHandler = [](
const llvm::Twine &) -> mlir::LogicalResult {
97 return mlir::LogicalResult::failure();
100 if (libOptPass->initializeOptions(libOptOptions, errorHandler).failed())
101 return mlir::failure();
103 pm.addPass(std::move(libOptPass));
115 if (enableCallConvLowering) {
128 pm.enableVerifier(enableVerifier);
129 (void)mlir::applyPassManagerCLOptions(pm);
130 return pm.run(theModule);
Defines the clang::ASTContext interface.
Defines the clang::LangOptions interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const LangOptions & getLangOpts() const
const TargetInfo & getTargetInfo() const
ClangABI
Clang versions with different platform ABI conformance.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Exposes information about the current target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual StringRef getABI() const
Get the ABI currently in use.
Defines the clang::TargetInfo interface.
static CallConvTarget getCallConvTarget(const llvm::Triple &triple)
Map a target triple to the ABI target that drives CallConvLowering.
static llvm::abi::ABICompatInfo getX86ABICompatInfo(const clang::ASTContext &astContext)
The x86_64 ABI-compatibility flags, derived from the target and the requested compatibility version.
mlir::LogicalResult runCIRToCIRPasses(mlir::ModuleOp theModule, mlir::MLIRContext &mlirCtx, clang::ASTContext &astCtx, bool enableVerifier, bool enableIdiomRecognizer, bool enableCIRSimplify, bool enableLibOpt, llvm::StringRef libOptOptions, bool enableCallConvLowering)
static llvm::abi::X86AVXABILevel getX86AVXABILevel(llvm::StringRef abi)
The AVX level the classifier uses to size a native vector, read from the target ABI name.
static bool allowsX86TargetAttrAvx(const clang::ASTContext &astContext)
Whether __attribute__((target(...))) on a function may raise its AVX ABI level above the command line...
CallConvTarget
The ABI target whose calling-convention rules drive CallConvLowering.
std::unique_ptr< Pass > createCallConvLoweringPass()
std::unique_ptr< Pass > createCIREHABILoweringPass()
std::unique_ptr< Pass > createCIRCanonicalizePass()
std::unique_ptr< Pass > createCIRFlattenCFGPass()
std::unique_ptr< Pass > createLibOptPass()
std::unique_ptr< Pass > createIdiomRecognizerPass()
void populateCIRPreLoweringPasses(mlir::OpPassManager &pm)
std::unique_ptr< Pass > createTargetLoweringPass()
std::unique_ptr< Pass > createGotoSolverPass()
std::unique_ptr< Pass > createLoweringPreparePass()
std::unique_ptr< Pass > createCIRSimplifyPass()
std::unique_ptr< Pass > createCXXABILoweringPass()
std::unique_ptr< Pass > createHoistAllocasPass()