bit_complement.carbon 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. package User;
  8. class C {};
  9. impl C as Core.BitComplement {
  10. fn Op[self: C]() -> C {
  11. return {};
  12. }
  13. }
  14. fn TestOp(a: C) -> C {
  15. return ^a;
  16. }
  17. // CHECK:STDOUT: --- bit_complement.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %C: type = class_type @C [template]
  21. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  22. // CHECK:STDOUT: %.2: type = interface_type @BitComplement [template]
  23. // CHECK:STDOUT: %Self: BitComplement = bind_symbolic_name Self 0 [symbolic]
  24. // CHECK:STDOUT: %Op.1: type = fn_type @Op.1 [template]
  25. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  26. // CHECK:STDOUT: %struct.1: Op = struct_value () [template]
  27. // CHECK:STDOUT: %Op.2: type = fn_type @Op.2 [template]
  28. // CHECK:STDOUT: %struct.2: Op = struct_value () [template]
  29. // CHECK:STDOUT: %.4: <witness> = interface_witness (%struct.1) [template]
  30. // CHECK:STDOUT: %.5: type = ptr_type {} [template]
  31. // CHECK:STDOUT: %struct.3: C = struct_value () [template]
  32. // CHECK:STDOUT: %TestOp: type = fn_type @TestOp [template]
  33. // CHECK:STDOUT: %struct.4: TestOp = struct_value () [template]
  34. // CHECK:STDOUT: %.6: type = assoc_entity_type @BitComplement, Op [template]
  35. // CHECK:STDOUT: %.7: <associated Op in BitComplement> = assoc_entity element0, file.%import_ref.6 [template]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: file {
  39. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  40. // CHECK:STDOUT: .Core = %Core
  41. // CHECK:STDOUT: .C = %C.decl
  42. // CHECK:STDOUT: .TestOp = %TestOp.decl
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  45. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  46. // CHECK:STDOUT: %import_ref.1: type = import_ref ir5, inst+1, loaded [template = constants.%.2]
  47. // CHECK:STDOUT: %import_ref.2 = import_ref ir5, inst+3, unloaded
  48. // CHECK:STDOUT: %import_ref.3: <associated Op in BitComplement> = import_ref ir5, inst+19, loaded [template = constants.%.7]
  49. // CHECK:STDOUT: %import_ref.4: Op = import_ref ir5, inst+14, loaded [template = constants.%struct.2]
  50. // CHECK:STDOUT: impl_decl @impl {
  51. // CHECK:STDOUT: %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
  52. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
  53. // CHECK:STDOUT: %BitComplement.ref: type = name_ref BitComplement, %import_ref.1 [template = constants.%.2]
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.4] {
  56. // CHECK:STDOUT: %C.ref.loc19_14: type = name_ref C, %C.decl [template = constants.%C]
  57. // CHECK:STDOUT: %a.loc19_11.1: C = param a
  58. // CHECK:STDOUT: @TestOp.%a: C = bind_name a, %a.loc19_11.1
  59. // CHECK:STDOUT: %C.ref.loc19_20: type = name_ref C, %C.decl [template = constants.%C]
  60. // CHECK:STDOUT: @TestOp.%return: ref C = var <return slot>
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: %import_ref.5: type = import_ref ir5, inst+1, loaded [template = constants.%.2]
  63. // CHECK:STDOUT: %import_ref.6 = import_ref ir5, inst+14, unloaded
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: interface @BitComplement {
  67. // CHECK:STDOUT: !members:
  68. // CHECK:STDOUT: .Self = file.%import_ref.2
  69. // CHECK:STDOUT: .Op = file.%import_ref.3
  70. // CHECK:STDOUT: witness = (file.%import_ref.4)
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: impl @impl: C as BitComplement {
  74. // CHECK:STDOUT: %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
  75. // CHECK:STDOUT: %C.ref.loc14_15: type = name_ref C, file.%C.decl [template = constants.%C]
  76. // CHECK:STDOUT: %self.loc14_9.1: C = param self
  77. // CHECK:STDOUT: %self.loc14_9.2: C = bind_name self, %self.loc14_9.1
  78. // CHECK:STDOUT: %C.ref.loc14_23: type = name_ref C, file.%C.decl [template = constants.%C]
  79. // CHECK:STDOUT: %return.var: ref C = var <return slot>
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT: %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
  82. // CHECK:STDOUT:
  83. // CHECK:STDOUT: !members:
  84. // CHECK:STDOUT: .Op = %Op.decl
  85. // CHECK:STDOUT: witness = %.1
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: class @C {
  89. // CHECK:STDOUT: !members:
  90. // CHECK:STDOUT: .Self = constants.%C
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT:
  93. // CHECK:STDOUT: fn @Op.1[@impl.%self.loc14_9.2: C]() -> @impl.%return.var: C {
  94. // CHECK:STDOUT: !entry:
  95. // CHECK:STDOUT: %.loc15_13.1: {} = struct_literal ()
  96. // CHECK:STDOUT: %.loc15_13.2: init C = class_init (), @impl.%return.var [template = constants.%struct.3]
  97. // CHECK:STDOUT: %.loc15_14: init C = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%struct.3]
  98. // CHECK:STDOUT: return %.loc15_14 to @impl.%return.var
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: fn @Op.2[%self: Self]() -> Self;
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: fn @TestOp(%a: C) -> %return: C {
  104. // CHECK:STDOUT: !entry:
  105. // CHECK:STDOUT: %a.ref: C = name_ref a, %a
  106. // CHECK:STDOUT: %.1: Op = interface_witness_access @impl.%.1, element0 [template = constants.%struct.1]
  107. // CHECK:STDOUT: %.loc20: <bound method> = bound_method %a.ref, %.1
  108. // CHECK:STDOUT: %.loc19: ref C = splice_block %return {}
  109. // CHECK:STDOUT: %Op.call: init C = call %.loc20(%a.ref) to %.loc19
  110. // CHECK:STDOUT: return %Op.call to %return
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT: