semantics_node_kind.def 5.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. // This is an X-macro header. It does not use `#include` guards, and instead is
  6. // designed to be `#include`ed after the x-macro is defined in order for its
  7. // inclusion to expand to the desired output. Macro definitions are cleaned up
  8. // at the end of this file.
  9. //
  10. // Exactly one of these macros should be defined before including this header:
  11. // - CARBON_SEMANTICS_NODE_KIND(Name)
  12. // Invoked for each kind of semantic node.
  13. // - CARBON_SEMANTICS_NODE_KIND_WITH_VALUE_KIND(Name, TypeFieldKind)
  14. // Invoked for each kind of semantic node, along with information about
  15. // whether the node produces a value, and if so, what kind of value.
  16. // - CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND(Name, TerminatorKind)
  17. // Invoked for each kind of semantic node, along with information about
  18. // whether the node is a terminator node.
  19. // - CARBON_SEMANTICS_NODE_KIND_WITH_IR_NAME(Name, IRName)
  20. // Invoked for each kind of semantic node, along with the name that is used
  21. // to denote this node in textual Semantics IR.
  22. #if defined(CARBON_SEMANTICS_NODE_KIND)
  23. #define CARBON_SEMANTICS_NODE_KIND_IMPL(Name, IRName, ValueKind, \
  24. TerminatorKind) \
  25. CARBON_SEMANTICS_NODE_KIND(Name)
  26. #elif defined(CARBON_SEMANTICS_NODE_KIND_WITH_VALUE_KIND)
  27. #define CARBON_SEMANTICS_NODE_KIND_IMPL(Name, IRName, ValueKind, \
  28. TerminatorKind) \
  29. CARBON_SEMANTICS_NODE_KIND_WITH_VALUE_KIND(Name, ValueKind)
  30. #elif defined(CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND)
  31. #define CARBON_SEMANTICS_NODE_KIND_IMPL(Name, IRName, ValueKind, \
  32. TerminatorKind) \
  33. CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND(Name, TerminatorKind)
  34. #elif defined(CARBON_SEMANTICS_NODE_KIND_WITH_IR_NAME)
  35. #define CARBON_SEMANTICS_NODE_KIND_IMPL(Name, IRName, ValueKind, \
  36. TerminatorKind) \
  37. CARBON_SEMANTICS_NODE_KIND_WITH_IR_NAME(Name, IRName)
  38. #else
  39. #error "Must define the x-macro to use this file."
  40. #endif
  41. CARBON_SEMANTICS_NODE_KIND_IMPL(Invalid, "invalid", None, NotTerminator)
  42. // A cross-reference between IRs.
  43. CARBON_SEMANTICS_NODE_KIND_IMPL(CrossReference, "xref", Typed, NotTerminator)
  44. CARBON_SEMANTICS_NODE_KIND_IMPL(AddressOf, "address_of", Typed, NotTerminator)
  45. CARBON_SEMANTICS_NODE_KIND_IMPL(Assign, "assign", None, NotTerminator)
  46. CARBON_SEMANTICS_NODE_KIND_IMPL(BinaryOperatorAdd, "add", Typed, NotTerminator)
  47. CARBON_SEMANTICS_NODE_KIND_IMPL(BindName, "bind_name", Typed, NotTerminator)
  48. CARBON_SEMANTICS_NODE_KIND_IMPL(BlockArg, "block_arg", Typed, NotTerminator)
  49. CARBON_SEMANTICS_NODE_KIND_IMPL(BoolLiteral, "bool_value", Typed, NotTerminator)
  50. CARBON_SEMANTICS_NODE_KIND_IMPL(Branch, "br", None, Terminator)
  51. CARBON_SEMANTICS_NODE_KIND_IMPL(BranchIf, "br", None, TerminatorSequence)
  52. CARBON_SEMANTICS_NODE_KIND_IMPL(BranchWithArg, "br", None, Terminator)
  53. CARBON_SEMANTICS_NODE_KIND_IMPL(Builtin, "builtin", Typed, NotTerminator)
  54. CARBON_SEMANTICS_NODE_KIND_IMPL(Call, "call", Typed, NotTerminator)
  55. CARBON_SEMANTICS_NODE_KIND_IMPL(ConstType, "const_type", Typed, NotTerminator)
  56. CARBON_SEMANTICS_NODE_KIND_IMPL(Dereference, "dereference", Typed,
  57. NotTerminator)
  58. CARBON_SEMANTICS_NODE_KIND_IMPL(FunctionDeclaration, "fn_decl", Untyped,
  59. NotTerminator)
  60. CARBON_SEMANTICS_NODE_KIND_IMPL(Index, "tuple_index", Typed, NotTerminator)
  61. CARBON_SEMANTICS_NODE_KIND_IMPL(IntegerLiteral, "int_value", Typed,
  62. NotTerminator)
  63. CARBON_SEMANTICS_NODE_KIND_IMPL(Namespace, "namespace", Untyped, NotTerminator)
  64. CARBON_SEMANTICS_NODE_KIND_IMPL(PointerType, "ptr_type", Typed, NotTerminator)
  65. CARBON_SEMANTICS_NODE_KIND_IMPL(RealLiteral, "real_value", Typed, NotTerminator)
  66. CARBON_SEMANTICS_NODE_KIND_IMPL(Return, "return", None, Terminator)
  67. CARBON_SEMANTICS_NODE_KIND_IMPL(ReturnExpression, "return", None, Terminator)
  68. CARBON_SEMANTICS_NODE_KIND_IMPL(StringLiteral, "string_value", Typed,
  69. NotTerminator)
  70. CARBON_SEMANTICS_NODE_KIND_IMPL(StructMemberAccess, "struct_access", Typed,
  71. NotTerminator)
  72. CARBON_SEMANTICS_NODE_KIND_IMPL(StructType, "struct_type", Typed, NotTerminator)
  73. CARBON_SEMANTICS_NODE_KIND_IMPL(StructTypeField, "struct_type_field", None,
  74. NotTerminator)
  75. CARBON_SEMANTICS_NODE_KIND_IMPL(StructValue, "struct_value", Typed,
  76. NotTerminator)
  77. CARBON_SEMANTICS_NODE_KIND_IMPL(StubReference, "stub_reference", Typed,
  78. NotTerminator)
  79. CARBON_SEMANTICS_NODE_KIND_IMPL(TupleType, "tuple_type", Typed, NotTerminator)
  80. CARBON_SEMANTICS_NODE_KIND_IMPL(TupleValue, "tuple_value", Typed, NotTerminator)
  81. CARBON_SEMANTICS_NODE_KIND_IMPL(UnaryOperatorNot, "not", Typed, NotTerminator)
  82. CARBON_SEMANTICS_NODE_KIND_IMPL(VarStorage, "var", Typed, NotTerminator)
  83. #undef CARBON_SEMANTICS_NODE_KIND
  84. #undef CARBON_SEMANTICS_NODE_KIND_WITH_VALUE_KIND
  85. #undef CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND
  86. #undef CARBON_SEMANTICS_NODE_KIND_WITH_IR_NAME
  87. #undef CARBON_SEMANTICS_NODE_KIND_IMPL