while.carbon 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. fn Cond() -> bool;
  7. fn F();
  8. fn G();
  9. fn H();
  10. fn While() {
  11. F();
  12. while (Cond()) {
  13. G();
  14. }
  15. H();
  16. }
  17. // CHECK:STDOUT: --- while.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %Cond: type = fn_type @Cond [template]
  21. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  22. // CHECK:STDOUT: %struct.1: Cond = struct_value () [template]
  23. // CHECK:STDOUT: %F: type = fn_type @F [template]
  24. // CHECK:STDOUT: %struct.2: F = struct_value () [template]
  25. // CHECK:STDOUT: %G: type = fn_type @G [template]
  26. // CHECK:STDOUT: %struct.3: G = struct_value () [template]
  27. // CHECK:STDOUT: %H: type = fn_type @H [template]
  28. // CHECK:STDOUT: %struct.4: H = struct_value () [template]
  29. // CHECK:STDOUT: %While: type = fn_type @While [template]
  30. // CHECK:STDOUT: %struct.5: While = struct_value () [template]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  35. // CHECK:STDOUT: .Core = %Core
  36. // CHECK:STDOUT: .Cond = %Cond.decl
  37. // CHECK:STDOUT: .F = %F.decl
  38. // CHECK:STDOUT: .G = %G.decl
  39. // CHECK:STDOUT: .H = %H.decl
  40. // CHECK:STDOUT: .While = %While.decl
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  43. // CHECK:STDOUT: %Cond.decl: Cond = fn_decl @Cond [template = constants.%struct.1] {
  44. // CHECK:STDOUT: @Cond.%return: ref bool = var <return slot>
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %F.decl: F = fn_decl @F [template = constants.%struct.2] {}
  47. // CHECK:STDOUT: %G.decl: G = fn_decl @G [template = constants.%struct.3] {}
  48. // CHECK:STDOUT: %H.decl: H = fn_decl @H [template = constants.%struct.4] {}
  49. // CHECK:STDOUT: %While.decl: While = fn_decl @While [template = constants.%struct.5] {}
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: fn @Cond() -> bool;
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: fn @F();
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: fn @G();
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: fn @H();
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: fn @While() {
  61. // CHECK:STDOUT: !entry:
  62. // CHECK:STDOUT: %F.ref: F = name_ref F, file.%F.decl [template = constants.%struct.2]
  63. // CHECK:STDOUT: %F.call: init () = call %F.ref()
  64. // CHECK:STDOUT: br !while.cond
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: !while.cond:
  67. // CHECK:STDOUT: %Cond.ref: Cond = name_ref Cond, file.%Cond.decl [template = constants.%struct.1]
  68. // CHECK:STDOUT: %Cond.call: init bool = call %Cond.ref()
  69. // CHECK:STDOUT: %.loc15_16.1: bool = value_of_initializer %Cond.call
  70. // CHECK:STDOUT: %.loc15_16.2: bool = converted %Cond.call, %.loc15_16.1
  71. // CHECK:STDOUT: if %.loc15_16.2 br !while.body else br !while.done
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: !while.body:
  74. // CHECK:STDOUT: %G.ref: G = name_ref G, file.%G.decl [template = constants.%struct.3]
  75. // CHECK:STDOUT: %G.call: init () = call %G.ref()
  76. // CHECK:STDOUT: br !while.cond
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: !while.done:
  79. // CHECK:STDOUT: %H.ref: H = name_ref H, file.%H.decl [template = constants.%struct.4]
  80. // CHECK:STDOUT: %H.call: init () = call %H.ref()
  81. // CHECK:STDOUT: return
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT: