raw_ir.carbon 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. // ARGS: compile --no-prelude-import --phase=check --dump-raw-sem-ir %s
  6. //
  7. // Check that raw IR dumping works as expected.
  8. //
  9. // AUTOUPDATE
  10. fn Foo(n: ()) -> ((), ()) {
  11. return (n, ());
  12. }
  13. // CHECK:STDOUT: ---
  14. // CHECK:STDOUT: filename: raw_ir.carbon
  15. // CHECK:STDOUT: sem_ir:
  16. // CHECK:STDOUT: import_irs_size: 2
  17. // CHECK:STDOUT: name_scopes:
  18. // CHECK:STDOUT: name_scope0: {inst: inst+0, enclosing_scope: name_scope<invalid>, has_error: false, extended_scopes: [], names: {name0: inst+15}}
  19. // CHECK:STDOUT: bind_names:
  20. // CHECK:STDOUT: bindName0: {name: name1, enclosing_scope: name_scope<invalid>}
  21. // CHECK:STDOUT: functions:
  22. // CHECK:STDOUT: function0: {name: name0, enclosing_scope: name_scope0, param_refs: block3, return_type: type2, return_slot: inst+13, body: [block6]}
  23. // CHECK:STDOUT: classes: {}
  24. // CHECK:STDOUT: types:
  25. // CHECK:STDOUT: type0: {constant: template instNamespaceType, value_rep: {kind: copy, type: type0}}
  26. // CHECK:STDOUT: type1: {constant: template inst+1, value_rep: {kind: none, type: type1}}
  27. // CHECK:STDOUT: type2: {constant: template inst+8, value_rep: {kind: pointer, type: type3}}
  28. // CHECK:STDOUT: type3: {constant: template inst+14, value_rep: {kind: copy, type: type3}}
  29. // CHECK:STDOUT: type4: {constant: template instFunctionType, value_rep: {kind: copy, type: type4}}
  30. // CHECK:STDOUT: type_blocks:
  31. // CHECK:STDOUT: typeBlock0: {}
  32. // CHECK:STDOUT: typeBlock1: {}
  33. // CHECK:STDOUT: typeBlock2: {}
  34. // CHECK:STDOUT: typeBlock3: {}
  35. // CHECK:STDOUT: typeBlock4:
  36. // CHECK:STDOUT: 0: type1
  37. // CHECK:STDOUT: 1: type1
  38. // CHECK:STDOUT: typeBlock5: {}
  39. // CHECK:STDOUT: typeBlock6: {}
  40. // CHECK:STDOUT: typeBlock7:
  41. // CHECK:STDOUT: 0: type1
  42. // CHECK:STDOUT: 1: type1
  43. // CHECK:STDOUT: typeBlock8: {}
  44. // CHECK:STDOUT: typeBlock9: {}
  45. // CHECK:STDOUT: typeBlock10:
  46. // CHECK:STDOUT: 0: type1
  47. // CHECK:STDOUT: 1: type1
  48. // CHECK:STDOUT: insts:
  49. // CHECK:STDOUT: inst+0: {kind: Namespace, arg0: name_scope0, arg1: inst<invalid>, type: type0}
  50. // CHECK:STDOUT: inst+1: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}
  51. // CHECK:STDOUT: inst+2: {kind: TupleLiteral, arg0: empty, type: type1}
  52. // CHECK:STDOUT: inst+3: {kind: Converted, arg0: inst+2, arg1: inst+1, type: typeTypeType}
  53. // CHECK:STDOUT: inst+4: {kind: Param, arg0: name1, type: type1}
  54. // CHECK:STDOUT: inst+5: {kind: BindName, arg0: bindName0, arg1: inst+4, type: type1}
  55. // CHECK:STDOUT: inst+6: {kind: TupleLiteral, arg0: empty, type: type1}
  56. // CHECK:STDOUT: inst+7: {kind: TupleLiteral, arg0: empty, type: type1}
  57. // CHECK:STDOUT: inst+8: {kind: TupleType, arg0: typeBlock4, type: typeTypeType}
  58. // CHECK:STDOUT: inst+9: {kind: TupleLiteral, arg0: block4, type: type2}
  59. // CHECK:STDOUT: inst+10: {kind: Converted, arg0: inst+6, arg1: inst+1, type: typeTypeType}
  60. // CHECK:STDOUT: inst+11: {kind: Converted, arg0: inst+7, arg1: inst+1, type: typeTypeType}
  61. // CHECK:STDOUT: inst+12: {kind: Converted, arg0: inst+9, arg1: inst+8, type: typeTypeType}
  62. // CHECK:STDOUT: inst+13: {kind: VarStorage, arg0: nameReturnSlot, type: type2}
  63. // CHECK:STDOUT: inst+14: {kind: PointerType, arg0: type2, type: typeTypeType}
  64. // CHECK:STDOUT: inst+15: {kind: FunctionDecl, arg0: function0, arg1: block5, type: type4}
  65. // CHECK:STDOUT: inst+16: {kind: NameRef, arg0: name1, arg1: inst+5, type: type1}
  66. // CHECK:STDOUT: inst+17: {kind: TupleLiteral, arg0: empty, type: type1}
  67. // CHECK:STDOUT: inst+18: {kind: TupleLiteral, arg0: block7, type: type2}
  68. // CHECK:STDOUT: inst+19: {kind: TupleAccess, arg0: inst+13, arg1: element0, type: type1}
  69. // CHECK:STDOUT: inst+20: {kind: TupleInit, arg0: block8, arg1: inst+19, type: type1}
  70. // CHECK:STDOUT: inst+21: {kind: TupleValue, arg0: block9, type: type1}
  71. // CHECK:STDOUT: inst+22: {kind: Converted, arg0: inst+16, arg1: inst+20, type: type1}
  72. // CHECK:STDOUT: inst+23: {kind: TupleAccess, arg0: inst+13, arg1: element1, type: type1}
  73. // CHECK:STDOUT: inst+24: {kind: TupleInit, arg0: empty, arg1: inst+23, type: type1}
  74. // CHECK:STDOUT: inst+25: {kind: Converted, arg0: inst+17, arg1: inst+24, type: type1}
  75. // CHECK:STDOUT: inst+26: {kind: TupleInit, arg0: block10, arg1: inst+13, type: type2}
  76. // CHECK:STDOUT: inst+27: {kind: TupleValue, arg0: block12, type: type2}
  77. // CHECK:STDOUT: inst+28: {kind: Converted, arg0: inst+18, arg1: inst+26, type: type2}
  78. // CHECK:STDOUT: inst+29: {kind: ReturnExpr, arg0: inst+28}
  79. // CHECK:STDOUT: constant_values:
  80. // CHECK:STDOUT: inst+0: template inst+0
  81. // CHECK:STDOUT: inst+1: template inst+1
  82. // CHECK:STDOUT: inst+3: template inst+1
  83. // CHECK:STDOUT: inst+8: template inst+8
  84. // CHECK:STDOUT: inst+10: template inst+1
  85. // CHECK:STDOUT: inst+11: template inst+1
  86. // CHECK:STDOUT: inst+12: template inst+8
  87. // CHECK:STDOUT: inst+14: template inst+14
  88. // CHECK:STDOUT: inst+15: template inst+15
  89. // CHECK:STDOUT: inst+20: template inst+21
  90. // CHECK:STDOUT: inst+21: template inst+21
  91. // CHECK:STDOUT: inst+22: template inst+21
  92. // CHECK:STDOUT: inst+24: template inst+21
  93. // CHECK:STDOUT: inst+25: template inst+21
  94. // CHECK:STDOUT: inst+26: template inst+27
  95. // CHECK:STDOUT: inst+27: template inst+27
  96. // CHECK:STDOUT: inst+28: template inst+27
  97. // CHECK:STDOUT: inst_blocks:
  98. // CHECK:STDOUT: empty: {}
  99. // CHECK:STDOUT: exports:
  100. // CHECK:STDOUT: 0: inst+15
  101. // CHECK:STDOUT: global_init: {}
  102. // CHECK:STDOUT: block3:
  103. // CHECK:STDOUT: 0: inst+5
  104. // CHECK:STDOUT: block4:
  105. // CHECK:STDOUT: 0: inst+6
  106. // CHECK:STDOUT: 1: inst+7
  107. // CHECK:STDOUT: block5:
  108. // CHECK:STDOUT: 0: inst+2
  109. // CHECK:STDOUT: 1: inst+3
  110. // CHECK:STDOUT: 2: inst+4
  111. // CHECK:STDOUT: 3: inst+5
  112. // CHECK:STDOUT: 4: inst+6
  113. // CHECK:STDOUT: 5: inst+7
  114. // CHECK:STDOUT: 6: inst+9
  115. // CHECK:STDOUT: 7: inst+10
  116. // CHECK:STDOUT: 8: inst+11
  117. // CHECK:STDOUT: 9: inst+12
  118. // CHECK:STDOUT: 10: inst+13
  119. // CHECK:STDOUT: block6:
  120. // CHECK:STDOUT: 0: inst+16
  121. // CHECK:STDOUT: 1: inst+17
  122. // CHECK:STDOUT: 2: inst+18
  123. // CHECK:STDOUT: 3: inst+19
  124. // CHECK:STDOUT: 4: inst+20
  125. // CHECK:STDOUT: 5: inst+22
  126. // CHECK:STDOUT: 6: inst+23
  127. // CHECK:STDOUT: 7: inst+24
  128. // CHECK:STDOUT: 8: inst+25
  129. // CHECK:STDOUT: 9: inst+26
  130. // CHECK:STDOUT: 10: inst+28
  131. // CHECK:STDOUT: 11: inst+29
  132. // CHECK:STDOUT: block7:
  133. // CHECK:STDOUT: 0: inst+16
  134. // CHECK:STDOUT: 1: inst+17
  135. // CHECK:STDOUT: block8: {}
  136. // CHECK:STDOUT: block9: {}
  137. // CHECK:STDOUT: block10:
  138. // CHECK:STDOUT: 0: inst+22
  139. // CHECK:STDOUT: 1: inst+25
  140. // CHECK:STDOUT: block11: {}
  141. // CHECK:STDOUT: block12:
  142. // CHECK:STDOUT: 0: inst+21
  143. // CHECK:STDOUT: 1: inst+21
  144. // CHECK:STDOUT: block13:
  145. // CHECK:STDOUT: 0: inst+0
  146. // CHECK:STDOUT: 1: inst+15
  147. // CHECK:STDOUT: ...