mirror of
https://github.com/wownero/RandomX.git
synced 2026-10-21 09:18:45 +02:00
Refactoring (#95)
* Blake2Generator::getInt32 renamed to getUInt32 to avoid confusion * isPowerOf2 renamed to isZeroOrPowerOf2 to avoid confusion * added asserts to validate the input/output size of AES functions * fixed possible overflow in JitCompilerX86::getCodeSize (unused function)
This commit is contained in:
+8
-7
@@ -37,6 +37,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "superscalar.hpp"
|
||||
#include "intrin_portable.h"
|
||||
#include "reciprocal.h"
|
||||
#include "common.hpp"
|
||||
|
||||
namespace randomx {
|
||||
|
||||
@@ -334,7 +335,7 @@ namespace randomx {
|
||||
return false;
|
||||
|
||||
if (availableRegisters.size() > 1) {
|
||||
index = gen.getInt32() % availableRegisters.size();
|
||||
index = gen.getUInt32() % availableRegisters.size();
|
||||
}
|
||||
else {
|
||||
index = 0;
|
||||
@@ -447,7 +448,7 @@ namespace randomx {
|
||||
case SuperscalarInstructionType::IADD_C8:
|
||||
case SuperscalarInstructionType::IADD_C9: {
|
||||
mod_ = 0;
|
||||
imm32_ = gen.getInt32();
|
||||
imm32_ = gen.getUInt32();
|
||||
opGroup_ = SuperscalarInstructionType::IADD_C7;
|
||||
opGroupPar_ = -1;
|
||||
} break;
|
||||
@@ -456,7 +457,7 @@ namespace randomx {
|
||||
case SuperscalarInstructionType::IXOR_C8:
|
||||
case SuperscalarInstructionType::IXOR_C9: {
|
||||
mod_ = 0;
|
||||
imm32_ = gen.getInt32();
|
||||
imm32_ = gen.getUInt32();
|
||||
opGroup_ = SuperscalarInstructionType::IXOR_C7;
|
||||
opGroupPar_ = -1;
|
||||
} break;
|
||||
@@ -466,7 +467,7 @@ namespace randomx {
|
||||
mod_ = 0;
|
||||
imm32_ = 0;
|
||||
opGroup_ = SuperscalarInstructionType::IMULH_R;
|
||||
opGroupPar_ = gen.getInt32();
|
||||
opGroupPar_ = gen.getUInt32();
|
||||
} break;
|
||||
|
||||
case SuperscalarInstructionType::ISMULH_R: {
|
||||
@@ -474,14 +475,14 @@ namespace randomx {
|
||||
mod_ = 0;
|
||||
imm32_ = 0;
|
||||
opGroup_ = SuperscalarInstructionType::ISMULH_R;
|
||||
opGroupPar_ = gen.getInt32();
|
||||
opGroupPar_ = gen.getUInt32();
|
||||
} break;
|
||||
|
||||
case SuperscalarInstructionType::IMUL_RCP: {
|
||||
mod_ = 0;
|
||||
do {
|
||||
imm32_ = gen.getInt32();
|
||||
} while ((imm32_ & (imm32_ - 1)) == 0);
|
||||
imm32_ = gen.getUInt32();
|
||||
} while (isZeroOrPowerOf2(imm32_));
|
||||
opGroup_ = SuperscalarInstructionType::IMUL_RCP;
|
||||
opGroupPar_ = -1;
|
||||
} break;
|
||||
|
||||
Reference in New Issue
Block a user