Monero
Toggle main menu visibility
Loading...
Searching...
No Matches
external
randomx
src
program.hpp
Go to the documentation of this file.
1
/*
2
Copyright (c) 2018-2019, tevador <tevador@gmail.com>
3
4
All rights reserved.
5
6
Redistribution and use in source and binary forms, with or without
7
modification, are permitted provided that the following conditions are met:
8
* Redistributions of source code must retain the above copyright
9
notice, this list of conditions and the following disclaimer.
10
* Redistributions in binary form must reproduce the above copyright
11
notice, this list of conditions and the following disclaimer in the
12
documentation and/or other materials provided with the distribution.
13
* Neither the name of the copyright holder nor the
14
names of its contributors may be used to endorse or promote products
15
derived from this software without specific prior written permission.
16
17
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
28
29
#pragma once
30
31
#include <cstdint>
32
#include <ostream>
33
#include "
common.hpp
"
34
#include "
instruction.hpp
"
35
#include "
blake2/endian.h
"
36
37
namespace
randomx
{
38
39
struct
ProgramConfiguration
{
40
uint64_t
eMask
[2];
41
uint32_t
readReg0
,
readReg1
,
readReg2
,
readReg3
;
42
};
43
44
class
Program
{
45
public
:
46
Instruction
&
operator()
(
int
pc) {
47
return
programBuffer
[pc];
48
}
49
friend
std::ostream&
operator<<
(std::ostream& os,
const
Program
& p) {
50
p.print(os);
51
return
os;
52
}
53
uint64_t
getEntropy
(
int
i) {
54
return
load64
(&
entropyBuffer
[i]);
55
}
56
uint32_t
getSize
() {
57
return
RANDOMX_PROGRAM_SIZE
;
58
}
59
private
:
60
void
print
(std::ostream& os)
const
{
61
for
(
int
i = 0; i <
RANDOMX_PROGRAM_SIZE
; ++i) {
62
auto
instr =
programBuffer
[i];
63
os << instr;
64
}
65
}
66
uint64_t
entropyBuffer
[16];
67
Instruction
programBuffer
[
RANDOMX_PROGRAM_SIZE
];
68
};
69
70
static_assert
(
sizeof
(
Program
) % 64 == 0,
"Invalid size of class randomx::Program"
);
71
}
randomx::Instruction
Definition
instruction.hpp:75
randomx::Program
Definition
program.hpp:44
randomx::Program::programBuffer
Instruction programBuffer[RANDOMX_PROGRAM_SIZE]
Definition
program.hpp:67
randomx::Program::entropyBuffer
uint64_t entropyBuffer[16]
Definition
program.hpp:66
randomx::Program::getSize
uint32_t getSize()
Definition
program.hpp:56
randomx::Program::print
void print(std::ostream &os) const
Definition
program.hpp:60
randomx::Program::operator()
Instruction & operator()(int pc)
Definition
program.hpp:46
randomx::Program::getEntropy
uint64_t getEntropy(int i)
Definition
program.hpp:53
randomx::Program::operator<<
friend std::ostream & operator<<(std::ostream &os, const Program &p)
Definition
program.hpp:49
common.hpp
RANDOMX_PROGRAM_SIZE
#define RANDOMX_PROGRAM_SIZE
Definition
configuration.h:56
endian.h
load64
static FORCE_INLINE uint64_t load64(const void *src)
Definition
endian.h:50
instruction.hpp
randomx
Definition
allocator.cpp:35
uint32_t
unsigned int uint32_t
Definition
stdint.h:126
uint64_t
unsigned __int64 uint64_t
Definition
stdint.h:136
randomx::ProgramConfiguration
Definition
program.hpp:39
randomx::ProgramConfiguration::eMask
uint64_t eMask[2]
Definition
program.hpp:40
randomx::ProgramConfiguration::readReg0
uint32_t readReg0
Definition
program.hpp:41
randomx::ProgramConfiguration::readReg2
uint32_t readReg2
Definition
program.hpp:41
randomx::ProgramConfiguration::readReg1
uint32_t readReg1
Definition
program.hpp:41
randomx::ProgramConfiguration::readReg3
uint32_t readReg3
Definition
program.hpp:41
Generated on
for Monero by
1.17.0