summaryrefslogtreecommitdiffstats
path: root/source/slang/ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/ir.cpp')
-rw-r--r--source/slang/ir.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp
index 9e39579f6..3a6410125 100644
--- a/source/slang/ir.cpp
+++ b/source/slang/ir.cpp
@@ -534,6 +534,25 @@ namespace Slang
&args[0]);
}
+ template<typename T>
+ static T* findOrEmitInst(
+ IRBuilder* builder,
+ IROp op,
+ IRType* type,
+ IRInst* arg1,
+ IRInst* arg2,
+ IRInst* arg3)
+ {
+ IRInst* args[] = { arg1, arg2, arg3 };
+ return (T*) findOrEmitInstImpl(
+ builder,
+ sizeof(T),
+ op,
+ type,
+ 3,
+ &args[0]);
+ }
+
//
bool operator==(IRConstantKey const& left, IRConstantKey const& right)
@@ -644,6 +663,20 @@ namespace Slang
elementCount);
}
+ IRType* IRBuilder::getMatrixType(
+ IRType* elementType,
+ IRValue* rowCount,
+ IRValue* columnCount)
+ {
+ return findOrEmitInst<IRMatrixType>(
+ this,
+ kIROp_MatrixType,
+ getTypeType(),
+ elementType,
+ rowCount,
+ columnCount);
+ }
+
IRType* IRBuilder::getTypeType()
{
return findOrEmitInst<IRType>(
@@ -931,6 +964,38 @@ namespace Slang
return inst;
}
+ IRInst* IRBuilder::emitElementExtract(
+ IRType* type,
+ IRValue* base,
+ IRValue* index)
+ {
+ auto inst = createInst<IRFieldAddress>(
+ this,
+ kIROp_getElement,
+ type,
+ base,
+ index);
+
+ addInst(inst);
+ return inst;
+ }
+
+ IRInst* IRBuilder::emitElementAddress(
+ IRType* type,
+ IRValue* basePtr,
+ IRValue* index)
+ {
+ auto inst = createInst<IRFieldAddress>(
+ this,
+ kIROp_getElementPtr,
+ type,
+ basePtr,
+ index);
+
+ addInst(inst);
+ return inst;
+ }
+
IRInst* IRBuilder::emitReturn(
IRValue* val)
{