Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Replace gt## with As## #27122

Merged
merged 4 commits into from
Oct 12, 2019
Merged

Replace gt## with As## #27122

merged 4 commits into from
Oct 12, 2019

Conversation

franksinankaya
Copy link

@mikedn
Copy link

mikedn commented Oct 10, 2019

gtOp. should be replaced with AsOp()->.

@franksinankaya
Copy link
Author

Sure, let's see the consensus. The only agreement I heart so far was GetXYZ/SetXYZ and IsXYZ/SetXYZ function combinations.

@mikedn
Copy link

mikedn commented Oct 10, 2019

That was for actual getter/setter functions. This gtOp thing and others like it are basically casts - they cast the node pointer to another GenTree class, while asserting that the node has the proper operator. Hence the "as" name, which is used in many other places already.

@franksinankaya
Copy link
Author

I see how about converting gtOp. to gtOp()./AsOp(). with a stub function as in this review?

I want to make the diff as close as possible for easy review.
I can go both ways. It doesn't matter for me.

@mikedn
Copy link

mikedn commented Oct 10, 2019

I'm not sure I understand what the stub is for. AsOp() already exists so it's simply a matter of replacing gtOp. with AsOp()->. Then, in another PR, you can do another gtX -> AsX replacement and once it's all done you can delete the __declspec.

@franksinankaya franksinankaya changed the title Replace gt## with Get## Replace gt## with As## Oct 10, 2019
Copy link

@sandreenko sandreenko left a comment

Choose a reason for hiding this comment

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

Thanks for that change, LGTM, ignore the notes, I will fix them in another PR.

@dotnet/jit-contrib please pay attention that this PR deletes tree.gtOp property, use AsOp() instead from now.

It is very appealing to replace all AsOp()->gtOp1 with gtGetOp1(), but as I remember @mikedn wants to get rid of gtGetOp1(), am I correct?

src/jit/compiler.hpp Outdated Show resolved Hide resolved
src/jit/flowgraph.cpp Outdated Show resolved Hide resolved
src/jit/gentree.cpp Show resolved Hide resolved
src/jit/importer.cpp Show resolved Hide resolved
src/jit/gcinfo.cpp Show resolved Hide resolved
src/jit/gentree.cpp Show resolved Hide resolved
@mikedn
Copy link

mikedn commented Oct 11, 2019

It is very appealing to replace all AsOp()->gtOp1 with gtGetOp1(), but as I remember @mikedn wants to get rid of gtGetOp1(), am I correct?

What I'd really like is to move gtGetOp1() and gtGetOp2() to GenTreeUnOp and GenTreeOp respectively.

I'm not sure if we'll ever get there though (it would require a very large PR) but I would recommend casting to the appropriate class before calling these 2 functions. Since you're going to call them you should already know what class you're dealing with and it makes the code more readable (though perhaps slightly longer, thanks to the unfortunate extensive use of GenTree* instead of the actual type) if that is made explicit.

This is even more important when the actual node class has getter/setters with alternative names, like GenTreeStoreInd has Addr() for gtOp1 and Data() for gtOp2. Using generic op1 and op2 names in such case makes the code even harder to follow and increases the chances of accidentally mixing up the 2 operands.

Given the above, I don't think that any kind of mechanical replacement around gtOp1, gtGetOp1 & co. is feasible. It will have to be done on a case by case basis.

@franksinankaya
Copy link
Author

@sandreenko : I'm assuming that you are taking care of the rest per your notes above. Let me know otherwise.

@sandreenko
Copy link

@sandreenko : I'm assuming that you are taking care of the rest per your notes above. Let me know otherwise.

Yes, thanks for the last commit. I was planning to do it myself as well, was just waiting for clean testing to merge that before this PR gets merge conflicts.

@sandreenko
Copy link

Link https://github.com/dotnet/coreclr/issues/27155, merging on red, the failures are not related to the change.

@sandreenko sandreenko merged commit fd0ca99 into dotnet:master Oct 12, 2019
@franksinankaya
Copy link
Author

Just a note here that converting gtXYZ. to AsXYZ() is going to cost 36 more reviews.

@franksinankaya franksinankaya deleted the frkaya/gt branch October 12, 2019 18:35
sandreenko pushed a commit to sandreenko/coreclr that referenced this pull request Oct 15, 2019
sandreenko pushed a commit to sandreenko/coreclr that referenced this pull request Oct 15, 2019
sandreenko pushed a commit that referenced this pull request Oct 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants