diff options
| author | kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> | 2025-05-15 11:59:15 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-15 09:59:15 -0700 |
| commit | b325474c4aba52cca7e0bcd4eae02d23ca4ab9a3 (patch) | |
| tree | d0790bb56bec865743c95895aedaeb14f63312d7 /source/slang/slang-ir-clone.cpp | |
| parent | ed837e205f3e67c4ae112f544cfe486ca3cc8455 (diff) | |
Implement spec const for generic parameter (#7121)
Close #6840.
This PR add supports to use specialize constant in generic parameter, and that parameter can also be used as array size, e.g. following code should work:
```
struct MyStruct<let N: int> { float buffer[N]; }
MyStruct<SpecConstVar> s;
```
- Loose the restriction from Link-Time to SpecializationConstant when extract generic argument
- Tweak the logic of how we decide whether a inst is hoistable. Besides checking existing hoistable flag of each
IRInst, when we detect a IRInst's type is SpecConstRateType, we will treat that inst hoistable. Because IRInst in
global scope can be deduplicated, and every SpecConstRateType inst should be in the global scope or IRGeneric
scope (which will be at global scope after specialization).
- Remove the SpecConstIntVal to IRInst map in IR lowering logic, because we already have way to deduplicate the
global scope IR.
Diffstat (limited to 'source/slang/slang-ir-clone.cpp')
| -rw-r--r-- | source/slang/slang-ir-clone.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/source/slang/slang-ir-clone.cpp b/source/slang/slang-ir-clone.cpp index 5bb1c1210..1a020ec26 100644 --- a/source/slang/slang-ir-clone.cpp +++ b/source/slang/slang-ir-clone.cpp @@ -93,6 +93,9 @@ IRInst* cloneInstAndOperands(IRCloneEnv* env, IRBuilder* builder, IRInst* oldIns auto newOperand = findCloneForOperand(env, oldOperand); newOperands[ii] = newOperand; + + if (isArithmeticInst(oldInst)) + newType = maybeAddRateType(builder, newOperand->getFullType(), newType); } // Finally we create the inst with the updated operands. |
