diff options
| author | Dietrich Geisler <dag368@cornell.edu> | 2020-08-17 12:50:44 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-17 09:50:44 -0700 |
| commit | ff2d490dc120708a2fcb6eea5880a6b7c6586a4b (patch) | |
| tree | 4bab7a7353ed5e9149510a48227da029d40d9d97 /source/slang/slang-emit-c-like.cpp | |
| parent | 0640a10ab85f8be3c3c925cb70711560265e6548 (diff) | |
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 <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-emit-c-like.cpp')
| -rw-r--r-- | source/slang/slang-emit-c-like.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
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<IRFunc>(operand)) + { + //emitOperand(operand->findDecoration<IREntryPointDecoration>(), 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; |
