mirror of
https://github.com/wownero/RandomWOW.git
synced 2026-10-19 16:28:44 +02:00
Code cleanup & refactoring
This commit is contained in:
+17
-37
@@ -29,12 +29,12 @@ namespace randomx {
|
||||
}
|
||||
|
||||
void Instruction::genAddressReg(std::ostream& os) const {
|
||||
os << ((mod % 4) ? "L1" : "L2") << "[r" << (int)src << std::showpos << (int32_t)getImm32() << std::noshowpos << "]";
|
||||
os << (getModMem() ? "L1" : "L2") << "[r" << (int)src << std::showpos << (int32_t)getImm32() << std::noshowpos << "]";
|
||||
}
|
||||
|
||||
void Instruction::genAddressRegDst(std::ostream& os) const {
|
||||
if (getModCond())
|
||||
os << ((mod % 4) ? "L1" : "L2");
|
||||
os << (getModMem() ? "L1" : "L2");
|
||||
else
|
||||
os << "L3";
|
||||
os << "[r" << (int)dst << std::showpos << (int32_t)getImm32() << std::noshowpos << "]";
|
||||
@@ -49,7 +49,7 @@ namespace randomx {
|
||||
if(dst == RegisterNeedsDisplacement) {
|
||||
os << ", " << (int32_t)getImm32();
|
||||
}
|
||||
os << ", LSH " << (int)(mod % 4) << std::endl;
|
||||
os << ", LSH " << (int)getModMem() << std::endl;
|
||||
}
|
||||
|
||||
void Instruction::h_IADD_M(std::ostream& os) const {
|
||||
@@ -65,7 +65,6 @@ namespace randomx {
|
||||
}
|
||||
}
|
||||
|
||||
//1 uOP
|
||||
void Instruction::h_ISUB_R(std::ostream& os) const {
|
||||
if (src != dst) {
|
||||
os << "r" << (int)dst << ", r" << (int)src << std::endl;
|
||||
@@ -197,57 +196,57 @@ namespace randomx {
|
||||
}
|
||||
|
||||
void Instruction::h_FSWAP_R(std::ostream& os) const {
|
||||
const char reg = (dst >= 4) ? 'e' : 'f';
|
||||
auto dstIndex = dst % 4;
|
||||
const char reg = (dst >= RegisterCountFlt) ? 'e' : 'f';
|
||||
auto dstIndex = dst % RegisterCountFlt;
|
||||
os << reg << dstIndex << std::endl;
|
||||
}
|
||||
|
||||
void Instruction::h_FADD_R(std::ostream& os) const {
|
||||
auto dstIndex = dst % 4;
|
||||
auto srcIndex = src % 4;
|
||||
auto dstIndex = dst % RegisterCountFlt;
|
||||
auto srcIndex = src % RegisterCountFlt;
|
||||
os << "f" << dstIndex << ", a" << srcIndex << std::endl;
|
||||
}
|
||||
|
||||
void Instruction::h_FADD_M(std::ostream& os) const {
|
||||
auto dstIndex = dst % 4;
|
||||
auto dstIndex = dst % RegisterCountFlt;
|
||||
os << "f" << dstIndex << ", ";
|
||||
genAddressReg(os);
|
||||
os << std::endl;
|
||||
}
|
||||
|
||||
void Instruction::h_FSUB_R(std::ostream& os) const {
|
||||
auto dstIndex = dst % 4;
|
||||
auto srcIndex = src % 4;
|
||||
auto dstIndex = dst % RegisterCountFlt;
|
||||
auto srcIndex = src % RegisterCountFlt;
|
||||
os << "f" << dstIndex << ", a" << srcIndex << std::endl;
|
||||
}
|
||||
|
||||
void Instruction::h_FSUB_M(std::ostream& os) const {
|
||||
auto dstIndex = dst % 4;
|
||||
auto dstIndex = dst % RegisterCountFlt;
|
||||
os << "f" << dstIndex << ", ";
|
||||
genAddressReg(os);
|
||||
os << std::endl;
|
||||
}
|
||||
|
||||
void Instruction::h_FSCAL_R(std::ostream& os) const {
|
||||
auto dstIndex = dst % 4;
|
||||
auto dstIndex = dst % RegisterCountFlt;
|
||||
os << "f" << dstIndex << std::endl;
|
||||
}
|
||||
|
||||
void Instruction::h_FMUL_R(std::ostream& os) const {
|
||||
auto dstIndex = dst % 4;
|
||||
auto srcIndex = src % 4;
|
||||
auto dstIndex = dst % RegisterCountFlt;
|
||||
auto srcIndex = src % RegisterCountFlt;
|
||||
os << "e" << dstIndex << ", a" << srcIndex << std::endl;
|
||||
}
|
||||
|
||||
void Instruction::h_FDIV_M(std::ostream& os) const {
|
||||
auto dstIndex = dst % 4;
|
||||
auto dstIndex = dst % RegisterCountFlt;
|
||||
os << "e" << dstIndex << ", ";
|
||||
genAddressReg(os);
|
||||
os << std::endl;
|
||||
}
|
||||
|
||||
void Instruction::h_FSQRT_R(std::ostream& os) const {
|
||||
auto dstIndex = dst % 4;
|
||||
auto dstIndex = dst % RegisterCountFlt;
|
||||
os << "e" << dstIndex << std::endl;
|
||||
}
|
||||
|
||||
@@ -280,7 +279,7 @@ namespace randomx {
|
||||
}
|
||||
|
||||
void Instruction::h_COND_R(std::ostream& os) const {
|
||||
os << "r" << (int)dst << ", " << condition((mod >> 2) & 7) << "(r" << (int)src << ", " << (int32_t)getImm32() << "), LSH " << (int)(mod >> 5) << std::endl;
|
||||
os << "r" << (int)dst << ", " << condition(getModCond()) << "(r" << (int)src << ", " << (int32_t)getImm32() << "), LSH " << (int)(getModShift()) << std::endl;
|
||||
}
|
||||
|
||||
void Instruction::h_ISTORE(std::ostream& os) const {
|
||||
@@ -297,7 +296,6 @@ namespace randomx {
|
||||
#define INST_HANDLE(x) REPN(&Instruction::h_##x, WT(x))
|
||||
|
||||
const char* Instruction::names[256] = {
|
||||
//Integer
|
||||
INST_NAME(IADD_RS)
|
||||
INST_NAME(IADD_M)
|
||||
INST_NAME(ISUB_R)
|
||||
@@ -314,33 +312,22 @@ namespace randomx {
|
||||
INST_NAME(IXOR_M)
|
||||
INST_NAME(IROR_R)
|
||||
INST_NAME(ISWAP_R)
|
||||
|
||||
//Common floating point
|
||||
INST_NAME(FSWAP_R)
|
||||
|
||||
//Floating point group F
|
||||
INST_NAME(FADD_R)
|
||||
INST_NAME(FADD_M)
|
||||
INST_NAME(FSUB_R)
|
||||
INST_NAME(FSUB_M)
|
||||
INST_NAME(FSCAL_R)
|
||||
|
||||
//Floating point group E
|
||||
INST_NAME(FMUL_R)
|
||||
INST_NAME(FDIV_M)
|
||||
INST_NAME(FSQRT_R)
|
||||
|
||||
//Control
|
||||
INST_NAME(COND_R)
|
||||
INST_NAME(CFROUND)
|
||||
|
||||
INST_NAME(ISTORE)
|
||||
|
||||
INST_NAME(NOP)
|
||||
};
|
||||
|
||||
InstructionFormatter Instruction::engine[256] = {
|
||||
//Integer
|
||||
INST_HANDLE(IADD_RS)
|
||||
INST_HANDLE(IADD_M)
|
||||
INST_HANDLE(ISUB_R)
|
||||
@@ -358,22 +345,15 @@ namespace randomx {
|
||||
INST_HANDLE(IROR_R)
|
||||
INST_HANDLE(IROL_R)
|
||||
INST_HANDLE(ISWAP_R)
|
||||
|
||||
//Common floating point
|
||||
INST_HANDLE(FSWAP_R)
|
||||
|
||||
//Floating point group F
|
||||
INST_HANDLE(FADD_R)
|
||||
INST_HANDLE(FADD_M)
|
||||
INST_HANDLE(FSUB_R)
|
||||
INST_HANDLE(FSUB_M)
|
||||
INST_HANDLE(FSCAL_R)
|
||||
|
||||
//Floating point group E
|
||||
INST_HANDLE(FMUL_R)
|
||||
INST_HANDLE(FDIV_M)
|
||||
INST_HANDLE(FSQRT_R)
|
||||
|
||||
INST_HANDLE(COND_R)
|
||||
INST_HANDLE(CFROUND)
|
||||
INST_HANDLE(ISTORE)
|
||||
|
||||
Reference in New Issue
Block a user