diff options
| author | Yong He <yonghe@outlook.com> | 2020-06-15 13:55:56 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-15 13:55:56 -0700 |
| commit | 3461ed41118480c3494f810cddd3cd8c735e2fbb (patch) | |
| tree | 74e8546df4ec1a0dd888bfb8617cbb651cbc0795 /source | |
| parent | d84cfb766b089c03f9545588a8590efea1749770 (diff) | |
Specialize function calls involving array arguments. (#1389)
Fixes #890.
Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-ir-specialize-resources.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/source/slang/slang-ir-specialize-resources.cpp b/source/slang/slang-ir-specialize-resources.cpp index f72ca6b38..60439abeb 100644 --- a/source/slang/slang-ir-specialize-resources.cpp +++ b/source/slang/slang-ir-specialize-resources.cpp @@ -171,6 +171,27 @@ struct ResourceParameterSpecializationContext return anySpecializableParam; } + // Returns true if `type` is an `IRStructType` with array-typed fields. + bool isStructTypeWithArray(IRType* type) + { + if (auto structType = as<IRStructType>(type)) + { + for (auto field : structType->getFields()) + { + if (auto arrayType = as<IRArrayType>(field->getFieldType())) + { + return true; + } + if (auto subStructType = as<IRStructType>(field->getFieldType())) + { + if (isStructTypeWithArray(subStructType)) + return true; + } + } + } + return false; + } + // Of course, now we need to back-fill the predicates that // the above function used to evaluate prameters and arguments. @@ -209,6 +230,8 @@ struct ResourceParameterSpecializationContext return true; if(as<IRByteAddressBufferTypeBase>(type)) return true; + if (isStructTypeWithArray(type)) + return true; } // For now, we will not treat any other parameters as @@ -257,7 +280,7 @@ struct ResourceParameterSpecializationContext // of the indexing operation is also // suitable for specialization. // - if( arg->op == kIROp_getElement ) + if( arg->op == kIROp_getElement || arg->op == kIROp_Load ) { auto base = arg->getOperand(0); @@ -565,6 +588,11 @@ struct ResourceParameterSpecializationContext // ioInfo.newArgs.add(oldIndex); } + else if (oldArg->op == kIROp_Load) + { + auto oldBase = oldArg->getOperand(0); + getCallInfoForArg(ioInfo, oldBase); + } else { // If we fail to match any of the cases above @@ -718,6 +746,10 @@ struct ResourceParameterSpecializationContext return newVal; } + else if (oldArg->op == kIROp_Load) + { + return getSpecializedValueForArg(ioInfo, oldArg->getOperand(0)); + } else { // If we don't match one of the above cases, |
