Skip to content
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

Clean up encoding-related code. NFC. #19717

Merged
merged 1 commit into from
Jan 16, 2025
Merged

Conversation

kuhar
Copy link
Member

@kuhar kuhar commented Jan 16, 2025

Fixing misc issues before modifying the surrounding code.

Fixing misc issues before modifying the surrounding code.

Signed-off-by: Jakub Kuderski <jakub@nod-labs.com>
@kuhar kuhar enabled auto-merge (squash) January 16, 2025 02:26
@kuhar kuhar merged commit 5ee9b27 into iree-org:main Jan 16, 2025
36 checks passed
auto addRhsOp = addRhs.getDefiningOp();
Value addLhs = addOp->getOperand(0);
Value addRhs = addOp->getOperand(1);
Operation *addLhsOp = addLhs.getDefiningOp();
Copy link
Collaborator

@benvanik benvanik Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good IDEs/LSPs really help with this stuff - readability without one is important (code reviews/those just peeking at source/etc) but anyone modifying the code can reasonably be expected to have a working development environment or this isn't their biggest issue - tblgen-produced op/attr defs are :P

Readability could be improved with the * - I prefer auto * for pointers where the type is obvious instead of just auto as due to MLIR's weird mix of value and pointer types. But we generally don't want to churn code unless it helps or is making things more consistent. This PR on a single file doesn't much matter but it's a game of whack-a-mole as it'd be just as valid for someone to come in and turn Operation *op = ...getOp() into auto *op = and we don't want to have randomness. I'm mostly focused on consistency - if you can get upstream to use Operation * when calling a getDefiningOp() and all other cases where something is an op then we can match that style - but otherwise it's just inconsistency (file A is different than file B in the same directory arbitrarily). 75% of getDefiningOp calls upstream and in IREE use auto of some kind. If you think there's consensus upstream that auto is misused on a line with "Op" in it twice then we should do a large scale change upstream and in our code and make that a rule (I'd be for that - just don't like the inconsistency :).

Copy link
Member Author

@kuhar kuhar Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression that we are following the llvm coding standards for the most parts, which cover the use of auto: https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable

Don’t “almost always” use auto, but do use auto with initializers like cast(...) or other places where the type is already obvious from the context.

To me these rules make sense and I find it useful to see types even without an IDE. This comes up quite often when sharing links to specific lines of code with other folks. And probably most importantly, in code reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants