summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-cpp.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-03-26 13:59:11 -0700
committerGitHub <noreply@github.com>2023-03-26 13:59:11 -0700
commitd64ee86a3130f8eeb75d09193c38c621d7565eba (patch)
treefed25a0cc2a7372d26175774f5983bed693e6b64 /source/slang/slang-emit-cpp.cpp
parent666af0962b6ab41489a3a3287db83f77c2f6461a (diff)
Add PyTorch C++ binding generation. (#2734)
* Add PyTorch C++ binding generation. * fix --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-emit-cpp.cpp')
-rw-r--r--source/slang/slang-emit-cpp.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp
index 2a2ae06c6..346926712 100644
--- a/source/slang/slang-emit-cpp.cpp
+++ b/source/slang/slang-emit-cpp.cpp
@@ -304,6 +304,18 @@ SlangResult CPPSourceEmitter::calcTypeName(IRType* type, CodeGenTarget target, S
out << ">";
return SLANG_OK;
}
+ case kIROp_TargetTupleType:
+ {
+ out << "std::tuple<";
+ for (UInt i = 0; i < type->getOperandCount(); i++)
+ {
+ if (i > 0) out << ", ";
+ auto elementType = (IRType*)type->getOperand(i);
+ SLANG_RETURN_ON_FAIL(calcTypeName(elementType, target, out));
+ }
+ out << ">";
+ return SLANG_OK;
+ }
default:
{
if (isNominalOp(type->getOp()))
@@ -1187,6 +1199,19 @@ bool CPPSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOut
return true;
}
+ case kIROp_MakeTargetTuple:
+ {
+ m_writer->emit("std::make_tuple(");
+ for (UInt i = 0; i < inst->getOperandCount(); i++)
+ {
+ if (i > 0)
+ m_writer->emit(", ");
+ auto arg = inst->getOperand(i);
+ emitOperand(arg, getInfo(EmitOp::General));
+ }
+ m_writer->emit(")");
+ return true;
+ }
case kIROp_CastFloatToInt:
case kIROp_CastIntToFloat:
case kIROp_FloatCast: