summaryrefslogtreecommitdiff
path: root/source/slang/slang-ast-modifier.h
blob: 2929a53c21308a777681069eb709e7062950e6bc (plain)
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
// slang-ast-modifier.h

#pragma once

#include "slang-ast-base.h"

namespace Slang { 

// Syntax class definitions for modifiers.

// Simple modifiers have no state beyond their identity

class InModifier : public Modifier { SLANG_AST_CLASS(InModifier)};
class OutModifier : public Modifier { SLANG_AST_CLASS(OutModifier)};
class ConstModifier : public Modifier { SLANG_AST_CLASS(ConstModifier)};
class InstanceModifier : public Modifier { SLANG_AST_CLASS(InstanceModifier)};
class BuiltinModifier : public Modifier { SLANG_AST_CLASS(BuiltinModifier)};
class InlineModifier : public Modifier { SLANG_AST_CLASS(InlineModifier)};
class PublicModifier : public Modifier { SLANG_AST_CLASS(PublicModifier)};
class RequireModifier : public Modifier { SLANG_AST_CLASS(RequireModifier)};
class ParamModifier : public Modifier { SLANG_AST_CLASS(ParamModifier)};
class ExternModifier : public Modifier { SLANG_AST_CLASS(ExternModifier)};
class InputModifier : public Modifier { SLANG_AST_CLASS(InputModifier)};
class TransparentModifier : public Modifier { SLANG_AST_CLASS(TransparentModifier)};
class FromStdLibModifier : public Modifier { SLANG_AST_CLASS(FromStdLibModifier)};
class PrefixModifier : public Modifier { SLANG_AST_CLASS(PrefixModifier)};
class PostfixModifier : public Modifier { SLANG_AST_CLASS(PostfixModifier)};
class ExportedModifier : public Modifier { SLANG_AST_CLASS(ExportedModifier)};
class ConstExprModifier : public Modifier { SLANG_AST_CLASS(ConstExprModifier)};
class GloballyCoherentModifier : public Modifier { SLANG_AST_CLASS(GloballyCoherentModifier)};

    /// A modifier that indicates an `InheritanceDecl` should be ignored during name lookup (and related checks).
class IgnoreForLookupModifier : public Modifier { SLANG_AST_CLASS(IgnoreForLookupModifier) };

// A modifier that marks something as an operation that
// has a one-to-one translation to the IR, and thus
// has no direct definition in the high-level language.
//
class IntrinsicOpModifier : public Modifier 
{
    SLANG_AST_CLASS(IntrinsicOpModifier)
 
    // Token that names the intrinsic op.
    Token opToken;

    // The IR opcode for the intrinsic operation.
    //
    uint32_t op = 0;
};

// A modifier that marks something as an intrinsic function,
// for some subset of targets.
class TargetIntrinsicModifier : public Modifier 
{
    SLANG_AST_CLASS(TargetIntrinsicModifier)
 
    // Token that names the target that the operation
    // is an intrisic for.
    Token targetToken;

    // A custom definition for the operation
    Token definitionToken;
};

// A modifier that marks a declaration as representing a
// specialization that should be preferred on a particular
// target.
class SpecializedForTargetModifier : public Modifier 
{
    SLANG_AST_CLASS(SpecializedForTargetModifier)
 
    // Token that names the target that the operation
    // has been specialized for.
    Token targetToken;
};

// A modifier to tag something as an intrinsic that requires
// a certain GLSL extension to be enabled when used
class RequiredGLSLExtensionModifier : public Modifier 
{
    SLANG_AST_CLASS(RequiredGLSLExtensionModifier)
 
    Token extensionNameToken;
};

// A modifier to tag something as an intrinsic that requires
// a certain GLSL version to be enabled when used
class RequiredGLSLVersionModifier : public Modifier 
{
    SLANG_AST_CLASS(RequiredGLSLVersionModifier)
 
    Token versionNumberToken;
};


// A modifier to tag something as an intrinsic that requires
// a certain SPIRV version to be enabled when used. Specified as "major.minor"
class RequiredSPIRVVersionModifier : public Modifier 
{
    SLANG_AST_CLASS(RequiredSPIRVVersionModifier)
 
    SemanticVersion version;
};

// A modifier to tag something as an intrinsic that requires
// a certain CUDA SM version to be enabled when used. Specified as "major.minor"
class RequiredCUDASMVersionModifier : public Modifier 
{
    SLANG_AST_CLASS(RequiredCUDASMVersionModifier)
 
    SemanticVersion version;
};

class InOutModifier : public OutModifier 
{
    SLANG_AST_CLASS(InOutModifier)
};


// `__ref` modifier for by-reference parameter passing
class RefModifier : public Modifier 
{
    SLANG_AST_CLASS(RefModifier)
};


// This is a special sentinel modifier that gets added
// to the list when we have multiple variable declarations
// all sharing the same modifiers:
//
//     static uniform int a : FOO, *b : register(x0);
//
// In this case both `a` and `b` share the syntax
// for part of their modifier list, but then have
// their own modifiers as well:
//
//     a: SemanticModifier("FOO") --> SharedModifiers --> StaticModifier --> UniformModifier
//                                 /
//     b: RegisterModifier("x0")  /
//
class SharedModifiers : public Modifier 
{
    SLANG_AST_CLASS(SharedModifiers)
};


// A GLSL `layout` modifier
//
// We use a distinct modifier for each key that
// appears within the `layout(...)` construct,
// and each key might have an optional value token.
//
// TODO: We probably want a notion of  "modifier groups"
// so that we can recover good source location info
// for modifiers that were part of the same vs.
// different constructs.
class GLSLLayoutModifier : public Modifier 
{
    SLANG_ABSTRACT_AST_CLASS(GLSLLayoutModifier)
 

    // The token used to introduce the modifier is stored
    // as the `nameToken` field.

    // TODO: may want to accept a full expression here
    Token valToken;
};

// AST nodes to represent the begin/end of a `layout` modifier group
class GLSLLayoutModifierGroupMarker : public Modifier 
{
    SLANG_ABSTRACT_AST_CLASS(GLSLLayoutModifierGroupMarker)
};

class GLSLLayoutModifierGroupBegin : public GLSLLayoutModifierGroupMarker 
{
    SLANG_AST_CLASS(GLSLLayoutModifierGroupBegin)
};

class GLSLLayoutModifierGroupEnd : public GLSLLayoutModifierGroupMarker 
{
    SLANG_AST_CLASS(GLSLLayoutModifierGroupEnd)
};


// We divide GLSL `layout` modifiers into those we have parsed
// (in the sense of having some notion of their semantics), and
// those we have not.
class GLSLParsedLayoutModifier : public GLSLLayoutModifier 
{
    SLANG_ABSTRACT_AST_CLASS(GLSLParsedLayoutModifier)
};

class GLSLUnparsedLayoutModifier : public GLSLLayoutModifier 
{
    SLANG_AST_CLASS(GLSLUnparsedLayoutModifier)
};


// Specific cases for known GLSL `layout` modifiers that we need to work with
class GLSLConstantIDLayoutModifier : public GLSLParsedLayoutModifier 
{
    SLANG_AST_CLASS(GLSLConstantIDLayoutModifier)
};

class GLSLLocationLayoutModifier : public GLSLParsedLayoutModifier 
{
    SLANG_AST_CLASS(GLSLLocationLayoutModifier)
};


// A catch-all for single-keyword modifiers
class SimpleModifier : public Modifier 
{
    SLANG_AST_CLASS(SimpleModifier)
};


// Some GLSL-specific modifiers
class GLSLBufferModifier : public SimpleModifier 
{
    SLANG_AST_CLASS(GLSLBufferModifier)
};

class GLSLWriteOnlyModifier : public SimpleModifier 
{
    SLANG_AST_CLASS(GLSLWriteOnlyModifier)
};

class GLSLReadOnlyModifier : public SimpleModifier 
{
    SLANG_AST_CLASS(GLSLReadOnlyModifier)
};

class GLSLPatchModifier : public SimpleModifier 
{
    SLANG_AST_CLASS(GLSLPatchModifier)
};


// Indicates that this is a variable declaration that corresponds to
// a parameter block declaration in the source program.
class ImplicitParameterGroupVariableModifier : public Modifier 
{
    SLANG_AST_CLASS(ImplicitParameterGroupVariableModifier)
};


// Indicates that this is a type that corresponds to the element
// type of a parameter block declaration in the source program.
class ImplicitParameterGroupElementTypeModifier : public Modifier 
{
    SLANG_AST_CLASS(ImplicitParameterGroupElementTypeModifier)
};


// An HLSL semantic
class HLSLSemantic : public Modifier 
{
    SLANG_ABSTRACT_AST_CLASS(HLSLSemantic)
 
