[Mlir-commits] [mlir] Give emitc.member_call_opaque operator precedence (PR #226349)
ioana ghiban
llvmlistbot at llvm.org
Fri Sep 25 06:31:20 PDT 2026
================
@@ -1777,6 +1778,8 @@ LogicalResult CppEmitter::emitOperand(Value value, bool isInBrackets) {
assert(def && "Expected operand to be defined by an operation");
if (auto expressionOp = dyn_cast<ExpressionOp>(def))
def = expressionOp.getRootOp();
+ if (auto loadOp = dyn_cast<emitc::LoadOp>(def))
----------------
ioghiban wrote:
I would add a comment above the `LoadOp` branch, explaining that loads do not generate any syntax in the emitted C++, so parenthesization must use the operand’s precedence. Otherwise it may look like an ad hoc exception. Something like:
```suggestion
// Within an expression, `emitc.load` emits only its operand, so determine
// parentheses from the operand rather than from the load operation.
if (auto loadOp = dyn_cast<emitc::LoadOp>(def))
```
https://github.com/llvm/llvm-project/pull/226349
More information about the Mlir-commits
mailing list