Files
carbon-lang/toolchain/sem_ir/builtin_inst_kind.def
T
Richard Smith 44fe65fbe5 Rename BigInt to IntLiteral. (#4476)
In preparation for changing the type of integer literals to
`IntLiteral`.
2024-11-02 02:09:10 +00:00

97 lines
4.0 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
//
// This is an X-macro header. It does not use `#include` guards, and instead is
// designed to be `#include`ed after the x-macro is defined in order for its
// inclusion to expand to the desired output. Macro definitions are cleaned up
// at the end of this file.
//
// Supported x-macros are:
// - CARBON_SEM_IR_BUILTIN_INST_KIND_NAME(Name)
// Used as a fallback if other macros are missing. Used directly by Invalid
// only, which is defined last.
// - CARBON_SEM_IR_BUILTIN_INST_KIND(Name, Label)
// Defines a non-Invalid builtin type. The label is used for stringifying
// types.
//
// This tree represents the subset relationship between these macros, where if a
// specific x-macro isn't defined, it'll fall back to the parent macro.
#if !(defined(CARBON_SEM_IR_BUILTIN_INST_KIND_NAME) || \
defined(CARBON_SEM_IR_BUILTIN_INST_KIND))
#error \
"Must define CARBON_SEM_IR_BUILTIN_INST_KIND family x-macros to use this file."
#endif
// If CARBON_SEM_IR_BUILTIN_INST_KIND_NAME is undefined, ignore calls.
#ifndef CARBON_SEM_IR_BUILTIN_INST_KIND_NAME
#define CARBON_SEM_IR_BUILTIN_INST_KIND_NAME(Name)
#endif
// If CARBON_SEM_IR_BUILTIN_INST_KIND is undefined, delegate calls to
// CARBON_SEM_IR_BUILTIN_INST_KIND_NAME.
#ifndef CARBON_SEM_IR_BUILTIN_INST_KIND
#define CARBON_SEM_IR_BUILTIN_INST_KIND(Name, ...) \
CARBON_SEM_IR_BUILTIN_INST_KIND_NAME(Name)
#endif
// Tracks expressions which are valid as types.
// This has a deliberately self-referential type.
CARBON_SEM_IR_BUILTIN_INST_KIND(TypeType, "type")
// Used when a semantic error has been detected, and a SemIR InstId is still
// required. For example, when there is a type checking issue, this will be used
// in the type_id. It's typically used as a cue that semantic checking doesn't
// need to issue further diagnostics.
CARBON_SEM_IR_BUILTIN_INST_KIND(Error, "<error>")
// Used for the type of patterns that do not match a fixed type.
CARBON_SEM_IR_BUILTIN_INST_KIND(AutoType, "auto")
// -----------------------------------------------------------------------------
// TODO: Below types are all placeholders. While the above may last, the below
// are expected to need to change in order to better reflect Carbon's design.
// Keeping distinct placeholders can help find usages for later fixes.
// -----------------------------------------------------------------------------
// The type of bool literals and branch conditions, bool.
CARBON_SEM_IR_BUILTIN_INST_KIND(BoolType, "bool")
// An arbitrary-precision integer type. This will eventually be used in the
// types of integer literals and as the parameter type of `Core.Int` and
// `Core.Float`. This type only provides compile-time operations, and is
// represented as an empty type at runtime.
CARBON_SEM_IR_BUILTIN_INST_KIND(IntLiteralType, "Core.IntLiteral")
// The type of integer values and integer literals, currently always i32.
CARBON_SEM_IR_BUILTIN_INST_KIND(IntType, "i32")
// The type of floating point values and real literals, currently always f64.
CARBON_SEM_IR_BUILTIN_INST_KIND(FloatType, "f64")
// The type of string values and String literals.
CARBON_SEM_IR_BUILTIN_INST_KIND(StringType, "String")
// The type of bound method values.
CARBON_SEM_IR_BUILTIN_INST_KIND(BoundMethodType, "<bound method>")
// The type of specific functions.
CARBON_SEM_IR_BUILTIN_INST_KIND(SpecificFunctionType, "<specific function>")
// The type of namespace and imported package names.
CARBON_SEM_IR_BUILTIN_INST_KIND(NamespaceType, "<namespace>")
// The type of witnesses.
CARBON_SEM_IR_BUILTIN_INST_KIND(WitnessType, "<witness>")
// The type of virtual function tables
CARBON_SEM_IR_BUILTIN_INST_KIND(VtableType, "<vtable>")
// Keep invalid last, so that we can use values as array indices without needing
// an invalid entry.
CARBON_SEM_IR_BUILTIN_INST_KIND_NAME(Invalid)
#undef CARBON_SEM_IR_BUILTIN_INST_KIND_NAME
#undef CARBON_SEM_IR_BUILTIN_INST_KIND