@@ -437,6 +437,25 @@ class SpirvBuilder {
437437 QualType resultType, NonSemanticDebugPrintfInstructions instId,
438438 llvm::ArrayRef<SpirvInstruction *> operands, SourceLocation);
439439
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+
440459 // / \brief Creates an OpMemoryBarrier or OpControlBarrier instruction with the
441460 // / given flags. If execution scope (exec) is provided, an OpControlBarrier
442461 // / is created; otherwise an OpMemoryBarrier is created.
@@ -445,6 +464,13 @@ class SpirvBuilder {
445464 llvm::Optional<spv::Scope> exec, SourceLocation,
446465 SourceRange range = {});
447466
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+
448474 // / \brief Creates an OpBitFieldInsert SPIR-V instruction for the given
449475 // / arguments.
450476 SpirvInstruction *createBitFieldInsert (QualType resultType,
@@ -609,14 +635,27 @@ class SpirvBuilder {
609635 const std::vector<llvm::StringRef> &name,
610636 llvm::StringRef content = " " );
611637
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+
612645 // / \brief Adds an execution mode to the module under construction if it does
613646 // / not already exist. Return the newly added instruction or the existing
614647 // / instruction, if one already exists.
615648 inline SpirvInstruction *addExecutionMode (SpirvFunction *entryPoint,
616649 spv::ExecutionMode em,
617650 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);
620659
621660 // / \brief Adds an OpModuleProcessed instruction to the module under
622661 // / construction.
@@ -759,6 +798,7 @@ class SpirvBuilder {
759798 llvm::ArrayRef<SpirvConstant *> constituents,
760799 bool specConst = false );
761800 SpirvConstant *getConstantNull (QualType);
801+ SpirvConstant *getConstantString (llvm::StringRef str, bool specConst = false );
762802 SpirvUndef *getUndef (QualType);
763803
764804 SpirvString *createString (llvm::StringRef str);
@@ -960,17 +1000,52 @@ SpirvBuilder::setDebugSource(uint32_t major, uint32_t minor,
9601000 return mainSource->getFile ();
9611001}
9621002
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+
9631021SpirvInstruction *
9641022SpirvBuilder::addExecutionMode (SpirvFunction *entryPoint, spv::ExecutionMode em,
9651023 llvm::ArrayRef<uint32_t > params,
966- SourceLocation loc, bool useIdParams ) {
1024+ SourceLocation loc) {
9671025 SpirvExecutionMode *mode = nullptr ;
9681026 SpirvExecutionMode *existingInstruction =
9691027 mod->findExecutionMode (entryPoint, em);
9701028
9711029 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);
9741049 mod->addExecutionMode (mode);
9751050 } else {
9761051 mode = existingInstruction;
0 commit comments