| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- // 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")
- // 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
|