Monero
Loading...
Searching...
No Matches
assembly_generator_x86.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2018-2019, tevador <tevador@gmail.com>
3
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, 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
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29#pragma once
30
31#include "common.hpp"
32#include <sstream>
33
34namespace randomx {
35
36 class Program;
39 class Instruction;
40
42
44 public:
48 void printCode(std::ostream& os) {
49 os << asmCode.rdbuf();
50 }
51 private:
52 void genAddressReg(Instruction&, const char*);
53 void genAddressRegDst(Instruction&, int);
55 void generateCode(Instruction&, int);
56 void traceint(Instruction&);
57 void traceflt(Instruction&);
58 void tracenop(Instruction&);
59 void h_IADD_RS(Instruction&, int);
60 void h_IADD_M(Instruction&, int);
61 void h_ISUB_R(Instruction&, int);
62 void h_ISUB_M(Instruction&, int);
63 void h_IMUL_R(Instruction&, int);
64 void h_IMUL_M(Instruction&, int);
65 void h_IMULH_R(Instruction&, int);
66 void h_IMULH_M(Instruction&, int);
67 void h_ISMULH_R(Instruction&, int);
68 void h_ISMULH_M(Instruction&, int);
69 void h_IMUL_RCP(Instruction&, int);
70 void h_INEG_R(Instruction&, int);
71 void h_IXOR_R(Instruction&, int);
72 void h_IXOR_M(Instruction&, int);
73 void h_IROR_R(Instruction&, int);
74 void h_IROL_R(Instruction&, int);
75 void h_ISWAP_R(Instruction&, int);
76 void h_FSWAP_R(Instruction&, int);
77 void h_FADD_R(Instruction&, int);
78 void h_FADD_M(Instruction&, int);
79 void h_FSUB_R(Instruction&, int);
80 void h_FSUB_M(Instruction&, int);
81 void h_FSCAL_R(Instruction&, int);
82 void h_FMUL_R(Instruction&, int);
83 void h_FDIV_M(Instruction&, int);
84 void h_FSQRT_R(Instruction&, int);
85 void h_CBRANCH(Instruction&, int);
86 void h_CFROUND(Instruction&, int);
87 void h_ISTORE(Instruction&, int);
88 void h_NOP(Instruction&, int);
89
91 std::stringstream asmCode;
93 };
94}
Definition assembly_generator_x86.hpp:43
void h_FSQRT_R(Instruction &, int)
Definition assembly_generator_x86.cpp:530
void h_ISTORE(Instruction &, int)
Definition assembly_generator_x86.cpp:565
void h_FADD_M(Instruction &, int)
Definition assembly_generator_x86.cpp:484
void traceint(Instruction &)
Definition assembly_generator_x86.cpp:236
void h_IROR_R(Instruction &, int)
Definition assembly_generator_x86.cpp:423
void h_INEG_R(Instruction &, int)
Definition assembly_generator_x86.cpp:394
std::stringstream asmCode
Definition assembly_generator_x86.hpp:91
void h_IADD_RS(Instruction &, int)
Definition assembly_generator_x86.cpp:281
void h_FDIV_M(Instruction &, int)
Definition assembly_generator_x86.cpp:520
void tracenop(Instruction &)
Definition assembly_generator_x86.cpp:248
int registerUsage[RegistersCount]
Definition assembly_generator_x86.hpp:92
void h_FSCAL_R(Instruction &, int)
Definition assembly_generator_x86.cpp:507
void h_IMULH_R(Instruction &, int)
Definition assembly_generator_x86.cpp:348
void h_IXOR_R(Instruction &, int)
Definition assembly_generator_x86.cpp:400
void h_FSWAP_R(Instruction &, int)
Definition assembly_generator_x86.cpp:472
void genAddressReg(Instruction &, const char *)
Definition assembly_generator_x86.cpp:260
void h_IADD_M(Instruction &, int)
Definition assembly_generator_x86.cpp:290
void h_FSUB_M(Instruction &, int)
Definition assembly_generator_x86.cpp:499
void generateCode(Instruction &, int)
Definition assembly_generator_x86.cpp:254
void h_ISUB_R(Instruction &, int)
Definition assembly_generator_x86.cpp:302
void generateC(SuperscalarProgram &prog)
Definition assembly_generator_x86.cpp:142
void h_FMUL_R(Instruction &, int)
Definition assembly_generator_x86.cpp:513
void h_IROL_R(Instruction &, int)
Definition assembly_generator_x86.cpp:435
void h_IMUL_R(Instruction &, int)
Definition assembly_generator_x86.cpp:325
void h_IXOR_M(Instruction &, int)
Definition assembly_generator_x86.cpp:411
void h_FSUB_R(Instruction &, int)
Definition assembly_generator_x86.cpp:492
void h_IMUL_RCP(Instruction &, int)
Definition assembly_generator_x86.cpp:447
void genAddressRegDst(Instruction &, int)
Definition assembly_generator_x86.cpp:265
void printCode(std::ostream &os)
Definition assembly_generator_x86.hpp:48
void h_CBRANCH(Instruction &, int)
Definition assembly_generator_x86.cpp:549
void generateProgram(Program &prog)
Definition assembly_generator_x86.cpp:54
void h_IMULH_M(Instruction &, int)
Definition assembly_generator_x86.cpp:356
void h_FADD_R(Instruction &, int)
Definition assembly_generator_x86.cpp:477
void traceflt(Instruction &)
Definition assembly_generator_x86.cpp:242
static InstructionGenerator engine[256]
Definition assembly_generator_x86.hpp:90
void generateAsm(SuperscalarProgram &prog)
Definition assembly_generator_x86.cpp:68
void h_ISUB_M(Instruction &, int)
Definition assembly_generator_x86.cpp:313
void h_ISMULH_R(Instruction &, int)
Definition assembly_generator_x86.cpp:371
void h_IMUL_M(Instruction &, int)
Definition assembly_generator_x86.cpp:336
void h_ISWAP_R(Instruction &, int)
Definition assembly_generator_x86.cpp:460
void h_ISMULH_M(Instruction &, int)
Definition assembly_generator_x86.cpp:379
void h_NOP(Instruction &, int)
Definition assembly_generator_x86.cpp:571
void h_CFROUND(Instruction &, int)
Definition assembly_generator_x86.cpp:536
int32_t genAddressImm(Instruction &)
Definition assembly_generator_x86.cpp:277
Definition instruction.hpp:75
Definition program.hpp:44
Definition superscalar_program.hpp:37
static char * prog
Definition mdb_load.c:33
Definition allocator.cpp:35
void(AssemblyGeneratorX86::* InstructionGenerator)(Instruction &, int)
Definition assembly_generator_x86.hpp:41
constexpr int RegistersCount
Definition common.hpp:156
signed int int32_t
Definition stdint.h:123