1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-05 00:22:01 +00:00
Ryujinx/ARMeilleure/IntermediateRepresentation/OperandHelper.cs
FICTURE7 89791ba68d
Add inlined on translation call counting (#2190)
* Add EntryTable<TEntry>

* Add on translation call counting

* Add Counter

* Add PPTC support

* Make Counter a generic & use a 32-bit counter instead

* Return false on overflow

* Set PPTC version

* Print more information about the rejit queue

* Make Counter<T> disposable

* Remove Block.TailCall since it is not used anymore

* Apply suggestions from code review

Address gdkchan's feedback

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Fix more stale docs

* Remove rejit requests queue logging

* Make Counter<T> finalizable

Most certainly quite an odd use case.

* Make EntryTable<T>.TryAllocate set entry to default

* Re-trigger CI

* Dispose Counters before they hit the finalizer queue

* Re-trigger CI

Just for good measure...

* Make EntryTable<T> expandable

* EntryTable is now expandable instead of being a fixed slab.
* Remove EntryTable<T>.TryAllocate
* Remove Counter<T>.TryCreate

Address LDj3SNuD's feedback

* Apply suggestions from code review

Address LDj3SNuD's feedback

Co-authored-by: LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com>

* Remove useless return

* POH approach, but the sequel

* Revert "POH approach, but the sequel"

This reverts commit 5f5abaa247.

The sequel got shelved

* Add extra documentation

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
Co-authored-by: LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com>
2021-04-18 23:43:53 +02:00

113 lines
3.2 KiB
C#

using ARMeilleure.Common;
using System.Runtime.CompilerServices;
namespace ARMeilleure.IntermediateRepresentation
{
static class OperandHelper
{
public static Operand Const(OperandType type, long value)
{
return type == OperandType.I32 ? Operand().With((int)value) : Operand().With(value);
}
public static Operand Const(bool value)
{
return Operand().With(value ? 1 : 0);
}
public static Operand Const(int value)
{
return Operand().With(value);
}
public static Operand Const(uint value)
{
return Operand().With(value);
}
public static Operand Const(long value, bool relocatable = false, int? index = null)
{
return Operand().With(value, relocatable, index);
}
public static Operand Const(ulong value)
{
return Operand().With(value);
}
public static unsafe Operand Const<T>(ref T reference, int? index = null)
{
return Operand().With((long)Unsafe.AsPointer(ref reference), index != null, index);
}
public static Operand ConstF(float value)
{
return Operand().With(value);
}
public static Operand ConstF(double value)
{
return Operand().With(value);
}
public static Operand Label()
{
return Operand().With(OperandKind.Label);
}
public static Operand Local(OperandType type)
{
return Operand().With(OperandKind.LocalVariable, type);
}
public static Operand Register(int index, RegisterType regType, OperandType type)
{
return Operand().With(index, regType, type);
}
public static Operand Undef()
{
return Operand().With(OperandKind.Undefined);
}
public static MemoryOperand MemoryOp(
OperandType type,
Operand baseAddress,
Operand index = null,
Multiplier scale = Multiplier.x1,
int displacement = 0)
{
return MemoryOperand().With(type, baseAddress, index, scale, displacement);
}
#region "ThreadStaticPool"
public static void PrepareOperandPool(int groupId = 0)
{
ThreadStaticPool<Operand>.PreparePool(groupId, ChunkSizeLimit.Large);
ThreadStaticPool<MemoryOperand>.PreparePool(groupId, ChunkSizeLimit.Small);
}
private static Operand Operand()
{
return ThreadStaticPool<Operand>.Instance.Allocate();
}
private static MemoryOperand MemoryOperand()
{
return ThreadStaticPool<MemoryOperand>.Instance.Allocate();
}
public static void ResetOperandPool(int groupId = 0)
{
ThreadStaticPool<MemoryOperand>.ResetPool(groupId);
ThreadStaticPool<Operand>.ResetPool(groupId);
}
public static void DisposeOperandPools()
{
ThreadStaticPool<Operand>.DisposePools();
ThreadStaticPool<MemoryOperand>.DisposePools();
}
#endregion
}
}