diff options
| author | Yong He <yonghe@outlook.com> | 2023-08-09 20:11:09 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-09 20:11:09 -0700 |
| commit | f875d3f5ba9c1ddc6aa9a0960efd5ab27ae4e4c9 (patch) | |
| tree | 42dae9fd6c260dfdafe7ce4a1ffc392e799c855d /source/slang/slang-ir-lower-l-value-cast.cpp | |
| parent | 03a5bb4bc0391e2de3c2dfb9ff3213bc0ccd9664 (diff) | |
Support implciit casted swizzled lvalue. (#3077)
* Support implciit casted swizzled lvalue.
* Fix warnings.
* Fix.
* fix comment.
* Prefer mangled linkage name for global params.
* Update tests.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-lower-l-value-cast.cpp')
| -rw-r--r-- | source/slang/slang-ir-lower-l-value-cast.cpp | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/source/slang/slang-ir-lower-l-value-cast.cpp b/source/slang/slang-ir-lower-l-value-cast.cpp index cd03d2bd5..aca58cef3 100644 --- a/source/slang/slang-ir-lower-l-value-cast.cpp +++ b/source/slang/slang-ir-lower-l-value-cast.cpp @@ -166,15 +166,10 @@ struct LValueCastLoweringContext // convert in. // Okay we are going to replace the implicit casts with temporaries around call sites/uses. - List<IRInst*> useSites; + List<IRUse*> useSites; for (auto use = castInst->firstUse; use; use = use->nextUse) { - auto useSite = use->getUser(); - - if (useSites.indexOf(useSite) < 0) - { - useSites.add(useSite); - } + useSites.add(use); } // If there is a name hint on the source, we'll copy it over to the temporaries @@ -187,7 +182,8 @@ struct LValueCastLoweringContext for (auto useSite : useSites) { - builder.setInsertBefore(useSite); + auto user = useSite->getUser(); + builder.setInsertBefore(user); auto tmpVar = builder.emitVar(toValueType); if (nameHintDecoration) @@ -196,27 +192,17 @@ struct LValueCastLoweringContext } // If it's inout we convert via cast whats in the castOperand - if (castInst->getOp() == kIROp_InOutImplicitCast) + if (castInst->getOp() == kIROp_InOutImplicitCast && user->getOp() != kIROp_Store) { builder.emitStore(tmpVar, builder.emitCast(toValueType, builder.emitLoad(castOperand))); } // Convert the temporary back to the original location - builder.setInsertAfter(useSite); + builder.setInsertAfter(user); builder.emitStore(castOperand, builder.emitCast(fromValueType, builder.emitLoad(tmpVar))); // Go through all of the operands of the use inst relacing, with the temporary - const auto operandCount = Count(useSite->getOperandCount()); - auto operands = useSite->getOperands(); - - for (Index i = 0; i < operandCount; ++i) - { - auto& callSiteOperand = operands[i]; - if(callSiteOperand.get() == castInst) - { - callSiteOperand.set(tmpVar); - } - } + builder.replaceOperand(useSite, tmpVar); } // When we are done we can destroy the inst |
