Distinguish between template constants and symbolic constants. (#3595)

This is accomplished by tracking an extra bit on the ID we store in the
constant values table, and propagating that from subexpressions to the
enclosing expression. This extra bit is not yet computed correctly for
types; that will be addressed in later PRs.

---------

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
Richard Smith
2024-01-12 02:56:22 +00:00
committed by GitHub
co-authored by Chandler Carruth
parent 8ba24bbe41
commit a3154356f0
284 changed files with 2735 additions and 2641 deletions
@@ -74,12 +74,12 @@ default final virtual fn ModifiersConflict2() {}
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.WrongOrder = %WrongOrder, .DuplicateVirtual = %DuplicateVirtual, .TwoAccess = %TwoAccess, .ModifiersConflict = %ModifiersConflict, .InvalidModifier = %InvalidModifier, .ModifiersConflict2 = %ModifiersConflict2}
// CHECK:STDOUT: %WrongOrder: <function> = fn_decl @WrongOrder, const
// CHECK:STDOUT: %DuplicateVirtual: <function> = fn_decl @DuplicateVirtual, const
// CHECK:STDOUT: %TwoAccess: <function> = fn_decl @TwoAccess, const
// CHECK:STDOUT: %ModifiersConflict: <function> = fn_decl @ModifiersConflict, const
// CHECK:STDOUT: %InvalidModifier: <function> = fn_decl @InvalidModifier, const
// CHECK:STDOUT: %ModifiersConflict2: <function> = fn_decl @ModifiersConflict2, const
// CHECK:STDOUT: %WrongOrder: <function> = fn_decl @WrongOrder [template]
// CHECK:STDOUT: %DuplicateVirtual: <function> = fn_decl @DuplicateVirtual [template]
// CHECK:STDOUT: %TwoAccess: <function> = fn_decl @TwoAccess [template]
// CHECK:STDOUT: %ModifiersConflict: <function> = fn_decl @ModifiersConflict [template]
// CHECK:STDOUT: %InvalidModifier: <function> = fn_decl @InvalidModifier [template]
// CHECK:STDOUT: %ModifiersConflict2: <function> = fn_decl @ModifiersConflict2 [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @WrongOrder();
@@ -13,7 +13,7 @@ private fn F();
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.F = %F}
// CHECK:STDOUT: %F: <function> = fn_decl @F, const
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F();
@@ -11,20 +11,20 @@ fn G() { F(); }
// CHECK:STDOUT: --- simple.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %.loc9: type = tuple_type (), const
// CHECK:STDOUT: %.loc9: type = tuple_type () [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
// CHECK:STDOUT: package: <namespace> = namespace package, {.F = %F, .G = %G}
// CHECK:STDOUT: %F: <function> = fn_decl @F, const
// CHECK:STDOUT: %G: <function> = fn_decl @G, const
// CHECK:STDOUT: %F: <function> = fn_decl @F [template]
// CHECK:STDOUT: %G: <function> = fn_decl @G [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @F();
// CHECK:STDOUT:
// CHECK:STDOUT: fn @G() {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %F.ref: <function> = name_ref F, file.%F, const = file.%F
// CHECK:STDOUT: %F.ref: <function> = name_ref F, file.%F [template = file.%F]
// CHECK:STDOUT: %.loc9: init () = call %F.ref()
// CHECK:STDOUT: return
// CHECK:STDOUT: }