mirror of
https://github.com/GreemDev/Ryujinx
synced 2025-01-29 00:37:11 +01:00
misc: chore: Use explicit types in ARMeilleure project
This commit is contained in:
parent
be3bd0bcb5
commit
e0567c5ce9
37 changed files with 109 additions and 106 deletions
|
@ -13,13 +13,13 @@ namespace ARMeilleure.CodeGen.Arm64
|
|||
|
||||
public static void RunPass(ControlFlowGraph cfg)
|
||||
{
|
||||
var constants = new Dictionary<ulong, Operand>();
|
||||
Dictionary<ulong, Operand> constants = new Dictionary<ulong, Operand>();
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -15,12 +15,12 @@ namespace ARMeilleure.CodeGen.RegisterAllocators
|
|||
{
|
||||
if (_count + 1 > _capacity)
|
||||
{
|
||||
var oldSpan = Span;
|
||||
Span<LiveInterval> oldSpan = Span;
|
||||
|
||||
_capacity = Math.Max(4, _capacity * 2);
|
||||
_items = Allocators.References.Allocate<LiveInterval>((uint)_capacity);
|
||||
|
||||
var newSpan = Span;
|
||||
Span<LiveInterval> newSpan = Span;
|
||||
|
||||
oldSpan.CopyTo(newSpan);
|
||||
}
|
||||
|
|
|
@ -16,12 +16,12 @@ namespace ARMeilleure.CodeGen.RegisterAllocators
|
|||
{
|
||||
if (Count + 1 > _capacity)
|
||||
{
|
||||
var oldSpan = Span;
|
||||
Span<int> oldSpan = Span;
|
||||
|
||||
_capacity = Math.Max(4, _capacity * 2);
|
||||
_items = Allocators.Default.Allocate<int>((uint)_capacity);
|
||||
|
||||
var newSpan = Span;
|
||||
Span<int> newSpan = Span;
|
||||
|
||||
oldSpan.CopyTo(newSpan);
|
||||
}
|
||||
|
|
|
@ -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<Jump> jumps = CollectionsMarshal.AsSpan(_jumps);
|
||||
Span<Reloc> 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<RelocEntry>();
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace ARMeilleure.CodeGen.X86
|
|||
|
||||
memGetXcr0.Reprotect(0, (ulong)asmGetXcr0.Length, MemoryPermission.ReadAndExecute);
|
||||
|
||||
var fGetXcr0 = Marshal.GetDelegateForFunctionPointer<GetXcr0>(memGetXcr0.Pointer);
|
||||
GetXcr0 fGetXcr0 = Marshal.GetDelegateForFunctionPointer<GetXcr0>(memGetXcr0.Pointer);
|
||||
|
||||
return fGetXcr0();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -13,13 +13,13 @@ namespace ARMeilleure.CodeGen.X86
|
|||
|
||||
public static void RunPass(ControlFlowGraph cfg)
|
||||
{
|
||||
var constants = new Dictionary<ulong, Operand>();
|
||||
Dictionary<ulong, Operand> constants = new Dictionary<ulong, Operand>();
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -129,13 +129,13 @@ namespace ARMeilleure.Common
|
|||
|
||||
if (count > _count)
|
||||
{
|
||||
var oldMask = _masks;
|
||||
var oldSpan = new Span<long>(_masks, _count);
|
||||
long* oldMask = _masks;
|
||||
Span<long> oldSpan = new Span<long>(_masks, _count);
|
||||
|
||||
_masks = _allocator.Allocate<long>((uint)count);
|
||||
_count = count;
|
||||
|
||||
var newSpan = new Span<long>(_masks, _count);
|
||||
Span<long> newSpan = new Span<long>(_masks, _count);
|
||||
|
||||
oldSpan.CopyTo(newSpan);
|
||||
newSpan[oldSpan.Length..].Clear();
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace ARMeilleure.Common
|
|||
}
|
||||
|
||||
int index = _freeHint++;
|
||||
var page = GetPage(index);
|
||||
Span<TEntry> 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<TEntry> page = GetPage(index);
|
||||
|
||||
return ref GetValue(page, index);
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ namespace ARMeilleure.Common
|
|||
/// <returns>Page for the specified <see cref="index"/></returns>
|
||||
private unsafe Span<TEntry> 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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace ARMeilleure.Decoders.Optimizations
|
|||
}
|
||||
}
|
||||
|
||||
var newBlocks = new List<Block>(blocks.Count);
|
||||
List<Block> newBlocks = new List<Block>(blocks.Count);
|
||||
|
||||
// Finally, rebuild decoded block list, ignoring blocks outside the contiguous range.
|
||||
for (int i = 0; i < blocks.Count; i++)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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<ulong> 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(
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<T>(data, count);
|
||||
Span<T> oldSpan = new Span<T>(data, count);
|
||||
|
||||
capacity = newCapacity;
|
||||
data = Allocators.References.Allocate<T>(capacity);
|
||||
|
@ -338,7 +338,7 @@ namespace ARMeilleure.IntermediateRepresentation
|
|||
throw new OverflowException();
|
||||
}
|
||||
|
||||
var oldSpan = new Span<T>(data, (int)count);
|
||||
Span<T> oldSpan = new Span<T>(data, (int)count);
|
||||
|
||||
capacity = newCapacity;
|
||||
data = Allocators.References.Allocate<T>(capacity);
|
||||
|
@ -352,7 +352,7 @@ namespace ARMeilleure.IntermediateRepresentation
|
|||
|
||||
private static void Remove<T>(in T item, ref T* data, ref ushort count) where T : unmanaged
|
||||
{
|
||||
var span = new Span<T>(data, count);
|
||||
Span<T> span = new Span<T>(data, count);
|
||||
|
||||
for (int i = 0; i < span.Length; i++)
|
||||
{
|
||||
|
@ -372,7 +372,7 @@ namespace ARMeilleure.IntermediateRepresentation
|
|||
|
||||
private static void Remove<T>(in T item, ref T* data, ref uint count) where T : unmanaged
|
||||
{
|
||||
var span = new Span<T>(data, (int)count);
|
||||
Span<T> span = new Span<T>(data, (int)count);
|
||||
|
||||
for (int i = 0; i < span.Length; i++)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -47,8 +47,8 @@ namespace ARMeilleure.Translation
|
|||
{
|
||||
RemoveUnreachableBlocks(Blocks);
|
||||
|
||||
var visited = new HashSet<BasicBlock>();
|
||||
var blockStack = new Stack<BasicBlock>();
|
||||
HashSet<BasicBlock> visited = new HashSet<BasicBlock>();
|
||||
Stack<BasicBlock> blockStack = new Stack<BasicBlock>();
|
||||
|
||||
Array.Resize(ref _postOrderBlocks, Blocks.Count);
|
||||
Array.Resize(ref _postOrderMap, Blocks.Count);
|
||||
|
@ -88,8 +88,8 @@ namespace ARMeilleure.Translation
|
|||
|
||||
private void RemoveUnreachableBlocks(IntrusiveList<BasicBlock> blocks)
|
||||
{
|
||||
var visited = new HashSet<BasicBlock>();
|
||||
var workQueue = new Queue<BasicBlock>();
|
||||
HashSet<BasicBlock> visited = new HashSet<BasicBlock>();
|
||||
Queue<BasicBlock> workQueue = new Queue<BasicBlock>();
|
||||
|
||||
visited.Add(Entry);
|
||||
workQueue.Enqueue(Entry);
|
||||
|
|
|
@ -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<GuestFunction>(out nint gFuncPointer);
|
||||
CompiledFunction cFunc = new CompiledFunction(code, unwindInfo, RelocInfo.Empty);
|
||||
GuestFunction gFunc = cFunc.MapWithPointer<GuestFunction>(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);
|
||||
|
||||
|
|
|
@ -111,9 +111,9 @@ namespace ARMeilleure.Translation.PTC
|
|||
|
||||
public ConcurrentQueue<(ulong address, FuncProfile funcProfile)> GetProfiledFuncsToTranslate(TranslatorCache<TranslatedFunction> 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<ulong, FuncProfile> profiledFunc in ProfiledFuncs)
|
||||
{
|
||||
if (!funcs.ContainsKey(profiledFunc.Key))
|
||||
{
|
||||
|
|
|
@ -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<BasicBlock>();
|
||||
Queue<BasicBlock> dfPhiBlocks = new Queue<BasicBlock>();
|
||||
|
||||
for (BasicBlock block = cfg.Blocks.First; block != null; block = block.ListNext)
|
||||
{
|
||||
|
|
|
@ -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<TranslatedFunction> 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<ulong, TranslatedFunction> 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);
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace ARMeilleure.Translation
|
|||
/// <returns>Generated <see cref="DispatchStub"/></returns>
|
||||
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>();
|
||||
GuestFunction func = Compiler.Compile(cfg, argTypes, retType, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map<GuestFunction>();
|
||||
|
||||
return Marshal.GetFunctionPointerForDelegate(func);
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ namespace ARMeilleure.Translation
|
|||
/// <returns>Generated <see cref="SlowDispatchStub"/></returns>
|
||||
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>();
|
||||
GuestFunction func = Compiler.Compile(cfg, argTypes, retType, CompilerOptions.HighCq, RuntimeInformation.ProcessArchitecture).Map<GuestFunction>();
|
||||
|
||||
return Marshal.GetFunctionPointerForDelegate(func);
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ namespace ARMeilleure.Translation
|
|||
/// <returns><see cref="DispatchLoop"/> function</returns>
|
||||
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<DispatcherFunction>();
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ namespace ARMeilleure.Translation
|
|||
/// <returns><see cref="ContextWrapper"/> function</returns>
|
||||
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<WrapperFunction>();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue