diff options
| -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 |
