diff options
| author | Yong He <yonghe@outlook.com> | 2024-08-19 15:03:56 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-19 15:03:56 -0700 |
| commit | 453683bf44f2112719802eaac2b332d49eebd640 (patch) | |
| tree | d399db4c9cba90c11980186d3df1ffcc4d423b5a /source/slang/slang-ir.cpp | |
| parent | ecf85df6eee3da76ef54b14e4ab083f22da89e46 (diff) | |
Tuple swizzling, concat, comparison and `countof`. (#4856)
* Tuple swizzling and element access.
* Update proposal status.
* Cleanup.
* Fix merrge error.
* Address review.
Diffstat (limited to 'source/slang/slang-ir.cpp')
| -rw-r--r-- | source/slang/slang-ir.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
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<IRInst*> capture) { ShortList<IRInst*> 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<IRType*> 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<IRInst>( + this, + kIROp_CountOf, + type, + sizedType); + addInst(inst); + return inst; + } + IRInst* IRBuilder::emitBitCast( IRType* type, IRInst* val) |
