raw_ir.carbon 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 --phase=check --dump-raw-sem-ir %s
  6. //
  7. // Check that raw IR dumping works as expected.
  8. //
  9. // AUTOUPDATE
  10. fn Foo(n: i32) -> (i32, i32, f64) {
  11. return (n, 2, 3.4);
  12. }
  13. // CHECK:STDOUT: ---
  14. // CHECK:STDOUT: filename: raw_ir.carbon
  15. // CHECK:STDOUT: sem_ir:
  16. // CHECK:STDOUT: import_irs_size: 1
  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+9}}
  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: type4, return_slot: inst+7, 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 instIntType, value_rep: {kind: copy, type: type1}}
  27. // CHECK:STDOUT: type2: {constant: template inst+3, value_rep: {kind: unknown, type: type<invalid>}}
  28. // CHECK:STDOUT: type3: {constant: template instFloatType, value_rep: {kind: copy, type: type3}}
  29. // CHECK:STDOUT: type4: {constant: template inst+5, value_rep: {kind: pointer, type: type5}}
  30. // CHECK:STDOUT: type5: {constant: template inst+8, value_rep: {kind: copy, type: type5}}
  31. // CHECK:STDOUT: type6: {constant: template instFunctionType, value_rep: {kind: copy, type: type6}}
  32. // CHECK:STDOUT: type_blocks:
  33. // CHECK:STDOUT: typeBlock0:
  34. // CHECK:STDOUT: 0: typeTypeType
  35. // CHECK:STDOUT: 1: typeTypeType
  36. // CHECK:STDOUT: 2: typeTypeType
  37. // CHECK:STDOUT: typeBlock1:
  38. // CHECK:STDOUT: 0: type1
  39. // CHECK:STDOUT: 1: type1
  40. // CHECK:STDOUT: 2: type3
  41. // CHECK:STDOUT: typeBlock2:
  42. // CHECK:STDOUT: 0: type1
  43. // CHECK:STDOUT: 1: type1
  44. // CHECK:STDOUT: 2: type3
  45. // CHECK:STDOUT: insts:
  46. // CHECK:STDOUT: inst+0: {kind: Namespace, arg0: name_scope0, arg1: inst<invalid>, type: type0}
  47. // CHECK:STDOUT: inst+1: {kind: Param, arg0: name1, type: type1}
  48. // CHECK:STDOUT: inst+2: {kind: BindName, arg0: bindName0, arg1: inst+1, type: type1}
  49. // CHECK:STDOUT: inst+3: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}
  50. // CHECK:STDOUT: inst+4: {kind: TupleLiteral, arg0: block4, type: type2}
  51. // CHECK:STDOUT: inst+5: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}
  52. // CHECK:STDOUT: inst+6: {kind: Converted, arg0: inst+4, arg1: inst+5, type: typeTypeType}
  53. // CHECK:STDOUT: inst+7: {kind: VarStorage, arg0: nameReturnSlot, type: type4}
  54. // CHECK:STDOUT: inst+8: {kind: PointerType, arg0: type4, type: typeTypeType}
  55. // CHECK:STDOUT: inst+9: {kind: FunctionDecl, arg0: function0, arg1: block5, type: type6}
  56. // CHECK:STDOUT: inst+10: {kind: NameRef, arg0: name1, arg1: inst+2, type: type1}
  57. // CHECK:STDOUT: inst+11: {kind: IntLiteral, arg0: int5, type: type1}
  58. // CHECK:STDOUT: inst+12: {kind: IntLiteral, arg0: int5, type: type1}
  59. // CHECK:STDOUT: inst+13: {kind: RealLiteral, arg0: real0, type: type3}
  60. // CHECK:STDOUT: inst+14: {kind: RealLiteral, arg0: real0, type: type3}
  61. // CHECK:STDOUT: inst+15: {kind: TupleLiteral, arg0: block7, type: type4}
  62. // CHECK:STDOUT: inst+16: {kind: TupleAccess, arg0: inst+7, arg1: element0, type: type1}
  63. // CHECK:STDOUT: inst+17: {kind: InitializeFrom, arg0: inst+10, arg1: inst+16, type: type1}
  64. // CHECK:STDOUT: inst+18: {kind: TupleAccess, arg0: inst+7, arg1: element1, type: type1}
  65. // CHECK:STDOUT: inst+19: {kind: InitializeFrom, arg0: inst+11, arg1: inst+18, type: type1}
  66. // CHECK:STDOUT: inst+20: {kind: TupleAccess, arg0: inst+7, arg1: element2, type: type3}
  67. // CHECK:STDOUT: inst+21: {kind: InitializeFrom, arg0: inst+13, arg1: inst+20, type: type3}
  68. // CHECK:STDOUT: inst+22: {kind: TupleInit, arg0: block8, arg1: inst+7, type: type4}
  69. // CHECK:STDOUT: inst+23: {kind: Converted, arg0: inst+15, arg1: inst+22, type: type4}
  70. // CHECK:STDOUT: inst+24: {kind: ReturnExpr, arg0: inst+23}
  71. // CHECK:STDOUT: constant_values:
  72. // CHECK:STDOUT: inst+0: template inst+0
  73. // CHECK:STDOUT: inst+3: template inst+3
  74. // CHECK:STDOUT: inst+5: template inst+5
  75. // CHECK:STDOUT: inst+6: template inst+5
  76. // CHECK:STDOUT: inst+8: template inst+8
  77. // CHECK:STDOUT: inst+9: template inst+9
  78. // CHECK:STDOUT: inst+11: template inst+12
  79. // CHECK:STDOUT: inst+12: template inst+12
  80. // CHECK:STDOUT: inst+13: template inst+14
  81. // CHECK:STDOUT: inst+14: template inst+14
  82. // CHECK:STDOUT: inst+19: template inst+12
  83. // CHECK:STDOUT: inst+21: template inst+14
  84. // CHECK:STDOUT: inst_blocks:
  85. // CHECK:STDOUT: empty: {}
  86. // CHECK:STDOUT: exports:
  87. // CHECK:STDOUT: 0: inst+9
  88. // CHECK:STDOUT: global_init: {}
  89. // CHECK:STDOUT: block3:
  90. // CHECK:STDOUT: 0: inst+2
  91. // CHECK:STDOUT: block4:
  92. // CHECK:STDOUT: 0: instIntType
  93. // CHECK:STDOUT: 1: instIntType
  94. // CHECK:STDOUT: 2: instFloatType
  95. // CHECK:STDOUT: block5:
  96. // CHECK:STDOUT: 0: inst+1
  97. // CHECK:STDOUT: 1: inst+2
  98. // CHECK:STDOUT: 2: inst+4
  99. // CHECK:STDOUT: 3: inst+6
  100. // CHECK:STDOUT: 4: inst+7
  101. // CHECK:STDOUT: block6:
  102. // CHECK:STDOUT: 0: inst+10
  103. // CHECK:STDOUT: 1: inst+11
  104. // CHECK:STDOUT: 2: inst+13
  105. // CHECK:STDOUT: 3: inst+15
  106. // CHECK:STDOUT: 4: inst+16
  107. // CHECK:STDOUT: 5: inst+17
  108. // CHECK:STDOUT: 6: inst+18
  109. // CHECK:STDOUT: 7: inst+19
  110. // CHECK:STDOUT: 8: inst+20
  111. // CHECK:STDOUT: 9: inst+21
  112. // CHECK:STDOUT: 10: inst+22
  113. // CHECK:STDOUT: 11: inst+23
  114. // CHECK:STDOUT: 12: inst+24
  115. // CHECK:STDOUT: block7:
  116. // CHECK:STDOUT: 0: inst+10
  117. // CHECK:STDOUT: 1: inst+11
  118. // CHECK:STDOUT: 2: inst+13
  119. // CHECK:STDOUT: block8:
  120. // CHECK:STDOUT: 0: inst+17
  121. // CHECK:STDOUT: 1: inst+19
  122. // CHECK:STDOUT: 2: inst+21
  123. // CHECK:STDOUT: block9:
  124. // CHECK:STDOUT: 0: inst+0
  125. // CHECK:STDOUT: 1: inst+9
  126. // CHECK:STDOUT: ...