diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-08-17 14:51:09 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-08-17 14:51:09 -0700 |
| commit | ec8175c1f0afe3f7758f70da240aba03a791c3a9 (patch) | |
| tree | 53a6a509f3bba87d964ba3a5007b538db1d83a4e /source/slang/ir.cpp | |
| parent | 95348fdb623509eb22c04d4c7c19af8228c5a533 (diff) | |
[ir] Add support for "decorations" on instructions
The terminology here is similar to SPIR-V. For right now the only decoration exposed is a fairly brute-force one that just points back to a high-level declaration so that we can look up info on it that might affect how we print output.
Diffstat (limited to 'source/slang/ir.cpp')
| -rw-r--r-- | source/slang/ir.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index b6af6aabb..8e4f789ef 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -46,6 +46,16 @@ namespace Slang return &type; } + IRDecoration* IRInst::findDecorationImpl(IRDecorationOp decorationOp) + { + for( auto dd = firstDecoration; dd; dd = dd->next ) + { + if(dd->op == decorationOp) + return dd; + } + return nullptr; + } + // IRParam* IRFunc::getFirstParam() @@ -129,8 +139,6 @@ namespace Slang IRValue* inst = (IRInst*) malloc(size); memset(inst, 0, size); - IRUse* instArgs = inst->getArgs(); - auto module = builder->getModule(); if (!module || (type && type->op == kIROp_VoidType)) { @@ -793,6 +801,32 @@ namespace Slang return inst; } + IRDecoration* IRBuilder::addDecorationImpl( + IRInst* inst, + UInt decorationSize, + IRDecorationOp op) + { + auto decoration = (IRDecoration*) malloc(decorationSize); + memset(decoration, 0, decorationSize); + + decoration->op = op; + + decoration->next = inst->firstDecoration; + inst->firstDecoration = decoration; + + return decoration; + } + + IRHighLevelDeclDecoration* IRBuilder::addHighLevelDeclDecoration(IRInst* inst, Decl* decl) + { + auto decoration = addDecoration<IRHighLevelDeclDecoration>(inst, kIRDecorationOp_HighLevelDecl); + decoration->decl = decl; + return decoration; + } + + // + + struct IRDumpContext { FILE* file; |
