bit_complement.carbon 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. // This file was generated from unary_op.carbon.tmpl. Run make_tests.sh to regenerate.
  7. // --- prelude.carbon
  8. package Core api;
  9. interface BitComplement {
  10. fn Op[self: Self]() -> Self;
  11. }
  12. // --- user.carbon
  13. package User api;
  14. import Core;
  15. class C {};
  16. impl C as Core.BitComplement {
  17. fn Op[self: C]() -> C {
  18. return {};
  19. }
  20. }
  21. fn TestOp(a: C) -> C {
  22. return ^a;
  23. }
  24. // CHECK:STDOUT: --- prelude.carbon
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: constants {
  27. // CHECK:STDOUT: %.1: type = interface_type @BitComplement [template]
  28. // CHECK:STDOUT: %.2: type = assoc_entity_type @BitComplement, <function> [template]
  29. // CHECK:STDOUT: %.3: <associated <function> in BitComplement> = assoc_entity element0, @BitComplement.%Op [template]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: file {
  33. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  34. // CHECK:STDOUT: .BitComplement = %BitComplement.decl
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: %BitComplement.decl: type = interface_decl @BitComplement [template = constants.%.1] {}
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: interface @BitComplement {
  40. // CHECK:STDOUT: %Self: BitComplement = bind_symbolic_name Self [symbolic]
  41. // CHECK:STDOUT: %Op: <function> = fn_decl @Op [template] {
  42. // CHECK:STDOUT: %Self.ref.loc5_15: BitComplement = name_ref Self, %Self [symbolic = %Self]
  43. // CHECK:STDOUT: %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = %Self]
  44. // CHECK:STDOUT: %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = %Self]
  45. // CHECK:STDOUT: %self.loc5_9.1: Self = param self
  46. // CHECK:STDOUT: %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
  47. // CHECK:STDOUT: %Self.ref.loc5_26: BitComplement = name_ref Self, %Self [symbolic = %Self]
  48. // CHECK:STDOUT: %.loc5_26.1: type = facet_type_access %Self.ref.loc5_26 [symbolic = %Self]
  49. // CHECK:STDOUT: %.loc5_26.2: type = converted %Self.ref.loc5_26, %.loc5_26.1 [symbolic = %Self]
  50. // CHECK:STDOUT: %return.var: ref Self = var <return slot>
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %.loc5_30: <associated <function> in BitComplement> = assoc_entity element0, %Op [template = constants.%.3]
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: !members:
  55. // CHECK:STDOUT: .Self = %Self
  56. // CHECK:STDOUT: .Op = %.loc5_30
  57. // CHECK:STDOUT: witness = (%Op)
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: fn @Op[@BitComplement.%self.loc5_9.2: Self]() -> Self;
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: --- user.carbon
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: constants {
  65. // CHECK:STDOUT: %C: type = class_type @C [template]
  66. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  67. // CHECK:STDOUT: %.2: type = interface_type @BitComplement [template]
  68. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  69. // CHECK:STDOUT: %.4: type = ptr_type {} [template]
  70. // CHECK:STDOUT: %.5: C = struct_value () [template]
  71. // CHECK:STDOUT: %.6: <witness> = interface_witness (@impl.%Op) [template]
  72. // CHECK:STDOUT: %.7: type = assoc_entity_type @BitComplement, <function> [template]
  73. // CHECK:STDOUT: %.8: <associated <function> in BitComplement> = assoc_entity element0, file.%import_ref.6 [template]
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: file {
  77. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  78. // CHECK:STDOUT: .Core = %Core
  79. // CHECK:STDOUT: .C = %C.decl
  80. // CHECK:STDOUT: .TestOp = %TestOp
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  83. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  84. // CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, used [template = constants.%.2]
  85. // CHECK:STDOUT: %import_ref.2: <associated <function> in BitComplement> = import_ref ir1, inst+15, used [template = constants.%.8]
  86. // CHECK:STDOUT: %import_ref.3 = import_ref ir1, inst+3, unused
  87. // CHECK:STDOUT: %import_ref.4: <function> = import_ref ir1, inst+13, used [template = imports.%Op]
  88. // CHECK:STDOUT: impl_decl @impl {
  89. // CHECK:STDOUT: %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
  90. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
  91. // CHECK:STDOUT: %BitComplement.decl: invalid = interface_decl @BitComplement [template = constants.%.2] {}
  92. // CHECK:STDOUT: %BitComplement.ref: type = name_ref BitComplement, %import_ref.1 [template = constants.%.2]
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: %TestOp: <function> = fn_decl @TestOp [template] {
  95. // CHECK:STDOUT: %C.ref.loc14_14: type = name_ref C, %C.decl [template = constants.%C]
  96. // CHECK:STDOUT: %a.loc14_11.1: C = param a
  97. // CHECK:STDOUT: @TestOp.%a: C = bind_name a, %a.loc14_11.1
  98. // CHECK:STDOUT: %C.ref.loc14_20: type = name_ref C, %C.decl [template = constants.%C]
  99. // CHECK:STDOUT: @TestOp.%return: ref C = var <return slot>
  100. // CHECK:STDOUT: }
  101. // CHECK:STDOUT: %import_ref.5: type = import_ref ir1, inst+1, used [template = constants.%.2]
  102. // CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+13, unused
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: interface @BitComplement {
  106. // CHECK:STDOUT: !members:
  107. // CHECK:STDOUT: .Op = file.%import_ref.2
  108. // CHECK:STDOUT: .Self = file.%import_ref.3
  109. // CHECK:STDOUT: witness = (file.%import_ref.4)
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: impl @impl: C as BitComplement {
  113. // CHECK:STDOUT: %Op: <function> = fn_decl @Op.1 [template] {
  114. // CHECK:STDOUT: %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
  115. // CHECK:STDOUT: %self.loc9_9.1: C = param self
  116. // CHECK:STDOUT: %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
  117. // CHECK:STDOUT: %C.ref.loc9_23: type = name_ref C, file.%C.decl [template = constants.%C]
  118. // CHECK:STDOUT: %return.var: ref C = var <return slot>
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT: %.1: <witness> = interface_witness (%Op) [template = constants.%.6]
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: !members:
  123. // CHECK:STDOUT: .Op = %Op
  124. // CHECK:STDOUT: witness = %.1
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: class @C {
  128. // CHECK:STDOUT: !members:
  129. // CHECK:STDOUT: .Self = constants.%C
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT:
  132. // CHECK:STDOUT: fn @Op.1[@impl.%self.loc9_9.2: C]() -> @impl.%return.var: C {
  133. // CHECK:STDOUT: !entry:
  134. // CHECK:STDOUT: %.loc10_13.1: {} = struct_literal ()
  135. // CHECK:STDOUT: %.loc10_13.2: init C = class_init (), @impl.%return.var [template = constants.%.5]
  136. // CHECK:STDOUT: %.loc10_13.3: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%.5]
  137. // CHECK:STDOUT: return %.loc10_13.3
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: fn @Op.2[%self: Self]() -> Self;
  141. // CHECK:STDOUT:
  142. // CHECK:STDOUT: fn @TestOp(%a: C) -> %return: C {
  143. // CHECK:STDOUT: !entry:
  144. // CHECK:STDOUT: %a.ref: C = name_ref a, %a
  145. // CHECK:STDOUT: %.1: <function> = interface_witness_access @impl.%.1, element0 [template = @impl.%Op]
  146. // CHECK:STDOUT: %.loc15_10.1: <bound method> = bound_method %a.ref, %.1
  147. // CHECK:STDOUT: %.loc14: ref C = splice_block %return {}
  148. // CHECK:STDOUT: %.loc15_10.2: init C = call %.loc15_10.1(%a.ref) to %.loc14
  149. // CHECK:STDOUT: return %.loc15_10.2
  150. // CHECK:STDOUT: }
  151. // CHECK:STDOUT: