summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-c-like.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-10-17 22:22:34 -0700
committerGitHub <noreply@github.com>2024-10-17 22:22:34 -0700
commit12e891ed9ac934adbcc4160da6a05938cc38b529 (patch)
treea519a57b0e7a53c17f47bf43989a51e88f911f66 /source/slang/slang-emit-c-like.cpp
parenta618b8c5e249b0f20e6c0c95f9da1b5cbfdbf08b (diff)
Cleanup definition of `printf`. (#5330)
* Cleanup definition of `printf`. * Fix. * Fix spirv generation. * Fix. * enhance test.
Diffstat (limited to 'source/slang/slang-emit-c-like.cpp')
-rw-r--r--source/slang/slang-emit-c-like.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp
index 79a9b1a56..dd5cb88d3 100644
--- a/source/slang/slang-emit-c-like.cpp
+++ b/source/slang/slang-emit-c-like.cpp
@@ -2847,6 +2847,26 @@ void CLikeSourceEmitter::defaultEmitInstExpr(IRInst* inst, const EmitOpInfo& inO
}
break;
}
+ case kIROp_Printf:
+ {
+ m_writer->emit("printf(");
+ emitOperand(inst->getOperand(0), getInfo(EmitOp::General));
+ if (inst->getOperandCount() == 2)
+ {
+ auto operand = inst->getOperand(1);
+ if (auto makeStruct = as<IRMakeStruct>(operand))
+ {
+ // Flatten the tuple resulting from the variadic pack.
+ for (UInt bb = 0; bb < makeStruct->getOperandCount(); ++bb)
+ {
+ m_writer->emit(", ");
+ emitOperand(makeStruct->getOperand(bb), getInfo(EmitOp::General));
+ }
+ }
+ }
+ m_writer->emit(")");
+ break;
+ }
case kIROp_RequireGLSLExtension:
{
break; //should already have set requirement; case covered for empty intrinsic block