From ff2d490dc120708a2fcb6eea5880a6b7c6586a4b Mon Sep 17 00:00:00 2001 From: Dietrich Geisler Date: Mon, 17 Aug 2020 12:50:44 -0400 Subject: GPU Foreach Loop (#1498) * GPU Foreach Loop This PR introduces the completed GPU foreach loop and updates the heterogeneous-hello-world example to use it. This PR builds on the previous introduction of the GPU Foreach loop parsing and semantic checking PR (#1482) by introducing IR lowering and emmitting. THe new feature can be used by having a GPU_Foreach loop interacting with a named non-CPP entry point, and using the -heterogeneous flag. * Fix to path Co-authored-by: Tim Foley --- source/slang/slang-emit-c-like.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source/slang/slang-emit-c-like.cpp') diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index 0708bc9a8..9e9117dcd 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -2425,6 +2425,31 @@ void CLikeSourceEmitter::defaultEmitInstExpr(IRInst* inst, const EmitOpInfo& inO m_writer->emit(")"); break; } + case kIROp_GpuForeach: + { + auto operand = inst->getOperand(2); + if (as(operand)) + { + //emitOperand(operand->findDecoration(), getInfo(EmitOp::General)); + emitOperand(operand, getInfo(EmitOp::General)); + } + else + { + SLANG_UNEXPECTED("Expected 3rd operand to be a function"); + } + m_writer->emit("_wrapper("); + emitOperand(inst->getOperand(0), getInfo(EmitOp::General)); + m_writer->emit(", "); + emitOperand(inst->getOperand(1), getInfo(EmitOp::General)); + UInt argCount = inst->getOperandCount(); + for (UInt aa = 3; aa < argCount; ++aa) + { + m_writer->emit(", "); + emitOperand(inst->getOperand(aa), getInfo(EmitOp::General)); + } + m_writer->emit(")"); + break; + } default: diagnoseUnhandledInst(inst); break; -- cgit v1.2.3