builtin_function_kind.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_BUILTIN_FUNCTION_KIND_H_
  5. #define CARBON_TOOLCHAIN_SEM_IR_BUILTIN_FUNCTION_KIND_H_
  6. #include <cstdint>
  7. #include "common/enum_base.h"
  8. #include "toolchain/sem_ir/ids.h"
  9. namespace Carbon::SemIR {
  10. class File;
  11. CARBON_DEFINE_RAW_ENUM_CLASS(BuiltinFunctionKind, std::uint8_t) {
  12. #define CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(Name) \
  13. CARBON_RAW_ENUM_ENUMERATOR(Name)
  14. #include "toolchain/sem_ir/builtin_function_kind.def"
  15. };
  16. // A kind of builtin function.
  17. class BuiltinFunctionKind : public CARBON_ENUM_BASE(BuiltinFunctionKind) {
  18. public:
  19. #define CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(Name) \
  20. CARBON_ENUM_CONSTANT_DECL(Name)
  21. #include "toolchain/sem_ir/builtin_function_kind.def"
  22. // Returns the builtin function kind with the given name, or None if the name
  23. // is unknown.
  24. static auto ForBuiltinName(llvm::StringRef name) -> BuiltinFunctionKind;
  25. // Determines whether this builtin function kind can have the specified
  26. // function type.
  27. auto IsValidType(const File& sem_ir, llvm::ArrayRef<TypeId> arg_types,
  28. TypeId return_type) const -> bool;
  29. // Returns whether this is a compile-time-only function.
  30. auto IsCompTimeOnly(const File& sem_ir, llvm::ArrayRef<InstId> arg_ids,
  31. TypeId return_type_id) const -> bool;
  32. };
  33. #define CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(Name) \
  34. CARBON_ENUM_CONSTANT_DEFINITION(BuiltinFunctionKind, Name)
  35. #include "toolchain/sem_ir/builtin_function_kind.def"
  36. } // namespace Carbon::SemIR
  37. #endif // CARBON_TOOLCHAIN_SEM_IR_BUILTIN_FUNCTION_KIND_H_