19#include "llvm/TargetParser/Triple.h"
24mlir::LogicalResult CIRToLLVMOffloadPrintfOpLowering::matchAndRewrite(
25 cir::OffloadPrintfOp op, OpAdaptor adaptor,
26 mlir::ConversionPatternRewriter &rewriter)
const {
27 auto mod = op->getParentOfType<mlir::ModuleOp>();
28 llvm::StringRef tripleStr;
29 if (
auto tripleAttr = mod->getAttrOfType<mlir::StringAttr>(
30 cir::CIRDialect::getTripleAttrName()))
31 tripleStr = tripleAttr.getValue();
32 llvm::Triple triple(tripleStr);
36 rewriter, dataLayout, symbolTables);
38 if (triple.isAMDGCN() ||
39 (triple.isSPIRV() && triple.getVendor() == llvm::Triple::AMD)) {
40 bool isBuffered =
false;
41 if (
auto kind = mod->getAttrOfType<mlir::StringAttr>(
42 cir::CIRDialect::getAMDGPUPrintfKindAttrName()))
43 isBuffered =
kind.getValue() ==
"buffered";
44 std::unique_ptr<cir::TargetLoweringInfo> targetInfo =
47 unsigned genericAddrSpace = targetInfo->getTargetAddrSpaceFromCIRAddrSpace(
48 cir::LangAddressSpace::OffloadGeneric);
50 symbolTables, genericAddrSpace, isBuffered);
53 return op.emitError() <<
"offload printf lowering is NYI for target '"
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
mlir::LogicalResult lowerAMDGPUPrintf(cir::OffloadPrintfOp op, mlir::ValueRange operands, mlir::ConversionPatternRewriter &rewriter, const mlir::DataLayout &dataLayout, mlir::SymbolTableCollection &symbolTables, unsigned genericAddrSpace, bool isBuffered)
Lowers op, whose lowered operands are operands, to the buffered printf runtime interface if isBuffere...
mlir::LogicalResult lowerNVPTXPrintf(cir::OffloadPrintfOp op, mlir::Value format, mlir::ValueRange args, mlir::ConversionPatternRewriter &rewriter, const mlir::DataLayout &dataLayout, mlir::SymbolTableCollection &symbolTables)
Lowers op, whose lowered format and arguments are format and args, to a call to vprintf.
std::unique_ptr< TargetLoweringInfo > createSPIRVTargetLoweringInfo()
std::unique_ptr< TargetLoweringInfo > createAMDGPUTargetLoweringInfo()