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"
31 mlir::ConversionPatternRewriter &rewriter,
32 mlir::SymbolTableCollection &symbolTables,
33 const mlir::TypeConverter *converter,
41 mlir::SymbolTableCollection &symbolTables,
42 mlir::Operation *srcOp, llvm::StringRef fnName,
44 mlir::ArrayAttr argAttrs =
nullptr,
45 mlir::ArrayAttr resAttrs =
nullptr);
51 void mapBlockTag(cir::BlockAddrInfoAttr info, mlir::LLVM::BlockTagOp tagOp) {
52 [[maybe_unused]]
auto result = blockInfoToTagOp.try_emplace(info, tagOp);
53 assert(result.second &&
54 "attempting to map a BlockTag operation that is already mapped");
59 return blockInfoToTagOp.lookup(info);
64 cir::BlockAddrInfoAttr info) {
65 unresolvedBlockAddressOp.try_emplace(op, info);
70 llvm::DenseMap<mlir::LLVM::BlockAddressOp, cir::BlockAddrInfoAttr> &
72 return unresolvedBlockAddressOp;
78 llvm::DenseMap<cir::BlockAddrInfoAttr, mlir::LLVM::BlockTagOp>
84 llvm::DenseMap<mlir::LLVM::BlockAddressOp, cir::BlockAddrInfoAttr>
85 unresolvedBlockAddressOp;
90 mlir::Operation *op, mlir::ValueRange operands, cir::FenvAttr fenv,
91 mlir::Type llvmResTy, mlir::ConversionPatternRewriter &rewriter,
92 llvm::StringRef constrainedMnemonic,
bool hasRoundingMode,
93 mlir::LLVM::FastmathFlags fastmathFlags = {});
95template <
typename LLVMOp>
97 mlir::Operation *op, mlir::ValueRange operands, cir::FenvAttr fenv,
98 cir::FastMathFlagsAttr fastmath,
const mlir::TypeConverter &typeConverter,
99 mlir::ConversionPatternRewriter &rewriter,
100 llvm::StringRef constrainedMnemonic,
bool hasRoundingMode);
102#define GET_LLVM_LOWERING_PATTERNS
103#include "clang/CIR/Dialect/IR/CIRLowering.inc"
104#undef GET_LLVM_LOWERING_PATTERNS
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)
mlir::Value lowerCirAttrAsValue(mlir::Operation *parentOp, const mlir::Attribute attr, mlir::ConversionPatternRewriter &rewriter, mlir::SymbolTableCollection &symbolTables, const mlir::TypeConverter *converter, LLVMBlockAddressInfo *blockInfoAddr)
Switches on the type of attribute and calls the appropriate conversion.
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)