From 659d8ea5d8aad57f5e6fdbc48f94cc4b10b1c4d5 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 28 Jul 2020 17:05:13 -0700 Subject: 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 --- source/slang/slang-lower-to-ir.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'source') 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 : ValVisitorgetValueType()); - return getBuilder()->getPtrType(valueType); - } - IRType* visitDeclRefType(DeclRefType* type) { auto declRef = type->declRef; @@ -1490,6 +1484,19 @@ struct ValLoweringVisitor : ValVisitor& operands, Substitutions* subst) + { + if (!subst) return; + _collectSubstitutionArgs(operands, subst->outer); + if (auto genSubst = as(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 : ValVisitordeclRef.getDecl()->findModifier(); SLANG_ASSERT(intrinsicTypeModifier); IROp op = IROp(intrinsicTypeModifier->irOp); - return getBuilder()->getType(op); + List 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(operands.getCount()), + operands.getBuffer()); } // Lower a type where the type declaration being referenced is assumed -- cgit v1.2.3