Ryujinx/ARMeilleure/IntermediateRepresentation/OperationHelper.cs
LDj3SNuD dc0adb533d
PPTC & Pool Enhancements. (#1968)
* PPTC & Pool Enhancements.

* Avoid buffer allocations in CodeGenContext.GetCode(). Avoid stream allocations in PTC.PtcInfo.

Refactoring/nits.

* Use XXHash128, for Ptc.Load & Ptc.Save, x10 faster than Md5.

* Why not a nice Span.

* Added a simple PtcFormatter library for deserialization/serialization, which does not require reflection, in use at PtcJumpTable and PtcProfiler; improves maintainability and simplicity/readability of affected code.

* Nits.

* Revert #1987.

* Revert "Revert #1987."

This reverts commit 998be765cf7f7da5ff0c1c08de704c9012b0f49c.
2021-02-22 03:23:48 +01:00

66 lines
2 KiB
C#

using ARMeilleure.Common;
namespace ARMeilleure.IntermediateRepresentation
{
static class OperationHelper
{
public static Operation Operation(Instruction instruction, Operand destination)
{
return Operation().With(instruction, destination);
}
public static Operation Operation(Instruction instruction, Operand destination,
Operand[] sources)
{
return Operation().With(instruction, destination, sources);
}
public static Operation Operation(Instruction instruction, Operand destination,
Operand source0)
{
return Operation().With(instruction, destination, source0);
}
public static Operation Operation(Instruction instruction, Operand destination,
Operand source0, Operand source1)
{
return Operation().With(instruction, destination, source0, source1);
}
public static Operation Operation(Instruction instruction, Operand destination,
Operand source0, Operand source1, Operand source2)
{
return Operation().With(instruction, destination, source0, source1, source2);
}
public static Operation Operation(
Instruction instruction,
Operand[] destinations,
Operand[] sources)
{
return Operation().With(instruction, destinations, sources);
}
#region "ThreadStaticPool"
public static void PrepareOperationPool(int groupId = 0)
{
ThreadStaticPool<Operation>.PreparePool(groupId, ChunkSizeLimit.Medium);
}
private static Operation Operation()
{
return ThreadStaticPool<Operation>.Instance.Allocate();
}
public static void ResetOperationPool(int groupId = 0)
{
ThreadStaticPool<Operation>.ResetPool(groupId);
}
public static void DisposeOperationPools()
{
ThreadStaticPool<Operation>.DisposePools();
}
#endregion
}
}