LightProgramGenerator.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. Copyright (c) 2019 tevador
  3. This file is part of RandomX.
  4. RandomX is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. RandomX is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with RandomX. If not, see<http://www.gnu.org/licenses/>.
  14. */
  15. #include "Program.hpp"
  16. namespace RandomX {
  17. // Intel Ivy Bridge reference
  18. namespace LightInstructionType { //uOPs (decode) execution ports latency code size
  19. constexpr int ISUB_R = 0; //1 p015 1 3
  20. constexpr int IXOR_R = 1; //1 p015 1 3
  21. constexpr int IADD_RS = 2; //1 p01 1 4
  22. constexpr int IMUL_R = 3; //1 p1 3 4
  23. constexpr int IROR_C = 4; //1 p05 1 4
  24. constexpr int IADD_C7 = 5; //1 p015 1 7
  25. constexpr int IXOR_C7 = 6; //1 p015 1 7
  26. constexpr int IADD_C8 = 7; //1+0 p015 1 8
  27. constexpr int IXOR_C8 = 8; //1+0 p015 1 8
  28. constexpr int IADD_C9 = 9; //1+0 p015 1 9
  29. constexpr int IXOR_C9 = 10; //1+0 p015 1 9
  30. constexpr int IMULH_R = 11; //1+2+1 0+(p1,p5)+0 3 3+3+3
  31. constexpr int ISMULH_R = 12; //1+2+1 0+(p1,p5)+0 3 3+3+3
  32. constexpr int IMUL_RCP = 13; //1+1 p015+p1 4 10+4
  33. constexpr int COUNT = 14;
  34. constexpr int INVALID = -1;
  35. }
  36. class Blake2Generator {
  37. public:
  38. Blake2Generator(const void* seed, int nonce);
  39. uint8_t getByte();
  40. uint32_t getInt32();
  41. private:
  42. uint8_t data[64];
  43. size_t dataIndex;
  44. void checkData(const size_t);
  45. };
  46. double generateLightProg2(LightProgram& prog, Blake2Generator& gen);
  47. }