Skip to content

Commit 9a94506

Browse files
committed
address comments
1 parent 8880dd2 commit 9a94506

2 files changed

Lines changed: 8 additions & 77 deletions

File tree

include/aie/Dialect/AIE/IR/AIEOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ def AIE_UseLockOp: AIE_Op<"use_lock", []> {
13941394
);
13951395

13961396
let assemblyFormat = [{
1397-
`(` $lock `,` custom<UseLockValue>($action, $value, $blocking) `)` attr-dict
1397+
`(` $lock `,` $action `,` $value (`,` $blocking^)? `)` attr-dict
13981398
}];
13991399

14001400
let hasVerifier = 1;

lib/Dialect/AIE/IR/AIEDialect.cpp

Lines changed: 7 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,9 @@ struct AIEDialectFoldInterface : DialectFoldInterface {
7575
// them with a core's identical constants, which would leave the core
7676
// referencing a device-level value that is erased when the core is
7777
// outlined.
78-
// - aie.mem/aie.memtile_dma/aie.shim_dma bodies carry constant lock values
79-
// (aie.use_lock operands). If these hoisted to the device, CSE would
80-
// merge them with the identical constant kept local to a core, and since
81-
// the device-level constant dominates the core, the core's use would be
82-
// rewritten to reference it -- reintroducing the cross-region reference
83-
// that breaks core outlining. Keeping them local avoids the dominating
84-
// device-level duplicate entirely.
78+
// - Make sure SSA values for aie.use_lock operands in
79+
// aie.mem/aie.memtile_dma/aie.shim_dma bodies do not get
80+
// hoisted.
8581
return isa<CoreOp, RuntimeSequenceOp, MemOp, MemTileDMAOp, ShimDMAOp>(
8682
region->getParentOp());
8783
}
@@ -2689,10 +2685,8 @@ LogicalResult LockOp::verify() {
26892685
return success();
26902686
}
26912687

2692-
// Centralized lookup for the compile-time constant lock value: returns the
2693-
// integer if `op`'s value operand is defined by an arith.constant, otherwise
2694-
// std::nullopt. This is the single place that knows how a static lock value is
2695-
// recovered from the SSA operand.
2688+
// Look up for compile-time constant lock values, if any.
2689+
// Returns std::nullopt if lock value does not reference an `arith.constant`.
26962690
static std::optional<int32_t> getConstantLockValue(UseLockOp op) {
26972691
if (auto constant = op.getValue().getDefiningOp<arith::ConstantOp>())
26982692
if (auto intAttr = llvm::dyn_cast<IntegerAttr>(constant.getValue()))
@@ -2763,8 +2757,8 @@ LogicalResult UseLockOp::verify() {
27632757
return (*this)->emitOpError(
27642758
"AcquireGreaterEqual is not supported in AIE1.");
27652759

2766-
// Locks used inside a DMA/BD block are configured via MMIO and therefore
2767-
// require a compile-time constant value (an arith.constant operand).
2760+
// Locks used inside a DMA/BD block are configured via static register writes
2761+
// and therefore require a compile-time constant value.
27682762
if (HasSomeParent<MemOp, MemTileDMAOp, ShimDMAOp>::verifyTrait(*this)
27692763
.succeeded() &&
27702764
!getConstantLockValue(*this))
@@ -2857,69 +2851,6 @@ static void printTraceRegValue(OpAsmPrinter &printer, Operation *op,
28572851
}
28582852

28592853
// Helper to parse a LockBlocking enum keyword.
2860-
static ParseResult parseLockBlockingKeyword(OpAsmParser &parser,
2861-
xilinx::AIE::LockBlockingAttr &blocking) {
2862-
StringRef keyword;
2863-
if (parser.parseKeyword(&keyword))
2864-
return failure();
2865-
auto symbol = xilinx::AIE::symbolizeLockBlocking(keyword);
2866-
if (!symbol)
2867-
return parser.emitError(parser.getCurrentLocation())
2868-
<< "invalid lock blocking value: " << keyword;
2869-
blocking =
2870-
xilinx::AIE::LockBlockingAttr::get(parser.getContext(), *symbol);
2871-
return success();
2872-
}
2873-
2874-
// Custom parser for the value slot of aie.use_lock. The lock value is a
2875-
// required `i32` SSA operand, optionally followed by a `blocking` keyword. The
2876-
// action keyword is parsed here as well so that the printed form has no stray
2877-
// space before the comma.
2878-
static ParseResult
2879-
parseUseLockValue(OpAsmParser &parser, xilinx::AIE::LockActionAttr &action,
2880-
OpAsmParser::UnresolvedOperand &value,
2881-
xilinx::AIE::LockBlockingAttr &blocking) {
2882-
// The action is accepted either as a bare keyword (`Acquire`) or, for
2883-
// backward compatibility with older textual IR, as a quoted string
2884-
// (`"Acquire"`).
2885-
StringRef actionKeyword;
2886-
std::string actionString;
2887-
if (succeeded(parser.parseOptionalKeyword(&actionKeyword))) {
2888-
// Parsed a bare keyword.
2889-
} else if (succeeded(parser.parseOptionalString(&actionString))) {
2890-
actionKeyword = actionString;
2891-
} else {
2892-
return parser.emitError(parser.getCurrentLocation())
2893-
<< "expected lock action keyword";
2894-
}
2895-
auto actionSymbol = xilinx::AIE::symbolizeLockAction(actionKeyword);
2896-
if (!actionSymbol)
2897-
return parser.emitError(parser.getCurrentLocation())
2898-
<< "invalid lock action: " << actionKeyword;
2899-
action = xilinx::AIE::LockActionAttr::get(parser.getContext(), *actionSymbol);
2900-
2901-
// The lock value SSA operand.
2902-
if (parser.parseComma() || parser.parseOperand(value))
2903-
return failure();
2904-
2905-
// Optionally parse a trailing blocking keyword.
2906-
if (!parser.parseOptionalComma())
2907-
return parseLockBlockingKeyword(parser, blocking);
2908-
return success();
2909-
}
2910-
2911-
// Custom printer for the value slot of aie.use_lock.
2912-
static void printUseLockValue(OpAsmPrinter &printer, Operation *op,
2913-
xilinx::AIE::LockActionAttr action, Value value,
2914-
xilinx::AIE::LockBlockingAttr blocking) {
2915-
printer << xilinx::AIE::stringifyLockAction(action.getValue());
2916-
printer << ", ";
2917-
printer.printOperand(value);
2918-
if (blocking)
2919-
printer << ", "
2920-
<< xilinx::AIE::stringifyLockBlocking(blocking.getValue());
2921-
}
2922-
29232854
#define GET_OP_CLASSES
29242855
#include "aie/Dialect/AIE/IR/AIEOps.cpp.inc"
29252856

0 commit comments

Comments
 (0)