-
Notifications
You must be signed in to change notification settings - Fork 657
/
hctdb.py
8974 lines (8696 loc) · 330 KB
/
hctdb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (C) Microsoft Corporation. All rights reserved.
# This file is distributed under the University of Illinois Open Source License. See LICENSE.TXT for details.
###############################################################################
# DXIL information. #
###############################################################################
import os
all_stages = (
"vertex",
"pixel",
"geometry",
"compute",
"hull",
"domain",
"library",
"raygeneration",
"intersection",
"anyhit",
"closesthit",
"miss",
"callable",
"mesh",
"amplification",
)
# These counters aren't collected directly from instructions,
# so they need to be added manually so they can be accessed
# with custom code in DxilCounters.cpp.
extra_counters = [
"insts",
"branches",
"array_tgsm_bytes",
"array_static_bytes",
"array_local_bytes",
"array_tgsm_ldst",
"array_static_ldst",
"array_local_ldst",
]
class db_dxil_enum_value(object):
"A representation for a value in an enumeration type"
def __init__(self, name, value, doc):
self.name = name # Name (identifier)
self.value = value # Numeric value
self.doc = doc # Documentation string
self.category = None
class db_dxil_enum(object):
"A representation for an enumeration type"
def __init__(self, name, doc, valNameDocTuples=()):
self.name = name
self.doc = doc
self.values = [
db_dxil_enum_value(n, v, d) for v, n, d in valNameDocTuples
] # Note transmutation
self.is_internal = False # whether this is never serialized
def value_names(self):
return [i.name for i in self.values]
class db_dxil_inst(object):
"A representation for a DXIL instruction"
def __init__(self, name, **kwargs):
self.name = name # short, unique name
self.llvm_id = 0 # ID of LLVM instruction
self.llvm_name = "" # name of LLVM instruction type
self.is_dxil_op = False # whether this is a call into a built-in DXIL function
self.dxil_op = "" # name of DXIL operation
self.dxil_opid = 0 # ID of DXIL operation
self.dxil_class = "" # name of the opcode class
self.category = "" # classification for this instruction
self.doc = "" # the documentation description of this instruction
self.remarks = "" # long-form remarks on this instruction
self.ops = [] # the operands that this instruction takes
self.is_allowed = True # whether this instruction is allowed in a DXIL program
self.oload_types = "" # overload types if applicable
self.fn_attr = "" # attribute shorthands: rn=does not access memory,ro=only reads from memory,
self.is_deriv = False # whether this is some kind of derivative
self.is_gradient = False # whether this requires a gradient calculation
self.is_feedback = False # whether this is a sampler feedback op
self.is_wave = False # whether this requires in-wave, cross-lane functionality
self.requires_uniform_inputs = False # whether this operation requires that all of its inputs are uniform across the wave
self.is_barrier = False # whether this is a barrier operation
self.shader_stages = () # shader stages to which this applies, empty for all.
self.shader_model = 6, 0 # minimum shader model required
self.inst_helper_prefix = None
self.fully_qualified_name_prefix = "hlsl::OP::OpCode"
for k, v in list(kwargs.items()):
setattr(self, k, v)
self.is_dxil_op = self.dxil_op != "" # whether this is a DXIL operation
self.is_reserved = self.dxil_class == "Reserved"
self.shader_model_translated = () # minimum shader model required with translation by linker
self.props = {} # extra properties
def __str__(self):
return self.name
def fully_qualified_name(self):
return "{}::{}".format(self.fully_qualified_name_prefix, self.name)
class db_dxil_metadata(object):
"A representation for a metadata record"
def __init__(self, name, doc, **kwargs):
self.name = name # named metadata, possibly empty
self.doc = doc # the documentation description of this record
for k, v in list(kwargs.items()):
setattr(self, k, v)
class db_dxil_param(object):
"The parameter description for a DXIL instruction"
def __init__(self, pos, llvm_type, name, doc, **kwargs):
self.pos = pos # position in parameter list
self.llvm_type = llvm_type # llvm type name, $o for overload, $r for resource type, $cb for legacy cbuffer, $u4 for u4 struct
self.name = name # short, unique name
self.doc = doc # the documentation description of this parameter
self.is_const = (
False # whether this argument requires a constant value in the IR
)
self.enum_name = "" # the name of the enum type if applicable
self.max_value = None # the maximum value for this parameter if applicable
for k, v in kwargs.items():
setattr(self, k, v)
class db_dxil_pass(object):
"The description for a DXIL optimization pass"
def __init__(self, name, **kwargs):
self.name = name # name for the option, typically the command-line switch name
self.args = [] # modifiers for the option
self.type_name = "" # name of the class that implements the pass
self.doc = "" # documentation for the pass
self.category_lib = "" # lib which pass belongs to
for k, v in kwargs.items():
setattr(self, k, v)
class db_dxil_pass_arg(object):
"An argument to a DXIL optimization pass"
def __init__(self, name, **kwargs):
self.name = name # name for the option, typically the command-line switch name
self.ident = "" # identifier for a parameter or global switch
self.is_ctor_param = False # whether this is a constructor parameter
for k, v in kwargs.items():
setattr(self, k, v)
if self.is_ctor_param:
self.is_ctor_param = True
class db_dxil_valrule(object):
"The description of a validation rule."
def __init__(self, name, id, **kwargs):
self.name = name.upper() # short, unique name, eg META.KNOWN
self.rule_id = id # unique identifier
self.enum_name = name.replace(".", "") # remove period for enum name
self.group_name = self.name[: self.name.index(".")] # group name, eg META
self.rule_name = self.name[self.name.index(".") + 1 :] # rule name, eg KNOWN
self.definition = (
"Check" + self.group_name + self.rule_name
) # function name that defines this constraint
self.is_disabled = False # True if the validation rule does not apply
self.err_msg = "" # error message associated with rule
self.category = "" # classification for this rule
self.doc = "" # the documentation description of this rule
self.shader_stages = () # shader stages to which this applies, empty for all.
self.shader_model = 6, 0 # minimum shader model required
for k, v in list(kwargs.items()):
setattr(self, k, v)
def __str__(self):
return self.name
class db_dxil(object):
"A database of DXIL instruction data"
def __init__(self):
self.instr = [] # DXIL instructions
self.enums = [] # enumeration types
self.val_rules = [] # validation rules
self.metadata = [] # named metadata (db_dxil_metadata)
self.passes = [] # inventory of available passes (db_dxil_pass)
self.name_idx = {} # DXIL instructions by name
self.enum_idx = {} # enumerations by name
self.dxil_version_info = {}
# list of counters for instructions and dxil ops,
# starting with extra ones specified here
self.counters = extra_counters
self.populate_llvm_instructions()
self.call_instr = self.get_instr_by_llvm_name("CallInst")
self.populate_dxil_operations()
self.build_indices()
self.populate_extended_docs()
self.populate_categories_and_models()
self.build_opcode_enum()
self.mark_disallowed_operations()
self.populate_metadata()
self.populate_passes()
self.build_valrules()
self.build_semantics()
self.build_indices()
self.populate_counters()
def __str__(self):
return "\n".join(str(i) for i in self.instr)
def add_enum_type(self, name, doc, valNameDocTuples):
"Adds a new enumeration type with name/value/doc tuples"
self.enums.append(db_dxil_enum(name, doc, valNameDocTuples))
def build_indices(self):
"Build a name_idx dictionary with instructions and an enum_idx dictionary with enumeration types"
self.name_idx = {}
for i in self.instr:
self.name_idx[i.name] = i
self.enum_idx = {}
for i in self.enums:
self.enum_idx[i.name] = i
def build_opcode_enum(self):
# Build enumeration from instructions
OpCodeEnum = db_dxil_enum(
"OpCode", "Enumeration for operations specified by DXIL"
)
class_dict = {}
class_dict["LlvmInst"] = "LLVM Instructions"
for i in self.instr:
if i.is_dxil_op:
v = db_dxil_enum_value(i.dxil_op, i.dxil_opid, i.doc)
v.category = i.category
class_dict[i.dxil_class] = i.category
OpCodeEnum.values.append(v)
self.enums.append(OpCodeEnum)
OpCodeClass = db_dxil_enum(
"OpCodeClass",
"Groups for DXIL operations with equivalent function templates",
)
OpCodeClass.is_internal = True
for k, v in iter(class_dict.items()):
ev = db_dxil_enum_value(k, 0, None)
ev.category = v
OpCodeClass.values.append(ev)
self.enums.append(OpCodeClass)
def mark_disallowed_operations(self):
# Disallow indirect branching, unreachable instructions and support for exception unwinding.
for i in "IndirectBr,Invoke,Resume,LandingPad,Unreachable".split(","):
self.name_idx[i].is_allowed = False
for i in "UserOp1,UserOp2,VAArg".split(","):
self.name_idx[i].is_allowed = False
# Disallow conversions used for pointer math; GEP is used exclusively in the current model.
for i in "PtrToInt,IntToPtr".split(","):
self.name_idx[i].is_allowed = False
# Barrier supersedes Fence.
self.name_idx["Fence"].is_allowed = False
def verify_dense(self, it, pred, name_proj):
val = None
for i in it:
i_val = pred(i)
if not val is None:
assert val + 1 == i_val, (
"values in predicate are not sequential and dense, %d follows %d for %s"
% (i_val, val, name_proj(i))
)
val = i_val
def set_op_count_for_version(self, major, minor, op_count):
info = self.dxil_version_info.setdefault((major, minor), dict())
info["NumOpCodes"] = op_count
info["NumOpClasses"] = len(set([op.dxil_class for op in self.instr]))
def populate_categories_and_models(self):
"Populate the category and shader_stages member of instructions."
for (
i
) in "TempRegLoad,TempRegStore,MinPrecXRegLoad,MinPrecXRegStore,LoadInput,StoreOutput".split(
","
):
self.name_idx[i].category = "Temporary, indexable, input, output registers"
for (
i
) in "FAbs,Saturate,IsNaN,IsInf,IsFinite,IsNormal,Cos,Sin,Tan,Acos,Asin,Atan,Hcos,Hsin,Htan,Exp,Frc,Log,Sqrt,Rsqrt".split(
","
):
self.name_idx[i].category = "Unary float"
for i in "Round_ne,Round_ni,Round_pi,Round_z".split(","):
self.name_idx[i].category = "Unary float - rounding"
for i in "Bfrev,Countbits,FirstbitLo,FirstbitSHi".split(","):
self.name_idx[i].category = "Unary int"
for i in "FirstbitHi".split(","):
self.name_idx[i].category = "Unary uint"
for i in "FMax,FMin".split(","):
self.name_idx[i].category = "Binary float"
for i in "IMax,IMin,Add,Sub,Mul,SDiv,SRem,And,Or,Xor,AShr,LShr,Shl".split(","):
self.name_idx[i].category = "Binary int"
for i in "UMax,UMin,UMul,UDiv,URem".split(","):
self.name_idx[i].category = "Binary uint"
for i in "IMul".split(","):
self.name_idx[i].category = "Binary int with two outputs"
for i in "UMul,UDiv".split(","): # Rename this UDiv OpCode to UDivMod
self.name_idx[i].category = "Binary uint with two outputs"
for i in "UAddc,USubb".split(","):
self.name_idx[i].category = "Binary uint with carry or borrow"
for i in "FMad,Fma".split(","):
self.name_idx[i].category = "Tertiary float"
for i in "IMad,Msad,Ibfe".split(","):
self.name_idx[i].category = "Tertiary int"
for i in "UMad,Ubfe".split(","):
self.name_idx[i].category = "Tertiary uint"
for i in "Bfi".split(","):
self.name_idx[i].category = "Quaternary"
for i in "Dot2,Dot3,Dot4".split(","):
self.name_idx[i].category = "Dot"
for (
i
) in "CreateHandle,CBufferLoad,CBufferLoadLegacy,TextureLoad,TextureStore,TextureStoreSample,BufferLoad,BufferStore,BufferUpdateCounter,CheckAccessFullyMapped,GetDimensions,RawBufferLoad,RawBufferStore".split(
","
):
self.name_idx[i].category = "Resources"
for (
i
) in "Sample,SampleBias,SampleLevel,SampleGrad,SampleCmp,SampleCmpLevelZero,SampleCmpLevel,SampleCmpBias,SampleCmpGrad,Texture2DMSGetSamplePosition,RenderTargetGetSamplePosition,RenderTargetGetSampleCount".split(
","
):
self.name_idx[i].category = "Resources - sample"
for i in "Sample,SampleBias,SampleCmp,SampleCmpBias".split(","):
self.name_idx[i].shader_stages = (
"library",
"pixel",
"compute",
"amplification",
"mesh",
"node",
)
for i in "RenderTargetGetSamplePosition,RenderTargetGetSampleCount".split(","):
self.name_idx[i].shader_stages = ("pixel",)
for i in "TextureGather,TextureGatherCmp,TextureGatherRaw".split(","):
self.name_idx[i].category = "Resources - gather"
for i in "AtomicBinOp,AtomicCompareExchange".split(","):
self.name_idx[i].category = "Synchronization"
for i in "CalculateLOD,DerivCoarseX,DerivCoarseY,DerivFineX,DerivFineY".split(
","
):
self.name_idx[i].category = "Derivatives"
self.name_idx[i].shader_stages = (
"library",
"pixel",
"compute",
"amplification",
"mesh",
"node",
)
for (
i
) in "Discard,EvalSnapped,EvalSampleIndex,EvalCentroid,SampleIndex,Coverage,InnerCoverage,AttributeAtVertex".split(
","
):
self.name_idx[i].category = "Pixel shader"
self.name_idx[i].shader_stages = ("pixel",)
for i in "ThreadId,GroupId,ThreadIdInGroup,FlattenedThreadIdInGroup".split(","):
self.name_idx[i].category = "Compute/Mesh/Amplification/Node shader"
self.name_idx[i].shader_stages = (
"compute",
"mesh",
"amplification",
"node",
)
for i in "EmitStream,CutStream,EmitThenCutStream,GSInstanceID".split(","):
self.name_idx[i].category = "Geometry shader"
self.name_idx[i].shader_stages = ("geometry",)
for i in "LoadOutputControlPoint,LoadPatchConstant".split(","):
self.name_idx[i].category = "Domain and hull shader"
self.name_idx[i].shader_stages = ("domain", "hull")
for i in "DomainLocation".split(","):
self.name_idx[i].category = "Domain shader"
self.name_idx[i].shader_stages = ("domain",)
for i in "StorePatchConstant,OutputControlPointID".split(","):
self.name_idx[i].category = "Hull shader"
self.name_idx[i].shader_stages = ("hull",)
for i in "PrimitiveID".split(","):
self.name_idx[i].category = "Hull, Domain and Geometry shaders"
self.name_idx[i].shader_stages = ("geometry", "domain", "hull")
for i in "ViewID".split(","):
self.name_idx[i].category = "Graphics shader"
self.name_idx[i].shader_stages = (
"vertex",
"hull",
"domain",
"geometry",
"pixel",
"mesh",
)
for (
i
) in "MakeDouble,SplitDouble,LegacyDoubleToFloat,LegacyDoubleToSInt32,LegacyDoubleToUInt32".split(
","
):
self.name_idx[i].category = "Double precision"
for i in "CycleCounterLegacy".split(","):
self.name_idx[i].category = "Other"
for i in "LegacyF32ToF16,LegacyF16ToF32".split(","):
self.name_idx[i].category = "Legacy floating-point"
for i in self.instr:
if i.name.startswith("Wave"):
i.category = "Wave"
i.is_wave = True
i.shader_stages = (
"library",
"compute",
"amplification",
"mesh",
"pixel",
"vertex",
"hull",
"domain",
"geometry",
"raygeneration",
"intersection",
"anyhit",
"closesthit",
"miss",
"callable",
"node",
)
elif i.name.startswith("Quad"):
i.category = "Quad Wave Ops"
i.is_wave = True
i.shader_stages = (
"library",
"compute",
"amplification",
"mesh",
"pixel",
"node",
)
elif i.name.startswith("Bitcast"):
i.category = "Bitcasts with different sizes"
for i in "ViewID,AttributeAtVertex".split(","):
self.name_idx[i].shader_model = 6, 1
for i in "RawBufferLoad,RawBufferStore".split(","):
self.name_idx[i].shader_model = 6, 2
self.name_idx[i].shader_model_translated = 6, 0
for i in "DispatchRaysIndex,DispatchRaysDimensions".split(","):
self.name_idx[i].category = "Ray Dispatch Arguments"
self.name_idx[i].shader_model = 6, 3
self.name_idx[i].shader_stages = (
"library",
"raygeneration",
"intersection",
"anyhit",
"closesthit",
"miss",
"callable",
)
for i in "InstanceID,InstanceIndex,PrimitiveIndex".split(","):
self.name_idx[i].category = "Raytracing object space uint System Values"
self.name_idx[i].shader_model = 6, 3
self.name_idx[i].shader_stages = (
"library",
"intersection",
"anyhit",
"closesthit",
)
for i in "GeometryIndex".split(","):
self.name_idx[
i
].category = (
"Raytracing object space uint System Values, raytracing tier 1.1"
)
self.name_idx[i].shader_model = 6, 5
self.name_idx[i].shader_stages = (
"library",
"intersection",
"anyhit",
"closesthit",
)
for i in "HitKind".split(","):
self.name_idx[i].category = "Raytracing hit uint System Values"
self.name_idx[i].shader_model = 6, 3
self.name_idx[i].shader_stages = (
"library",
"intersection",
"anyhit",
"closesthit",
)
for i in "RayFlags".split(","):
self.name_idx[i].category = "Raytracing uint System Values"
self.name_idx[i].shader_model = 6, 3
self.name_idx[i].shader_stages = (
"library",
"intersection",
"anyhit",
"closesthit",
"miss",
)
for i in "WorldRayOrigin,WorldRayDirection".split(","):
self.name_idx[i].category = "Ray Vectors"
self.name_idx[i].shader_model = 6, 3
self.name_idx[i].shader_stages = (
"library",
"intersection",
"anyhit",
"closesthit",
"miss",
)
for i in "ObjectRayOrigin,ObjectRayDirection".split(","):
self.name_idx[i].category = "Ray object space Vectors"
self.name_idx[i].shader_model = 6, 3
self.name_idx[i].shader_stages = (
"library",
"intersection",
"anyhit",
"closesthit",
)
for i in "ObjectToWorld,WorldToObject".split(","):
self.name_idx[i].category = "Ray Transforms"
self.name_idx[i].shader_model = 6, 3
self.name_idx[i].shader_stages = (
"library",
"intersection",
"anyhit",
"closesthit",
)
for i in "RayTMin,RayTCurrent".split(","):
self.name_idx[i].category = "RayT"
self.name_idx[i].shader_model = 6, 3
self.name_idx[i].shader_stages = (
"library",
"intersection",
"anyhit",
"closesthit",
"miss",
)
for i in "IgnoreHit,AcceptHitAndEndSearch".split(","):
self.name_idx[i].category = "AnyHit Terminals"
self.name_idx[i].shader_model = 6, 3
self.name_idx[i].shader_stages = ("anyhit",)
for i in "CallShader".split(","):
self.name_idx[i].category = "Indirect Shader Invocation"
self.name_idx[i].shader_model = 6, 3
self.name_idx[i].shader_stages = (
"library",
"closesthit",
"raygeneration",
"miss",
"callable",
)
for i in "TraceRay".split(","):
self.name_idx[i].category = "Indirect Shader Invocation"
self.name_idx[i].shader_model = 6, 3
self.name_idx[i].shader_stages = (
"library",
"raygeneration",
"closesthit",
"miss",
)
for i in "ReportHit".split(","):
self.name_idx[i].category = "Indirect Shader Invocation"
self.name_idx[i].shader_model = 6, 3
self.name_idx[i].shader_stages = ("library", "intersection")
for i in "CreateHandleForLib".split(","):
self.name_idx[
i
].category = (
"Library create handle from resource struct (like HL intrinsic)"
)
self.name_idx[i].shader_model = 6, 3
self.name_idx[i].shader_model_translated = 6, 0
for i in "AnnotateHandle,CreateHandleFromBinding,CreateHandleFromHeap".split(
","
):
self.name_idx[i].category = "Get handle from heap"
self.name_idx[i].shader_model = 6, 6
for i in "AnnotateHandle,CreateHandleFromBinding".split(","):
self.name_idx[i].shader_model_translated = 6, 0
for i in "Dot4AddU8Packed,Dot4AddI8Packed,Dot2AddHalf".split(","):
self.name_idx[i].category = "Dot product with accumulate"
self.name_idx[i].shader_model = 6, 4
for i in "WaveMatch,WaveMultiPrefixOp,WaveMultiPrefixBitCount".split(","):
self.name_idx[i].category = "Wave"
self.name_idx[i].shader_model = 6, 5
for (
i
) in "SetMeshOutputCounts,EmitIndices,GetMeshPayload,StoreVertexOutput,StorePrimitiveOutput".split(
","
):
self.name_idx[i].category = "Mesh shader instructions"
self.name_idx[i].shader_stages = ("mesh",)
self.name_idx[i].shader_model = 6, 5
for i in "DispatchMesh".split(","):
self.name_idx[i].category = "Amplification shader instructions"
self.name_idx[i].shader_stages = ("amplification",)
self.name_idx[i].shader_model = 6, 5
for i in "WriteSamplerFeedback,WriteSamplerFeedbackBias".split(","):
self.name_idx[i].category = "Sampler Feedback"
self.name_idx[i].is_feedback = True
self.name_idx[i].is_gradient = True
self.name_idx[i].shader_model = 6, 5
self.name_idx[i].shader_stages = (
"library",
"pixel",
)
for i in "WriteSamplerFeedbackLevel,WriteSamplerFeedbackGrad".split(","):
self.name_idx[i].category = "Sampler Feedback"
self.name_idx[i].is_feedback = True
self.name_idx[i].shader_model = 6, 5
for i in (
"AllocateRayQuery,RayQuery_TraceRayInline,RayQuery_Proceed,RayQuery_Abort,RayQuery_CommitNonOpaqueTriangleHit,RayQuery_CommitProceduralPrimitiveHit,RayQuery_RayFlags,RayQuery_WorldRayOrigin,RayQuery_WorldRayDirection,RayQuery_RayTMin,"
+ "RayQuery_CandidateTriangleRayT,RayQuery_CommittedRayT,RayQuery_CandidateInstanceIndex,RayQuery_CandidateInstanceID,RayQuery_CandidateGeometryIndex,RayQuery_CandidatePrimitiveIndex,"
+ "RayQuery_CandidateObjectRayOrigin,RayQuery_CandidateObjectRayDirection,RayQuery_CommittedInstanceIndex,RayQuery_CommittedInstanceID,RayQuery_CommittedGeometryIndex,RayQuery_CommittedPrimitiveIndex,"
+ "RayQuery_CommittedObjectRayOrigin,RayQuery_CommittedObjectRayDirection,RayQuery_CandidateProceduralPrimitiveNonOpaque,RayQuery_CandidateTriangleFrontFace,RayQuery_CommittedTriangleFrontFace,"
+ "RayQuery_CandidateTriangleBarycentrics,RayQuery_CommittedTriangleBarycentrics,RayQuery_CommittedStatus,RayQuery_CandidateType,RayQuery_CandidateObjectToWorld3x4,"
+ "RayQuery_CandidateWorldToObject3x4,RayQuery_CommittedObjectToWorld3x4,RayQuery_CommittedWorldToObject3x4,RayQuery_CandidateInstanceContributionToHitGroupIndex,RayQuery_CommittedInstanceContributionToHitGroupIndex"
).split(","):
self.name_idx[i].category = "Inline Ray Query"
self.name_idx[i].shader_model = 6, 5
for i in "Unpack4x8".split(","):
self.name_idx[i].category = "Unpacking intrinsics"
self.name_idx[i].shader_model = 6, 6
for i in "Pack4x8".split(","):
self.name_idx[i].category = "Packing intrinsics"
self.name_idx[i].shader_model = 6, 6
for i in "IsHelperLane".split(","):
self.name_idx[i].category = "Helper Lanes"
self.name_idx[i].shader_model = 6, 6
for i in (
"WaveMatrix_Annotate,WaveMatrix_Depth,WaveMatrix_Fill,"
+ "WaveMatrix_LoadRawBuf,WaveMatrix_LoadGroupShared,WaveMatrix_StoreRawBuf,WaveMatrix_StoreGroupShared,"
+ "WaveMatrix_Multiply,WaveMatrix_MultiplyAccumulate,WaveMatrix_ScalarOp,"
+ "WaveMatrix_SumAccumulate,WaveMatrix_Add"
).split(","):
self.name_idx[i].category = "WaveMatrix"
self.name_idx[i].shader_model = 6, 9
self.name_idx[i].shader_stages = (
"library",
"compute",
)
for i in "QuadVote,TextureGatherRaw,SampleCmpLevel,TextureStoreSample".split(
","
):
self.name_idx[i].shader_model = 6, 7
for i in "QuadVote".split(","):
self.name_idx[i].shader_model_translated = 6, 0
for i in "CreateNodeOutputHandle".split(","):
self.name_idx[i].category = "Create/Annotate Node Handles"
self.name_idx[i].shader_model = 6, 8
self.name_idx[i].shader_stages = ("node",)
for i in "CreateNodeInputRecordHandle,AllocateNodeOutputRecords".split(","):
self.name_idx[i].category = "Create/Annotate Node Handles"
self.name_idx[i].shader_model = 6, 8
self.name_idx[i].shader_stages = ("node",)
for i in "IndexNodeHandle".split(","):
self.name_idx[i].category = "Create/Annotate Node Handles"
self.name_idx[i].shader_model = 6, 8
self.name_idx[i].shader_stages = ("node",) # TBD: add "library"
for i in "AnnotateNodeHandle,AnnotateNodeRecordHandle".split(","):
self.name_idx[i].category = "Create/Annotate Node Handles"
self.name_idx[i].shader_model = 6, 8
self.name_idx[i].shader_stages = ("node",) # TBD: add "library"
for i in "GetNodeRecordPtr".split(","):
self.name_idx[i].category = "Get Pointer to Node Record in Address Space 6"
self.name_idx[i].shader_model = 6, 8
self.name_idx[i].shader_stages = ("node",) # TBD: add "library"
for i in (
"IncrementOutputCount,OutputComplete,GetInputRecordCount,FinishedCrossGroupSharing,NodeOutputIsValid,GetRemainingRecursionLevels"
).split(","):
self.name_idx[i].category = "Work Graph intrinsics"
self.name_idx[i].shader_model = 6, 8
self.name_idx[i].shader_stages = ("node",)
# All barrier ops:
for i in "Barrier".split(","):
self.name_idx[i].category = "Synchronization"
self.name_idx[i].is_barrier = True
for i in "BarrierByMemoryType".split(","):
self.name_idx[i].category = "Synchronization"
self.name_idx[i].is_barrier = True
self.name_idx[i].shader_model = 6, 8
self.name_idx[i].shader_model_translated = 6, 0
for i in "BarrierByMemoryHandle".split(","):
self.name_idx[i].category = "Synchronization"
self.name_idx[i].is_barrier = True
self.name_idx[i].shader_model = 6, 8
for i in "BarrierByNodeRecordHandle".split(","):
self.name_idx[i].category = "Synchronization"
self.name_idx[i].is_barrier = True
self.name_idx[i].shader_model = 6, 8
self.name_idx[i].shader_stages = ("node",)
for i in "SampleCmpBias,SampleCmpGrad".split(","):
self.name_idx[i].category = "Comparison Samples"
self.name_idx[i].shader_model = 6, 8
for i in "StartVertexLocation,StartInstanceLocation".split(","):
self.name_idx[i].category = "Extended Command Information"
self.name_idx[i].shader_stages = ("vertex",)
self.name_idx[i].shader_model = 6, 8
def populate_llvm_instructions(self):
# Add instructions that map to LLVM instructions.
# This is basically include\llvm\IR\Instruction.def
#
# Some instructions don't have their operands defined here because they are
# very specific and expanding generality isn't worth it; for example,
# branching refers to basic block arguments.
retvoid_param = db_dxil_param(0, "v", "", "no return value")
retoload_param = db_dxil_param(0, "$o", "", "no return value")
oload_all_arith = "hfd1wil" # note that 8 is missing
oload_all_arith_v = "v" + oload_all_arith
oload_int_arith = "wil" # note that 8 is missing
oload_int_arith_b = "1wil" # note that 8 is missing
oload_float_arith = "hfd"
oload_cast_params = [
retoload_param,
db_dxil_param(1, "$o", "value", "Value to cast/convert"),
]
oload_binary_params = [
retoload_param,
db_dxil_param(1, "$o", "a", "first value"),
db_dxil_param(2, "$o", "b", "second value"),
]
self.add_llvm_instr(
"TERM",
1,
"Ret",
"ReturnInst",
"returns a value (possibly void), from a function.",
oload_all_arith_v,
[retoload_param],
)
self.add_llvm_instr(
"TERM",
2,
"Br",
"BranchInst",
"branches (conditional or unconditional)",
"",
[],
)
self.add_llvm_instr(
"TERM", 3, "Switch", "SwitchInst", "performs a multiway switch", "", []
)
self.add_llvm_instr(
"TERM", 4, "IndirectBr", "IndirectBrInst", "branches indirectly", "", []
)
self.add_llvm_instr(
"TERM",
5,
"Invoke",
"InvokeInst",
"invokes function with normal and exceptional returns",
"",
[],
)
self.add_llvm_instr(
"TERM",
6,
"Resume",
"ResumeInst",
"resumes the propagation of an exception",
"",
[],
)
self.add_llvm_instr(
"TERM", 7, "Unreachable", "UnreachableInst", "is unreachable", "", []
)
self.add_llvm_instr(
"BINARY",
8,
"Add",
"BinaryOperator",
"returns the sum of its two operands",
oload_int_arith,
oload_binary_params,
counters=("ints",),
)
self.add_llvm_instr(
"BINARY",
9,
"FAdd",
"BinaryOperator",
"returns the sum of its two operands",
oload_float_arith,
oload_binary_params,
counters=("floats",),
)
self.add_llvm_instr(
"BINARY",
10,
"Sub",
"BinaryOperator",
"returns the difference of its two operands",
oload_int_arith,
oload_binary_params,
counters=("ints",),
)
self.add_llvm_instr(
"BINARY",
11,
"FSub",
"BinaryOperator",
"returns the difference of its two operands",
oload_float_arith,
oload_binary_params,
counters=("floats",),
)
self.add_llvm_instr(
"BINARY",
12,
"Mul",
"BinaryOperator",
"returns the product of its two operands",
oload_int_arith,
oload_binary_params,
counters=("ints",),
)
self.add_llvm_instr(
"BINARY",
13,
"FMul",
"BinaryOperator",
"returns the product of its two operands",
oload_float_arith,
oload_binary_params,
counters=("floats",),
)
self.add_llvm_instr(
"BINARY",
14,
"UDiv",
"BinaryOperator",
"returns the quotient of its two unsigned operands",
oload_int_arith,
oload_binary_params,
counters=("uints",),
)
self.add_llvm_instr(
"BINARY",
15,
"SDiv",
"BinaryOperator",
"returns the quotient of its two signed operands",
oload_int_arith,
oload_binary_params,
counters=("ints",),
)
self.add_llvm_instr(
"BINARY",
16,
"FDiv",
"BinaryOperator",
"returns the quotient of its two operands",
oload_float_arith,
oload_binary_params,
counters=("floats",),
)
self.add_llvm_instr(
"BINARY",
17,
"URem",
"BinaryOperator",
"returns the remainder from the unsigned division of its two operands",
oload_int_arith,
oload_binary_params,
counters=("uints",),
)
self.add_llvm_instr(
"BINARY",
18,
"SRem",
"BinaryOperator",
"returns the remainder from the signed division of its two operands",
oload_int_arith,
oload_binary_params,
counters=("ints",),
)
self.add_llvm_instr(
"BINARY",
19,
"FRem",
"BinaryOperator",
"returns the remainder from the division of its two operands",
oload_float_arith,
oload_binary_params,
counters=("floats",),
)
self.add_llvm_instr(
"BINARY",
20,
"Shl",
"BinaryOperator",
"shifts left (logical)",
oload_int_arith,
oload_binary_params,
counters=("uints",),
)
self.add_llvm_instr(
"BINARY",
21,
"LShr",
"BinaryOperator",
"shifts right (logical), with zero bit fill",
oload_int_arith,
oload_binary_params,
counters=("uints",),
)
self.add_llvm_instr(
"BINARY",
22,
"AShr",
"BinaryOperator",
"shifts right (arithmetic), with 'a' operand sign bit fill",
oload_int_arith,
oload_binary_params,
counters=("ints",),
)
self.add_llvm_instr(
"BINARY",
23,
"And",
"BinaryOperator",
"returns a bitwise logical and of its two operands",
oload_int_arith_b,
oload_binary_params,
counters=("uints",),
)
self.add_llvm_instr(
"BINARY",
24,
"Or",
"BinaryOperator",
"returns a bitwise logical or of its two operands",
oload_int_arith_b,
oload_binary_params,
counters=("uints",),
)
self.add_llvm_instr(
"BINARY",
25,
"Xor",
"BinaryOperator",
"returns a bitwise logical xor of its two operands",
oload_int_arith_b,
oload_binary_params,
counters=("uints",),
)
self.add_llvm_instr(
"MEMORY",
26,
"Alloca",
"AllocaInst",
"allocates memory on the stack frame of the currently executing function",
"",
[],
)
self.add_llvm_instr(
"MEMORY", 27, "Load", "LoadInst", "reads from memory", "", []
)
self.add_llvm_instr(
"MEMORY", 28, "Store", "StoreInst", "writes to memory", "", []
)
self.add_llvm_instr(
"MEMORY",
29,
"GetElementPtr",
"GetElementPtrInst",
"gets the address of a subelement of an aggregate value",
"",
[],
)
self.add_llvm_instr(
"MEMORY",
30,
"Fence",
"FenceInst",
"introduces happens-before edges between operations",
"",
[],
counters=("fence",),
)
self.add_llvm_instr(
"MEMORY",
31,
"AtomicCmpXchg",