Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
slangbot committed Dec 11, 2024
1 parent 5591ef5 commit 6eec5c0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
15 changes: 10 additions & 5 deletions source/slang/slang-ir-legalize-global-values.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ void GlobalInstInliningContextGeneric::inlineGlobalValuesAndRemoveIfUnused(IRMod
}

// Since certain globals that appear in the IR are considered illegal for all targets,
// e.g. calls to functions, we delete globals which no longer have uses (or children with uses) after inlining.
for (auto& globalInst: globalInstsToConsiderDeleting)
// e.g. calls to functions, we delete globals which no longer have uses (or children with uses)
// after inlining.
for (auto& globalInst : globalInstsToConsiderDeleting)
{
if (!hasDescendantSatisfyingPredicate(globalInst, [](IRInst* inst){return inst->hasUses();}))
if (!hasDescendantSatisfyingPredicate(
globalInst,
[](IRInst* inst) { return inst->hasUses(); }))
globalInst->removeAndDeallocate();
}

}

bool GlobalInstInliningContextGeneric::isLegalGlobalInst(IRInst* inst)
Expand Down Expand Up @@ -186,7 +188,10 @@ bool GlobalInstInliningContextGeneric::shouldInlineInst(IRInst* inst)
return result;
}

IRInst* GlobalInstInliningContextGeneric::inlineInst(IRBuilder& builder, IRCloneEnv& cloneEnv, IRInst* inst)
IRInst* GlobalInstInliningContextGeneric::inlineInst(
IRBuilder& builder,
IRCloneEnv& cloneEnv,
IRInst* inst)
{
IRInst* result;
if (cloneEnv.mapOldValToNew.tryGetValue(inst, result))
Expand Down
10 changes: 5 additions & 5 deletions source/slang/slang-ir-legalize-global-values.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ struct GlobalInstInliningContextGeneric
Dictionary<IRInst*, bool> m_mapGlobalInstToShouldInline;

// Target-specific control over how inlining happens
virtual bool isLegalGlobalInstForTarget(IRInst* inst) =0;
virtual bool isInlinableGlobalInstForTarget(IRInst* inst) =0;
virtual bool shouldBeInlinedForTarget(IRInst* user) =0;
virtual IRInst* getOutsideASM(IRInst* beforeInst) =0;
virtual bool isLegalGlobalInstForTarget(IRInst* inst) = 0;
virtual bool isInlinableGlobalInstForTarget(IRInst* inst) = 0;
virtual bool shouldBeInlinedForTarget(IRInst* user) = 0;
virtual IRInst* getOutsideASM(IRInst* beforeInst) = 0;

// Inline global values that can't represented by the target to their use sites.
// If this leaves any global unused, then remove it.
void inlineGlobalValuesAndRemoveIfUnused(IRModule * module);
void inlineGlobalValuesAndRemoveIfUnused(IRModule* module);

// Opcodes that can exist in global scope, as long as the operands are.
bool isLegalGlobalInst(IRInst* inst);
Expand Down
12 changes: 6 additions & 6 deletions source/slang/slang-ir-spirv-legalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "slang-ir-glsl-legalize.h"
#include "slang-ir-insts.h"
#include "slang-ir-layout.h"
#include "slang-ir-legalize-mesh-outputs.h"
#include "slang-ir-legalize-global-values.h"
#include "slang-ir-legalize-mesh-outputs.h"
#include "slang-ir-loop-unroll.h"
#include "slang-ir-lower-buffer-element-type.h"
#include "slang-ir-peephole.h"
Expand Down Expand Up @@ -1591,7 +1591,7 @@ struct SPIRVLegalizationContext : public SourceEmitterBase
}
}

struct GlobalInstInliningContext: public GlobalInstInliningContextGeneric
struct GlobalInstInliningContext : public GlobalInstInliningContextGeneric
{
bool isLegalGlobalInstForTarget(IRInst* inst) override
{
Expand All @@ -1602,10 +1602,10 @@ struct SPIRVLegalizationContext : public SourceEmitterBase
{
switch (inst->getOp())
{
case kIROp_SPIRVAsm:
return true;
default:
break;
case kIROp_SPIRVAsm:
return true;
default:
break;
}

if (as<IRSPIRVAsmInst>(inst))
Expand Down
4 changes: 2 additions & 2 deletions source/slang/slang-ir-wgsl-legalize.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "slang-ir-wgsl-legalize.h"

#include "slang-ir-insts.h"
#include "slang-ir-legalize-varying-params.h"
#include "slang-ir-legalize-global-values.h"
#include "slang-ir-legalize-varying-params.h"
#include "slang-ir-util.h"
#include "slang-ir.h"
#include "slang-parameter-binding.h"
Expand Down Expand Up @@ -1588,7 +1588,7 @@ struct LegalizeWGSLEntryPointContext
}
};

struct GlobalInstInliningContext: public GlobalInstInliningContextGeneric
struct GlobalInstInliningContext : public GlobalInstInliningContextGeneric
{
bool isLegalGlobalInstForTarget(IRInst* /* inst */) override
{
Expand Down

0 comments on commit 6eec5c0

Please sign in to comment.