Stream: t-compiler/const-eval

Topic: reuse visitor for const patterns


oli (Nov 14 2018 at 09:41, on Zulip):

We convert const items used in patterns into full patterns by expanding e.g. a use of const FOO: (u32, u32) = (5, 6); as a FOO pattern into a tuple pattern of constants like (5, 6). This is main user of const_field and const_downcast. I have started looking into cleaning this up. There's significant overlap with Visitor, but I don't really know how to use the Visitors for that use case. What I basically want is to not mutate a value in place by visiting it, I want to convert it to a completely different type

oli (Nov 14 2018 at 09:43, on Zulip):

@RalfJ do you think these use cases are different enough to warrant a parallel but similar setup? Or should I try to make the Visitors support my use case?

RalfJ (Nov 14 2018 at 09:45, on Zulip):

main user of const_field and const_downcast

main or only? :D

RalfJ (Nov 14 2018 at 09:48, on Zulip):

@RalfJ do you think these use cases are different enough to warrant a parallel but similar setup? Or should I try to make the Visitors support my use case?

I suppose this depends on how much of a change this would require to the visitor, how big the complexity cost is there. I suppose what you want is a thing where the visit methods actually return something? Turning them from visit more into a map_and_fold? I feel this should be possible to add without too much additional complexity, where the default visitor uses () as return type.

oli (Nov 14 2018 at 09:49, on Zulip):

main user, but the other one can be solved, too I think. The other user is some simd stuff during mir construction

oli (Nov 14 2018 at 09:50, on Zulip):

Yea, I think the return value change should totally suffice and not affect the regular visitor uses at all.

RalfJ (Nov 14 2018 at 10:05, on Zulip):

well there will likely have to be a folding method somewhere for which we cannot have a default impl. but the visitor implementation would trivially return (). or maybe I am wrong and we have enough wrappers for that already.

RalfJ (Nov 14 2018 at 10:05, on Zulip):

So yeah, generalizing from a visitor to a map-fold is fine for me

Last update: Nov 15 2019 at 20:40UTC