node_kind.def 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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(ArrayIndex, "array_index", Typed, NotTerminator)
  46. CARBON_SEMANTICS_NODE_KIND_IMPL(ArrayType, "array_type", Typed, NotTerminator)
  47. CARBON_SEMANTICS_NODE_KIND_IMPL(ArrayValue, "array_value", Typed, NotTerminator)
  48. CARBON_SEMANTICS_NODE_KIND_IMPL(Assign, "assign", None, NotTerminator)
  49. CARBON_SEMANTICS_NODE_KIND_IMPL(BinaryOperatorAdd, "add", Typed, NotTerminator)
  50. CARBON_SEMANTICS_NODE_KIND_IMPL(BindValue, "bind_value", Typed, NotTerminator)
  51. CARBON_SEMANTICS_NODE_KIND_IMPL(BlockArg, "block_arg", Typed, NotTerminator)
  52. CARBON_SEMANTICS_NODE_KIND_IMPL(BoolLiteral, "bool_literal", Typed, NotTerminator)
  53. CARBON_SEMANTICS_NODE_KIND_IMPL(Branch, "br", None, Terminator)
  54. CARBON_SEMANTICS_NODE_KIND_IMPL(BranchIf, "br", None, TerminatorSequence)
  55. CARBON_SEMANTICS_NODE_KIND_IMPL(BranchWithArg, "br", None, Terminator)
  56. CARBON_SEMANTICS_NODE_KIND_IMPL(Builtin, "builtin", Typed, NotTerminator)
  57. CARBON_SEMANTICS_NODE_KIND_IMPL(Call, "call", Typed, NotTerminator)
  58. CARBON_SEMANTICS_NODE_KIND_IMPL(ConstType, "const_type", Typed, NotTerminator)
  59. CARBON_SEMANTICS_NODE_KIND_IMPL(Dereference, "dereference", Typed,
  60. NotTerminator)
  61. CARBON_SEMANTICS_NODE_KIND_IMPL(FunctionDeclaration, "fn_decl", Untyped,
  62. NotTerminator)
  63. CARBON_SEMANTICS_NODE_KIND_IMPL(IntegerLiteral, "int_literal", Typed,
  64. NotTerminator)
  65. CARBON_SEMANTICS_NODE_KIND_IMPL(Namespace, "namespace", Untyped, NotTerminator)
  66. CARBON_SEMANTICS_NODE_KIND_IMPL(NoOp, "no_op", None, NotTerminator)
  67. CARBON_SEMANTICS_NODE_KIND_IMPL(Parameter, "parameter", Typed, NotTerminator)
  68. CARBON_SEMANTICS_NODE_KIND_IMPL(PointerType, "ptr_type", Typed, NotTerminator)
  69. CARBON_SEMANTICS_NODE_KIND_IMPL(RealLiteral, "real_literal", Typed,
  70. NotTerminator)
  71. CARBON_SEMANTICS_NODE_KIND_IMPL(Return, "return", None, Terminator)
  72. CARBON_SEMANTICS_NODE_KIND_IMPL(ReturnExpression, "return", None, Terminator)
  73. CARBON_SEMANTICS_NODE_KIND_IMPL(StringLiteral, "string_literal", Typed,
  74. NotTerminator)
  75. CARBON_SEMANTICS_NODE_KIND_IMPL(StructAccess, "struct_access", Typed,
  76. NotTerminator)
  77. CARBON_SEMANTICS_NODE_KIND_IMPL(StructType, "struct_type", Typed, NotTerminator)
  78. CARBON_SEMANTICS_NODE_KIND_IMPL(StructTypeField, "struct_type_field", None,
  79. NotTerminator)
  80. CARBON_SEMANTICS_NODE_KIND_IMPL(StructValue, "struct_value", Typed,
  81. NotTerminator)
  82. CARBON_SEMANTICS_NODE_KIND_IMPL(StubReference, "stub_reference", Typed,
  83. NotTerminator)
  84. CARBON_SEMANTICS_NODE_KIND_IMPL(Temporary, "temporary", Typed, NotTerminator)
  85. CARBON_SEMANTICS_NODE_KIND_IMPL(TemporaryStorage, "temporary_storage", Typed,
  86. NotTerminator)
  87. CARBON_SEMANTICS_NODE_KIND_IMPL(TupleIndex, "tuple_index", Typed, NotTerminator)
  88. CARBON_SEMANTICS_NODE_KIND_IMPL(TupleType, "tuple_type", Typed, NotTerminator)
  89. CARBON_SEMANTICS_NODE_KIND_IMPL(TupleValue, "tuple_value", Typed, NotTerminator)
  90. CARBON_SEMANTICS_NODE_KIND_IMPL(UnaryOperatorNot, "not", Typed, NotTerminator)
  91. CARBON_SEMANTICS_NODE_KIND_IMPL(VarStorage, "var", Typed, NotTerminator)
  92. #undef CARBON_SEMANTICS_NODE_KIND
  93. #undef CARBON_SEMANTICS_NODE_KIND_WITH_VALUE_KIND
  94. #undef CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND
  95. #undef CARBON_SEMANTICS_NODE_KIND_WITH_IR_NAME
  96. #undef CARBON_SEMANTICS_NODE_KIND_IMPL