    Token name;
};

// An HLSL semantic that affects layout
class HLSLLayoutSemantic : public HLSLSemantic 
{
    SLANG_AST_CLASS(HLSLLayoutSemantic)
 
    Token registerName;
    Token componentMask;
};

// An HLSL `register` semantic
class HLSLRegisterSemantic : public HLSLLayoutSemantic 
{
    SLANG_AST_CLASS(HLSLRegisterSemantic)
 
    Token spaceName;
};

// TODO(tfoley): `packoffset`
class HLSLPackOffsetSemantic : public HLSLLayoutSemantic 
{
    SLANG_AST_CLASS(HLSLPackOffsetSemantic)
};


// An HLSL semantic that just associated a declaration with a semantic name
class HLSLSimpleSemantic : public HLSLSemantic 
{
    SLANG_AST_CLASS(HLSLSimpleSemantic)
};

// A semantic applied to a field of a ray-payload type, to control access
class RayPayloadAccessSemantic : public HLSLSemantic
{
    SLANG_AST_CLASS(RayPayloadAccessSemantic)

    List<Token> stageNameTokens;
};

class RayPayloadReadSemantic : public RayPayloadAccessSemantic
{
    SLANG_AST_CLASS(RayPayloadReadSemantic)
};

class RayPayloadWriteSemantic : public RayPayloadAccessSemantic
{
    SLANG_AST_CLASS(RayPayloadWriteSemantic)
};


// GLSL

// Directives that came in via the preprocessor, but
// that we need to keep around for later steps
class GLSLPreprocessorDirective : public Modifier 
{
    SLANG_AST_CLASS(GLSLPreprocessorDirective)
};


// A GLSL `#version` directive
class GLSLVersionDirective : public GLSLPreprocessorDirective 
{
    SLANG_AST_CLASS(GLSLVersionDirective)
 

    // Token giving the version number to use
    Token versionNumberToken;

    // Optional token giving the sub-profile to be used
    Token glslProfileToken;
};

// A GLSL `#extension` directive
class GLSLExtensionDirective : public GLSLPreprocessorDirective 
{
    SLANG_AST_CLASS(GLSLExtensionDirective)
 

    // Token giving the version number to use
    Token extensionNameToken;

    // Optional token giving the sub-profile to be used
    Token dispositionToken;
};

class ParameterGroupReflectionName : public Modifier 
{
    SLANG_AST_CLASS(ParameterGroupReflectionName)
 
    NameLoc nameAndLoc;
};

// A modifier that indicates a built-in base type (e.g., `float`)
class BuiltinTypeModifier : public Modifier 
{
    SLANG_AST_CLASS(BuiltinTypeModifier)
 
    BaseType tag;
};

// A modifier that indicates a built-in type that isn't a base type (e.g., `vector`)
//
// TODO(tfoley): This deserves a better name than "magic"
class MagicTypeModifier : public Modifier 
{
    SLANG_AST_CLASS(MagicTypeModifier)

        /// Modifier has a name so call this magicModifier to disambiguate
    String magicName;
    uint32_t tag = uint32_t(0);
};

// A modifier applied to declarations of builtin types to indicate how they
// should be lowered to the IR.
//
// TODO: This should really subsume `BuiltinTypeModifier` and
// `MagicTypeModifier` so that we don't have to apply all of them.
class IntrinsicTypeModifier : public Modifier 
{
    SLANG_AST_CLASS(IntrinsicTypeModifier)
 
    // The IR opcode to use when constructing a type
    uint32_t irOp;

