12#ifndef CLANG_CIR_LOWERTOLLVM_H
13#define CLANG_CIR_LOWERTOLLVM_H
15#include "mlir/Dialect/LLVMIR/LLVMAttrs.h"
16#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
17#include "mlir/Transforms/DialectConversion.h"
36 mlir::ConversionPatternRewriter &rewriter,
37 mlir::SymbolTableCollection &symbolTables,
38 const mlir::TypeConverter *converter,
47 mlir::SymbolTableCollection &symbolTables,
48 mlir::Operation *srcOp, llvm::StringRef fnName,
50 mlir::ArrayAttr argAttrs =
nullptr,
51 mlir::ArrayAttr resAttrs =
nullptr);
57 void mapBlockTag(cir::BlockAddrInfoAttr info, mlir::LLVM::BlockTagOp tagOp) {
58 [[maybe_unused]]
auto result = blockInfoToTagOp.try_emplace(info, tagOp);
59 assert(result.second &&
60 "attempting to map a BlockTag operation that is already mapped");
65 return blockInfoToTagOp.lookup(info);
70 cir::BlockAddrInfoAttr info) {
71 unresolvedBlockAddressOp.try_emplace(op, info);
76 llvm::DenseMap<mlir::LLVM::BlockAddressOp, cir::BlockAddrInfoAttr> &
78 return unresolvedBlockAddressOp;
84 llvm::DenseMap<cir::BlockAddrInfoAttr, mlir::LLVM::BlockTagOp>
90 llvm::DenseMap<mlir::LLVM::BlockAddressOp, cir::BlockAddrInfoAttr>
91 unresolvedBlockAddressOp;
96 mlir::Operation *op, mlir::ValueRange operands, cir::FenvAttr fenv,
97 mlir::Type llvmResTy, mlir::ConversionPatternRewriter &rewriter,
98 llvm::StringRef constrainedMnemonic,
bool hasRoundingMode,
99 mlir::LLVM::FastmathFlags fastmathFlags = {});
101template <
typename LLVMOp>
102mlir::LogicalResult
lowerFPOp(mlir::Operation *op, mlir::ValueRange operands,
103 cir::FastMathFlagsAttr fastmath,
104 const mlir::TypeConverter &typeConverter,
105 mlir::ConversionPatternRewriter &rewriter);
107template <
typename LLVMOp>
109 mlir::Operation *op, mlir::ValueRange operands, cir::FenvAttr fenv,
110 cir::FastMathFlagsAttr fastmath,
const mlir::TypeConverter &typeConverter,
111 mlir::ConversionPatternRewriter &rewriter,
112 llvm::StringRef constrainedMnemonic,
bool hasRoundingMode);
117mlir::LLVM::IntegerOverflowFlags
119mlir::LLVM::FastmathFlagsAttr
121 std::optional<cir::FastMathFlags> flags);
123 cir::FPClassTest flags);
126#define GET_LLVM_LOWERING_PATTERNS
127#include "clang/CIR/Dialect/IR/CIRLowering.inc"
128#undef GET_LLVM_LOWERING_PATTERNS
llvm::StringMap< mlir::Type > CIRPreConversionTypeMap
mlir::LogicalResult lowerFPOp(mlir::Operation *op, mlir::ValueRange operands, cir::FastMathFlagsAttr fastmath, const mlir::TypeConverter &typeConverter, mlir::ConversionPatternRewriter &rewriter)
mlir::Value lowerCirAttrAsValue(mlir::Location parentLoc, mlir::ModuleOp parentModule, const mlir::Attribute attr, mlir::ConversionPatternRewriter &rewriter, mlir::SymbolTableCollection &symbolTables, const mlir::TypeConverter *converter, const CIRPreConversionTypeMap &preConversionTypes, LLVMBlockAddressInfo *blockInfoAddr)
Switches on the type of attribute and calls the appropriate conversion.
mlir::LogicalResult lowerToConstrainedFPIntrinsic(mlir::Operation *op, mlir::ValueRange operands, cir::FenvAttr fenv, mlir::Type llvmResTy, mlir::ConversionPatternRewriter &rewriter, llvm::StringRef constrainedMnemonic, bool hasRoundingMode, mlir::LLVM::FastmathFlags fastmathFlags)
void createLLVMFuncOpIfNotExist(mlir::ConversionPatternRewriter &rewriter, mlir::SymbolTableCollection &symbolTables, mlir::Operation *srcOp, llvm::StringRef fnName, mlir::Type fnTy, mlir::ArrayAttr argAttrs, mlir::ArrayAttr resAttrs)
Declare fnName with type fnTy before the function enclosing srcOp, unless the module already has a sy...
mlir::LogicalResult lowerConstrainableFPOp(mlir::Operation *op, mlir::ValueRange operands, cir::FenvAttr fenv, cir::FastMathFlagsAttr fastmath, const mlir::TypeConverter &typeConverter, mlir::ConversionPatternRewriter &rewriter, llvm::StringRef constrainedMnemonic, bool hasRoundingMode)
mlir::LLVM::Linkage convertLinkage(cir::GlobalLinkageKind linkage)
mlir::LLVM::FastmathFlagsAttr convertToLLVMProperty(mlir::MLIRContext *ctx, std::optional< cir::FastMathFlags > flags)
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t
Annotation strings and arguments, shared by all annotations in a module.
mlir::LLVM::BlockTagOp lookupBlockTag(cir::BlockAddrInfoAttr info) const
void clearUnresolvedMap()
llvm::DenseMap< mlir::LLVM::BlockAddressOp, cir::BlockAddrInfoAttr > & getUnresolvedBlockAddress()
void mapBlockTag(cir::BlockAddrInfoAttr info, mlir::LLVM::BlockTagOp tagOp)
void addUnresolvedBlockAddress(mlir::LLVM::BlockAddressOp op, cir::BlockAddrInfoAttr info)