diff --git a/src/backend_x64/routines.cpp b/src/backend_x64/routines.cpp index 690fb4ef..de1cf6d1 100644 --- a/src/backend_x64/routines.cpp +++ b/src/backend_x64/routines.cpp @@ -18,6 +18,7 @@ namespace BackendX64 { Routines::Routines() { AllocCodeSpace(1024); + GenConstants(); GenRunCode(); } @@ -30,6 +31,22 @@ size_t Routines::RunCode(JitState* jit_state, CodePtr basic_block, size_t cycles return cycles_to_run - jit_state->cycles_remaining; // Return number of cycles actually run. } +void Routines::GenConstants() { + const_FloatNegativeZero32 = AlignCode16(); + Write32(0x80000000u); + const_FloatNaN32 = AlignCode16(); + Write32(0x7fc00000u); + const_FloatNegativeZero64 = AlignCode16(); + Write64(0x8000000000000000u); + const_FloatNaN64 = AlignCode16(); + Write64(0x7ff8000000000000u); + const_FloatNonSignMask64 = AlignCode16(); + Write64(0x7fffffffffffffffu); + const_FloatPenultimatePositiveDenormal64 = AlignCode16(); + Write64(0x000ffffffffffffeu); + AlignCode16(); +} + void Routines::GenRunCode() { run_code = reinterpret_cast(const_cast(this->GetCodePtr())); diff --git a/src/backend_x64/routines.h b/src/backend_x64/routines.h index bd113dad..88117552 100644 --- a/src/backend_x64/routines.h +++ b/src/backend_x64/routines.h @@ -19,8 +19,34 @@ public: size_t RunCode(JitState* jit_state, CodePtr basic_block, size_t cycles_to_run) const; void GenReturnFromRunCode(Gen::XEmitter* code) const; + Gen::OpArg MFloatNegativeZero32() const { + return Gen::M(const_FloatNegativeZero32); + } + Gen::OpArg MFloatNaN32() const { + return Gen::M(const_FloatNaN32); + } + Gen::OpArg MFloatNegativeZero64() const { + return Gen::M(const_FloatNegativeZero64); + } + Gen::OpArg MFloatNaN64() const { + return Gen::M(const_FloatNaN64); + } + Gen::OpArg MFloatNonSignMask64() const { + return Gen::M(const_FloatNonSignMask64); + } + Gen::OpArg MFloatPenultimatePositiveDenormal64() const { + return Gen::M(const_FloatPenultimatePositiveDenormal64); + } private: + const u8* const_FloatNegativeZero32; + const u8* const_FloatNaN32; + const u8* const_FloatNegativeZero64; + const u8* const_FloatNaN64; + const u8* const_FloatNonSignMask64; + const u8* const_FloatPenultimatePositiveDenormal64; + void GenConstants(); + using RunCodeFuncType = void(*)(JitState*, CodePtr); RunCodeFuncType run_code; void GenRunCode();