RetroArch
doc.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2014-2015 LunarG, Inc.
3 //
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions
8 // are met:
9 //
10 // Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //
13 // Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following
15 // disclaimer in the documentation and/or other materials provided
16 // with the distribution.
17 //
18 // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
19 // contributors may be used to endorse or promote products derived
20 // from this software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 // POSSIBILITY OF SUCH DAMAGE.
34 
35 #ifndef _SPIRV_doc_h
36 #define _SPIRV_doc_h
37 
38 //
39 // Parameterize the SPIR-V enumerants.
40 //
41 
42 #pragma once
43 
44 #include "spirv.hpp"
45 
46 #include <vector>
47 
48 namespace spv {
49 
50 // Fill in all the parameters
51 void Parameterize();
52 
53 // Return the English names of all the enums.
54 const char* SourceString(int);
55 const char* AddressingString(int);
56 const char* MemoryString(int);
57 const char* ExecutionModelString(int);
58 const char* ExecutionModeString(int);
59 const char* StorageClassString(int);
60 const char* DecorationString(int);
61 const char* BuiltInString(int);
62 const char* DimensionString(int);
63 const char* SelectControlString(int);
64 const char* LoopControlString(int);
65 const char* FunctionControlString(int);
66 const char* SamplerAddressingModeString(int);
67 const char* SamplerFilterModeString(int);
68 const char* ImageFormatString(int);
69 const char* ImageChannelOrderString(int);
70 const char* ImageChannelTypeString(int);
71 const char* ImageChannelDataTypeString(int type);
72 const char* ImageOperandsString(int format);
73 const char* ImageOperands(int);
74 const char* FPFastMathString(int);
75 const char* FPRoundingModeString(int);
76 const char* LinkageTypeString(int);
77 const char* FuncParamAttrString(int);
78 const char* AccessQualifierString(int);
79 const char* MemorySemanticsString(int);
80 const char* MemoryAccessString(int);
81 const char* ExecutionScopeString(int);
82 const char* GroupOperationString(int);
83 const char* KernelEnqueueFlagsString(int);
84 const char* KernelProfilingInfoString(int);
85 const char* CapabilityString(int);
86 const char* OpcodeString(int);
87 const char* ScopeString(int mem);
88 
89 // For grouping opcodes into subsections
114 
116  OpClassMissing // all instructions start out as missing
117 };
118 
119 // For parameterizing operands.
161 
163 
165 };
166 
167 // Any specific enum can have a set of capabilities that allow it:
168 typedef std::vector<Capability> EnumCaps;
169 
170 // Parameterize a set of operands with their OperandClass(es) and descriptions.
172 public:
174  void push(OperandClass oc, const char* d, bool opt = false)
175  {
176  opClass.push_back(oc);
177  desc.push_back(d);
178  optional.push_back(opt);
179  }
180  void setOptional();
181  OperandClass getClass(int op) const { return opClass[op]; }
182  const char* getDesc(int op) const { return desc[op]; }
183  bool isOptional(int op) const { return optional[op]; }
184  int getNum() const { return (int)opClass.size(); }
185 
186 protected:
187  std::vector<OperandClass> opClass;
188  std::vector<const char*> desc;
189  std::vector<bool> optional;
190 };
191 
192 // Parameterize an enumerant
194 public:
195  EnumParameters() : desc(0) { }
196  const char* desc;
197 };
198 
199 // Parameterize a set of enumerants that form an enum
201 public:
203  ceiling(0), bitmask(false), getName(0), enumParams(0), operandParams(0) { }
204  void set(int ceil, const char* (*name)(int), EnumParameters* ep, bool mask = false)
205  {
206  ceiling = ceil;
207  getName = name;
208  bitmask = mask;
209  enumParams = ep;
210  }
212  int ceiling; // ceiling of enumerants
213  bool bitmask; // true if these enumerants combine into a bitmask
214  const char* (*getName)(int); // a function that returns the name for each enumerant value (or shift)
215  EnumParameters* enumParams; // parameters for each individual enumerant
216  OperandParameters* operandParams; // sets of operands
217 };
218 
219 // Parameterize an instruction's logical format, including its known set of operands,
220 // per OperandParameters above.
222 public:
224  opDesc("TBD"),
226  typePresent(true), // most normal, only exceptions have to be spelled out
227  resultPresent(true) // most normal, only exceptions have to be spelled out
228  { }
229 
230  void setResultAndType(bool r, bool t)
231  {
232  resultPresent = r;
233  typePresent = t;
234  }
235 
236  bool hasResult() const { return resultPresent != 0; }
237  bool hasType() const { return typePresent != 0; }
238 
239  const char* opDesc;
242 
243 protected:
244  int typePresent : 1;
245  int resultPresent : 1;
246 };
247 
248 // The set of objects that hold all the instruction/operand
249 // parameterization information.
251 
252 // These hold definitions of the enumerants used for operands
254 
255 const char* GetOperandDesc(OperandClass operand);
256 void PrintImmediateRow(int imm, const char* name, const EnumParameters* enumParams, bool caps, bool hex = false);
257 const char* AccessQualifierString(int attr);
258 
259 void PrintOperands(const OperandParameters& operands, int reservedOperands);
260 
261 }; // end namespace spv
262 
263 #endif
int resultPresent
Definition: doc.h:245
InstructionParameters InstructionDesc[OpCodeMask+1]
Definition: doc.cpp:1233
EnumParameters * enumParams
Definition: doc.h:215
Definition: doc.h:97
void push(OperandClass oc, const char *d, bool opt=false)
Definition: doc.h:174
void Parameterize()
Definition: doc.cpp:1246
GLuint const GLchar * name
Definition: glext.h:6671
Definition: doc.h:116
std::vector< OperandClass > opClass
Definition: doc.h:187
Definition: doc.h:133
Definition: doc.h:137
const char * opDesc
Definition: doc.h:239
const char * AccessQualifierString(int attr)
Definition: doc.cpp:573
const char * ImageOperands(int)
set set set set set set set macro pixldst1 op
Definition: pixman-arm-neon-asm.h:54
OpcodeClass
Definition: doc.h:90
Definition: doc.h:129
const char * FunctionControlString(int cont)
Definition: doc.cpp:614
Definition: disassemble.cpp:50
Definition: doc.h:154
OperandParameters * operandParams
Definition: doc.h:216
Definition: doc.h:96
const char * DimensionString(int dim)
Definition: doc.cpp:348
GLdouble GLdouble GLdouble r
Definition: glext.h:6406
bool bitmask
Definition: doc.h:213
#define ceil(x)
Definition: math.h:24
Definition: doc.h:130
GLdouble GLdouble t
Definition: glext.h:6398
Definition: memr.c:17
Definition: doc.h:143
Definition: doc.h:162
Definition: doc.h:146
std::vector< bool > optional
Definition: doc.h:189
const char * LoopControlString(int cont)
Definition: doc.cpp:599
const char * ExecutionScopeString(int)
Definition: doc.h:147
Definition: doc.h:104
OperandParameters operands
Definition: doc.h:241
Definition: doc.h:134
Definition: doc.h:94
const char * desc
Definition: doc.h:196
OperandParameters()
Definition: doc.h:173
Definition: doc.h:98
OperandClass getClass(int op) const
Definition: doc.h:181
const char * StorageClassString(int StorageClass)
Definition: doc.cpp:173
const char *(* getName)(int)
Definition: doc.h:214
Definition: doc.h:102
Definition: doc.h:111
Definition: doc.h:127
void set(int ceil, const char *(*name)(int), EnumParameters *ep, bool mask=false)
Definition: doc.h:204
Definition: doc.h:110
Definition: doc.h:136
Definition: doc.h:100
const char * SourceString(int source)
Definition: doc.cpp:77
const char * AddressingString(int addr)
Definition: doc.cpp:106
Definition: doc.h:131
Definition: doc.h:107
Definition: doc.h:160
const char * ScopeString(int mem)
Definition: doc.cpp:659
const char * GroupOperationString(int gop)
Definition: doc.cpp:672
Definition: doc.h:93
Definition: doc.h:156
Definition: doc.h:150
const char * KernelProfilingInfoString(int info)
Definition: doc.cpp:703
const char * MemoryAccessString(int mem)
Definition: doc.cpp:648
int typePresent
Definition: doc.h:244
const char * MemorySemanticsString(int mem)
Definition: doc.cpp:627
Definition: doc.h:141
GLenum type
Definition: glext.h:6233
const char * ExecutionModeString(int mode)
Definition: doc.cpp:130
OpcodeClass opClass
Definition: doc.h:240
Definition: doc.h:132
Definition: doc.h:155
const char * ImageChannelTypeString(int)
EnumDefinition OperandClassParams[OperandCount]
Definition: doc.cpp:1237
const char * OpcodeString(int op)
Definition: doc.cpp:836
InstructionParameters()
Definition: doc.h:223
Definition: doc.h:149
void PrintImmediateRow(int imm, const char *name, const EnumParameters *enumParams, bool caps, bool hex=false)
const char * GetOperandDesc(OperandClass operand)
Definition: doc.h:200
Definition: doc.h:91
Definition: doc.h:124
void setOperands(OperandParameters *op)
Definition: doc.h:211
int getNum() const
Definition: doc.h:184
GLenum GLint GLuint mask
Definition: glext.h:6668
Definition: doc.h:101
const char * FPRoundingModeString(int mode)
Definition: doc.cpp:535
Definition: doc.h:123
const char * SamplerFilterModeString(int mode)
Definition: doc.cpp:376
Definition: doc.h:115
Definition: doc.h:148
const char * ImageChannelDataTypeString(int type)
Definition: doc.cpp:475
EnumDefinition()
Definition: doc.h:202
Definition: doc.h:99
Definition: doc.h:126
std::shared_ptr< Ope > opt(const std::shared_ptr< Ope > &ope)
Definition: peglib.h:1579
const char * FuncParamAttrString(int attr)
Definition: doc.cpp:557
static s32 hex(char ch)
Definition: debug.c:111
std::vector< const char * > desc
Definition: doc.h:188
Definition: doc.h:122
Definition: doc.h:140
Definition: doc.h:106
Definition: doc.h:157
bool isOptional(int op) const
Definition: doc.h:183
Definition: doc.h:108
const char * ExecutionModelString(int model)
Definition: doc.cpp:91
bool hasType() const
Definition: doc.h:237
void PrintOperands(const OperandParameters &operands, int reservedOperands)
Definition: doc.h:158
const char * CapabilityString(int info)
Definition: doc.cpp:713
EnumParameters()
Definition: doc.h:195
const char * getDesc(int op) const
Definition: doc.h:182
Definition: doc.h:128
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glext.h:6293
OperandClass
Definition: doc.h:120
Definition: doc.h:113
const char * LinkageTypeString(int type)
Definition: doc.cpp:547
std::vector< Capability > EnumCaps
Definition: doc.h:168
Definition: doc.h:164
const char * SelectControlString(int cont)
Definition: doc.cpp:586
Definition: doc.h:193
Definition: doc.h:135
const char * DecorationString(int decoration)
Definition: doc.cpp:196
void setResultAndType(bool r, bool t)
Definition: doc.h:230
const char * ImageOperandsString(int format)
Definition: doc.cpp:504
const char * MemoryString(int mem)
Definition: doc.cpp:117
Definition: doc.h:95
const char * ImageFormatString(int format)
Definition: doc.cpp:386
#define false
Definition: ordinals.h:83
const char * FPFastMathString(int mode)
Definition: doc.cpp:522
Definition: doc.h:151
Definition: doc.h:221
#define true
Definition: ordinals.h:82
int ceiling
Definition: doc.h:212
bool hasResult() const
Definition: doc.h:236
Definition: doc.h:171
Definition: doc.h:105
const char * BuiltInString(int builtIn)
Definition: doc.cpp:264
Definition: doc.h:139
Definition: doc.h:145
Definition: doc.h:109
const char * KernelEnqueueFlagsString(int flag)
Definition: doc.cpp:691
Definition: doc.h:153
Definition: doc.h:144
const char * ImageChannelOrderString(int format)
Definition: doc.cpp:447
Definition: doc.h:112
Definition: doc.h:152
Definition: doc.h:92
Definition: doc.h:121
const char * SamplerAddressingModeString(int mode)
Definition: doc.cpp:363
Definition: doc.h:159
Definition: doc.h:103