diff options
Diffstat (limited to 'source/slang/slang-ir-specialize.cpp')
| -rw-r--r-- | source/slang/slang-ir-specialize.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/source/slang/slang-ir-specialize.cpp b/source/slang/slang-ir-specialize.cpp index f1de6e408..83e2cad70 100644 --- a/source/slang/slang-ir-specialize.cpp +++ b/source/slang/slang-ir-specialize.cpp @@ -288,17 +288,10 @@ struct SpecializationContext IRGeneric* g = generic; for (;;) { - // We can't specialize a generic if it is marked as - // being imported from an external module (in which - // case its definition is not available to us). - // - if (!isDefinition(g)) - return false; - // Given the generic `g`, we will find the value // it appears to return in its body. // - auto val = findGenericReturnVal(g); + const auto val = findGenericReturnVal(g); if (!val) return false; @@ -311,6 +304,29 @@ struct SpecializationContext continue; } + // HACK: there are conflicting features in our target intrinsic decorations + // Some reference generic parameter with the `$G0` syntax (the + // first generic parameter) while other have a predicate + // `boolean(T)` where the T is resolved properly in IR lowering. We + // need to specialize the latter and not the former. + // + // The solution is to remove the `$G` syntax and replace that with + // resolved types too. + bool intrinsicNeedsSpecialization = false; + for(const auto dec : val->getDecorations()) + { + // TODO: We should probably take into account our target to see if the intrinsic applies + if(const auto intrinsicDec = as<IRTargetIntrinsicDecoration>(dec)) + intrinsicNeedsSpecialization = intrinsicNeedsSpecialization || intrinsicDec->hasPredicate(); + } + + // We can't specialize a generic if it is marked as + // being imported from an external module (in which + // case its definition is not available to us). + // + if (!isDefinition(g) && !intrinsicNeedsSpecialization) + return false; + // We should never specialize intrinsic types. // // TODO: This logic assumes that having *any* target |
