diff --git a/src/ARMeilleure/CodeGen/Arm64/Arm64Optimizer.cs b/src/ARMeilleure/CodeGen/Arm64/Arm64Optimizer.cs index 00ffd1958..979b471ac 100644 --- a/src/ARMeilleure/CodeGen/Arm64/Arm64Optimizer.cs +++ b/src/ARMeilleure/CodeGen/Arm64/Arm64Optimizer.cs @@ -13,13 +13,13 @@ namespace ARMeilleure.CodeGen.Arm64 public static void RunPass(ControlFlowGraph cfg) { - var constants = new Dictionary(); + Dictionary constants = new Dictionary(); Operand GetConstantCopy(BasicBlock block, Operation operation, Operand source) { // If the constant has many uses, we also force a new constant mov to be added, in order // to avoid overflow of the counts field (that is limited to 16 bits). - if (!constants.TryGetValue(source.Value, out var constant) || constant.UsesCount > MaxConstantUses) + if (!constants.TryGetValue(source.Value, out Operand constant) || constant.UsesCount > MaxConstantUses) { constant = Local(source.Type); diff --git a/src/ARMeilleure/CodeGen/Arm64/Assembler.cs b/src/ARMeilleure/CodeGen/Arm64/Assembler.cs index 41684faf2..47902ddc8 100644 --- a/src/ARMeilleure/CodeGen/Arm64/Assembler.cs +++ b/src/ARMeilleure/CodeGen/Arm64/Assembler.cs @@ -123,7 +123,7 @@ namespace ARMeilleure.CodeGen.Arm64 public void Cset(Operand rd, ArmCondition condition) { - var zr = Factory.Register(ZrRegister, RegisterType.Integer, rd.Type); + Operand zr = Factory.Register(ZrRegister, RegisterType.Integer, rd.Type); Csinc(rd, zr, zr, (ArmCondition)((int)condition ^ 1)); } diff --git a/src/ARMeilleure/CodeGen/Arm64/CodeGenContext.cs b/src/ARMeilleure/CodeGen/Arm64/CodeGenContext.cs index 89b1e9e6b..ed271d24e 100644 --- a/src/ARMeilleure/CodeGen/Arm64/CodeGenContext.cs +++ b/src/ARMeilleure/CodeGen/Arm64/CodeGenContext.cs @@ -91,7 +91,7 @@ namespace ARMeilleure.CodeGen.Arm64 long target = _stream.Position; - if (_pendingBranches.TryGetValue(block, out var list)) + if (_pendingBranches.TryGetValue(block, out List<(ArmCondition Condition, long BranchPos)> list)) { foreach ((ArmCondition condition, long branchPos) in list) { @@ -119,7 +119,7 @@ namespace ARMeilleure.CodeGen.Arm64 } else { - if (!_pendingBranches.TryGetValue(target, out var list)) + if (!_pendingBranches.TryGetValue(target, out List<(ArmCondition Condition, long BranchPos)> list)) { list = new List<(ArmCondition, long)>(); _pendingBranches.Add(target, list); diff --git a/src/ARMeilleure/CodeGen/Arm64/CodeGenerator.cs b/src/ARMeilleure/CodeGen/Arm64/CodeGenerator.cs index 2df86671a..6c422a5bb 100644 --- a/src/ARMeilleure/CodeGen/Arm64/CodeGenerator.cs +++ b/src/ARMeilleure/CodeGen/Arm64/CodeGenerator.cs @@ -322,7 +322,7 @@ namespace ARMeilleure.CodeGen.Arm64 Debug.Assert(comp.Kind == OperandKind.Constant); - var cond = ((Comparison)comp.AsInt32()).ToArmCondition(); + ArmCondition cond = ((Comparison)comp.AsInt32()).ToArmCondition(); GenerateCompareCommon(context, operation); @@ -354,7 +354,7 @@ namespace ARMeilleure.CodeGen.Arm64 Debug.Assert(dest.Type == OperandType.I32); Debug.Assert(comp.Kind == OperandKind.Constant); - var cond = ((Comparison)comp.AsInt32()).ToArmCondition(); + ArmCondition cond = ((Comparison)comp.AsInt32()).ToArmCondition(); GenerateCompareCommon(context, operation); diff --git a/src/ARMeilleure/CodeGen/Arm64/PreAllocator.cs b/src/ARMeilleure/CodeGen/Arm64/PreAllocator.cs index f66bb66e6..e8193a9ab 100644 --- a/src/ARMeilleure/CodeGen/Arm64/PreAllocator.cs +++ b/src/ARMeilleure/CodeGen/Arm64/PreAllocator.cs @@ -847,7 +847,7 @@ namespace ARMeilleure.CodeGen.Arm64 Debug.Assert(comp.Kind == OperandKind.Constant); - var compType = (Comparison)comp.AsInt32(); + Comparison compType = (Comparison)comp.AsInt32(); return compType == Comparison.Equal || compType == Comparison.NotEqual; } diff --git a/src/ARMeilleure/CodeGen/RegisterAllocators/LinearScanAllocator.cs b/src/ARMeilleure/CodeGen/RegisterAllocators/LinearScanAllocator.cs index 16feeb914..fa0b8aa24 100644 --- a/src/ARMeilleure/CodeGen/RegisterAllocators/LinearScanAllocator.cs +++ b/src/ARMeilleure/CodeGen/RegisterAllocators/LinearScanAllocator.cs @@ -115,7 +115,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators { NumberLocals(cfg, regMasks.RegistersCount); - var context = new AllocationContext(stackAlloc, regMasks, _intervals.Count); + AllocationContext context = new AllocationContext(stackAlloc, regMasks, _intervals.Count); BuildIntervals(cfg, context); diff --git a/src/ARMeilleure/CodeGen/RegisterAllocators/LiveIntervalList.cs b/src/ARMeilleure/CodeGen/RegisterAllocators/LiveIntervalList.cs index 84b892f42..b31d8fa78 100644 --- a/src/ARMeilleure/CodeGen/RegisterAllocators/LiveIntervalList.cs +++ b/src/ARMeilleure/CodeGen/RegisterAllocators/LiveIntervalList.cs @@ -15,12 +15,12 @@ namespace ARMeilleure.CodeGen.RegisterAllocators { if (_count + 1 > _capacity) { - var oldSpan = Span; + Span oldSpan = Span; _capacity = Math.Max(4, _capacity * 2); _items = Allocators.References.Allocate((uint)_capacity); - var newSpan = Span; + Span newSpan = Span; oldSpan.CopyTo(newSpan); } diff --git a/src/ARMeilleure/CodeGen/RegisterAllocators/UseList.cs b/src/ARMeilleure/CodeGen/RegisterAllocators/UseList.cs index 806002f83..c78201785 100644 --- a/src/ARMeilleure/CodeGen/RegisterAllocators/UseList.cs +++ b/src/ARMeilleure/CodeGen/RegisterAllocators/UseList.cs @@ -16,12 +16,12 @@ namespace ARMeilleure.CodeGen.RegisterAllocators { if (Count + 1 > _capacity) { - var oldSpan = Span; + Span oldSpan = Span; _capacity = Math.Max(4, _capacity * 2); _items = Allocators.Default.Allocate((uint)_capacity); - var newSpan = Span; + Span newSpan = Span; oldSpan.CopyTo(newSpan); } diff --git a/src/ARMeilleure/CodeGen/X86/Assembler.cs b/src/ARMeilleure/CodeGen/X86/Assembler.cs index 96f4de049..74774a8cf 100644 --- a/src/ARMeilleure/CodeGen/X86/Assembler.cs +++ b/src/ARMeilleure/CodeGen/X86/Assembler.cs @@ -1,5 +1,6 @@ using ARMeilleure.CodeGen.Linking; using ARMeilleure.IntermediateRepresentation; +using Microsoft.IO; using Ryujinx.Common.Memory; using System; using System.Collections.Generic; @@ -1324,8 +1325,8 @@ namespace ARMeilleure.CodeGen.X86 public (byte[], RelocInfo) GetCode() { - var jumps = CollectionsMarshal.AsSpan(_jumps); - var relocs = CollectionsMarshal.AsSpan(_relocs); + Span jumps = CollectionsMarshal.AsSpan(_jumps); + Span relocs = CollectionsMarshal.AsSpan(_relocs); // Write jump relative offsets. bool modified; @@ -1410,13 +1411,13 @@ namespace ARMeilleure.CodeGen.X86 // Write the code, ignoring the dummy bytes after jumps, into a new stream. _stream.Seek(0, SeekOrigin.Begin); - using var codeStream = MemoryStreamManager.Shared.GetStream(); - var assembler = new Assembler(codeStream, HasRelocs); + using RecyclableMemoryStream codeStream = MemoryStreamManager.Shared.GetStream(); + Assembler assembler = new Assembler(codeStream, HasRelocs); bool hasRelocs = HasRelocs; int relocIndex = 0; int relocOffset = 0; - var relocEntries = hasRelocs + RelocEntry[] relocEntries = hasRelocs ? new RelocEntry[relocs.Length] : Array.Empty(); @@ -1469,8 +1470,8 @@ namespace ARMeilleure.CodeGen.X86 _stream.CopyTo(codeStream); - var code = codeStream.ToArray(); - var relocInfo = new RelocInfo(relocEntries); + byte[] code = codeStream.ToArray(); + RelocInfo relocInfo = new RelocInfo(relocEntries); return (code, relocInfo); } diff --git a/src/ARMeilleure/CodeGen/X86/CodeGenerator.cs b/src/ARMeilleure/CodeGen/X86/CodeGenerator.cs index 9e94a077f..ab8612133 100644 --- a/src/ARMeilleure/CodeGen/X86/CodeGenerator.cs +++ b/src/ARMeilleure/CodeGen/X86/CodeGenerator.cs @@ -623,7 +623,7 @@ namespace ARMeilleure.CodeGen.X86 Debug.Assert(comp.Kind == OperandKind.Constant); - var cond = ((Comparison)comp.AsInt32()).ToX86Condition(); + X86Condition cond = ((Comparison)comp.AsInt32()).ToX86Condition(); GenerateCompareCommon(context, operation); @@ -661,7 +661,7 @@ namespace ARMeilleure.CodeGen.X86 Debug.Assert(dest.Type == OperandType.I32); Debug.Assert(comp.Kind == OperandKind.Constant); - var cond = ((Comparison)comp.AsInt32()).ToX86Condition(); + X86Condition cond = ((Comparison)comp.AsInt32()).ToX86Condition(); GenerateCompareCommon(context, operation); diff --git a/src/ARMeilleure/CodeGen/X86/HardwareCapabilities.cs b/src/ARMeilleure/CodeGen/X86/HardwareCapabilities.cs index 4f6f1e87b..03a747071 100644 --- a/src/ARMeilleure/CodeGen/X86/HardwareCapabilities.cs +++ b/src/ARMeilleure/CodeGen/X86/HardwareCapabilities.cs @@ -53,7 +53,7 @@ namespace ARMeilleure.CodeGen.X86 memGetXcr0.Reprotect(0, (ulong)asmGetXcr0.Length, MemoryPermission.ReadAndExecute); - var fGetXcr0 = Marshal.GetDelegateForFunctionPointer(memGetXcr0.Pointer); + GetXcr0 fGetXcr0 = Marshal.GetDelegateForFunctionPointer(memGetXcr0.Pointer); return fGetXcr0(); } diff --git a/src/ARMeilleure/CodeGen/X86/PreAllocator.cs b/src/ARMeilleure/CodeGen/X86/PreAllocator.cs index 590c35c7b..ded3f866c 100644 --- a/src/ARMeilleure/CodeGen/X86/PreAllocator.cs +++ b/src/ARMeilleure/CodeGen/X86/PreAllocator.cs @@ -759,7 +759,7 @@ namespace ARMeilleure.CodeGen.X86 Debug.Assert(comp.Kind == OperandKind.Constant); - var compType = (Comparison)comp.AsInt32(); + Comparison compType = (Comparison)comp.AsInt32(); return compType == Comparison.Equal || compType == Comparison.NotEqual; } diff --git a/src/ARMeilleure/CodeGen/X86/X86Optimizer.cs b/src/ARMeilleure/CodeGen/X86/X86Optimizer.cs index 690ca5043..8fcc41bc4 100644 --- a/src/ARMeilleure/CodeGen/X86/X86Optimizer.cs +++ b/src/ARMeilleure/CodeGen/X86/X86Optimizer.cs @@ -13,13 +13,13 @@ namespace ARMeilleure.CodeGen.X86 public static void RunPass(ControlFlowGraph cfg) { - var constants = new Dictionary(); + Dictionary constants = new Dictionary(); Operand GetConstantCopy(BasicBlock block, Operation operation, Operand source) { // If the constant has many uses, we also force a new constant mov to be added, in order // to avoid overflow of the counts field (that is limited to 16 bits). - if (!constants.TryGetValue(source.Value, out var constant) || constant.UsesCount > MaxConstantUses) + if (!constants.TryGetValue(source.Value, out Operand constant) || constant.UsesCount > MaxConstantUses) { constant = Local(source.Type); diff --git a/src/ARMeilleure/Common/BitMap.cs b/src/ARMeilleure/Common/BitMap.cs index 94d47ea59..a7bc69238 100644 --- a/src/ARMeilleure/Common/BitMap.cs +++ b/src/ARMeilleure/Common/BitMap.cs @@ -129,13 +129,13 @@ namespace ARMeilleure.Common if (count > _count) { - var oldMask = _masks; - var oldSpan = new Span(_masks, _count); + long* oldMask = _masks; + Span oldSpan = new Span(_masks, _count); _masks = _allocator.Allocate((uint)count); _count = count; - var newSpan = new Span(_masks, _count); + Span newSpan = new Span(_masks, _count); oldSpan.CopyTo(newSpan); newSpan[oldSpan.Length..].Clear(); diff --git a/src/ARMeilleure/Common/EntryTable.cs b/src/ARMeilleure/Common/EntryTable.cs index e49a0989e..7b8c1e134 100644 --- a/src/ARMeilleure/Common/EntryTable.cs +++ b/src/ARMeilleure/Common/EntryTable.cs @@ -63,7 +63,7 @@ namespace ARMeilleure.Common } int index = _freeHint++; - var page = GetPage(index); + Span page = GetPage(index); _allocated.Set(index); @@ -111,7 +111,7 @@ namespace ARMeilleure.Common throw new ArgumentException("Entry at the specified index was not allocated", nameof(index)); } - var page = GetPage(index); + Span page = GetPage(index); return ref GetValue(page, index); } @@ -136,7 +136,7 @@ namespace ARMeilleure.Common /// Page for the specified private unsafe Span GetPage(int index) { - var pageIndex = (int)((uint)(index & ~(_pageCapacity - 1)) >> _pageLogCapacity); + int pageIndex = (int)((uint)(index & ~(_pageCapacity - 1)) >> _pageLogCapacity); if (!_pages.TryGetValue(pageIndex, out nint page)) { @@ -168,7 +168,7 @@ namespace ARMeilleure.Common { _allocated.Dispose(); - foreach (var page in _pages.Values) + foreach (IntPtr page in _pages.Values) { NativeAllocator.Instance.Free((void*)page); } diff --git a/src/ARMeilleure/Decoders/OpCode32SimdDupElem.cs b/src/ARMeilleure/Decoders/OpCode32SimdDupElem.cs index b6cdff088..fbb14056d 100644 --- a/src/ARMeilleure/Decoders/OpCode32SimdDupElem.cs +++ b/src/ARMeilleure/Decoders/OpCode32SimdDupElem.cs @@ -9,7 +9,7 @@ namespace ARMeilleure.Decoders public OpCode32SimdDupElem(InstDescriptor inst, ulong address, int opCode, bool isThumb) : base(inst, address, opCode, isThumb) { - var opc = (opCode >> 16) & 0xf; + int opc = (opCode >> 16) & 0xf; if ((opc & 0b1) == 1) { diff --git a/src/ARMeilleure/Decoders/OpCode32SimdMovGpElem.cs b/src/ARMeilleure/Decoders/OpCode32SimdMovGpElem.cs index f6fce7d99..3b9431da4 100644 --- a/src/ARMeilleure/Decoders/OpCode32SimdMovGpElem.cs +++ b/src/ARMeilleure/Decoders/OpCode32SimdMovGpElem.cs @@ -21,7 +21,7 @@ namespace ARMeilleure.Decoders Op = (opCode >> 20) & 0x1; U = ((opCode >> 23) & 1) != 0; - var opc = (((opCode >> 23) & 1) << 4) | (((opCode >> 21) & 0x3) << 2) | ((opCode >> 5) & 0x3); + int opc = (((opCode >> 23) & 1) << 4) | (((opCode >> 21) & 0x3) << 2) | ((opCode >> 5) & 0x3); if ((opc & 0b01000) == 0b01000) { diff --git a/src/ARMeilleure/Decoders/OpCodeAluImm.cs b/src/ARMeilleure/Decoders/OpCodeAluImm.cs index 0d2f7202f..41a12e474 100644 --- a/src/ARMeilleure/Decoders/OpCodeAluImm.cs +++ b/src/ARMeilleure/Decoders/OpCodeAluImm.cs @@ -20,7 +20,7 @@ namespace ARMeilleure.Decoders } else if (DataOp == DataOp.Logical) { - var bm = DecoderHelper.DecodeBitMask(opCode, true); + DecoderHelper.BitMask bm = DecoderHelper.DecodeBitMask(opCode, true); if (bm.IsUndefined) { diff --git a/src/ARMeilleure/Decoders/OpCodeBfm.cs b/src/ARMeilleure/Decoders/OpCodeBfm.cs index d51efade2..969c782f8 100644 --- a/src/ARMeilleure/Decoders/OpCodeBfm.cs +++ b/src/ARMeilleure/Decoders/OpCodeBfm.cs @@ -11,7 +11,7 @@ namespace ARMeilleure.Decoders public OpCodeBfm(InstDescriptor inst, ulong address, int opCode) : base(inst, address, opCode) { - var bm = DecoderHelper.DecodeBitMask(opCode, false); + DecoderHelper.BitMask bm = DecoderHelper.DecodeBitMask(opCode, false); if (bm.IsUndefined) { diff --git a/src/ARMeilleure/Decoders/Optimizations/TailCallRemover.cs b/src/ARMeilleure/Decoders/Optimizations/TailCallRemover.cs index 9d988f0c9..361a7f0d0 100644 --- a/src/ARMeilleure/Decoders/Optimizations/TailCallRemover.cs +++ b/src/ARMeilleure/Decoders/Optimizations/TailCallRemover.cs @@ -69,7 +69,7 @@ namespace ARMeilleure.Decoders.Optimizations } } - var newBlocks = new List(blocks.Count); + List newBlocks = new List(blocks.Count); // Finally, rebuild decoded block list, ignoring blocks outside the contiguous range. for (int i = 0; i < blocks.Count; i++) diff --git a/src/ARMeilleure/Diagnostics/IRDumper.cs b/src/ARMeilleure/Diagnostics/IRDumper.cs index 16833d085..9d6a708b6 100644 --- a/src/ARMeilleure/Diagnostics/IRDumper.cs +++ b/src/ARMeilleure/Diagnostics/IRDumper.cs @@ -141,7 +141,7 @@ namespace ARMeilleure.Diagnostics break; case OperandKind.Memory: - var memOp = operand.GetMemory(); + MemoryOperand memOp = operand.GetMemory(); _builder.Append('['); @@ -285,7 +285,7 @@ namespace ARMeilleure.Diagnostics public static string GetDump(ControlFlowGraph cfg) { - var dumper = new IRDumper(1); + IRDumper dumper = new IRDumper(1); for (BasicBlock block = cfg.Blocks.First; block != null; block = block.ListNext) { diff --git a/src/ARMeilleure/Instructions/InstEmitAlu32.cs b/src/ARMeilleure/Instructions/InstEmitAlu32.cs index 8eabe093e..2e659fd5f 100644 --- a/src/ARMeilleure/Instructions/InstEmitAlu32.cs +++ b/src/ARMeilleure/Instructions/InstEmitAlu32.cs @@ -415,7 +415,7 @@ namespace ARMeilleure.Instructions { IOpCode32AluBf op = (IOpCode32AluBf)context.CurrOp; - var msb = op.Lsb + op.Msb; // For this instruction, the msb is actually a width. + int msb = op.Lsb + op.Msb; // For this instruction, the msb is actually a width. Operand n = GetIntA32(context, op.Rn); Operand res = context.ShiftRightSI(context.ShiftLeft(n, Const(31 - msb)), Const(31 - op.Msb)); @@ -547,7 +547,7 @@ namespace ARMeilleure.Instructions { IOpCode32AluBf op = (IOpCode32AluBf)context.CurrOp; - var msb = op.Lsb + op.Msb; // For this instruction, the msb is actually a width. + int msb = op.Lsb + op.Msb; // For this instruction, the msb is actually a width. Operand n = GetIntA32(context, op.Rn); Operand res = context.ShiftRightUI(context.ShiftLeft(n, Const(31 - msb)), Const(31 - op.Msb)); diff --git a/src/ARMeilleure/Instructions/InstEmitFlowHelper.cs b/src/ARMeilleure/Instructions/InstEmitFlowHelper.cs index a602ea49e..f67668da4 100644 --- a/src/ARMeilleure/Instructions/InstEmitFlowHelper.cs +++ b/src/ARMeilleure/Instructions/InstEmitFlowHelper.cs @@ -1,4 +1,5 @@ using ARMeilleure.CodeGen.Linking; +using ARMeilleure.Common; using ARMeilleure.Decoders; using ARMeilleure.IntermediateRepresentation; using ARMeilleure.State; @@ -193,7 +194,7 @@ namespace ARMeilleure.Instructions Operand hostAddress; - var table = context.FunctionTable; + IAddressTable table = context.FunctionTable; // If address is mapped onto the function table, we can skip the table walk. Otherwise we fallback // onto the dispatch stub. @@ -218,7 +219,7 @@ namespace ARMeilleure.Instructions for (int i = 0; i < table.Levels.Length; i++) { - var level = table.Levels[i]; + AddressTableLevel level = table.Levels[i]; int clearBits = 64 - (level.Index + level.Length); Operand index = context.ShiftLeft( diff --git a/src/ARMeilleure/Instructions/InstEmitMemoryEx32.cs b/src/ARMeilleure/Instructions/InstEmitMemoryEx32.cs index 150218827..ea9e33f26 100644 --- a/src/ARMeilleure/Instructions/InstEmitMemoryEx32.cs +++ b/src/ARMeilleure/Instructions/InstEmitMemoryEx32.cs @@ -143,8 +143,8 @@ namespace ARMeilleure.Instructions Operand address = context.Copy(GetIntA32(context, op.Rn)); - var exclusive = (accType & AccessType.Exclusive) != 0; - var ordered = (accType & AccessType.Ordered) != 0; + bool exclusive = (accType & AccessType.Exclusive) != 0; + bool ordered = (accType & AccessType.Ordered) != 0; if ((accType & AccessType.Load) != 0) { diff --git a/src/ARMeilleure/Instructions/InstEmitSimdCmp32.cs b/src/ARMeilleure/Instructions/InstEmitSimdCmp32.cs index 1d68bce6b..6ec2b58f9 100644 --- a/src/ARMeilleure/Instructions/InstEmitSimdCmp32.cs +++ b/src/ARMeilleure/Instructions/InstEmitSimdCmp32.cs @@ -229,7 +229,7 @@ namespace ARMeilleure.Instructions private static Operand ZerosOrOnes(ArmEmitterContext context, Operand fromBool, OperandType baseType) { - var ones = (baseType == OperandType.I64) ? Const(-1L) : Const(-1); + Operand ones = (baseType == OperandType.I64) ? Const(-1L) : Const(-1); return context.ConditionalSelect(fromBool, ones, Const(baseType, 0L)); } diff --git a/src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs b/src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs index 216726df9..d3fafc856 100644 --- a/src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs +++ b/src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs @@ -118,15 +118,15 @@ namespace ARMeilleure.Instructions { OpCode32SimdCvtFFixed op = (OpCode32SimdCvtFFixed)context.CurrOp; - var toFixed = op.Opc == 1; + bool toFixed = op.Opc == 1; int fracBits = op.Fbits; - var unsigned = op.U; + bool unsigned = op.U; if (toFixed) // F32 to S32 or U32 (fixed) { EmitVectorUnaryOpF32(context, (op1) => { - var scaledValue = context.Multiply(op1, ConstF(MathF.Pow(2f, fracBits))); + Operand scaledValue = context.Multiply(op1, ConstF(MathF.Pow(2f, fracBits))); MethodInfo info = unsigned ? typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF32ToU32)) : typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF32ToS32)); return context.Call(info, scaledValue); @@ -136,7 +136,7 @@ namespace ARMeilleure.Instructions { EmitVectorUnaryOpI32(context, (op1) => { - var floatValue = unsigned ? context.ConvertToFPUI(OperandType.FP32, op1) : context.ConvertToFP(OperandType.FP32, op1); + Operand floatValue = unsigned ? context.ConvertToFPUI(OperandType.FP32, op1) : context.ConvertToFP(OperandType.FP32, op1); return context.Multiply(floatValue, ConstF(1f / MathF.Pow(2f, fracBits))); }, !unsigned); diff --git a/src/ARMeilleure/Instructions/InstEmitSimdMemory32.cs b/src/ARMeilleure/Instructions/InstEmitSimdMemory32.cs index 35c6dd328..3808ef929 100644 --- a/src/ARMeilleure/Instructions/InstEmitSimdMemory32.cs +++ b/src/ARMeilleure/Instructions/InstEmitSimdMemory32.cs @@ -87,7 +87,7 @@ namespace ARMeilleure.Instructions { if (op.Replicate) { - var regs = (count > 1) ? 1 : op.Increment; + int regs = (count > 1) ? 1 : op.Increment; for (int reg = 0; reg < regs; reg++) { int dreg = reg + d; diff --git a/src/ARMeilleure/Instructions/SoftFloat.cs b/src/ARMeilleure/Instructions/SoftFloat.cs index 7895ca1dc..a2bb23be8 100644 --- a/src/ARMeilleure/Instructions/SoftFloat.cs +++ b/src/ARMeilleure/Instructions/SoftFloat.cs @@ -1538,7 +1538,7 @@ namespace ARMeilleure.Instructions } else if (MathF.Abs(value) < MathF.Pow(2f, -128)) { - var overflowToInf = fpcr.GetRoundingMode() switch + bool overflowToInf = fpcr.GetRoundingMode() switch { FPRoundingMode.ToNearest => true, FPRoundingMode.TowardsPlusInfinity => !sign, @@ -3073,7 +3073,7 @@ namespace ARMeilleure.Instructions } else if (Math.Abs(value) < Math.Pow(2d, -1024)) { - var overflowToInf = fpcr.GetRoundingMode() switch + bool overflowToInf = fpcr.GetRoundingMode() switch { FPRoundingMode.ToNearest => true, FPRoundingMode.TowardsPlusInfinity => !sign, diff --git a/src/ARMeilleure/IntermediateRepresentation/Operand.cs b/src/ARMeilleure/IntermediateRepresentation/Operand.cs index 89aefacb1..495a9d04a 100644 --- a/src/ARMeilleure/IntermediateRepresentation/Operand.cs +++ b/src/ARMeilleure/IntermediateRepresentation/Operand.cs @@ -304,7 +304,7 @@ namespace ARMeilleure.IntermediateRepresentation ushort newCount = checked((ushort)(count + 1)); ushort newCapacity = (ushort)Math.Min(capacity * 2, ushort.MaxValue); - var oldSpan = new Span(data, count); + Span oldSpan = new Span(data, count); capacity = newCapacity; data = Allocators.References.Allocate(capacity); @@ -338,7 +338,7 @@ namespace ARMeilleure.IntermediateRepresentation throw new OverflowException(); } - var oldSpan = new Span(data, (int)count); + Span oldSpan = new Span(data, (int)count); capacity = newCapacity; data = Allocators.References.Allocate(capacity); @@ -352,7 +352,7 @@ namespace ARMeilleure.IntermediateRepresentation private static void Remove(in T item, ref T* data, ref ushort count) where T : unmanaged { - var span = new Span(data, count); + Span span = new Span(data, count); for (int i = 0; i < span.Length; i++) { @@ -372,7 +372,7 @@ namespace ARMeilleure.IntermediateRepresentation private static void Remove(in T item, ref T* data, ref uint count) where T : unmanaged { - var span = new Span(data, (int)count); + Span span = new Span(data, (int)count); for (int i = 0; i < span.Length; i++) { diff --git a/src/ARMeilleure/Signal/TestMethods.cs b/src/ARMeilleure/Signal/TestMethods.cs index 9d11ab183..714bcc01b 100644 --- a/src/ARMeilleure/Signal/TestMethods.cs +++ b/src/ARMeilleure/Signal/TestMethods.cs @@ -22,7 +22,7 @@ namespace ARMeilleure.Signal { EmitterContext context = new(); - var result = WindowsPartialUnmapHandler.EmitRetryFromAccessViolation(context); + Operand result = WindowsPartialUnmapHandler.EmitRetryFromAccessViolation(context); context.Return(result); @@ -39,7 +39,7 @@ namespace ARMeilleure.Signal { EmitterContext context = new(); - var result = WindowsPartialUnmapHandler.EmitThreadLocalMapIntGetOrReserve(context, structPtr, context.LoadArgument(OperandType.I32, 0), context.LoadArgument(OperandType.I32, 1)); + Operand result = WindowsPartialUnmapHandler.EmitThreadLocalMapIntGetOrReserve(context, structPtr, context.LoadArgument(OperandType.I32, 0), context.LoadArgument(OperandType.I32, 1)); context.Return(result); diff --git a/src/ARMeilleure/Translation/Cache/JitUnwindWindows.cs b/src/ARMeilleure/Translation/Cache/JitUnwindWindows.cs index 642794188..01b2aa8ed 100644 --- a/src/ARMeilleure/Translation/Cache/JitUnwindWindows.cs +++ b/src/ARMeilleure/Translation/Cache/JitUnwindWindows.cs @@ -100,13 +100,13 @@ namespace ARMeilleure.Translation.Cache return null; // Not found. } - var unwindInfo = funcEntry.UnwindInfo; + CodeGen.Unwinding.UnwindInfo unwindInfo = funcEntry.UnwindInfo; int codeIndex = 0; for (int index = unwindInfo.PushEntries.Length - 1; index >= 0; index--) { - var entry = unwindInfo.PushEntries[index]; + UnwindPushEntry entry = unwindInfo.PushEntries[index]; switch (entry.PseudoOp) { diff --git a/src/ARMeilleure/Translation/ControlFlowGraph.cs b/src/ARMeilleure/Translation/ControlFlowGraph.cs index 45b092ec5..03ef6f461 100644 --- a/src/ARMeilleure/Translation/ControlFlowGraph.cs +++ b/src/ARMeilleure/Translation/ControlFlowGraph.cs @@ -47,8 +47,8 @@ namespace ARMeilleure.Translation { RemoveUnreachableBlocks(Blocks); - var visited = new HashSet(); - var blockStack = new Stack(); + HashSet visited = new HashSet(); + Stack blockStack = new Stack(); Array.Resize(ref _postOrderBlocks, Blocks.Count); Array.Resize(ref _postOrderMap, Blocks.Count); @@ -88,8 +88,8 @@ namespace ARMeilleure.Translation private void RemoveUnreachableBlocks(IntrusiveList blocks) { - var visited = new HashSet(); - var workQueue = new Queue(); + HashSet visited = new HashSet(); + Queue workQueue = new Queue(); visited.Add(Entry); workQueue.Enqueue(Entry); diff --git a/src/ARMeilleure/Translation/PTC/Ptc.cs b/src/ARMeilleure/Translation/PTC/Ptc.cs index 894e825cf..10f8f3043 100644 --- a/src/ARMeilleure/Translation/PTC/Ptc.cs +++ b/src/ARMeilleure/Translation/PTC/Ptc.cs @@ -9,6 +9,7 @@ using Ryujinx.Common.Logging; using Ryujinx.Common.Memory; using System; using System.Buffers.Binary; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -562,7 +563,7 @@ namespace ARMeilleure.Translation.PTC bool isEntryChanged = infoEntry.Hash != ComputeHash(translator.Memory, infoEntry.Address, infoEntry.GuestSize); - if (isEntryChanged || (!infoEntry.HighCq && Profiler.ProfiledFuncs.TryGetValue(infoEntry.Address, out var value) && value.HighCq)) + if (isEntryChanged || (!infoEntry.HighCq && Profiler.ProfiledFuncs.TryGetValue(infoEntry.Address, out PtcProfiler.FuncProfile value) && value.HighCq)) { infoEntry.Stubbed = true; infoEntry.CodeLength = 0; @@ -749,8 +750,8 @@ namespace ARMeilleure.Translation.PTC UnwindInfo unwindInfo, bool highCq) { - var cFunc = new CompiledFunction(code, unwindInfo, RelocInfo.Empty); - var gFunc = cFunc.MapWithPointer(out nint gFuncPointer); + CompiledFunction cFunc = new CompiledFunction(code, unwindInfo, RelocInfo.Empty); + GuestFunction gFunc = cFunc.MapWithPointer(out nint gFuncPointer); return new TranslatedFunction(gFunc, gFuncPointer, callCounter, guestSize, highCq); } @@ -787,7 +788,7 @@ namespace ARMeilleure.Translation.PTC public void MakeAndSaveTranslations(Translator translator) { - var profiledFuncsToTranslate = Profiler.GetProfiledFuncsToTranslate(translator.Functions); + ConcurrentQueue<(ulong address, PtcProfiler.FuncProfile funcProfile)> profiledFuncsToTranslate = Profiler.GetProfiledFuncsToTranslate(translator.Functions); _translateCount = 0; _translateTotalCount = profiledFuncsToTranslate.Count; @@ -831,7 +832,7 @@ namespace ARMeilleure.Translation.PTC void TranslateFuncs() { - while (profiledFuncsToTranslate.TryDequeue(out var item)) + while (profiledFuncsToTranslate.TryDequeue(out (ulong address, PtcProfiler.FuncProfile funcProfile) item)) { ulong address = item.address; @@ -866,11 +867,11 @@ namespace ARMeilleure.Translation.PTC Stopwatch sw = Stopwatch.StartNew(); - foreach (var thread in threads) + foreach (Thread thread in threads) { thread.Start(); } - foreach (var thread in threads) + foreach (Thread thread in threads) { thread.Join(); } @@ -944,7 +945,7 @@ namespace ARMeilleure.Translation.PTC WriteCode(code.AsSpan()); // WriteReloc. - using var relocInfoWriter = new BinaryWriter(_relocsStream, EncodingCache.UTF8NoBOM, true); + using BinaryWriter relocInfoWriter = new BinaryWriter(_relocsStream, EncodingCache.UTF8NoBOM, true); foreach (RelocEntry entry in relocInfo.Entries) { @@ -954,7 +955,7 @@ namespace ARMeilleure.Translation.PTC } // WriteUnwindInfo. - using var unwindInfoWriter = new BinaryWriter(_unwindInfosStream, EncodingCache.UTF8NoBOM, true); + using BinaryWriter unwindInfoWriter = new BinaryWriter(_unwindInfosStream, EncodingCache.UTF8NoBOM, true); unwindInfoWriter.Write(unwindInfo.PushEntries.Length); diff --git a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs index bdb9abd05..250ef70bb 100644 --- a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs +++ b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs @@ -111,9 +111,9 @@ namespace ARMeilleure.Translation.PTC public ConcurrentQueue<(ulong address, FuncProfile funcProfile)> GetProfiledFuncsToTranslate(TranslatorCache funcs) { - var profiledFuncsToTranslate = new ConcurrentQueue<(ulong address, FuncProfile funcProfile)>(); + ConcurrentQueue<(ulong address, FuncProfile funcProfile)> profiledFuncsToTranslate = new ConcurrentQueue<(ulong address, FuncProfile funcProfile)>(); - foreach (var profiledFunc in ProfiledFuncs) + foreach (KeyValuePair profiledFunc in ProfiledFuncs) { if (!funcs.ContainsKey(profiledFunc.Key)) { diff --git a/src/ARMeilleure/Translation/SsaConstruction.cs b/src/ARMeilleure/Translation/SsaConstruction.cs index cddcfcd4f..3819340c6 100644 --- a/src/ARMeilleure/Translation/SsaConstruction.cs +++ b/src/ARMeilleure/Translation/SsaConstruction.cs @@ -44,10 +44,10 @@ namespace ARMeilleure.Translation public static void Construct(ControlFlowGraph cfg) { - var globalDefs = new DefMap[cfg.Blocks.Count]; - var localDefs = new Operand[cfg.LocalsCount + RegisterConsts.TotalCount]; + DefMap[] globalDefs = new DefMap[cfg.Blocks.Count]; + Operand[] localDefs = new Operand[cfg.LocalsCount + RegisterConsts.TotalCount]; - var dfPhiBlocks = new Queue(); + Queue dfPhiBlocks = new Queue(); for (BasicBlock block = cfg.Blocks.First; block != null; block = block.ListNext) { diff --git a/src/ARMeilleure/Translation/Translator.cs b/src/ARMeilleure/Translation/Translator.cs index 162368782..8e1a437db 100644 --- a/src/ARMeilleure/Translation/Translator.cs +++ b/src/ARMeilleure/Translation/Translator.cs @@ -222,7 +222,7 @@ namespace ARMeilleure.Translation internal TranslatedFunction Translate(ulong address, ExecutionMode mode, bool highCq, bool singleStep = false) { - var context = new ArmEmitterContext( + ArmEmitterContext context = new ArmEmitterContext( Memory, CountTable, FunctionTable, @@ -259,10 +259,10 @@ namespace ARMeilleure.Translation Logger.EndPass(PassName.RegisterUsage); - var retType = OperandType.I64; - var argTypes = new OperandType[] { OperandType.I64 }; + OperandType retType = OperandType.I64; + OperandType[] argTypes = new OperandType[] { OperandType.I64 }; - var options = highCq ? CompilerOptions.HighCq : CompilerOptions.None; + CompilerOptions options = highCq ? CompilerOptions.HighCq : CompilerOptions.None; if (context.HasPtc && !singleStep) { @@ -521,7 +521,7 @@ namespace ARMeilleure.Translation List functions = Functions.AsList(); - foreach (var func in functions) + foreach (TranslatedFunction func in functions) { JitCache.Unmap(func.FuncPointer); @@ -530,7 +530,7 @@ namespace ARMeilleure.Translation Functions.Clear(); - while (_oldFuncs.TryDequeue(out var kv)) + while (_oldFuncs.TryDequeue(out KeyValuePair kv)) { JitCache.Unmap(kv.Value.FuncPointer); @@ -551,7 +551,7 @@ namespace ARMeilleure.Translation { while (Queue.Count > 0 && Queue.TryDequeue(out RejitRequest request)) { - if (Functions.TryGetValue(request.Address, out var func) && func.CallCounter != null) + if (Functions.TryGetValue(request.Address, out TranslatedFunction func) && func.CallCounter != null) { Volatile.Write(ref func.CallCounter.Value, 0); } diff --git a/src/ARMeilleure/Translation/TranslatorStubs.cs b/src/ARMeilleure/Translation/TranslatorStubs.cs index bd9aed8d4..e48349963 100644 --- a/src/ARMeilleure/Translation/TranslatorStubs.cs +++ b/src/ARMeilleure/Translation/TranslatorStubs.cs @@ -142,7 +142,7 @@ namespace ARMeilleure.Translation /// Generated private nint GenerateDispatchStub() { - var context = new EmitterContext(); + EmitterContext context = new EmitterContext(); Operand lblFallback = Label(); Operand lblEnd = Label(); @@ -161,7 +161,7 @@ namespace ARMeilleure.Translation for (int i = 0; i < _functionTable.Levels.Length; i++) { - ref var level = ref _functionTable.Levels[i]; + ref AddressTableLevel level = ref _functionTable.Levels[i]; // level.Mask is not used directly because it is more often bigger than 32-bits, so it will not // be encoded as an immediate on x86's bitwise and operation. @@ -185,11 +185,11 @@ namespace ARMeilleure.Translation hostAddress = context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.GetFunctionAddress)), guestAddress); context.Tailcall(hostAddress, nativeContext); - var cfg = context.GetControlFlowGraph(); - var retType = OperandType.I64; - var argTypes = new[] { OperandType.I64 }; + ControlFlowGraph cfg = context.GetControlFlowGraph(); + OperandType retType = OperandType.I64; + OperandType[] argTypes = new[] { OperandType.I64 }; - var func = Compiler.Compile(cfg, argTypes, retType, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map(); + GuestFunction func = Compiler.Compile(cfg, argTypes, retType, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map(); return Marshal.GetFunctionPointerForDelegate(func); } @@ -200,7 +200,7 @@ namespace ARMeilleure.Translation /// Generated private nint GenerateSlowDispatchStub() { - var context = new EmitterContext(); + EmitterContext context = new EmitterContext(); // Load the target guest address from the native context. Operand nativeContext = context.LoadArgument(OperandType.I64, 0); @@ -210,11 +210,11 @@ namespace ARMeilleure.Translation Operand hostAddress = context.Call(typeof(NativeInterface).GetMethod(nameof(NativeInterface.GetFunctionAddress)), guestAddress); context.Tailcall(hostAddress, nativeContext); - var cfg = context.GetControlFlowGraph(); - var retType = OperandType.I64; - var argTypes = new[] { OperandType.I64 }; + ControlFlowGraph cfg = context.GetControlFlowGraph(); + OperandType retType = OperandType.I64; + OperandType[] argTypes = new[] { OperandType.I64 }; - var func = Compiler.Compile(cfg, argTypes, retType, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map(); + GuestFunction func = Compiler.Compile(cfg, argTypes, retType, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map(); return Marshal.GetFunctionPointerForDelegate(func); } @@ -251,7 +251,7 @@ namespace ARMeilleure.Translation /// function private DispatcherFunction GenerateDispatchLoop() { - var context = new EmitterContext(); + EmitterContext context = new EmitterContext(); Operand beginLbl = Label(); Operand endLbl = Label(); @@ -279,9 +279,9 @@ namespace ARMeilleure.Translation context.Return(); - var cfg = context.GetControlFlowGraph(); - var retType = OperandType.None; - var argTypes = new[] { OperandType.I64, OperandType.I64 }; + ControlFlowGraph cfg = context.GetControlFlowGraph(); + OperandType retType = OperandType.None; + OperandType[] argTypes = new[] { OperandType.I64, OperandType.I64 }; return Compiler.Compile(cfg, argTypes, retType, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map(); } @@ -292,7 +292,7 @@ namespace ARMeilleure.Translation /// function private WrapperFunction GenerateContextWrapper() { - var context = new EmitterContext(); + EmitterContext context = new EmitterContext(); Operand nativeContext = context.LoadArgument(OperandType.I64, 0); Operand guestMethod = context.LoadArgument(OperandType.I64, 1); @@ -303,9 +303,9 @@ namespace ARMeilleure.Translation context.Return(returnValue); - var cfg = context.GetControlFlowGraph(); - var retType = OperandType.I64; - var argTypes = new[] { OperandType.I64, OperandType.I64 }; + ControlFlowGraph cfg = context.GetControlFlowGraph(); + OperandType retType = OperandType.I64; + OperandType[] argTypes = new[] { OperandType.I64, OperandType.I64 }; return Compiler.Compile(cfg, argTypes, retType, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map(); }