-
Notifications
You must be signed in to change notification settings - Fork 447
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
Implement a semantic-less comparison for IR nodes. #4302
base: main
Are you sure you want to change the base?
Conversation
9e8b5c8
to
618a3e1
Compare
c6997a5
to
cdd44a6
Compare
011cf5d
to
a2e0aed
Compare
It seems to me like this would mean that I'd suggest defining a member function instead (e.g. |
The way |
3579104
to
39df9b8
Compare
dab3f29
to
a065152
Compare
a065152
to
52e8daa
Compare
Just some loud thinking. Now we are having an integer typeid for each node, so could order according to these. And only for same typeid we can use something "internal" |
Yes, at least for base types and nodes! I still do need a form of semantic comparison on all the pointer members. |
52e8daa
to
cd9f797
Compare
2a4b843
to
2388500
Compare
I replaced |
2388500
to
9f41b51
Compare
0c4f381
to
4edc8c8
Compare
34c5c0c
to
afcd0ea
Compare
afcd0ea
to
8cfe4f7
Compare
8cfe4f7
to
b27ddeb
Compare
b27ddeb
to
a9bed2d
Compare
61b5311
to
4aa774f
Compare
569839f
to
56899d9
Compare
56899d9
to
9e60469
Compare
Signed-off-by: fruffy <[email protected]>
Signed-off-by: fruffy <[email protected]>
9e60469
to
9d0b2d3
Compare
IR nodes can not be part of sets or maps because they do not implement
operator<
. This makes maintaining a collection of nodes difficult (especially when pointer values change). This PR is an attempt to implement a generaloperator<
for all nodes.This PR is a pragmatic way to approach this problem, ideally ordering should be concretely specified in the compiler.
Currently, ordering is approached similarly to how
equiv
works for each node. We do not compare based on pointers, but based on the values of each node member. The tests contain a list of nonexhaustives example, for instance:In general, ordering is deferred to the members of each IR node. Ordering priority is evaluated based on the order of the individual members of a class. Nodes themselves are sorted based on their
node_type_name()
. This function returns a cstring, which provides the same ordering guarantees as cstring does.We should also implement hash operators for nodes, but this is something that is be handled separately.