mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add documentation for the three most common kinds of instruction operand (#4594)
Co-authored-by: Carbon Infra Bot <carbon-external-infra@google.com> Co-authored-by: Dana Jansens <danakj@orodu.net>
This commit is contained in:
co-authored by
Carbon Infra Bot
Dana Jansens
parent
4d3b962029
commit
6468450c95
+23
-1
@@ -13,6 +13,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
- [Overview](#overview)
|
||||
- [Postorder processing](#postorder-processing)
|
||||
- [Key IR concepts](#key-ir-concepts)
|
||||
- [Instruction operands](#instruction-operands)
|
||||
- [Parameters and arguments](#parameters-and-arguments)
|
||||
- [SemIR textual format](#semir-textual-format)
|
||||
- [Raw form](#raw-form)
|
||||
@@ -74,7 +75,7 @@ interprets to build the `SemIR`.
|
||||
|
||||
A `SemIR::Inst` is the basic building block that represents a simple
|
||||
instruction, such as an operator or declaring a literal. For each kind of
|
||||
instruction, a typedef for that specific kind of instruction is provided in the
|
||||
instruction, a struct for that specific kind of instruction is provided in the
|
||||
`SemIR` namespace. For example, `SemIR::Assign` represents an assignment
|
||||
instruction, and `SemIR::PointerType` represents a pointer type instruction.
|
||||
|
||||
@@ -108,6 +109,27 @@ facet type `type`. We will also have built-in functions which would need to form
|
||||
the implementation of some library types, such as `i32`. Built-ins are in a
|
||||
stable index across `SemIR` instances.
|
||||
|
||||
### Instruction operands
|
||||
|
||||
The kind-specific members on a typed instruction struct can be of any type
|
||||
listed in the `SemIR::IdKind` enumeration defined in
|
||||
[sem_ir/id_kind.h](/toolchain/sem_ir/id_kind.h). The most commonly used kinds
|
||||
refer to other instructions:
|
||||
|
||||
- `SemIR::InstId`: Refers to a specific instance of an instruction. For
|
||||
example, this should be used if the operand may have side-effects or a
|
||||
meaningful location.
|
||||
- `SemIR::ConstantId`: An abstract reference to a known constant value. This
|
||||
should be used instead of `InstId` if you care only about the identity of
|
||||
the value and not how it was formed.
|
||||
- `SemIR::TypeId`: An abstract reference to a known constant value of type
|
||||
`type`. This should be used instead of `ConstantId` if you know that the
|
||||
type of the constant value is always `type` (or the value is the "error"
|
||||
constant, whose type is also the "error" constant).
|
||||
|
||||
Other ID types are used for more specialized purposes. Refer to the class
|
||||
documentation for the ID type for more details.
|
||||
|
||||
### Parameters and arguments
|
||||
|
||||
Parameters and arguments will be stored as two `SemIR::InstBlock`s each. The
|
||||
|
||||
Reference in New Issue
Block a user