MemoryOperand.cs 1.2 KB

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