Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code for PR #5768 #21

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading