diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2019-01-28 14:21:21 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-28 14:21:21 -0800 |
| commit | adb3e222393a780de41f258bd273fa3231db10c0 (patch) | |
| tree | 1d39bbf22e31dbc0e1d3861258dbcbbeb0dc3bc6 /source/slang/ir-existential.cpp | |
| parent | 3b9573af2c1c898eb8c5b98b6d29cd3889579a51 (diff) | |
| parent | 3c3513ab501277333d1062ad2737ac4a60dac6f7 (diff) | |
Merge branch 'master' into yong-fix2
Diffstat (limited to 'source/slang/ir-existential.cpp')
| -rw-r--r-- | source/slang/ir-existential.cpp | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/source/slang/ir-existential.cpp b/source/slang/ir-existential.cpp deleted file mode 100644 index af15472bf..000000000 --- a/source/slang/ir-existential.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// ir-existential.cpp -#include "ir-existential.h" - -#include "ir.h" -#include "ir-insts.h" - -namespace Slang { - -struct ExistentialTypeSimplificationContext -{ - List<IRInst*> instsToRemove; - -}; - -void simplifyExistentialTypesRec( - ExistentialTypeSimplificationContext* context, - IRInst* inst) -{ - switch( inst->op ) - { - default: - break; - - case kIROp_ExtractExistentialValue: - { - auto arg = inst->getOperand(0); - if( auto makeExistential = as<IRMakeExistential>(arg) ) - { - auto value = makeExistential->getWrappedValue(); - inst->replaceUsesWith(value); - context->instsToRemove.Add(inst); - } - } - break; - - case kIROp_ExtractExistentialType: - { - auto arg = inst->getOperand(0); - if( auto makeExistential = as<IRMakeExistential>(arg) ) - { - auto value = makeExistential->getWrappedValue(); - inst->replaceUsesWith(value->getFullType()); - context->instsToRemove.Add(inst); - } - } - break; - - case kIROp_ExtractExistentialWitnessTable: - { - auto arg = inst->getOperand(0); - if( auto makeExistential = as<IRMakeExistential>(arg) ) - { - auto witnessTable = makeExistential->getWitnessTable(); - inst->replaceUsesWith(witnessTable); - context->instsToRemove.Add(inst); - } - } - break; - } - - for( auto childInst : inst->getChildren() ) - { - simplifyExistentialTypesRec(context, childInst); - } -} - -void removeUnusedExistentialsRec( - ExistentialTypeSimplificationContext* context, - IRInst* inst) -{ - switch( inst->op ) - { - default: - break; - - case kIROp_MakeExistential: - { - if( !inst->hasUses() ) - { - context->instsToRemove.Add(inst); - } - } - break; - } - - for( auto childInst : inst->getChildren() ) - { - removeUnusedExistentialsRec(context, childInst); - } -} - -void simplifyExistentialTypes( - IRModule* module) -{ - { - ExistentialTypeSimplificationContext context; - simplifyExistentialTypesRec(&context, module->getModuleInst()); - for( auto inst : context.instsToRemove ) - { - inst->removeAndDeallocate(); - } - } - - { - ExistentialTypeSimplificationContext context; - removeUnusedExistentialsRec(&context, module->getModuleInst()); - for( auto inst : context.instsToRemove ) - { - inst->removeAndDeallocate(); - } - } -} - -} // namespace Slang |
