2017-03-18 17:20:21 +00:00
|
|
|
/* This file is part of the dynarmic project.
|
|
|
|
* Copyright (c) 2016 MerryMage
|
2020-04-23 15:25:11 +01:00
|
|
|
* SPDX-License-Identifier: 0BSD
|
2017-03-18 17:20:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
2019-05-24 01:04:37 +01:00
|
|
|
#include <tuple>
|
2017-03-18 17:20:21 +00:00
|
|
|
|
|
|
|
#include <xbyak.h>
|
|
|
|
|
|
|
|
#include "common/common_types.h"
|
|
|
|
|
2020-04-08 11:46:36 +01:00
|
|
|
namespace Dynarmic::Backend::X64 {
|
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;
|
|
|
|
};
|
|
|
|
|
2020-04-08 11:46:36 +01:00
|
|
|
} // namespace Dynarmic::Backend::X64
|