bit_complement.carbon 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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: %Self: BitComplement = bind_symbolic_name Self 0 [symbolic]
  29. // CHECK:STDOUT: %Op: type = fn_type @Op [template]
  30. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  31. // CHECK:STDOUT: %struct: Op = struct_value () [template]
  32. // CHECK:STDOUT: %.3: type = assoc_entity_type @BitComplement, Op [template]
  33. // CHECK:STDOUT: %.4: <associated Op in BitComplement> = assoc_entity element0, @BitComplement.%Op.decl [template]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  38. // CHECK:STDOUT: .BitComplement = %BitComplement.decl
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %BitComplement.decl: type = interface_decl @BitComplement [template = constants.%.1] {}
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: interface @BitComplement {
  44. // CHECK:STDOUT: %Self: BitComplement = bind_symbolic_name Self 0 [symbolic = constants.%Self]
  45. // CHECK:STDOUT: %Op.decl: Op = fn_decl @Op [template = constants.%struct] {
  46. // CHECK:STDOUT: %Self.ref.loc5_15: BitComplement = name_ref Self, %Self [symbolic = constants.%Self]
  47. // CHECK:STDOUT: %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self]
  48. // CHECK:STDOUT: %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self]
  49. // CHECK:STDOUT: %self.loc5_9.1: Self = param self
  50. // CHECK:STDOUT: %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
  51. // CHECK:STDOUT: %Self.ref.loc5_26: BitComplement = name_ref Self, %Self [symbolic = constants.%Self]
  52. // CHECK:STDOUT: %.loc5_26.1: type = facet_type_access %Self.ref.loc5_26 [symbolic = constants.%Self]
  53. // CHECK:STDOUT: %.loc5_26.2: type = converted %Self.ref.loc5_26, %.loc5_26.1 [symbolic = constants.%Self]
  54. // CHECK:STDOUT: %return.var: ref Self = var <return slot>
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: %.loc5_30: <associated Op in BitComplement> = assoc_entity element0, %Op.decl [template = constants.%.4]
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: !members:
  59. // CHECK:STDOUT: .Self = %Self
  60. // CHECK:STDOUT: .Op = %.loc5_30
  61. // CHECK:STDOUT: witness = (%Op.decl)
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: fn @Op[@BitComplement.%self.loc5_9.2: Self]() -> Self;
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: --- user.carbon
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: constants {
  69. // CHECK:STDOUT: %C: type = class_type @C [template]
  70. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  71. // CHECK:STDOUT: %.2: type = interface_type @BitComplement [template]
  72. // CHECK:STDOUT: %Self: BitComplement = bind_symbolic_name Self 0 [symbolic]
  73. // CHECK:STDOUT: %Op.1: type = fn_type @Op.1 [template]
  74. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  75. // CHECK:STDOUT: %struct.1: Op = struct_value () [template]
  76. // CHECK:STDOUT: %Op.2: type = fn_type @Op.2 [template]
  77. // CHECK:STDOUT: %struct.2: Op = struct_value () [template]
  78. // CHECK:STDOUT: %.4: <witness> = interface_witness (%struct.1) [template]
  79. // CHECK:STDOUT: %.5: type = ptr_type {} [template]
  80. // CHECK:STDOUT: %struct.3: C = struct_value () [template]
  81. // CHECK:STDOUT: %TestOp: type = fn_type @TestOp [template]
  82. // CHECK:STDOUT: %struct.4: TestOp = struct_value () [template]
  83. // CHECK:STDOUT: %.6: type = assoc_entity_type @BitComplement, Op [template]
  84. // CHECK:STDOUT: %.7: <associated Op in BitComplement> = assoc_entity element0, file.%import_ref.6 [template]
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: file {
  88. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  89. // CHECK:STDOUT: .Core = %Core
  90. // CHECK:STDOUT: .C = %C.decl
  91. // CHECK:STDOUT: .TestOp = %TestOp.decl
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  94. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  95. // CHECK:STDOUT: %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
  96. // CHECK:STDOUT: %import_ref.2: <associated Op in BitComplement> = import_ref ir2, inst+19, loaded [template = constants.%.7]
  97. // CHECK:STDOUT: %import_ref.3 = import_ref ir2, inst+3, unloaded
  98. // CHECK:STDOUT: %import_ref.4: Op = import_ref ir2, inst+14, loaded [template = constants.%struct.2]
  99. // CHECK:STDOUT: impl_decl @impl {
  100. // CHECK:STDOUT: %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
  101. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
  102. // CHECK:STDOUT: %BitComplement.decl: type = interface_decl @BitComplement [template = constants.%.2] {}
  103. // CHECK:STDOUT: %BitComplement.ref: type = name_ref BitComplement, %import_ref.1 [template = constants.%.2]
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT: %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.4] {
  106. // CHECK:STDOUT: %C.ref.loc14_14: type = name_ref C, %C.decl [template = constants.%C]
  107. // CHECK:STDOUT: %a.loc14_11.1: C = param a
  108. // CHECK:STDOUT: @TestOp.%a: C = bind_name a, %a.loc14_11.1
  109. // CHECK:STDOUT: %C.ref.loc14_20: type = name_ref C, %C.decl [template = constants.%C]
  110. // CHECK:STDOUT: @TestOp.%return: ref C = var <return slot>
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT: %import_ref.5: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
  113. // CHECK:STDOUT: %import_ref.6 = import_ref ir2, inst+14, unloaded
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT:
  116. // CHECK:STDOUT: interface @BitComplement {
  117. // CHECK:STDOUT: !members:
  118. // CHECK:STDOUT: .Op = file.%import_ref.2
  119. // CHECK:STDOUT: .Self = file.%import_ref.3
  120. // CHECK:STDOUT: witness = (file.%import_ref.4)
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: impl @impl: C as BitComplement {
  124. // CHECK:STDOUT: %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
  125. // CHECK:STDOUT: %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
  126. // CHECK:STDOUT: %self.loc9_9.1: C = param self
  127. // CHECK:STDOUT: %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
  128. // CHECK:STDOUT: %C.ref.loc9_23: type = name_ref C, file.%C.decl [template = constants.%C]
  129. // CHECK:STDOUT: %return.var: ref C = var <return slot>
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT: %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
  132. // CHECK:STDOUT:
  133. // CHECK:STDOUT: !members:
  134. // CHECK:STDOUT: .Op = %Op.decl
  135. // CHECK:STDOUT: witness = %.1
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: class @C {
  139. // CHECK:STDOUT: !members:
  140. // CHECK:STDOUT: .Self = constants.%C
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT:
  143. // CHECK:STDOUT: fn @Op.1[@impl.%self.loc9_9.2: C]() -> @impl.%return.var: C {
  144. // CHECK:STDOUT: !entry:
  145. // CHECK:STDOUT: %.loc10_13.1: {} = struct_literal ()
  146. // CHECK:STDOUT: %.loc10_13.2: init C = class_init (), @impl.%return.var [template = constants.%struct.3]
  147. // CHECK:STDOUT: %.loc10_14: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.3]
  148. // CHECK:STDOUT: return %.loc10_14 to @impl.%return.var
  149. // CHECK:STDOUT: }
  150. // CHECK:STDOUT:
  151. // CHECK:STDOUT: fn @Op.2[%self: Self]() -> Self;
  152. // CHECK:STDOUT:
  153. // CHECK:STDOUT: fn @TestOp(%a: C) -> %return: C {
  154. // CHECK:STDOUT: !entry:
  155. // CHECK:STDOUT: %a.ref: C = name_ref a, %a
  156. // CHECK:STDOUT: %.1: Op = interface_witness_access @impl.%.1, element0 [template = constants.%struct.1]
  157. // CHECK:STDOUT: %.loc15: <bound method> = bound_method %a.ref, %.1
  158. // CHECK:STDOUT: %.loc14: ref C = splice_block %return {}
  159. // CHECK:STDOUT: %Op.call: init C = call %.loc15(%a.ref) to %.loc14
  160. // CHECK:STDOUT: return %Op.call to %return
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT: