diff options
Diffstat (limited to 'ARMeilleure/IntermediateRepresentation/OperandHelper.cs')
-rw-r--r-- | ARMeilleure/IntermediateRepresentation/OperandHelper.cs | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/ARMeilleure/IntermediateRepresentation/OperandHelper.cs b/ARMeilleure/IntermediateRepresentation/OperandHelper.cs index 4a930e03..cfdb32d9 100644 --- a/ARMeilleure/IntermediateRepresentation/OperandHelper.cs +++ b/ARMeilleure/IntermediateRepresentation/OperandHelper.cs @@ -1,68 +1,99 @@ -using ARMeilleure.State; -using System; +using ARMeilleure.Common; namespace ARMeilleure.IntermediateRepresentation { static class OperandHelper { + private static MemoryOperand MemoryOperand() + { + return ThreadStaticPool<MemoryOperand>.Instance.Allocate(); + } + + private static Operand Operand() + { + return ThreadStaticPool<Operand>.Instance.Allocate(); + } + public static Operand Const(OperandType type, long value) { - return type == OperandType.I32 ? new Operand((int)value) : new Operand(value); + return type == OperandType.I32 ? Operand().With((int)value) : Operand().With(value); } public static Operand Const(bool value) { - return new Operand(value ? 1 : 0); + return Operand().With(value ? 1 : 0); } public static Operand Const(int value) { - return new Operand(value); + return Operand().With(value); } public static Operand Const(uint value) { - return new Operand(value); + return Operand().With(value); } public static Operand Const(long value) { - return new Operand(value); + return Operand().With(value); } public static Operand Const(ulong value) { - return new Operand(value); + return Operand().With(value); } public static Operand ConstF(float value) { - return new Operand(value); + return Operand().With(value); } public static Operand ConstF(double value) { - return new Operand(value); + return Operand().With(value); } public static Operand Label() { - return new Operand(OperandKind.Label); + return Operand().With(OperandKind.Label); } public static Operand Local(OperandType type) { - return new Operand(OperandKind.LocalVariable, type); + return Operand().With(OperandKind.LocalVariable, type); } public static Operand Register(int index, RegisterType regType, OperandType type) { - return new Operand(index, regType, type); + return Operand().With(index, regType, type); } public static Operand Undef() { - return new Operand(OperandKind.Undefined); + 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); + } + + public static void PrepareOperandPool(bool highCq) + { + ThreadStaticPool<Operand>.PreparePool(highCq ? 1 : 0); + ThreadStaticPool<MemoryOperand>.PreparePool(highCq ? 1 : 0); + } + + public static void ResetOperandPool(bool highCq) + { + ThreadStaticPool<Operand>.ReturnPool(highCq ? 1 : 0); + ThreadStaticPool<MemoryOperand>.ReturnPool(highCq ? 1 : 0); } } }
\ No newline at end of file |