2017-03-18 17:20:21 +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
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include <xbyak.h>
|
|
|
|
|
|
|
|
#include "common/common_types.h"
|
|
|
|
|
2018-01-26 13:51:48 +00:00
|
|
|
namespace Dynarmic::BackendX64 {
|
2017-03-18 17:20:21 +00:00
|
|
|
|
|
|
|
class BlockOfCode;
|
|
|
|
|
|
|
|
/// ConstantPool allocates a block of memory from BlockOfCode.
|
|
|
|
/// It places constants into this block of memory, returning the address
|
|
|
|
/// of the memory location where the constant is placed. If the constant
|
|
|
|
/// already exists, its memory location is reused.
|
|
|
|
class ConstantPool final {
|
|
|
|
public:
|
2018-02-03 14:28:57 +00:00
|
|
|
ConstantPool(BlockOfCode& code, size_t size);
|
2017-03-18 17:20:21 +00:00
|
|
|
|
2018-02-20 14:04:11 +00:00
|
|
|
Xbyak::Address GetConstant(const Xbyak::AddressFrame& frame, u64 lower, u64 upper = 0);
|
2017-03-18 17:20:21 +00:00
|
|
|
|
|
|
|
private:
|
2017-09-29 01:23:45 +01:00
|
|
|
static constexpr size_t align_size = 16; // bytes
|
2017-03-18 17:20:21 +00:00
|
|
|
|
2018-02-10 16:25:07 +00:00
|
|
|
std::map<std::tuple<u64, u64>, void*> constant_info;
|
2017-03-18 17:20:21 +00:00
|
|
|
|
2018-02-03 14:28:57 +00:00
|
|
|
BlockOfCode& code;
|
2017-03-18 17:20:21 +00:00
|
|
|
size_t pool_size;
|
|
|
|
u8* pool_begin;
|
|
|
|
u8* current_pool_ptr;
|
|
|
|
};
|
|
|
|
|
2018-01-26 13:51:48 +00:00
|
|
|
} // namespace Dynarmic::BackendX64
|