2018-01-06 21:15:25 +00: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
|
|
|
|
|
2018-02-12 19:49:56 +00:00
|
|
|
#include <map>
|
|
|
|
#include <tuple>
|
|
|
|
|
2018-08-14 19:13:47 +01:00
|
|
|
#include "backend/x64/a64_jitstate.h"
|
|
|
|
#include "backend/x64/block_range_information.h"
|
|
|
|
#include "backend/x64/emit_x64.h"
|
2018-08-18 01:20:42 +01:00
|
|
|
#include "dynarmic/A64/a64.h"
|
2018-01-06 21:15:25 +00:00
|
|
|
#include "dynarmic/A64/config.h"
|
|
|
|
#include "frontend/A64/location_descriptor.h"
|
|
|
|
#include "frontend/ir/terminal.h"
|
|
|
|
|
2018-01-26 13:51:48 +00:00
|
|
|
namespace Dynarmic::BackendX64 {
|
2018-01-06 21:15:25 +00:00
|
|
|
|
|
|
|
class RegAlloc;
|
|
|
|
|
|
|
|
struct A64EmitContext final : public EmitContext {
|
2018-02-18 13:00:41 +00:00
|
|
|
A64EmitContext(const A64::UserConfig& conf, RegAlloc& reg_alloc, IR::Block& block);
|
2018-01-06 21:15:25 +00:00
|
|
|
A64::LocationDescriptor Location() const;
|
2018-07-14 07:08:15 +01:00
|
|
|
FP::RoundingMode FPSCR_RMode() const override;
|
2018-07-15 14:23:50 +01:00
|
|
|
u32 FPCR() const override;
|
2018-01-06 21:15:25 +00:00
|
|
|
bool FPSCR_FTZ() const override;
|
|
|
|
bool FPSCR_DN() const override;
|
2018-02-18 13:04:45 +00:00
|
|
|
bool AccurateNaN() const override;
|
2018-02-18 13:00:41 +00:00
|
|
|
|
|
|
|
const A64::UserConfig& conf;
|
2018-01-06 21:15:25 +00:00
|
|
|
};
|
|
|
|
|
2018-01-23 19:16:39 +00:00
|
|
|
class A64EmitX64 final : public EmitX64 {
|
2018-01-06 21:15:25 +00:00
|
|
|
public:
|
2018-08-18 01:20:42 +01:00
|
|
|
A64EmitX64(BlockOfCode& code, A64::UserConfig conf, A64::Jit* jit_interface);
|
2018-01-27 02:25:27 +00:00
|
|
|
~A64EmitX64() override;
|
2018-01-06 21:15:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Emit host machine code for a basic block with intermediate representation `ir`.
|
|
|
|
* @note ir is modified.
|
|
|
|
*/
|
|
|
|
BlockDescriptor Emit(IR::Block& ir);
|
|
|
|
|
2018-01-23 19:16:39 +00:00
|
|
|
void ClearCache() override;
|
|
|
|
|
|
|
|
void InvalidateCacheRanges(const boost::icl::interval_set<u64>& ranges);
|
|
|
|
|
2018-01-06 21:15:25 +00:00
|
|
|
protected:
|
|
|
|
const A64::UserConfig conf;
|
2018-08-18 01:20:42 +01:00
|
|
|
A64::Jit* jit_interface;
|
2018-01-23 19:16:39 +00:00
|
|
|
BlockRangeInformation<u64> block_ranges;
|
2018-01-06 21:15:25 +00:00
|
|
|
|
2018-02-12 18:18:47 +00:00
|
|
|
void (*memory_read_128)();
|
|
|
|
void (*memory_write_128)();
|
|
|
|
void GenMemory128Accessors();
|
|
|
|
|
2018-02-12 19:49:56 +00:00
|
|
|
std::map<std::tuple<size_t, int, int>, void(*)()> read_fallbacks;
|
|
|
|
std::map<std::tuple<size_t, int, int>, void(*)()> write_fallbacks;
|
|
|
|
void GenFastmemFallbacks();
|
|
|
|
|
|
|
|
void EmitDirectPageTableMemoryRead(A64EmitContext& ctx, IR::Inst* inst, size_t bitsize);
|
|
|
|
void EmitDirectPageTableMemoryWrite(A64EmitContext& ctx, IR::Inst* inst, size_t bitsize);
|
2018-06-05 12:26:05 +01:00
|
|
|
void EmitExclusiveWrite(A64EmitContext& ctx, IR::Inst* inst, size_t bitsize);
|
2018-02-12 19:49:56 +00:00
|
|
|
|
2018-01-06 21:15:25 +00:00
|
|
|
// Microinstruction emitters
|
|
|
|
#define OPCODE(...)
|
|
|
|
#define A32OPC(...)
|
|
|
|
#define A64OPC(name, type, ...) void EmitA64##name(A64EmitContext& ctx, IR::Inst* inst);
|
|
|
|
#include "frontend/ir/opcodes.inc"
|
|
|
|
#undef OPCODE
|
|
|
|
#undef A32OPC
|
|
|
|
#undef A64OPC
|
|
|
|
|
|
|
|
// Terminal instruction emitters
|
|
|
|
void EmitTerminalImpl(IR::Term::Interpret terminal, IR::LocationDescriptor initial_location) override;
|
|
|
|
void EmitTerminalImpl(IR::Term::ReturnToDispatch terminal, IR::LocationDescriptor initial_location) override;
|
|
|
|
void EmitTerminalImpl(IR::Term::LinkBlock terminal, IR::LocationDescriptor initial_location) override;
|
|
|
|
void EmitTerminalImpl(IR::Term::LinkBlockFast terminal, IR::LocationDescriptor initial_location) override;
|
|
|
|
void EmitTerminalImpl(IR::Term::PopRSBHint terminal, IR::LocationDescriptor initial_location) override;
|
|
|
|
void EmitTerminalImpl(IR::Term::If terminal, IR::LocationDescriptor initial_location) override;
|
2018-01-07 16:33:02 +00:00
|
|
|
void EmitTerminalImpl(IR::Term::CheckBit terminal, IR::LocationDescriptor initial_location) override;
|
2018-01-06 21:15:25 +00:00
|
|
|
void EmitTerminalImpl(IR::Term::CheckHalt terminal, IR::LocationDescriptor initial_location) override;
|
|
|
|
|
|
|
|
// Patching
|
|
|
|
void EmitPatchJg(const IR::LocationDescriptor& target_desc, CodePtr target_code_ptr = nullptr) override;
|
|
|
|
void EmitPatchJmp(const IR::LocationDescriptor& target_desc, CodePtr target_code_ptr = nullptr) override;
|
|
|
|
void EmitPatchMovRcx(CodePtr target_code_ptr = nullptr) override;
|
|
|
|
};
|
|
|
|
|
2018-01-26 13:51:48 +00:00
|
|
|
} // namespace Dynarmic::BackendX64
|