@@ -437,6 +437,25 @@ class SpirvBuilder {
437
437
QualType resultType, NonSemanticDebugPrintfInstructions instId,
438
438
llvm::ArrayRef<SpirvInstruction *> operands, SourceLocation);
439
439
440
+ SpirvInstruction *createIsNodePayloadValid (SpirvInstruction *payloadArray,
441
+ SpirvInstruction *nodeIndex,
442
+ SourceLocation);
443
+
444
+ SpirvInstruction *createNodePayloadArrayLength (SpirvInstruction *payloadArray,
445
+ SourceLocation);
446
+
447
+ SpirvInstruction *createAllocateNodePayloads (QualType resultType,
448
+ spv::Scope allocationScope,
449
+ SpirvInstruction *shaderIndex,
450
+ SpirvInstruction *recordCount,
451
+ SourceLocation);
452
+
453
+ void createEnqueueOutputNodePayloads (SpirvInstruction *payload,
454
+ SourceLocation);
455
+
456
+ SpirvInstruction *createFinishWritingNodePayload (SpirvInstruction *payload,
457
+ SourceLocation);
458
+
440
459
// / \brief Creates an OpMemoryBarrier or OpControlBarrier instruction with the
441
460
// / given flags. If execution scope (exec) is provided, an OpControlBarrier
442
461
// / is created; otherwise an OpMemoryBarrier is created.
@@ -445,6 +464,13 @@ class SpirvBuilder {
445
464
llvm::Optional<spv::Scope> exec, SourceLocation,
446
465
SourceRange range = {});
447
466
467
+ // / \brief Creates an OpMemoryBarrier or OpControlBarrier instruction with the
468
+ // / given flags. If execution scope (exec) has its low-order bit set, an
469
+ // / OpControlBarrier is created; otherwise an OpMemoryBarrier is created.
470
+ void createBarrier (SpirvInstruction *memoryScope,
471
+ SpirvInstruction *memorySemantics,
472
+ SpirvInstruction *execScope, SourceLocation);
473
+
448
474
// / \brief Creates an OpBitFieldInsert SPIR-V instruction for the given
449
475
// / arguments.
450
476
SpirvInstruction *createBitFieldInsert (QualType resultType,
@@ -609,14 +635,27 @@ class SpirvBuilder {
609
635
const std::vector<llvm::StringRef> &name,
610
636
llvm::StringRef content = " " );
611
637
638
+ // / \brief Adds an execution mode to the module under construction if it does
639
+ // / not already exist. Return the newly added instruction or the existing
640
+ // / instruction, if one already exists.
641
+ inline SpirvInstruction *addExecutionMode (SpirvFunction *entryPoint,
642
+ spv::ExecutionMode em,
643
+ SourceLocation);
644
+
612
645
// / \brief Adds an execution mode to the module under construction if it does
613
646
// / not already exist. Return the newly added instruction or the existing
614
647
// / instruction, if one already exists.
615
648
inline SpirvInstruction *addExecutionMode (SpirvFunction *entryPoint,
616
649
spv::ExecutionMode em,
617
650
llvm::ArrayRef<uint32_t > params,
618
- SourceLocation,
619
- bool useIdParams = false );
651
+ SourceLocation);
652
+
653
+ // / \brief Adds an execution mode to the module under construction if it does
654
+ // / not already exist. Return the newly added instruction or the existing
655
+ // / instruction, if one already exists.
656
+ inline SpirvInstruction *
657
+ addExecutionMode (SpirvFunction *entryPoint, spv::ExecutionMode em,
658
+ llvm::ArrayRef<SpirvInstruction *> params, SourceLocation);
620
659
621
660
// / \brief Adds an OpModuleProcessed instruction to the module under
622
661
// / construction.
@@ -759,6 +798,7 @@ class SpirvBuilder {
759
798
llvm::ArrayRef<SpirvConstant *> constituents,
760
799
bool specConst = false );
761
800
SpirvConstant *getConstantNull (QualType);
801
+ SpirvConstant *getConstantString (llvm::StringRef str, bool specConst = false );
762
802
SpirvUndef *getUndef (QualType);
763
803
764
804
SpirvString *createString (llvm::StringRef str);
@@ -960,17 +1000,52 @@ SpirvBuilder::setDebugSource(uint32_t major, uint32_t minor,
960
1000
return mainSource->getFile ();
961
1001
}
962
1002
1003
+ SpirvInstruction *SpirvBuilder::addExecutionMode (SpirvFunction *entryPoint,
1004
+ spv::ExecutionMode em,
1005
+ SourceLocation loc) {
1006
+ SpirvExecutionMode *mode = nullptr ;
1007
+ SpirvExecutionMode *existingInstruction =
1008
+ mod->findExecutionMode (entryPoint, em);
1009
+
1010
+ if (!existingInstruction) {
1011
+ mode = new (context)
1012
+ SpirvExecutionMode (loc, entryPoint, em, ArrayRef<uint32_t >());
1013
+ mod->addExecutionMode (mode);
1014
+ } else {
1015
+ mode = existingInstruction;
1016
+ }
1017
+
1018
+ return mode;
1019
+ }
1020
+
963
1021
SpirvInstruction *
964
1022
SpirvBuilder::addExecutionMode (SpirvFunction *entryPoint, spv::ExecutionMode em,
965
1023
llvm::ArrayRef<uint32_t > params,
966
- SourceLocation loc, bool useIdParams ) {
1024
+ SourceLocation loc) {
967
1025
SpirvExecutionMode *mode = nullptr ;
968
1026
SpirvExecutionMode *existingInstruction =
969
1027
mod->findExecutionMode (entryPoint, em);
970
1028
971
1029
if (!existingInstruction) {
972
- mode = new (context)
973
- SpirvExecutionMode (loc, entryPoint, em, params, useIdParams);
1030
+ mode = new (context) SpirvExecutionMode (loc, entryPoint, em, params);
1031
+ mod->addExecutionMode (mode);
1032
+ } else {
1033
+ mode = existingInstruction;
1034
+ }
1035
+
1036
+ return mode;
1037
+ }
1038
+
1039
+ SpirvInstruction *
1040
+ SpirvBuilder::addExecutionMode (SpirvFunction *entryPoint, spv::ExecutionMode em,
1041
+ llvm::ArrayRef<SpirvInstruction *> params,
1042
+ SourceLocation loc) {
1043
+ SpirvExecutionMode *mode = nullptr ;
1044
+ SpirvExecutionMode *existingInstruction =
1045
+ mod->findExecutionMode (entryPoint, em);
1046
+
1047
+ if (!existingInstruction) {
1048
+ mode = new (context) SpirvExecutionMode (loc, entryPoint, em, params);
974
1049
mod->addExecutionMode (mode);
975
1050
} else {
976
1051
mode = existingInstruction;
0 commit comments