semantics_builtin_kind.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #ifndef CARBON_TOOLCHAIN_SEMANTICS_SEMANTICS_BUILTIN_KIND_H_
  5. #define CARBON_TOOLCHAIN_SEMANTICS_SEMANTICS_BUILTIN_KIND_H_
  6. #include "toolchain/common/enum_base.h"
  7. namespace Carbon {
  8. CARBON_DEFINE_RAW_ENUM_CLASS(SemanticsBuiltinKind, uint8_t){
  9. #define CARBON_SEMANTICS_BUILTIN_KIND(Name) CARBON_RAW_ENUM_ENUMERATOR(Name)
  10. #include "toolchain/semantics/semantics_builtin_kind.def"
  11. };
  12. class SemanticsBuiltinKind : public CARBON_ENUM_BASE(SemanticsBuiltinKind) {
  13. public:
  14. #define CARBON_SEMANTICS_BUILTIN_KIND(Name) \
  15. CARBON_ENUM_CONSTANT_DECLARATION(Name)
  16. #include "toolchain/semantics/semantics_builtin_kind.def"
  17. // The count of enum values excluding Invalid.
  18. // NOLINTNEXTLINE(readability-identifier-naming)
  19. static const uint8_t ValidCount;
  20. // Support conversion to and from an int32_t for SemanticNode storage.
  21. using EnumBase::AsInt;
  22. using EnumBase::FromInt;
  23. };
  24. #define CARBON_SEMANTICS_BUILTIN_KIND(Name) \
  25. CARBON_ENUM_CONSTANT_DEFINITION(SemanticsBuiltinKind, Name)
  26. #include "toolchain/semantics/semantics_builtin_kind.def"
  27. constexpr uint8_t SemanticsBuiltinKind::ValidCount = Invalid.AsInt();
  28. // We expect the builtin kind to fit compactly into 8 bits.
  29. static_assert(sizeof(SemanticsBuiltinKind) == 1,
  30. "Kind objects include padding!");
  31. } // namespace Carbon
  32. #endif // CARBON_TOOLCHAIN_SEMANTICS_SEMANTICS_BUILTIN_KIND_H_