mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 13:31:06 +01:00
Promote FunctionType to a standard instruction. (#3931)
This removes the builtin FunctionType, replacing it with a FunctionType instruction. The constant for a FunctionDecl is now a StructValue with type of FunctionType. Note this means a function declaration produces _both_ a type, and a value of the type. This has some consequences in terms of circularity, and makes the importing of function declarations a little more complex. It'll get particularly peculiar for imports because of the behavior of the reference, but that's a known issue due to other things such as `alias`. The impact will hopefully be contained to ResolvePrevInstForMerge (and ImportRefs). To note a small formatting change in diagnostics: ``` - // CHECK:STDERR: fail_member_lookup.carbon:[[@LINE+4]]:3: ERROR: Value of type `<associated <function> in Interface>` is not callable. + // CHECK:STDERR: fail_member_lookup.carbon:[[@LINE+4]]:3: ERROR: Value of type `<associated F in Interface>` is not callable. - // CHECK:STDERR: fail_todo_facet_lookup.carbon:[[@LINE+4]]:3: ERROR: Value of type `<associated <function> in Interface>` is not callable. + // CHECK:STDERR: fail_todo_facet_lookup.carbon:[[@LINE+4]]:3: ERROR: Value of type `<associated F in Interface>` is not callable. ``` --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
co-authored by
Richard Smith
parent
e6061f6910
commit
76ed3c73cb
+34
-31
@@ -13,64 +13,67 @@ fn G() {
|
||||
// CHECK:STDOUT: --- array_vs_tuple.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %.1: i32 = int_literal 3 [template]
|
||||
// CHECK:STDOUT: %.2: type = array_type %.1, i32 [template]
|
||||
// CHECK:STDOUT: %.3: type = ptr_type [i32; 3] [template]
|
||||
// CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
|
||||
// CHECK:STDOUT: %.5: i32 = int_literal 2 [template]
|
||||
// CHECK:STDOUT: %.6: type = tuple_type (i32, i32, i32) [template]
|
||||
// CHECK:STDOUT: %.7: i32 = int_literal 0 [template]
|
||||
// CHECK:STDOUT: %array: [i32; 3] = tuple_value (%.4, %.5, %.1) [template]
|
||||
// CHECK:STDOUT: %.8: type = tuple_type (type, type, type) [template]
|
||||
// CHECK:STDOUT: %.9: type = ptr_type (i32, i32, i32) [template]
|
||||
// CHECK:STDOUT: %tuple: (i32, i32, i32) = tuple_value (%.4, %.5, %.1) [template]
|
||||
// CHECK:STDOUT: %G: type = fn_type @G [template]
|
||||
// CHECK:STDOUT: %.1: type = tuple_type () [template]
|
||||
// CHECK:STDOUT: %struct: G = struct_value () [template]
|
||||
// CHECK:STDOUT: %.2: i32 = int_literal 3 [template]
|
||||
// CHECK:STDOUT: %.3: type = array_type %.2, i32 [template]
|
||||
// CHECK:STDOUT: %.4: type = ptr_type [i32; 3] [template]
|
||||
// CHECK:STDOUT: %.5: i32 = int_literal 1 [template]
|
||||
// CHECK:STDOUT: %.6: i32 = int_literal 2 [template]
|
||||
// CHECK:STDOUT: %.7: type = tuple_type (i32, i32, i32) [template]
|
||||
// CHECK:STDOUT: %.8: i32 = int_literal 0 [template]
|
||||
// CHECK:STDOUT: %array: [i32; 3] = tuple_value (%.5, %.6, %.2) [template]
|
||||
// CHECK:STDOUT: %.9: type = tuple_type (type, type, type) [template]
|
||||
// CHECK:STDOUT: %.10: type = ptr_type (i32, i32, i32) [template]
|
||||
// CHECK:STDOUT: %tuple: (i32, i32, i32) = tuple_value (%.5, %.6, %.2) [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = %Core
|
||||
// CHECK:STDOUT: .G = %G
|
||||
// CHECK:STDOUT: .G = %G.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
|
||||
// CHECK:STDOUT: %G: <function> = fn_decl @G [template] {}
|
||||
// CHECK:STDOUT: %G.decl: G = fn_decl @G [template = constants.%struct] {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @G() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %.loc9_16: i32 = int_literal 3 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc9_17: type = array_type %.loc9_16, i32 [template = constants.%.2]
|
||||
// CHECK:STDOUT: %.loc9_16: i32 = int_literal 3 [template = constants.%.2]
|
||||
// CHECK:STDOUT: %.loc9_17: type = array_type %.loc9_16, i32 [template = constants.%.3]
|
||||
// CHECK:STDOUT: %a.var: ref [i32; 3] = var a
|
||||
// CHECK:STDOUT: %a: ref [i32; 3] = bind_name a, %a.var
|
||||
// CHECK:STDOUT: %.loc9_22: i32 = int_literal 1 [template = constants.%.4]
|
||||
// CHECK:STDOUT: %.loc9_25: i32 = int_literal 2 [template = constants.%.5]
|
||||
// CHECK:STDOUT: %.loc9_28: i32 = int_literal 3 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc9_22: i32 = int_literal 1 [template = constants.%.5]
|
||||
// CHECK:STDOUT: %.loc9_25: i32 = int_literal 2 [template = constants.%.6]
|
||||
// CHECK:STDOUT: %.loc9_28: i32 = int_literal 3 [template = constants.%.2]
|
||||
// CHECK:STDOUT: %.loc9_29.1: (i32, i32, i32) = tuple_literal (%.loc9_22, %.loc9_25, %.loc9_28)
|
||||
// CHECK:STDOUT: %.loc9_29.2: i32 = int_literal 0 [template = constants.%.7]
|
||||
// CHECK:STDOUT: %.loc9_29.2: i32 = int_literal 0 [template = constants.%.8]
|
||||
// CHECK:STDOUT: %.loc9_29.3: ref i32 = array_index %a.var, %.loc9_29.2
|
||||
// CHECK:STDOUT: %.loc9_29.4: init i32 = initialize_from %.loc9_22 to %.loc9_29.3 [template = constants.%.4]
|
||||
// CHECK:STDOUT: %.loc9_29.5: i32 = int_literal 1 [template = constants.%.4]
|
||||
// CHECK:STDOUT: %.loc9_29.4: init i32 = initialize_from %.loc9_22 to %.loc9_29.3 [template = constants.%.5]
|
||||
// CHECK:STDOUT: %.loc9_29.5: i32 = int_literal 1 [template = constants.%.5]
|
||||
// CHECK:STDOUT: %.loc9_29.6: ref i32 = array_index %a.var, %.loc9_29.5
|
||||
// CHECK:STDOUT: %.loc9_29.7: init i32 = initialize_from %.loc9_25 to %.loc9_29.6 [template = constants.%.5]
|
||||
// CHECK:STDOUT: %.loc9_29.8: i32 = int_literal 2 [template = constants.%.5]
|
||||
// CHECK:STDOUT: %.loc9_29.7: init i32 = initialize_from %.loc9_25 to %.loc9_29.6 [template = constants.%.6]
|
||||
// CHECK:STDOUT: %.loc9_29.8: i32 = int_literal 2 [template = constants.%.6]
|
||||
// CHECK:STDOUT: %.loc9_29.9: ref i32 = array_index %a.var, %.loc9_29.8
|
||||
// CHECK:STDOUT: %.loc9_29.10: init i32 = initialize_from %.loc9_28 to %.loc9_29.9 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc9_29.10: init i32 = initialize_from %.loc9_28 to %.loc9_29.9 [template = constants.%.2]
|
||||
// CHECK:STDOUT: %.loc9_29.11: init [i32; 3] = array_init (%.loc9_29.4, %.loc9_29.7, %.loc9_29.10) to %a.var [template = constants.%array]
|
||||
// CHECK:STDOUT: %.loc9_30: init [i32; 3] = converted %.loc9_29.1, %.loc9_29.11 [template = constants.%array]
|
||||
// CHECK:STDOUT: assign %a.var, %.loc9_30
|
||||
// CHECK:STDOUT: %.loc10_24.1: (type, type, type) = tuple_literal (i32, i32, i32)
|
||||
// CHECK:STDOUT: %.loc10_24.2: type = converted %.loc10_24.1, constants.%.6 [template = constants.%.6]
|
||||
// CHECK:STDOUT: %.loc10_24.2: type = converted %.loc10_24.1, constants.%.7 [template = constants.%.7]
|
||||
// CHECK:STDOUT: %b.var: ref (i32, i32, i32) = var b
|
||||
// CHECK:STDOUT: %b: ref (i32, i32, i32) = bind_name b, %b.var
|
||||
// CHECK:STDOUT: %.loc10_29: i32 = int_literal 1 [template = constants.%.4]
|
||||
// CHECK:STDOUT: %.loc10_32: i32 = int_literal 2 [template = constants.%.5]
|
||||
// CHECK:STDOUT: %.loc10_35: i32 = int_literal 3 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc10_29: i32 = int_literal 1 [template = constants.%.5]
|
||||
// CHECK:STDOUT: %.loc10_32: i32 = int_literal 2 [template = constants.%.6]
|
||||
// CHECK:STDOUT: %.loc10_35: i32 = int_literal 3 [template = constants.%.2]
|
||||
// CHECK:STDOUT: %.loc10_36.1: (i32, i32, i32) = tuple_literal (%.loc10_29, %.loc10_32, %.loc10_35)
|
||||
// CHECK:STDOUT: %.loc10_36.2: ref i32 = tuple_access %b.var, element0
|
||||
// CHECK:STDOUT: %.loc10_36.3: init i32 = initialize_from %.loc10_29 to %.loc10_36.2 [template = constants.%.4]
|
||||
// CHECK:STDOUT: %.loc10_36.3: init i32 = initialize_from %.loc10_29 to %.loc10_36.2 [template = constants.%.5]
|
||||
// CHECK:STDOUT: %.loc10_36.4: ref i32 = tuple_access %b.var, element1
|
||||
// CHECK:STDOUT: %.loc10_36.5: init i32 = initialize_from %.loc10_32 to %.loc10_36.4 [template = constants.%.5]
|
||||
// CHECK:STDOUT: %.loc10_36.5: init i32 = initialize_from %.loc10_32 to %.loc10_36.4 [template = constants.%.6]
|
||||
// CHECK:STDOUT: %.loc10_36.6: ref i32 = tuple_access %b.var, element2
|
||||
// CHECK:STDOUT: %.loc10_36.7: init i32 = initialize_from %.loc10_35 to %.loc10_36.6 [template = constants.%.1]
|
||||
// CHECK:STDOUT: %.loc10_36.7: init i32 = initialize_from %.loc10_35 to %.loc10_36.6 [template = constants.%.2]
|
||||
// CHECK:STDOUT: %.loc10_36.8: init (i32, i32, i32) = tuple_init (%.loc10_36.3, %.loc10_36.5, %.loc10_36.7) to %b.var [template = constants.%tuple]
|
||||
// CHECK:STDOUT: %.loc10_37: init (i32, i32, i32) = converted %.loc10_36.1, %.loc10_36.8 [template = constants.%tuple]
|
||||
// CHECK:STDOUT: assign %b.var, %.loc10_37
|
||||
|
||||
Reference in New Issue
Block a user