Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
slangbot committed Dec 5, 2024
1 parent fc18647 commit ba0a84e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
8 changes: 6 additions & 2 deletions source/slang/slang-ir-legalize-global-values.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ 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 after inlining.
// TODO: Explain why tests/spirv/global-compute.slang fails if we don't exclude kIROp_SPIRVAsm
// TODO: Explain why tests/spirv/global-compute.slang fails if we don't exclude
// kIROp_SPIRVAsm
if (!inst->hasUses() && inst->getOp() != kIROp_SPIRVAsm)
inst->removeAndDeallocate();
}
Expand Down Expand Up @@ -159,7 +160,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 ba0a84e

Please sign in to comment.