    // Additional literal opreands to provide when creating instances.
    // (e.g., for a texture type this passes in shape/mutability info)
    List<uint32_t> irOperands;
};

// Modifiers that affect the storage layout for matrices
class MatrixLayoutModifier : public Modifier 
{
    SLANG_AST_CLASS(MatrixLayoutModifier)
};


// Modifiers that specify row- and column-major layout, respectively
class RowMajorLayoutModifier : public MatrixLayoutModifier 
{
    SLANG_AST_CLASS(RowMajorLayoutModifier)
};

class ColumnMajorLayoutModifier : public MatrixLayoutModifier 
{
    SLANG_AST_CLASS(ColumnMajorLayoutModifier)
};


// The HLSL flavor of those modifiers
class HLSLRowMajorLayoutModifier : public RowMajorLayoutModifier 
{
    SLANG_AST_CLASS(HLSLRowMajorLayoutModifier)
};

class HLSLColumnMajorLayoutModifier : public ColumnMajorLayoutModifier 
{
    SLANG_AST_CLASS(HLSLColumnMajorLayoutModifier)
};


// The GLSL flavor of those modifiers
//
// Note(tfoley): The GLSL versions of these modifiers are "backwards"
// in the sense that when a GLSL programmer requests row-major layout,
// we actually interpret that as requesting column-major. This makes
// sense because we interpret matrix conventions backwards from how
// GLSL specifies them.
class GLSLRowMajorLayoutModifier : public ColumnMajorLayoutModifier 
{
    SLANG_AST_CLASS(GLSLRowMajorLayoutModifier)
};

class GLSLColumnMajorLayoutModifier : public RowMajorLayoutModifier 
{
    SLANG_AST_CLASS(GLSLColumnMajorLayoutModifier)
};


// More HLSL Keyword

class InterpolationModeModifier : public Modifier 
{
    SLANG_ABSTRACT_AST_CLASS(InterpolationModeModifier)
 
};

// HLSL `nointerpolation` modifier
class HLSLNoInterpolationModifier : public InterpolationModeModifier 
{
    SLANG_AST_CLASS(HLSLNoInterpolationModifier)
};


// HLSL `noperspective` modifier
class HLSLNoPerspectiveModifier : public InterpolationModeModifier 
{
    SLANG_AST_CLASS(HLSLNoPerspectiveModifier)
};


// HLSL `linear` modifier
class HLSLLinearModifier : public InterpolationModeModifier 
{
    SLANG_AST_CLASS(HLSLLinearModifier)
};


// HLSL `sample` modifier
class HLSLSampleModifier : public InterpolationModeModifier 
{
    SLANG_AST_CLASS(HLSLSampleModifier)
};


// HLSL `centroid` modifier
class HLSLCentroidModifier : public InterpolationModeModifier 
{
    SLANG_AST_CLASS(HLSLCentroidModifier)
};

    /// Slang-defined `pervertex` modifier
class PerVertexModifier : public InterpolationModeModifier
{
    SLANG_AST_CLASS(PerVertexModifier)
};


// HLSL `precise` modifier
class PreciseModifier : public Modifier 
{
    SLANG_AST_CLASS(PreciseModifier)
};


// HLSL `shared` modifier (which is used by the effect system,
// and shouldn't be confused with `groupshared`)
class HLSLEffectSharedModifier : public Modifier 
{
    SLANG_AST_CLASS(HLSLEffectSharedModifier)
};


// HLSL `groupshared` modifier
class HLSLGroupSharedModifier : public Modifier 
{
    SLANG_AST_CLASS(HLSLGroupSharedModifier)
};


// HLSL `static` modifier (probably doesn't need to be
// treated as HLSL-specific)
class HLSLStaticModifier : public Modifier 
{
    SLANG_AST_CLASS(HLSLStaticModifier)
};


// HLSL `uniform` modifier (distinct meaning from GLSL
// use of the keyword)
class HLSLUniformModifier : public Modifier 
{
    SLANG_AST_CLASS(HLSLUniformModifier)
};


// HLSL `volatile` modifier (ignored)
class HLSLVolatileModifier : public Modifier 
{
    SLANG_AST_CLASS(HLSLVolatileModifier)
};


class AttributeTargetModifier : public Modifier 
{
    SLANG_AST_CLASS(AttributeTargetModifier)
 
    // A class to which the declared attribute type is applicable
    SyntaxClass<NodeBase> syntaxClass;
};

// Base class for checked and unchecked `[name(arg0, ...)]` style attribute.
class AttributeBase : public Modifier 
{
    SLANG_AST_CLASS(AttributeBase)
 
    List<Expr*> args;
};

// A `[name(...)]` attribute that hasn't undergone any semantic analysis.
// After analysis, this will be transformed into a more specific case.
class UncheckedAttribute : public AttributeBase 
{
    SLANG_AST_CLASS(UncheckedAttribute)

    SLANG_UNREFLECTED
    Scope* scope = nullptr;
};

// A `[name(arg0, ...)]` style attribute that has been validated.
class Attribute : public AttributeBase 
{
    SLANG_AST_CLASS(Attribute)
 
