From 453683bf44f2112719802eaac2b332d49eebd640 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 19 Aug 2024 15:03:56 -0700 Subject: Tuple swizzling, concat, comparison and `countof`. (#4856) * Tuple swizzling and element access. * Update proposal status. * Cleanup. * Fix merrge error. * Address review. --- source/slang/slang-ir.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source/slang/slang-ir.cpp') diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index c97c04f88..1441b0567 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -2802,6 +2802,11 @@ namespace Slang return getTupleType(SLANG_COUNT_OF(operands), operands); } + IRTypePack* IRBuilder::getTypePack(UInt count, IRType* const* types) + { + return (IRTypePack*)getType(kIROp_TypePack, count, (IRInst* const*)types); + } + IRExpandType* IRBuilder::getExpandTypeOrVal(IRType* type, IRInst* pattern, ArrayView capture) { ShortList args; @@ -4046,6 +4051,21 @@ namespace Slang return inst; } + IRInst* IRBuilder::emitMakeValuePack(IRType* type, UInt count, IRInst* const* args) + { + return emitIntrinsicInst(type, kIROp_MakeValuePack, count, args); + } + + IRInst* IRBuilder::emitMakeValuePack(UInt count, IRInst* const* args) + { + ShortList types; + for (UInt i = 0; i < count; ++i) + types.add(args[i]->getFullType()); + + auto type = getTypePack((UInt)types.getCount(), types.getArrayView().getBuffer()); + return emitIntrinsicInst(type, kIROp_MakeValuePack, count, args); + } + IRInst* IRBuilder::emitMakeTuple(IRType* type, UInt count, IRInst* const* args) { return emitIntrinsicInst(type, kIROp_MakeTuple, count, args); @@ -5778,6 +5798,19 @@ namespace Slang return inst; } + IRInst* IRBuilder::emitCountOf( + IRType* type, + IRInst* sizedType) + { + auto inst = createInst( + this, + kIROp_CountOf, + type, + sizedType); + addInst(inst); + return inst; + } + IRInst* IRBuilder::emitBitCast( IRType* type, IRInst* val) -- cgit v1.2.3