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-specialize-dispatch.cpp | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'source/slang/slang-ir-specialize-dispatch.cpp')
| -rw-r--r-- | source/slang/slang-ir-specialize-dispatch.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/source/slang/slang-ir-specialize-dispatch.cpp b/source/slang/slang-ir-specialize-dispatch.cpp index 9eba0aa4f..ae7b2dc67 100644 --- a/source/slang/slang-ir-specialize-dispatch.cpp +++ b/source/slang/slang-ir-specialize-dispatch.cpp @@ -2,17 +2,20 @@ #include "slang-ir-generics-lowering-context.h" #include "slang-ir-insts.h" -#include "slang-ir.h" #include "slang-ir-util.h" +#include "slang-ir.h" namespace Slang { -IRFunc* specializeDispatchFunction(SharedGenericsLoweringContext* sharedContext, IRFunc* dispatchFunc) +IRFunc* specializeDispatchFunction( + SharedGenericsLoweringContext* sharedContext, + IRFunc* dispatchFunc) { auto witnessTableType = cast<IRFuncType>(dispatchFunc->getDataType())->getParamType(0); auto conformanceType = cast<IRWitnessTableTypeBase>(witnessTableType)->getConformanceType(); // Collect all witness tables of `witnessTableType` in current module. - List<IRWitnessTable*> witnessTables = sharedContext->getWitnessTablesFromInterfaceType(conformanceType); + List<IRWitnessTable*> witnessTables = + sharedContext->getWitnessTablesFromInterfaceType(conformanceType); SLANG_ASSERT(dispatchFunc->getFirstBlock() == dispatchFunc->getLastBlock()); auto block = dispatchFunc->getFirstBlock(); @@ -28,17 +31,10 @@ IRFunc* specializeDispatchFunction(SharedGenericsLoweringContext* sharedContext, { switch (inst->getOp()) { - case kIROp_Call: - callInst = cast<IRCall>(inst); - break; - case kIROp_LookupWitness: - lookupInst = cast<IRLookupWitnessMethod>(inst); - break; - case kIROp_Return: - returnInst = cast<IRReturn>(inst); - break; - default: - break; + case kIROp_Call: callInst = cast<IRCall>(inst); break; + case kIROp_LookupWitness: lookupInst = cast<IRLookupWitnessMethod>(inst); break; + case kIROp_Return: returnInst = cast<IRReturn>(inst); break; + default: break; } } SLANG_ASSERT(callInst && lookupInst && returnInst); @@ -56,7 +52,8 @@ IRFunc* specializeDispatchFunction(SharedGenericsLoweringContext* sharedContext, paramTypes.add(paramInst->getFullType()); } - // Modify the first paramter from IRWitnessTable to IRWitnessTableID representing the sequential ID. + // Modify the first paramter from IRWitnessTable to IRWitnessTableID representing the sequential + // ID. paramTypes[0] = builder->getWitnessTableIDType((IRType*)conformanceType); auto newDipsatchFuncType = builder->getFuncType(paramTypes, dispatchFunc->getResultType()); @@ -95,7 +92,10 @@ IRFunc* specializeDispatchFunction(SharedGenericsLoweringContext* sharedContext, auto seqIdDecoration = witnessTable->findDecoration<IRSequentialIDDecoration>(); if (!seqIdDecoration) { - sharedContext->sink->diagnose(witnessTable->getConcreteType(), Diagnostics::typeCannotBeUsedInDynamicDispatch, witnessTable->getConcreteType()); + sharedContext->sink->diagnose( + witnessTable->getConcreteType(), + Diagnostics::typeCannotBeUsedInDynamicDispatch, + witnessTable->getConcreteType()); } if (i != witnessTables.getCount() - 1) @@ -226,11 +226,12 @@ void ensureWitnessTableSequentialIDs(SharedGenericsLoweringContext* sharedContex else { auto witnessTableType = as<IRWitnessTableType>(inst->getDataType()); - if (witnessTableType && witnessTableType->getConformanceType()->findDecoration<IRSpecializeDecoration>()) + if (witnessTableType && witnessTableType->getConformanceType() + ->findDecoration<IRSpecializeDecoration>()) { - // The interface is for specialization only, it would be an error if dynamic dispatch is used - // through the interface. - // Skip assigning ID for the witness table. + // The interface is for specialization only, it would be an error if dynamic + // dispatch is used through the interface. Skip assigning ID for the witness + // table. continue; } @@ -264,7 +265,8 @@ void ensureWitnessTableSequentialIDs(SharedGenericsLoweringContext* sharedContex // Get a sequential ID for the witness table using the map from the Linkage. uint32_t seqID = 0; if (!linkage->mapMangledNameToRTTIObjectIndex.tryGetValue( - witnessTableMangledName, seqID)) + witnessTableMangledName, + seqID)) { auto interfaceType = cast<IRWitnessTableType>(inst->getDataType())->getConformanceType(); |