    AttributeArgumentValueDict intArgVals;
};

class UserDefinedAttribute : public Attribute 
{
    SLANG_AST_CLASS(UserDefinedAttribute)
 
};

class AttributeUsageAttribute : public Attribute 
{
    SLANG_AST_CLASS(AttributeUsageAttribute)
 
    SyntaxClass<NodeBase> targetSyntaxClass;
};

// An `[unroll]` or `[unroll(count)]` attribute
class UnrollAttribute : public Attribute 
{
    SLANG_AST_CLASS(UnrollAttribute)
 
    IntegerLiteralValue getCount();
};

class LoopAttribute : public Attribute 
{
    SLANG_AST_CLASS(LoopAttribute)
};
               // `[loop]`
class FastOptAttribute : public Attribute 
{
    SLANG_AST_CLASS(FastOptAttribute)
};
            // `[fastopt]`
class AllowUAVConditionAttribute : public Attribute 
{
    SLANG_AST_CLASS(AllowUAVConditionAttribute)
};
  // `[allow_uav_condition]`
class BranchAttribute : public Attribute 
{
    SLANG_AST_CLASS(BranchAttribute)
};
             // `[branch]`
class FlattenAttribute : public Attribute 
{
    SLANG_AST_CLASS(FlattenAttribute)
};
            // `[flatten]`
class ForceCaseAttribute : public Attribute 
{
    SLANG_AST_CLASS(ForceCaseAttribute)
};
          // `[forcecase]`
class CallAttribute : public Attribute 
{
    SLANG_AST_CLASS(CallAttribute)
};
               // `[call]`


// [[vk_push_constant]] [[push_constant]]
class PushConstantAttribute : public Attribute 
{
    SLANG_AST_CLASS(PushConstantAttribute)
};


// [[vk_shader_record]] [[shader_record]]
class ShaderRecordAttribute : public Attribute 
{
    SLANG_AST_CLASS(ShaderRecordAttribute)
};


// [[vk_binding]]
class GLSLBindingAttribute : public Attribute 
{
    SLANG_AST_CLASS(GLSLBindingAttribute)
 
    int32_t binding = 0;
    int32_t set = 0;
};

class GLSLSimpleIntegerLayoutAttribute : public Attribute 
{
    SLANG_AST_CLASS(GLSLSimpleIntegerLayoutAttribute)
 
    int32_t value = 0;
};

// [[vk_location]]
class GLSLLocationAttribute : public GLSLSimpleIntegerLayoutAttribute 
{
    SLANG_AST_CLASS(GLSLLocationAttribute)
};


// [[vk_index]]
class GLSLIndexAttribute : public GLSLSimpleIntegerLayoutAttribute 
{
    SLANG_AST_CLASS(GLSLIndexAttribute)
};


// TODO: for attributes that take arguments, the syntax node
// classes should provide accessors for the values of those arguments.

class MaxTessFactorAttribute : public Attribute 
{
    SLANG_AST_CLASS(MaxTessFactorAttribute)
};

class OutputControlPointsAttribute : public Attribute 
{
    SLANG_AST_CLASS(OutputControlPointsAttribute)
};

class OutputTopologyAttribute : public Attribute 
{
    SLANG_AST_CLASS(OutputTopologyAttribute)
};

class PartitioningAttribute : public Attribute 
{
    SLANG_AST_CLASS(PartitioningAttribute)
};

class PatchConstantFuncAttribute : public Attribute 
{
    SLANG_AST_CLASS(PatchConstantFuncAttribute)
 
    FuncDecl* patchConstantFuncDecl = nullptr;
};
class DomainAttribute : public Attribute 
{
    SLANG_AST_CLASS(DomainAttribute)
};


class EarlyDepthStencilAttribute : public Attribute 
{
    SLANG_AST_CLASS(EarlyDepthStencilAttribute)
};
  // `[earlydepthstencil]`

// An HLSL `[numthreads(x,y,z)]` attribute
class NumThreadsAttribute : public Attribute 
{
    SLANG_AST_CLASS(NumThreadsAttribute)
 
    // The number of threads to use along each axis
    //
    // TODO: These should be accessors that use the
    // ordinary `args` list, rather than side data.
    int32_t x;
    int32_t y;
    int32_t z;
};

class MaxVertexCountAttribute : public Attribute 
{
    SLANG_AST_CLASS(MaxVertexCountAttribute)
 
    // The number of max vertex count for geometry shader
    //
    // TODO: This should be an accessor that uses the
    // ordinary `args` list, rather than side data.
    int32_t value;
};

class InstanceAttribute : public Attribute 
{
    SLANG_AST_CLASS(InstanceAttribute)
 
    // The number of instances to run for geometry shader
    //
    // TODO: This should be an accessor that uses the
    // ordinary `args` list, rather than side data.
    int32_t value;
};

// A `[shader("stageName")]` attribute, which marks an entry point
// to be compiled, and specifies the stage for that entry point
class EntryPointAttribute : public Attribute 
{
    SLANG_AST_CLASS(EntryPointAttribute)
 
    // The resolved stage that the entry point is targetting.
    //
    // TODO: This should be an accessor that uses the
    // ordinary `args` list, rather than side data.
    Stage stage;
};

// A `[__vulkanRayPayload]` attribute, which is used in the
// standard library implementation to indicate that a variable
// actually represents the input/output interface for a Vulkan
// ray tracing shader to pass per-ray payload information.
class VulkanRayPayloadAttribute : public Attribute 
{
    SLANG_AST_CLASS(VulkanRayPayloadAttribute)
};


// A `[__vulkanCallablePayload]` attribute, which is used in the
// standard library implementation to indicate that a variable
// actually represents the input/output interface for a Vulkan
// ray tracing shader to pass payload information to/from a callee.
class VulkanCallablePayloadAttribute : public Attribute 
{
    SLANG_AST_CLASS(VulkanCallablePayloadAttribute)
};


// A `[__vulkanHitAttributes]` attribute, which is used in the
// standard library implementation to indicate that a variable
// actually represents the output interface for a Vulkan
// intersection shader to pass hit attribute information.
class VulkanHitAttributesAttribute : public Attribute 
{
    SLANG_AST_CLASS(VulkanHitAttributesAttribute)
};


// A `[mutating]` attribute, which indicates that a member
// function is allowed to modify things through its `this`
// argument.
//
class MutatingAttribute : public Attribute 
{
    SLANG_AST_CLASS(MutatingAttribute)
};

// A `[nonmutating]` attribute, which indicates that a
// `set` accessor does not need to modify anything through
// its `this` parameter.
//
class NonmutatingAttribute : public Attribute
{
    SLANG_AST_CLASS(NonmutatingAttribute)
};


// A `[__readNone]` attribute, which indicates that a function
// computes its results strictly based on argument values, without
// reading or writing through any pointer arguments, or any other
// state that could be observed by a caller.
//
class ReadNoneAttribute : public Attribute 
{
    SLANG_AST_CLASS(ReadNoneAttribute)
};



// HLSL modifiers for geometry shader input topology
class HLSLGeometryShaderInputPrimitiveTypeModifier : public Modifier 
{
    SLANG_AST_CLASS(HLSLGeometryShaderInputPrimitiveTypeModifier)
};

class HLSLPointModifier : public HLSLGeometryShaderInputPrimitiveTypeModifier 
{
    SLANG_AST_CLASS(HLSLPointModifier)
};

class HLSLLineModifier : public HLSLGeometryShaderInputPrimitiveTypeModifier 
{
    SLANG_AST_CLASS(HLSLLineModifier)
};

class HLSLTriangleModifier : public HLSLGeometryShaderInputPrimitiveTypeModifier 
{
    SLANG_AST_CLASS(HLSLTriangleModifier)
};

class HLSLLineAdjModifier : public HLSLGeometryShaderInputPrimitiveTypeModifier 
{
    SLANG_AST_CLASS(HLSLLineAdjModifier)
};

class HLSLTriangleAdjModifier : public HLSLGeometryShaderInputPrimitiveTypeModifier 
{
    SLANG_AST_CLASS(HLSLTriangleAdjModifier)
};

// A modifier to indicate that a constructor/initializer can be used
// to perform implicit type conversion, and to specify the cost of
// the conversion, if applied.
class ImplicitConversionModifier : public Modifier 
{
    SLANG_AST_CLASS(ImplicitConversionModifier)
 
    // The conversion cost, used to rank conversions
    ConversionCost cost;
};

class FormatAttribute : public Attribute 
{
    SLANG_AST_CLASS(FormatAttribute)
 
