MemoryOperand.cs
1 using System; 2 using System.Diagnostics; 3 using System.Runtime.CompilerServices; 4 5 namespace ARMeilleure.IntermediateRepresentation 6 { 7 readonly unsafe struct MemoryOperand 8 { 9 private struct Data 10 { 11 #pragma warning disable CS0649 // Field is never assigned to 12 public byte Kind; 13 public byte Type; 14 #pragma warning restore CS0649 15 public byte Scale; 16 public Operand BaseAddress; 17 public Operand Index; 18 public int Displacement; 19 } 20 21 private readonly Data* _data; 22 23 public MemoryOperand(Operand operand) 24 { 25 Debug.Assert(operand.Kind == OperandKind.Memory); 26 27 _data = (Data*)Unsafe.As<Operand, IntPtr>(ref operand); 28 } 29 30 public Operand BaseAddress 31 { 32 get => _data->BaseAddress; 33 set => _data->BaseAddress = value; 34 } 35 36 public Operand Index 37 { 38 get => _data->Index; 39 set => _data->Index = value; 40 } 41 42 public Multiplier Scale 43 { 44 get => (Multiplier)_data->Scale; 45 set => _data->Scale = (byte)value; 46 } 47 48 public int Displacement 49 { 50 get => _data->Displacement; 51 set => _data->Displacement = value; 52 } 53 } 54 }