diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-09-11 15:25:31 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-09-11 15:27:08 -0700 |
| commit | 4644b64d648893718336d83fae0139ee19405e61 (patch) | |
| tree | f7c623dc814b823a535d38b68029f529af36780f /source/slang/ir.cpp | |
| parent | e2de1eaec725e979f98ad6f518b93b4d9ce55a36 (diff) | |
Get another test working with IR codedgen
- Add support for matrix types in IR/codegen
- Add support for basic indexing operations in IR/codegen
Diffstat (limited to 'source/slang/ir.cpp')
| -rw-r--r-- | source/slang/ir.cpp | 65 |
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) { |
