OperandHelper.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using ARMeilleure.State;
  2. using System;
  3. namespace ARMeilleure.IntermediateRepresentation
  4. {
  5. static class OperandHelper
  6. {
  7. public static Operand Const(OperandType type, long value)
  8. {
  9. return type == OperandType.I32 ? new Operand((int)value) : new Operand(value);
  10. }
  11. public static Operand Const(bool value)
  12. {
  13. return new Operand(value ? 1 : 0);
  14. }
  15. public static Operand Const(int value)
  16. {
  17. return new Operand(value);
  18. }
  19. public static Operand Const(uint value)
  20. {
  21. return new Operand(value);
  22. }
  23. public static Operand Const(long value)
  24. {
  25. return new Operand(value);
  26. }
  27. public static Operand Const(ulong value)
  28. {
  29. return new Operand(value);
  30. }
  31. public static Operand ConstF(float value)
  32. {
  33. return new Operand(value);
  34. }
  35. public static Operand ConstF(double value)
  36. {
  37. return new Operand(value);
  38. }
  39. public static Operand Label()
  40. {
  41. return new Operand(OperandKind.Label);
  42. }
  43. public static Operand Local(OperandType type)
  44. {
  45. return new Operand(OperandKind.LocalVariable, type);
  46. }
  47. public static Operand Register(int index, RegisterType regType, OperandType type)
  48. {
  49. return new Operand(index, regType, type);
  50. }
  51. public static Operand Undef()
  52. {
  53. return new Operand(OperandKind.Undefined);
  54. }
  55. }
  56. }