Files
carbon-lang/toolchain/sem_ir/core_interface.h
T
Christopher Di Bella f0c4b37c63 adds a field to SemIR::Interface to indicate whether it is a core interface (#7091)
The existing `GetCoreInterface` has linear-time complexity and adds more
than the search criteria to the `CoreInterfaceCache`. Adding a new field
to `Interface` changes this operation when building packages other than
`Core`, as this should only be set for the core library.
2026-04-24 17:33:23 +00:00

50 lines
1.7 KiB
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef CARBON_TOOLCHAIN_SEM_IR_CORE_INTERFACE_H_
#define CARBON_TOOLCHAIN_SEM_IR_CORE_INTERFACE_H_
#include <cstdint>
#include "common/enum_base.h"
#include "llvm/ADT/ArrayRef.h"
namespace Carbon::SemIR {
CARBON_DEFINE_RAW_ENUM_CLASS(CoreInterface, std::uint8_t) {
#define CARBON_SEM_IR_CORE_INTERFACE_KIND(Name) CARBON_RAW_ENUM_ENUMERATOR(Name)
#include "toolchain/sem_ir/core_interface_kind.def"
};
// Significant interfaces in `Core` which correspond to language features and
// can have custom witnesses.
class CoreInterface : public CARBON_ENUM_BASE(CoreInterface) {
public:
#define CARBON_SEM_IR_CORE_INTERFACE_KIND(Name) CARBON_ENUM_CONSTANT_DECL(Name)
#include "toolchain/sem_ir/core_interface_kind.def"
static const llvm::ArrayRef<CoreInterface> CoreInterfaces;
using EnumBase::AsInt;
using EnumBase::EnumBase;
private:
static const CoreInterface CoreInterfacesStorage[];
static const llvm::StringLiteral Spelling[];
};
#define CARBON_SEM_IR_CORE_INTERFACE_KIND(Name) \
CARBON_ENUM_CONSTANT_DEFINITION(CoreInterface, Name)
#include "toolchain/sem_ir/core_interface_kind.def"
inline constexpr CoreInterface CoreInterface::CoreInterfacesStorage[] = {
#define CARBON_SEM_IR_CORE_INTERFACE_KIND(Name) CoreInterface::Name,
#include "toolchain/sem_ir/core_interface_kind.def"
};
inline constexpr llvm::ArrayRef<CoreInterface> CoreInterface::CoreInterfaces =
CoreInterfacesStorage;
} // namespace Carbon::SemIR
#endif // CARBON_TOOLCHAIN_SEM_IR_CORE_INTERFACE_H_