[mlir][emitc] Refactor getEmittedExpression (NFC)#168361
Merged
Conversation
Member
|
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-emitc Author: Gil Rapaport (aniragil) ChangesThis 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. Full diff: https://github.com/llvm/llvm-project/pull/168361.diff 1 Files Affected:
diff --git a/mlir/lib/Target/Cpp/TranslateToCpp.cpp b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
index 6bd76bb1ffc4b..5bf6108756a2f 100644
--- a/mlir/lib/Target/Cpp/TranslateToCpp.cpp
+++ b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
@@ -250,8 +250,8 @@ struct CppEmitter {
return !fileId.empty() && file.getId() == fileId;
}
- /// Get expression currently being emitted.
- ExpressionOp getEmittedExpression() { return emittedExpression; }
+ /// Is expression currently being emitted.
+ bool isEmittingExpression() { return emittedExpression; }
/// Determine whether given value is part of the expression potentially being
/// emitted.
@@ -1630,11 +1630,11 @@ LogicalResult CppEmitter::emitOperands(Operation &op) {
return interleaveCommaWithError(op.getOperands(), os, [&](Value operand) {
// If an expression is being emitted, push lowest precedence as these
// operands are either wrapped by parenthesis.
- if (getEmittedExpression())
+ if (isEmittingExpression())
pushExpressionPrecedence(lowestPrecedence());
if (failed(emitOperand(operand)))
return failure();
- if (getEmittedExpression())
+ if (isEmittingExpression())
popExpressionPrecedence();
return success();
});
@@ -1718,7 +1718,7 @@ LogicalResult CppEmitter::emitGlobalVariable(GlobalOp op) {
LogicalResult CppEmitter::emitAssignPrefix(Operation &op) {
// If op is being emitted as part of an expression, bail out.
- if (getEmittedExpression())
+ if (isEmittingExpression())
return success();
switch (op.getNumResults()) {
@@ -1800,7 +1800,7 @@ LogicalResult CppEmitter::emitOperation(Operation &op, bool trailingSemicolon) {
if (hasDeferredEmission(&op))
return success();
- if (getEmittedExpression() ||
+ if (isEmittingExpression() ||
(isa<emitc::ExpressionOp>(op) &&
shouldBeInlined(cast<emitc::ExpressionOp>(op))))
return success();
|
Contributor
Author
|
ping |
simon-camp
approved these changes
Nov 24, 2025
Contributor
Author
|
thanks @simon-camp ! |
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.
6f89af4 to
cb8fef4
Compare
Contributor
Author
|
(rebased, one of the uses of |
aadeshps-mcw
pushed a commit
to aadeshps-mcw/llvm-project
that referenced
this pull request
Nov 26, 2025
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.
Priyanshu3820
pushed a commit
to Priyanshu3820/llvm-project
that referenced
this pull request
Nov 26, 2025
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.
augusto2112
pushed a commit
to augusto2112/llvm-project
that referenced
this pull request
Dec 3, 2025
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.