import_builtin_call.carbon 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/no_prelude/import_builtin_call.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/no_prelude/import_builtin_call.carbon
  10. // --- generic_impl.carbon
  11. library "[[@TEST_NAME]]";
  12. interface Add {
  13. fn Op[self: Self](other: Self) -> Self;
  14. }
  15. fn IntLiteral() -> type = "int_literal.make_type";
  16. fn Int(n: IntLiteral()) -> type = "int.make_type_signed";
  17. class MyInt(N:! IntLiteral()) {
  18. adapt Int(N);
  19. }
  20. impl forall [N:! IntLiteral()] MyInt(N) as Add {
  21. fn Op[self: Self](other: Self) -> Self = "int.sadd";
  22. }
  23. fn Double[N:! IntLiteral()](x: MyInt(N)) -> MyInt(N) {
  24. return x.(Add.Op)(x);
  25. }
  26. // --- use_generic_impl.carbon
  27. library "[[@TEST_NAME]]";
  28. import library "generic_impl";
  29. // TODO: The call below crashes if this one is not present because the generics
  30. // get imported in a bad order.
  31. fn LocalDouble(x: MyInt(64)) -> MyInt(64) {
  32. return x.(Add.Op)(x);
  33. }
  34. fn CallImportedDouble(n: MyInt(64)) -> MyInt(64) {
  35. return Double(n);
  36. }
  37. // --- convert_symbolic.carbon
  38. library "[[@TEST_NAME]]";
  39. fn IntLiteral() -> type = "int_literal.make_type";
  40. fn Int(n: IntLiteral()) -> type = "int.make_type_signed";
  41. fn ToLiteral(n: Int(32)) -> IntLiteral() = "int.convert_checked";
  42. fn FromLiteral(n: IntLiteral()) -> Int(32) = "int.convert_checked";
  43. fn Make(N:! Int(32)) -> Int(ToLiteral(N)) { return Make(N); }
  44. class OtherInt {
  45. adapt Int(32);
  46. fn ToLiteral[self: Self]() -> IntLiteral();
  47. };
  48. fn OtherInt.ToLiteral[self: Self]() -> IntLiteral() = "int.convert_checked";
  49. fn MakeFromClass(N:! OtherInt) -> Int(N.ToLiteral()) { return MakeFromClass(N); }
  50. // --- use_convert_symbolic.carbon
  51. library "[[@TEST_NAME]]";
  52. import library "convert_symbolic";
  53. var m: Int(64) = Make(FromLiteral(64));
  54. var n: Int(64) = MakeFromClass(FromLiteral(64) as OtherInt);
  55. // CHECK:STDOUT: --- generic_impl.carbon
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: constants {
  58. // CHECK:STDOUT: %Add.type: type = facet_type <@Add> [template]
  59. // CHECK:STDOUT: %Self: %Add.type = bind_symbolic_name Self, 0 [symbolic]
  60. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic]
  61. // CHECK:STDOUT: %Op.type.16a: type = fn_type @Op.1 [template]
  62. // CHECK:STDOUT: %Op.93e: %Op.type.16a = struct_value () [template]
  63. // CHECK:STDOUT: %Op.assoc_type: type = assoc_entity_type %Add.type, %Op.type.16a [template]
  64. // CHECK:STDOUT: %assoc0: %Op.assoc_type = assoc_entity element0, @Add.%Op.decl [template]
  65. // CHECK:STDOUT: %IntLiteral.type: type = fn_type @IntLiteral [template]
  66. // CHECK:STDOUT: %IntLiteral: %IntLiteral.type = struct_value () [template]
  67. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  68. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  69. // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic]
  70. // CHECK:STDOUT: %N.patt: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic]
  71. // CHECK:STDOUT: %MyInt.type: type = generic_class_type @MyInt [template]
  72. // CHECK:STDOUT: %MyInt.generic: %MyInt.type = struct_value () [template]
  73. // CHECK:STDOUT: %MyInt: type = class_type @MyInt, @MyInt(%N) [symbolic]
  74. // CHECK:STDOUT: %iN.builtin: type = int_type signed, %N [symbolic]
  75. // CHECK:STDOUT: %require_complete.889: <witness> = require_complete_type %iN.builtin [symbolic]
  76. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %iN.builtin [symbolic]
  77. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%Op.decl), @impl(%N) [symbolic]
  78. // CHECK:STDOUT: %Op.type.43e: type = fn_type @Op.2, @impl(%N) [symbolic]
  79. // CHECK:STDOUT: %Op.83a: %Op.type.43e = struct_value () [symbolic]
  80. // CHECK:STDOUT: %require_complete.b8c: <witness> = require_complete_type %MyInt [symbolic]
  81. // CHECK:STDOUT: %Add.facet: %Add.type = facet_value %MyInt, %impl_witness [symbolic]
  82. // CHECK:STDOUT: %Double.type: type = fn_type @Double [template]
  83. // CHECK:STDOUT: %Double: %Double.type = struct_value () [template]
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: file {
  87. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  88. // CHECK:STDOUT: .Add = %Add.decl
  89. // CHECK:STDOUT: .IntLiteral = %IntLiteral.decl
  90. // CHECK:STDOUT: .Int = %Int.decl
  91. // CHECK:STDOUT: .MyInt = %MyInt.decl
  92. // CHECK:STDOUT: .Double = %Double.decl
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: %Add.decl: type = interface_decl @Add [template = constants.%Add.type] {} {}
  95. // CHECK:STDOUT: %IntLiteral.decl: %IntLiteral.type = fn_decl @IntLiteral [template = constants.%IntLiteral] {
  96. // CHECK:STDOUT: %return.patt: type = return_slot_pattern
  97. // CHECK:STDOUT: %return.param_patt: type = out_param_pattern %return.patt, runtime_param0
  98. // CHECK:STDOUT: } {
  99. // CHECK:STDOUT: %return.param: ref type = out_param runtime_param0
  100. // CHECK:STDOUT: %return: ref type = return_slot %return.param
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT: %Int.decl: %Int.type = fn_decl @Int [template = constants.%Int] {
  103. // CHECK:STDOUT: %n.patt: Core.IntLiteral = binding_pattern n
  104. // CHECK:STDOUT: %n.param_patt: Core.IntLiteral = value_param_pattern %n.patt, runtime_param0
  105. // CHECK:STDOUT: %return.patt: type = return_slot_pattern
  106. // CHECK:STDOUT: %return.param_patt: type = out_param_pattern %return.patt, runtime_param1
  107. // CHECK:STDOUT: } {
  108. // CHECK:STDOUT: %n.param: Core.IntLiteral = value_param runtime_param0
  109. // CHECK:STDOUT: %.loc9_22.1: type = splice_block %.loc9_22.3 [template = Core.IntLiteral] {
  110. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [template = constants.%IntLiteral]
  111. // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
  112. // CHECK:STDOUT: %.loc9_22.2: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
  113. // CHECK:STDOUT: %.loc9_22.3: type = converted %int_literal.make_type, %.loc9_22.2 [template = Core.IntLiteral]
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT: %n: Core.IntLiteral = bind_name n, %n.param
  116. // CHECK:STDOUT: %return.param: ref type = out_param runtime_param1
  117. // CHECK:STDOUT: %return: ref type = return_slot %return.param
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT: %MyInt.decl: %MyInt.type = class_decl @MyInt [template = constants.%MyInt.generic] {
  120. // CHECK:STDOUT: %N.patt.loc11_13.1: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc11_13.2 (constants.%N.patt)]
  121. // CHECK:STDOUT: %N.param_patt: Core.IntLiteral = value_param_pattern %N.patt.loc11_13.1, runtime_param<invalid> [symbolic = %N.patt.loc11_13.2 (constants.%N.patt)]
  122. // CHECK:STDOUT: } {
  123. // CHECK:STDOUT: %N.param: Core.IntLiteral = value_param runtime_param<invalid>
  124. // CHECK:STDOUT: %.loc11_28.1: type = splice_block %.loc11_28.3 [template = Core.IntLiteral] {
  125. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [template = constants.%IntLiteral]
  126. // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
  127. // CHECK:STDOUT: %.loc11_28.2: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
  128. // CHECK:STDOUT: %.loc11_28.3: type = converted %int_literal.make_type, %.loc11_28.2 [template = Core.IntLiteral]
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT: %N.loc11_13.1: Core.IntLiteral = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc11_13.2 (constants.%N)]
  131. // CHECK:STDOUT: }
  132. // CHECK:STDOUT: impl_decl @impl [template] {
  133. // CHECK:STDOUT: %N.patt.loc15_14.1: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc15_14.2 (constants.%N.patt)]
  134. // CHECK:STDOUT: %N.param_patt: Core.IntLiteral = value_param_pattern %N.patt.loc15_14.1, runtime_param<invalid> [symbolic = %N.patt.loc15_14.2 (constants.%N.patt)]
  135. // CHECK:STDOUT: } {
  136. // CHECK:STDOUT: %MyInt.ref: %MyInt.type = name_ref MyInt, file.%MyInt.decl [template = constants.%MyInt.generic]
  137. // CHECK:STDOUT: %N.ref: Core.IntLiteral = name_ref N, %N.loc15_14.1 [symbolic = %N.loc15_14.2 (constants.%N)]
  138. // CHECK:STDOUT: %MyInt.loc15_39.1: type = class_type @MyInt, @MyInt(constants.%N) [symbolic = %MyInt.loc15_39.2 (constants.%MyInt)]
  139. // CHECK:STDOUT: %Add.ref: type = name_ref Add, file.%Add.decl [template = constants.%Add.type]
  140. // CHECK:STDOUT: %N.param: Core.IntLiteral = value_param runtime_param<invalid>
  141. // CHECK:STDOUT: %.loc15_29.1: type = splice_block %.loc15_29.3 [template = Core.IntLiteral] {
  142. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [template = constants.%IntLiteral]
  143. // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
  144. // CHECK:STDOUT: %.loc15_29.2: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
  145. // CHECK:STDOUT: %.loc15_29.3: type = converted %int_literal.make_type, %.loc15_29.2 [template = Core.IntLiteral]
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT: %N.loc15_14.1: Core.IntLiteral = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc15_14.2 (constants.%N)]
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%Op.decl), @impl(constants.%N) [symbolic = @impl.%impl_witness (constants.%impl_witness)]
  150. // CHECK:STDOUT: %Double.decl: %Double.type = fn_decl @Double [template = constants.%Double] {
  151. // CHECK:STDOUT: %N.patt.loc19_11.1: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc19_11.2 (constants.%N.patt)]
  152. // CHECK:STDOUT: %N.param_patt: Core.IntLiteral = value_param_pattern %N.patt.loc19_11.1, runtime_param<invalid> [symbolic = %N.patt.loc19_11.2 (constants.%N.patt)]
  153. // CHECK:STDOUT: %x.patt: @Double.%MyInt.loc19_39.2 (%MyInt) = binding_pattern x
  154. // CHECK:STDOUT: %x.param_patt: @Double.%MyInt.loc19_39.2 (%MyInt) = value_param_pattern %x.patt, runtime_param0
  155. // CHECK:STDOUT: %return.patt: @Double.%MyInt.loc19_39.2 (%MyInt) = return_slot_pattern
  156. // CHECK:STDOUT: %return.param_patt: @Double.%MyInt.loc19_39.2 (%MyInt) = out_param_pattern %return.patt, runtime_param1
  157. // CHECK:STDOUT: } {
  158. // CHECK:STDOUT: %MyInt.ref.loc19_45: %MyInt.type = name_ref MyInt, file.%MyInt.decl [template = constants.%MyInt.generic]
  159. // CHECK:STDOUT: %N.ref.loc19_51: Core.IntLiteral = name_ref N, %N.loc19_11.1 [symbolic = %N.loc19_11.2 (constants.%N)]
  160. // CHECK:STDOUT: %MyInt.loc19_52: type = class_type @MyInt, @MyInt(constants.%N) [symbolic = %MyInt.loc19_39.2 (constants.%MyInt)]
  161. // CHECK:STDOUT: %N.param: Core.IntLiteral = value_param runtime_param<invalid>
  162. // CHECK:STDOUT: %.loc19_26.1: type = splice_block %.loc19_26.3 [template = Core.IntLiteral] {
  163. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [template = constants.%IntLiteral]
  164. // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
  165. // CHECK:STDOUT: %.loc19_26.2: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
  166. // CHECK:STDOUT: %.loc19_26.3: type = converted %int_literal.make_type, %.loc19_26.2 [template = Core.IntLiteral]
  167. // CHECK:STDOUT: }
  168. // CHECK:STDOUT: %N.loc19_11.1: Core.IntLiteral = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc19_11.2 (constants.%N)]
  169. // CHECK:STDOUT: %x.param: @Double.%MyInt.loc19_39.2 (%MyInt) = value_param runtime_param0
  170. // CHECK:STDOUT: %.loc19_39: type = splice_block %MyInt.loc19_39.1 [symbolic = %MyInt.loc19_39.2 (constants.%MyInt)] {
  171. // CHECK:STDOUT: %MyInt.ref.loc19_32: %MyInt.type = name_ref MyInt, file.%MyInt.decl [template = constants.%MyInt.generic]
  172. // CHECK:STDOUT: %N.ref.loc19_38: Core.IntLiteral = name_ref N, %N.loc19_11.1 [symbolic = %N.loc19_11.2 (constants.%N)]
  173. // CHECK:STDOUT: %MyInt.loc19_39.1: type = class_type @MyInt, @MyInt(constants.%N) [symbolic = %MyInt.loc19_39.2 (constants.%MyInt)]
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT: %x: @Double.%MyInt.loc19_39.2 (%MyInt) = bind_name x, %x.param
  176. // CHECK:STDOUT: %return.param: ref @Double.%MyInt.loc19_39.2 (%MyInt) = out_param runtime_param1
  177. // CHECK:STDOUT: %return: ref @Double.%MyInt.loc19_39.2 (%MyInt) = return_slot %return.param
  178. // CHECK:STDOUT: }
  179. // CHECK:STDOUT: }
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: interface @Add {
  182. // CHECK:STDOUT: %Self: %Add.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  183. // CHECK:STDOUT: %Op.decl: %Op.type.16a = fn_decl @Op.1 [template = constants.%Op.93e] {
  184. // CHECK:STDOUT: %self.patt: @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type) = binding_pattern self
  185. // CHECK:STDOUT: %self.param_patt: @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type) = value_param_pattern %self.patt, runtime_param0
  186. // CHECK:STDOUT: %other.patt: @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type) = binding_pattern other
  187. // CHECK:STDOUT: %other.param_patt: @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type) = value_param_pattern %other.patt, runtime_param1
  188. // CHECK:STDOUT: %return.patt: @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type) = return_slot_pattern
  189. // CHECK:STDOUT: %return.param_patt: @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type) = out_param_pattern %return.patt, runtime_param2
  190. // CHECK:STDOUT: } {
  191. // CHECK:STDOUT: %Self.ref.loc5_37: %Add.type = name_ref Self, @Add.%Self [symbolic = %Self (constants.%Self)]
  192. // CHECK:STDOUT: %Self.as_type.loc5_37: type = facet_access_type %Self.ref.loc5_37 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  193. // CHECK:STDOUT: %.loc5_37: type = converted %Self.ref.loc5_37, %Self.as_type.loc5_37 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  194. // CHECK:STDOUT: %self.param: @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type) = value_param runtime_param0
  195. // CHECK:STDOUT: %.loc5_15.1: type = splice_block %.loc5_15.2 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)] {
  196. // CHECK:STDOUT: %Self.ref.loc5_15: %Add.type = name_ref Self, @Add.%Self [symbolic = %Self (constants.%Self)]
  197. // CHECK:STDOUT: %Self.as_type.loc5_15.2: type = facet_access_type %Self.ref.loc5_15 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  198. // CHECK:STDOUT: %.loc5_15.2: type = converted %Self.ref.loc5_15, %Self.as_type.loc5_15.2 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  199. // CHECK:STDOUT: }
  200. // CHECK:STDOUT: %self: @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type) = bind_name self, %self.param
  201. // CHECK:STDOUT: %other.param: @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type) = value_param runtime_param1
  202. // CHECK:STDOUT: %.loc5_28.1: type = splice_block %.loc5_28.2 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)] {
  203. // CHECK:STDOUT: %Self.ref.loc5_28: %Add.type = name_ref Self, @Add.%Self [symbolic = %Self (constants.%Self)]
  204. // CHECK:STDOUT: %Self.as_type.loc5_28: type = facet_access_type %Self.ref.loc5_28 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  205. // CHECK:STDOUT: %.loc5_28.2: type = converted %Self.ref.loc5_28, %Self.as_type.loc5_28 [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT: %other: @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type) = bind_name other, %other.param
  208. // CHECK:STDOUT: %return.param: ref @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type) = out_param runtime_param2
  209. // CHECK:STDOUT: %return: ref @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type) = return_slot %return.param
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT: %assoc0: %Op.assoc_type = assoc_entity element0, %Op.decl [template = constants.%assoc0]
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: !members:
  214. // CHECK:STDOUT: .Self = %Self
  215. // CHECK:STDOUT: .Op = %assoc0
  216. // CHECK:STDOUT: witness = (%Op.decl)
  217. // CHECK:STDOUT: }
  218. // CHECK:STDOUT:
  219. // CHECK:STDOUT: generic impl @impl(%N.loc15_14.1: Core.IntLiteral) {
  220. // CHECK:STDOUT: %N.loc15_14.2: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic = %N.loc15_14.2 (constants.%N)]
  221. // CHECK:STDOUT: %N.patt.loc15_14.2: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc15_14.2 (constants.%N.patt)]
  222. // CHECK:STDOUT: %MyInt.loc15_39.2: type = class_type @MyInt, @MyInt(%N.loc15_14.2) [symbolic = %MyInt.loc15_39.2 (constants.%MyInt)]
  223. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (%Op.decl), @impl(%N.loc15_14.2) [symbolic = %impl_witness (constants.%impl_witness)]
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: !definition:
  226. // CHECK:STDOUT: %Op.type: type = fn_type @Op.2, @impl(%N.loc15_14.2) [symbolic = %Op.type (constants.%Op.type.43e)]
  227. // CHECK:STDOUT: %Op: @impl.%Op.type (%Op.type.43e) = struct_value () [symbolic = %Op (constants.%Op.83a)]
  228. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @impl.%MyInt.loc15_39.2 (%MyInt) [symbolic = %require_complete (constants.%require_complete.b8c)]
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: impl: %MyInt.loc15_39.1 as %Add.ref {
  231. // CHECK:STDOUT: %Op.decl: @impl.%Op.type (%Op.type.43e) = fn_decl @Op.2 [symbolic = @impl.%Op (constants.%Op.83a)] {
  232. // CHECK:STDOUT: %self.patt: @Op.2.%MyInt (%MyInt) = binding_pattern self
  233. // CHECK:STDOUT: %self.param_patt: @Op.2.%MyInt (%MyInt) = value_param_pattern %self.patt, runtime_param0
  234. // CHECK:STDOUT: %other.patt: @Op.2.%MyInt (%MyInt) = binding_pattern other
  235. // CHECK:STDOUT: %other.param_patt: @Op.2.%MyInt (%MyInt) = value_param_pattern %other.patt, runtime_param1
  236. // CHECK:STDOUT: %return.patt: @Op.2.%MyInt (%MyInt) = return_slot_pattern
  237. // CHECK:STDOUT: %return.param_patt: @Op.2.%MyInt (%MyInt) = out_param_pattern %return.patt, runtime_param2
  238. // CHECK:STDOUT: } {
  239. // CHECK:STDOUT: %Self.ref.loc16_37: type = name_ref Self, @impl.%MyInt.loc15_39.1 [symbolic = %MyInt (constants.%MyInt)]
  240. // CHECK:STDOUT: %self.param: @Op.2.%MyInt (%MyInt) = value_param runtime_param0
  241. // CHECK:STDOUT: %Self.ref.loc16_15: type = name_ref Self, @impl.%MyInt.loc15_39.1 [symbolic = %MyInt (constants.%MyInt)]
  242. // CHECK:STDOUT: %self: @Op.2.%MyInt (%MyInt) = bind_name self, %self.param
  243. // CHECK:STDOUT: %other.param: @Op.2.%MyInt (%MyInt) = value_param runtime_param1
  244. // CHECK:STDOUT: %Self.ref.loc16_28: type = name_ref Self, @impl.%MyInt.loc15_39.1 [symbolic = %MyInt (constants.%MyInt)]
  245. // CHECK:STDOUT: %other: @Op.2.%MyInt (%MyInt) = bind_name other, %other.param
  246. // CHECK:STDOUT: %return.param: ref @Op.2.%MyInt (%MyInt) = out_param runtime_param2
  247. // CHECK:STDOUT: %return: ref @Op.2.%MyInt (%MyInt) = return_slot %return.param
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: !members:
  251. // CHECK:STDOUT: .Op = %Op.decl
  252. // CHECK:STDOUT: witness = file.%impl_witness
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT: }
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: generic class @MyInt(%N.loc11_13.1: Core.IntLiteral) {
  257. // CHECK:STDOUT: %N.loc11_13.2: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic = %N.loc11_13.2 (constants.%N)]
  258. // CHECK:STDOUT: %N.patt.loc11_13.2: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc11_13.2 (constants.%N.patt)]
  259. // CHECK:STDOUT:
  260. // CHECK:STDOUT: !definition:
  261. // CHECK:STDOUT: %iN.builtin: type = int_type signed, %N.loc11_13.2 [symbolic = %iN.builtin (constants.%iN.builtin)]
  262. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @MyInt.%iN.builtin (%iN.builtin) [symbolic = %require_complete (constants.%require_complete.889)]
  263. // CHECK:STDOUT: %complete_type.loc13_1.2: <witness> = complete_type_witness @MyInt.%iN.builtin (%iN.builtin) [symbolic = %complete_type.loc13_1.2 (constants.%complete_type)]
  264. // CHECK:STDOUT:
  265. // CHECK:STDOUT: class {
  266. // CHECK:STDOUT: %Int.ref: %Int.type = name_ref Int, file.%Int.decl [template = constants.%Int]
  267. // CHECK:STDOUT: %N.ref: Core.IntLiteral = name_ref N, %N.loc11_13.1 [symbolic = %N.loc11_13.2 (constants.%N)]
  268. // CHECK:STDOUT: %int.make_type_signed: init type = call %Int.ref(%N.ref) [symbolic = %iN.builtin (constants.%iN.builtin)]
  269. // CHECK:STDOUT: %.loc12_15.1: type = value_of_initializer %int.make_type_signed [symbolic = %iN.builtin (constants.%iN.builtin)]
  270. // CHECK:STDOUT: %.loc12_15.2: type = converted %int.make_type_signed, %.loc12_15.1 [symbolic = %iN.builtin (constants.%iN.builtin)]
  271. // CHECK:STDOUT: adapt_decl %.loc12_15.2 [template]
  272. // CHECK:STDOUT: %complete_type.loc13_1.1: <witness> = complete_type_witness %iN.builtin [symbolic = %complete_type.loc13_1.2 (constants.%complete_type)]
  273. // CHECK:STDOUT:
  274. // CHECK:STDOUT: !members:
  275. // CHECK:STDOUT: .Self = constants.%MyInt
  276. // CHECK:STDOUT: complete_type_witness = %complete_type.loc13_1.1
  277. // CHECK:STDOUT: }
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT:
  280. // CHECK:STDOUT: generic fn @Op.1(@Add.%Self: %Add.type) {
  281. // CHECK:STDOUT: %Self: %Add.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  282. // CHECK:STDOUT: %Self.as_type.loc5_15.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc5_15.1 (constants.%Self.as_type)]
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: fn[%self.param_patt: @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type)](%other.param_patt: @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type)) -> @Op.1.%Self.as_type.loc5_15.1 (%Self.as_type);
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: fn @IntLiteral() -> type = "int_literal.make_type";
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: fn @Int(%n.param_patt: Core.IntLiteral) -> type = "int.make_type_signed";
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: generic fn @Op.2(@impl.%N.loc15_14.1: Core.IntLiteral) {
  292. // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic = %N (constants.%N)]
  293. // CHECK:STDOUT: %MyInt: type = class_type @MyInt, @MyInt(%N) [symbolic = %MyInt (constants.%MyInt)]
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: !definition:
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: fn[%self.param_patt: @Op.2.%MyInt (%MyInt)](%other.param_patt: @Op.2.%MyInt (%MyInt)) -> @Op.2.%MyInt (%MyInt) = "int.sadd";
  298. // CHECK:STDOUT: }
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: generic fn @Double(%N.loc19_11.1: Core.IntLiteral) {
  301. // CHECK:STDOUT: %N.loc19_11.2: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic = %N.loc19_11.2 (constants.%N)]
  302. // CHECK:STDOUT: %N.patt.loc19_11.2: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc19_11.2 (constants.%N.patt)]
  303. // CHECK:STDOUT: %MyInt.loc19_39.2: type = class_type @MyInt, @MyInt(%N.loc19_11.2) [symbolic = %MyInt.loc19_39.2 (constants.%MyInt)]
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: !definition:
  306. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @Double.%MyInt.loc19_39.2 (%MyInt) [symbolic = %require_complete (constants.%require_complete.b8c)]
  307. // CHECK:STDOUT: %Op.type: type = fn_type @Op.2, @impl(%N.loc19_11.2) [symbolic = %Op.type (constants.%Op.type.43e)]
  308. // CHECK:STDOUT: %Op: @Double.%Op.type (%Op.type.43e) = struct_value () [symbolic = %Op (constants.%Op.83a)]
  309. // CHECK:STDOUT:
  310. // CHECK:STDOUT: fn[%N.param_patt: Core.IntLiteral](%x.param_patt: @Double.%MyInt.loc19_39.2 (%MyInt)) -> @Double.%MyInt.loc19_39.2 (%MyInt) {
  311. // CHECK:STDOUT: !entry:
  312. // CHECK:STDOUT: %x.ref.loc20_10: @Double.%MyInt.loc19_39.2 (%MyInt) = name_ref x, %x
  313. // CHECK:STDOUT: %Add.ref: type = name_ref Add, file.%Add.decl [template = constants.%Add.type]
  314. // CHECK:STDOUT: %Op.ref: %Op.assoc_type = name_ref Op, @Add.%assoc0 [template = constants.%assoc0]
  315. // CHECK:STDOUT: %impl.elem0: %Op.type.16a = impl_witness_access constants.%impl_witness, element0 [symbolic = %Op (constants.%Op.83a)]
  316. // CHECK:STDOUT: %Op.bound: <bound method> = bound_method %x.ref.loc20_10, %impl.elem0
  317. // CHECK:STDOUT: %x.ref.loc20_21: @Double.%MyInt.loc19_39.2 (%MyInt) = name_ref x, %x
  318. // CHECK:STDOUT: %Op.specific_fn: <specific function> = specific_function %Op.bound, @Op.2(constants.%N)
  319. // CHECK:STDOUT: %int.sadd: init @Double.%MyInt.loc19_39.2 (%MyInt) = call %Op.specific_fn(%x.ref.loc20_10, %x.ref.loc20_21)
  320. // CHECK:STDOUT: %.loc20_23.1: @Double.%MyInt.loc19_39.2 (%MyInt) = value_of_initializer %int.sadd
  321. // CHECK:STDOUT: %.loc20_23.2: @Double.%MyInt.loc19_39.2 (%MyInt) = converted %int.sadd, %.loc20_23.1
  322. // CHECK:STDOUT: return %.loc20_23.2
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT: }
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: specific @Op.1(constants.%Self) {
  327. // CHECK:STDOUT: %Self => constants.%Self
  328. // CHECK:STDOUT: %Self.as_type.loc5_15.1 => constants.%Self.as_type
  329. // CHECK:STDOUT: }
  330. // CHECK:STDOUT:
  331. // CHECK:STDOUT: specific @MyInt(constants.%N) {
  332. // CHECK:STDOUT: %N.loc11_13.2 => constants.%N
  333. // CHECK:STDOUT: %N.patt.loc11_13.2 => constants.%N
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: !definition:
  336. // CHECK:STDOUT: %iN.builtin => constants.%iN.builtin
  337. // CHECK:STDOUT: %require_complete => constants.%require_complete.889
  338. // CHECK:STDOUT: %complete_type.loc13_1.2 => constants.%complete_type
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT:
  341. // CHECK:STDOUT: specific @impl(constants.%N) {
  342. // CHECK:STDOUT: %N.loc15_14.2 => constants.%N
  343. // CHECK:STDOUT: %N.patt.loc15_14.2 => constants.%N
  344. // CHECK:STDOUT: %MyInt.loc15_39.2 => constants.%MyInt
  345. // CHECK:STDOUT: %impl_witness => constants.%impl_witness
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: !definition:
  348. // CHECK:STDOUT: %Op.type => constants.%Op.type.43e
  349. // CHECK:STDOUT: %Op => constants.%Op.83a
  350. // CHECK:STDOUT: %require_complete => constants.%require_complete.b8c
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: specific @MyInt(@impl.%N.loc15_14.2) {}
  354. // CHECK:STDOUT:
  355. // CHECK:STDOUT: specific @impl(%N.loc15_14.2) {}
  356. // CHECK:STDOUT:
  357. // CHECK:STDOUT: specific @Op.2(constants.%N) {
  358. // CHECK:STDOUT: %N => constants.%N
  359. // CHECK:STDOUT: %MyInt => constants.%MyInt
  360. // CHECK:STDOUT:
  361. // CHECK:STDOUT: !definition:
  362. // CHECK:STDOUT: }
  363. // CHECK:STDOUT:
  364. // CHECK:STDOUT: specific @MyInt(@Op.2.%N) {}
  365. // CHECK:STDOUT:
  366. // CHECK:STDOUT: specific @Op.1(constants.%Add.facet) {
  367. // CHECK:STDOUT: %Self => constants.%Add.facet
  368. // CHECK:STDOUT: %Self.as_type.loc5_15.1 => constants.%MyInt
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT:
  371. // CHECK:STDOUT: specific @Double(constants.%N) {
  372. // CHECK:STDOUT: %N.loc19_11.2 => constants.%N
  373. // CHECK:STDOUT: %N.patt.loc19_11.2 => constants.%N
  374. // CHECK:STDOUT: %MyInt.loc19_39.2 => constants.%MyInt
  375. // CHECK:STDOUT: }
  376. // CHECK:STDOUT:
  377. // CHECK:STDOUT: specific @MyInt(@Double.%N.loc19_11.2) {}
  378. // CHECK:STDOUT:
  379. // CHECK:STDOUT: specific @impl(@Double.%N.loc19_11.2) {}
  380. // CHECK:STDOUT:
  381. // CHECK:STDOUT: --- use_generic_impl.carbon
  382. // CHECK:STDOUT:
  383. // CHECK:STDOUT: constants {
  384. // CHECK:STDOUT: %MyInt.type: type = generic_class_type @MyInt [template]
  385. // CHECK:STDOUT: %MyInt.generic: %MyInt.type = struct_value () [template]
  386. // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic]
  387. // CHECK:STDOUT: %iN.builtin: type = int_type signed, %N [symbolic]
  388. // CHECK:STDOUT: %complete_type.c6b: <witness> = complete_type_witness %iN.builtin [symbolic]
  389. // CHECK:STDOUT: %MyInt.080: type = class_type @MyInt, @MyInt(%N) [symbolic]
  390. // CHECK:STDOUT: %N.patt: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic]
  391. // CHECK:STDOUT: %require_complete.889: <witness> = require_complete_type %iN.builtin [symbolic]
  392. // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template]
  393. // CHECK:STDOUT: %MyInt.f94: type = class_type @MyInt, @MyInt(%int_64) [template]
  394. // CHECK:STDOUT: %LocalDouble.type: type = fn_type @LocalDouble [template]
  395. // CHECK:STDOUT: %LocalDouble: %LocalDouble.type = struct_value () [template]
  396. // CHECK:STDOUT: %i64.builtin: type = int_type signed, %int_64 [template]
  397. // CHECK:STDOUT: %complete_type.4a1: <witness> = complete_type_witness %i64.builtin [template]
  398. // CHECK:STDOUT: %Add.type: type = facet_type <@Add> [template]
  399. // CHECK:STDOUT: %Self: %Add.type = bind_symbolic_name Self, 0 [symbolic]
  400. // CHECK:STDOUT: %Op.type.16a: type = fn_type @Op.1 [template]
  401. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic]
  402. // CHECK:STDOUT: %Op.assoc_type: type = assoc_entity_type %Add.type, %Op.type.16a [template]
  403. // CHECK:STDOUT: %assoc0: %Op.assoc_type = assoc_entity element0, imports.%import_ref.3bf [template]
  404. // CHECK:STDOUT: %impl_witness.43f: <witness> = impl_witness (imports.%import_ref.b01), @impl(%N) [symbolic]
  405. // CHECK:STDOUT: %Op.type.c77: type = fn_type @Op.2, @impl(%N) [symbolic]
  406. // CHECK:STDOUT: %Op.947: %Op.type.c77 = struct_value () [symbolic]
  407. // CHECK:STDOUT: %require_complete.e07: <witness> = require_complete_type %MyInt.080 [symbolic]
  408. // CHECK:STDOUT: %impl_witness.463: <witness> = impl_witness (imports.%import_ref.b01), @impl(%int_64) [template]
  409. // CHECK:STDOUT: %impl_witness.68e: <witness> = impl_witness (imports.%import_ref.1b9), @impl(%N) [symbolic]
  410. // CHECK:STDOUT: %Op.type.d80: type = fn_type @Op.2, @impl(%int_64) [template]
  411. // CHECK:STDOUT: %Op.bdc: %Op.type.d80 = struct_value () [template]
  412. // CHECK:STDOUT: %CallImportedDouble.type: type = fn_type @CallImportedDouble [template]
  413. // CHECK:STDOUT: %CallImportedDouble: %CallImportedDouble.type = struct_value () [template]
  414. // CHECK:STDOUT: %Double.type: type = fn_type @Double [template]
  415. // CHECK:STDOUT: %Double: %Double.type = struct_value () [template]
  416. // CHECK:STDOUT: %Double.specific_fn: <specific function> = specific_function %Double, @Double(%int_64) [template]
  417. // CHECK:STDOUT: }
  418. // CHECK:STDOUT:
  419. // CHECK:STDOUT: imports {
  420. // CHECK:STDOUT: %import_ref.4b5: type = import_ref Main//generic_impl, Add, loaded [template = constants.%Add.type]
  421. // CHECK:STDOUT: %import_ref.f28 = import_ref Main//generic_impl, IntLiteral, unloaded
  422. // CHECK:STDOUT: %import_ref.11e = import_ref Main//generic_impl, Int, unloaded
  423. // CHECK:STDOUT: %import_ref.ea3: %MyInt.type = import_ref Main//generic_impl, MyInt, loaded [template = constants.%MyInt.generic]
  424. // CHECK:STDOUT: %import_ref.206: %Double.type = import_ref Main//generic_impl, Double, loaded [template = constants.%Double]
  425. // CHECK:STDOUT: %import_ref.caf: <witness> = import_ref Main//generic_impl, loc13_1, loaded [symbolic = @MyInt.%complete_type (constants.%complete_type.c6b)]
  426. // CHECK:STDOUT: %import_ref.b26 = import_ref Main//generic_impl, inst89 [no loc], unloaded
  427. // CHECK:STDOUT: %import_ref.72a = import_ref Main//generic_impl, inst15 [no loc], unloaded
  428. // CHECK:STDOUT: %import_ref.b57: %Op.assoc_type = import_ref Main//generic_impl, loc5_41, loaded [template = constants.%assoc0]
  429. // CHECK:STDOUT: %import_ref.b75 = import_ref Main//generic_impl, Op, unloaded
  430. // CHECK:STDOUT: %import_ref.0f5: <witness> = import_ref Main//generic_impl, loc15_48, loaded [symbolic = @impl.%impl_witness (constants.%impl_witness.68e)]
  431. // CHECK:STDOUT: %import_ref.7b9: type = import_ref Main//generic_impl, loc15_39, loaded [symbolic = @impl.%MyInt (constants.%MyInt.080)]
  432. // CHECK:STDOUT: %import_ref.d37: type = import_ref Main//generic_impl, loc15_44, loaded [template = constants.%Add.type]
  433. // CHECK:STDOUT: %import_ref.b01: @impl.%Op.type (%Op.type.c77) = import_ref Main//generic_impl, loc16_42, loaded [symbolic = @impl.%Op (constants.%Op.947)]
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: file {
  437. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  438. // CHECK:STDOUT: .Add = imports.%import_ref.4b5
  439. // CHECK:STDOUT: .IntLiteral = imports.%import_ref.f28
  440. // CHECK:STDOUT: .Int = imports.%import_ref.11e
  441. // CHECK:STDOUT: .MyInt = imports.%import_ref.ea3
  442. // CHECK:STDOUT: .Double = imports.%import_ref.206
  443. // CHECK:STDOUT: .LocalDouble = %LocalDouble.decl
  444. // CHECK:STDOUT: .CallImportedDouble = %CallImportedDouble.decl
  445. // CHECK:STDOUT: }
  446. // CHECK:STDOUT: %default.import = import <invalid>
  447. // CHECK:STDOUT: %LocalDouble.decl: %LocalDouble.type = fn_decl @LocalDouble [template = constants.%LocalDouble] {
  448. // CHECK:STDOUT: %x.patt: %MyInt.f94 = binding_pattern x
  449. // CHECK:STDOUT: %x.param_patt: %MyInt.f94 = value_param_pattern %x.patt, runtime_param0
  450. // CHECK:STDOUT: %return.patt: %MyInt.f94 = return_slot_pattern
  451. // CHECK:STDOUT: %return.param_patt: %MyInt.f94 = out_param_pattern %return.patt, runtime_param1
  452. // CHECK:STDOUT: } {
  453. // CHECK:STDOUT: %MyInt.ref.loc8_33: %MyInt.type = name_ref MyInt, imports.%import_ref.ea3 [template = constants.%MyInt.generic]
  454. // CHECK:STDOUT: %int_64.loc8_39: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  455. // CHECK:STDOUT: %MyInt.loc8_41: type = class_type @MyInt, @MyInt(constants.%int_64) [template = constants.%MyInt.f94]
  456. // CHECK:STDOUT: %x.param: %MyInt.f94 = value_param runtime_param0
  457. // CHECK:STDOUT: %.loc8: type = splice_block %MyInt.loc8_27 [template = constants.%MyInt.f94] {
  458. // CHECK:STDOUT: %MyInt.ref.loc8_19: %MyInt.type = name_ref MyInt, imports.%import_ref.ea3 [template = constants.%MyInt.generic]
  459. // CHECK:STDOUT: %int_64.loc8_25: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  460. // CHECK:STDOUT: %MyInt.loc8_27: type = class_type @MyInt, @MyInt(constants.%int_64) [template = constants.%MyInt.f94]
  461. // CHECK:STDOUT: }
  462. // CHECK:STDOUT: %x: %MyInt.f94 = bind_name x, %x.param
  463. // CHECK:STDOUT: %return.param: ref %MyInt.f94 = out_param runtime_param1
  464. // CHECK:STDOUT: %return: ref %MyInt.f94 = return_slot %return.param
  465. // CHECK:STDOUT: }
  466. // CHECK:STDOUT: %CallImportedDouble.decl: %CallImportedDouble.type = fn_decl @CallImportedDouble [template = constants.%CallImportedDouble] {
  467. // CHECK:STDOUT: %n.patt: %MyInt.f94 = binding_pattern n
  468. // CHECK:STDOUT: %n.param_patt: %MyInt.f94 = value_param_pattern %n.patt, runtime_param0
  469. // CHECK:STDOUT: %return.patt: %MyInt.f94 = return_slot_pattern
  470. // CHECK:STDOUT: %return.param_patt: %MyInt.f94 = out_param_pattern %return.patt, runtime_param1
  471. // CHECK:STDOUT: } {
  472. // CHECK:STDOUT: %MyInt.ref.loc12_40: %MyInt.type = name_ref MyInt, imports.%import_ref.ea3 [template = constants.%MyInt.generic]
  473. // CHECK:STDOUT: %int_64.loc12_46: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  474. // CHECK:STDOUT: %MyInt.loc12_48: type = class_type @MyInt, @MyInt(constants.%int_64) [template = constants.%MyInt.f94]
  475. // CHECK:STDOUT: %n.param: %MyInt.f94 = value_param runtime_param0
  476. // CHECK:STDOUT: %.loc12: type = splice_block %MyInt.loc12_34 [template = constants.%MyInt.f94] {
  477. // CHECK:STDOUT: %MyInt.ref.loc12_26: %MyInt.type = name_ref MyInt, imports.%import_ref.ea3 [template = constants.%MyInt.generic]
  478. // CHECK:STDOUT: %int_64.loc12_32: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  479. // CHECK:STDOUT: %MyInt.loc12_34: type = class_type @MyInt, @MyInt(constants.%int_64) [template = constants.%MyInt.f94]
  480. // CHECK:STDOUT: }
  481. // CHECK:STDOUT: %n: %MyInt.f94 = bind_name n, %n.param
  482. // CHECK:STDOUT: %return.param: ref %MyInt.f94 = out_param runtime_param1
  483. // CHECK:STDOUT: %return: ref %MyInt.f94 = return_slot %return.param
  484. // CHECK:STDOUT: }
  485. // CHECK:STDOUT: }
  486. // CHECK:STDOUT:
  487. // CHECK:STDOUT: interface @Add [from "generic_impl.carbon"] {
  488. // CHECK:STDOUT: !members:
  489. // CHECK:STDOUT: .Self = imports.%import_ref.72a
  490. // CHECK:STDOUT: .Op = imports.%import_ref.b57
  491. // CHECK:STDOUT: witness = (imports.%import_ref.b75)
  492. // CHECK:STDOUT: }
  493. // CHECK:STDOUT:
  494. // CHECK:STDOUT: generic impl @impl(constants.%N: Core.IntLiteral) [from "generic_impl.carbon"] {
  495. // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic = %N (constants.%N)]
  496. // CHECK:STDOUT: %N.patt: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt (constants.%N.patt)]
  497. // CHECK:STDOUT: %MyInt: type = class_type @MyInt, @MyInt(%N) [symbolic = %MyInt (constants.%MyInt.080)]
  498. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (imports.%import_ref.b01), @impl(%N) [symbolic = %impl_witness (constants.%impl_witness.43f)]
  499. // CHECK:STDOUT:
  500. // CHECK:STDOUT: !definition:
  501. // CHECK:STDOUT: %Op.type: type = fn_type @Op.2, @impl(%N) [symbolic = %Op.type (constants.%Op.type.c77)]
  502. // CHECK:STDOUT: %Op: @impl.%Op.type (%Op.type.c77) = struct_value () [symbolic = %Op (constants.%Op.947)]
  503. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @impl.%MyInt (%MyInt.080) [symbolic = %require_complete (constants.%require_complete.e07)]
  504. // CHECK:STDOUT:
  505. // CHECK:STDOUT: impl: imports.%import_ref.7b9 as imports.%import_ref.d37 {
  506. // CHECK:STDOUT: !members:
  507. // CHECK:STDOUT: witness = imports.%import_ref.0f5
  508. // CHECK:STDOUT: }
  509. // CHECK:STDOUT: }
  510. // CHECK:STDOUT:
  511. // CHECK:STDOUT: generic class @MyInt(constants.%N: Core.IntLiteral) [from "generic_impl.carbon"] {
  512. // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic = %N (constants.%N)]
  513. // CHECK:STDOUT: %N.patt: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt (constants.%N.patt)]
  514. // CHECK:STDOUT:
  515. // CHECK:STDOUT: !definition:
  516. // CHECK:STDOUT: %iN.builtin: type = int_type signed, %N [symbolic = %iN.builtin (constants.%iN.builtin)]
  517. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @MyInt.%iN.builtin (%iN.builtin) [symbolic = %require_complete (constants.%require_complete.889)]
  518. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness @MyInt.%iN.builtin (%iN.builtin) [symbolic = %complete_type (constants.%complete_type.c6b)]
  519. // CHECK:STDOUT:
  520. // CHECK:STDOUT: class {
  521. // CHECK:STDOUT: !members:
  522. // CHECK:STDOUT: .Self = imports.%import_ref.b26
  523. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.caf
  524. // CHECK:STDOUT: }
  525. // CHECK:STDOUT: }
  526. // CHECK:STDOUT:
  527. // CHECK:STDOUT: fn @LocalDouble(%x.param_patt: %MyInt.f94) -> %MyInt.f94 {
  528. // CHECK:STDOUT: !entry:
  529. // CHECK:STDOUT: %x.ref.loc9_10: %MyInt.f94 = name_ref x, %x
  530. // CHECK:STDOUT: %Add.ref: type = name_ref Add, imports.%import_ref.4b5 [template = constants.%Add.type]
  531. // CHECK:STDOUT: %Op.ref: %Op.assoc_type = name_ref Op, imports.%import_ref.b57 [template = constants.%assoc0]
  532. // CHECK:STDOUT: %impl.elem0: %Op.type.16a = impl_witness_access constants.%impl_witness.463, element0 [template = constants.%Op.bdc]
  533. // CHECK:STDOUT: %Op.bound: <bound method> = bound_method %x.ref.loc9_10, %impl.elem0
  534. // CHECK:STDOUT: %x.ref.loc9_21: %MyInt.f94 = name_ref x, %x
  535. // CHECK:STDOUT: %Op.specific_fn: <specific function> = specific_function %Op.bound, @Op.2(constants.%int_64)
  536. // CHECK:STDOUT: %int.sadd: init %MyInt.f94 = call %Op.specific_fn(%x.ref.loc9_10, %x.ref.loc9_21)
  537. // CHECK:STDOUT: %.loc9_23.1: %MyInt.f94 = value_of_initializer %int.sadd
  538. // CHECK:STDOUT: %.loc9_23.2: %MyInt.f94 = converted %int.sadd, %.loc9_23.1
  539. // CHECK:STDOUT: return %.loc9_23.2
  540. // CHECK:STDOUT: }
  541. // CHECK:STDOUT:
  542. // CHECK:STDOUT: generic fn @Op.1(constants.%Self: %Add.type) [from "generic_impl.carbon"] {
  543. // CHECK:STDOUT: %Self: %Add.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  544. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic = %Self.as_type (constants.%Self.as_type)]
  545. // CHECK:STDOUT:
  546. // CHECK:STDOUT: fn[%self.param_patt: @Op.1.%Self.as_type (%Self.as_type)](%other.param_patt: @Op.1.%Self.as_type (%Self.as_type)) -> @Op.1.%Self.as_type (%Self.as_type);
  547. // CHECK:STDOUT: }
  548. // CHECK:STDOUT:
  549. // CHECK:STDOUT: generic fn @Op.2(constants.%N: Core.IntLiteral) [from "generic_impl.carbon"] {
  550. // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic = %N (constants.%N)]
  551. // CHECK:STDOUT: %MyInt: type = class_type @MyInt, @MyInt(%N) [symbolic = %MyInt (constants.%MyInt.080)]
  552. // CHECK:STDOUT:
  553. // CHECK:STDOUT: !definition:
  554. // CHECK:STDOUT:
  555. // CHECK:STDOUT: fn[%self.param_patt: @Op.2.%MyInt (%MyInt.080)](%other.param_patt: @Op.2.%MyInt (%MyInt.080)) -> @Op.2.%MyInt (%MyInt.080) = "int.sadd";
  556. // CHECK:STDOUT: }
  557. // CHECK:STDOUT:
  558. // CHECK:STDOUT: fn @CallImportedDouble(%n.param_patt: %MyInt.f94) -> %MyInt.f94 {
  559. // CHECK:STDOUT: !entry:
  560. // CHECK:STDOUT: %Double.ref: %Double.type = name_ref Double, imports.%import_ref.206 [template = constants.%Double]
  561. // CHECK:STDOUT: %n.ref: %MyInt.f94 = name_ref n, %n
  562. // CHECK:STDOUT: %Double.specific_fn: <specific function> = specific_function %Double.ref, @Double(constants.%int_64) [template = constants.%Double.specific_fn]
  563. // CHECK:STDOUT: %Double.call: init %MyInt.f94 = call %Double.specific_fn(%n.ref)
  564. // CHECK:STDOUT: %.loc13_19.1: %MyInt.f94 = value_of_initializer %Double.call
  565. // CHECK:STDOUT: %.loc13_19.2: %MyInt.f94 = converted %Double.call, %.loc13_19.1
  566. // CHECK:STDOUT: return %.loc13_19.2
  567. // CHECK:STDOUT: }
  568. // CHECK:STDOUT:
  569. // CHECK:STDOUT: generic fn @Double(constants.%N: Core.IntLiteral) [from "generic_impl.carbon"] {
  570. // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic = %N (constants.%N)]
  571. // CHECK:STDOUT: %N.patt: Core.IntLiteral = symbolic_binding_pattern N, 0 [symbolic = %N.patt (constants.%N.patt)]
  572. // CHECK:STDOUT: %MyInt: type = class_type @MyInt, @MyInt(%N) [symbolic = %MyInt (constants.%MyInt.080)]
  573. // CHECK:STDOUT:
  574. // CHECK:STDOUT: !definition:
  575. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @Double.%MyInt (%MyInt.080) [symbolic = %require_complete (constants.%require_complete.e07)]
  576. // CHECK:STDOUT: %Op.type: type = fn_type @Op.2, @impl(%N) [symbolic = %Op.type (constants.%Op.type.c77)]
  577. // CHECK:STDOUT: %Op: @Double.%Op.type (%Op.type.c77) = struct_value () [symbolic = %Op (constants.%Op.947)]
  578. // CHECK:STDOUT:
  579. // CHECK:STDOUT: fn[%N.param_patt: Core.IntLiteral](%x.param_patt: @Double.%MyInt (%MyInt.080)) -> @Double.%MyInt (%MyInt.080);
  580. // CHECK:STDOUT: }
  581. // CHECK:STDOUT:
  582. // CHECK:STDOUT: specific @MyInt(constants.%N) {
  583. // CHECK:STDOUT: %N => constants.%N
  584. // CHECK:STDOUT: %N.patt => constants.%N
  585. // CHECK:STDOUT:
  586. // CHECK:STDOUT: !definition:
  587. // CHECK:STDOUT: %iN.builtin => constants.%iN.builtin
  588. // CHECK:STDOUT: %require_complete => constants.%require_complete.889
  589. // CHECK:STDOUT: %complete_type => constants.%complete_type.c6b
  590. // CHECK:STDOUT: }
  591. // CHECK:STDOUT:
  592. // CHECK:STDOUT: specific @MyInt(constants.%int_64) {
  593. // CHECK:STDOUT: %N => constants.%int_64
  594. // CHECK:STDOUT: %N.patt => constants.%int_64
  595. // CHECK:STDOUT:
  596. // CHECK:STDOUT: !definition:
  597. // CHECK:STDOUT: %iN.builtin => constants.%i64.builtin
  598. // CHECK:STDOUT: %require_complete => constants.%complete_type.4a1
  599. // CHECK:STDOUT: %complete_type => constants.%complete_type.4a1
  600. // CHECK:STDOUT: }
  601. // CHECK:STDOUT:
  602. // CHECK:STDOUT: specific @Op.1(constants.%Self) {
  603. // CHECK:STDOUT: %Self => constants.%Self
  604. // CHECK:STDOUT: %Self.as_type => constants.%Self.as_type
  605. // CHECK:STDOUT: }
  606. // CHECK:STDOUT:
  607. // CHECK:STDOUT: specific @impl(constants.%N) {
  608. // CHECK:STDOUT: %N => constants.%N
  609. // CHECK:STDOUT: %N.patt => constants.%N
  610. // CHECK:STDOUT: %MyInt => constants.%MyInt.080
  611. // CHECK:STDOUT: %impl_witness => constants.%impl_witness.43f
  612. // CHECK:STDOUT:
  613. // CHECK:STDOUT: !definition:
  614. // CHECK:STDOUT: %Op.type => constants.%Op.type.c77
  615. // CHECK:STDOUT: %Op => constants.%Op.947
  616. // CHECK:STDOUT: %require_complete => constants.%require_complete.e07
  617. // CHECK:STDOUT: }
  618. // CHECK:STDOUT:
  619. // CHECK:STDOUT: specific @MyInt(@impl.%N) {}
  620. // CHECK:STDOUT:
  621. // CHECK:STDOUT: specific @impl(%N) {}
  622. // CHECK:STDOUT:
  623. // CHECK:STDOUT: specific @MyInt(@Op.2.%N) {}
  624. // CHECK:STDOUT:
  625. // CHECK:STDOUT: specific @Op.2(constants.%N) {
  626. // CHECK:STDOUT: %N => constants.%N
  627. // CHECK:STDOUT: %MyInt => constants.%MyInt.080
  628. // CHECK:STDOUT:
  629. // CHECK:STDOUT: !definition:
  630. // CHECK:STDOUT: }
  631. // CHECK:STDOUT:
  632. // CHECK:STDOUT: specific @impl(constants.%int_64) {
  633. // CHECK:STDOUT: %N => constants.%int_64
  634. // CHECK:STDOUT: %N.patt => constants.%int_64
  635. // CHECK:STDOUT: %MyInt => constants.%MyInt.f94
  636. // CHECK:STDOUT: %impl_witness => constants.%impl_witness.463
  637. // CHECK:STDOUT:
  638. // CHECK:STDOUT: !definition:
  639. // CHECK:STDOUT: %Op.type => constants.%Op.type.d80
  640. // CHECK:STDOUT: %Op => constants.%Op.bdc
  641. // CHECK:STDOUT: %require_complete => constants.%complete_type.4a1
  642. // CHECK:STDOUT: }
  643. // CHECK:STDOUT:
  644. // CHECK:STDOUT: specific @Op.2(constants.%int_64) {
  645. // CHECK:STDOUT: %N => constants.%int_64
  646. // CHECK:STDOUT: %MyInt => constants.%MyInt.f94
  647. // CHECK:STDOUT:
  648. // CHECK:STDOUT: !definition:
  649. // CHECK:STDOUT: }
  650. // CHECK:STDOUT:
  651. // CHECK:STDOUT: specific @MyInt(@Double.%N) {}
  652. // CHECK:STDOUT:
  653. // CHECK:STDOUT: specific @Double(constants.%N) {
  654. // CHECK:STDOUT: %N => constants.%N
  655. // CHECK:STDOUT: %N.patt => constants.%N
  656. // CHECK:STDOUT: %MyInt => constants.%MyInt.080
  657. // CHECK:STDOUT: }
  658. // CHECK:STDOUT:
  659. // CHECK:STDOUT: specific @impl(@Double.%N) {}
  660. // CHECK:STDOUT:
  661. // CHECK:STDOUT: specific @Double(constants.%int_64) {
  662. // CHECK:STDOUT: %N => constants.%int_64
  663. // CHECK:STDOUT: %N.patt => constants.%int_64
  664. // CHECK:STDOUT: %MyInt => constants.%MyInt.f94
  665. // CHECK:STDOUT:
  666. // CHECK:STDOUT: !definition:
  667. // CHECK:STDOUT: %require_complete => constants.%complete_type.4a1
  668. // CHECK:STDOUT: %Op.type => constants.%Op.type.d80
  669. // CHECK:STDOUT: %Op => constants.%Op.bdc
  670. // CHECK:STDOUT: }
  671. // CHECK:STDOUT:
  672. // CHECK:STDOUT: --- convert_symbolic.carbon
  673. // CHECK:STDOUT:
  674. // CHECK:STDOUT: constants {
  675. // CHECK:STDOUT: %IntLiteral.type: type = fn_type @IntLiteral [template]
  676. // CHECK:STDOUT: %IntLiteral: %IntLiteral.type = struct_value () [template]
  677. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  678. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  679. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  680. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  681. // CHECK:STDOUT: %ToLiteral.type.e7c: type = fn_type @ToLiteral.1 [template]
  682. // CHECK:STDOUT: %ToLiteral.cf3: %ToLiteral.type.e7c = struct_value () [template]
  683. // CHECK:STDOUT: %FromLiteral.type: type = fn_type @FromLiteral [template]
  684. // CHECK:STDOUT: %FromLiteral: %FromLiteral.type = struct_value () [template]
  685. // CHECK:STDOUT: %N.a7a: %i32.builtin = bind_symbolic_name N, 0 [symbolic]
  686. // CHECK:STDOUT: %N.patt.8e9: %i32.builtin = symbolic_binding_pattern N, 0 [symbolic]
  687. // CHECK:STDOUT: %int.convert_checked.84b: init Core.IntLiteral = call %ToLiteral.cf3(%N.a7a) [symbolic]
  688. // CHECK:STDOUT: %iN.builtin.b6f: type = int_type signed, %int.convert_checked.84b [symbolic]
  689. // CHECK:STDOUT: %Make.type: type = fn_type @Make [template]
  690. // CHECK:STDOUT: %Make: %Make.type = struct_value () [template]
  691. // CHECK:STDOUT: %require_complete.b3f: <witness> = require_complete_type %iN.builtin.b6f [symbolic]
  692. // CHECK:STDOUT: %Make.specific_fn: <specific function> = specific_function %Make, @Make(%N.a7a) [symbolic]
  693. // CHECK:STDOUT: %OtherInt: type = class_type @OtherInt [template]
  694. // CHECK:STDOUT: %ToLiteral.type.ea8: type = fn_type @ToLiteral.2 [template]
  695. // CHECK:STDOUT: %ToLiteral.5b3: %ToLiteral.type.ea8 = struct_value () [template]
  696. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %i32.builtin [template]
  697. // CHECK:STDOUT: %N.1a2: %OtherInt = bind_symbolic_name N, 0 [symbolic]
  698. // CHECK:STDOUT: %N.patt.71c: %OtherInt = symbolic_binding_pattern N, 0 [symbolic]
  699. // CHECK:STDOUT: %ToLiteral.bound: <bound method> = bound_method %N.1a2, %ToLiteral.5b3 [symbolic]
  700. // CHECK:STDOUT: %int.convert_checked.519: init Core.IntLiteral = call %ToLiteral.bound(%N.1a2) [symbolic]
  701. // CHECK:STDOUT: %iN.builtin.5d1: type = int_type signed, %int.convert_checked.519 [symbolic]
  702. // CHECK:STDOUT: %MakeFromClass.type: type = fn_type @MakeFromClass [template]
  703. // CHECK:STDOUT: %MakeFromClass: %MakeFromClass.type = struct_value () [template]
  704. // CHECK:STDOUT: %require_complete.02e: <witness> = require_complete_type %iN.builtin.5d1 [symbolic]
  705. // CHECK:STDOUT: %MakeFromClass.specific_fn: <specific function> = specific_function %MakeFromClass, @MakeFromClass(%N.1a2) [symbolic]
  706. // CHECK:STDOUT: }
  707. // CHECK:STDOUT:
  708. // CHECK:STDOUT: file {
  709. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  710. // CHECK:STDOUT: .IntLiteral = %IntLiteral.decl
  711. // CHECK:STDOUT: .Int = %Int.decl
  712. // CHECK:STDOUT: .ToLiteral = %ToLiteral.decl.loc6
  713. // CHECK:STDOUT: .FromLiteral = %FromLiteral.decl
  714. // CHECK:STDOUT: .Make = %Make.decl
  715. // CHECK:STDOUT: .OtherInt = %OtherInt.decl
  716. // CHECK:STDOUT: .MakeFromClass = %MakeFromClass.decl
  717. // CHECK:STDOUT: }
  718. // CHECK:STDOUT: %IntLiteral.decl: %IntLiteral.type = fn_decl @IntLiteral [template = constants.%IntLiteral] {
  719. // CHECK:STDOUT: %return.patt: type = return_slot_pattern
  720. // CHECK:STDOUT: %return.param_patt: type = out_param_pattern %return.patt, runtime_param0
  721. // CHECK:STDOUT: } {
  722. // CHECK:STDOUT: %return.param: ref type = out_param runtime_param0
  723. // CHECK:STDOUT: %return: ref type = return_slot %return.param
  724. // CHECK:STDOUT: }
  725. // CHECK:STDOUT: %Int.decl: %Int.type = fn_decl @Int [template = constants.%Int] {
  726. // CHECK:STDOUT: %n.patt: Core.IntLiteral = binding_pattern n
  727. // CHECK:STDOUT: %n.param_patt: Core.IntLiteral = value_param_pattern %n.patt, runtime_param0
  728. // CHECK:STDOUT: %return.patt: type = return_slot_pattern
  729. // CHECK:STDOUT: %return.param_patt: type = out_param_pattern %return.patt, runtime_param1
  730. // CHECK:STDOUT: } {
  731. // CHECK:STDOUT: %n.param: Core.IntLiteral = value_param runtime_param0
  732. // CHECK:STDOUT: %.loc5_22.1: type = splice_block %.loc5_22.3 [template = Core.IntLiteral] {
  733. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [template = constants.%IntLiteral]
  734. // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
  735. // CHECK:STDOUT: %.loc5_22.2: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
  736. // CHECK:STDOUT: %.loc5_22.3: type = converted %int_literal.make_type, %.loc5_22.2 [template = Core.IntLiteral]
  737. // CHECK:STDOUT: }
  738. // CHECK:STDOUT: %n: Core.IntLiteral = bind_name n, %n.param
  739. // CHECK:STDOUT: %return.param: ref type = out_param runtime_param1
  740. // CHECK:STDOUT: %return: ref type = return_slot %return.param
  741. // CHECK:STDOUT: }
  742. // CHECK:STDOUT: %ToLiteral.decl.loc6: %ToLiteral.type.e7c = fn_decl @ToLiteral.1 [template = constants.%ToLiteral.cf3] {
  743. // CHECK:STDOUT: %n.patt: %i32.builtin = binding_pattern n
  744. // CHECK:STDOUT: %n.param_patt: %i32.builtin = value_param_pattern %n.patt, runtime_param0
  745. // CHECK:STDOUT: %return.patt: Core.IntLiteral = return_slot_pattern
  746. // CHECK:STDOUT: %return.param_patt: Core.IntLiteral = out_param_pattern %return.patt, runtime_param1
  747. // CHECK:STDOUT: } {
  748. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [template = constants.%IntLiteral]
  749. // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
  750. // CHECK:STDOUT: %.loc6_40.1: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
  751. // CHECK:STDOUT: %.loc6_40.2: type = converted %int_literal.make_type, %.loc6_40.1 [template = Core.IntLiteral]
  752. // CHECK:STDOUT: %n.param: %i32.builtin = value_param runtime_param0
  753. // CHECK:STDOUT: %.loc6_23.1: type = splice_block %.loc6_23.3 [template = constants.%i32.builtin] {
  754. // CHECK:STDOUT: %Int.ref: %Int.type = name_ref Int, file.%Int.decl [template = constants.%Int]
  755. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  756. // CHECK:STDOUT: %int.make_type_signed: init type = call %Int.ref(%int_32) [template = constants.%i32.builtin]
  757. // CHECK:STDOUT: %.loc6_23.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32.builtin]
  758. // CHECK:STDOUT: %.loc6_23.3: type = converted %int.make_type_signed, %.loc6_23.2 [template = constants.%i32.builtin]
  759. // CHECK:STDOUT: }
  760. // CHECK:STDOUT: %n: %i32.builtin = bind_name n, %n.param
  761. // CHECK:STDOUT: %return.param: ref Core.IntLiteral = out_param runtime_param1
  762. // CHECK:STDOUT: %return: ref Core.IntLiteral = return_slot %return.param
  763. // CHECK:STDOUT: }
  764. // CHECK:STDOUT: %FromLiteral.decl: %FromLiteral.type = fn_decl @FromLiteral [template = constants.%FromLiteral] {
  765. // CHECK:STDOUT: %n.patt: Core.IntLiteral = binding_pattern n
  766. // CHECK:STDOUT: %n.param_patt: Core.IntLiteral = value_param_pattern %n.patt, runtime_param0
  767. // CHECK:STDOUT: %return.patt: %i32.builtin = return_slot_pattern
  768. // CHECK:STDOUT: %return.param_patt: %i32.builtin = out_param_pattern %return.patt, runtime_param1
  769. // CHECK:STDOUT: } {
  770. // CHECK:STDOUT: %Int.ref: %Int.type = name_ref Int, file.%Int.decl [template = constants.%Int]
  771. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  772. // CHECK:STDOUT: %int.make_type_signed: init type = call %Int.ref(%int_32) [template = constants.%i32.builtin]
  773. // CHECK:STDOUT: %.loc7_42.1: type = value_of_initializer %int.make_type_signed [template = constants.%i32.builtin]
  774. // CHECK:STDOUT: %.loc7_42.2: type = converted %int.make_type_signed, %.loc7_42.1 [template = constants.%i32.builtin]
  775. // CHECK:STDOUT: %n.param: Core.IntLiteral = value_param runtime_param0
  776. // CHECK:STDOUT: %.loc7_30.1: type = splice_block %.loc7_30.3 [template = Core.IntLiteral] {
  777. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [template = constants.%IntLiteral]
  778. // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
  779. // CHECK:STDOUT: %.loc7_30.2: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
  780. // CHECK:STDOUT: %.loc7_30.3: type = converted %int_literal.make_type, %.loc7_30.2 [template = Core.IntLiteral]
  781. // CHECK:STDOUT: }
  782. // CHECK:STDOUT: %n: Core.IntLiteral = bind_name n, %n.param
  783. // CHECK:STDOUT: %return.param: ref %i32.builtin = out_param runtime_param1
  784. // CHECK:STDOUT: %return: ref %i32.builtin = return_slot %return.param
  785. // CHECK:STDOUT: }
  786. // CHECK:STDOUT: %Make.decl: %Make.type = fn_decl @Make [template = constants.%Make] {
  787. // CHECK:STDOUT: %N.patt.loc9_9.1: %i32.builtin = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc9_9.2 (constants.%N.patt.8e9)]
  788. // CHECK:STDOUT: %N.param_patt: %i32.builtin = value_param_pattern %N.patt.loc9_9.1, runtime_param<invalid> [symbolic = %N.patt.loc9_9.2 (constants.%N.patt.8e9)]
  789. // CHECK:STDOUT: %return.patt: @Make.%iN.builtin (%iN.builtin.b6f) = return_slot_pattern
  790. // CHECK:STDOUT: %return.param_patt: @Make.%iN.builtin (%iN.builtin.b6f) = out_param_pattern %return.patt, runtime_param0
  791. // CHECK:STDOUT: } {
  792. // CHECK:STDOUT: %Int.ref.loc9_25: %Int.type = name_ref Int, file.%Int.decl [template = constants.%Int]
  793. // CHECK:STDOUT: %ToLiteral.ref: %ToLiteral.type.e7c = name_ref ToLiteral, file.%ToLiteral.decl.loc6 [template = constants.%ToLiteral.cf3]
  794. // CHECK:STDOUT: %N.ref.loc9_39: %i32.builtin = name_ref N, %N.loc9_9.1 [symbolic = %N.loc9_9.2 (constants.%N.a7a)]
  795. // CHECK:STDOUT: %int.convert_checked.loc9_40.1: init Core.IntLiteral = call %ToLiteral.ref(%N.ref.loc9_39) [symbolic = %int.convert_checked.loc9_40.2 (constants.%int.convert_checked.84b)]
  796. // CHECK:STDOUT: %.loc9_40.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc9_40.1 [symbolic = %int.convert_checked.loc9_40.2 (constants.%int.convert_checked.84b)]
  797. // CHECK:STDOUT: %.loc9_40.2: Core.IntLiteral = converted %int.convert_checked.loc9_40.1, %.loc9_40.1 [symbolic = %int.convert_checked.loc9_40.2 (constants.%int.convert_checked.84b)]
  798. // CHECK:STDOUT: %int.make_type_signed.loc9_41: init type = call %Int.ref.loc9_25(%.loc9_40.2) [symbolic = %iN.builtin (constants.%iN.builtin.b6f)]
  799. // CHECK:STDOUT: %.loc9_41.1: type = value_of_initializer %int.make_type_signed.loc9_41 [symbolic = %iN.builtin (constants.%iN.builtin.b6f)]
  800. // CHECK:STDOUT: %.loc9_41.2: type = converted %int.make_type_signed.loc9_41, %.loc9_41.1 [symbolic = %iN.builtin (constants.%iN.builtin.b6f)]
  801. // CHECK:STDOUT: %N.param: %i32.builtin = value_param runtime_param<invalid>
  802. // CHECK:STDOUT: %.loc9_19.1: type = splice_block %.loc9_19.3 [template = constants.%i32.builtin] {
  803. // CHECK:STDOUT: %Int.ref.loc9_13: %Int.type = name_ref Int, file.%Int.decl [template = constants.%Int]
  804. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  805. // CHECK:STDOUT: %int.make_type_signed.loc9_19: init type = call %Int.ref.loc9_13(%int_32) [template = constants.%i32.builtin]
  806. // CHECK:STDOUT: %.loc9_19.2: type = value_of_initializer %int.make_type_signed.loc9_19 [template = constants.%i32.builtin]
  807. // CHECK:STDOUT: %.loc9_19.3: type = converted %int.make_type_signed.loc9_19, %.loc9_19.2 [template = constants.%i32.builtin]
  808. // CHECK:STDOUT: }
  809. // CHECK:STDOUT: %N.loc9_9.1: %i32.builtin = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc9_9.2 (constants.%N.a7a)]
  810. // CHECK:STDOUT: %return.param: ref @Make.%iN.builtin (%iN.builtin.b6f) = out_param runtime_param0
  811. // CHECK:STDOUT: %return: ref @Make.%iN.builtin (%iN.builtin.b6f) = return_slot %return.param
  812. // CHECK:STDOUT: }
  813. // CHECK:STDOUT: %OtherInt.decl: type = class_decl @OtherInt [template = constants.%OtherInt] {} {}
  814. // CHECK:STDOUT: %ToLiteral.decl.loc16: %ToLiteral.type.ea8 = fn_decl @ToLiteral.2 [template = constants.%ToLiteral.5b3] {
  815. // CHECK:STDOUT: %self.patt: %OtherInt = binding_pattern self
  816. // CHECK:STDOUT: %self.param_patt: %OtherInt = value_param_pattern %self.patt, runtime_param0
  817. // CHECK:STDOUT: %return.patt: Core.IntLiteral = return_slot_pattern
  818. // CHECK:STDOUT: %return.param_patt: Core.IntLiteral = out_param_pattern %return.patt, runtime_param1
  819. // CHECK:STDOUT: } {
  820. // CHECK:STDOUT: %IntLiteral.ref.loc16: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [template = constants.%IntLiteral]
  821. // CHECK:STDOUT: %int_literal.make_type.loc16: init type = call %IntLiteral.ref.loc16() [template = Core.IntLiteral]
  822. // CHECK:STDOUT: %.loc16_51.1: type = value_of_initializer %int_literal.make_type.loc16 [template = Core.IntLiteral]
  823. // CHECK:STDOUT: %.loc16_51.2: type = converted %int_literal.make_type.loc16, %.loc16_51.1 [template = Core.IntLiteral]
  824. // CHECK:STDOUT: %self.param.loc16: %OtherInt = value_param runtime_param0
  825. // CHECK:STDOUT: %Self.ref.loc16: type = name_ref Self, constants.%OtherInt [template = constants.%OtherInt]
  826. // CHECK:STDOUT: %self.loc16: %OtherInt = bind_name self, %self.param.loc16
  827. // CHECK:STDOUT: %return.param.loc16: ref Core.IntLiteral = out_param runtime_param1
  828. // CHECK:STDOUT: %return.loc16: ref Core.IntLiteral = return_slot %return.param.loc16
  829. // CHECK:STDOUT: }
  830. // CHECK:STDOUT: %MakeFromClass.decl: %MakeFromClass.type = fn_decl @MakeFromClass [template = constants.%MakeFromClass] {
  831. // CHECK:STDOUT: %N.patt.loc18_18.1: %OtherInt = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc18_18.2 (constants.%N.patt.71c)]
  832. // CHECK:STDOUT: %N.param_patt: %OtherInt = value_param_pattern %N.patt.loc18_18.1, runtime_param<invalid> [symbolic = %N.patt.loc18_18.2 (constants.%N.patt.71c)]
  833. // CHECK:STDOUT: %return.patt: @MakeFromClass.%iN.builtin (%iN.builtin.5d1) = return_slot_pattern
  834. // CHECK:STDOUT: %return.param_patt: @MakeFromClass.%iN.builtin (%iN.builtin.5d1) = out_param_pattern %return.patt, runtime_param0
  835. // CHECK:STDOUT: } {
  836. // CHECK:STDOUT: %Int.ref: %Int.type = name_ref Int, file.%Int.decl [template = constants.%Int]
  837. // CHECK:STDOUT: %N.ref.loc18_39: %OtherInt = name_ref N, %N.loc18_18.1 [symbolic = %N.loc18_18.2 (constants.%N.1a2)]
  838. // CHECK:STDOUT: %ToLiteral.ref: %ToLiteral.type.ea8 = name_ref ToLiteral, @OtherInt.%ToLiteral.decl [template = constants.%ToLiteral.5b3]
  839. // CHECK:STDOUT: %ToLiteral.bound.loc18_40.1: <bound method> = bound_method %N.ref.loc18_39, %ToLiteral.ref [symbolic = %ToLiteral.bound.loc18_40.2 (constants.%ToLiteral.bound)]
  840. // CHECK:STDOUT: %int.convert_checked.loc18_51.1: init Core.IntLiteral = call %ToLiteral.bound.loc18_40.1(%N.ref.loc18_39) [symbolic = %int.convert_checked.loc18_51.2 (constants.%int.convert_checked.519)]
  841. // CHECK:STDOUT: %.loc18_51.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc18_51.1 [symbolic = %int.convert_checked.loc18_51.2 (constants.%int.convert_checked.519)]
  842. // CHECK:STDOUT: %.loc18_51.2: Core.IntLiteral = converted %int.convert_checked.loc18_51.1, %.loc18_51.1 [symbolic = %int.convert_checked.loc18_51.2 (constants.%int.convert_checked.519)]
  843. // CHECK:STDOUT: %int.make_type_signed: init type = call %Int.ref(%.loc18_51.2) [symbolic = %iN.builtin (constants.%iN.builtin.5d1)]
  844. // CHECK:STDOUT: %.loc18_52.1: type = value_of_initializer %int.make_type_signed [symbolic = %iN.builtin (constants.%iN.builtin.5d1)]
  845. // CHECK:STDOUT: %.loc18_52.2: type = converted %int.make_type_signed, %.loc18_52.1 [symbolic = %iN.builtin (constants.%iN.builtin.5d1)]
  846. // CHECK:STDOUT: %N.param: %OtherInt = value_param runtime_param<invalid>
  847. // CHECK:STDOUT: %OtherInt.ref: type = name_ref OtherInt, file.%OtherInt.decl [template = constants.%OtherInt]
  848. // CHECK:STDOUT: %N.loc18_18.1: %OtherInt = bind_symbolic_name N, 0, %N.param [symbolic = %N.loc18_18.2 (constants.%N.1a2)]
  849. // CHECK:STDOUT: %return.param: ref @MakeFromClass.%iN.builtin (%iN.builtin.5d1) = out_param runtime_param0
  850. // CHECK:STDOUT: %return: ref @MakeFromClass.%iN.builtin (%iN.builtin.5d1) = return_slot %return.param
  851. // CHECK:STDOUT: }
  852. // CHECK:STDOUT: }
  853. // CHECK:STDOUT:
  854. // CHECK:STDOUT: class @OtherInt {
  855. // CHECK:STDOUT: %Int.ref: %Int.type = name_ref Int, file.%Int.decl [template = constants.%Int]
  856. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  857. // CHECK:STDOUT: %int.make_type_signed: init type = call %Int.ref(%int_32) [template = constants.%i32.builtin]
  858. // CHECK:STDOUT: %.loc12_16.1: type = value_of_initializer %int.make_type_signed [template = constants.%i32.builtin]
  859. // CHECK:STDOUT: %.loc12_16.2: type = converted %int.make_type_signed, %.loc12_16.1 [template = constants.%i32.builtin]
  860. // CHECK:STDOUT: adapt_decl %.loc12_16.2 [template]
  861. // CHECK:STDOUT: %ToLiteral.decl: %ToLiteral.type.ea8 = fn_decl @ToLiteral.2 [template = constants.%ToLiteral.5b3] {
  862. // CHECK:STDOUT: %self.patt: %OtherInt = binding_pattern self
  863. // CHECK:STDOUT: %self.param_patt: %OtherInt = value_param_pattern %self.patt, runtime_param0
  864. // CHECK:STDOUT: %return.patt: Core.IntLiteral = return_slot_pattern
  865. // CHECK:STDOUT: %return.param_patt: Core.IntLiteral = out_param_pattern %return.patt, runtime_param1
  866. // CHECK:STDOUT: } {
  867. // CHECK:STDOUT: %IntLiteral.ref.loc13: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [template = constants.%IntLiteral]
  868. // CHECK:STDOUT: %int_literal.make_type.loc13: init type = call %IntLiteral.ref.loc13() [template = Core.IntLiteral]
  869. // CHECK:STDOUT: %.loc13_44.1: type = value_of_initializer %int_literal.make_type.loc13 [template = Core.IntLiteral]
  870. // CHECK:STDOUT: %.loc13_44.2: type = converted %int_literal.make_type.loc13, %.loc13_44.1 [template = Core.IntLiteral]
  871. // CHECK:STDOUT: %self.param.loc13: %OtherInt = value_param runtime_param0
  872. // CHECK:STDOUT: %Self.ref.loc13: type = name_ref Self, constants.%OtherInt [template = constants.%OtherInt]
  873. // CHECK:STDOUT: %self.loc13: %OtherInt = bind_name self, %self.param.loc13
  874. // CHECK:STDOUT: %return.param.loc13: ref Core.IntLiteral = out_param runtime_param1
  875. // CHECK:STDOUT: %return.loc13: ref Core.IntLiteral = return_slot %return.param.loc13
  876. // CHECK:STDOUT: }
  877. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %i32.builtin [template = constants.%complete_type]
  878. // CHECK:STDOUT:
  879. // CHECK:STDOUT: !members:
  880. // CHECK:STDOUT: .Self = constants.%OtherInt
  881. // CHECK:STDOUT: .ToLiteral = %ToLiteral.decl
  882. // CHECK:STDOUT: complete_type_witness = %complete_type
  883. // CHECK:STDOUT: }
  884. // CHECK:STDOUT:
  885. // CHECK:STDOUT: fn @IntLiteral() -> type = "int_literal.make_type";
  886. // CHECK:STDOUT:
  887. // CHECK:STDOUT: fn @Int(%n.param_patt: Core.IntLiteral) -> type = "int.make_type_signed";
  888. // CHECK:STDOUT:
  889. // CHECK:STDOUT: fn @ToLiteral.1(%n.param_patt: %i32.builtin) -> Core.IntLiteral = "int.convert_checked";
  890. // CHECK:STDOUT:
  891. // CHECK:STDOUT: fn @FromLiteral(%n.param_patt: Core.IntLiteral) -> %i32.builtin = "int.convert_checked";
  892. // CHECK:STDOUT:
  893. // CHECK:STDOUT: generic fn @Make(%N.loc9_9.1: %i32.builtin) {
  894. // CHECK:STDOUT: %N.loc9_9.2: %i32.builtin = bind_symbolic_name N, 0 [symbolic = %N.loc9_9.2 (constants.%N.a7a)]
  895. // CHECK:STDOUT: %N.patt.loc9_9.2: %i32.builtin = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc9_9.2 (constants.%N.patt.8e9)]
  896. // CHECK:STDOUT: %int.convert_checked.loc9_40.2: init Core.IntLiteral = call constants.%ToLiteral.cf3(%N.loc9_9.2) [symbolic = %int.convert_checked.loc9_40.2 (constants.%int.convert_checked.84b)]
  897. // CHECK:STDOUT: %iN.builtin: type = int_type signed, %int.convert_checked.loc9_40.2 [symbolic = %iN.builtin (constants.%iN.builtin.b6f)]
  898. // CHECK:STDOUT:
  899. // CHECK:STDOUT: !definition:
  900. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @Make.%iN.builtin (%iN.builtin.b6f) [symbolic = %require_complete (constants.%require_complete.b3f)]
  901. // CHECK:STDOUT: %Make.specific_fn.loc9_52.2: <specific function> = specific_function constants.%Make, @Make(%N.loc9_9.2) [symbolic = %Make.specific_fn.loc9_52.2 (constants.%Make.specific_fn)]
  902. // CHECK:STDOUT:
  903. // CHECK:STDOUT: fn(%N.param_patt: %i32.builtin) -> @Make.%iN.builtin (%iN.builtin.b6f) {
  904. // CHECK:STDOUT: !entry:
  905. // CHECK:STDOUT: %Make.ref: %Make.type = name_ref Make, file.%Make.decl [template = constants.%Make]
  906. // CHECK:STDOUT: %N.ref.loc9_57: %i32.builtin = name_ref N, %N.loc9_9.1 [symbolic = %N.loc9_9.2 (constants.%N.a7a)]
  907. // CHECK:STDOUT: %Make.specific_fn.loc9_52.1: <specific function> = specific_function %Make.ref, @Make(constants.%N.a7a) [symbolic = %Make.specific_fn.loc9_52.2 (constants.%Make.specific_fn)]
  908. // CHECK:STDOUT: %Make.call: init @Make.%iN.builtin (%iN.builtin.b6f) = call %Make.specific_fn.loc9_52.1()
  909. // CHECK:STDOUT: %.loc9_59.1: @Make.%iN.builtin (%iN.builtin.b6f) = value_of_initializer %Make.call
  910. // CHECK:STDOUT: %.loc9_59.2: @Make.%iN.builtin (%iN.builtin.b6f) = converted %Make.call, %.loc9_59.1
  911. // CHECK:STDOUT: return %.loc9_59.2
  912. // CHECK:STDOUT: }
  913. // CHECK:STDOUT: }
  914. // CHECK:STDOUT:
  915. // CHECK:STDOUT: fn @ToLiteral.2[%self.param_patt: %OtherInt]() -> Core.IntLiteral = "int.convert_checked";
  916. // CHECK:STDOUT:
  917. // CHECK:STDOUT: generic fn @MakeFromClass(%N.loc18_18.1: %OtherInt) {
  918. // CHECK:STDOUT: %N.loc18_18.2: %OtherInt = bind_symbolic_name N, 0 [symbolic = %N.loc18_18.2 (constants.%N.1a2)]
  919. // CHECK:STDOUT: %N.patt.loc18_18.2: %OtherInt = symbolic_binding_pattern N, 0 [symbolic = %N.patt.loc18_18.2 (constants.%N.patt.71c)]
  920. // CHECK:STDOUT: %ToLiteral.bound.loc18_40.2: <bound method> = bound_method %N.loc18_18.2, constants.%ToLiteral.5b3 [symbolic = %ToLiteral.bound.loc18_40.2 (constants.%ToLiteral.bound)]
  921. // CHECK:STDOUT: %int.convert_checked.loc18_51.2: init Core.IntLiteral = call %ToLiteral.bound.loc18_40.2(%N.loc18_18.2) [symbolic = %int.convert_checked.loc18_51.2 (constants.%int.convert_checked.519)]
  922. // CHECK:STDOUT: %iN.builtin: type = int_type signed, %int.convert_checked.loc18_51.2 [symbolic = %iN.builtin (constants.%iN.builtin.5d1)]
  923. // CHECK:STDOUT:
  924. // CHECK:STDOUT: !definition:
  925. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @MakeFromClass.%iN.builtin (%iN.builtin.5d1) [symbolic = %require_complete (constants.%require_complete.02e)]
  926. // CHECK:STDOUT: %MakeFromClass.specific_fn.loc18_63.2: <specific function> = specific_function constants.%MakeFromClass, @MakeFromClass(%N.loc18_18.2) [symbolic = %MakeFromClass.specific_fn.loc18_63.2 (constants.%MakeFromClass.specific_fn)]
  927. // CHECK:STDOUT:
  928. // CHECK:STDOUT: fn(%N.param_patt: %OtherInt) -> @MakeFromClass.%iN.builtin (%iN.builtin.5d1) {
  929. // CHECK:STDOUT: !entry:
  930. // CHECK:STDOUT: %MakeFromClass.ref: %MakeFromClass.type = name_ref MakeFromClass, file.%MakeFromClass.decl [template = constants.%MakeFromClass]
  931. // CHECK:STDOUT: %N.ref.loc18_77: %OtherInt = name_ref N, %N.loc18_18.1 [symbolic = %N.loc18_18.2 (constants.%N.1a2)]
  932. // CHECK:STDOUT: %MakeFromClass.specific_fn.loc18_63.1: <specific function> = specific_function %MakeFromClass.ref, @MakeFromClass(constants.%N.1a2) [symbolic = %MakeFromClass.specific_fn.loc18_63.2 (constants.%MakeFromClass.specific_fn)]
  933. // CHECK:STDOUT: %MakeFromClass.call: init @MakeFromClass.%iN.builtin (%iN.builtin.5d1) = call %MakeFromClass.specific_fn.loc18_63.1()
  934. // CHECK:STDOUT: %.loc18_79.1: @MakeFromClass.%iN.builtin (%iN.builtin.5d1) = value_of_initializer %MakeFromClass.call
  935. // CHECK:STDOUT: %.loc18_79.2: @MakeFromClass.%iN.builtin (%iN.builtin.5d1) = converted %MakeFromClass.call, %.loc18_79.1
  936. // CHECK:STDOUT: return %.loc18_79.2
  937. // CHECK:STDOUT: }
  938. // CHECK:STDOUT: }
  939. // CHECK:STDOUT:
  940. // CHECK:STDOUT: specific @Make(constants.%N.a7a) {
  941. // CHECK:STDOUT: %N.loc9_9.2 => constants.%N.a7a
  942. // CHECK:STDOUT: %N.patt.loc9_9.2 => constants.%N.a7a
  943. // CHECK:STDOUT: %int.convert_checked.loc9_40.2 => constants.%int.convert_checked.84b
  944. // CHECK:STDOUT: %iN.builtin => constants.%iN.builtin.b6f
  945. // CHECK:STDOUT:
  946. // CHECK:STDOUT: !definition:
  947. // CHECK:STDOUT: %require_complete => constants.%require_complete.b3f
  948. // CHECK:STDOUT: %Make.specific_fn.loc9_52.2 => constants.%Make.specific_fn
  949. // CHECK:STDOUT: }
  950. // CHECK:STDOUT:
  951. // CHECK:STDOUT: specific @Make(%N.loc9_9.2) {}
  952. // CHECK:STDOUT:
  953. // CHECK:STDOUT: specific @MakeFromClass(constants.%N.1a2) {
  954. // CHECK:STDOUT: %N.loc18_18.2 => constants.%N.1a2
  955. // CHECK:STDOUT: %N.patt.loc18_18.2 => constants.%N.1a2
  956. // CHECK:STDOUT: %ToLiteral.bound.loc18_40.2 => constants.%ToLiteral.bound
  957. // CHECK:STDOUT: %int.convert_checked.loc18_51.2 => constants.%int.convert_checked.519
  958. // CHECK:STDOUT: %iN.builtin => constants.%iN.builtin.5d1
  959. // CHECK:STDOUT:
  960. // CHECK:STDOUT: !definition:
  961. // CHECK:STDOUT: %require_complete => constants.%require_complete.02e
  962. // CHECK:STDOUT: %MakeFromClass.specific_fn.loc18_63.2 => constants.%MakeFromClass.specific_fn
  963. // CHECK:STDOUT: }
  964. // CHECK:STDOUT:
  965. // CHECK:STDOUT: specific @MakeFromClass(%N.loc18_18.2) {}
  966. // CHECK:STDOUT:
  967. // CHECK:STDOUT: --- use_convert_symbolic.carbon
  968. // CHECK:STDOUT:
  969. // CHECK:STDOUT: constants {
  970. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  971. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  972. // CHECK:STDOUT: %int_64.fab: Core.IntLiteral = int_value 64 [template]
  973. // CHECK:STDOUT: %i64.builtin: type = int_type signed, %int_64.fab [template]
  974. // CHECK:STDOUT: %Make.type: type = fn_type @Make [template]
  975. // CHECK:STDOUT: %Make: %Make.type = struct_value () [template]
  976. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  977. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  978. // CHECK:STDOUT: %N.a7a: %i32.builtin = bind_symbolic_name N, 0 [symbolic]
  979. // CHECK:STDOUT: %N.patt.8e9: %i32.builtin = symbolic_binding_pattern N, 0 [symbolic]
  980. // CHECK:STDOUT: %ToLiteral.type.e7c: type = fn_type @ToLiteral.1 [template]
  981. // CHECK:STDOUT: %ToLiteral.cf3: %ToLiteral.type.e7c = struct_value () [template]
  982. // CHECK:STDOUT: %int.convert_checked.84b: init Core.IntLiteral = call %ToLiteral.cf3(%N.a7a) [symbolic]
  983. // CHECK:STDOUT: %iN.builtin.b6f: type = int_type signed, %int.convert_checked.84b [symbolic]
  984. // CHECK:STDOUT: %require_complete.b3f: <witness> = require_complete_type %iN.builtin.b6f [symbolic]
  985. // CHECK:STDOUT: %Make.specific_fn.45b: <specific function> = specific_function %Make, @Make(%N.a7a) [symbolic]
  986. // CHECK:STDOUT: %FromLiteral.type: type = fn_type @FromLiteral [template]
  987. // CHECK:STDOUT: %FromLiteral: %FromLiteral.type = struct_value () [template]
  988. // CHECK:STDOUT: %int_64.f82: %i32.builtin = int_value 64 [template]
  989. // CHECK:STDOUT: %Make.specific_fn.525: <specific function> = specific_function %Make, @Make(%int_64.f82) [template]
  990. // CHECK:STDOUT: %MakeFromClass.type: type = fn_type @MakeFromClass [template]
  991. // CHECK:STDOUT: %MakeFromClass: %MakeFromClass.type = struct_value () [template]
  992. // CHECK:STDOUT: %OtherInt: type = class_type @OtherInt [template]
  993. // CHECK:STDOUT: %complete_type.f8a: <witness> = complete_type_witness %i32.builtin [template]
  994. // CHECK:STDOUT: %N.1a2: %OtherInt = bind_symbolic_name N, 0 [symbolic]
  995. // CHECK:STDOUT: %N.patt.71c: %OtherInt = symbolic_binding_pattern N, 0 [symbolic]
  996. // CHECK:STDOUT: %ToLiteral.type.ea8: type = fn_type @ToLiteral.2 [template]
  997. // CHECK:STDOUT: %ToLiteral.5b3: %ToLiteral.type.ea8 = struct_value () [template]
  998. // CHECK:STDOUT: %ToLiteral.bound.e03: <bound method> = bound_method %N.1a2, %ToLiteral.5b3 [symbolic]
  999. // CHECK:STDOUT: %int.convert_checked.519: init Core.IntLiteral = call %ToLiteral.bound.e03(%N.1a2) [symbolic]
  1000. // CHECK:STDOUT: %iN.builtin.5d1: type = int_type signed, %int.convert_checked.519 [symbolic]
  1001. // CHECK:STDOUT: %require_complete.02e: <witness> = require_complete_type %iN.builtin.5d1 [symbolic]
  1002. // CHECK:STDOUT: %MakeFromClass.specific_fn.f22: <specific function> = specific_function %MakeFromClass, @MakeFromClass(%N.1a2) [symbolic]
  1003. // CHECK:STDOUT: %ToLiteral.bound.648: <bound method> = bound_method %int_64.f82, %ToLiteral.5b3 [template]
  1004. // CHECK:STDOUT: %MakeFromClass.specific_fn.b9d: <specific function> = specific_function %MakeFromClass, @MakeFromClass(%int_64.f82) [template]
  1005. // CHECK:STDOUT: %complete_type.4a1: <witness> = complete_type_witness %i64.builtin [template]
  1006. // CHECK:STDOUT: }
  1007. // CHECK:STDOUT:
  1008. // CHECK:STDOUT: imports {
  1009. // CHECK:STDOUT: %import_ref.f28 = import_ref Main//convert_symbolic, IntLiteral, unloaded
  1010. // CHECK:STDOUT: %import_ref.85d: %Int.type = import_ref Main//convert_symbolic, Int, loaded [template = constants.%Int]
  1011. // CHECK:STDOUT: %import_ref.4be = import_ref Main//convert_symbolic, ToLiteral, unloaded
  1012. // CHECK:STDOUT: %import_ref.3f7: %FromLiteral.type = import_ref Main//convert_symbolic, FromLiteral, loaded [template = constants.%FromLiteral]
  1013. // CHECK:STDOUT: %import_ref.0e9: %Make.type = import_ref Main//convert_symbolic, Make, loaded [template = constants.%Make]
  1014. // CHECK:STDOUT: %import_ref.9cf: type = import_ref Main//convert_symbolic, OtherInt, loaded [template = constants.%OtherInt]
  1015. // CHECK:STDOUT: %import_ref.87f: %MakeFromClass.type = import_ref Main//convert_symbolic, MakeFromClass, loaded [template = constants.%MakeFromClass]
  1016. // CHECK:STDOUT: %import_ref.b03: <witness> = import_ref Main//convert_symbolic, loc14_1, loaded [template = constants.%complete_type.f8a]
  1017. // CHECK:STDOUT: %import_ref.d11 = import_ref Main//convert_symbolic, inst129 [no loc], unloaded
  1018. // CHECK:STDOUT: %import_ref.6ba = import_ref Main//convert_symbolic, loc13_45, unloaded
  1019. // CHECK:STDOUT: }
  1020. // CHECK:STDOUT:
  1021. // CHECK:STDOUT: file {
  1022. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1023. // CHECK:STDOUT: .IntLiteral = imports.%import_ref.f28
  1024. // CHECK:STDOUT: .Int = imports.%import_ref.85d
  1025. // CHECK:STDOUT: .ToLiteral = imports.%import_ref.4be
  1026. // CHECK:STDOUT: .FromLiteral = imports.%import_ref.3f7
  1027. // CHECK:STDOUT: .Make = imports.%import_ref.0e9
  1028. // CHECK:STDOUT: .OtherInt = imports.%import_ref.9cf
  1029. // CHECK:STDOUT: .MakeFromClass = imports.%import_ref.87f
  1030. // CHECK:STDOUT: .m = %m
  1031. // CHECK:STDOUT: .n = %n
  1032. // CHECK:STDOUT: }
  1033. // CHECK:STDOUT: %default.import = import <invalid>
  1034. // CHECK:STDOUT: %m.var: ref %i64.builtin = var m
  1035. // CHECK:STDOUT: %m: ref %i64.builtin = bind_name m, %m.var
  1036. // CHECK:STDOUT: %n.var: ref %i64.builtin = var n
  1037. // CHECK:STDOUT: %n: ref %i64.builtin = bind_name n, %n.var
  1038. // CHECK:STDOUT: }
  1039. // CHECK:STDOUT:
  1040. // CHECK:STDOUT: class @OtherInt [from "convert_symbolic.carbon"] {
  1041. // CHECK:STDOUT: !members:
  1042. // CHECK:STDOUT: .Self = imports.%import_ref.d11
  1043. // CHECK:STDOUT: .ToLiteral = imports.%import_ref.6ba
  1044. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.b03
  1045. // CHECK:STDOUT: }
  1046. // CHECK:STDOUT:
  1047. // CHECK:STDOUT: fn @Int(%n.param_patt: Core.IntLiteral) -> type = "int.make_type_signed" [from "convert_symbolic.carbon"];
  1048. // CHECK:STDOUT:
  1049. // CHECK:STDOUT: generic fn @Make(constants.%N.a7a: %i32.builtin) [from "convert_symbolic.carbon"] {
  1050. // CHECK:STDOUT: %N: %i32.builtin = bind_symbolic_name N, 0 [symbolic = %N (constants.%N.a7a)]
  1051. // CHECK:STDOUT: %N.patt: %i32.builtin = symbolic_binding_pattern N, 0 [symbolic = %N.patt (constants.%N.patt.8e9)]
  1052. // CHECK:STDOUT: %int.convert_checked: init Core.IntLiteral = call constants.%ToLiteral.cf3(%N) [symbolic = %int.convert_checked (constants.%int.convert_checked.84b)]
  1053. // CHECK:STDOUT: %iN.builtin: type = int_type signed, %int.convert_checked [symbolic = %iN.builtin (constants.%iN.builtin.b6f)]
  1054. // CHECK:STDOUT:
  1055. // CHECK:STDOUT: !definition:
  1056. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @Make.%iN.builtin (%iN.builtin.b6f) [symbolic = %require_complete (constants.%require_complete.b3f)]
  1057. // CHECK:STDOUT: %Make.specific_fn: <specific function> = specific_function constants.%Make, @Make(%N) [symbolic = %Make.specific_fn (constants.%Make.specific_fn.45b)]
  1058. // CHECK:STDOUT:
  1059. // CHECK:STDOUT: fn(%N.param_patt: %i32.builtin) -> @Make.%iN.builtin (%iN.builtin.b6f);
  1060. // CHECK:STDOUT: }
  1061. // CHECK:STDOUT:
  1062. // CHECK:STDOUT: fn @ToLiteral.1(%n.param_patt: %i32.builtin) -> Core.IntLiteral = "int.convert_checked" [from "convert_symbolic.carbon"];
  1063. // CHECK:STDOUT:
  1064. // CHECK:STDOUT: fn @FromLiteral(%n.param_patt: Core.IntLiteral) -> %i32.builtin = "int.convert_checked" [from "convert_symbolic.carbon"];
  1065. // CHECK:STDOUT:
  1066. // CHECK:STDOUT: generic fn @MakeFromClass(constants.%N.1a2: %OtherInt) [from "convert_symbolic.carbon"] {
  1067. // CHECK:STDOUT: %N: %OtherInt = bind_symbolic_name N, 0 [symbolic = %N (constants.%N.1a2)]
  1068. // CHECK:STDOUT: %N.patt: %OtherInt = symbolic_binding_pattern N, 0 [symbolic = %N.patt (constants.%N.patt.71c)]
  1069. // CHECK:STDOUT: %ToLiteral.bound: <bound method> = bound_method %N, constants.%ToLiteral.5b3 [symbolic = %ToLiteral.bound (constants.%ToLiteral.bound.e03)]
  1070. // CHECK:STDOUT: %int.convert_checked: init Core.IntLiteral = call %ToLiteral.bound(%N) [symbolic = %int.convert_checked (constants.%int.convert_checked.519)]
  1071. // CHECK:STDOUT: %iN.builtin: type = int_type signed, %int.convert_checked [symbolic = %iN.builtin (constants.%iN.builtin.5d1)]
  1072. // CHECK:STDOUT:
  1073. // CHECK:STDOUT: !definition:
  1074. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type @MakeFromClass.%iN.builtin (%iN.builtin.5d1) [symbolic = %require_complete (constants.%require_complete.02e)]
  1075. // CHECK:STDOUT: %MakeFromClass.specific_fn: <specific function> = specific_function constants.%MakeFromClass, @MakeFromClass(%N) [symbolic = %MakeFromClass.specific_fn (constants.%MakeFromClass.specific_fn.f22)]
  1076. // CHECK:STDOUT:
  1077. // CHECK:STDOUT: fn(%N.param_patt: %OtherInt) -> @MakeFromClass.%iN.builtin (%iN.builtin.5d1);
  1078. // CHECK:STDOUT: }
  1079. // CHECK:STDOUT:
  1080. // CHECK:STDOUT: fn @ToLiteral.2[%self.param_patt: %OtherInt]() -> Core.IntLiteral = "int.convert_checked" [from "convert_symbolic.carbon"];
  1081. // CHECK:STDOUT:
  1082. // CHECK:STDOUT: fn @__global_init() {
  1083. // CHECK:STDOUT: !entry:
  1084. // CHECK:STDOUT: %Make.ref: %Make.type = name_ref Make, imports.%import_ref.0e9 [template = constants.%Make]
  1085. // CHECK:STDOUT: %FromLiteral.ref.loc6: %FromLiteral.type = name_ref FromLiteral, imports.%import_ref.3f7 [template = constants.%FromLiteral]
  1086. // CHECK:STDOUT: %int_64.loc6: Core.IntLiteral = int_value 64 [template = constants.%int_64.fab]
  1087. // CHECK:STDOUT: %int.convert_checked.loc6: init %i32.builtin = call %FromLiteral.ref.loc6(%int_64.loc6) [template = constants.%int_64.f82]
  1088. // CHECK:STDOUT: %.loc6_38.1: %i32.builtin = value_of_initializer %int.convert_checked.loc6 [template = constants.%int_64.f82]
  1089. // CHECK:STDOUT: %.loc6_38.2: %i32.builtin = converted %int.convert_checked.loc6, %.loc6_38.1 [template = constants.%int_64.f82]
  1090. // CHECK:STDOUT: %Make.specific_fn: <specific function> = specific_function %Make.ref, @Make(constants.%int_64.f82) [template = constants.%Make.specific_fn.525]
  1091. // CHECK:STDOUT: %Make.call: init %i64.builtin = call %Make.specific_fn()
  1092. // CHECK:STDOUT: assign file.%m.var, %Make.call
  1093. // CHECK:STDOUT: %MakeFromClass.ref: %MakeFromClass.type = name_ref MakeFromClass, imports.%import_ref.87f [template = constants.%MakeFromClass]
  1094. // CHECK:STDOUT: %FromLiteral.ref.loc7: %FromLiteral.type = name_ref FromLiteral, imports.%import_ref.3f7 [template = constants.%FromLiteral]
  1095. // CHECK:STDOUT: %int_64.loc7: Core.IntLiteral = int_value 64 [template = constants.%int_64.fab]
  1096. // CHECK:STDOUT: %int.convert_checked.loc7: init %i32.builtin = call %FromLiteral.ref.loc7(%int_64.loc7) [template = constants.%int_64.f82]
  1097. // CHECK:STDOUT: %OtherInt.ref: type = name_ref OtherInt, imports.%import_ref.9cf [template = constants.%OtherInt]
  1098. // CHECK:STDOUT: %.loc7_48.1: init %OtherInt = as_compatible %int.convert_checked.loc7 [template = constants.%int_64.f82]
  1099. // CHECK:STDOUT: %.loc7_48.2: init %OtherInt = converted %int.convert_checked.loc7, %.loc7_48.1 [template = constants.%int_64.f82]
  1100. // CHECK:STDOUT: %.loc7_59.1: %OtherInt = value_of_initializer %.loc7_48.2 [template = constants.%int_64.f82]
  1101. // CHECK:STDOUT: %.loc7_59.2: %OtherInt = converted %.loc7_48.2, %.loc7_59.1 [template = constants.%int_64.f82]
  1102. // CHECK:STDOUT: %MakeFromClass.specific_fn: <specific function> = specific_function %MakeFromClass.ref, @MakeFromClass(constants.%int_64.f82) [template = constants.%MakeFromClass.specific_fn.b9d]
  1103. // CHECK:STDOUT: %MakeFromClass.call: init %i64.builtin = call %MakeFromClass.specific_fn()
  1104. // CHECK:STDOUT: assign file.%n.var, %MakeFromClass.call
  1105. // CHECK:STDOUT: return
  1106. // CHECK:STDOUT: }
  1107. // CHECK:STDOUT:
  1108. // CHECK:STDOUT: specific @Make(constants.%N.a7a) {
  1109. // CHECK:STDOUT: %N => constants.%N.a7a
  1110. // CHECK:STDOUT: %N.patt => constants.%N.a7a
  1111. // CHECK:STDOUT: %int.convert_checked => constants.%int.convert_checked.84b
  1112. // CHECK:STDOUT: %iN.builtin => constants.%iN.builtin.b6f
  1113. // CHECK:STDOUT:
  1114. // CHECK:STDOUT: !definition:
  1115. // CHECK:STDOUT: %require_complete => constants.%require_complete.b3f
  1116. // CHECK:STDOUT: %Make.specific_fn => constants.%Make.specific_fn.45b
  1117. // CHECK:STDOUT: }
  1118. // CHECK:STDOUT:
  1119. // CHECK:STDOUT: specific @Make(%N) {}
  1120. // CHECK:STDOUT:
  1121. // CHECK:STDOUT: specific @Make(constants.%int_64.f82) {
  1122. // CHECK:STDOUT: %N => constants.%int_64.f82
  1123. // CHECK:STDOUT: %N.patt => constants.%int_64.f82
  1124. // CHECK:STDOUT: %int.convert_checked => constants.%int_64.fab
  1125. // CHECK:STDOUT: %iN.builtin => constants.%i64.builtin
  1126. // CHECK:STDOUT:
  1127. // CHECK:STDOUT: !definition:
  1128. // CHECK:STDOUT: %require_complete => constants.%complete_type.4a1
  1129. // CHECK:STDOUT: %Make.specific_fn => constants.%Make.specific_fn.525
  1130. // CHECK:STDOUT: }
  1131. // CHECK:STDOUT:
  1132. // CHECK:STDOUT: specific @MakeFromClass(constants.%N.1a2) {
  1133. // CHECK:STDOUT: %N => constants.%N.1a2
  1134. // CHECK:STDOUT: %N.patt => constants.%N.1a2
  1135. // CHECK:STDOUT: %ToLiteral.bound => constants.%ToLiteral.bound.e03
  1136. // CHECK:STDOUT: %int.convert_checked => constants.%int.convert_checked.519
  1137. // CHECK:STDOUT: %iN.builtin => constants.%iN.builtin.5d1
  1138. // CHECK:STDOUT:
  1139. // CHECK:STDOUT: !definition:
  1140. // CHECK:STDOUT: %require_complete => constants.%require_complete.02e
  1141. // CHECK:STDOUT: %MakeFromClass.specific_fn => constants.%MakeFromClass.specific_fn.f22
  1142. // CHECK:STDOUT: }
  1143. // CHECK:STDOUT:
  1144. // CHECK:STDOUT: specific @MakeFromClass(%N) {}
  1145. // CHECK:STDOUT:
  1146. // CHECK:STDOUT: specific @MakeFromClass(constants.%int_64.f82) {
  1147. // CHECK:STDOUT: %N => constants.%int_64.f82
  1148. // CHECK:STDOUT: %N.patt => constants.%int_64.f82
  1149. // CHECK:STDOUT: %ToLiteral.bound => constants.%ToLiteral.bound.648
  1150. // CHECK:STDOUT: %int.convert_checked => constants.%int_64.fab
  1151. // CHECK:STDOUT: %iN.builtin => constants.%i64.builtin
  1152. // CHECK:STDOUT:
  1153. // CHECK:STDOUT: !definition:
  1154. // CHECK:STDOUT: %require_complete => constants.%complete_type.4a1
  1155. // CHECK:STDOUT: %MakeFromClass.specific_fn => constants.%MakeFromClass.specific_fn.b9d
  1156. // CHECK:STDOUT: }
  1157. // CHECK:STDOUT: