Skip to content

Commit 6f89af4

Browse files
committed
[mlir][emitc] Refactor getEmittedExpression (NFC)
This method returns the current expression being emitted, but is only used testing whether an expression is being emitted or not. This patch therefore replaces it with a boolean isEmittingExpression() method.
1 parent 5613e4a commit 6f89af4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

mlir/lib/Target/Cpp/TranslateToCpp.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ struct CppEmitter {
250250
return !fileId.empty() && file.getId() == fileId;
251251
}
252252

253-
/// Get expression currently being emitted.
254-
ExpressionOp getEmittedExpression() { return emittedExpression; }
253+
/// Is expression currently being emitted.
254+
bool isEmittingExpression() { return emittedExpression; }
255255

256256
/// Determine whether given value is part of the expression potentially being
257257
/// emitted.
@@ -1630,11 +1630,11 @@ LogicalResult CppEmitter::emitOperands(Operation &op) {
16301630
return interleaveCommaWithError(op.getOperands(), os, [&](Value operand) {
16311631
// If an expression is being emitted, push lowest precedence as these
16321632
// operands are either wrapped by parenthesis.
1633-
if (getEmittedExpression())
1633+
if (isEmittingExpression())
16341634
pushExpressionPrecedence(lowestPrecedence());
16351635
if (failed(emitOperand(operand)))
16361636
return failure();
1637-
if (getEmittedExpression())
1637+
if (isEmittingExpression())
16381638
popExpressionPrecedence();
16391639
return success();
16401640
});
@@ -1718,7 +1718,7 @@ LogicalResult CppEmitter::emitGlobalVariable(GlobalOp op) {
17181718

17191719
LogicalResult CppEmitter::emitAssignPrefix(Operation &op) {
17201720
// If op is being emitted as part of an expression, bail out.
1721-
if (getEmittedExpression())
1721+
if (isEmittingExpression())
17221722
return success();
17231723

17241724
switch (op.getNumResults()) {
@@ -1800,7 +1800,7 @@ LogicalResult CppEmitter::emitOperation(Operation &op, bool trailingSemicolon) {
18001800
if (hasDeferredEmission(&op))
18011801
return success();
18021802

1803-
if (getEmittedExpression() ||
1803+
if (isEmittingExpression() ||
18041804
(isa<emitc::ExpressionOp>(op) &&
18051805
shouldBeInlined(cast<emitc::ExpressionOp>(op))))
18061806
return success();

0 commit comments

Comments
 (0)