From cd7f01b63a52eaaad00088524801e502bcb0f168 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 17 Jun 2020 13:08:27 -0700 Subject: Generate dynamic C++ code for the minimal test case. (#1391) * Add IR pass to lower generics into ordinary functions. * Fix project files * Emit dynamic C++ code for simple generics and witness tables. Fixes #1386. * Remove -dump-ir flag. * Fixups. --- source/slang/slang-lower-to-ir.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'source/slang/slang-lower-to-ir.cpp') diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index fa23b3307..01bd0e972 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1034,7 +1034,8 @@ struct ValLoweringVisitor : ValVisitordeclRef, - context->irBuilder->getWitnessTableType()); + context->irBuilder->getWitnessTableType( + lowerType(context, DeclRefType::create(context->astBuilder, val->declRef)))); } LoweredValInfo visitTransitiveSubtypeWitness( @@ -4480,8 +4481,8 @@ struct DeclLoweringVisitor : DeclVisitor { // This is a constraint on a global generic type parameters, // and so it should lower as a parameter of its own. - - auto inst = getBuilder()->emitGlobalGenericWitnessTableParam(); + auto supType = lowerType(context, decl->getSup().type); + auto inst = getBuilder()->emitGlobalGenericWitnessTableParam(supType); addLinkageDecoration(context, inst, decl); return LoweredValInfo::simple(inst); } @@ -5728,7 +5729,7 @@ struct DeclLoweringVisitor : DeclVisitor { // TODO: use a `TypeKind` to represent the // classifier of the parameter. - auto param = subBuilder->emitParam(nullptr); + auto param = subBuilder->emitParam(subBuilder->getTypeType()); addNameHint(context, param, typeParamDecl); setValue(subContext, typeParamDecl, LoweredValInfo::simple(param)); } @@ -5748,7 +5749,8 @@ struct DeclLoweringVisitor : DeclVisitor { // TODO: use a `WitnessTableKind` to represent the // classifier of the parameter. - auto param = subBuilder->emitParam(nullptr); + auto param = subBuilder->emitParam(subBuilder->getWitnessTableType( + lowerType(context, constraintDecl->sup.type))); addNameHint(context, param, constraintDecl); setValue(subContext, constraintDecl, LoweredValInfo::simple(param)); } @@ -6590,12 +6592,15 @@ IRInst* lowerSubstitutionArg( else if (auto declaredSubtypeWitness = as(val)) { // We need to look up the IR-level representation of the witness (which will be a witness table). + auto supType = lowerType( + context, + DeclRefType::create(context->astBuilder, declaredSubtypeWitness->declRef)); auto irWitnessTable = getSimpleVal( context, emitDeclRef( context, declaredSubtypeWitness->declRef, - context->irBuilder->getWitnessTableType())); + context->irBuilder->getWitnessTableType(supType))); return irWitnessTable; } else -- cgit v1.2.3