    ImageFormat format;
};

class AllowAttribute : public Attribute 
{
    SLANG_AST_CLASS(AllowAttribute)
 
    DiagnosticInfo const* diagnostic = nullptr;
};


// A `[__extern]` attribute, which indicates that a function/type is defined externally
//
class ExternAttribute : public Attribute 
{
    SLANG_AST_CLASS(ExternAttribute)
};


// An `[__unsafeForceInlineExternal]` attribute indicates that the callee should be inlined
// into call sites after initial IR generation (that is, as early as possible).
//
class UnsafeForceInlineEarlyAttribute : public Attribute 
{
    SLANG_AST_CLASS(UnsafeForceInlineEarlyAttribute)
};

    /// An attribute that marks a type declaration as either allowing or
    /// disallowing the type to be inherited from in other modules.
class InheritanceControlAttribute : public Attribute { SLANG_AST_CLASS(InheritanceControlAttribute) };

    /// An attribute that marks a type declaration as allowing the type to be inherited from in other modules.
class OpenAttribute : public InheritanceControlAttribute { SLANG_AST_CLASS(OpenAttribute) };

    /// An attribute that marks a type declaration as disallowing the type to be inherited from in other modules.
class SealedAttribute : public InheritanceControlAttribute { SLANG_AST_CLASS(SealedAttribute) };

    /// An attribute that marks a decl as a compiler built-in object.
class BuiltinAttribute : public Attribute
{
    SLANG_AST_CLASS(BuiltinAttribute)
};

    /// An attribute that defines the size of `AnyValue` type to represent a polymoprhic value that conforms to
    /// the decorated interface type.
class AnyValueSizeAttribute : public Attribute
{
    SLANG_AST_CLASS(AnyValueSizeAttribute)

    int32_t size;
};

    /// A `[__requiresNVAPI]` attribute indicates that the declaration being modifed
    /// requires NVAPI operations for its implementation on D3D.
class RequiresNVAPIAttribute : public Attribute
{
    SLANG_AST_CLASS(RequiresNVAPIAttribute)
};

    /// Indicates that the modified declaration is one of the "magic" declarations
    /// that NVAPI uses to communicate extended operations. When NVAPI is being included
    /// via the prelude for downstream compilation, declarations with this modifier
    /// will not be emitted, instead allowing the versions from the prelude to be used.
class NVAPIMagicModifier : public Modifier
{
    SLANG_AST_CLASS(NVAPIMagicModifier)
};

    /// A modifier that attaches to a `ModuleDecl` to indicate the register/space binding
    /// that NVAPI wants to use, as indicated by, e.g., the `NV_SHADER_EXTN_SLOT` and
    /// `NV_SHADER_EXTN_REGISTER_SPACE` preprocessor definitions.
class NVAPISlotModifier : public Modifier
{
    SLANG_AST_CLASS(NVAPISlotModifier)

        /// The name of the register that is to be used (e.g., `"u3"`)
        ///
        /// This value will come from the `NV_SHADER_EXTN_SLOT` macro, if set.
        ///
        /// The `registerName` field must always be filled in when adding
        /// an `NVAPISlotModifier` to a module; if no register name is defined,
        /// then the modifier should not be added.
        ///
    String registerName;

        /// The name of the register space to be used (e.g., `space1`)
        ///
        /// This value will come from the `NV_SHADER_EXTN_REGISTER_SPACE` macro,
        /// if set.
        ///
        /// It is valid for a user to specify a register name but not a space name,
        /// and in that case `spaceName` will be set to `"space0"`.
    String spaceName;
};

    /// A `[noinline]` attribute represents a request by the application that,
    /// to the extent possible, a function should not be inlined into call sites.
    ///
    /// Note that due to various limitations of different targets, it is entirely
    /// possible for such functions to be inlined or specialized to call sites.
    ///
class NoInlineAttribute : public Attribute
{
    SLANG_AST_CLASS(NoInlineAttribute)
};

    /// A `[payload]` attribute indicates that a `struct` type will be used as
    /// a ray payload for `TraceRay()` calls, and thus also as input/output
    /// for shaders in the ray tracing pipeline that might be invoked for
    /// such a ray.
    ///
class PayloadAttribute : public Attribute
{
    SLANG_AST_CLASS(PayloadAttribute)
};

} // namespace Slang