From 876968ccadf96ff592061c61855d77c6071f89f5 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 13 Aug 2020 12:17:59 -0700 Subject: IR support for Tuple types. (#1492) * Tuple types. * Fix x86 warning * Improved deduplication Co-authored-by: Tim Foley --- source/slang/slang-ir.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'source/slang/slang-ir.cpp') diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 1a6187a92..13840a84a 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -2270,6 +2270,23 @@ namespace Slang return (IRAnyValueType*)getType(kIROp_AnyValueType, size); } + IRTupleType* IRBuilder::getTupleType(UInt count, IRType* const* types) + { + return (IRTupleType*)getType(kIROp_TupleType, count, (IRInst*const*)types); + } + + IRTupleType* IRBuilder::getTupleType(IRType* type0, IRType* type1) + { + IRType* operands[] = { type0, type1 }; + return getTupleType(2, operands); + } + + IRTupleType* IRBuilder::getTupleType(IRType* type0, IRType* type1, IRType* type2) + { + IRType* operands[] = { type0, type1, type2 }; + return getTupleType(3, operands); + } + IRBasicBlockType* IRBuilder::getBasicBlockType() { return (IRBasicBlockType*)getType(kIROp_BasicBlockType); @@ -2721,6 +2738,17 @@ namespace Slang return inst; } + IRInst* IRBuilder::emitMakeTuple(IRType* type, UInt count, IRInst* const* args) + { + return emitIntrinsicInst(type, kIROp_MakeTuple, count, args); + } + + IRInst* IRBuilder::emitGetTupleElement(IRType* type, IRInst* tuple, UInt element) + { + IRInst* args[] = { tuple, getIntValue(getIntType(), element) }; + return emitIntrinsicInst(type, kIROp_GetTupleElement, 2, args); + } + IRInst* IRBuilder::emitMakeVector( IRType* type, UInt argCount, -- cgit v1.2.3