-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add a FacetValue
instruction
#4545
base: trunk
Are you sure you want to change the base?
Conversation
// CHECK:STDOUT: } | ||
// CHECK:STDOUT: | ||
// CHECK:STDOUT: specific @F.1(i32) {} | ||
// CHECK:STDOUT: specific @F.1(@impl.%.loc17) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I think this should be referring to the constant value of the FacetValue
instruction, not to the instruction itself, or we won't properly deduplicate specifics for the same type.
Probably just need a constant_values().Get
call when we create the FacetValue
-- or you can pass the FacetValue
directly to TryEvalInst
to get a ConstantId
without creating an extra instruction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is expecting an InstId
, not a ConstantId
-- is the idea that I will get the InstId
for the constant? TryEvalInst
also takes an InstId
argument, should I pass in invalid or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the PR with the TryEvalInst
approach with an invalid InstId
. It does reduce the constant indices back, as well as changing the arguments to these specifics.
toolchain/sem_ir/stringify_type.cpp
Outdated
push_inst_id(inst.type_inst_id); | ||
push_string(" as "); | ||
push_inst_id(sem_ir.types().GetInstId(inst.type_id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be:
push_inst_id(inst.type_inst_id); | |
push_string(" as "); | |
push_inst_id(sem_ir.types().GetInstId(inst.type_id)); | |
push_inst_id(sem_ir.types().GetInstId(inst.type_id)); | |
push_string(" as "); | |
push_inst_id(inst.type_inst_id); |
... because we process the pushed parts in reverse order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied this change, but it seems this isn't covered by any of our tests. When would this type be stringified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the test you suggested, which seemed to have worked! 1371f33
Co-authored-by: Richard Smith <[email protected]>
Should I be concerned about the number of unused constants being generated? The most recent change seems to have increased how much this is happening: d605bf2 |
Co-authored-by: Richard Smith <[email protected]>
The new
FacetValue
instruction representsC as I
for some typeC
and facet typeI
. It is namedFacetValue
instead of justFacet
to parallel theFacetType
instruction.This PR uses this instruction represent the facet value
Self
in animpl
declaration. This instruction will be used in the future to also support things like:C as I
whereC
is a class; andT:! I
parameter whereT
is being given a concrete value.(Here
I
is an interface or other non-type
facet type.)Also do some renaming and add some comments to make things a bit more clear.
FacetTypeAccess
->FacetAccessType
to clarify this is not access of a facet type, but access of the type of a facet.facet_id
->.facet_value_inst_id
to parallel theFacetValue
instructionFacetAccessWitness
will be in a future PR.