Instructions.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //RandomX ALU + FPU test
  2. //https://github.com/tevador/RandomX
  3. //License: GPL v3
  4. #include <cstdint>
  5. namespace RandomX {
  6. constexpr int RoundToNearest = 0;
  7. constexpr int RoundDown = 1;
  8. constexpr int RoundUp = 2;
  9. constexpr int RoundToZero = 3;
  10. typedef union {
  11. double f64;
  12. int64_t i64;
  13. uint64_t u64;
  14. int32_t i32;
  15. uint32_t u32;
  16. } convertible_t;
  17. extern "C" {
  18. void ADD_64(convertible_t& a, convertible_t& b, convertible_t& c);
  19. void ADD_32(convertible_t& a, convertible_t& b, convertible_t& c);
  20. void SUB_64(convertible_t& a, convertible_t& b, convertible_t& c);
  21. void SUB_32(convertible_t& a, convertible_t& b, convertible_t& c);
  22. void MUL_64(convertible_t& a, convertible_t& b, convertible_t& c);
  23. void MULH_64(convertible_t& a, convertible_t& b, convertible_t& c);
  24. void MUL_32(convertible_t& a, convertible_t& b, convertible_t& c);
  25. void IMUL_32(convertible_t& a, convertible_t& b, convertible_t& c);
  26. void IMULH_64(convertible_t& a, convertible_t& b, convertible_t& c);
  27. void DIV_64(convertible_t& a, convertible_t& b, convertible_t& c);
  28. void IDIV_64(convertible_t& a, convertible_t& b, convertible_t& c);
  29. void AND_64(convertible_t& a, convertible_t& b, convertible_t& c);
  30. void AND_32(convertible_t& a, convertible_t& b, convertible_t& c);
  31. void OR_64(convertible_t& a, convertible_t& b, convertible_t& c);
  32. void OR_32(convertible_t& a, convertible_t& b, convertible_t& c);
  33. void XOR_64(convertible_t& a, convertible_t& b, convertible_t& c);
  34. void XOR_32(convertible_t& a, convertible_t& b, convertible_t& c);
  35. void SHL_64(convertible_t& a, convertible_t& b, convertible_t& c);
  36. void SHR_64(convertible_t& a, convertible_t& b, convertible_t& c);
  37. void SAR_64(convertible_t& a, convertible_t& b, convertible_t& c);
  38. void ROL_64(convertible_t& a, convertible_t& b, convertible_t& c);
  39. void ROR_64(convertible_t& a, convertible_t& b, convertible_t& c);
  40. void FPINIT();
  41. void FADD_64(convertible_t& a, double b, convertible_t& c);
  42. void FSUB_64(convertible_t& a, double b, convertible_t& c);
  43. void FMUL_64(convertible_t& a, double b, convertible_t& c);
  44. void FDIV_64(convertible_t& a, double b, convertible_t& c);
  45. void FABSQRT(convertible_t& a, convertible_t& b, convertible_t& c);
  46. void FROUND(convertible_t& a, convertible_t& b, convertible_t& c);
  47. inline void FADD(convertible_t& a, convertible_t& b, convertible_t& c) {
  48. FADD_64(a, (double)b.i64, c);
  49. }
  50. inline void FSUB(convertible_t& a, convertible_t& b, convertible_t& c) {
  51. FSUB_64(a, (double)b.i64, c);
  52. }
  53. inline void FMUL(convertible_t& a, convertible_t& b, convertible_t& c) {
  54. FMUL_64(a, (double)b.i64, c);
  55. }
  56. inline void FDIV(convertible_t& a, convertible_t& b, convertible_t& c) {
  57. FDIV_64(a, (double)b.i64, c);
  58. }
  59. }
  60. }