2016-07-01 15:01:06 +02:00
|
|
|
/* This file is part of the dynarmic project.
|
|
|
|
* Copyright (c) 2016 MerryMage
|
|
|
|
* This software may be used and distributed according to the terms of the GNU
|
|
|
|
* General Public License version 2 or any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2016-08-13 01:10:23 +02:00
|
|
|
#include <array>
|
|
|
|
|
2016-07-01 15:01:06 +02:00
|
|
|
#include "backend_x64/jitstate.h"
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "common/x64/emitter.h"
|
|
|
|
|
|
|
|
namespace Dynarmic {
|
|
|
|
namespace BackendX64 {
|
|
|
|
|
2016-08-07 19:08:48 +02:00
|
|
|
class BlockOfCode final : public Gen::XCodeBlock {
|
2016-07-01 15:01:06 +02:00
|
|
|
public:
|
2016-08-07 19:08:48 +02:00
|
|
|
BlockOfCode();
|
|
|
|
|
2016-08-12 19:17:31 +02:00
|
|
|
/// Clears this block of code and resets code pointer to beginning.
|
2016-08-07 19:08:48 +02:00
|
|
|
void ClearCache(bool poison_memory);
|
2016-07-01 15:01:06 +02:00
|
|
|
|
2016-08-12 19:17:31 +02:00
|
|
|
/// Runs emulated code for approximately `cycles_to_run` cycles.
|
2016-07-01 15:01:06 +02:00
|
|
|
size_t RunCode(JitState* jit_state, CodePtr basic_block, size_t cycles_to_run) const;
|
2016-08-12 19:17:31 +02:00
|
|
|
/// Code emitter: Returns to host
|
2016-08-07 23:47:17 +02:00
|
|
|
void ReturnFromRunCode(bool MXCSR_switch = true);
|
2016-08-12 19:17:31 +02:00
|
|
|
/// Code emitter: Makes guest MXCSR the current MXCSR
|
2016-08-07 23:47:17 +02:00
|
|
|
void SwitchMxcsrOnEntry();
|
2016-08-12 19:17:31 +02:00
|
|
|
/// Code emitter: Makes saved host MXCSR the current MXCSR
|
2016-08-07 23:47:17 +02:00
|
|
|
void SwitchMxcsrOnExit();
|
2016-08-07 19:08:48 +02:00
|
|
|
|
2016-08-22 16:35:07 +02:00
|
|
|
Gen::OpArg MFloatPositiveZero32() const {
|
|
|
|
return Gen::M(const_FloatPositiveZero32);
|
|
|
|
}
|
2016-08-06 18:12:40 +02:00
|
|
|
Gen::OpArg MFloatNegativeZero32() const {
|
|
|
|
return Gen::M(const_FloatNegativeZero32);
|
|
|
|
}
|
|
|
|
Gen::OpArg MFloatNaN32() const {
|
|
|
|
return Gen::M(const_FloatNaN32);
|
|
|
|
}
|
2016-08-07 02:27:18 +02:00
|
|
|
Gen::OpArg MFloatNonSignMask32() const {
|
|
|
|
return Gen::M(const_FloatNonSignMask32);
|
|
|
|
}
|
2016-08-22 16:35:07 +02:00
|
|
|
Gen::OpArg MFloatPositiveZero64() const {
|
|
|
|
return Gen::M(const_FloatPositiveZero64);
|
|
|
|
}
|
2016-08-06 18:12:40 +02:00
|
|
|
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);
|
|
|
|
}
|
2016-08-22 16:35:07 +02:00
|
|
|
Gen::OpArg MFloatMinS32() const {
|
|
|
|
return Gen::M(const_FloatMinS32);
|
|
|
|
}
|
|
|
|
Gen::OpArg MFloatMaxS32() const {
|
|
|
|
return Gen::M(const_FloatMaxS32);
|
|
|
|
}
|
|
|
|
Gen::OpArg MFloatMinU32() const {
|
|
|
|
return Gen::M(const_FloatMinU32);
|
|
|
|
}
|
|
|
|
Gen::OpArg MFloatMaxU32() const {
|
|
|
|
return Gen::M(const_FloatMaxU32);
|
|
|
|
}
|
2016-07-01 15:01:06 +02:00
|
|
|
|
2016-08-13 01:10:23 +02:00
|
|
|
CodePtr GetReturnFromRunCodeAddress() const {
|
|
|
|
return return_from_run_code;
|
|
|
|
}
|
|
|
|
|
2016-07-01 15:01:06 +02:00
|
|
|
private:
|
2016-08-22 16:35:07 +02:00
|
|
|
const u8* const_FloatPositiveZero32 = nullptr;
|
|
|
|
const u8* const_FloatNegativeZero32 = nullptr;
|
|
|
|
const u8* const_FloatNaN32 = nullptr;
|
|
|
|
const u8* const_FloatNonSignMask32 = nullptr;
|
|
|
|
const u8* const_FloatPositiveZero64 = nullptr;
|
|
|
|
const u8* const_FloatNegativeZero64 = nullptr;
|
|
|
|
const u8* const_FloatNaN64 = nullptr;
|
|
|
|
const u8* const_FloatNonSignMask64 = nullptr;
|
|
|
|
const u8* const_FloatPenultimatePositiveDenormal64 = nullptr;
|
|
|
|
const u8* const_FloatMinS32 = nullptr;
|
|
|
|
const u8* const_FloatMaxS32 = nullptr;
|
|
|
|
const u8* const_FloatMinU32 = nullptr;
|
|
|
|
const u8* const_FloatMaxU32 = nullptr;
|
2016-08-06 18:12:40 +02:00
|
|
|
void GenConstants();
|
|
|
|
|
2016-07-01 15:01:06 +02:00
|
|
|
using RunCodeFuncType = void(*)(JitState*, CodePtr);
|
2016-08-22 16:35:07 +02:00
|
|
|
RunCodeFuncType run_code = nullptr;
|
2016-07-01 15:01:06 +02:00
|
|
|
void GenRunCode();
|
2016-08-13 01:10:23 +02:00
|
|
|
|
2016-08-22 16:35:07 +02:00
|
|
|
CodePtr return_from_run_code = nullptr;
|
|
|
|
CodePtr return_from_run_code_without_mxcsr_switch = nullptr;
|
2016-08-13 01:10:23 +02:00
|
|
|
void GenReturnFromRunCode();
|
2016-07-01 15:01:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace BackendX64
|
|
|
|
} // namespace Dynarmic
|