1// University of Illinois/NCSA
2// Open Source License
3//
4// Copyright (c) 2013-2015, Advanced Micro Devices, Inc.
5// All rights reserved.
6//
7// Developed by:
8//
9//     HSA Team
10//
11//     Advanced Micro Devices, Inc
12//
13//     www.amd.com
14//
15// Permission is hereby granted, free of charge, to any person obtaining a copy of
16// this software and associated documentation files (the "Software"), to deal with
17// the Software without restriction, including without limitation the rights to
18// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
19// of the Software, and to permit persons to whom the Software is furnished to do
20// so, subject to the following conditions:
21//
22//     * Redistributions of source code must retain the above copyright notice,
23//       this list of conditions and the following disclaimers.
24//
25//     * Redistributions in binary form must reproduce the above copyright notice,
26//       this list of conditions and the following disclaimers in the
27//       documentation and/or other materials provided with the distribution.
28//
29//     * Neither the names of the LLVM Team, University of Illinois at
30//       Urbana-Champaign, nor the names of its contributors may be used to
31//       endorse or promote products derived from this Software without specific
32//       prior written permission.
33//
34// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
36// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
37// CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
40// SOFTWARE.
41
42//.ignore{
43
44#ifndef INCLUDED_BRIG_H
45#define INCLUDED_BRIG_H
46
47#include <stdint.h>
48
49enum BrigAuxDefs {
50  MAX_OPERANDS_NUM = 6
51};
52
53//}
54
55typedef uint32_t BrigVersion32_t;
56
57enum BrigVersion {
58
59    //.nowrap
60    //.nodump
61    //.nollvm
62
63    BRIG_VERSION_HSAIL_MAJOR = 1,
64    BRIG_VERSION_HSAIL_MINOR = 0,
65    BRIG_VERSION_BRIG_MAJOR  = 1,
66    BRIG_VERSION_BRIG_MINOR  = 0
67};
68
69typedef uint8_t BrigAlignment8_t;                           //.defValue=BRIG_ALIGNMENT_NONE
70
71typedef uint8_t BrigAllocation8_t;                          //.defValue=BRIG_ALLOCATION_NONE
72
73typedef uint8_t BrigAluModifier8_t;
74
75typedef uint8_t BrigAtomicOperation8_t;
76
77typedef uint32_t BrigCodeOffset32_t;                        //.defValue=0   //.wtype=ItemRef<Code>
78
79typedef uint8_t BrigCompareOperation8_t;
80
81typedef uint16_t BrigControlDirective16_t;
82
83typedef uint32_t BrigDataOffset32_t;
84
85typedef BrigDataOffset32_t BrigDataOffsetCodeList32_t;      //.wtype=ListRef<Code>      //.defValue=0
86
87typedef BrigDataOffset32_t BrigDataOffsetOperandList32_t;   //.wtype=ListRef<Operand>   //.defValue=0
88
89typedef BrigDataOffset32_t BrigDataOffsetString32_t;        //.wtype=StrRef             //.defValue=0
90
91typedef uint8_t BrigExecutableModifier8_t;
92
93typedef uint8_t BrigImageChannelOrder8_t;                   //.defValue=BRIG_CHANNEL_ORDER_UNKNOWN
94
95typedef uint8_t BrigImageChannelType8_t;                    //.defValue=BRIG_CHANNEL_TYPE_UNKNOWN
96
97typedef uint8_t BrigImageGeometry8_t;                       //.defValue=BRIG_GEOMETRY_UNKNOWN
98
99typedef uint8_t BrigImageQuery8_t;
100
101typedef uint16_t BrigKind16_t;
102
103typedef uint8_t BrigLinkage8_t;                             //.defValue=BRIG_LINKAGE_NONE
104
105typedef uint8_t BrigMachineModel8_t;                        //.defValue=BRIG_MACHINE_LARGE
106
107typedef uint8_t BrigMemoryModifier8_t;
108
109typedef uint8_t BrigMemoryOrder8_t;                         //.defValue=BRIG_MEMORY_ORDER_RELAXED
110
111typedef uint8_t BrigMemoryScope8_t;                         //.defValue=BRIG_MEMORY_SCOPE_SYSTEM
112
113typedef uint16_t BrigOpcode16_t;
114
115typedef uint32_t BrigOperandOffset32_t;                     //.defValue=0 //.wtype=ItemRef<Operand>
116
117typedef uint8_t BrigPack8_t;                                //.defValue=BRIG_PACK_NONE
118
119typedef uint8_t BrigProfile8_t;                             //.defValue=BRIG_PROFILE_FULL
120
121typedef uint16_t BrigRegisterKind16_t;
122
123typedef uint8_t BrigRound8_t;                               //.defValue=BRIG_ROUND_NONE
124
125typedef uint8_t BrigSamplerAddressing8_t;                   //.defValue=BRIG_ADDRESSING_CLAMP_TO_EDGE
126
127typedef uint8_t BrigSamplerCoordNormalization8_t;
128
129typedef uint8_t BrigSamplerFilter8_t;
130
131typedef uint8_t BrigSamplerQuery8_t;
132
133typedef uint32_t BrigSectionIndex32_t;
134
135typedef uint8_t BrigSegCvtModifier8_t;
136
137typedef uint8_t BrigSegment8_t;                             //.defValue=BRIG_SEGMENT_NONE
138
139typedef uint32_t BrigStringOffset32_t;                      //.defValue=0       //.wtype=StrRef
140
141typedef uint16_t BrigType16_t;
142
143typedef uint8_t BrigVariableModifier8_t;
144
145typedef uint8_t BrigWidth8_t;
146
147typedef uint32_t BrigExceptions32_t;
148
149enum BrigKind {
150
151    //.nollvm
152    //
153    //.wname={ s/^BRIG_KIND//; MACRO2Name($_) }
154    //.mnemo=$wname{ $wname }
155    //
156    //.sizeof=$wname{ "sizeof(".$structs->{"Brig".$wname}->{rawbrig}.")" }
157    //.sizeof_switch //.sizeof_proto="int size_of_brig_record(unsigned arg)" //.sizeof_default="return -1"
158    //
159    //.isBodyOnly={ "false" }
160    //.isBodyOnly_switch //.isBodyOnly_proto="bool isBodyOnly(Directive d)" //.isBodyOnly_arg="d.kind()"
161    //.isBodyOnly_default="assert(false); return false"
162    //
163    //.isToplevelOnly={ "false" }
164    //.isToplevelOnly_switch //.isToplevelOnly_proto="bool isToplevelOnly(Directive d)" //.isToplevelOnly_arg="d.kind()"
165    //.isToplevelOnly_default="assert(false); return false"
166
167    BRIG_KIND_NONE = 0x0000,                        //.skip
168
169    BRIG_KIND_DIRECTIVE_BEGIN = 0x1000,             //.skip
170    BRIG_KIND_DIRECTIVE_ARG_BLOCK_END = 0x1000,     //.isBodyOnly=true
171    BRIG_KIND_DIRECTIVE_ARG_BLOCK_START = 0x1001,   //.isBodyOnly=true
172    BRIG_KIND_DIRECTIVE_COMMENT = 0x1002,
173    BRIG_KIND_DIRECTIVE_CONTROL = 0x1003,           //.isBodyOnly=true
174    BRIG_KIND_DIRECTIVE_EXTENSION = 0x1004,         //.isToplevelOnly=true
175    BRIG_KIND_DIRECTIVE_FBARRIER = 0x1005,
176    BRIG_KIND_DIRECTIVE_FUNCTION = 0x1006,          //.isToplevelOnly=true
177    BRIG_KIND_DIRECTIVE_INDIRECT_FUNCTION = 0x1007, //.isToplevelOnly=true
178    BRIG_KIND_DIRECTIVE_KERNEL = 0x1008,            //.isToplevelOnly=true
179    BRIG_KIND_DIRECTIVE_LABEL = 0x1009,             //.isBodyOnly=true
180    BRIG_KIND_DIRECTIVE_LOC = 0x100a,
181    BRIG_KIND_DIRECTIVE_MODULE = 0x100b,            //.isToplevelOnly=true
182    BRIG_KIND_DIRECTIVE_PRAGMA = 0x100c,
183    BRIG_KIND_DIRECTIVE_SIGNATURE = 0x100d,         //.isToplevelOnly=true
184    BRIG_KIND_DIRECTIVE_VARIABLE = 0x100e,
185    BRIG_KIND_DIRECTIVE_END = 0x100f,               //.skip
186
187    BRIG_KIND_INST_BEGIN = 0x2000,                  //.skip
188    BRIG_KIND_INST_ADDR = 0x2000,
189    BRIG_KIND_INST_ATOMIC = 0x2001,
190    BRIG_KIND_INST_BASIC = 0x2002,
191    BRIG_KIND_INST_BR = 0x2003,
192    BRIG_KIND_INST_CMP = 0x2004,
193    BRIG_KIND_INST_CVT = 0x2005,
194    BRIG_KIND_INST_IMAGE = 0x2006,
195    BRIG_KIND_INST_LANE = 0x2007,
196    BRIG_KIND_INST_MEM = 0x2008,
197    BRIG_KIND_INST_MEM_FENCE = 0x2009,
198    BRIG_KIND_INST_MOD = 0x200a,
199    BRIG_KIND_INST_QUERY_IMAGE = 0x200b,
200    BRIG_KIND_INST_QUERY_SAMPLER = 0x200c,
201    BRIG_KIND_INST_QUEUE = 0x200d,
202    BRIG_KIND_INST_SEG = 0x200e,
203    BRIG_KIND_INST_SEG_CVT = 0x200f,
204    BRIG_KIND_INST_SIGNAL = 0x2010,
205    BRIG_KIND_INST_SOURCE_TYPE = 0x2011,
206    BRIG_KIND_INST_END = 0x2012,                    //.skip
207
208    BRIG_KIND_OPERAND_BEGIN = 0x3000,               //.skip
209    BRIG_KIND_OPERAND_ADDRESS = 0x3000,
210    BRIG_KIND_OPERAND_ALIGN = 0x3001,
211    BRIG_KIND_OPERAND_CODE_LIST = 0x3002,
212    BRIG_KIND_OPERAND_CODE_REF = 0x3003,
213    BRIG_KIND_OPERAND_CONSTANT_BYTES = 0x3004,
214    BRIG_KIND_OPERAND_RESERVED = 0x3005, //.skip
215    BRIG_KIND_OPERAND_CONSTANT_IMAGE = 0x3006,
216    BRIG_KIND_OPERAND_CONSTANT_OPERAND_LIST = 0x3007,
217    BRIG_KIND_OPERAND_CONSTANT_SAMPLER = 0x3008,
218    BRIG_KIND_OPERAND_OPERAND_LIST = 0x3009,
219    BRIG_KIND_OPERAND_REGISTER = 0x300a,
220    BRIG_KIND_OPERAND_STRING = 0x300b,
221    BRIG_KIND_OPERAND_WAVESIZE = 0x300c,
222    BRIG_KIND_OPERAND_END = 0x300d                  //.skip
223};
224
225enum BrigAlignment {
226
227    //.mnemo={ s/^BRIG_ALIGNMENT_//; lc }
228    //.mnemo_proto="const char* align2str(unsigned arg)"
229    //
230    //.bytes={ /(\d+)/ ? $1 : undef }
231    //.bytes_switch //.bytes_proto="unsigned align2num(unsigned arg)" //.bytes_default="assert(false); return -1"
232    //
233    //.rbytes=$bytes{ $bytes }
234    //.rbytes_switch //.rbytes_reverse //.rbytes_proto="BrigAlignment num2align(uint64_t arg)"
235    //.rbytes_default="return BRIG_ALIGNMENT_LAST"
236    //
237    //.print=$bytes{ $bytes>1 ? "_align($bytes)" : "" }
238
239    BRIG_ALIGNMENT_NONE = 0,                        //.no_mnemo
240    BRIG_ALIGNMENT_1 = 1,                           //.mnemo=""
241    BRIG_ALIGNMENT_2 = 2,
242    BRIG_ALIGNMENT_4 = 3,
243    BRIG_ALIGNMENT_8 = 4,
244    BRIG_ALIGNMENT_16 = 5,
245    BRIG_ALIGNMENT_32 = 6,
246    BRIG_ALIGNMENT_64 = 7,
247    BRIG_ALIGNMENT_128 = 8,
248    BRIG_ALIGNMENT_256 = 9,
249
250    BRIG_ALIGNMENT_LAST,                            //.skip
251    BRIG_ALIGNMENT_MAX = BRIG_ALIGNMENT_LAST - 1    //.skip
252};
253
254enum BrigAllocation {
255
256    //.mnemo={ s/^BRIG_ALLOCATION_//;lc }
257    //.mnemo_token=EAllocKind
258
259    BRIG_ALLOCATION_NONE = 0,       //.mnemo=""
260    BRIG_ALLOCATION_PROGRAM = 1,
261    BRIG_ALLOCATION_AGENT = 2,
262    BRIG_ALLOCATION_AUTOMATIC = 3
263};
264
265enum BrigAluModifierMask {
266    BRIG_ALU_FTZ = 1
267};
268
269enum BrigAtomicOperation {
270
271    //.tdcaption="Atomic Operations"
272    //
273    //.mnemo={ s/^BRIG_ATOMIC_//;lc }
274    //.mnemo_token=_EMAtomicOp
275    //.mnemo_context=EInstModifierInstAtomicContext
276    //
277    //.print=$mnemo{ "_$mnemo" }
278
279    BRIG_ATOMIC_ADD = 0,
280    BRIG_ATOMIC_AND = 1,
281    BRIG_ATOMIC_CAS = 2,
282    BRIG_ATOMIC_EXCH = 3,
283    BRIG_ATOMIC_LD = 4,
284    BRIG_ATOMIC_MAX = 5,
285    BRIG_ATOMIC_MIN = 6,
286    BRIG_ATOMIC_OR = 7,
287    BRIG_ATOMIC_ST = 8,
288    BRIG_ATOMIC_SUB = 9,
289    BRIG_ATOMIC_WRAPDEC = 10,
290    BRIG_ATOMIC_WRAPINC = 11,
291    BRIG_ATOMIC_XOR = 12,
292    BRIG_ATOMIC_WAIT_EQ = 13,
293    BRIG_ATOMIC_WAIT_NE = 14,
294    BRIG_ATOMIC_WAIT_LT = 15,
295    BRIG_ATOMIC_WAIT_GTE = 16,
296    BRIG_ATOMIC_WAITTIMEOUT_EQ = 17,
297    BRIG_ATOMIC_WAITTIMEOUT_NE = 18,
298    BRIG_ATOMIC_WAITTIMEOUT_LT = 19,
299    BRIG_ATOMIC_WAITTIMEOUT_GTE = 20
300};
301
302enum BrigCompareOperation {
303
304    //.tdcaption="Comparison Operators"
305    //
306    //.mnemo={ s/^BRIG_COMPARE_//;lc }
307    //.mnemo_token=_EMCompare
308    //
309    //.print=$mnemo{ "_$mnemo" }
310
311    BRIG_COMPARE_EQ = 0,
312    BRIG_COMPARE_NE = 1,
313    BRIG_COMPARE_LT = 2,
314    BRIG_COMPARE_LE = 3,
315    BRIG_COMPARE_GT = 4,
316    BRIG_COMPARE_GE = 5,
317    BRIG_COMPARE_EQU = 6,
318    BRIG_COMPARE_NEU = 7,
319    BRIG_COMPARE_LTU = 8,
320    BRIG_COMPARE_LEU = 9,
321    BRIG_COMPARE_GTU = 10,
322    BRIG_COMPARE_GEU = 11,
323    BRIG_COMPARE_NUM = 12,
324    BRIG_COMPARE_NAN = 13,
325    BRIG_COMPARE_SEQ = 14,
326    BRIG_COMPARE_SNE = 15,
327    BRIG_COMPARE_SLT = 16,
328    BRIG_COMPARE_SLE = 17,
329    BRIG_COMPARE_SGT = 18,
330    BRIG_COMPARE_SGE = 19,
331    BRIG_COMPARE_SGEU = 20,
332    BRIG_COMPARE_SEQU = 21,
333    BRIG_COMPARE_SNEU = 22,
334    BRIG_COMPARE_SLTU = 23,
335    BRIG_COMPARE_SLEU = 24,
336    BRIG_COMPARE_SNUM = 25,
337    BRIG_COMPARE_SNAN = 26,
338    BRIG_COMPARE_SGTU = 27
339};
340
341enum BrigControlDirective {
342
343    //.mnemo={ s/^BRIG_CONTROL_//;lc }
344    //.mnemo_token=EControl
345    //
346    //.print=$mnemo{ $mnemo }
347
348    BRIG_CONTROL_NONE = 0, //.skip
349    BRIG_CONTROL_ENABLEBREAKEXCEPTIONS = 1,
350    BRIG_CONTROL_ENABLEDETECTEXCEPTIONS = 2,
351    BRIG_CONTROL_MAXDYNAMICGROUPSIZE = 3,
352    BRIG_CONTROL_MAXFLATGRIDSIZE = 4,
353    BRIG_CONTROL_MAXFLATWORKGROUPSIZE = 5,
354    BRIG_CONTROL_REQUIREDDIM = 6,
355    BRIG_CONTROL_REQUIREDGRIDSIZE = 7,
356    BRIG_CONTROL_REQUIREDWORKGROUPSIZE = 8,
357    BRIG_CONTROL_REQUIRENOPARTIALWORKGROUPS = 9
358};
359
360enum BrigExecutableModifierMask {
361    //.nodump
362    BRIG_EXECUTABLE_DEFINITION = 1
363};
364
365enum BrigImageChannelOrder {
366
367    //.mnemo={ s/^BRIG_CHANNEL_ORDER_?//;lc }
368    //.mnemo_token=EImageOrder
369    //.mnemo_context=EImageOrderContext
370    //
371    //.print=$mnemo{ $mnemo }
372
373    BRIG_CHANNEL_ORDER_A = 0,
374    BRIG_CHANNEL_ORDER_R = 1,
375    BRIG_CHANNEL_ORDER_RX = 2,
376    BRIG_CHANNEL_ORDER_RG = 3,
377    BRIG_CHANNEL_ORDER_RGX = 4,
378    BRIG_CHANNEL_ORDER_RA = 5,
379    BRIG_CHANNEL_ORDER_RGB = 6,
380    BRIG_CHANNEL_ORDER_RGBX = 7,
381    BRIG_CHANNEL_ORDER_RGBA = 8,
382    BRIG_CHANNEL_ORDER_BGRA = 9,
383    BRIG_CHANNEL_ORDER_ARGB = 10,
384    BRIG_CHANNEL_ORDER_ABGR = 11,
385    BRIG_CHANNEL_ORDER_SRGB = 12,
386    BRIG_CHANNEL_ORDER_SRGBX = 13,
387    BRIG_CHANNEL_ORDER_SRGBA = 14,
388    BRIG_CHANNEL_ORDER_SBGRA = 15,
389    BRIG_CHANNEL_ORDER_INTENSITY = 16,
390    BRIG_CHANNEL_ORDER_LUMINANCE = 17,
391    BRIG_CHANNEL_ORDER_DEPTH = 18,
392    BRIG_CHANNEL_ORDER_DEPTH_STENCIL = 19,
393
394    // used internally
395    BRIG_CHANNEL_ORDER_UNKNOWN, //.mnemo="" // used when no order is specified
396
397    BRIG_CHANNEL_ORDER_FIRST_USER_DEFINED = 128 //.skip
398
399};
400
401enum BrigImageChannelType {
402
403    //.mnemo={ s/^BRIG_CHANNEL_TYPE_//;lc }
404    //.mnemo_token=EImageFormat
405    //
406    //.print=$mnemo{ $mnemo }
407
408    BRIG_CHANNEL_TYPE_SNORM_INT8 = 0,
409    BRIG_CHANNEL_TYPE_SNORM_INT16 = 1,
410    BRIG_CHANNEL_TYPE_UNORM_INT8 = 2,
411    BRIG_CHANNEL_TYPE_UNORM_INT16 = 3,
412    BRIG_CHANNEL_TYPE_UNORM_INT24 = 4,
413    BRIG_CHANNEL_TYPE_UNORM_SHORT_555 = 5,
414    BRIG_CHANNEL_TYPE_UNORM_SHORT_565 = 6,
415    BRIG_CHANNEL_TYPE_UNORM_INT_101010 = 7,
416    BRIG_CHANNEL_TYPE_SIGNED_INT8 = 8,
417    BRIG_CHANNEL_TYPE_SIGNED_INT16 = 9,
418    BRIG_CHANNEL_TYPE_SIGNED_INT32 = 10,
419    BRIG_CHANNEL_TYPE_UNSIGNED_INT8 = 11,
420    BRIG_CHANNEL_TYPE_UNSIGNED_INT16 = 12,
421    BRIG_CHANNEL_TYPE_UNSIGNED_INT32 = 13,
422    BRIG_CHANNEL_TYPE_HALF_FLOAT = 14,
423    BRIG_CHANNEL_TYPE_FLOAT = 15,
424
425    // used internally
426    BRIG_CHANNEL_TYPE_UNKNOWN, //.mnemo=""
427
428    BRIG_CHANNEL_TYPE_FIRST_USER_DEFINED = 128 //.skip
429};
430
431enum BrigImageGeometry {
432
433    //.tdcaption="Geometry"
434    //
435    //.mnemo={ s/^BRIG_GEOMETRY_//;lc }
436    //.mnemo_token=EImageGeometry
437    //
438    //.dim={/_([0-9]+D)(A)?/ ? $1+(defined $2?1:0) : undef}
439    //.dim_switch //.dim_proto="unsigned getBrigGeometryDim(unsigned geo)" //.dim_arg="geo"
440    //.dim_default="assert(0); return 0"
441    //
442    //.depth={/DEPTH$/?"true":"false"}
443    //.depth_switch //.depth_proto="bool isBrigGeometryDepth(unsigned geo)" //.depth_arg="geo"
444    //.depth_default="return false"
445
446    BRIG_GEOMETRY_1D = 0,
447    BRIG_GEOMETRY_2D = 1,
448    BRIG_GEOMETRY_3D = 2,
449    BRIG_GEOMETRY_1DA = 3,
450    BRIG_GEOMETRY_2DA = 4,
451    BRIG_GEOMETRY_1DB = 5,
452    BRIG_GEOMETRY_2DDEPTH = 6,
453    BRIG_GEOMETRY_2DADEPTH = 7,
454
455    // used internally
456    BRIG_GEOMETRY_UNKNOWN, //.mnemo=""
457
458    BRIG_GEOMETRY_FIRST_USER_DEFINED = 128 //.skip
459};
460
461enum BrigImageQuery {
462
463    //.mnemo={ s/^BRIG_IMAGE_QUERY_//;lc }
464    //
465    //.print=$mnemo{ $mnemo }
466
467    BRIG_IMAGE_QUERY_WIDTH = 0,
468    BRIG_IMAGE_QUERY_HEIGHT = 1,
469    BRIG_IMAGE_QUERY_DEPTH = 2,
470    BRIG_IMAGE_QUERY_ARRAY = 3,
471    BRIG_IMAGE_QUERY_CHANNELORDER = 4,
472    BRIG_IMAGE_QUERY_CHANNELTYPE = 5,
473    BRIG_IMAGE_QUERY_NUMMIPLEVELS = 6
474};
475
476enum BrigLinkage {
477
478    //.mnemo={ s/^BRIG_LINKAGE_//;s/NONE//;lc }
479
480    BRIG_LINKAGE_NONE = 0,
481    BRIG_LINKAGE_PROGRAM = 1,
482    BRIG_LINKAGE_MODULE = 2,
483    BRIG_LINKAGE_FUNCTION = 3,
484    BRIG_LINKAGE_ARG = 4
485};
486
487enum BrigMachineModel {
488
489    //.mnemo={ s/^BRIG_MACHINE_//; '$'.lc }
490    //.mnemo_token=ETargetMachine
491    //
492    //.print=$mnemo{ $mnemo }
493
494    BRIG_MACHINE_SMALL = 0,
495    BRIG_MACHINE_LARGE = 1,
496
497    BRIG_MACHINE_UNDEF = 2 //.skip
498};
499
500enum BrigMemoryModifierMask { //.tddef=0
501    BRIG_MEMORY_CONST = 1
502};
503
504enum BrigMemoryOrder {
505
506    //.mnemo={ s/^BRIG_MEMORY_ORDER_//; lc }
507    //.mnemo_token=_EMMemoryOrder
508    //
509    //.print=$mnemo{ "_$mnemo" }
510
511    BRIG_MEMORY_ORDER_NONE = 0,                 //.mnemo=""
512    BRIG_MEMORY_ORDER_RELAXED = 1,              //.mnemo=rlx
513    BRIG_MEMORY_ORDER_SC_ACQUIRE = 2,           //.mnemo=scacq
514    BRIG_MEMORY_ORDER_SC_RELEASE = 3,           //.mnemo=screl
515    BRIG_MEMORY_ORDER_SC_ACQUIRE_RELEASE = 4,   //.mnemo=scar
516
517    BRIG_MEMORY_ORDER_LAST = 5 //.skip
518};
519
520enum BrigMemoryScope {
521
522    //.mnemo={ s/^BRIG_MEMORY_SCOPE_//; lc }
523    //.mnemo_token=_EMMemoryScope
524    //
525    //.print=$mnemo{ $mnemo }
526
527    BRIG_MEMORY_SCOPE_NONE = 0,         //.mnemo=""
528    BRIG_MEMORY_SCOPE_WORKITEM = 1,     //.mnemo=""
529    BRIG_MEMORY_SCOPE_WAVEFRONT = 2,    //.mnemo=wave
530    BRIG_MEMORY_SCOPE_WORKGROUP = 3,    //.mnemo=wg
531    BRIG_MEMORY_SCOPE_AGENT = 4,        //.mnemo=agent
532    BRIG_MEMORY_SCOPE_SYSTEM = 5,       //.mnemo=system
533
534    BRIG_MEMORY_SCOPE_LAST = 6 //.skip
535};
536
537enum BrigOpcode {
538
539    //.tdcaption="Instruction Opcodes"
540    //
541    //.k={ "BASIC" }
542    //.pscode=$k{ MACRO2Name("_".$k) }
543    //.opcodeparser=$pscode{ return $pscode && "parseMnemo$pscode" }
544    //.opcodeparser_incfile=ParserUtilities
545    //.opcodeparser_switch //.opcodeparser_proto="OpcodeParser getOpcodeParser(BrigOpcode16_t arg)" //.opcodeparser_default="return parseMnemoBasic"
546    //
547    //.psopnd={undef}
548    //.opndparser=$psopnd{ return $psopnd && "&Parser::parse$psopnd" }
549    //.opndparser_incfile=ParserUtilities
550    //.opndparser_switch //.opndparser_proto="Parser::OperandParser Parser::getOperandParser(BrigOpcode16_t arg)" //.opndparser_default="return &Parser::parseOperands"
551    //
552    //.mnemo={ s/^BRIG_OPCODE_//; s/GCN([^_])/GCN_$1/; lc }
553    //.mnemo_scanner=Instructions //.mnemo_token=EInstruction
554    //.mnemo_context=EDefaultContext
555    //
556    //.has_memory_order={undef}
557    //.semsupport=$has_memory_order{ return $has_memory_order && "true" }
558    //
559    //.hasType=$k{ return ($k and $k eq "BASIC_NO_TYPE") ? "false" : undef; }
560    //.hasType_switch //.hasType_proto="bool instHasType(BrigOpcode16_t arg)" //.hasType_default="return true"
561    //
562    //.opcodevis=$pscode{ s/^BRIG_OPCODE_//; sprintf("%-47s(","vis.visitOpcode_".$_) . ($pscode =~m/^(BasicOrMod|Nop)$/? "inst" : "HSAIL_ASM::Inst". ($pscode=~m/BasicNoType/? "Basic":$pscode) ."(inst)").")" }
563    //.opcodevis_switch //.opcodevis_proto="template <typename RetType, typename Visitor> RetType visitOpcode_gen(HSAIL_ASM::Inst inst, Visitor& vis)"
564    //.opcodevis_arg="inst.opcode()" //.opcodevis_default="return RetType()"
565    //.opcodevis_incfile=ItemUtils
566    //
567    //.ftz=$k{ return ($k eq "BASIC_OR_MOD" or $k eq "CMP" or $k eq "CVT") ? "true" : undef }
568    //.ftz_incfile=ItemUtils //.ftz_switch //.ftz_proto="inline bool instSupportsFtz(BrigOpcode16_t arg)" //.ftz_default="return false"
569    //
570    //.vecOpndIndex={undef}
571    //.vecOpndIndex_switch  //.vecOpndIndex_proto="int vecOpndIndex(BrigOpcode16_t arg)" //.vecOpndIndex_default="return -1"
572    //.vecOpndIndex_incfile=ParserUtilities
573    //
574    //.numdst={undef}
575    //.numdst_switch //.numdst_proto="int instNumDstOperands(BrigOpcode16_t arg)" //.numdst_default="return 1"
576    //
577    //.print=$mnemo{ $mnemo }
578
579    BRIG_OPCODE_NOP = 0,                    //.k=NOP            //.hasType=false
580    BRIG_OPCODE_ABS = 1,                    //.k=BASIC_OR_MOD
581    BRIG_OPCODE_ADD = 2,                    //.k=BASIC_OR_MOD
582    BRIG_OPCODE_BORROW = 3,
583    BRIG_OPCODE_CARRY = 4,
584    BRIG_OPCODE_CEIL = 5,                   //.k=BASIC_OR_MOD
585    BRIG_OPCODE_COPYSIGN = 6,               //.k=BASIC_OR_MOD
586    BRIG_OPCODE_DIV = 7,                    //.k=BASIC_OR_MOD
587    BRIG_OPCODE_FLOOR = 8,                  //.k=BASIC_OR_MOD
588    BRIG_OPCODE_FMA = 9,                    //.k=BASIC_OR_MOD
589    BRIG_OPCODE_FRACT = 10,                 //.k=BASIC_OR_MOD
590    BRIG_OPCODE_MAD = 11,                   //.k=BASIC_OR_MOD
591    BRIG_OPCODE_MAX = 12,                   //.k=BASIC_OR_MOD
592    BRIG_OPCODE_MIN = 13,                   //.k=BASIC_OR_MOD
593    BRIG_OPCODE_MUL = 14,                   //.k=BASIC_OR_MOD
594    BRIG_OPCODE_MULHI = 15,                 //.k=BASIC_OR_MOD
595    BRIG_OPCODE_NEG = 16,                   //.k=BASIC_OR_MOD
596    BRIG_OPCODE_REM = 17,
597    BRIG_OPCODE_RINT = 18,                  //.k=BASIC_OR_MOD
598    BRIG_OPCODE_SQRT = 19,                  //.k=BASIC_OR_MOD
599    BRIG_OPCODE_SUB = 20,                   //.k=BASIC_OR_MOD
600    BRIG_OPCODE_TRUNC = 21,                 //.k=BASIC_OR_MOD
601    BRIG_OPCODE_MAD24 = 22,
602    BRIG_OPCODE_MAD24HI = 23,
603    BRIG_OPCODE_MUL24 = 24,
604    BRIG_OPCODE_MUL24HI = 25,
605    BRIG_OPCODE_SHL = 26,
606    BRIG_OPCODE_SHR = 27,
607    BRIG_OPCODE_AND = 28,
608    BRIG_OPCODE_NOT = 29,
609    BRIG_OPCODE_OR = 30,
610    BRIG_OPCODE_POPCOUNT = 31,              //.k=SOURCE_TYPE
611    BRIG_OPCODE_XOR = 32,
612    BRIG_OPCODE_BITEXTRACT = 33,
613    BRIG_OPCODE_BITINSERT = 34,
614    BRIG_OPCODE_BITMASK = 35,
615    BRIG_OPCODE_BITREV = 36,
616    BRIG_OPCODE_BITSELECT = 37,
617    BRIG_OPCODE_FIRSTBIT = 38,              //.k=SOURCE_TYPE
618    BRIG_OPCODE_LASTBIT = 39,               //.k=SOURCE_TYPE
619    BRIG_OPCODE_COMBINE = 40,               //.k=SOURCE_TYPE    //.vecOpndIndex=1
620    BRIG_OPCODE_EXPAND = 41,                //.k=SOURCE_TYPE    //.vecOpndIndex=0
621    BRIG_OPCODE_LDA = 42,                   //.k=ADDR
622    BRIG_OPCODE_MOV = 43,
623    BRIG_OPCODE_SHUFFLE = 44,
624    BRIG_OPCODE_UNPACKHI = 45,
625    BRIG_OPCODE_UNPACKLO = 46,
626    BRIG_OPCODE_PACK = 47,                  //.k=SOURCE_TYPE
627    BRIG_OPCODE_UNPACK = 48,                //.k=SOURCE_TYPE
628    BRIG_OPCODE_CMOV = 49,
629    BRIG_OPCODE_CLASS = 50,                 //.k=SOURCE_TYPE
630    BRIG_OPCODE_NCOS = 51,
631    BRIG_OPCODE_NEXP2 = 52,
632    BRIG_OPCODE_NFMA = 53,
633    BRIG_OPCODE_NLOG2 = 54,
634    BRIG_OPCODE_NRCP = 55,
635    BRIG_OPCODE_NRSQRT = 56,
636    BRIG_OPCODE_NSIN = 57,
637    BRIG_OPCODE_NSQRT = 58,
638    BRIG_OPCODE_BITALIGN = 59,
639    BRIG_OPCODE_BYTEALIGN = 60,
640    BRIG_OPCODE_PACKCVT = 61,               //.k=SOURCE_TYPE
641    BRIG_OPCODE_UNPACKCVT = 62,             //.k=SOURCE_TYPE
642    BRIG_OPCODE_LERP = 63,
643    BRIG_OPCODE_SAD = 64,                   //.k=SOURCE_TYPE
644    BRIG_OPCODE_SADHI = 65,                 //.k=SOURCE_TYPE
645    BRIG_OPCODE_SEGMENTP = 66,              //.k=SEG_CVT
646    BRIG_OPCODE_FTOS = 67,                  //.k=SEG_CVT
647    BRIG_OPCODE_STOF = 68,                  //.k=SEG_CVT
648    BRIG_OPCODE_CMP = 69,                   //.k=CMP
649    BRIG_OPCODE_CVT = 70,                   //.k=CVT
650    BRIG_OPCODE_LD = 71,                    //.k=MEM            //.has_memory_order //.vecOpndIndex=0
651    BRIG_OPCODE_ST = 72,                    //.k=MEM            //.has_memory_order //.vecOpndIndex=0 //.numdst=0
652    BRIG_OPCODE_ATOMIC = 73,                //.k=ATOMIC
653    BRIG_OPCODE_ATOMICNORET = 74,           //.k=ATOMIC         //.numdst=0
654    BRIG_OPCODE_SIGNAL = 75,                //.k=SIGNAL
655    BRIG_OPCODE_SIGNALNORET = 76,           //.k=SIGNAL         //.numdst=0
656    BRIG_OPCODE_MEMFENCE = 77,              //.k=MEM_FENCE      //.numdst=0
657    BRIG_OPCODE_RDIMAGE = 78,               //.k=IMAGE          //.vecOpndIndex=0
658    BRIG_OPCODE_LDIMAGE = 79,               //.k=IMAGE          //.vecOpndIndex=0
659    BRIG_OPCODE_STIMAGE = 80,               //.k=IMAGE          //.vecOpndIndex=0 //.numdst=0
660    BRIG_OPCODE_IMAGEFENCE = 81,            //.k=BASIC_NO_TYPE
661    BRIG_OPCODE_QUERYIMAGE = 82,            //.k=QUERY_IMAGE
662    BRIG_OPCODE_QUERYSAMPLER = 83,          //.k=QUERY_SAMPLER
663    BRIG_OPCODE_CBR = 84,                   //.k=BR             //.numdst=0
664    BRIG_OPCODE_BR = 85,                    //.k=BR             //.numdst=0     //.hasType=false
665    BRIG_OPCODE_SBR = 86,                   //.k=BR             //.numdst=0     //.psopnd=SbrOperands
666    BRIG_OPCODE_BARRIER = 87,               //.k=BR             //.numdst=0     //.hasType=false
667    BRIG_OPCODE_WAVEBARRIER = 88,           //.k=BR             //.numdst=0     //.hasType=false
668    BRIG_OPCODE_ARRIVEFBAR = 89,            //.k=BR             //.numdst=0     //.hasType=false
669    BRIG_OPCODE_INITFBAR = 90,              //.k=BASIC_NO_TYPE  //.numdst=0     //.hasType=false
670    BRIG_OPCODE_JOINFBAR = 91,              //.k=BR             //.numdst=0     //.hasType=false
671    BRIG_OPCODE_LEAVEFBAR = 92,             //.k=BR             //.numdst=0     //.hasType=false
672    BRIG_OPCODE_RELEASEFBAR = 93,           //.k=BASIC_NO_TYPE  //.numdst=0
673    BRIG_OPCODE_WAITFBAR = 94,              //.k=BR             //.numdst=0     //.hasType=false
674    BRIG_OPCODE_LDF = 95,
675    BRIG_OPCODE_ACTIVELANECOUNT = 96,       //.k=LANE
676    BRIG_OPCODE_ACTIVELANEID = 97,          //.k=LANE
677    BRIG_OPCODE_ACTIVELANEMASK = 98,        //.k=LANE           //.vecOpndIndex=0
678    BRIG_OPCODE_ACTIVELANEPERMUTE = 99,     //.k=LANE
679    BRIG_OPCODE_CALL = 100,                 //.k=BR             //.psopnd=CallOperands //.numdst=0 //.hasType=false
680    BRIG_OPCODE_SCALL = 101,                //.k=BR             //.psopnd=CallOperands //.numdst=0
681    BRIG_OPCODE_ICALL = 102,                //.k=BR             //.psopnd=CallOperands //.numdst=0
682    BRIG_OPCODE_RET = 103,                  //.k=BASIC_NO_TYPE
683    BRIG_OPCODE_ALLOCA = 104,               //.k=MEM
684    BRIG_OPCODE_CURRENTWORKGROUPSIZE = 105,
685    BRIG_OPCODE_CURRENTWORKITEMFLATID = 106,
686    BRIG_OPCODE_DIM = 107,
687    BRIG_OPCODE_GRIDGROUPS = 108,
688    BRIG_OPCODE_GRIDSIZE = 109,
689    BRIG_OPCODE_PACKETCOMPLETIONSIG = 110,
690    BRIG_OPCODE_PACKETID = 111,
691    BRIG_OPCODE_WORKGROUPID = 112,
692    BRIG_OPCODE_WORKGROUPSIZE = 113,
693    BRIG_OPCODE_WORKITEMABSID = 114,
694    BRIG_OPCODE_WORKITEMFLATABSID = 115,
695    BRIG_OPCODE_WORKITEMFLATID = 116,
696    BRIG_OPCODE_WORKITEMID = 117,
697    BRIG_OPCODE_CLEARDETECTEXCEPT = 118,    //.numdst=0
698    BRIG_OPCODE_GETDETECTEXCEPT = 119,
699    BRIG_OPCODE_SETDETECTEXCEPT = 120,      //.numdst=0
700    BRIG_OPCODE_ADDQUEUEWRITEINDEX = 121,   //.k=QUEUE
701    BRIG_OPCODE_CASQUEUEWRITEINDEX = 122,   //.k=QUEUE
702    BRIG_OPCODE_LDQUEUEREADINDEX = 123,     //.k=QUEUE
703    BRIG_OPCODE_LDQUEUEWRITEINDEX = 124,    //.k=QUEUE
704    BRIG_OPCODE_STQUEUEREADINDEX = 125,     //.k=QUEUE      //.numdst=0
705    BRIG_OPCODE_STQUEUEWRITEINDEX = 126,    //.k=QUEUE      //.numdst=0
706    BRIG_OPCODE_CLOCK = 127,
707    BRIG_OPCODE_CUID = 128,
708    BRIG_OPCODE_DEBUGTRAP = 129,            //.numdst=0
709    BRIG_OPCODE_GROUPBASEPTR = 130,
710    BRIG_OPCODE_KERNARGBASEPTR = 131,
711    BRIG_OPCODE_LANEID = 132,
712    BRIG_OPCODE_MAXCUID = 133,
713    BRIG_OPCODE_MAXWAVEID = 134,
714    BRIG_OPCODE_NULLPTR = 135,              //.k=SEG
715    BRIG_OPCODE_WAVEID = 136,
716    BRIG_OPCODE_FIRST_USER_DEFINED = 32768, //.skip
717
718    BRIG_OPCODE_GCNMADU = (1u << 15) | 0,           //.k=BASIC_NO_TYPE
719    BRIG_OPCODE_GCNMADS = (1u << 15) | 1,           //.k=BASIC_NO_TYPE
720    BRIG_OPCODE_GCNMAX3 = (1u << 15) | 2,
721    BRIG_OPCODE_GCNMIN3 = (1u << 15) | 3,
722    BRIG_OPCODE_GCNMED3 = (1u << 15) | 4,
723    BRIG_OPCODE_GCNFLDEXP = (1u << 15) | 5,         //.k=BASIC_OR_MOD
724    BRIG_OPCODE_GCNFREXP_EXP = (1u << 15) | 6,      //.k=BASIC_OR_MOD
725    BRIG_OPCODE_GCNFREXP_MANT = (1u << 15) | 7,     //.k=BASIC_OR_MOD
726    BRIG_OPCODE_GCNTRIG_PREOP = (1u << 15) | 8,     //.k=BASIC_OR_MOD
727    BRIG_OPCODE_GCNBFM = (1u << 15) | 9,
728    BRIG_OPCODE_GCNLD = (1u << 15) | 10,            //.k=MEM            //.has_memory_order //.vecOpndIndex=0
729    BRIG_OPCODE_GCNST = (1u << 15) | 11,            //.k=MEM            //.has_memory_order //.vecOpndIndex=0
730    BRIG_OPCODE_GCNATOMIC = (1u << 15) | 12,        //.k=ATOMIC
731    BRIG_OPCODE_GCNATOMICNORET = (1u << 15) | 13,   //.k=ATOMIC         //.mnemo=gcn_atomicNoRet
732    BRIG_OPCODE_GCNSLEEP = (1u << 15) | 14,
733    BRIG_OPCODE_GCNPRIORITY = (1u << 15) | 15,
734    BRIG_OPCODE_GCNREGIONALLOC = (1u << 15) | 16,   //.k=BASIC_NO_TYPE //.mnemo=gcn_region_alloc
735    BRIG_OPCODE_GCNMSAD = (1u << 15) | 17,
736    BRIG_OPCODE_GCNQSAD = (1u << 15) | 18,
737    BRIG_OPCODE_GCNMQSAD = (1u << 15) | 19,
738    BRIG_OPCODE_GCNMQSAD4 = (1u << 15) | 20,        //.k=BASIC_NO_TYPE
739    BRIG_OPCODE_GCNSADW = (1u << 15) | 21,
740    BRIG_OPCODE_GCNSADD = (1u << 15) | 22,
741    BRIG_OPCODE_GCNCONSUME = (1u << 15) | 23,       //.k=ADDR           //.mnemo=gcn_atomic_consume
742    BRIG_OPCODE_GCNAPPEND = (1u << 15) | 24,        //.k=ADDR           //.mnemo=gcn_atomic_append
743    BRIG_OPCODE_GCNB4XCHG = (1u << 15) | 25,        //.mnemo=gcn_b4xchg
744    BRIG_OPCODE_GCNB32XCHG = (1u << 15) | 26,       //.mnemo=gcn_b32xchg
745    BRIG_OPCODE_GCNMAX = (1u << 15) | 27,
746    BRIG_OPCODE_GCNMIN = (1u << 15) | 28,
747    BRIG_OPCODE_GCNDIVRELAXED = (1u << 15) | 29,    //.k=BASIC_OR_MOD
748    BRIG_OPCODE_GCNDIVRELAXEDNARROW = (1u << 15) | 30,
749
750    BRIG_OPCODE_AMDRDIMAGELOD  = (1u << 15) | 31,    //.k=IMAGE //.mnemo=amd_rdimagelod  //.vecOpndIndex=0
751    BRIG_OPCODE_AMDRDIMAGEGRAD = (1u << 15) | 32,    //.k=IMAGE //.mnemo=amd_rdimagegrad //.vecOpndIndex=0
752    BRIG_OPCODE_AMDLDIMAGEMIP  = (1u << 15) | 33,    //.k=IMAGE //.mnemo=amd_ldimagemip //.vecOpndIndex=0
753    BRIG_OPCODE_AMDSTIMAGEMIP  = (1u << 15) | 34,    //.k=IMAGE //.mnemo=amd_stimagemip //.vecOpndIndex=0 //.numdst=0
754    BRIG_OPCODE_AMDQUERYIMAGE  = (1u << 15) | 35     //.k=QUERY_IMAGE //.mnemo=amd_queryimage
755};
756
757enum BrigPack {
758
759    //.tdcaption="Packing"
760    //
761    //.mnemo={ s/^BRIG_PACK_//;s/SAT$/_sat/;lc }
762    //.mnemo_token=_EMPacking
763    //
764    //.print=$mnemo{ "_$mnemo" }
765
766    BRIG_PACK_NONE = 0, //.mnemo=""
767    BRIG_PACK_PP = 1,
768    BRIG_PACK_PS = 2,
769    BRIG_PACK_SP = 3,
770    BRIG_PACK_SS = 4,
771    BRIG_PACK_S = 5,
772    BRIG_PACK_P = 6,
773    BRIG_PACK_PPSAT = 7,
774    BRIG_PACK_PSSAT = 8,
775    BRIG_PACK_SPSAT = 9,
776    BRIG_PACK_SSSAT = 10,
777    BRIG_PACK_SSAT = 11,
778    BRIG_PACK_PSAT = 12
779};
780
781enum BrigProfile {
782
783    //.mnemo={ s/^BRIG_PROFILE_//;'$'.lc }
784    //.mnemo_token=ETargetProfile
785    //
786    //.print=$mnemo{ $mnemo }
787
788    BRIG_PROFILE_BASE = 0,
789    BRIG_PROFILE_FULL = 1,
790
791    BRIG_PROFILE_UNDEF = 2 //.skip
792};
793
794enum BrigRegisterKind {
795
796    //.mnemo={ s/^BRIG_REGISTER_KIND_//;'$'.lc(substr($_,0,1)) }
797    //
798    //.bits={ }
799    //.bits_switch //.bits_proto="unsigned getRegBits(BrigRegisterKind16_t arg)" //.bits_default="return (unsigned)-1"
800    //
801    //.nollvm
802
803    BRIG_REGISTER_KIND_CONTROL = 0, //.bits=1
804    BRIG_REGISTER_KIND_SINGLE = 1,  //.bits=32
805    BRIG_REGISTER_KIND_DOUBLE = 2,  //.bits=64
806    BRIG_REGISTER_KIND_QUAD = 3     //.bits=128
807};
808
809enum BrigRound {
810
811    //.mnemo={}
812    //.mnemo_fn=round2str //.mnemo_token=_EMRound
813    //
814    //.sat={/_SAT$/? "true" : "false"}
815    //.sat_switch //.sat_proto="bool isSatRounding(unsigned rounding)" //.sat_arg="rounding"
816    //.sat_default="return false"
817    //
818    //.sig={/_SIGNALING_/? "true" : "false"}
819    //.sig_switch //.sig_proto="bool isSignalingRounding(unsigned rounding)" //.sig_arg="rounding"
820    //.sig_default="return false"
821    //
822    //.int={/_INTEGER_/? "true" : "false"}
823    //.int_switch //.int_proto="bool isIntRounding(unsigned rounding)" //.int_arg="rounding"
824    //.int_default="return false"
825    //
826    //.flt={/_FLOAT_/? "true" : "false"}
827    //.flt_switch //.flt_proto="bool isFloatRounding(unsigned rounding)" //.flt_arg="rounding"
828    //.flt_default="return false"
829    //
830    //.print=$mnemo{ "_$mnemo" }
831
832    BRIG_ROUND_NONE = 0,                                    //.no_mnemo
833    BRIG_ROUND_FLOAT_DEFAULT = 1,                           //.no_mnemo
834    BRIG_ROUND_FLOAT_NEAR_EVEN = 2,                         //.mnemo=near
835    BRIG_ROUND_FLOAT_ZERO = 3,                              //.mnemo=zero
836    BRIG_ROUND_FLOAT_PLUS_INFINITY = 4,                     //.mnemo=up
837    BRIG_ROUND_FLOAT_MINUS_INFINITY = 5,                    //.mnemo=down
838    BRIG_ROUND_INTEGER_NEAR_EVEN = 6,                       //.mnemo=neari
839    BRIG_ROUND_INTEGER_ZERO = 7,                            //.mnemo=zeroi
840    BRIG_ROUND_INTEGER_PLUS_INFINITY = 8,                   //.mnemo=upi
841    BRIG_ROUND_INTEGER_MINUS_INFINITY = 9,                  //.mnemo=downi
842    BRIG_ROUND_INTEGER_NEAR_EVEN_SAT = 10,                  //.mnemo=neari_sat
843    BRIG_ROUND_INTEGER_ZERO_SAT = 11,                       //.mnemo=zeroi_sat
844    BRIG_ROUND_INTEGER_PLUS_INFINITY_SAT = 12,              //.mnemo=upi_sat
845    BRIG_ROUND_INTEGER_MINUS_INFINITY_SAT = 13,             //.mnemo=downi_sat
846    BRIG_ROUND_INTEGER_SIGNALING_NEAR_EVEN = 14,            //.mnemo=sneari
847    BRIG_ROUND_INTEGER_SIGNALING_ZERO = 15,                 //.mnemo=szeroi
848    BRIG_ROUND_INTEGER_SIGNALING_PLUS_INFINITY = 16,        //.mnemo=supi
849    BRIG_ROUND_INTEGER_SIGNALING_MINUS_INFINITY = 17,       //.mnemo=sdowni
850    BRIG_ROUND_INTEGER_SIGNALING_NEAR_EVEN_SAT = 18,        //.mnemo=sneari_sat
851    BRIG_ROUND_INTEGER_SIGNALING_ZERO_SAT = 19,             //.mnemo=szeroi_sat
852    BRIG_ROUND_INTEGER_SIGNALING_PLUS_INFINITY_SAT = 20,    //.mnemo=supi_sat
853    BRIG_ROUND_INTEGER_SIGNALING_MINUS_INFINITY_SAT = 21    //.mnemo=sdowni_sat
854};
855
856enum BrigSamplerAddressing {
857
858    //.mnemo={ s/^BRIG_ADDRESSING_//;lc }
859    //.mnemo_token=ESamplerAddressingMode
860
861    BRIG_ADDRESSING_UNDEFINED = 0,
862    BRIG_ADDRESSING_CLAMP_TO_EDGE = 1,
863    BRIG_ADDRESSING_CLAMP_TO_BORDER = 2,
864    BRIG_ADDRESSING_REPEAT = 3,
865    BRIG_ADDRESSING_MIRRORED_REPEAT = 4,
866
867    BRIG_ADDRESSING_FIRST_USER_DEFINED = 128 //.skip
868};
869
870enum BrigSamplerCoordNormalization {
871
872    //.mnemo={ s/^BRIG_COORD_//;lc }
873    //.mnemo_token=ESamplerCoord
874    //
875    //.print=$mnemo{ $mnemo }
876
877    BRIG_COORD_UNNORMALIZED = 0,
878    BRIG_COORD_NORMALIZED = 1
879};
880
881enum BrigSamplerFilter {
882
883    //.mnemo={ s/^BRIG_FILTER_//;lc }
884    //
885    //.print=$mnemo{ $mnemo }
886
887    BRIG_FILTER_NEAREST = 0,
888    BRIG_FILTER_LINEAR = 1,
889
890    BRIG_FILTER_FIRST_USER_DEFINED = 128 //.skip
891};
892
893enum BrigSamplerQuery {
894
895    //.mnemo={ s/^BRIG_SAMPLER_QUERY_//;lc }
896    //.mnemo_token=_EMSamplerQuery
897    //
898    //.print=$mnemo{ $mnemo }
899
900    BRIG_SAMPLER_QUERY_ADDRESSING = 0,
901    BRIG_SAMPLER_QUERY_COORD = 1,
902    BRIG_SAMPLER_QUERY_FILTER = 2
903};
904
905enum BrigSectionIndex {
906
907    //.nollvm
908    //
909    //.mnemo={ s/^BRIG_SECTION_INDEX_/HSA_/;lc }
910
911    BRIG_SECTION_INDEX_DATA = 0,
912    BRIG_SECTION_INDEX_CODE = 1,
913    BRIG_SECTION_INDEX_OPERAND = 2,
914    BRIG_SECTION_INDEX_BEGIN_IMPLEMENTATION_DEFINED = 3,
915
916    // used internally
917    BRIG_SECTION_INDEX_IMPLEMENTATION_DEFINED = BRIG_SECTION_INDEX_BEGIN_IMPLEMENTATION_DEFINED //.skip
918};
919
920enum BrigSegCvtModifierMask {
921    BRIG_SEG_CVT_NONULL = 1         //.mnemo="nonull" //.print="_nonull"
922};
923
924enum BrigSegment {
925
926    //.mnemo={ s/^BRIG_SEGMENT_//;lc}
927    //.mnemo_token=_EMSegment
928    //.mnemo_context=EInstModifierContext
929    //
930    //.print=$mnemo{ $mnemo ? "_$mnemo" : "" }
931
932    BRIG_SEGMENT_NONE = 0, //.mnemo=""
933    BRIG_SEGMENT_FLAT = 1, //.mnemo=""
934    BRIG_SEGMENT_GLOBAL = 2,
935    BRIG_SEGMENT_READONLY = 3,
936    BRIG_SEGMENT_KERNARG = 4,
937    BRIG_SEGMENT_GROUP = 5,
938    BRIG_SEGMENT_PRIVATE = 6,
939    BRIG_SEGMENT_SPILL = 7,
940    BRIG_SEGMENT_ARG = 8,
941
942    BRIG_SEGMENT_FIRST_USER_DEFINED = 128, //.skip
943
944    BRIG_SEGMENT_AMD_GCN = 9, //.mnemo="region"
945};
946
947enum BrigPackedTypeBits {
948
949    //.nodump
950    //
951    //.nollvm
952
953    BRIG_TYPE_BASE_SIZE  = 5,
954    BRIG_TYPE_PACK_SIZE  = 2,
955    BRIG_TYPE_ARRAY_SIZE = 1,
956
957    BRIG_TYPE_BASE_SHIFT  = 0,
958    BRIG_TYPE_PACK_SHIFT  = BRIG_TYPE_BASE_SHIFT + BRIG_TYPE_BASE_SIZE,
959    BRIG_TYPE_ARRAY_SHIFT = BRIG_TYPE_PACK_SHIFT + BRIG_TYPE_PACK_SIZE,
960
961    BRIG_TYPE_BASE_MASK  = ((1 << BRIG_TYPE_BASE_SIZE)  - 1) << BRIG_TYPE_BASE_SHIFT,
962    BRIG_TYPE_PACK_MASK  = ((1 << BRIG_TYPE_PACK_SIZE)  - 1) << BRIG_TYPE_PACK_SHIFT,
963    BRIG_TYPE_ARRAY_MASK = ((1 << BRIG_TYPE_ARRAY_SIZE) - 1) << BRIG_TYPE_ARRAY_SHIFT,
964
965    BRIG_TYPE_PACK_NONE = 0 << BRIG_TYPE_PACK_SHIFT,
966    BRIG_TYPE_PACK_32   = 1 << BRIG_TYPE_PACK_SHIFT,
967    BRIG_TYPE_PACK_64   = 2 << BRIG_TYPE_PACK_SHIFT,
968    BRIG_TYPE_PACK_128  = 3 << BRIG_TYPE_PACK_SHIFT,
969
970    BRIG_TYPE_ARRAY     = 1 << BRIG_TYPE_ARRAY_SHIFT
971};
972
973enum BrigType {
974
975    //.numBits={ /ARRAY$/ ? undef : /([0-9]+)X([0-9]+)/ ? $1*$2 : /([0-9]+)/ ? $1 : undef }
976    //.numBits_switch //.numBits_proto="unsigned getBrigTypeNumBits(unsigned arg)" //.numBits_default="assert(0); return 0"
977    //.numBytes=$numBits{ $numBits > 1 ? $numBits/8 : undef }
978    //.numBytes_switch //.numBytes_proto="unsigned getBrigTypeNumBytes(unsigned arg)" //.numBytes_default="assert(0); return 0"
979    //
980    //.mnemo={ s/^BRIG_TYPE_//;lc }
981    //.mnemo_token=_EMType
982    //
983    //.array={/ARRAY$/?"true":"false"}
984    //.array_switch //.array_proto="bool isArrayType(unsigned type)" //.array_arg="type"
985    //.array_default="return false"
986    //
987    //.a2e={/(.*)_ARRAY$/? $1 : "BRIG_TYPE_NONE"}
988    //.a2e_switch //.a2e_proto="unsigned arrayType2elementType(unsigned type)" //.a2e_arg="type"
989    //.a2e_default="return BRIG_TYPE_NONE"
990    //
991    //.e2a={/_ARRAY$/? "BRIG_TYPE_NONE" : /_NONE$/ ? "BRIG_TYPE_NONE" : /_B1$/ ? "BRIG_TYPE_NONE" : $_ . "_ARRAY"}
992    //.e2a_switch //.e2a_proto="unsigned elementType2arrayType(unsigned type)" //.e2a_arg="type"
993    //.e2a_default="return BRIG_TYPE_NONE"
994    //
995    //.t2s={s/^BRIG_TYPE_//;lc s/_ARRAY$/[]/;lc}
996    //.t2s_switch //.t2s_proto="const char* type2name(unsigned type)" //.t2s_arg="type"
997    //.t2s_default="return NULL"
998    //
999    //.dispatch_switch //.dispatch_incfile=TemplateUtilities
1000    //.dispatch_proto="template<typename RetType, typename Visitor>\nRetType dispatchByType_gen(unsigned type, Visitor& v)"
1001    //.dispatch={ /ARRAY$/ ? "v.visitNone(type)" : /^BRIG_TYPE_([BUSF]|SIG)[0-9]+/ ? "v.template visit< BrigTypeTraits<$_> >()" : "v.visitNone(type)" }
1002    //.dispatch_arg="type" //.dispatch_default="return v.visitNone(type)"
1003    //
1004    //- .tdname=BrigType
1005    //
1006    //.print=$mnemo{ "_$mnemo" }
1007
1008    BRIG_TYPE_NONE  = 0,  //.mnemo=""       //.print=""
1009    BRIG_TYPE_U8    = 1,  //.ctype=uint8_t
1010    BRIG_TYPE_U16   = 2,  //.ctype=uint16_t
1011    BRIG_TYPE_U32   = 3,  //.ctype=uint32_t
1012    BRIG_TYPE_U64   = 4,  //.ctype=uint64_t
1013    BRIG_TYPE_S8    = 5,  //.ctype=int8_t
1014    BRIG_TYPE_S16   = 6,  //.ctype=int16_t
1015    BRIG_TYPE_S32   = 7,  //.ctype=int32_t
1016    BRIG_TYPE_S64   = 8,  //.ctype=int64_t
1017    BRIG_TYPE_F16   = 9,  //.ctype=f16_t
1018    BRIG_TYPE_F32   = 10, //.ctype=float
1019    BRIG_TYPE_F64   = 11, //.ctype=double
1020    BRIG_TYPE_B1    = 12, //.ctype=bool     //.numBytes=1
1021    BRIG_TYPE_B8    = 13, //.ctype=uint8_t
1022    BRIG_TYPE_B16   = 14, //.ctype=uint16_t
1023    BRIG_TYPE_B32   = 15, //.ctype=uint32_t
1024    BRIG_TYPE_B64   = 16, //.ctype=uint64_t
1025    BRIG_TYPE_B128  = 17, //.ctype=b128_t
1026    BRIG_TYPE_SAMP  = 18, //.mnemo=samp     //.numBits=64
1027    BRIG_TYPE_ROIMG = 19, //.mnemo=roimg    //.numBits=64
1028    BRIG_TYPE_WOIMG = 20, //.mnemo=woimg    //.numBits=64
1029    BRIG_TYPE_RWIMG = 21, //.mnemo=rwimg    //.numBits=64
1030    BRIG_TYPE_SIG32 = 22, //.mnemo=sig32    //.numBits=64
1031    BRIG_TYPE_SIG64 = 23, //.mnemo=sig64    //.numBits=64
1032
1033    BRIG_TYPE_U8X4  = BRIG_TYPE_U8  | BRIG_TYPE_PACK_32,  //.ctype=uint8_t
1034    BRIG_TYPE_U8X8  = BRIG_TYPE_U8  | BRIG_TYPE_PACK_64,  //.ctype=uint8_t
1035    BRIG_TYPE_U8X16 = BRIG_TYPE_U8  | BRIG_TYPE_PACK_128, //.ctype=uint8_t
1036    BRIG_TYPE_U16X2 = BRIG_TYPE_U16 | BRIG_TYPE_PACK_32,  //.ctype=uint16_t
1037    BRIG_TYPE_U16X4 = BRIG_TYPE_U16 | BRIG_TYPE_PACK_64,  //.ctype=uint16_t
1038    BRIG_TYPE_U16X8 = BRIG_TYPE_U16 | BRIG_TYPE_PACK_128, //.ctype=uint16_t
1039    BRIG_TYPE_U32X2 = BRIG_TYPE_U32 | BRIG_TYPE_PACK_64,  //.ctype=uint32_t
1040    BRIG_TYPE_U32X4 = BRIG_TYPE_U32 | BRIG_TYPE_PACK_128, //.ctype=uint32_t
1041    BRIG_TYPE_U64X2 = BRIG_TYPE_U64 | BRIG_TYPE_PACK_128, //.ctype=uint64_t
1042    BRIG_TYPE_S8X4  = BRIG_TYPE_S8  | BRIG_TYPE_PACK_32,  //.ctype=int8_t
1043    BRIG_TYPE_S8X8  = BRIG_TYPE_S8  | BRIG_TYPE_PACK_64,  //.ctype=int8_t
1044    BRIG_TYPE_S8X16 = BRIG_TYPE_S8  | BRIG_TYPE_PACK_128, //.ctype=int8_t
1045    BRIG_TYPE_S16X2 = BRIG_TYPE_S16 | BRIG_TYPE_PACK_32,  //.ctype=int16_t
1046    BRIG_TYPE_S16X4 = BRIG_TYPE_S16 | BRIG_TYPE_PACK_64,  //.ctype=int16_t
1047    BRIG_TYPE_S16X8 = BRIG_TYPE_S16 | BRIG_TYPE_PACK_128, //.ctype=int16_t
1048    BRIG_TYPE_S32X2 = BRIG_TYPE_S32 | BRIG_TYPE_PACK_64,  //.ctype=int32_t
1049    BRIG_TYPE_S32X4 = BRIG_TYPE_S32 | BRIG_TYPE_PACK_128, //.ctype=int32_t
1050    BRIG_TYPE_S64X2 = BRIG_TYPE_S64 | BRIG_TYPE_PACK_128, //.ctype=int64_t
1051    BRIG_TYPE_F16X2 = BRIG_TYPE_F16 | BRIG_TYPE_PACK_32,  //.ctype=f16_t
1052    BRIG_TYPE_F16X4 = BRIG_TYPE_F16 | BRIG_TYPE_PACK_64,  //.ctype=f16_t
1053    BRIG_TYPE_F16X8 = BRIG_TYPE_F16 | BRIG_TYPE_PACK_128, //.ctype=f16_t
1054    BRIG_TYPE_F32X2 = BRIG_TYPE_F32 | BRIG_TYPE_PACK_64,  //.ctype=float
1055    BRIG_TYPE_F32X4 = BRIG_TYPE_F32 | BRIG_TYPE_PACK_128, //.ctype=float
1056    BRIG_TYPE_F64X2 = BRIG_TYPE_F64 | BRIG_TYPE_PACK_128, //.ctype=double
1057
1058    BRIG_TYPE_U8_ARRAY    = BRIG_TYPE_U8    | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1059    BRIG_TYPE_U16_ARRAY   = BRIG_TYPE_U16   | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1060    BRIG_TYPE_U32_ARRAY   = BRIG_TYPE_U32   | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1061    BRIG_TYPE_U64_ARRAY   = BRIG_TYPE_U64   | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1062    BRIG_TYPE_S8_ARRAY    = BRIG_TYPE_S8    | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1063    BRIG_TYPE_S16_ARRAY   = BRIG_TYPE_S16   | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1064    BRIG_TYPE_S32_ARRAY   = BRIG_TYPE_S32   | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1065    BRIG_TYPE_S64_ARRAY   = BRIG_TYPE_S64   | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1066    BRIG_TYPE_F16_ARRAY   = BRIG_TYPE_F16   | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1067    BRIG_TYPE_F32_ARRAY   = BRIG_TYPE_F32   | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1068    BRIG_TYPE_F64_ARRAY   = BRIG_TYPE_F64   | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1069    BRIG_TYPE_B8_ARRAY    = BRIG_TYPE_B8    | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1070    BRIG_TYPE_B16_ARRAY   = BRIG_TYPE_B16   | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1071    BRIG_TYPE_B32_ARRAY   = BRIG_TYPE_B32   | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1072    BRIG_TYPE_B64_ARRAY   = BRIG_TYPE_B64   | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1073    BRIG_TYPE_B128_ARRAY  = BRIG_TYPE_B128  | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1074    BRIG_TYPE_SAMP_ARRAY  = BRIG_TYPE_SAMP  | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1075    BRIG_TYPE_ROIMG_ARRAY = BRIG_TYPE_ROIMG | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1076    BRIG_TYPE_WOIMG_ARRAY = BRIG_TYPE_WOIMG | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1077    BRIG_TYPE_RWIMG_ARRAY = BRIG_TYPE_RWIMG | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1078    BRIG_TYPE_SIG32_ARRAY = BRIG_TYPE_SIG32 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1079    BRIG_TYPE_SIG64_ARRAY = BRIG_TYPE_SIG64 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1080    BRIG_TYPE_U8X4_ARRAY  = BRIG_TYPE_U8X4  | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1081    BRIG_TYPE_U8X8_ARRAY  = BRIG_TYPE_U8X8  | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1082    BRIG_TYPE_U8X16_ARRAY = BRIG_TYPE_U8X16 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1083    BRIG_TYPE_U16X2_ARRAY = BRIG_TYPE_U16X2 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1084    BRIG_TYPE_U16X4_ARRAY = BRIG_TYPE_U16X4 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1085    BRIG_TYPE_U16X8_ARRAY = BRIG_TYPE_U16X8 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1086    BRIG_TYPE_U32X2_ARRAY = BRIG_TYPE_U32X2 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1087    BRIG_TYPE_U32X4_ARRAY = BRIG_TYPE_U32X4 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1088    BRIG_TYPE_U64X2_ARRAY = BRIG_TYPE_U64X2 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1089    BRIG_TYPE_S8X4_ARRAY  = BRIG_TYPE_S8X4  | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1090    BRIG_TYPE_S8X8_ARRAY  = BRIG_TYPE_S8X8  | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1091    BRIG_TYPE_S8X16_ARRAY = BRIG_TYPE_S8X16 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1092    BRIG_TYPE_S16X2_ARRAY = BRIG_TYPE_S16X2 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1093    BRIG_TYPE_S16X4_ARRAY = BRIG_TYPE_S16X4 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1094    BRIG_TYPE_S16X8_ARRAY = BRIG_TYPE_S16X8 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1095    BRIG_TYPE_S32X2_ARRAY = BRIG_TYPE_S32X2 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1096    BRIG_TYPE_S32X4_ARRAY = BRIG_TYPE_S32X4 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1097    BRIG_TYPE_S64X2_ARRAY = BRIG_TYPE_S64X2 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1098    BRIG_TYPE_F16X2_ARRAY = BRIG_TYPE_F16X2 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1099    BRIG_TYPE_F16X4_ARRAY = BRIG_TYPE_F16X4 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1100    BRIG_TYPE_F16X8_ARRAY = BRIG_TYPE_F16X8 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1101    BRIG_TYPE_F32X2_ARRAY = BRIG_TYPE_F32X2 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1102    BRIG_TYPE_F32X4_ARRAY = BRIG_TYPE_F32X4 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1103    BRIG_TYPE_F64X2_ARRAY = BRIG_TYPE_F64X2 | BRIG_TYPE_ARRAY,  //.mnemo=""     //.print=""
1104
1105    // Used internally
1106    BRIG_TYPE_INVALID = (unsigned) -1 //.skip
1107};
1108
1109enum BrigVariableModifierMask {
1110
1111    //.nodump
1112
1113    BRIG_VARIABLE_DEFINITION = 1,
1114    BRIG_VARIABLE_CONST = 2
1115};
1116
1117enum BrigWidth {
1118
1119    //.tddef=1
1120    //
1121    //.print={ s/^BRIG_WIDTH_//; "_width($_)" }
1122
1123    BRIG_WIDTH_NONE = 0,
1124    BRIG_WIDTH_1 = 1,
1125    BRIG_WIDTH_2 = 2,
1126    BRIG_WIDTH_4 = 3,
1127    BRIG_WIDTH_8 = 4,
1128    BRIG_WIDTH_16 = 5,
1129    BRIG_WIDTH_32 = 6,
1130    BRIG_WIDTH_64 = 7,
1131    BRIG_WIDTH_128 = 8,
1132    BRIG_WIDTH_256 = 9,
1133    BRIG_WIDTH_512 = 10,
1134    BRIG_WIDTH_1024 = 11,
1135    BRIG_WIDTH_2048 = 12,
1136    BRIG_WIDTH_4096 = 13,
1137    BRIG_WIDTH_8192 = 14,
1138    BRIG_WIDTH_16384 = 15,
1139    BRIG_WIDTH_32768 = 16,
1140    BRIG_WIDTH_65536 = 17,
1141    BRIG_WIDTH_131072 = 18,
1142    BRIG_WIDTH_262144 = 19,
1143    BRIG_WIDTH_524288 = 20,
1144    BRIG_WIDTH_1048576 = 21,
1145    BRIG_WIDTH_2097152 = 22,
1146    BRIG_WIDTH_4194304 = 23,
1147    BRIG_WIDTH_8388608 = 24,
1148    BRIG_WIDTH_16777216 = 25,
1149    BRIG_WIDTH_33554432 = 26,
1150    BRIG_WIDTH_67108864 = 27,
1151    BRIG_WIDTH_134217728 = 28,
1152    BRIG_WIDTH_268435456 = 29,
1153    BRIG_WIDTH_536870912 = 30,
1154    BRIG_WIDTH_1073741824 = 31,
1155    BRIG_WIDTH_2147483648 = 32,
1156    BRIG_WIDTH_WAVESIZE = 33,
1157    BRIG_WIDTH_ALL = 34,
1158
1159    BRIG_WIDTH_LAST //.skip
1160};
1161
1162struct BrigUInt64 { //.isroot //.standalone
1163    uint32_t lo;     //.defValue=0
1164    uint32_t hi;     //.defValue=0
1165
1166    //+hcode KLASS& operator=(uint64_t rhs);
1167    //+hcode operator uint64_t();
1168    //+implcode inline KLASS& KLASS::operator=(uint64_t rhs) { lo() = (uint32_t)rhs; hi() = (uint32_t)(rhs >> 32); return *this; }
1169    //+implcode inline KLASS::operator uint64_t() { return ((uint64_t)hi()) << 32 | lo(); }
1170};
1171
1172struct BrigAluModifier { //.isroot //.standalone
1173    BrigAluModifier8_t allBits; //.defValue=0
1174    //^^ bool ftz; //.wtype=BitValRef<0>
1175};
1176
1177struct BrigBase { //.nowrap
1178    uint16_t byteCount;
1179    BrigKind16_t kind;
1180};
1181
1182//.alias Code:Base { //.generic //.isroot //.section=BRIG_SECTION_INDEX_CODE };
1183//.alias Directive:Code { //.generic };
1184//.alias Operand:Base { //.generic //.isroot //.section=BRIG_SECTION_INDEX_OPERAND };
1185
1186struct BrigData {
1187    //.nowrap
1188    uint32_t byteCount;
1189    uint8_t bytes[1];
1190};
1191
1192struct BrigExecutableModifier { //.isroot //.standalone
1193    BrigExecutableModifier8_t allBits; //.defValue=0
1194    //^^ bool isDefinition; //.wtype=BitValRef<0>
1195};
1196
1197struct BrigMemoryModifier { //.isroot //.standalone
1198    BrigMemoryModifier8_t allBits; //.defValue=0
1199    //^^ bool isConst; //.wtype=BitValRef<0>
1200};
1201
1202struct BrigSegCvtModifier { //.isroot //.standalone
1203    BrigSegCvtModifier8_t allBits; //.defValue=0
1204    //^^ bool isNoNull; //.wtype=BitValRef<0>
1205};
1206
1207struct BrigVariableModifier { //.isroot //.standalone
1208    BrigVariableModifier8_t allBits;    //.defValue=0
1209
1210    //^^ bool isDefinition;     //.wtype=BitValRef<0>
1211    //^^ bool isConst;          //.wtype=BitValRef<1>
1212};
1213
1214struct BrigDirectiveArgBlockEnd {
1215    BrigBase base;
1216};
1217
1218struct BrigDirectiveArgBlockStart {
1219    BrigBase base;
1220};
1221
1222struct BrigDirectiveComment {
1223    BrigBase base;
1224    BrigDataOffsetString32_t name;
1225};
1226
1227struct BrigDirectiveControl {
1228    BrigBase base;
1229    BrigControlDirective16_t control;
1230    uint16_t reserved; //.defValue=0
1231    BrigDataOffsetOperandList32_t operands;
1232};
1233
1234struct BrigDirectiveExecutable { //.generic
1235    BrigBase base;
1236    BrigDataOffsetString32_t name;
1237    uint16_t outArgCount; //.defValue=0
1238    uint16_t inArgCount;  //.defValue=0
1239    BrigCodeOffset32_t firstInArg;
1240    BrigCodeOffset32_t firstCodeBlockEntry;
1241    BrigCodeOffset32_t nextModuleEntry;
1242    BrigExecutableModifier modifier; //.acc=subItem<ExecutableModifier> //.wtype=ExecutableModifier
1243    BrigLinkage8_t linkage;
1244    uint16_t reserved; //.defValue=0
1245};
1246
1247//.alias DirectiveKernel:DirectiveExecutable { };
1248//.alias DirectiveFunction:DirectiveExecutable { };
1249//.alias DirectiveSignature:DirectiveExecutable { };
1250//.alias DirectiveIndirectFunction:DirectiveExecutable { };
1251
1252struct BrigDirectiveExtension {
1253    BrigBase base;
1254    BrigDataOffsetString32_t name;
1255};
1256
1257struct BrigDirectiveFbarrier {
1258    BrigBase base;
1259    BrigDataOffsetString32_t name;
1260    BrigVariableModifier modifier; //.acc=subItem<VariableModifier> //.wtype=VariableModifier
1261    BrigLinkage8_t linkage;
1262    uint16_t reserved; //.defValue=0
1263};
1264
1265struct BrigDirectiveLabel {
1266    BrigBase base;
1267    BrigDataOffsetString32_t name;
1268};
1269
1270struct BrigDirectiveLoc {
1271    BrigBase base;
1272    BrigDataOffsetString32_t filename;
1273    uint32_t line;
1274    uint32_t column; //.defValue=1
1275};
1276
1277struct BrigDirectiveNone { //.enum=BRIG_KIND_NONE
1278    BrigBase base;
1279};
1280
1281struct BrigDirectivePragma {
1282    BrigBase base;
1283    BrigDataOffsetOperandList32_t operands;
1284};
1285
1286struct BrigDirectiveVariable {
1287    BrigBase base;
1288    BrigDataOffsetString32_t name;
1289    BrigOperandOffset32_t init;
1290    BrigType16_t type;
1291
1292    //+hcode bool isArray();
1293    //+implcode inline bool KLASS::isArray() { return isArrayType(type()); }
1294
1295    //+hcode unsigned elementType();
1296    //+implcode inline unsigned KLASS::elementType() { return isArray()? arrayType2elementType(type()) : type(); }
1297
1298    BrigSegment8_t segment;
1299    BrigAlignment8_t align;
1300    BrigUInt64 dim; //.acc=subItem<UInt64> //.wtype=UInt64
1301    BrigVariableModifier modifier; //.acc=subItem<VariableModifier> //.wtype=VariableModifier
1302    BrigLinkage8_t linkage;
1303    BrigAllocation8_t allocation;
1304    uint8_t reserved; //.defValue=0
1305};
1306
1307struct BrigDirectiveModule {
1308    BrigBase base;
1309    BrigDataOffsetString32_t name;
1310    BrigVersion32_t hsailMajor;         //.wtype=ValRef<uint32_t>
1311    BrigVersion32_t hsailMinor;         //.wtype=ValRef<uint32_t>
1312    BrigProfile8_t profile;
1313    BrigMachineModel8_t machineModel;
1314    BrigRound8_t defaultFloatRound;
1315    uint8_t reserved;                   //.defValue=0
1316};
1317
1318struct BrigInstBase { //.wname=Inst //.generic //.parent=BrigCode
1319    BrigBase base;
1320    BrigOpcode16_t opcode;
1321    BrigType16_t type;
1322    BrigDataOffsetOperandList32_t operands;
1323
1324    //+hcode Operand operand(int index);
1325    //+implcode inline Operand KLASS::operand(int index) { return operands()[index]; }
1326};
1327
1328struct BrigInstAddr {
1329    BrigInstBase base;
1330    BrigSegment8_t segment;
1331    uint8_t reserved[3]; //.defValue=0
1332};
1333
1334struct BrigInstAtomic {
1335    BrigInstBase base;
1336    BrigSegment8_t segment;
1337    BrigMemoryOrder8_t memoryOrder;
1338    BrigMemoryScope8_t memoryScope;
1339    BrigAtomicOperation8_t atomicOperation;
1340    uint8_t equivClass;
1341    uint8_t reserved[3]; //.defValue=0
1342};
1343
1344struct BrigInstBasic {
1345    BrigInstBase base;
1346};
1347
1348struct BrigInstBr {
1349    BrigInstBase base;
1350    BrigWidth8_t width;
1351    uint8_t reserved[3]; //.defValue=0
1352};
1353
1354struct BrigInstCmp {
1355    BrigInstBase base;
1356    BrigType16_t sourceType;
1357    BrigAluModifier modifier; //.acc=subItem<AluModifier> //.wtype=AluModifier
1358    BrigCompareOperation8_t compare;
1359    BrigPack8_t pack;
1360    uint8_t reserved[3]; //.defValue=0
1361};
1362
1363struct BrigInstCvt {
1364    BrigInstBase base;
1365    BrigType16_t sourceType;
1366    BrigAluModifier modifier; //.acc=subItem<AluModifier> //.wtype=AluModifier
1367    BrigRound8_t round;
1368};
1369
1370struct BrigInstImage {
1371    BrigInstBase base;
1372    BrigType16_t imageType;
1373    BrigType16_t coordType;
1374    BrigImageGeometry8_t geometry;
1375    uint8_t equivClass;
1376    uint16_t reserved; //.defValue=0
1377};
1378
1379struct BrigInstLane {
1380    BrigInstBase base;
1381    BrigType16_t sourceType;
1382    BrigWidth8_t width;
1383    uint8_t reserved; //.defValue=0
1384};
1385
1386struct BrigInstMem {
1387    BrigInstBase base;
1388    BrigSegment8_t segment;
1389    BrigAlignment8_t align;
1390    uint8_t equivClass;
1391    BrigWidth8_t width;
1392    BrigMemoryModifier modifier; //.acc=subItem<MemoryModifier> //.wtype=MemoryModifier
1393    uint8_t reserved[3]; //.defValue=0
1394};
1395
1396struct BrigInstMemFence {
1397    BrigInstBase base;
1398    BrigMemoryOrder8_t memoryOrder;
1399    BrigMemoryScope8_t globalSegmentMemoryScope;
1400    BrigMemoryScope8_t groupSegmentMemoryScope;
1401    BrigMemoryScope8_t imageSegmentMemoryScope;
1402};
1403
1404struct BrigInstMod {
1405    BrigInstBase base;
1406    BrigAluModifier modifier; //.acc=subItem<AluModifier> //.wtype=AluModifier
1407    BrigRound8_t round;
1408    BrigPack8_t pack;
1409    uint8_t reserved; //.defValue=0
1410};
1411
1412struct BrigInstQueryImage {
1413    BrigInstBase base;
1414    BrigType16_t imageType;
1415    BrigImageGeometry8_t geometry;
1416    BrigImageQuery8_t imageQuery;
1417};
1418
1419struct BrigInstQuerySampler {
1420    BrigInstBase base;
1421    BrigSamplerQuery8_t samplerQuery;
1422    uint8_t reserved[3]; //.defValue=0
1423};
1424
1425struct BrigInstQueue {
1426    BrigInstBase base;
1427    BrigSegment8_t segment;
1428    BrigMemoryOrder8_t memoryOrder;
1429    uint16_t reserved; //.defValue=0
1430};
1431
1432struct BrigInstSeg {
1433    BrigInstBase base;
1434    BrigSegment8_t segment;
1435    uint8_t reserved[3]; //.defValue=0
1436};
1437
1438struct BrigInstSegCvt {
1439    BrigInstBase base;
1440    BrigType16_t sourceType;
1441    BrigSegment8_t segment;
1442    BrigSegCvtModifier modifier; //.acc=subItem<SegCvtModifier> //.wtype=SegCvtModifier
1443};
1444
1445struct BrigInstSignal {
1446    BrigInstBase base;
1447    BrigType16_t signalType;
1448    BrigMemoryOrder8_t memoryOrder;
1449    BrigAtomicOperation8_t signalOperation;
1450};
1451
1452struct BrigInstSourceType {
1453    BrigInstBase base;
1454    BrigType16_t sourceType;
1455    uint16_t reserved; //.defValue=0
1456};
1457
1458typedef BrigInstSourceType BrigInstPopcount;
1459
1460struct BrigOperandAddress {
1461    BrigBase base;
1462    BrigCodeOffset32_t symbol; //.wtype=ItemRef<DirectiveVariable>
1463    BrigOperandOffset32_t reg; //.wtype=ItemRef<OperandRegister>
1464    BrigUInt64 offset; //.acc=subItem<UInt64> //.wtype=UInt64
1465};
1466
1467struct BrigOperandAlign {
1468    BrigBase base;
1469    BrigAlignment8_t align;
1470    uint8_t reserved[3]; //.defValue=0
1471};
1472
1473struct BrigOperandCodeList {
1474    BrigBase base;
1475    BrigDataOffsetCodeList32_t elements;
1476
1477    //+hcode unsigned elementCount();
1478    //+implcode inline unsigned KLASS::elementCount() { return elements().size(); }
1479    //+hcode Code elements(int index);
1480    //+implcode inline Code KLASS::elements(int index) { return elements()[index]; }
1481};
1482
1483struct BrigOperandCodeRef {
1484    BrigBase base;
1485    BrigCodeOffset32_t ref;
1486};
1487
1488struct BrigOperandConstantBytes {
1489    BrigBase base;
1490    BrigType16_t type; //.defValue=0
1491    uint16_t reserved; //.defValue=0
1492    BrigDataOffsetString32_t bytes;
1493};
1494
1495struct BrigOperandConstantOperandList {
1496    BrigBase base;
1497    BrigType16_t type;
1498    uint16_t reserved; //.defValue=0
1499    BrigDataOffsetOperandList32_t elements;
1500
1501    //+hcode unsigned elementCount();
1502    //+implcode inline unsigned KLASS::elementCount() { return elements().size(); }
1503    //+hcode Operand elements(int index);
1504    //+implcode inline Operand KLASS::elements(int index) { return elements()[index]; }
1505};
1506
1507struct BrigOperandConstantImage {
1508    BrigBase base;
1509    BrigType16_t type;
1510    BrigImageGeometry8_t geometry;
1511    BrigImageChannelOrder8_t channelOrder;
1512    BrigImageChannelType8_t channelType;
1513    uint8_t reserved[3]; //.defValue=0
1514    BrigUInt64 width;    //.acc=subItem<UInt64> //.wtype=UInt64
1515    BrigUInt64 height;   //.acc=subItem<UInt64> //.wtype=UInt64
1516    BrigUInt64 depth;    //.acc=subItem<UInt64> //.wtype=UInt64
1517    BrigUInt64 array;    //.acc=subItem<UInt64> //.wtype=UInt64
1518};
1519
1520struct BrigOperandOperandList {
1521    BrigBase base;
1522    BrigDataOffsetOperandList32_t elements;
1523
1524    //+hcode unsigned elementCount();
1525    //+implcode inline unsigned KLASS::elementCount() { return elements().size(); }
1526    //+hcode Operand elements(int index);
1527    //+implcode inline Operand KLASS::elements(int index) { return elements()[index]; }
1528};
1529
1530struct BrigOperandRegister {
1531    BrigBase base;
1532    BrigRegisterKind16_t regKind;
1533    uint16_t regNum;
1534};
1535
1536struct BrigOperandConstantSampler {
1537    BrigBase base;
1538    BrigType16_t type;
1539    BrigSamplerCoordNormalization8_t coord;
1540    BrigSamplerFilter8_t filter;
1541    BrigSamplerAddressing8_t addressing;
1542    uint8_t reserved[3]; //.defValue=0
1543};
1544
1545struct BrigOperandString {
1546    BrigBase base;
1547    BrigDataOffsetString32_t string;
1548};
1549
1550struct BrigOperandWavesize {
1551    BrigBase base;
1552};
1553
1554//.ignore{
1555
1556enum BrigExceptionsMask {
1557    BRIG_EXCEPTIONS_INVALID_OPERATION = 1 << 0,
1558    BRIG_EXCEPTIONS_DIVIDE_BY_ZERO = 1 << 1,
1559    BRIG_EXCEPTIONS_OVERFLOW = 1 << 2,
1560    BRIG_EXCEPTIONS_UNDERFLOW = 1 << 3,
1561    BRIG_EXCEPTIONS_INEXACT = 1 << 4,
1562
1563    BRIG_EXCEPTIONS_FIRST_USER_DEFINED = 1 << 16
1564};
1565
1566struct BrigSectionHeader {
1567    uint64_t byteCount;
1568    uint32_t headerByteCount;
1569    uint32_t nameLength;
1570    uint8_t name[1];
1571};
1572
1573#define MODULE_IDENTIFICATION_LENGTH (8)
1574
1575struct BrigModuleHeader {
1576    char identification[MODULE_IDENTIFICATION_LENGTH];
1577    BrigVersion32_t brigMajor;
1578    BrigVersion32_t brigMinor;
1579    uint64_t byteCount;
1580    uint8_t hash[64];
1581    uint32_t reserved;
1582    uint32_t sectionCount;
1583    uint64_t sectionIndex;
1584};
1585
1586typedef BrigModuleHeader* BrigModule_t;
1587
1588#endif // defined(INCLUDED_BRIG_H)
1589//}
1590