-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[mlir][emitc] Refactor getEmittedExpression (NFC) #168361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mlir][emitc] Refactor getEmittedExpression (NFC) #168361
Conversation
|
@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();
|
|
ping |
|
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
|
(rebased, one of the uses of |
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 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 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.