mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
tint: Split tables for unary and binary operators
Do the partitioning of unary and binary operators in the intrinsic table generators, instead of searching all operators at runtime. Will allow code to be simplified. Bug: tint:1504 Change-Id: I67246b954e530e0542b1b67c99fb34a756cf532a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90240 Commit-Queue: Ben Clayton <bclayton@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
62bfd318ae
commit
77473b4699
@@ -37,13 +37,14 @@ type IntrinsicTable struct {
|
||||
NMatchers []sem.Named
|
||||
NMatcherIndex map[sem.Named]int // [object -> index] in NMatchers
|
||||
|
||||
MatcherIndices []int // kMatcherIndices table content
|
||||
OpenTypes []OpenType // kOpenTypes table content
|
||||
OpenNumbers []OpenNumber // kOpenNumbers table content
|
||||
Parameters []Parameter // kParameters table content
|
||||
Overloads []Overload // kOverloads table content
|
||||
Builtins []Intrinsic // kBuiltins table content
|
||||
Operators []Intrinsic // kOperators table content
|
||||
MatcherIndices []int // kMatcherIndices table content
|
||||
OpenTypes []OpenType // kOpenTypes table content
|
||||
OpenNumbers []OpenNumber // kOpenNumbers table content
|
||||
Parameters []Parameter // kParameters table content
|
||||
Overloads []Overload // kOverloads table content
|
||||
Builtins []Intrinsic // kBuiltins table content
|
||||
UnaryOperators []Intrinsic // kUnaryOperators table content
|
||||
BinaryOperators []Intrinsic // kBinaryOperators table content
|
||||
}
|
||||
|
||||
// OpenType is used to create the C++ OpenTypeInfo structure
|
||||
@@ -361,9 +362,16 @@ func buildIntrinsicTable(s *sem.Sem) (*IntrinsicTable, error) {
|
||||
|
||||
b.layoutMatchers(s)
|
||||
|
||||
buildIntrinsics := func(in []*sem.Intrinsic) ([]Intrinsic, error) {
|
||||
out := make([]Intrinsic, len(in))
|
||||
for i, f := range in {
|
||||
for _, intrinsics := range []struct {
|
||||
in []*sem.Intrinsic
|
||||
out *[]Intrinsic
|
||||
}{
|
||||
{s.Builtins, &b.Builtins},
|
||||
{s.UnaryOperators, &b.UnaryOperators},
|
||||
{s.BinaryOperators, &b.BinaryOperators},
|
||||
} {
|
||||
out := make([]Intrinsic, len(intrinsics.in))
|
||||
for i, f := range intrinsics.in {
|
||||
overloads := make([]Overload, len(f.Overloads))
|
||||
overloadDescriptions := make([]string, len(f.Overloads))
|
||||
for i, o := range f.Overloads {
|
||||
@@ -380,15 +388,7 @@ func buildIntrinsicTable(s *sem.Sem) (*IntrinsicTable, error) {
|
||||
OverloadsOffset: b.lut.overloads.Add(overloads),
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
var err error
|
||||
if b.Builtins, err = buildIntrinsics(s.Builtins); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if b.Operators, err = buildIntrinsics(s.Operators); err != nil {
|
||||
return nil, err
|
||||
*intrinsics.out = out
|
||||
}
|
||||
|
||||
b.lut.matcherIndices.Compact()
|
||||
|
||||
Reference in New Issue
Block a user