15#include "mlir/Support/LLVM.h"
17#include "llvm/ADT/TypeSwitch.h"
23#define GEN_PASS_DEF_TARGETLOWERING
24#include "clang/CIR/Dialect/Passes.h.inc"
29struct TargetLoweringPass
30 :
public impl::TargetLoweringBase<TargetLoweringPass> {
31 TargetLoweringPass() =
default;
32 void runOnOperation()
override;
40 mlir::cast_if_present<cir::SyncScopeKindAttr>(op->getAttr(
"sync_scope"));
42 cir::SyncScopeKind convertedSyncScope =
44 syncScopeAttr.getValue());
45 op->setAttr(
"sync_scope", cir::SyncScopeKindAttr::get(op->getContext(),
50void TargetLoweringPass::runOnOperation() {
51 auto mod = mlir::cast<mlir::ModuleOp>(getOperation());
55 mod.emitWarning(
"Cannot create a CIR lower module, skipping the ")
60 mod->walk([&](mlir::Operation *op) {
61 if (mlir::isa<cir::LoadOp, cir::StoreOp, cir::AtomicXchgOp,
62 cir::AtomicCmpXchgOp, cir::AtomicFetchOp>(op))
68 return std::make_unique<TargetLoweringPass>();
static void convertSyncScopeIfPresent(mlir::Operation *op, cir::LowerModule &lowerModule)
const TargetLoweringInfo & getTargetLoweringInfo()
virtual cir::SyncScopeKind convertSyncScope(cir::SyncScopeKind syncScope) const
std::unique_ptr< LowerModule > createLowerModule(mlir::ModuleOp module)
StringRef getName(const HeaderType T)
std::unique_ptr< Pass > createTargetLoweringPass()