X86Condition.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using ARMeilleure.IntermediateRepresentation;
  2. using System;
  3. namespace ARMeilleure.CodeGen.X86
  4. {
  5. enum X86Condition
  6. {
  7. Overflow = 0x0,
  8. NotOverflow = 0x1,
  9. Below = 0x2,
  10. AboveOrEqual = 0x3,
  11. Equal = 0x4,
  12. NotEqual = 0x5,
  13. BelowOrEqual = 0x6,
  14. Above = 0x7,
  15. Sign = 0x8,
  16. NotSign = 0x9,
  17. ParityEven = 0xa,
  18. ParityOdd = 0xb,
  19. Less = 0xc,
  20. GreaterOrEqual = 0xd,
  21. LessOrEqual = 0xe,
  22. Greater = 0xf,
  23. }
  24. static class ComparisonX86Extensions
  25. {
  26. public static X86Condition ToX86Condition(this Comparison comp)
  27. {
  28. return comp switch
  29. {
  30. #pragma warning disable IDE0055 // Disable formatting
  31. Comparison.Equal => X86Condition.Equal,
  32. Comparison.NotEqual => X86Condition.NotEqual,
  33. Comparison.Greater => X86Condition.Greater,
  34. Comparison.LessOrEqual => X86Condition.LessOrEqual,
  35. Comparison.GreaterUI => X86Condition.Above,
  36. Comparison.LessOrEqualUI => X86Condition.BelowOrEqual,
  37. Comparison.GreaterOrEqual => X86Condition.GreaterOrEqual,
  38. Comparison.Less => X86Condition.Less,
  39. Comparison.GreaterOrEqualUI => X86Condition.AboveOrEqual,
  40. Comparison.LessUI => X86Condition.Below,
  41. #pragma warning restore IDE0055
  42. _ => throw new ArgumentException(null, nameof(comp)),
  43. };
  44. }
  45. }
  46. }