1fd4e5da5Sopenharmony_ci// Copyright (C) 2019 Google Inc.
2fd4e5da5Sopenharmony_ci//
3fd4e5da5Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License");
4fd4e5da5Sopenharmony_ci// you may not use this file except in compliance with the License.
5fd4e5da5Sopenharmony_ci// You may obtain a copy of the License at
6fd4e5da5Sopenharmony_ci//
7fd4e5da5Sopenharmony_ci//      http://www.apache.org/licenses/LICENSE-2.0
8fd4e5da5Sopenharmony_ci//
9fd4e5da5Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software
10fd4e5da5Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS,
11fd4e5da5Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fd4e5da5Sopenharmony_ci// See the License for the specific language governing permissions and
13fd4e5da5Sopenharmony_ci// limitations under the License.
14fd4e5da5Sopenharmony_ci
15fd4e5da5Sopenharmony_ci// Generated by {{GenerateArguments}}
16fd4e5da5Sopenharmony_ci// Do not modify this file directly.
17fd4e5da5Sopenharmony_ci
18fd4e5da5Sopenharmony_cipackage schema
19fd4e5da5Sopenharmony_ci
20fd4e5da5Sopenharmony_ci// Opcode holds information about a specific SPIR-V opcode.
21fd4e5da5Sopenharmony_citype Opcode struct {
22fd4e5da5Sopenharmony_ci	Opname   string
23fd4e5da5Sopenharmony_ci	Class    string
24fd4e5da5Sopenharmony_ci	Opcode   int
25fd4e5da5Sopenharmony_ci	Operands []Operand
26fd4e5da5Sopenharmony_ci}
27fd4e5da5Sopenharmony_ci
28fd4e5da5Sopenharmony_ci// Operand contains information about a logical operand for an instruction.
29fd4e5da5Sopenharmony_citype Operand struct {
30fd4e5da5Sopenharmony_ci	Kind       *OperandKind
31fd4e5da5Sopenharmony_ci	Name       string
32fd4e5da5Sopenharmony_ci	Quantifier Quantifier
33fd4e5da5Sopenharmony_ci}
34fd4e5da5Sopenharmony_ci
35fd4e5da5Sopenharmony_ci// OperandKind contains information about a specific operand kind.
36fd4e5da5Sopenharmony_citype OperandKind struct {
37fd4e5da5Sopenharmony_ci	Category   OperandCategory
38fd4e5da5Sopenharmony_ci	Kind       string
39fd4e5da5Sopenharmony_ci	Enumerants []Enumerant
40fd4e5da5Sopenharmony_ci	Bases      []*OperandKind
41fd4e5da5Sopenharmony_ci}
42fd4e5da5Sopenharmony_ci
43fd4e5da5Sopenharmony_ci// Enumerant contains information about an enumerant in an enum.
44fd4e5da5Sopenharmony_citype Enumerant struct {
45fd4e5da5Sopenharmony_ci	Enumerant    string
46fd4e5da5Sopenharmony_ci	Value        interface{}
47fd4e5da5Sopenharmony_ci	Capabilities []string
48fd4e5da5Sopenharmony_ci	Parameters   []Parameter
49fd4e5da5Sopenharmony_ci	Version      string
50fd4e5da5Sopenharmony_ci}
51fd4e5da5Sopenharmony_ci
52fd4e5da5Sopenharmony_ci// Parameter contains information about a logical parameter for an enumerant.
53fd4e5da5Sopenharmony_citype Parameter struct {
54fd4e5da5Sopenharmony_ci	Kind *OperandKind
55fd4e5da5Sopenharmony_ci	Name string
56fd4e5da5Sopenharmony_ci}
57fd4e5da5Sopenharmony_ci
58fd4e5da5Sopenharmony_ci// Quantifier indicates the number of times the quantified term may appear.
59fd4e5da5Sopenharmony_citype Quantifier string
60fd4e5da5Sopenharmony_ci
61fd4e5da5Sopenharmony_ciconst (
62fd4e5da5Sopenharmony_ci	// Once indicates the quantified term may appear exactly once.
63fd4e5da5Sopenharmony_ci	Once Quantifier = ""
64fd4e5da5Sopenharmony_ci
65fd4e5da5Sopenharmony_ci	// ZeroOrOnce indicates the quantified term may appear zero or one
66fd4e5da5Sopenharmony_ci	// time; an optional term.
67fd4e5da5Sopenharmony_ci	ZeroOrOnce Quantifier = "?"
68fd4e5da5Sopenharmony_ci
69fd4e5da5Sopenharmony_ci	// ZeroOrMany indicates the quantified term may appear any number of
70fd4e5da5Sopenharmony_ci	// times.
71fd4e5da5Sopenharmony_ci	ZeroOrMany Quantifier = "*"
72fd4e5da5Sopenharmony_ci)
73fd4e5da5Sopenharmony_ci
74fd4e5da5Sopenharmony_ci// OperandCategory is an enumerator that groups operand kinds.
75fd4e5da5Sopenharmony_citype OperandCategory string
76fd4e5da5Sopenharmony_ci
77fd4e5da5Sopenharmony_ciconst (
78fd4e5da5Sopenharmony_ci	// OperandCategoryBitEnum describes an operand kind where its value is a
79fd4e5da5Sopenharmony_ci	// mask, which is formed by combining the bits specified as enumerants in an
80fd4e5da5Sopenharmony_ci	// enum.
81fd4e5da5Sopenharmony_ci	OperandCategoryBitEnum = "BitEnum"
82fd4e5da5Sopenharmony_ci
83fd4e5da5Sopenharmony_ci	// OperandCategoryValueEnum describes an operand kind where its value is an
84fd4e5da5Sopenharmony_ci	// enumerant from an enum.
85fd4e5da5Sopenharmony_ci	OperandCategoryValueEnum = "ValueEnum"
86fd4e5da5Sopenharmony_ci
87fd4e5da5Sopenharmony_ci	// OperandCategoryID describes and operand kind where its value is an <id>
88fd4e5da5Sopenharmony_ci	// definition or reference.
89fd4e5da5Sopenharmony_ci	OperandCategoryID = "Id"
90fd4e5da5Sopenharmony_ci
91fd4e5da5Sopenharmony_ci	// OperandCategoryLiteral describes and operand kind where its value is an
92fd4e5da5Sopenharmony_ci	// literal number or string.
93fd4e5da5Sopenharmony_ci	OperandCategoryLiteral = "Literal"
94fd4e5da5Sopenharmony_ci
95fd4e5da5Sopenharmony_ci	// OperandCategoryComposite describes and operand kind where its value is
96fd4e5da5Sopenharmony_ci	// composed from operand values from the above categories.
97fd4e5da5Sopenharmony_ci	OperandCategoryComposite = "Composite"
98fd4e5da5Sopenharmony_ci)
99fd4e5da5Sopenharmony_ci
100fd4e5da5Sopenharmony_ci// OpcodeMap is a map of opcode name to Opcode type.
101fd4e5da5Sopenharmony_citype OpcodeMap map[string]*Opcode
102fd4e5da5Sopenharmony_ci
103fd4e5da5Sopenharmony_civar (
104fd4e5da5Sopenharmony_ci	// Opcodes is a map of opcode name to Opcode description.
105fd4e5da5Sopenharmony_ci	Opcodes = OpcodeMap {•{{range $i := .SPIRV.Instructions}}
106fd4e5da5Sopenharmony_ci		"{{$i.Opname}}": {{Title $i.Opname}},{{end}}
107fd4e5da5Sopenharmony_ci	}
108fd4e5da5Sopenharmony_ci
109fd4e5da5Sopenharmony_ci	// ExtOpcodes is a map of extension name to Opcode description list.
110fd4e5da5Sopenharmony_ci	ExtOpcodes = map[string]OpcodeMap {•{{range $ext := .Extensions}}
111fd4e5da5Sopenharmony_ci		"{{$ext.Name}}": {•{{range $i := $ext.Instructions}}
112fd4e5da5Sopenharmony_ci			"{{$i.Opname}}": {{Global $ext.Name}}_{{$i.Opname}},{{end}}
113fd4e5da5Sopenharmony_ci		},{{end}}
114fd4e5da5Sopenharmony_ci	}
115fd4e5da5Sopenharmony_ci
116fd4e5da5Sopenharmony_ci{{range $i := .SPIRV.Instructions}}	{{Title $i.Opname}} = &Opcode {
117fd4e5da5Sopenharmony_ci		Opname:   "{{$i.Opname}}",
118fd4e5da5Sopenharmony_ci		Class:    "{{$i.Class}}",
119fd4e5da5Sopenharmony_ci		Opcode:   {{$i.Opcode}},
120fd4e5da5Sopenharmony_ci		Operands: []Operand {•{{range $i := $i.Operands}}
121fd4e5da5Sopenharmony_ci			Operand {
122fd4e5da5Sopenharmony_ci				Kind:       OperandKind{{$i.Kind}},
123fd4e5da5Sopenharmony_ci				Name:       "{{Replace $i.Name "\n" " "}}",
124fd4e5da5Sopenharmony_ci				Quantifier: "{{$i.Quantifier}}",
125fd4e5da5Sopenharmony_ci			}, {{end}}
126fd4e5da5Sopenharmony_ci		},
127fd4e5da5Sopenharmony_ci	}
128fd4e5da5Sopenharmony_ci{{end}}
129fd4e5da5Sopenharmony_ci{{range $ext := .Extensions}}{{range $i := $ext.Instructions}}	{{Global $ext.Name}}_{{$i.Opname}} = &Opcode {
130fd4e5da5Sopenharmony_ci		Opname:   "{{$i.Opname}}",
131fd4e5da5Sopenharmony_ci		Operands: []Operand {•{{range $i := $i.Operands}}
132fd4e5da5Sopenharmony_ci			Operand {
133fd4e5da5Sopenharmony_ci				Kind:       OperandKind{{$i.Kind}},
134fd4e5da5Sopenharmony_ci				Name:       "{{Replace $i.Name "\n" " "}}",
135fd4e5da5Sopenharmony_ci				Quantifier: "{{$i.Quantifier}}",
136fd4e5da5Sopenharmony_ci			}, {{end}}
137fd4e5da5Sopenharmony_ci		},
138fd4e5da5Sopenharmony_ci	}
139fd4e5da5Sopenharmony_ci{{end}}{{end}}
140fd4e5da5Sopenharmony_ci
141fd4e5da5Sopenharmony_ci{{range $o := .All.OperandKinds}}	OperandKind{{$o.Kind}} = &OperandKind {
142fd4e5da5Sopenharmony_ci		Kind:       "{{$o.Kind}}",
143fd4e5da5Sopenharmony_ci		Category:   "{{$o.Category}}",
144fd4e5da5Sopenharmony_ci		Enumerants: []Enumerant {•{{range $e := $o.Enumerants}}
145fd4e5da5Sopenharmony_ci			Enumerant{
146fd4e5da5Sopenharmony_ci				Enumerant:    "{{$e.Enumerant}}",
147fd4e5da5Sopenharmony_ci				Value:        {{$e.Value}},
148fd4e5da5Sopenharmony_ci				Capabilities: []string{•{{range $c := $e.Capabilities}}"{{$c}}",{{end}}•},
149fd4e5da5Sopenharmony_ci				Parameters:   []Parameter{•{{range $p := $e.Parameters}}{•OperandKind{{$p.Kind}}, "{{$p.Name}}"•},{{end}}•},
150fd4e5da5Sopenharmony_ci				Version:      "{{$e.Version}}",
151fd4e5da5Sopenharmony_ci			},{{end}}
152fd4e5da5Sopenharmony_ci		},
153fd4e5da5Sopenharmony_ci		Bases:      []*OperandKind {•{{range $b := $o.Bases}}OperandKind{{$b}},{{end}}•},
154fd4e5da5Sopenharmony_ci	}
155fd4e5da5Sopenharmony_ci{{end}}
156fd4e5da5Sopenharmony_ci)
157