superscalar_program.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #pragma once
  16. #include <cstdint>
  17. #include "Instruction.hpp"
  18. #include "configuration.h"
  19. namespace randomx {
  20. class SuperscalarProgram {
  21. public:
  22. Instruction& operator()(int pc) {
  23. return programBuffer[pc];
  24. }
  25. friend std::ostream& operator<<(std::ostream& os, const SuperscalarProgram& p) {
  26. p.print(os);
  27. return os;
  28. }
  29. uint32_t getSize() {
  30. return size;
  31. }
  32. void setSize(uint32_t val) {
  33. size = val;
  34. }
  35. int getAddressRegister() {
  36. return addrReg;
  37. }
  38. void setAddressRegister(uint32_t val) {
  39. addrReg = val;
  40. }
  41. double ipc;
  42. int codeSize;
  43. int macroOps;
  44. int decodeCycles;
  45. int cpuLatency;
  46. int asicLatency;
  47. int mulCount;
  48. int cpuLatencies[8];
  49. int asicLatencies[8];
  50. private:
  51. void print(std::ostream& os) const {
  52. for (unsigned i = 0; i < size; ++i) {
  53. auto instr = programBuffer[i];
  54. os << instr;
  55. }
  56. }
  57. Instruction programBuffer[RANDOMX_SUPERSCALAR_MAX_SIZE];
  58. uint32_t size;
  59. int addrReg;
  60. };
  61. }