diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 14:49:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 14:49:26 +0800 |
| commit | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch) | |
| tree | ea1d61342cd29368e19135000ec2948813096205 /source/slang/slang-ir-lower-reinterpret.cpp | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'source/slang/slang-ir-lower-reinterpret.cpp')
| -rw-r--r-- | source/slang/slang-ir-lower-reinterpret.cpp | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/source/slang/slang-ir-lower-reinterpret.cpp b/source/slang/slang-ir-lower-reinterpret.cpp index 34d4b77d9..9dd31aa4d 100644 --- a/source/slang/slang-ir-lower-reinterpret.cpp +++ b/source/slang/slang-ir-lower-reinterpret.cpp @@ -1,9 +1,10 @@ #include "slang-ir-lower-reinterpret.h" -#include "slang-ir.h" + +#include "slang-ir-any-value-inference.h" +#include "slang-ir-any-value-marshalling.h" #include "slang-ir-insts.h" #include "slang-ir-layout.h" -#include "slang-ir-any-value-marshalling.h" -#include "slang-ir-any-value-inference.h" +#include "slang-ir.h" namespace Slang { @@ -27,11 +28,8 @@ struct ReinterpretLoweringContext { switch (inst->getOp()) { - case kIROp_Reinterpret: - processReinterpret(inst); - break; - default: - break; + case kIROp_Reinterpret: processReinterpret(inst); break; + default: break; } } @@ -64,27 +62,37 @@ struct ReinterpretLoweringContext if (fromTypeSize < 0) { cantPack = true; - sink->diagnose(inst->sourceLoc, Slang::Diagnostics::typeCannotBePackedIntoAnyValue, fromType); + sink->diagnose( + inst->sourceLoc, + Slang::Diagnostics::typeCannotBePackedIntoAnyValue, + fromType); } SlangInt toTypeSize = getAnyValueSize(toType); if (toTypeSize < 0) { cantPack = true; - sink->diagnose(inst->sourceLoc, Slang::Diagnostics::typeCannotBePackedIntoAnyValue, toType); + sink->diagnose( + inst->sourceLoc, + Slang::Diagnostics::typeCannotBePackedIntoAnyValue, + toType); } - if (fromTypeSize != toTypeSize - && cantPack == false) + if (fromTypeSize != toTypeSize && cantPack == false) { - sink->diagnose(inst->sourceLoc, Slang::Diagnostics::notEqualReinterpretCastSize, fromType, fromTypeSize, toType, toTypeSize); + sink->diagnose( + inst->sourceLoc, + Slang::Diagnostics::notEqualReinterpretCastSize, + fromType, + fromTypeSize, + toType, + toTypeSize); } SlangInt anyValueSize = Math::Max(fromTypeSize, toTypeSize); IRBuilder builder(module); builder.setInsertBefore(inst); - auto anyValueType = builder.getAnyValueType(builder.getIntValue(builder.getUIntType(), anyValueSize)); - auto packInst = builder.emitPackAnyValue( - anyValueType, - operand); + auto anyValueType = + builder.getAnyValueType(builder.getIntValue(builder.getUIntType(), anyValueSize)); + auto packInst = builder.emitPackAnyValue(anyValueType, operand); auto unpackInst = builder.emitUnpackAnyValue(toType, packInst); inst->replaceUsesWith(unpackInst); inst->removeAndDeallocate(); @@ -93,9 +101,9 @@ struct ReinterpretLoweringContext void lowerReinterpret(TargetProgram* target, IRModule* module, DiagnosticSink* sink) { - // Before processing reinterpret insts, ensure that existential types without + // Before processing reinterpret insts, ensure that existential types without // user-defined sizes have inferred sizes where possible. - // + // inferAnyValueSizeWhereNecessary(target, module); ReinterpretLoweringContext context; @@ -105,4 +113,4 @@ void lowerReinterpret(TargetProgram* target, IRModule* module, DiagnosticSink* s context.processModule(); } -} +} // namespace Slang |
