Code generator fixups

- fixed a crash in Instruction::print
- new example program
- added a design note about the number of x86 instruction per VM instruction
This commit is contained in:
tevador 2019-06-23 23:10:29 +02:00
parent 77f809e8db
commit e6ba0a1b7d
4 changed files with 956 additions and 953 deletions

View File

@ -133,6 +133,10 @@ This section describes the design of the RandomX virtual machine (VM).
RandomX uses a fixed-length instruction encoding with 8 bytes per instruction. This allows a 32-bit immediate value to be included in the instruction word. The interpretation of the instruction word bits was chosen so that any 8-byte word is a valid instruction. This allows for very efficient random program generation (see chapter 1.1.1). RandomX uses a fixed-length instruction encoding with 8 bytes per instruction. This allows a 32-bit immediate value to be included in the instruction word. The interpretation of the instruction word bits was chosen so that any 8-byte word is a valid instruction. This allows for very efficient random program generation (see chapter 1.1.1).
#### 2.1.1 Instruction complexity
The VM is a complex instruction set machine that allows both register and memory addressed operands. However, each RandomX instructions translates to only 1-7 x86 instructions (1.8 on average). It is important to keep the instruction complexity relatively low to minimize the efficiency advantage of specialized hardware with a tailored instruction set.
### 2.2 Program ### 2.2 Program
The program executed by the VM has the form of a loop consisting of 256 random instructions. The program executed by the VM has the form of a loop consisting of 256 random instructions.

File diff suppressed because it is too large Load Diff

View File

@ -337,6 +337,7 @@ namespace randomx {
INST_NAME(IXOR_R) INST_NAME(IXOR_R)
INST_NAME(IXOR_M) INST_NAME(IXOR_M)
INST_NAME(IROR_R) INST_NAME(IROR_R)
INST_NAME(IROL_R)
INST_NAME(ISWAP_R) INST_NAME(ISWAP_R)
INST_NAME(FSWAP_R) INST_NAME(FSWAP_R)
INST_NAME(FADD_R) INST_NAME(FADD_R)

View File

@ -54,7 +54,7 @@ void generateAsm(uint32_t nonce) {
fillAes1Rx4<softAes>((void*)hash, randomx::ScratchpadSize, scratchpad); fillAes1Rx4<softAes>((void*)hash, randomx::ScratchpadSize, scratchpad);
randomx::AssemblyGeneratorX86 asmX86; randomx::AssemblyGeneratorX86 asmX86;
randomx::Program p; randomx::Program p;
fillAes1Rx4<softAes>(hash, sizeof(p), &p); fillAes4Rx4<softAes>(hash, sizeof(p), &p);
asmX86.generateProgram(p); asmX86.generateProgram(p);
asmX86.printCode(std::cout); asmX86.printCode(std::cout);
} }