diff options
| author | Yong He <yonghe@outlook.com> | 2020-07-28 17:05:13 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-28 17:05:13 -0700 |
| commit | 659d8ea5d8aad57f5e6fdbc48f94cc4b10b1c4d5 (patch) | |
| tree | a34742c03e3d2b77b0b00557d91c9f078303670f /source/slang | |
| parent | cd106730ea52511a672c9c2c5c8697eaca3b57c8 (diff) | |
Generalize lowerSimpleIntrinsicType to include generic arguments (#1464)
* Generalize lowerSimpleIntrinsicType to include generic arguments
* Use recursion instead of loop to get the correct ordering for nested generics
Diffstat (limited to 'source/slang')
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 54e82848c..b115b8222 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1416,12 +1416,6 @@ struct ValLoweringVisitor : ValVisitor<ValLoweringVisitor, LoweredValInfo, Lower resultType); } - IRType* visitPtrType(PtrType* type) - { - IRType* valueType = lowerType(context, type->getValueType()); - return getBuilder()->getPtrType(valueType); - } - IRType* visitDeclRefType(DeclRefType* type) { auto declRef = type->declRef; @@ -1490,6 +1484,19 @@ struct ValLoweringVisitor : ValVisitor<ValLoweringVisitor, LoweredValInfo, Lower } } + // Lower substitution args and collect them into a list of IR operands. + void _collectSubstitutionArgs(List<IRInst*>& operands, Substitutions* subst) + { + if (!subst) return; + _collectSubstitutionArgs(operands, subst->outer); + if (auto genSubst = as<GenericSubstitution>(subst)) + { + for (auto arg : genSubst->args) + { + operands.add(lowerVal(context, arg).val); + } + } + } // Lower a type where the type declaration being referenced is assumed // to be an intrinsic type, which can thus be lowered to a simple IR // type with the appropriate opcode. @@ -1498,7 +1505,14 @@ struct ValLoweringVisitor : ValVisitor<ValLoweringVisitor, LoweredValInfo, Lower auto intrinsicTypeModifier = type->declRef.getDecl()->findModifier<IntrinsicTypeModifier>(); SLANG_ASSERT(intrinsicTypeModifier); IROp op = IROp(intrinsicTypeModifier->irOp); - return getBuilder()->getType(op); + List<IRInst*> operands; + // If there are any substitutions attached to the declRef, + // add them as operands of the IR type. + _collectSubstitutionArgs(operands, type->declRef.substitutions.substitutions); + return getBuilder()->getType( + op, + static_cast<UInt>(operands.getCount()), + operands.getBuffer()); } // Lower a type where the type declaration being referenced is assumed |
