misc: chore: Use collection expressions (part 2)

This commit is contained in:
KeatonTheBot
2025-03-10 21:32:01 -05:00
parent c923c0043a
commit 340ec79e9f
176 changed files with 308 additions and 308 deletions
@@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
private class BlockState
{
private int _entryCount;
private readonly List<Instruction> _labels = new();
private readonly List<Instruction> _labels = [];
public Instruction GetNextLabel(CodeGenContext context)
{
@@ -81,7 +81,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
private static void DeclareBuffers(CodeGenContext context, IEnumerable<BufferDefinition> buffers, bool isBuffer)
{
HashSet<SpvInstruction> decoratedTypes = new();
HashSet<SpvInstruction> decoratedTypes = [];
foreach (BufferDefinition buffer in buffers)
{
@@ -45,11 +45,11 @@ namespace Ryujinx.Graphics.Shader.Decoders
{
Address = address;
Predecessors = new List<Block>();
Successors = new List<Block>();
Predecessors = [];
Successors = [];
OpCodes = new List<InstOp>();
PushOpCodes = new List<PushOpInfo>();
OpCodes = [];
PushOpCodes = [];
SyncTargets = new Dictionary<ulong, SyncTarget>();
}
@@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
public DecodedFunction(ulong address)
{
Address = address;
_callers = new HashSet<DecodedFunction>();
_callers = [];
Type = FunctionType.User;
Id = -1;
}
@@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
{
MainFunction = mainFunction;
_functions = functions;
_functionsWithId = new();
_functionsWithId = [];
AttributeUsage = attributeUsage;
UsedFeatures = usedFeatures;
ClipDistancesWritten = clipDistancesWritten;
@@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
while (functionsQueue.TryDequeue(out DecodedFunction currentFunction))
{
List<Block> blocks = new();
List<Block> blocks = [];
Queue<Block> workQueue = new();
Dictionary<ulong, Block> visited = new();
@@ -520,7 +520,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
if (lastOp.Name == InstName.Brx && block.Successors.Count == (hasNext ? 1 : 0))
{
HashSet<ulong> visited = new();
HashSet<ulong> visited = [];
InstBrx opBrx = new(lastOp.RawOpCode);
ulong baseOffset = lastOp.GetAbsoluteAddress();
@@ -566,7 +566,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
// On a successful match, "BaseOffset" is the offset in bytes where the jump offsets are
// located on the constant buffer, and "UpperBound" is the total number of offsets for the BRX, minus 1.
HashSet<Block> visited = new();
HashSet<Block> visited = [];
var ldcLocation = FindFirstRegWrite(visited, new BlockLocation(block, block.OpCodes.Count - 1), brxReg);
if (ldcLocation.Block == null || ldcLocation.Block.OpCodes[ldcLocation.Index].Name != InstName.Ldc)
@@ -752,7 +752,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
Block target = blocks[pushOp.GetAbsoluteAddress()];
Stack<PathBlockState> workQueue = new();
HashSet<Block> visited = new();
HashSet<Block> visited = [];
Stack<(ulong, MergeType)> branchStack = new();
void Push(PathBlockState pbs)
@@ -221,7 +221,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand d = Register(dest, RegisterType.Gpr);
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -328,7 +328,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcA++, RegisterType.Gpr));
}
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -500,7 +500,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcB++, RegisterType.Gpr));
}
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -605,7 +605,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
return context.Copy(Register(srcB++, RegisterType.Gpr));
}
List<Operand> sourcesList = new();
List<Operand> sourcesList = [];
if (isBindless)
{
@@ -34,11 +34,11 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
public BasicBlock()
{
Operations = new LinkedList<INode>();
Operations = [];
Predecessors = new List<BasicBlock>();
Predecessors = [];
DominanceFrontiers = new HashSet<BasicBlock>();
DominanceFrontiers = [];
}
public BasicBlock(int index) : this()
@@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
private Operand()
{
UseOps = new HashSet<INode>();
UseOps = [];
}
public Operand(OperandType type) : this()
@@ -35,9 +35,9 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
public PhiNode(Operand dest)
{
_blocks = new HashSet<BasicBlock>();
_blocks = [];
_sources = new List<PhiSource>();
_sources = [];
dest.AsgOp = this;
@@ -41,7 +41,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
Type = type;
Condition = condition;
_nodes = new LinkedList<IAstNode>();
_nodes = [];
}
public void Add(IAstNode node)
@@ -17,8 +17,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private AstOperand()
{
Defs = new HashSet<IAstNode>();
Uses = new HashSet<IAstNode>();
Defs = [];
Uses = [];
VarType = AggregateType.S32;
}
@@ -429,7 +429,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
AstBlock block = bottom;
List<AstBlock> path = new();
List<AstBlock> path = [];
while (block != top)
{
@@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
InArguments = inArguments;
OutArguments = outArguments;
Locals = new HashSet<AstOperand>();
Locals = [];
}
public AggregateType GetArgumentType(int index)
@@ -343,7 +343,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
private static AggregateType GetVarTypeFromUses(Operand dest)
{
HashSet<Operand> visited = new();
HashSet<Operand> visited = [];
Queue<Operand> pending = new();
@@ -12,9 +12,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
public StructuredProgramInfo()
{
Functions = new List<StructuredFunction>();
Functions = [];
IoDefinitions = new HashSet<IoDefinition>();
IoDefinitions = [];
}
}
}
@@ -25,8 +25,8 @@ namespace Ryujinx.Graphics.Shader.Translation
{
_gpuAccessor = gpuAccessor;
UsedInputAttributesPerPatch = new();
UsedOutputAttributesPerPatch = new();
UsedInputAttributesPerPatch = [];
UsedOutputAttributesPerPatch = [];
}
public void SetInputUserAttribute(int index, int component)
@@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.Translation
{
Blocks = blocks;
HashSet<BasicBlock> visited = new();
HashSet<BasicBlock> visited = [];
Stack<BasicBlock> blockStack = new();
@@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.Shader.Translation
{
Dictionary<Operand, BasicBlock> labels = new();
List<BasicBlock> blocks = new();
List<BasicBlock> blocks = [];
BasicBlock currentBlock = null;
@@ -128,8 +128,8 @@ namespace Ryujinx.Graphics.Shader.Translation
public static FunctionRegisterUsage RunPass(ControlFlowGraph cfg)
{
List<Register> inArguments = new();
List<Register> outArguments = new();
List<Register> inArguments = [];
List<Register> outArguments = [];
// Compute local register inputs and outputs used inside blocks.
RegisterMask[] localInputs = new RegisterMask[cfg.Blocks.Length];