BackendX64/Routines: Add floating-point constants

This commit is contained in:
MerryMage 2016-08-06 17:12:40 +01:00
parent 8754728a82
commit 94d5738f62
2 changed files with 43 additions and 0 deletions

View file

@ -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<RunCodeFuncType>(const_cast<u8*>(this->GetCodePtr()));

View file

@ -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();