mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-21 05:26:39 +00:00
Update adding features (#6719)
Trying to update obsolete mentions in the "adding features" info (this is just a skim, I may have mistakes and/or missed items). Assisted-by: Google Antigravity with Gemini 3 Flash --------- Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
1 parent
8b967943d3
commit
e2f451dc9c
3 files changed
+132
-86
No files matched your search
@@ -36,8 +36,8 @@ New lexed tokens must be added to
|
||||
`CARBON_KEYWORD_TOKEN` both provide some built-in lexing logic, while
|
||||
`CARBON_TOKEN` requires custom lexing support.
|
||||
|
||||
[TokenizedBuffer::Lex](/toolchain/lex/tokenized_buffer.h) is the main dispatch
|
||||
for lexing, and calls that need to do custom lexing will be dispatched there.
|
||||
[Lex](/toolchain/lex/lex.h) is the main dispatch for lexing, and calls that need
|
||||
to do custom lexing will be dispatched there.
|
||||
|
||||
## Parse
|
||||
|
||||
@@ -51,7 +51,7 @@ designs. Adding a parse node kind will also require a handler in the `Check`
|
||||
step.
|
||||
|
||||
The state transitions are in [parse/state.def](/toolchain/parse/state.def). Each
|
||||
`CARBON_PARSER_STATE` defines a distinct state and has comments for state
|
||||
`CARBON_PARSE_STATE` defines a distinct state and has comments for state
|
||||
transitions. If several states should share handling, name them
|
||||
`FeatureAsVariant`.
|
||||
|
||||
@@ -63,16 +63,43 @@ processing.
|
||||
|
||||
### Typed parse node metadata implementation
|
||||
|
||||
As of [#3534](https://github.com/carbon-language/carbon-lang/pull/3534):
|
||||
The key file structure is:
|
||||
|
||||

|
||||
```mermaid
|
||||
graph BT
|
||||
subgraph common
|
||||
EnumBase["enum_base.h"]
|
||||
end
|
||||
|
||||
> TODO: Convert this chart to Mermaid.
|
||||
subgraph parse
|
||||
NodeKindDef["node_kind.def"]
|
||||
NodeKind["node_kind.h"]
|
||||
NodeIds["node_ids.h"]
|
||||
TypedNodes["typed_nodes.h"]
|
||||
NodeKindCpp["node_kind.cpp"]
|
||||
Tree["tree.h"]
|
||||
TreeAndSubtrees["tree_and_subtrees.h"]
|
||||
Extract["extract.cpp"]
|
||||
end
|
||||
|
||||
NodeKind --> EnumBase
|
||||
NodeKind --> NodeKindDef
|
||||
NodeIds --> NodeKindDef
|
||||
TypedNodes --> NodeKindDef
|
||||
NodeKindCpp --> NodeKindDef
|
||||
TypedNodes --> NodeKind
|
||||
Tree --> NodeIds
|
||||
NodeKindCpp --> TypedNodes
|
||||
Tree --> TypedNodes
|
||||
Extract --> TypedNodes
|
||||
TreeAndSubtrees --> Tree
|
||||
Extract --> TreeAndSubtrees
|
||||
```
|
||||
|
||||
- [common/enum_base.h](/common/enum_base.h) defines the `EnumBase`
|
||||
[CRTP](idioms.md#crtp-or-curiously-recurring-template-pattern) class
|
||||
extending `Printable` from [common/ostream.h](/common/ostream.h), along with
|
||||
`CARBON_ENUM` macros for making enumerations
|
||||
`CARBON_ENUM` macros for making enumerations.
|
||||
|
||||
- [parse/node_kind.h](/toolchain/parse/node_kind.h) includes
|
||||
[common/enum_base.h](/common/enum_base.h) and defines an enumeration
|
||||
@@ -81,46 +108,41 @@ As of [#3534](https://github.com/carbon-language/carbon-lang/pull/3534):
|
||||
- The `NodeKind` enumeration is populated with the list of all parse node
|
||||
kinds using [parse/node_kind.def](/toolchain/parse/node_kind.def) (using
|
||||
[the .def file idiom](idioms.md#def-files)) _declared_ in this file
|
||||
using a macro from [common/enum_base.h](/common/enum_base.h)
|
||||
using a macro from [common/enum_base.h](/common/enum_base.h).
|
||||
|
||||
- `NodeKind` has a member type `NodeKind::Definition` that extends
|
||||
`NodeKind` and adds a `NodeCategory` field (and others in the future).
|
||||
`NodeKind` and adds a `NodeCategory` field (and others).
|
||||
|
||||
- `NodeKind` has a method `Define` for creating a `NodeKind::Definition`
|
||||
with the same enumerant value, plus values for the other fields.
|
||||
with the same enumerant value, plus values for the added fields.
|
||||
|
||||
- `HasKindMember<T>` at the bottom of
|
||||
[parse/node_kind.h](/toolchain/parse/node_kind.h) uses
|
||||
[field detection](idioms.md#field-detection) to determine if the type
|
||||
`T` has a `NodeKind::Definition Kind` static constant member.
|
||||
|
||||
- Note: both the type and name of these fields must match exactly.
|
||||
|
||||
- Note that additional information is needed to define the `category()`
|
||||
method (and other methods in the future) of `NodeKind`. This information
|
||||
comes from the typed parse node definitions in
|
||||
[parse/typed_nodes.h](/toolchain/parse/typed_nodes.h) (described below).
|
||||
|
||||
- [parse/node_ids.h](/toolchain/parse/node_ids.h) defines a number of types
|
||||
that store a _node id_ that identifies a node in the parse tree
|
||||
that store a _node id_ that identifies a node in the `Tree`.
|
||||
|
||||
- `NodeId` stores a node id with no restrictions
|
||||
- `NodeId` stores an node id with no restrictions.
|
||||
|
||||
- `NodeIdForKind<Kind>` inherits from `NodeId` and stores the id of a node
|
||||
that must have the specified `NodeKind` "`Kind`". Note that this is not
|
||||
used directly, instead aliases `FooId` for
|
||||
`NodeIdForKind<NodeKind::Foo>` are defined for every node kind using
|
||||
used directly; instead, `using FooId = NodeIdForKind<NodeKind::Foo>;` is
|
||||
defined for every node kind using
|
||||
[parse/node_kind.def](/toolchain/parse/node_kind.def) (using
|
||||
[the .def file idiom](idioms.md#def-files)).
|
||||
|
||||
- `NodeIdInCategory<Category>` inherits from `NodeId` and stores the id of
|
||||
a node that must overlap the specified `NodeCategory` "`Category`". Note
|
||||
that this is not typically used directly, instead this file defines
|
||||
aliases `AnyDeclId`, `AnyExprId`, ..., `AnyStatementId`.
|
||||
a node that must overlap the specified `NodeCategory`. Note that this is
|
||||
not typically used directly; instead, this file defines aliases such as
|
||||
`using AnyDeclId = NodeIdInCategory<NodeCategory::Decl>;`.
|
||||
|
||||
- Similarly `NodeIdOneOf<T, U>` and `NodeIdNot<V>` inherit from `NodeId`
|
||||
- Similarly, `NodeIdOneOf<T, U>` and `NodeIdNot<V>` inherit from `NodeId`
|
||||
and stores the id of a node restricted to either matching `T::Kind` or
|
||||
`U::Kind` or not matching `V::Kind`.
|
||||
|
||||
- In addition to the node id type definitions above, the struct
|
||||
`NodeForId<T>` is declared but not defined.
|
||||
|
||||
@@ -131,6 +153,7 @@ As of [#3534](https://github.com/carbon-language/carbon-lang/pull/3534):
|
||||
to `Define()` on the corresponding enumerant member of `NodeKind` from
|
||||
[parse/node_kind.h](/toolchain/parse/node_kind.h) (which is included by
|
||||
this file).
|
||||
|
||||
- The fields of these types specify the children of the parse node using
|
||||
the types from [parse/node_ids.h](/toolchain/parse/node_ids.h).
|
||||
|
||||
@@ -145,12 +168,12 @@ As of [#3534](https://github.com/carbon-language/carbon-lang/pull/3534):
|
||||
|
||||
- [parse/node_kind.cpp](/toolchain/parse/node_kind.cpp) includes both
|
||||
[parse/node_kind.h](/toolchain/parse/node_kind.h) and
|
||||
[parse/typed_nodes.h](/toolchain/parse/typed_nodes.h)
|
||||
[parse/typed_nodes.h](/toolchain/parse/typed_nodes.h).
|
||||
|
||||
- Uses the macro from [common/enum_base.h](/common/enum_base.h), the
|
||||
enumerants of `NodeKind` are _defined_ using the list of parse node
|
||||
kinds from [parse/node_kind.def](/toolchain/parse/node_kind.def) (using
|
||||
[the .def file idiom](idioms.md#def-files)).
|
||||
- The enumerants of `NodeKind` that were declared in parse/node*kind.h are
|
||||
\_defined*, again using the macro from
|
||||
[common/enum_base.h](/common/enum_base.h) and the list of node kinds in
|
||||
[parse/node_kind.def](/toolchain/parse/node_kind.def).
|
||||
|
||||
- `NodeKind::definition()` is defined. It has a static table of
|
||||
`const NodeKind::Definition*` indexed by the enum value, populated by
|
||||
@@ -166,28 +189,37 @@ As of [#3534](https://github.com/carbon-language/carbon-lang/pull/3534):
|
||||
[parse/node_kind.def](/toolchain/parse/node_kind.def).
|
||||
|
||||
- [parse/tree.h](/toolchain/parse/tree.h) includes
|
||||
[parse/node_ids.h](/toolchain/parse/node_ids.h). It does not depend on
|
||||
[parse/typed_nodes.h](/toolchain/parse/typed_nodes.h) to reduce compilation
|
||||
time in those files that don't use the typed parse node struct types.
|
||||
[parse/node_ids.h](/toolchain/parse/node_ids.h).
|
||||
|
||||
- Defines `Tree::Extract`... functions that take a node id and return a
|
||||
typed parse node struct type from
|
||||
- `Tree` is the parse tree. It is a node-based tree where each node has a
|
||||
kind, a token, and a list of children. It has basic iterator support,
|
||||
sufficient for checking tree structure.
|
||||
|
||||
- [parse/tree_and_subtrees.h](/toolchain/parse/tree_and_subtrees.h) includes
|
||||
[parse/tree.h](/toolchain/parse/tree.h).
|
||||
|
||||
- `TreeAndSubtrees` is separate from `Tree` because we try to avoid
|
||||
building subtrees when compiling valid code. It builds subtree
|
||||
information that can be helpful for diagnostics and other tooling.
|
||||
|
||||
- Defines `TreeAndSubtrees::Extract`... functions that take a node id and
|
||||
return a typed parse node struct type from
|
||||
[parse/typed_nodes.h](/toolchain/parse/typed_nodes.h).
|
||||
|
||||
- Uses `HasKindMember<T>` to restrict calling `ExtractAs` except on typed
|
||||
nodes defined in [parse/typed_nodes.h](/toolchain/parse/typed_nodes.h).
|
||||
|
||||
- `Tree::Extract` uses `NodeForId<T>` to get the corresponding typed parse
|
||||
node struct type for a `FooId` type defined in
|
||||
- `TreeAndSubtrees::Extract` uses `NodeForId<T>` to get the corresponding
|
||||
typed parse node struct type for a `FooId` type defined in
|
||||
[parse/node_ids.h](/toolchain/parse/node_ids.h).
|
||||
|
||||
- Note that this is done without a dependency on the typed parse node
|
||||
struct types by using the forward declaration of `NodeForId<T>` from
|
||||
[parse/node_ids.h](/toolchain/parse/node_ids.h).
|
||||
|
||||
- The `Tree::Extract`... functions ultimately call
|
||||
`Tree::TryExtractNodeFromChildren<T>`, which is a templated function
|
||||
only declared in this file. Its definition is in
|
||||
- The `TreeAndSubtrees::Extract`... functions ultimately call
|
||||
`TreeAndSubtrees::TryExtractNodeFromChildren<T>`, which is a templated
|
||||
function only declared in this file. Its definition is in
|
||||
[parse/extract.cpp](/toolchain/parse/extract.cpp).
|
||||
|
||||
- [parse/extract.cpp](/toolchain/parse/extract.cpp) includes
|
||||
@@ -195,8 +227,8 @@ As of [#3534](https://github.com/carbon-language/carbon-lang/pull/3534):
|
||||
[parse/typed_nodes.h](/toolchain/parse/typed_nodes.h)
|
||||
|
||||
- Defines struct `Extractable<T>` that defines how to extract a field of
|
||||
type `T` from a `Tree::SiblingIterator` pointing at the corresponding
|
||||
child node.
|
||||
type `T` from a `TreeAndSubtrees::SiblingIterator` pointing at the
|
||||
corresponding child node.
|
||||
|
||||
- `Extractable<T>` is defined for the node id types defined in
|
||||
[parse/node_ids.h](/toolchain/parse/node_ids.h).
|
||||
@@ -214,7 +246,7 @@ As of [#3534](https://github.com/carbon-language/carbon-lang/pull/3534):
|
||||
directly as fields of typed parse node struct types -- in those places
|
||||
`FooId` should be used instead.
|
||||
|
||||
- Defines `Tree::TryExtractNodeFromChildren<T>` and explicitly
|
||||
- Defines `TreeAndSubtrees::TryExtractNodeFromChildren<T>` and explicitly
|
||||
instantiates it for every typed parse node struct type defined in
|
||||
[parse/typed_nodes.h](/toolchain/parse/typed_nodes.h) using
|
||||
[parse/node_kind.def](/toolchain/parse/node_kind.def) (using
|
||||
@@ -233,7 +265,7 @@ Note: this is broadly similar to
|
||||
|
||||
## Check
|
||||
|
||||
Each parse node kind requires adding a `Handle<kind>` function in a
|
||||
Each parse node kind requires adding a `HandleParseNode` function in a
|
||||
`check/handle_*.cpp` file.
|
||||
|
||||
### Adding a new SemIR instruction
|
||||
@@ -243,7 +275,7 @@ If the resulting SemIR needs a new instruction:
|
||||
- Add a new kind to [sem_ir/inst_kind.def](/toolchain/sem_ir/inst_kind.def).
|
||||
|
||||
- Add a `CARBON_SEM_IR_INST_KIND(NewInstKindName)` line in alphabetical
|
||||
order
|
||||
order.
|
||||
|
||||
- Add a new struct definition to
|
||||
[sem_ir/typed_insts.h](/toolchain/sem_ir/typed_insts.h), such as:
|
||||
@@ -269,8 +301,8 @@ If the resulting SemIR needs a new instruction:
|
||||
// an expression.
|
||||
TypeId type_id;
|
||||
|
||||
// 0-2 id fields, with types from sem_ir/ids.h or
|
||||
// sem_ir/builtin_kind.h. For example, fields would look like:
|
||||
// 0-2 id fields, with allowed types listed in `sem_ir/id_kind.h`. For
|
||||
// example, fields would look like:
|
||||
NameId name_id;
|
||||
InstId value_id;
|
||||
};
|
||||
@@ -279,6 +311,7 @@ If the resulting SemIR needs a new instruction:
|
||||
- [`sem_ir/inst_kind.h`](/toolchain/sem_ir/inst_kind.h) documents the
|
||||
different options when defining a new instruction, as well as their
|
||||
defaults, see `InstKind::DefinitionInfo`.
|
||||
|
||||
- If an instruction always produces a type:
|
||||
|
||||
- Set `.is_type = InstIsType::Always` in its `Kind` definition.
|
||||
@@ -293,14 +326,12 @@ If the resulting SemIR needs a new instruction:
|
||||
|
||||
- Although most instructions have distinct types represented by
|
||||
instructions like `ClassType`, we also have builtin types for cases
|
||||
where types don't need to be distinct per-entity. This is rare, but
|
||||
used, for example, when an expression implicitly uses a value as part of
|
||||
where types don't need to be distinct per-entity. This is rare; an
|
||||
example use is when an expression implicitly uses a value as part of
|
||||
SemIR evaluation or as part of desugaring. We have builtin types for
|
||||
bound methods, namespaces, witnesses, among others. These are
|
||||
constructed as a special-case in
|
||||
[`File` construction](/toolchain/sem_ir/file.cpp). To get a type id for
|
||||
bound methods, namespaces, witnesses, and others. To get a type id for
|
||||
one of these builtin types, use something like
|
||||
`GetSingletonType(context,SemIR::WitnessType::TypeInstId)`, as in:
|
||||
`GetSingletonType(context, SemIR::WitnessType::TypeInstId)`, as in:
|
||||
|
||||
```
|
||||
SemIR::TypeId witness_type_id =
|
||||
@@ -318,36 +349,49 @@ type. Look to the comments on those functions for instructions on what is
|
||||
needed.
|
||||
|
||||
Instructions won't be given a name unless
|
||||
[`InstNamer::CollectNamesInBlock`](/toolchain/sem_ir/inst_namer.cpp) is called
|
||||
on the `InstBlockId` they are a member of. As of this writing,
|
||||
`InstNamer::CollectNamesInBlock` should only be called once per `InstBlockId`.
|
||||
To accomplish this, there should be one instruction kind that "owns" the
|
||||
instruction block, and will have a case in `InstNamer::CollectNamesInBlock` that
|
||||
visits the `InstBlockId`. That instruction kind will typically use
|
||||
`FormatTrailingBlock` in the `sem_ir/formatter.cpp` to list the instructions in
|
||||
curly braces (`{`...`}`). Other instructions that reference that `InstBlockId`
|
||||
will use the default rendering that has just the instruction names in parens
|
||||
(`(`...`)`).
|
||||
[`InstNamer`](/toolchain/sem_ir/inst_namer.cpp) traverses the `InstBlockId` they
|
||||
are a member of. To accomplish this, `InstNamer` starts at each of constants,
|
||||
imports, and the file scope blocks. It then recursively traverses instructions
|
||||
those contain, blocks referenced by those instructions, and so on. Instructions
|
||||
must be "owned" by exactly one of the recursively traversed blocks to be
|
||||
correctly named. That instruction kind will typically use `FormatTrailingBlock`
|
||||
in the `sem_ir/formatter.cpp` to list the instructions in curly braces
|
||||
(`{`...`}`). Other instructions that reference that `InstBlockId` will use the
|
||||
default rendering that has just the instruction names in parens (`(`...`)`).
|
||||
|
||||
Adding an instruction will generally also require a handler in the Lower step.
|
||||
|
||||
Most new instructions will automatically be formatted reasonably by the SemIR
|
||||
formatter. If not, then add a `FormatInst` overload to
|
||||
[`sem_ir/formatter.cpp`](/toolchain/sem_ir/formatter.cpp). If only the arguments
|
||||
need custom formatting, then a `FormatInstRhs` overload can be implemented
|
||||
instead.
|
||||
|
||||
If the resulting SemIR needs a new built-in, add it to
|
||||
[`File` construction](/toolchain/sem_ir/file.cpp).
|
||||
formatter. Some instructions need specialized formatting to `FormatInstLhs` and
|
||||
`FormatInstRhs` in [`sem_ir/formatter.cpp`](/toolchain/sem_ir/formatter.cpp). If
|
||||
an argument needs custom formatting, then a `FormatArg` overload can be
|
||||
implemented instead.
|
||||
|
||||
### SemIR typed instruction metadata implementation
|
||||
|
||||
How does this work? As of
|
||||
[#3310](https://github.com/carbon-language/carbon-lang/pull/3310):
|
||||
The key file structure is:
|
||||
|
||||

|
||||
```mermaid
|
||||
graph BT
|
||||
subgraph common
|
||||
EnumBase["enum_base.h"]
|
||||
end
|
||||
|
||||
> TODO: Convert this chart to Mermaid.
|
||||
subgraph sem_ir
|
||||
InstKindDef["inst_kind.def"]
|
||||
InstKindH["inst_kind.h"]
|
||||
TypedInstsH["typed_insts.h"]
|
||||
InstKindCpp["inst_kind.cpp"]
|
||||
InstH["inst.h"]
|
||||
end
|
||||
|
||||
InstKindH --> EnumBase
|
||||
InstKindH --> InstKindDef
|
||||
InstKindCpp --> InstKindDef
|
||||
TypedInstsH --> InstKindH
|
||||
InstKindCpp --> TypedInstsH
|
||||
InstH --> TypedInstsH
|
||||
```
|
||||
|
||||
- [common/enum_base.h](/common/enum_base.h) defines the `EnumBase`
|
||||
[CRTP](idioms.md#crtp-or-curiously-recurring-template-pattern) class
|
||||
@@ -384,10 +428,10 @@ How does this work? As of
|
||||
[sem_ir/inst_kind.h](/toolchain/sem_ir/inst_kind.h) (which is included
|
||||
by this file).
|
||||
|
||||
- `HasParseNodeMember<TypedInst>` and `HasTypeIdMember<TypedInst>` at the
|
||||
- `HasKindMemberAsField<TypedInst>` and `HasTypeIdMember<TypedInst>` at the
|
||||
bottom of [sem_ir/typed_insts.h](/toolchain/sem_ir/typed_insts.h) use
|
||||
[field detection](idioms.md#field-detection) to determine if `TypedInst` has
|
||||
a `Parse::Node parse_node` or a `TypeId type_id` field respectively.
|
||||
an `InstKind kind` or a `TypeId type_id` field respectively.
|
||||
|
||||
- Note: both the type and name of these fields must match exactly.
|
||||
|
||||
@@ -405,6 +449,7 @@ How does this work? As of
|
||||
[sem_ir/typed_insts.h](/toolchain/sem_ir/typed_insts.h) to every
|
||||
instruction kind by using the list from
|
||||
[sem_ir/inst_kind.def](/toolchain/sem_ir/inst_kind.def).
|
||||
|
||||
- `InstKind::definition()` is defined. It has a static table of
|
||||
`const InstKind::Definition*` indexed by the enum value, populated by
|
||||
taking the address of the `Kind` member of each `TypedInst`, using the
|
||||
@@ -412,6 +457,7 @@ How does this work? As of
|
||||
|
||||
- `InstKind::ir_name()` and `InstKind::terminator_kind()` are defined
|
||||
using `InstKind::definition()`.
|
||||
|
||||
- Tested assumption: the tables built in this file are indexed by the enum
|
||||
values. We rely on the fact that we get the instruction kinds in the
|
||||
same order by consistently using
|
||||
@@ -422,35 +468,37 @@ How does this work? As of
|
||||
corresponding struct type in
|
||||
[sem_ir/typed_insts.h](/toolchain/sem_ir/typed_insts.h).
|
||||
|
||||
- `TypedInstArgsInfo<TypedInst>` defined in
|
||||
- `InstLikeTypeInfo<TypedInst>` defined in
|
||||
[sem_ir/inst.h](/toolchain/sem_ir/inst.h) uses
|
||||
[struct reflection](idioms.md#struct-reflection) to determine the other
|
||||
fields from `TypedInst`. It skips the `parse_node` and `type_id` fields
|
||||
using `HasParseNodeMember<TypedInst>` and `HasTypeIdMember<TypedInst>`.
|
||||
fields from `TypedInst`. It skips the `kind` and `type_id` fields using
|
||||
`HasKindMemberAsField<TypedInst>` and `HasTypeIdMember<TypedInst>`.
|
||||
|
||||
- Tested assumption: the `parse_node` and `type_id` are the first fields
|
||||
in `TypedInst`, and there are at most two more fields.
|
||||
- Tested assumption: the `kind` and `type_id` are the first fields in
|
||||
`TypedInst`, and there are at most two more fields.
|
||||
|
||||
- [sem_ir/inst.h](/toolchain/sem_ir/inst.h) defines templated conversions
|
||||
between `Inst` and each of the typed instruction structs:
|
||||
|
||||
- Uses `TypedInstArgsInfo<TypedInst>`, `HasParseNodeMember<TypedInst>`,
|
||||
- Uses `InstLikeTypeInfo<TypedInst>`, `HasKindMemberAsField<TypedInst>`,
|
||||
and `HasTypeIdMember<TypedInst>`, and
|
||||
[local lambda](idioms.md#local-lambdas-to-reduce-duplicate-code).
|
||||
|
||||
- Defines a templated `ToRaw` function that converts the various id field
|
||||
types to an `int32_t`.
|
||||
|
||||
- Defines a templated `FromRaw<T>` function that converts an `int32_t` to
|
||||
`T` to perform the opposite conversion.
|
||||
- Tested assumption: The `parse_node` field is first, when present, and
|
||||
the `type_id` is next, when present, in each `TypedInst` struct type.
|
||||
|
||||
- Tested assumption: The `kind` field is first, when present, and the
|
||||
`type_id` is next, when present, in each `TypedInst` struct type.
|
||||
|
||||
- The "tested assumptions" above are all tested by
|
||||
[sem_ir/typed_insts_test.cpp](/toolchain/sem_ir/typed_insts_test.cpp)
|
||||
|
||||
## Lower
|
||||
|
||||
Each SemIR instruction requires adding a `Handle<kind>` function in a
|
||||
Each SemIR instruction requires adding a `HandleInst` function in a
|
||||
`lower/handle_*.cpp` file.
|
||||
|
||||
## Tests and debugging
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<svg version="1.1" viewBox="0.0 0.0 1280.0 960.0" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg"><clipPath id="p.0"><path d="m0 0l1280.0 0l0 960.0l-1280.0 0l0 -960.0z" clip-rule="nonzero"/></clipPath><g clip-path="url(#p.0)"><path fill="#000000" fill-opacity="0.0" d="m0 0l1280.0 0l0 960.0l-1280.0 0z" fill-rule="evenodd"/><path fill="#000000" fill-opacity="0.0" d="m328.0 29.984251l136.0 0l0 42.015747l-136.0 0z" fill-rule="evenodd"/><path stroke="#000000" stroke-width="2.0" stroke-linejoin="round" stroke-linecap="butt" d="m328.0 29.984251l136.0 0l0 42.015747l-136.0 0z" fill-rule="evenodd"/><path fill="#000000" d="m347.33038 54.602753l1.6875 0.203125q-0.40625 1.484375 -1.484375 2.3125q-1.078125 0.8125 -2.765625 0.8125q-2.125 0 -3.375 -1.296875q-1.234375 -1.3125 -1.234375 -3.671875q0 -2.453125 1.25 -3.796875q1.265625 -1.34375 3.265625 -1.34375q1.9375 0 3.15625 1.328125q1.234375 1.3125 1.234375 3.703125q0 0.15625 0 0.4375l-7.21875 0q0.09375 1.59375 0.90625 2.453125q0.8125 0.84375 2.015625 0.84375q0.90625 0 1.546875 -0.46875q0.640625 -0.484375 1.015625 -1.515625zm-5.390625 -2.65625l5.40625 0q-0.109375 -1.21875 -0.625 -1.828125q-0.78125 -0.953125 -2.03125 -0.953125q-1.125 0 -1.90625 0.765625q-0.765625 0.75 -0.84375 2.015625zm9.141357 5.765625l0 -9.671875l1.46875 0l0 1.375q1.0625 -1.59375 3.078125 -1.59375q0.875 0 1.609375 0.3125q0.734375 0.3125 1.09375 0.828125q0.375 0.5 0.515625 1.203125q0.09375 0.453125 0.09375 1.59375l0 5.953125l-1.640625 0l0 -5.890625q0 -1.0 -0.203125 -1.484375q-0.1875 -0.5 -0.671875 -0.796875q-0.484375 -0.296875 -1.140625 -0.296875q-1.046875 0 -1.8125 0.671875q-0.75 0.65625 -0.75 2.515625l0 5.28125l-1.640625 0zm16.703827 0l0 -1.421875q-1.125 1.640625 -3.0625 1.640625q-0.859375 0 -1.609375 -0.328125q-0.734375 -0.328125 -1.09375 -0.828125q-0.359375 -0.5 -0.5 -1.21875q-0.109375 -0.46875 -0.109375 -1.53125l0 -5.984375l1.640625 0l0 5.359375q0 1.28125 0.109375 1.734375q0.15625 0.640625 0.65625 1.015625q0.5 0.375 1.234375 0.375q0.734375 0 1.375 -0.375q0.65625 -0.390625 0.921875 -1.03125q0.265625 -0.65625 0.265625 -1.890625l0 -5.1875l1.640625 0l0 9.671875l-1.46875 0zm4.0476074 0l0 -9.671875l1.46875 0l0 1.359375q0.453125 -0.71875 1.203125 -1.140625q0.765625 -0.4375 1.71875 -0.4375q1.078125 0 1.765625 0.453125q0.6875 0.4375 0.96875 1.234375q1.15625 -1.6875 2.984375 -1.6875q1.453125 0 2.21875 0.796875q0.78125 0.796875 0.78125 2.453125l0 6.640625l-1.640625 0l0 -6.09375q0 -0.984375 -0.15625 -1.40625q-0.15625 -0.4375 -0.578125 -0.703125q-0.421875 -0.265625 -0.984375 -0.265625q-1.015625 0 -1.6875 0.6875q-0.671875 0.671875 -0.671875 2.15625l0 5.625l-1.640625 0l0 -6.28125q0 -1.09375 -0.40625 -1.640625q-0.40625 -0.546875 -1.3125 -0.546875q-0.6875 0 -1.28125 0.359375q-0.59375 0.359375 -0.859375 1.0625q-0.25 0.703125 -0.25 2.03125l0 5.015625l-1.640625 0zm14.025177 3.703125l0 -1.1875l10.859375 0l0 1.1875l-10.859375 0zm13.391327 -3.703125l-1.515625 0l0 -13.359375l1.640625 0l0 4.765625q1.046875 -1.296875 2.65625 -1.296875q0.890625 0 1.6875 0.359375q0.796875 0.359375 1.3125 1.015625q0.515625 0.640625 0.796875 1.5625q0.296875 0.921875 0.296875 1.96875q0 2.484375 -1.234375 3.84375q-1.21875 1.359375 -2.953125 1.359375q-1.703125 0 -2.6875 -1.4375l0 1.21875zm-0.015625 -4.90625q0 1.734375 0.484375 2.515625q0.765625 1.265625 2.09375 1.265625q1.078125 0 1.859375 -0.9375q0.78125 -0.9375 0.78125 -2.78125q0 -1.890625 -0.75 -2.796875q-0.75 -0.90625 -1.828125 -0.90625q-1.0625 0 -1.859375 0.9375q-0.78125 0.9375 -0.78125 2.703125zm15.203857 3.71875q-0.921875 0.765625 -1.765625 1.09375q-0.828125 0.3125 -1.796875 0.3125q-1.59375 0 -2.453125 -0.78125q-0.859375 -0.78125 -0.859375 -1.984375q0 -0.71875 0.328125 -1.296875q0.328125 -0.59375 0.84375 -0.9375q0.53125 -0.359375 1.1875 -0.546875q0.46875 -0.125 1.453125 -0.25q1.984375 -0.234375 2.921875 -0.5625q0.015625 -0.34375 0.015625 -0.421875q0 -1.0 -0.46875 -1.421875q-0.625 -0.546875 -1.875 -0.546875q-1.15625 0 -1.703125 0.40625q-0.546875 0.40625 -0.8125 1.421875l-1.609375 -0.21875q0.21875 -1.015625 0.71875 -1.640625q0.5 -0.640625 1.453125 -0.984375q0.953125 -0.34375 2.1875 -0.34375q1.25 0 2.015625 0.296875q0.78125 0.28125 1.140625 0.734375q0.375 0.4375 0.515625 1.109375q0.078125 0.421875 0.078125 1.515625l0 2.1875q0 2.28125 0.109375 2.890625q0.109375 0.59375 0.40625 1.15625l-1.703125 0q-0.265625 -0.515625 -0.328125 -1.1875zm-0.140625 -3.671875q-0.890625 0.375 -2.671875 0.625q-1.015625 0.140625 -1.4375 0.328125q-0.421875 0.1875 -0.65625 0.53125q-0.21875 0.34375 -0.21875 0.78125q0 0.65625 0.5 1.09375q0.5 0.4375 1.453125 0.4375q0.9375 0 1.671875 -0.40625q0.75 -0.421875 1.09375 -1.140625q0.265625 -0.5625 0.265625 -1.640625l0 -0.609375zm3.547577 1.96875l1.625 -0.25q0.125 0.96875 0.75 1.5q0.625 0.515625 1.75 0.515625q1.125 0 1.671875 -0.453125q0.546875 -0.46875 0.546875 -1.09375q0 -0.546875 -0.484375 -0.875q-0.328125 -0.21875 -1.671875 -0.546875q-1.8125 -0.46875 -2.515625 -0.796875q-0.6875 Line truncated
|
||||
|
Before Width: | Height: | Size: 86 KiB |
@@ -1 +0,0 @@
|
||||
<svg version="1.1" viewBox="0.0 0.0 1280.0 960.0" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg"><clipPath id="p.0"><path d="m0 0l1280.0 0l0 960.0l-1280.0 0l0 -960.0z" clip-rule="nonzero"/></clipPath><g clip-path="url(#p.0)"><path fill="#000000" fill-opacity="0.0" d="m0 0l1280.0 0l0 960.0l-1280.0 0z" fill-rule="evenodd"/><path fill="#000000" fill-opacity="0.0" d="m328.0 29.984251l136.0 0l0 42.015747l-136.0 0z" fill-rule="evenodd"/><path stroke="#000000" stroke-width="2.0" stroke-linejoin="round" stroke-linecap="butt" d="m328.0 29.984251l136.0 0l0 42.015747l-136.0 0z" fill-rule="evenodd"/><path fill="#000000" d="m347.33038 54.602753l1.6875 0.203125q-0.40625 1.484375 -1.484375 2.3125q-1.078125 0.8125 -2.765625 0.8125q-2.125 0 -3.375 -1.296875q-1.234375 -1.3125 -1.234375 -3.671875q0 -2.453125 1.25 -3.796875q1.265625 -1.34375 3.265625 -1.34375q1.9375 0 3.15625 1.328125q1.234375 1.3125 1.234375 3.703125q0 0.15625 0 0.4375l-7.21875 0q0.09375 1.59375 0.90625 2.453125q0.8125 0.84375 2.015625 0.84375q0.90625 0 1.546875 -0.46875q0.640625 -0.484375 1.015625 -1.515625zm-5.390625 -2.65625l5.40625 0q-0.109375 -1.21875 -0.625 -1.828125q-0.78125 -0.953125 -2.03125 -0.953125q-1.125 0 -1.90625 0.765625q-0.765625 0.75 -0.84375 2.015625zm9.141357 5.765625l0 -9.671875l1.46875 0l0 1.375q1.0625 -1.59375 3.078125 -1.59375q0.875 0 1.609375 0.3125q0.734375 0.3125 1.09375 0.828125q0.375 0.5 0.515625 1.203125q0.09375 0.453125 0.09375 1.59375l0 5.953125l-1.640625 0l0 -5.890625q0 -1.0 -0.203125 -1.484375q-0.1875 -0.5 -0.671875 -0.796875q-0.484375 -0.296875 -1.140625 -0.296875q-1.046875 0 -1.8125 0.671875q-0.75 0.65625 -0.75 2.515625l0 5.28125l-1.640625 0zm16.703827 0l0 -1.421875q-1.125 1.640625 -3.0625 1.640625q-0.859375 0 -1.609375 -0.328125q-0.734375 -0.328125 -1.09375 -0.828125q-0.359375 -0.5 -0.5 -1.21875q-0.109375 -0.46875 -0.109375 -1.53125l0 -5.984375l1.640625 0l0 5.359375q0 1.28125 0.109375 1.734375q0.15625 0.640625 0.65625 1.015625q0.5 0.375 1.234375 0.375q0.734375 0 1.375 -0.375q0.65625 -0.390625 0.921875 -1.03125q0.265625 -0.65625 0.265625 -1.890625l0 -5.1875l1.640625 0l0 9.671875l-1.46875 0zm4.0476074 0l0 -9.671875l1.46875 0l0 1.359375q0.453125 -0.71875 1.203125 -1.140625q0.765625 -0.4375 1.71875 -0.4375q1.078125 0 1.765625 0.453125q0.6875 0.4375 0.96875 1.234375q1.15625 -1.6875 2.984375 -1.6875q1.453125 0 2.21875 0.796875q0.78125 0.796875 0.78125 2.453125l0 6.640625l-1.640625 0l0 -6.09375q0 -0.984375 -0.15625 -1.40625q-0.15625 -0.4375 -0.578125 -0.703125q-0.421875 -0.265625 -0.984375 -0.265625q-1.015625 0 -1.6875 0.6875q-0.671875 0.671875 -0.671875 2.15625l0 5.625l-1.640625 0l0 -6.28125q0 -1.09375 -0.40625 -1.640625q-0.40625 -0.546875 -1.3125 -0.546875q-0.6875 0 -1.28125 0.359375q-0.59375 0.359375 -0.859375 1.0625q-0.25 0.703125 -0.25 2.03125l0 5.015625l-1.640625 0zm14.025177 3.703125l0 -1.1875l10.859375 0l0 1.1875l-10.859375 0zm13.391327 -3.703125l-1.515625 0l0 -13.359375l1.640625 0l0 4.765625q1.046875 -1.296875 2.65625 -1.296875q0.890625 0 1.6875 0.359375q0.796875 0.359375 1.3125 1.015625q0.515625 0.640625 0.796875 1.5625q0.296875 0.921875 0.296875 1.96875q0 2.484375 -1.234375 3.84375q-1.21875 1.359375 -2.953125 1.359375q-1.703125 0 -2.6875 -1.4375l0 1.21875zm-0.015625 -4.90625q0 1.734375 0.484375 2.515625q0.765625 1.265625 2.09375 1.265625q1.078125 0 1.859375 -0.9375q0.78125 -0.9375 0.78125 -2.78125q0 -1.890625 -0.75 -2.796875q-0.75 -0.90625 -1.828125 -0.90625q-1.0625 0 -1.859375 0.9375q-0.78125 0.9375 -0.78125 2.703125zm15.203857 3.71875q-0.921875 0.765625 -1.765625 1.09375q-0.828125 0.3125 -1.796875 0.3125q-1.59375 0 -2.453125 -0.78125q-0.859375 -0.78125 -0.859375 -1.984375q0 -0.71875 0.328125 -1.296875q0.328125 -0.59375 0.84375 -0.9375q0.53125 -0.359375 1.1875 -0.546875q0.46875 -0.125 1.453125 -0.25q1.984375 -0.234375 2.921875 -0.5625q0.015625 -0.34375 0.015625 -0.421875q0 -1.0 -0.46875 -1.421875q-0.625 -0.546875 -1.875 -0.546875q-1.15625 0 -1.703125 0.40625q-0.546875 0.40625 -0.8125 1.421875l-1.609375 -0.21875q0.21875 -1.015625 0.71875 -1.640625q0.5 -0.640625 1.453125 -0.984375q0.953125 -0.34375 2.1875 -0.34375q1.25 0 2.015625 0.296875q0.78125 0.28125 1.140625 0.734375q0.375 0.4375 0.515625 1.109375q0.078125 0.421875 0.078125 1.515625l0 2.1875q0 2.28125 0.109375 2.890625q0.109375 0.59375 0.40625 1.15625l-1.703125 0q-0.265625 -0.515625 -0.328125 -1.1875zm-0.140625 -3.671875q-0.890625 0.375 -2.671875 0.625q-1.015625 0.140625 -1.4375 0.328125q-0.421875 0.1875 -0.65625 0.53125q-0.21875 0.34375 -0.21875 0.78125q0 0.65625 0.5 1.09375q0.5 0.4375 1.453125 0.4375q0.9375 0 1.671875 -0.40625q0.75 -0.421875 1.09375 -1.140625q0.265625 -0.5625 0.265625 -1.640625l0 -0.609375zm3.547577 1.96875l1.625 -0.25q0.125 0.96875 0.75 1.5q0.625 0.515625 1.75 0.515625q1.125 0 1.671875 -0.453125q0.546875 -0.46875 0.546875 -1.09375q0 -0.546875 -0.484375 -0.875q-0.328125 -0.21875 -1.671875 -0.546875q-1.8125 -0.46875 -2.515625 -0.796875q-0.6875 Line truncated
|
||||
|
Before Width: | Height: | Size: 135 KiB |
Reference in new issue
Block a user