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"
35 mlir::ConversionPatternRewriter &rewriter,
36 mlir::SymbolTableCollection &symbolTables,
37 const mlir::TypeConverter *converter,
46 mlir::SymbolTableCollection &symbolTables,
47 mlir::Operation *srcOp, llvm::StringRef fnName,
49 mlir::ArrayAttr argAttrs =
nullptr,
50 mlir::ArrayAttr resAttrs =
nullptr);
56 void mapBlockTag(cir::BlockAddrInfoAttr info, mlir::LLVM::BlockTagOp tagOp) {
57 [[maybe_unused]]
auto result = blockInfoToTagOp.try_emplace(info, tagOp);
58 assert(result.second &&
59 "attempting to map a BlockTag operation that is already mapped");
64 return blockInfoToTagOp.lookup(info);
69 cir::BlockAddrInfoAttr info) {
70 unresolvedBlockAddressOp.try_emplace(op, info);
75 llvm::DenseMap<mlir::LLVM::BlockAddressOp, cir::BlockAddrInfoAttr> &
77 return unresolvedBlockAddressOp;
83 llvm::DenseMap<cir::BlockAddrInfoAttr, mlir::LLVM::BlockTagOp>
89 llvm::DenseMap<mlir::LLVM::BlockAddressOp, cir::BlockAddrInfoAttr>
90 unresolvedBlockAddressOp;
95 mlir::Operation *op, mlir::ValueRange operands, cir::FenvAttr fenv,
96 mlir::Type llvmResTy, mlir::ConversionPatternRewriter &rewriter,
97 llvm::StringRef constrainedMnemonic,
bool hasRoundingMode,
98 mlir::LLVM::FastmathFlags fastmathFlags = {});
100template <
typename LLVMOp>
102 mlir::Operation *op, mlir::ValueRange operands, cir::FenvAttr fenv,
103 cir::FastMathFlagsAttr fastmath,
const mlir::TypeConverter &typeConverter,
104 mlir::ConversionPatternRewriter &rewriter,
105 llvm::StringRef constrainedMnemonic,
bool hasRoundingMode);
107#define GET_LLVM_LOWERING_PATTERNS
108#include "clang/CIR/Dialect/IR/CIRLowering.inc"
109#undef GET_LLVM_LOWERING_PATTERNS
llvm::StringMap< mlir::Type > CIRPreConversionTypeMap
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)
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t
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)