core_interface.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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_SEM_IR_CORE_INTERFACE_H_
  5. #define CARBON_TOOLCHAIN_SEM_IR_CORE_INTERFACE_H_
  6. #include <cstdint>
  7. #include "common/enum_base.h"
  8. #include "llvm/ADT/ArrayRef.h"
  9. namespace Carbon::SemIR {
  10. CARBON_DEFINE_RAW_ENUM_CLASS(CoreInterface, std::uint8_t) {
  11. #define CARBON_SEM_IR_CORE_INTERFACE_KIND(Name) CARBON_RAW_ENUM_ENUMERATOR(Name)
  12. #include "toolchain/sem_ir/core_interface_kind.def"
  13. };
  14. // Significant interfaces in `Core` which correspond to language features and
  15. // can have custom witnesses.
  16. class CoreInterface : public CARBON_ENUM_BASE(CoreInterface) {
  17. public:
  18. #define CARBON_SEM_IR_CORE_INTERFACE_KIND(Name) CARBON_ENUM_CONSTANT_DECL(Name)
  19. #include "toolchain/sem_ir/core_interface_kind.def"
  20. static const llvm::ArrayRef<CoreInterface> CoreInterfaces;
  21. using EnumBase::AsInt;
  22. using EnumBase::EnumBase;
  23. private:
  24. static const CoreInterface CoreInterfacesStorage[];
  25. static const llvm::StringLiteral Spelling[];
  26. };
  27. #define CARBON_SEM_IR_CORE_INTERFACE_KIND(Name) \
  28. CARBON_ENUM_CONSTANT_DEFINITION(CoreInterface, Name)
  29. #include "toolchain/sem_ir/core_interface_kind.def"
  30. inline constexpr CoreInterface CoreInterface::CoreInterfacesStorage[] = {
  31. #define CARBON_SEM_IR_CORE_INTERFACE_KIND(Name) CoreInterface::Name,
  32. #include "toolchain/sem_ir/core_interface_kind.def"
  33. };
  34. inline constexpr llvm::ArrayRef<CoreInterface> CoreInterface::CoreInterfaces =
  35. CoreInterfacesStorage;
  36. } // namespace Carbon::SemIR
  37. #endif // CARBON_TOOLCHAIN_SEM_IR_CORE_INTERFACE_H_