Code cleanup: moving poly/ into xenia/base/
This commit is contained in:
parent
99816056be
commit
e3220f7ae6
|
@ -1,5 +1,4 @@
|
|||
All code (headers and sources) lives under this path, excluding third_party code.
|
||||
|
||||
* poly: a lightweight cross-platform/compiler compatibility library.
|
||||
* xdb: xenia debugger library and UI.
|
||||
* xenia: emulator code.
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2014 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_ASSERT_H_
|
||||
#define POLY_ASSERT_H_
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "poly/platform.h"
|
||||
|
||||
namespace poly {
|
||||
|
||||
#define static_assert_size(type, size) \
|
||||
static_assert(sizeof(type) == size, \
|
||||
"bad definition for " #type ": must be " #size " bytes")
|
||||
|
||||
// We rely on assert being compiled out in NDEBUG.
|
||||
#define poly_assert assert
|
||||
|
||||
#define __POLY_EXPAND(x) x
|
||||
#define __POLY_ARGC(...) \
|
||||
__POLY_EXPAND(__POLY_ARGC_IMPL(__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, \
|
||||
6, 5, 4, 3, 2, 1, 0))
|
||||
#define __POLY_ARGC_IMPL(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, \
|
||||
x13, x14, x15, N, ...) \
|
||||
N
|
||||
#define __POLY_MACRO_DISPATCH(func, ...) \
|
||||
__POLY_MACRO_DISPATCH_(func, __POLY_ARGC(__VA_ARGS__))
|
||||
#define __POLY_MACRO_DISPATCH_(func, nargs) __POLY_MACRO_DISPATCH__(func, nargs)
|
||||
#define __POLY_MACRO_DISPATCH__(func, nargs) func##nargs
|
||||
|
||||
#define assert_always(...) poly_assert(false)
|
||||
|
||||
#define assert_true(...) \
|
||||
__POLY_MACRO_DISPATCH(assert_true, __VA_ARGS__)(__VA_ARGS__)
|
||||
#define assert_true1(expr) poly_assert(expr)
|
||||
#define assert_true2(expr, message) poly_assert((expr) || !message)
|
||||
|
||||
#define assert_false(...) \
|
||||
__POLY_MACRO_DISPATCH(assert_false, __VA_ARGS__)(__VA_ARGS__)
|
||||
#define assert_false1(expr) poly_assert(!(expr))
|
||||
#define assert_false2(expr, message) poly_assert(!(expr) || !message)
|
||||
|
||||
#define assert_zero(...) \
|
||||
__POLY_MACRO_DISPATCH(assert_zero, __VA_ARGS__)(__VA_ARGS__)
|
||||
#define assert_zero1(expr) poly_assert((expr) == 0)
|
||||
#define assert_zero2(expr, message) poly_assert((expr) == 0 || !message)
|
||||
|
||||
#define assert_not_zero(...) \
|
||||
__POLY_MACRO_DISPATCH(assert_not_zero, __VA_ARGS__)(__VA_ARGS__)
|
||||
#define assert_not_zero1(expr) poly_assert((expr) != 0)
|
||||
#define assert_not_zero2(expr, message) poly_assert((expr) != 0 || !message)
|
||||
|
||||
#define assert_null(...) \
|
||||
__POLY_MACRO_DISPATCH(assert_null, __VA_ARGS__)(__VA_ARGS__)
|
||||
#define assert_null1(expr) poly_assert((expr) == nullptr)
|
||||
#define assert_null2(expr, message) poly_assert((expr) == nullptr || !message)
|
||||
|
||||
#define assert_not_null(...) \
|
||||
__POLY_MACRO_DISPATCH(assert_not_null, __VA_ARGS__)(__VA_ARGS__)
|
||||
#define assert_not_null1(expr) poly_assert((expr) != nullptr)
|
||||
#define assert_not_null2(expr, message) \
|
||||
poly_assert((expr) != nullptr || !message)
|
||||
|
||||
#define assert_unhandled_case(variable) \
|
||||
assert_always("unhandled switch(" #variable ") case")
|
||||
|
||||
} // namespace poly
|
||||
|
||||
#endif // POLY_ASSERT_H_
|
|
@ -1,65 +0,0 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2014 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_BYTE_ORDER_H_
|
||||
#define POLY_BYTE_ORDER_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "poly/platform.h"
|
||||
|
||||
#if XE_PLATFORM_MAC
|
||||
#include <libkern/OSByteOrder.h>
|
||||
#endif // XE_PLATFORM_MAC
|
||||
|
||||
namespace poly {
|
||||
|
||||
#if XE_COMPILER_MSVC
|
||||
#define POLY_BYTE_SWAP_16 _byteswap_ushort
|
||||
#define POLY_BYTE_SWAP_32 _byteswap_ulong
|
||||
#define POLY_BYTE_SWAP_64 _byteswap_uint64
|
||||
#elif XE_PLATFORM_MAC
|
||||
#define POLY_BYTE_SWAP_16 OSSwapInt16
|
||||
#define POLY_BYTE_SWAP_32 OSSwapInt32
|
||||
#define POLY_BYTE_SWAP_64 OSSwapInt64
|
||||
#else
|
||||
#define POLY_BYTE_SWAP_16 __bswap_16
|
||||
#define POLY_BYTE_SWAP_32 __bswap_32
|
||||
#define POLY_BYTE_SWAP_64 __bswap_64
|
||||
#endif // XE_COMPILER_MSVC
|
||||
|
||||
inline int8_t byte_swap(int8_t value) { return value; }
|
||||
inline uint8_t byte_swap(uint8_t value) { return value; }
|
||||
inline int16_t byte_swap(int16_t value) {
|
||||
return static_cast<int16_t>(POLY_BYTE_SWAP_16(static_cast<int16_t>(value)));
|
||||
}
|
||||
inline uint16_t byte_swap(uint16_t value) { return POLY_BYTE_SWAP_16(value); }
|
||||
inline uint16_t byte_swap(wchar_t value) {
|
||||
return static_cast<wchar_t>(POLY_BYTE_SWAP_16(value));
|
||||
}
|
||||
inline int32_t byte_swap(int32_t value) {
|
||||
return static_cast<int32_t>(POLY_BYTE_SWAP_32(static_cast<int32_t>(value)));
|
||||
}
|
||||
inline uint32_t byte_swap(uint32_t value) { return POLY_BYTE_SWAP_32(value); }
|
||||
inline int64_t byte_swap(int64_t value) {
|
||||
return static_cast<int64_t>(POLY_BYTE_SWAP_64(static_cast<int64_t>(value)));
|
||||
}
|
||||
inline uint64_t byte_swap(uint64_t value) { return POLY_BYTE_SWAP_64(value); }
|
||||
inline float byte_swap(float value) {
|
||||
uint32_t temp = byte_swap(*reinterpret_cast<uint32_t *>(&value));
|
||||
return *reinterpret_cast<float *>(&temp);
|
||||
}
|
||||
inline double byte_swap(double value) {
|
||||
uint64_t temp = byte_swap(*reinterpret_cast<uint64_t *>(&value));
|
||||
return *reinterpret_cast<double *>(&temp);
|
||||
}
|
||||
|
||||
} // namespace poly
|
||||
|
||||
#endif // POLY_BYTE_ORDER_H_
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include <functional>
|
||||
|
||||
#include <poly/delegate.h>
|
||||
#include "xenia/base/delegate.h"
|
||||
#include <xdb/module.h>
|
||||
#include <xdb/protocol.h>
|
||||
#include <xdb/thread.h>
|
||||
|
@ -27,15 +27,15 @@ class Cursor {
|
|||
|
||||
// TODO(benvanik): breakpoints/events
|
||||
|
||||
poly::Delegate<void> end_of_stream;
|
||||
xe::Delegate<void> end_of_stream;
|
||||
|
||||
std::vector<Module*> modules();
|
||||
std::vector<Thread*> threads();
|
||||
|
||||
poly::Delegate<Module*> module_loaded;
|
||||
poly::Delegate<Module*> module_unloaded;
|
||||
poly::Delegate<Thread*> thread_created;
|
||||
poly::Delegate<Thread*> thread_exited;
|
||||
xe::Delegate<Module*> module_loaded;
|
||||
xe::Delegate<Module*> module_unloaded;
|
||||
xe::Delegate<Thread*> thread_created;
|
||||
xe::Delegate<Thread*> thread_exited;
|
||||
|
||||
// TODO(benvanik): memory access
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ class PostmortemCursor::Executor {
|
|||
return;
|
||||
}
|
||||
while (!exit_signal) {
|
||||
auto event_type = poly::load<EventType>(trace_ptr_);
|
||||
auto event_type = xe::load<EventType>(trace_ptr_);
|
||||
switch (event_type) {
|
||||
case EventType::END_OF_STREAM: {
|
||||
eof_= true;
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include <xdb/postmortem_debug_target.h>
|
||||
|
||||
#include <poly/poly.h>
|
||||
#include <xdb/postmortem_cursor.h>
|
||||
#include <xenia/logging.h>
|
||||
|
||||
|
@ -60,8 +59,7 @@ bool PostmortemDebugTarget::LoadTrace(const std::wstring& path,
|
|||
// path lookup.
|
||||
const uint8_t* ptr = trace_base_ + 8;
|
||||
EventType event_type;
|
||||
while ((event_type = poly::load<EventType>(ptr)) !=
|
||||
EventType::END_OF_STREAM) {
|
||||
while ((event_type = xe::load<EventType>(ptr)) != EventType::END_OF_STREAM) {
|
||||
switch (event_type) {
|
||||
case EventType::PROCESS_START: {
|
||||
process_start_event_ = protocol::ProcessStartEvent::Get(ptr);
|
||||
|
@ -80,7 +78,7 @@ bool PostmortemDebugTarget::LoadTrace(const std::wstring& path,
|
|||
} else {
|
||||
// If no path was provided just use what's in the trace.
|
||||
auto trace_content_path =
|
||||
poly::to_wstring(std::string(process_start_event_->launch_path));
|
||||
xe::to_wstring(std::string(process_start_event_->launch_path));
|
||||
initialized_filesystem = InitializeFileSystem(trace_content_path);
|
||||
}
|
||||
if (!initialized_filesystem) {
|
||||
|
@ -101,8 +99,7 @@ bool PostmortemDebugTarget::Prepare(std::atomic<bool>& cancelled) {
|
|||
|
||||
const uint8_t* ptr = trace_base_ + 8;
|
||||
EventType event_type;
|
||||
while ((event_type = poly::load<EventType>(ptr)) !=
|
||||
EventType::END_OF_STREAM) {
|
||||
while ((event_type = xe::load<EventType>(ptr)) != EventType::END_OF_STREAM) {
|
||||
switch (event_type) {
|
||||
case EventType::PROCESS_START: {
|
||||
assert_true(process_start_event_ ==
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "poly/atomic.h"
|
||||
#include "poly/vec128.h"
|
||||
#include "xenia/base/atomic.h"
|
||||
#include "xenia/base/vec128.h"
|
||||
|
||||
namespace xdb {
|
||||
namespace protocol {
|
||||
|
||||
using vec128_t = poly::vec128_t;
|
||||
using vec128_t = xe::vec128_t;
|
||||
|
||||
#pragma pack(push, 4)
|
||||
|
||||
|
@ -57,7 +57,7 @@ struct Event {
|
|||
if (!trace_base) {
|
||||
return nullptr;
|
||||
}
|
||||
uint64_t ptr = poly::atomic_exchange_add(
|
||||
uint64_t ptr = xe::atomic_exchange_add(
|
||||
sizeof(T), reinterpret_cast<uint64_t*>(trace_base));
|
||||
return reinterpret_cast<T*>(ptr);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ struct Registers {
|
|||
uint32_t vscr;
|
||||
uint64_t gpr[32];
|
||||
double fpr[32];
|
||||
poly::vec128_t vr[128];
|
||||
xe::vec128_t vr[128];
|
||||
};
|
||||
|
||||
struct ThreadCreateEvent : public Event<ThreadCreateEvent> {
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
|
||||
#include "xenia/apu/audio_system.h"
|
||||
|
||||
#include "poly/math.h"
|
||||
#include "xenia/apu/audio_driver.h"
|
||||
#include "xenia/emulator.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/cpu/processor.h"
|
||||
#include "xenia/cpu/thread_state.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/emulator.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
// As with normal Microsoft, there are like twelve different ways to access
|
||||
|
@ -59,13 +59,13 @@ AudioSystem::AudioSystem(Emulator* emulator)
|
|||
for (size_t i = 0; i < maximum_client_count_; ++i) {
|
||||
unused_clients_.push(i);
|
||||
}
|
||||
for (size_t i = 0; i < poly::countof(client_wait_handles_); ++i) {
|
||||
for (size_t i = 0; i < xe::countof(client_wait_handles_); ++i) {
|
||||
client_wait_handles_[i] = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
AudioSystem::~AudioSystem() {
|
||||
for (size_t i = 0; i < poly::countof(client_wait_handles_); ++i) {
|
||||
for (size_t i = 0; i < xe::countof(client_wait_handles_); ++i) {
|
||||
CloseHandle(client_wait_handles_[i]);
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ X_STATUS AudioSystem::Setup() {
|
|||
}
|
||||
|
||||
void AudioSystem::ThreadStart() {
|
||||
poly::threading::set_name("Audio Worker");
|
||||
xe::threading::set_name("Audio Worker");
|
||||
xe::Profiler::ThreadEnter("Audio Worker");
|
||||
|
||||
// Initialize driver and ringbuffer.
|
||||
|
@ -118,7 +118,7 @@ void AudioSystem::ThreadStart() {
|
|||
// Main run loop.
|
||||
while (running_) {
|
||||
auto result =
|
||||
WaitForMultipleObjectsEx(DWORD(poly::countof(client_wait_handles_)),
|
||||
WaitForMultipleObjectsEx(DWORD(xe::countof(client_wait_handles_)),
|
||||
client_wait_handles_, FALSE, INFINITE, FALSE);
|
||||
if (result == WAIT_FAILED ||
|
||||
result == WAIT_OBJECT_0 + maximum_client_count_) {
|
||||
|
@ -137,7 +137,7 @@ void AudioSystem::ThreadStart() {
|
|||
if (client_callback) {
|
||||
uint64_t args[] = {client_callback_arg};
|
||||
processor->Execute(thread_state_, client_callback, args,
|
||||
poly::countof(args));
|
||||
xe::countof(args));
|
||||
}
|
||||
pumped++;
|
||||
index++;
|
||||
|
@ -219,7 +219,7 @@ X_STATUS AudioSystem::RegisterClient(uint32_t callback, uint32_t callback_arg,
|
|||
unused_clients_.pop();
|
||||
|
||||
uint32_t ptr = memory()->SystemHeapAlloc(0x4);
|
||||
poly::store_and_swap<uint32_t>(memory()->TranslateVirtual(ptr), callback_arg);
|
||||
xe::store_and_swap<uint32_t>(memory()->TranslateVirtual(ptr), callback_arg);
|
||||
|
||||
clients_[index] = {driver, callback, callback_arg, ptr};
|
||||
|
||||
|
@ -276,13 +276,13 @@ uint64_t AudioSystem::ReadRegister(uint64_t addr) {
|
|||
value = registers_.current_context;
|
||||
}
|
||||
|
||||
value = poly::byte_swap(value);
|
||||
value = xe::byte_swap(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
void AudioSystem::WriteRegister(uint64_t addr, uint64_t value) {
|
||||
uint32_t r = addr & 0xFFFF;
|
||||
value = poly::byte_swap(uint32_t(value));
|
||||
value = xe::byte_swap(uint32_t(value));
|
||||
XELOGAPU("WriteRegister(%.4X, %.8X)", r, value);
|
||||
// 1804h is written to with 0x02000000 and 0x03000000 around a lock operation
|
||||
|
||||
|
@ -303,15 +303,15 @@ void AudioSystem::WriteRegister(uint64_t addr, uint64_t value) {
|
|||
uint32_t guest_ptr =
|
||||
registers_.xma_context_array_ptr + context_id * kXmaContextSize;
|
||||
auto context_ptr = memory()->TranslateVirtual(guest_ptr);
|
||||
uint32_t dword0 = poly::load_and_swap<uint32_t>(context_ptr + 0);
|
||||
uint32_t dword0 = xe::load_and_swap<uint32_t>(context_ptr + 0);
|
||||
bool has_valid_input = (dword0 & 0x00300000) != 0;
|
||||
if (has_valid_input) {
|
||||
dword0 = dword0 & ~0x00300000;
|
||||
poly::store_and_swap<uint32_t>(context_ptr + 0, dword0);
|
||||
xe::store_and_swap<uint32_t>(context_ptr + 0, dword0);
|
||||
// Set output buffer to invalid.
|
||||
uint32_t dword1 = poly::load_and_swap<uint32_t>(context_ptr + 4);
|
||||
uint32_t dword1 = xe::load_and_swap<uint32_t>(context_ptr + 4);
|
||||
dword1 = dword1 & ~0x80000000;
|
||||
poly::store_and_swap<uint32_t>(context_ptr + 4, dword1);
|
||||
xe::store_and_swap<uint32_t>(context_ptr + 4, dword1);
|
||||
}
|
||||
}
|
||||
value >>= 1;
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include "xenia/apu/xaudio2/xaudio2_audio_driver.h"
|
||||
|
||||
#include "xenia/apu/apu-private.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/emulator.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace apu {
|
||||
|
@ -131,7 +131,7 @@ void XAudio2AudioDriver::SubmitFrame(uint32_t frame_ptr) {
|
|||
for (int index = 0, o = 0; index < channel_samples_; ++index) {
|
||||
for (int channel = 0, table = 0; channel < interleave_channels;
|
||||
++channel, table += channel_samples_) {
|
||||
output_frame[o++] = poly::byte_swap(input_frame[table + index]);
|
||||
output_frame[o++] = xe::byte_swap(input_frame[table + index]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
poly is a lightweight cross-platform/compiler compatibility library.
|
||||
A lightweight cross-platform/compiler compatibility library.
|
||||
|
||||
This library presupposes C++11/14 support. As more compilers get C++14 it will
|
||||
assume that.
|
||||
|
@ -7,9 +7,9 @@ Other parts of the project use this to avoid creating spaghetti linkage. Code
|
|||
specific to the emulator should be kept out, as not all of the projects that
|
||||
depend on this need it.
|
||||
|
||||
Where possible, C++11/14 STL should be used instead of adding any code in here, and
|
||||
the code should be kept as small as possible (by reusing STL/etc). Third party
|
||||
dependencies should be kept to a minimum.
|
||||
Where possible, C++11/14 STL should be used instead of adding any code in here,
|
||||
and the code should be kept as small as possible (by reusing STL/etc). Third
|
||||
party dependencies should be kept to a minimum.
|
||||
|
||||
Target compilers:
|
||||
* MSVC++ 2013+
|
|
@ -7,13 +7,13 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/arena.h"
|
||||
#include "xenia/base/arena.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xenia/base/assert.h"
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
Arena::Arena(size_t chunk_size)
|
||||
: chunk_size_(chunk_size), head_chunk_(nullptr), active_chunk_(nullptr) {}
|
||||
|
@ -100,4 +100,4 @@ Arena::Chunk::~Chunk() {
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,13 +7,13 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_ARENA_H_
|
||||
#define POLY_ARENA_H_
|
||||
#ifndef XENIA_BASE_ARENA_H_
|
||||
#define XENIA_BASE_ARENA_H_
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
class Arena {
|
||||
public:
|
||||
|
@ -50,6 +50,6 @@ class Arena {
|
|||
Chunk* active_chunk_;
|
||||
};
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_ARENA_H_
|
||||
#endif // XENIA_BASE_ARENA_H_
|
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2014 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_BASE_ASSERT_H_
|
||||
#define XENIA_BASE_ASSERT_H_
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
namespace xe {
|
||||
|
||||
#define static_assert_size(type, size) \
|
||||
static_assert(sizeof(type) == size, \
|
||||
"bad definition for " #type ": must be " #size " bytes")
|
||||
|
||||
// We rely on assert being compiled out in NDEBUG.
|
||||
#define xenia_assert assert
|
||||
|
||||
#define __XENIA_EXPAND(x) x
|
||||
#define __XENIA_ARGC(...) \
|
||||
__XENIA_EXPAND(__XENIA_ARGC_IMPL(__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, \
|
||||
7, 6, 5, 4, 3, 2, 1, 0))
|
||||
#define __XENIA_ARGC_IMPL(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, \
|
||||
x13, x14, x15, N, ...) \
|
||||
N
|
||||
#define __XENIA_MACRO_DISPATCH(func, ...) \
|
||||
__XENIA_MACRO_DISPATCH_(func, __XENIA_ARGC(__VA_ARGS__))
|
||||
#define __XENIA_MACRO_DISPATCH_(func, nargs) \
|
||||
__XENIA_MACRO_DISPATCH__(func, nargs)
|
||||
#define __XENIA_MACRO_DISPATCH__(func, nargs) func##nargs
|
||||
|
||||
#define assert_always(...) xenia_assert(false)
|
||||
|
||||
#define assert_true(...) \
|
||||
__XENIA_MACRO_DISPATCH(assert_true, __VA_ARGS__)(__VA_ARGS__)
|
||||
#define assert_true1(expr) xenia_assert(expr)
|
||||
#define assert_true2(expr, message) xenia_assert((expr) || !message)
|
||||
|
||||
#define assert_false(...) \
|
||||
__XENIA_MACRO_DISPATCH(assert_false, __VA_ARGS__)(__VA_ARGS__)
|
||||
#define assert_false1(expr) xenia_assert(!(expr))
|
||||
#define assert_false2(expr, message) xenia_assert(!(expr) || !message)
|
||||
|
||||
#define assert_zero(...) \
|
||||
__XENIA_MACRO_DISPATCH(assert_zero, __VA_ARGS__)(__VA_ARGS__)
|
||||
#define assert_zero1(expr) xenia_assert((expr) == 0)
|
||||
#define assert_zero2(expr, message) xenia_assert((expr) == 0 || !message)
|
||||
|
||||
#define assert_not_zero(...) \
|
||||
__XENIA_MACRO_DISPATCH(assert_not_zero, __VA_ARGS__)(__VA_ARGS__)
|
||||
#define assert_not_zero1(expr) xenia_assert((expr) != 0)
|
||||
#define assert_not_zero2(expr, message) xenia_assert((expr) != 0 || !message)
|
||||
|
||||
#define assert_null(...) \
|
||||
__XENIA_MACRO_DISPATCH(assert_null, __VA_ARGS__)(__VA_ARGS__)
|
||||
#define assert_null1(expr) xenia_assert((expr) == nullptr)
|
||||
#define assert_null2(expr, message) xenia_assert((expr) == nullptr || !message)
|
||||
|
||||
#define assert_not_null(...) \
|
||||
__XENIA_MACRO_DISPATCH(assert_not_null, __VA_ARGS__)(__VA_ARGS__)
|
||||
#define assert_not_null1(expr) xenia_assert((expr) != nullptr)
|
||||
#define assert_not_null2(expr, message) \
|
||||
xenia_assert((expr) != nullptr || !message)
|
||||
|
||||
#define assert_unhandled_case(variable) \
|
||||
assert_always("unhandled switch(" #variable ") case")
|
||||
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_BASE_ASSERT_H_
|
|
@ -7,18 +7,18 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_ATOMIC_H_
|
||||
#define POLY_ATOMIC_H_
|
||||
#ifndef XENIA_BASE_ATOMIC_H_
|
||||
#define XENIA_BASE_ATOMIC_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "poly/platform.h"
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
#if XE_PLATFORM_MAC
|
||||
#include <libkern/OSAtomic.h>
|
||||
#endif // XE_PLATFORM_MAC
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
// These functions are modeled off of the Apple OSAtomic routines
|
||||
// http://developer.apple.com/library/mac/#documentation/DriversKernelHardware/Reference/libkern_ref/OSAtomic_h/
|
||||
|
@ -179,6 +179,6 @@ inline bool atomic_cas(uint64_t old_value, uint64_t new_value,
|
|||
reinterpret_cast<volatile int64_t*>(value));
|
||||
}
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_ATOMIC_H_
|
||||
#endif // XENIA_BASE_ATOMIC_H_
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2014 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_BASE_BYTE_ORDER_H_
|
||||
#define XENIA_BASE_BYTE_ORDER_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
#if XE_PLATFORM_MAC
|
||||
#include <libkern/OSByteOrder.h>
|
||||
#endif // XE_PLATFORM_MAC
|
||||
|
||||
namespace xe {
|
||||
|
||||
#if XE_COMPILER_MSVC
|
||||
#define XENIA_BASE_BYTE_SWAP_16 _byteswap_ushort
|
||||
#define XENIA_BASE_BYTE_SWAP_32 _byteswap_ulong
|
||||
#define XENIA_BASE_BYTE_SWAP_64 _byteswap_uint64
|
||||
#elif XE_PLATFORM_MAC
|
||||
#define XENIA_BASE_BYTE_SWAP_16 OSSwapInt16
|
||||
#define XENIA_BASE_BYTE_SWAP_32 OSSwapInt32
|
||||
#define XENIA_BASE_BYTE_SWAP_64 OSSwapInt64
|
||||
#else
|
||||
#define XENIA_BASE_BYTE_SWAP_16 __bswap_16
|
||||
#define XENIA_BASE_BYTE_SWAP_32 __bswap_32
|
||||
#define XENIA_BASE_BYTE_SWAP_64 __bswap_64
|
||||
#endif // XE_COMPILER_MSVC
|
||||
|
||||
inline int8_t byte_swap(int8_t value) { return value; }
|
||||
inline uint8_t byte_swap(uint8_t value) { return value; }
|
||||
inline int16_t byte_swap(int16_t value) {
|
||||
return static_cast<int16_t>(
|
||||
XENIA_BASE_BYTE_SWAP_16(static_cast<int16_t>(value)));
|
||||
}
|
||||
inline uint16_t byte_swap(uint16_t value) {
|
||||
return XENIA_BASE_BYTE_SWAP_16(value);
|
||||
}
|
||||
inline uint16_t byte_swap(wchar_t value) {
|
||||
return static_cast<wchar_t>(XENIA_BASE_BYTE_SWAP_16(value));
|
||||
}
|
||||
inline int32_t byte_swap(int32_t value) {
|
||||
return static_cast<int32_t>(
|
||||
XENIA_BASE_BYTE_SWAP_32(static_cast<int32_t>(value)));
|
||||
}
|
||||
inline uint32_t byte_swap(uint32_t value) {
|
||||
return XENIA_BASE_BYTE_SWAP_32(value);
|
||||
}
|
||||
inline int64_t byte_swap(int64_t value) {
|
||||
return static_cast<int64_t>(
|
||||
XENIA_BASE_BYTE_SWAP_64(static_cast<int64_t>(value)));
|
||||
}
|
||||
inline uint64_t byte_swap(uint64_t value) {
|
||||
return XENIA_BASE_BYTE_SWAP_64(value);
|
||||
}
|
||||
inline float byte_swap(float value) {
|
||||
uint32_t temp = byte_swap(*reinterpret_cast<uint32_t *>(&value));
|
||||
return *reinterpret_cast<float *>(&temp);
|
||||
}
|
||||
inline double byte_swap(double value) {
|
||||
uint64_t temp = byte_swap(*reinterpret_cast<uint64_t *>(&value));
|
||||
return *reinterpret_cast<double *>(&temp);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct be {
|
||||
be() = default;
|
||||
be(const T &src) : value(xe::byte_swap(src)) {}
|
||||
be(const be &other) { value = other.value; }
|
||||
operator T() const { return xe::byte_swap(value); }
|
||||
T value;
|
||||
};
|
||||
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_BASE_BYTE_ORDER_H_
|
|
@ -7,12 +7,12 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_CXX_COMPAT_H_
|
||||
#define POLY_CXX_COMPAT_H_
|
||||
#ifndef XENIA_BASE_CXX_COMPAT_H_
|
||||
#define XENIA_BASE_CXX_COMPAT_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "poly/platform.h"
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
// C++11 thread local storage.
|
||||
// http://en.cppreference.com/w/cpp/language/storage_duration
|
||||
|
@ -46,6 +46,6 @@ unique_ptr<T> make_unique(Args&&... args) {
|
|||
#endif // clang < 3.4
|
||||
#endif // !XE_COMPILER_MSVC
|
||||
|
||||
namespace poly {} // namespace poly
|
||||
namespace xe {} // namespace xe
|
||||
|
||||
#endif // POLY_CXX_COMPAT_H_
|
||||
#endif // XENIA_BASE_CXX_COMPAT_H_
|
|
@ -7,13 +7,12 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_DEBUGGING_H_
|
||||
#define POLY_DEBUGGING_H_
|
||||
#ifndef XENIA_BASE_DEBUGGING_H_
|
||||
#define XENIA_BASE_DEBUGGING_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
namespace debugging {
|
||||
|
||||
// Returns true if a debugger is attached to this process.
|
||||
|
@ -27,6 +26,6 @@ bool IsDebuggerAttached();
|
|||
void Break();
|
||||
|
||||
} // namespace debugging
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_DEBUGGING_H_
|
||||
#endif // XENIA_BASE_DEBUGGING_H_
|
|
@ -7,12 +7,12 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <poly/debugging.h>
|
||||
#include "xenia/base/debugging.h"
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
namespace debugging {
|
||||
|
||||
bool IsDebuggerAttached() {
|
||||
|
@ -32,4 +32,4 @@ void Break() {
|
|||
}
|
||||
|
||||
} // namespace debugging
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,20 +7,16 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/debugging.h"
|
||||
#include "xenia/base/debugging.h"
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
namespace debugging {
|
||||
|
||||
bool IsDebuggerAttached() {
|
||||
return IsDebuggerPresent() ? true : false;
|
||||
}
|
||||
bool IsDebuggerAttached() { return IsDebuggerPresent() ? true : false; }
|
||||
|
||||
void Break() {
|
||||
__debugbreak();
|
||||
}
|
||||
void Break() { __debugbreak(); }
|
||||
|
||||
} // namespace debugging
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,14 +7,14 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_DELEGATE_H_
|
||||
#define POLY_DELEGATE_H_
|
||||
#ifndef XENIA_BASE_DELEGATE_H_
|
||||
#define XENIA_BASE_DELEGATE_H_
|
||||
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
// TODO(benvanik): go lockfree, and don't hold the lock while emitting.
|
||||
|
||||
|
@ -45,6 +45,6 @@ class Delegate {
|
|||
std::vector<Listener> listeners_;
|
||||
};
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_DELEGATE_H_
|
||||
#endif // XENIA_BASE_DELEGATE_H_
|
|
@ -7,18 +7,18 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/fs.h"
|
||||
#include "xenia/base/fs.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
namespace fs {
|
||||
|
||||
std::string CanonicalizePath(const std::string& original_path) {
|
||||
char path_sep('\\');
|
||||
std::string path(poly::fix_path_separators(original_path, path_sep));
|
||||
std::string path(xe::fix_path_separators(original_path, path_sep));
|
||||
|
||||
std::vector<std::string::size_type> path_breaks;
|
||||
|
||||
|
@ -179,4 +179,4 @@ bool WildcardEngine::Match(const std::string& str) const {
|
|||
}
|
||||
|
||||
} // namespace fs
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,17 +7,17 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_FS_H_
|
||||
#define POLY_FS_H_
|
||||
#ifndef XENIA_BASE_FS_H_
|
||||
#define XENIA_BASE_FS_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "poly/string.h"
|
||||
#include "xenia/base/string.h"
|
||||
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
namespace fs {
|
||||
|
||||
bool PathExists(const std::wstring& path);
|
||||
|
@ -39,12 +39,9 @@ std::vector<FileInfo> ListFiles(const std::wstring& path);
|
|||
|
||||
std::string CanonicalizePath(const std::string& original_path);
|
||||
|
||||
class WildcardFlags
|
||||
{
|
||||
class WildcardFlags {
|
||||
public:
|
||||
bool
|
||||
FromStart: 1,
|
||||
ToEnd : 1;
|
||||
bool FromStart : 1, ToEnd : 1;
|
||||
|
||||
WildcardFlags();
|
||||
WildcardFlags(bool start, bool end);
|
||||
|
@ -53,30 +50,30 @@ public:
|
|||
static WildcardFlags LAST;
|
||||
};
|
||||
|
||||
class WildcardRule
|
||||
{
|
||||
class WildcardRule {
|
||||
public:
|
||||
WildcardRule(const std::string& str_match, const WildcardFlags& flags);
|
||||
bool Check(const std::string& str_lower, std::string::size_type& offset) const;
|
||||
bool Check(const std::string& str_lower,
|
||||
std::string::size_type& offset) const;
|
||||
|
||||
private:
|
||||
std::string match;
|
||||
WildcardFlags rules;
|
||||
};
|
||||
|
||||
class WildcardEngine
|
||||
{
|
||||
class WildcardEngine {
|
||||
public:
|
||||
void SetRule(const std::string& pattern);
|
||||
|
||||
// Always ignoring case
|
||||
bool Match(const std::string& str) const;
|
||||
|
||||
private:
|
||||
std::vector<WildcardRule> rules;
|
||||
void PreparePattern(const std::string& pattern);
|
||||
};
|
||||
|
||||
} // namespace fs
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_FS_H_
|
||||
#endif // XENIA_BASE_FS_H_
|
|
@ -7,15 +7,15 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/fs.h"
|
||||
#include "xenia/base/fs.h"
|
||||
|
||||
#include <shellapi.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "poly/platform.h"
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
namespace fs {
|
||||
|
||||
bool PathExists(const std::wstring& path) {
|
||||
|
@ -74,4 +74,4 @@ std::vector<FileInfo> ListFiles(const std::wstring& path) {
|
|||
}
|
||||
|
||||
} // namespace fs
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,16 +7,16 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/base/logging.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "poly/cxx_compat.h"
|
||||
#include "poly/main.h"
|
||||
#include "poly/math.h"
|
||||
#include "poly/threading.h"
|
||||
#include "xenia/base/cxx_compat.h"
|
||||
#include "xenia/base/main.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/threading.h"
|
||||
|
||||
DEFINE_bool(fast_stdout, false,
|
||||
"Don't lock around stdout/stderr. May introduce weirdness.");
|
||||
|
@ -34,7 +34,7 @@ void format_log_line(char* buffer, size_t buffer_count, const char* file_path,
|
|||
char* buffer_ptr;
|
||||
if (FLAGS_log_filenames) {
|
||||
// Strip out just the filename from the path.
|
||||
const char* filename = strrchr(file_path, poly::path_separator);
|
||||
const char* filename = strrchr(file_path, xe::path_separator);
|
||||
if (filename) {
|
||||
// Slash - skip over it.
|
||||
filename++;
|
||||
|
@ -46,15 +46,15 @@ void format_log_line(char* buffer, size_t buffer_count, const char* file_path,
|
|||
// Format string - add a trailing newline if required.
|
||||
const char* outfmt = "%c> %.2X %s:%d: ";
|
||||
buffer_ptr = buffer + snprintf(buffer, buffer_count - 1, outfmt, level_char,
|
||||
poly::threading::current_thread_id(),
|
||||
filename, line_number);
|
||||
xe::threading::current_thread_id(), filename,
|
||||
line_number);
|
||||
} else {
|
||||
buffer_ptr = buffer;
|
||||
*(buffer_ptr++) = level_char;
|
||||
*(buffer_ptr++) = '>';
|
||||
*(buffer_ptr++) = ' ';
|
||||
buffer_ptr +=
|
||||
sprintf(buffer_ptr, "%.4X", poly::threading::current_thread_id());
|
||||
sprintf(buffer_ptr, "%.4X", xe::threading::current_thread_id());
|
||||
*(buffer_ptr++) = ' ';
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ void log_line(const char* file_path, const uint32_t line_number,
|
|||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
format_log_line(log_buffer, poly::countof(log_buffer), file_path, line_number,
|
||||
format_log_line(log_buffer, xe::countof(log_buffer), file_path, line_number,
|
||||
level_char, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
|
@ -103,8 +103,8 @@ void handle_fatal(const char* file_path, const uint32_t line_number,
|
|||
char buffer[2048];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
format_log_line(buffer, poly::countof(buffer), file_path, line_number, 'X',
|
||||
fmt, args);
|
||||
format_log_line(buffer, xe::countof(buffer), file_path, line_number, 'X', fmt,
|
||||
args);
|
||||
va_end(args);
|
||||
|
||||
if (!FLAGS_fast_stdout) {
|
||||
|
@ -121,7 +121,7 @@ void handle_fatal(const char* file_path, const uint32_t line_number,
|
|||
}
|
||||
|
||||
#if XE_PLATFORM_WIN32
|
||||
if (!poly::has_console_attached()) {
|
||||
if (!xe::has_console_attached()) {
|
||||
MessageBoxA(NULL, buffer, "Xenia Error",
|
||||
MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "poly/string.h"
|
||||
#include "xenia/base/string.h"
|
||||
|
||||
namespace xe {
|
||||
|
|
@ -7,15 +7,15 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_MAIN_H_
|
||||
#define POLY_MAIN_H_
|
||||
#ifndef XENIA_BASE_MAIN_H_
|
||||
#define XENIA_BASE_MAIN_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "poly/platform.h"
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
// Returns true if there is a user-visible console attached to receive stdout.
|
||||
bool has_console_attached();
|
||||
|
@ -30,10 +30,10 @@ struct EntryInfo {
|
|||
EntryInfo GetEntryInfo();
|
||||
|
||||
#define DEFINE_ENTRY_POINT(name, usage, entry_point) \
|
||||
poly::EntryInfo poly::GetEntryInfo() { \
|
||||
return poly::EntryInfo({name, usage, entry_point}); \
|
||||
xe::EntryInfo xe::GetEntryInfo() { \
|
||||
return xe::EntryInfo({name, usage, entry_point}); \
|
||||
}
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_MAIN_H_
|
||||
#endif // XENIA_BASE_MAIN_H_
|
|
@ -7,28 +7,29 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <poly/main.h>
|
||||
#include "xenia/base/main.h"
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
#include <poly/string.h>
|
||||
|
||||
namespace poly {
|
||||
#include "xenia/base/string.h"
|
||||
|
||||
namespace xe {
|
||||
|
||||
bool has_console_attached() { return true; }
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
extern "C" int main(int argc, char** argv) {
|
||||
auto entry_info = poly::GetEntryInfo();
|
||||
auto entry_info = xe::GetEntryInfo();
|
||||
|
||||
google::SetUsageMessage(std::string("usage: ") +
|
||||
poly::to_string(entry_info.usage));
|
||||
xe::to_string(entry_info.usage));
|
||||
google::SetVersionString("1.0");
|
||||
google::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
std::vector<std::wstring> args;
|
||||
for (int n = 0; n < argc; n++) {
|
||||
args.push_back(poly::to_wstring(argv[n]));
|
||||
args.push_back(xe::to_wstring(argv[n]));
|
||||
}
|
||||
|
||||
// Call app-provided entry point.
|
|
@ -7,16 +7,16 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/main.h"
|
||||
#include "xenia/base/main.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
#include "poly/string.h"
|
||||
#include "xenia/base/string.h"
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
bool has_console_attached_ = true;
|
||||
|
||||
|
@ -46,14 +46,14 @@ void AttachConsole() {
|
|||
setvbuf(stderr, nullptr, _IONBF, 0);
|
||||
}
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
// Used in console mode apps; automatically picked based on subsystem.
|
||||
int wmain(int argc, wchar_t* argv[]) {
|
||||
auto entry_info = poly::GetEntryInfo();
|
||||
auto entry_info = xe::GetEntryInfo();
|
||||
|
||||
google::SetUsageMessage(std::string("usage: ") +
|
||||
poly::to_string(entry_info.usage));
|
||||
xe::to_string(entry_info.usage));
|
||||
google::SetVersionString("1.0");
|
||||
|
||||
// Convert all args to narrow, as gflags doesn't support wchar.
|
||||
|
@ -71,7 +71,7 @@ int wmain(int argc, wchar_t* argv[]) {
|
|||
// Widen all remaining flags and convert to usable strings.
|
||||
std::vector<std::wstring> args;
|
||||
for (int n = 0; n < argc; n++) {
|
||||
args.push_back(poly::to_wstring(argva[n]));
|
||||
args.push_back(xe::to_wstring(argva[n]));
|
||||
}
|
||||
|
||||
// Setup COM on the main thread.
|
||||
|
@ -89,9 +89,9 @@ int wmain(int argc, wchar_t* argv[]) {
|
|||
int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR command_line, int) {
|
||||
// Attach a console so we can write output to stdout. If the user hasn't
|
||||
// redirected output themselves it'll pop up a window.
|
||||
poly::AttachConsole();
|
||||
xe::AttachConsole();
|
||||
|
||||
auto entry_info = poly::GetEntryInfo();
|
||||
auto entry_info = xe::GetEntryInfo();
|
||||
|
||||
// Convert to an argv-like format so we can share code/use gflags.
|
||||
std::wstring buffer = entry_info.name + L" " + command_line;
|
||||
|
@ -109,11 +109,19 @@ int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR command_line, int) {
|
|||
}
|
||||
|
||||
#if defined _M_IX86
|
||||
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#pragma comment( \
|
||||
linker, \
|
||||
"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#elif defined _M_IA64
|
||||
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#pragma comment( \
|
||||
linker, \
|
||||
"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#elif defined _M_X64
|
||||
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#pragma comment( \
|
||||
linker, \
|
||||
"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#else
|
||||
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#pragma comment( \
|
||||
linker, \
|
||||
"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#endif
|
|
@ -7,13 +7,13 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_MAPPED_MEMORY_H_
|
||||
#define POLY_MAPPED_MEMORY_H_
|
||||
#ifndef XENIA_BASE_MAPPED_MEMORY_H_
|
||||
#define XENIA_BASE_MAPPED_MEMORY_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
class MappedMemory {
|
||||
public:
|
||||
|
@ -41,6 +41,6 @@ class MappedMemory {
|
|||
size_t size_;
|
||||
};
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_MAPPED_MEMORY_H_
|
||||
#endif // XENIA_BASE_MAPPED_MEMORY_H_
|
|
@ -7,14 +7,14 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <poly/mapped_memory.h>
|
||||
#include "xenia/base/mapped_memory.h"
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include <poly/string.h>
|
||||
#include "xenia/base/string.h"
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
class PosixMappedMemory : public MappedMemory {
|
||||
public:
|
||||
|
@ -51,7 +51,7 @@ std::unique_ptr<MappedMemory> MappedMemory::Open(const std::wstring& path,
|
|||
|
||||
auto mm = std::make_unique<PosixMappedMemory>(path, mode);
|
||||
|
||||
mm->file_handle = fopen(poly::to_string(path).c_str(), mode_str);
|
||||
mm->file_handle = fopen(xe::to_string(path).c_str(), mode_str);
|
||||
if (!mm->file_handle) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -74,4 +74,4 @@ std::unique_ptr<MappedMemory> MappedMemory::Open(const std::wstring& path,
|
|||
return std::move(mm);
|
||||
}
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,11 +7,11 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/mapped_memory.h"
|
||||
#include "xenia/base/mapped_memory.h"
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
class Win32MappedMemory : public MappedMemory {
|
||||
public:
|
||||
|
@ -102,4 +102,4 @@ std::unique_ptr<MappedMemory> MappedMemory::Open(const std::wstring& path,
|
|||
return std::move(mm);
|
||||
}
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,9 +7,9 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/math.h"
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
// TODO(benvanik): replace with alternate implementation.
|
||||
// XMConvertFloatToHalf
|
||||
|
@ -66,4 +66,4 @@ float half_to_float(uint16_t value) {
|
|||
return *(float *)&Result;
|
||||
}
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,8 +7,8 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_MATH_H_
|
||||
#define POLY_MATH_H_
|
||||
#ifndef XENIA_BASE_MATH_H_
|
||||
#define XENIA_BASE_MATH_H_
|
||||
|
||||
#include <xmmintrin.h>
|
||||
|
||||
|
@ -17,9 +17,9 @@
|
|||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
#include "poly/platform.h"
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
template <typename T, size_t N>
|
||||
size_t countof(T (&arr)[N]) {
|
||||
|
@ -220,6 +220,6 @@ int64_t m128_i64(const __m128& v) {
|
|||
uint16_t float_to_half(float value);
|
||||
float half_to_float(uint16_t value);
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_MATH_H_
|
||||
#endif // XENIA_BASE_MATH_H_
|
|
@ -7,16 +7,16 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_MEMORY_H_
|
||||
#define POLY_MEMORY_H_
|
||||
#ifndef XENIA_BASE_MEMORY_H_
|
||||
#define XENIA_BASE_MEMORY_H_
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/byte_order.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/byte_order.h"
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
inline size_t hash_combine(size_t seed) { return seed; }
|
||||
|
||||
|
@ -73,7 +73,7 @@ void copy_and_swap(T* dest, const T* src, size_t count) {
|
|||
copy_and_swap_64_unaligned(pd, ps, count);
|
||||
}
|
||||
} else {
|
||||
assert_always("Invalid poly::copy_and_swap size");
|
||||
assert_always("Invalid xe::copy_and_swap size");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ inline T load(const void* mem) {
|
|||
} else if (sizeof(T) == 8) {
|
||||
return static_cast<T>(load<uint64_t>(mem));
|
||||
} else {
|
||||
assert_always("Invalid poly::load size");
|
||||
assert_always("Invalid xe::load size");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ inline std::string load_and_swap<std::string>(const void* mem) {
|
|||
std::string value;
|
||||
for (int i = 0;; ++i) {
|
||||
auto c =
|
||||
poly::load_and_swap<uint8_t>(reinterpret_cast<const uint8_t*>(mem) + i);
|
||||
xe::load_and_swap<uint8_t>(reinterpret_cast<const uint8_t*>(mem) + i);
|
||||
if (!c) {
|
||||
break;
|
||||
}
|
||||
|
@ -193,8 +193,8 @@ template <>
|
|||
inline std::wstring load_and_swap<std::wstring>(const void* mem) {
|
||||
std::wstring value;
|
||||
for (int i = 0;; ++i) {
|
||||
auto c = poly::load_and_swap<uint16_t>(
|
||||
reinterpret_cast<const uint16_t*>(mem) + i);
|
||||
auto c =
|
||||
xe::load_and_swap<uint16_t>(reinterpret_cast<const uint16_t*>(mem) + i);
|
||||
if (!c) {
|
||||
break;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ inline void store(const void* mem, T value) {
|
|||
} else if (sizeof(T) == 8) {
|
||||
store<uint8_t>(mem, static_cast<uint64_t>(value));
|
||||
} else {
|
||||
assert_always("Invalid poly::store size");
|
||||
assert_always("Invalid xe::store size");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,27 +305,17 @@ inline void store_and_swap<double>(void* mem, double value) {
|
|||
template <>
|
||||
inline void store_and_swap<std::string>(void* mem, std::string value) {
|
||||
for (auto i = 0; i < value.size(); ++i) {
|
||||
poly::store_and_swap<uint8_t>(reinterpret_cast<uint8_t*>(mem) + i,
|
||||
value[i]);
|
||||
xe::store_and_swap<uint8_t>(reinterpret_cast<uint8_t*>(mem) + i, value[i]);
|
||||
}
|
||||
}
|
||||
template <>
|
||||
inline void store_and_swap<std::wstring>(void* mem, std::wstring value) {
|
||||
for (auto i = 0; i < value.size(); ++i) {
|
||||
poly::store_and_swap<uint16_t>(reinterpret_cast<uint16_t*>(mem) + i,
|
||||
xe::store_and_swap<uint16_t>(reinterpret_cast<uint16_t*>(mem) + i,
|
||||
value[i]);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct be {
|
||||
be() = default;
|
||||
be(const T& src) : value(poly::byte_swap(src)) {}
|
||||
be(const be& other) { value = other.value; }
|
||||
operator T() const { return poly::byte_swap(value); }
|
||||
T value;
|
||||
};
|
||||
} // namespace xe
|
||||
|
||||
} // namespace poly
|
||||
|
||||
#endif // POLY_MEMORY_H_
|
||||
#endif // XENIA_BASE_MEMORY_H_
|
|
@ -7,7 +7,7 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/memory.h"
|
||||
#include "xenia/base/memory.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
|||
#include <unistd.h>
|
||||
#endif // !XE_PLATFORM_WIN32
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
size_t page_size() {
|
||||
static size_t value = 0;
|
||||
|
@ -72,4 +72,4 @@ void copy_and_swap_64_unaligned(uint64_t* dest, const uint64_t* src,
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,8 +7,8 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_PLATFORM_H_
|
||||
#define POLY_PLATFORM_H_
|
||||
#ifndef XENIA_BASE_PLATFORM_H_
|
||||
#define XENIA_BASE_PLATFORM_H_
|
||||
|
||||
// NOTE: ordering matters here as sometimes multiple flags are defined on
|
||||
// certain platforms.
|
||||
|
@ -61,7 +61,7 @@
|
|||
#include <x86intrin.h>
|
||||
#endif // XE_COMPILER_MSVC
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
#if XE_PLATFORM_WIN32
|
||||
const char path_separator = '\\';
|
||||
|
@ -71,6 +71,6 @@ const char path_separator = '/';
|
|||
const size_t max_path = 1024; // PATH_MAX
|
||||
#endif // XE_PLATFORM_WIN32
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_PLATFORM_H_
|
||||
#endif // XENIA_BASE_PLATFORM_H_
|
|
@ -7,12 +7,12 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_RESET_SCOPE_H_
|
||||
#define POLY_RESET_SCOPE_H_
|
||||
#ifndef XENIA_BASE_RESET_SCOPE_H_
|
||||
#define XENIA_BASE_RESET_SCOPE_H_
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
template <typename T>
|
||||
class ResetScope {
|
||||
|
@ -38,6 +38,6 @@ inline ResetScope<T> make_reset_scope(const std::unique_ptr<T>& value) {
|
|||
return ResetScope<T>(value.get());
|
||||
}
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_RESET_SCOPE_H_
|
||||
#endif // XENIA_BASE_RESET_SCOPE_H_
|
|
@ -11,11 +11,13 @@
|
|||
'cxx_compat.h',
|
||||
'fs.h',
|
||||
'fs.cc',
|
||||
'logging.cc',
|
||||
'logging.h',
|
||||
'main.h',
|
||||
'mapped_memory.h',
|
||||
'math.cc',
|
||||
'math.h',
|
||||
'memory.cc',
|
||||
'memory_generic.cc',
|
||||
'memory.h',
|
||||
'platform.h',
|
||||
'reset_scope.h',
|
|
@ -7,12 +7,12 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/string.h"
|
||||
#include "xenia/base/string.h"
|
||||
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
std::string to_string(const std::wstring& source) {
|
||||
static std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||
|
@ -42,13 +42,13 @@ std::string::size_type find_first_of_case(const std::string& target,
|
|||
|
||||
std::wstring to_absolute_path(const std::wstring& path) {
|
||||
#if XE_PLATFORM_WIN32
|
||||
wchar_t buffer[poly::max_path];
|
||||
wchar_t buffer[xe::max_path];
|
||||
_wfullpath(buffer, path.c_str(), sizeof(buffer) / sizeof(wchar_t));
|
||||
return buffer;
|
||||
#else
|
||||
char buffer[poly::max_path];
|
||||
realpath(poly::to_string(path).c_str(), buffer);
|
||||
return poly::to_wstring(buffer);
|
||||
char buffer[xe::max_path];
|
||||
realpath(xe::to_string(path).c_str(), buffer);
|
||||
return xe::to_wstring(buffer);
|
||||
#endif // XE_PLATFORM_WIN32
|
||||
}
|
||||
|
||||
|
@ -166,4 +166,4 @@ std::wstring find_name_from_path(const std::wstring& path) {
|
|||
return name;
|
||||
}
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,16 +7,16 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_STRING_H_
|
||||
#define POLY_STRING_H_
|
||||
#ifndef XENIA_BASE_STRING_H_
|
||||
#define XENIA_BASE_STRING_H_
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "poly/platform.h"
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
std::string to_string(const std::wstring& source);
|
||||
std::wstring to_wstring(const std::string& source);
|
||||
|
@ -33,19 +33,19 @@ std::vector<std::string> split_path(const std::string& path);
|
|||
|
||||
// Joins two path segments with the given separator.
|
||||
std::wstring join_paths(const std::wstring& left, const std::wstring& right,
|
||||
wchar_t sep = poly::path_separator);
|
||||
wchar_t sep = xe::path_separator);
|
||||
|
||||
// Replaces all path separators with the given value and removes redundant
|
||||
// separators.
|
||||
std::wstring fix_path_separators(const std::wstring& source,
|
||||
wchar_t new_sep = poly::path_separator);
|
||||
wchar_t new_sep = xe::path_separator);
|
||||
std::string fix_path_separators(const std::string& source,
|
||||
char new_sep = poly::path_separator);
|
||||
char new_sep = xe::path_separator);
|
||||
|
||||
// Find the top directory name or filename from a path
|
||||
std::string find_name_from_path(const std::string& path);
|
||||
std::wstring find_name_from_path(const std::wstring& path);
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_STRING_H_
|
||||
#endif // XENIA_BASE_STRING_H_
|
|
@ -7,12 +7,12 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/string_buffer.h"
|
||||
#include "xenia/base/string_buffer.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
StringBuffer::StringBuffer(size_t initial_capacity) {
|
||||
buffer_.reserve(std::max(initial_capacity, static_cast<size_t>(1024)));
|
||||
|
@ -68,4 +68,4 @@ std::string StringBuffer::to_string() {
|
|||
|
||||
char* StringBuffer::ToString() { return strdup(buffer_.data()); }
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,14 +7,14 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_STRING_BUFFER_H_
|
||||
#define POLY_STRING_BUFFER_H_
|
||||
#ifndef XENIA_BASE_STRING_BUFFER_H_
|
||||
#define XENIA_BASE_STRING_BUFFER_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
class StringBuffer {
|
||||
public:
|
||||
|
@ -41,6 +41,6 @@ class StringBuffer {
|
|||
std::vector<char> buffer_;
|
||||
};
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_STRING_BUFFER_H_
|
||||
#endif // XENIA_BASE_STRING_BUFFER_H_
|
|
@ -7,12 +7,12 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/threading.h"
|
||||
#include "xenia/base/threading.h"
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
namespace threading {
|
||||
|
||||
//
|
||||
|
||||
} // namespace threading
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,8 +7,8 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_THREADING_H_
|
||||
#define POLY_THREADING_H_
|
||||
#ifndef XENIA_BASE_THREADING_H_
|
||||
#define XENIA_BASE_THREADING_H_
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
|
@ -18,8 +18,7 @@
|
|||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
namespace threading {
|
||||
|
||||
class Fence {
|
||||
|
@ -69,6 +68,6 @@ void Sleep(std::chrono::duration<Rep, Period> duration) {
|
|||
}
|
||||
|
||||
} // namespace threading
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_THREADING_H_
|
||||
#endif // XENIA_BASE_THREADING_H_
|
|
@ -7,14 +7,14 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <poly/threading.h>
|
||||
#include "xenia/base/threading.h"
|
||||
|
||||
#include <mach/mach.h>
|
||||
#include <mach/mach_time.h>
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
namespace threading {
|
||||
|
||||
uint64_t ticks() { return mach_absolute_time(); }
|
||||
|
@ -24,9 +24,7 @@ uint32_t current_thread_id() {
|
|||
return static_cast<uint32_t>(tid);
|
||||
}
|
||||
|
||||
void set_name(const std::string& name) {
|
||||
pthread_setname_np(name.c_str());
|
||||
}
|
||||
void set_name(const std::string& name) { pthread_setname_np(name.c_str()); }
|
||||
|
||||
void set_name(std::thread::native_handle_type handle, const std::string& name) {
|
||||
// ?
|
||||
|
@ -41,4 +39,4 @@ void Sleep(std::chrono::microseconds duration) {
|
|||
}
|
||||
|
||||
} // namespace threading
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,12 +7,12 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <poly/threading.h>
|
||||
#include "xenia/base/threading.h"
|
||||
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
namespace threading {
|
||||
|
||||
// uint64_t ticks() { return mach_absolute_time(); }
|
||||
|
@ -39,4 +39,4 @@ void Sleep(std::chrono::microseconds duration) {
|
|||
}
|
||||
|
||||
} // namespace threading
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,11 +7,11 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/threading.h"
|
||||
#include "xenia/base/threading.h"
|
||||
|
||||
#include "poly/platform.h"
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
namespace threading {
|
||||
|
||||
uint64_t ticks() {
|
||||
|
@ -80,4 +80,4 @@ void Sleep(std::chrono::microseconds duration) {
|
|||
}
|
||||
|
||||
} // namespace threading
|
||||
} // namespace poly
|
||||
} // namespace xe
|
|
@ -7,13 +7,13 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_TYPE_POOL_H_
|
||||
#define POLY_TYPE_POOL_H_
|
||||
#ifndef XENIA_BASE_TYPE_POOL_H_
|
||||
#define XENIA_BASE_TYPE_POOL_H_
|
||||
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
template <class T, typename A>
|
||||
class TypePool {
|
||||
|
@ -54,6 +54,6 @@ class TypePool {
|
|||
std::vector<T*> list_;
|
||||
};
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_TYPE_POOL_H_
|
||||
#endif // XENIA_BASE_TYPE_POOL_H_
|
|
@ -7,15 +7,15 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef POLY_VEC128_H_
|
||||
#define POLY_VEC128_H_
|
||||
#ifndef XENIA_BASE_VEC128_H_
|
||||
#define XENIA_BASE_VEC128_H_
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "poly/math.h"
|
||||
#include "poly/platform.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/platform.h"
|
||||
|
||||
namespace poly {
|
||||
namespace xe {
|
||||
|
||||
// The first rule of vector programming is to only rely on exact positions
|
||||
// when absolutely required - prefer dumb loops to exact offsets.
|
||||
|
@ -194,6 +194,6 @@ static inline vec128_t vec128b(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3,
|
|||
return v;
|
||||
}
|
||||
|
||||
} // namespace poly
|
||||
} // namespace xe
|
||||
|
||||
#endif // POLY_VEC128_H_
|
||||
#endif // XENIA_BASE_VEC128_H_
|
|
@ -9,13 +9,13 @@
|
|||
|
||||
#include "xenia/cpu/backend/x64/x64_assembler.h"
|
||||
|
||||
#include "xenia/base/reset_scope.h"
|
||||
#include "xenia/cpu/backend/x64/x64_backend.h"
|
||||
#include "xenia/cpu/backend/x64/x64_emitter.h"
|
||||
#include "xenia/cpu/backend/x64/x64_function.h"
|
||||
#include "xenia/cpu/hir/hir_builder.h"
|
||||
#include "xenia/cpu/hir/label.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "poly/reset_scope.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
namespace BE {
|
||||
|
@ -65,7 +65,7 @@ int X64Assembler::Assemble(FunctionInfo* symbol_info, HIRBuilder* builder,
|
|||
SCOPE_profile_cpu_f("cpu");
|
||||
|
||||
// Reset when we leave.
|
||||
poly::make_reset_scope(this);
|
||||
xe::make_reset_scope(this);
|
||||
|
||||
// Lower HIR -> x64.
|
||||
void* machine_code = 0;
|
||||
|
@ -95,7 +95,7 @@ int X64Assembler::Assemble(FunctionInfo* symbol_info, HIRBuilder* builder,
|
|||
}
|
||||
|
||||
void X64Assembler::DumpMachineCode(DebugInfo* debug_info, void* machine_code,
|
||||
size_t code_size, poly::StringBuffer* str) {
|
||||
size_t code_size, StringBuffer* str) {
|
||||
BE::DISASM disasm = {0};
|
||||
disasm.Archi = 64;
|
||||
disasm.Options = BE::Tabulation + BE::MasmSyntax + BE::PrefixedNumeral;
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "xenia/base/string_buffer.h"
|
||||
#include "xenia/cpu/backend/assembler.h"
|
||||
#include "poly/string_buffer.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -39,14 +39,14 @@ class X64Assembler : public Assembler {
|
|||
|
||||
private:
|
||||
void DumpMachineCode(DebugInfo* debug_info, void* machine_code,
|
||||
size_t code_size, poly::StringBuffer* str);
|
||||
size_t code_size, StringBuffer* str);
|
||||
|
||||
private:
|
||||
X64Backend* x64_backend_;
|
||||
std::unique_ptr<X64Emitter> emitter_;
|
||||
std::unique_ptr<XbyakAllocator> allocator_;
|
||||
|
||||
poly::StringBuffer string_buffer_;
|
||||
StringBuffer string_buffer_;
|
||||
};
|
||||
|
||||
} // namespace x64
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/math.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -51,7 +51,7 @@ void* X64CodeCache::PlaceCode(void* machine_code, size_t code_size,
|
|||
size_t stack_size) {
|
||||
// Always move the code to land on 16b alignment. We do this by rounding up
|
||||
// to 16b so that all offsets are aligned.
|
||||
code_size = poly::round_up(code_size, 16);
|
||||
code_size = xe::round_up(code_size, 16);
|
||||
|
||||
lock_.lock();
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
#include "xenia/cpu/backend/x64/x64_code_cache.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -64,11 +64,11 @@ void* X64CodeCache::PlaceCode(void* machine_code, size_t code_size,
|
|||
size_t alloc_size = code_size;
|
||||
|
||||
// Add unwind info into the allocation size. Keep things 16b aligned.
|
||||
alloc_size += poly::round_up(X64CodeChunk::UNWIND_INFO_SIZE, 16);
|
||||
alloc_size += xe::round_up(X64CodeChunk::UNWIND_INFO_SIZE, 16);
|
||||
|
||||
// Always move the code to land on 16b alignment. We do this by rounding up
|
||||
// to 16b so that all offsets are aligned.
|
||||
alloc_size = poly::round_up(alloc_size, 16);
|
||||
alloc_size = xe::round_up(alloc_size, 16);
|
||||
|
||||
lock_.lock();
|
||||
|
||||
|
@ -108,7 +108,7 @@ X64CodeChunk::X64CodeChunk(size_t chunk_size)
|
|||
PAGE_EXECUTE_READWRITE);
|
||||
|
||||
fn_table_capacity =
|
||||
static_cast<uint32_t>(poly::round_up(capacity / ESTIMATED_FN_SIZE, 16));
|
||||
static_cast<uint32_t>(xe::round_up(capacity / ESTIMATED_FN_SIZE, 16));
|
||||
size_t table_size = fn_table_capacity * sizeof(RUNTIME_FUNCTION);
|
||||
fn_table = (RUNTIME_FUNCTION*)malloc(table_size);
|
||||
fn_table_count = 0;
|
||||
|
|
|
@ -9,21 +9,21 @@
|
|||
|
||||
#include "xenia/cpu/backend/x64/x64_emitter.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/math.h"
|
||||
#include "poly/vec128.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/vec128.h"
|
||||
#include "xenia/cpu/backend/x64/x64_backend.h"
|
||||
#include "xenia/cpu/backend/x64/x64_code_cache.h"
|
||||
#include "xenia/cpu/backend/x64/x64_function.h"
|
||||
#include "xenia/cpu/backend/x64/x64_sequences.h"
|
||||
#include "xenia/cpu/backend/x64/x64_thunk_emitter.h"
|
||||
#include "xenia/cpu/cpu-private.h"
|
||||
#include "xenia/cpu/hir/hir_builder.h"
|
||||
#include "xenia/cpu/debug_info.h"
|
||||
#include "xenia/cpu/hir/hir_builder.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "xenia/cpu/symbol_info.h"
|
||||
#include "xenia/cpu/thread_state.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
#include "xdb/protocol.h"
|
||||
|
||||
|
@ -36,10 +36,6 @@ namespace x64 {
|
|||
using namespace xe::cpu::hir;
|
||||
using namespace xe::cpu;
|
||||
|
||||
using poly::vec128b;
|
||||
using poly::vec128f;
|
||||
using poly::vec128i;
|
||||
|
||||
using namespace Xbyak;
|
||||
using xe::cpu::hir::HIRBuilder;
|
||||
using xe::cpu::hir::Instr;
|
||||
|
@ -132,13 +128,13 @@ int X64Emitter::Emit(HIRBuilder* builder, size_t& out_stack_size) {
|
|||
auto slot = *it;
|
||||
size_t type_size = GetTypeSize(slot->type);
|
||||
// Align to natural size.
|
||||
stack_offset = poly::align(stack_offset, type_size);
|
||||
stack_offset = xe::align(stack_offset, type_size);
|
||||
slot->set_constant((uint32_t)stack_offset);
|
||||
stack_offset += type_size;
|
||||
}
|
||||
// Ensure 16b alignment.
|
||||
stack_offset -= StackLayout::GUEST_STACK_SIZE;
|
||||
stack_offset = poly::align(stack_offset, static_cast<size_t>(16));
|
||||
stack_offset = xe::align(stack_offset, static_cast<size_t>(16));
|
||||
|
||||
// Function prolog.
|
||||
// Must be 16b aligned.
|
||||
|
@ -536,7 +532,7 @@ uint64_t ResolveFunctionAddress(void* raw_context, uint32_t target_address) {
|
|||
Asm* table_slot = reinterpret_cast<Asm*>(table_start);
|
||||
bool wrote_ic = false;
|
||||
for (int i = 0; i < kICSlotCount; ++i) {
|
||||
if (poly::atomic_cas(kICSlotInvalidTargetAddress, addr,
|
||||
if (xe::atomic_cas(kICSlotInvalidTargetAddress, addr,
|
||||
&table_slot->target_constant)) {
|
||||
// Got slot! Just write the compare and we're done.
|
||||
table_slot->address_constant = static_cast<uint32_t>(target_address);
|
||||
|
|
|
@ -10,10 +10,11 @@
|
|||
#ifndef XENIA_BACKEND_X64_X64_EMITTER_H_
|
||||
#define XENIA_BACKEND_X64_X64_EMITTER_H_
|
||||
|
||||
#include "xenia/cpu/hir/value.h"
|
||||
#include "poly/arena.h"
|
||||
#include "third_party/xbyak/xbyak/xbyak.h"
|
||||
|
||||
#include "xenia/base/arena.h"
|
||||
#include "xenia/cpu/hir/value.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
class DebugInfo;
|
||||
|
@ -32,8 +33,6 @@ namespace cpu {
|
|||
namespace backend {
|
||||
namespace x64 {
|
||||
|
||||
using vec128_t = poly::vec128_t;
|
||||
|
||||
class X64Backend;
|
||||
class X64CodeCache;
|
||||
|
||||
|
@ -196,7 +195,7 @@ class X64Emitter : public Xbyak::CodeGenerator {
|
|||
hir::Instr* current_instr_;
|
||||
|
||||
size_t source_map_count_;
|
||||
poly::Arena source_map_arena_;
|
||||
Arena source_map_arena_;
|
||||
|
||||
size_t stack_size_;
|
||||
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
|
||||
#include "xenia/cpu/backend/x64/x64_sequences.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/threading.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/threading.h"
|
||||
#include "xenia/cpu/backend/x64/x64_emitter.h"
|
||||
#include "xenia/cpu/backend/x64/x64_tracers.h"
|
||||
#include "xenia/cpu/hir/hir_builder.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -43,8 +43,6 @@ using namespace Xbyak;
|
|||
using namespace xe::cpu::hir;
|
||||
using namespace xe::cpu;
|
||||
|
||||
using poly::vec128b;
|
||||
|
||||
typedef bool (*SequenceSelectFn)(X64Emitter&, const Instr*, const Instr**);
|
||||
std::unordered_multimap<uint32_t, SequenceSelectFn> sequence_table;
|
||||
|
||||
|
@ -1022,7 +1020,7 @@ EMITTER(LOAD_VECTOR_SHL_I8, MATCH(I<OPCODE_LOAD_VECTOR_SHL, V128<>, I8<>>)) {
|
|||
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
||||
if (i.src1.is_constant) {
|
||||
auto sh = i.src1.constant();
|
||||
assert_true(sh < poly::countof(lvsl_table));
|
||||
assert_true(sh < xe::countof(lvsl_table));
|
||||
e.mov(e.rax, (uintptr_t)&lvsl_table[sh]);
|
||||
e.vmovaps(i.dest, e.ptr[e.rax]);
|
||||
} else {
|
||||
|
@ -1066,7 +1064,7 @@ EMITTER(LOAD_VECTOR_SHR_I8, MATCH(I<OPCODE_LOAD_VECTOR_SHR, V128<>, I8<>>)) {
|
|||
static void Emit(X64Emitter& e, const EmitArgType& i) {
|
||||
if (i.src1.is_constant) {
|
||||
auto sh = i.src1.constant();
|
||||
assert_true(sh < poly::countof(lvsr_table));
|
||||
assert_true(sh < xe::countof(lvsr_table));
|
||||
e.mov(e.rax, (uintptr_t)&lvsr_table[sh]);
|
||||
e.vmovaps(i.dest, e.ptr[e.rax]);
|
||||
} else {
|
||||
|
@ -1095,7 +1093,7 @@ EMITTER(LOAD_CLOCK, MATCH(I<OPCODE_LOAD_CLOCK, I64<>>)) {
|
|||
e.mov(i.dest, e.rax);
|
||||
}
|
||||
static uint64_t LoadClock(void* raw_context) {
|
||||
return poly::threading::ticks();
|
||||
return xe::threading::ticks();
|
||||
}
|
||||
};
|
||||
EMITTER_OPCODE_TABLE(
|
||||
|
@ -4697,7 +4695,7 @@ EMITTER(VECTOR_ROTATE_LEFT_V128, MATCH(I<OPCODE_VECTOR_ROTATE_LEFT, V128<>, V128
|
|||
_mm_store_si128(reinterpret_cast<__m128i*>(value), src1);
|
||||
_mm_store_si128(reinterpret_cast<__m128i*>(shamt), src2);
|
||||
for (size_t i = 0; i < 16; ++i) {
|
||||
value[i] = poly::rotate_left<uint8_t>(value[i], shamt[i] & 0x7);
|
||||
value[i] = xe::rotate_left<uint8_t>(value[i], shamt[i] & 0x7);
|
||||
}
|
||||
return _mm_load_si128(reinterpret_cast<__m128i*>(value));
|
||||
}
|
||||
|
@ -4707,7 +4705,7 @@ EMITTER(VECTOR_ROTATE_LEFT_V128, MATCH(I<OPCODE_VECTOR_ROTATE_LEFT, V128<>, V128
|
|||
_mm_store_si128(reinterpret_cast<__m128i*>(value), src1);
|
||||
_mm_store_si128(reinterpret_cast<__m128i*>(shamt), src2);
|
||||
for (size_t i = 0; i < 8; ++i) {
|
||||
value[i] = poly::rotate_left<uint16_t>(value[i], shamt[i] & 0xF);
|
||||
value[i] = xe::rotate_left<uint16_t>(value[i], shamt[i] & 0xF);
|
||||
}
|
||||
return _mm_load_si128(reinterpret_cast<__m128i*>(value));
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "xenia/cpu/backend/x64/x64_tracers.h"
|
||||
|
||||
#include "poly/vec128.h"
|
||||
#include "xenia/base/vec128.h"
|
||||
#include "xenia/cpu/backend/x64/x64_emitter.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "xenia/cpu/thread_state.h"
|
||||
|
@ -71,23 +71,22 @@ void TraceContextLoadI64(void* raw_context, uint64_t offset, uint64_t value) {
|
|||
}
|
||||
void TraceContextLoadF32(void* raw_context, uint64_t offset, __m128 value) {
|
||||
auto thread_state = *((ThreadState**)raw_context);
|
||||
DPRINT("%e (%X) = ctx f32 +%llu\n", poly::m128_f32<0>(value),
|
||||
poly::m128_i32<0>(value), offset);
|
||||
DPRINT("%e (%X) = ctx f32 +%llu\n", xe::m128_f32<0>(value),
|
||||
xe::m128_i32<0>(value), offset);
|
||||
}
|
||||
void TraceContextLoadF64(void* raw_context, uint64_t offset,
|
||||
const double* value) {
|
||||
auto thread_state = *((ThreadState**)raw_context);
|
||||
auto v = _mm_loadu_pd(value);
|
||||
DPRINT("%le (%llX) = ctx f64 +%llu\n", poly::m128_f64<0>(v),
|
||||
poly::m128_i64<0>(v), offset);
|
||||
DPRINT("%le (%llX) = ctx f64 +%llu\n", xe::m128_f64<0>(v), xe::m128_i64<0>(v),
|
||||
offset);
|
||||
}
|
||||
void TraceContextLoadV128(void* raw_context, uint64_t offset, __m128 value) {
|
||||
auto thread_state = *((ThreadState**)raw_context);
|
||||
DPRINT("[%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X] = ctx v128 +%llu\n",
|
||||
poly::m128_f32<0>(value), poly::m128_f32<1>(value),
|
||||
poly::m128_f32<2>(value), poly::m128_f32<3>(value),
|
||||
poly::m128_i32<0>(value), poly::m128_i32<1>(value),
|
||||
poly::m128_i32<2>(value), poly::m128_i32<3>(value), offset);
|
||||
xe::m128_f32<0>(value), xe::m128_f32<1>(value), xe::m128_f32<2>(value),
|
||||
xe::m128_f32<3>(value), xe::m128_i32<0>(value), xe::m128_i32<1>(value),
|
||||
xe::m128_i32<2>(value), xe::m128_i32<3>(value), offset);
|
||||
}
|
||||
|
||||
void TraceContextStoreI8(void* raw_context, uint64_t offset, uint8_t value) {
|
||||
|
@ -108,23 +107,22 @@ void TraceContextStoreI64(void* raw_context, uint64_t offset, uint64_t value) {
|
|||
}
|
||||
void TraceContextStoreF32(void* raw_context, uint64_t offset, __m128 value) {
|
||||
auto thread_state = *((ThreadState**)raw_context);
|
||||
DPRINT("ctx f32 +%llu = %e (%X)\n", offset, poly::m128_f32<0>(value),
|
||||
poly::m128_i32<0>(value));
|
||||
DPRINT("ctx f32 +%llu = %e (%X)\n", offset, xe::m128_f32<0>(value),
|
||||
xe::m128_i32<0>(value));
|
||||
}
|
||||
void TraceContextStoreF64(void* raw_context, uint64_t offset,
|
||||
const double* value) {
|
||||
auto thread_state = *((ThreadState**)raw_context);
|
||||
auto v = _mm_loadu_pd(value);
|
||||
DPRINT("ctx f64 +%llu = %le (%llX)\n", offset, poly::m128_f64<0>(v),
|
||||
poly::m128_i64<0>(v));
|
||||
DPRINT("ctx f64 +%llu = %le (%llX)\n", offset, xe::m128_f64<0>(v),
|
||||
xe::m128_i64<0>(v));
|
||||
}
|
||||
void TraceContextStoreV128(void* raw_context, uint64_t offset, __m128 value) {
|
||||
auto thread_state = *((ThreadState**)raw_context);
|
||||
DPRINT("ctx v128 +%llu = [%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X]\n", offset,
|
||||
poly::m128_f32<0>(value), poly::m128_f32<1>(value),
|
||||
poly::m128_f32<2>(value), poly::m128_f32<3>(value),
|
||||
poly::m128_i32<0>(value), poly::m128_i32<1>(value),
|
||||
poly::m128_i32<2>(value), poly::m128_i32<3>(value));
|
||||
xe::m128_f32<0>(value), xe::m128_f32<1>(value), xe::m128_f32<2>(value),
|
||||
xe::m128_f32<3>(value), xe::m128_i32<0>(value), xe::m128_i32<1>(value),
|
||||
xe::m128_i32<2>(value), xe::m128_i32<3>(value));
|
||||
}
|
||||
|
||||
void TraceMemoryLoadI8(void* raw_context, uint32_t address, uint8_t value) {
|
||||
|
@ -145,21 +143,20 @@ void TraceMemoryLoadI64(void* raw_context, uint32_t address, uint64_t value) {
|
|||
}
|
||||
void TraceMemoryLoadF32(void* raw_context, uint32_t address, __m128 value) {
|
||||
auto thread_state = *((ThreadState**)raw_context);
|
||||
DPRINT("%e (%X) = load.f32 %.8X\n", poly::m128_f32<0>(value),
|
||||
poly::m128_i32<0>(value), address);
|
||||
DPRINT("%e (%X) = load.f32 %.8X\n", xe::m128_f32<0>(value),
|
||||
xe::m128_i32<0>(value), address);
|
||||
}
|
||||
void TraceMemoryLoadF64(void* raw_context, uint32_t address, __m128 value) {
|
||||
auto thread_state = *((ThreadState**)raw_context);
|
||||
DPRINT("%le (%llX) = load.f64 %.8X\n", poly::m128_f64<0>(value),
|
||||
poly::m128_i64<0>(value), address);
|
||||
DPRINT("%le (%llX) = load.f64 %.8X\n", xe::m128_f64<0>(value),
|
||||
xe::m128_i64<0>(value), address);
|
||||
}
|
||||
void TraceMemoryLoadV128(void* raw_context, uint32_t address, __m128 value) {
|
||||
auto thread_state = *((ThreadState**)raw_context);
|
||||
DPRINT("[%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X] = load.v128 %.8X\n",
|
||||
poly::m128_f32<0>(value), poly::m128_f32<1>(value),
|
||||
poly::m128_f32<2>(value), poly::m128_f32<3>(value),
|
||||
poly::m128_i32<0>(value), poly::m128_i32<1>(value),
|
||||
poly::m128_i32<2>(value), poly::m128_i32<3>(value), address);
|
||||
xe::m128_f32<0>(value), xe::m128_f32<1>(value), xe::m128_f32<2>(value),
|
||||
xe::m128_f32<3>(value), xe::m128_i32<0>(value), xe::m128_i32<1>(value),
|
||||
xe::m128_i32<2>(value), xe::m128_i32<3>(value), address);
|
||||
}
|
||||
|
||||
void TraceMemoryStoreI8(void* raw_context, uint32_t address, uint8_t value) {
|
||||
|
@ -180,21 +177,21 @@ void TraceMemoryStoreI64(void* raw_context, uint32_t address, uint64_t value) {
|
|||
}
|
||||
void TraceMemoryStoreF32(void* raw_context, uint32_t address, __m128 value) {
|
||||
auto thread_state = *((ThreadState**)raw_context);
|
||||
DPRINT("store.f32 %.8X = %e (%X)\n", address, poly::m128_f32<0>(value),
|
||||
poly::m128_i32<0>(value));
|
||||
DPRINT("store.f32 %.8X = %e (%X)\n", address, xe::m128_f32<0>(value),
|
||||
xe::m128_i32<0>(value));
|
||||
}
|
||||
void TraceMemoryStoreF64(void* raw_context, uint32_t address, __m128 value) {
|
||||
auto thread_state = *((ThreadState**)raw_context);
|
||||
DPRINT("store.f64 %.8X = %le (%llX)\n", address, poly::m128_f64<0>(value),
|
||||
poly::m128_i64<0>(value));
|
||||
DPRINT("store.f64 %.8X = %le (%llX)\n", address, xe::m128_f64<0>(value),
|
||||
xe::m128_i64<0>(value));
|
||||
}
|
||||
void TraceMemoryStoreV128(void* raw_context, uint32_t address, __m128 value) {
|
||||
auto thread_state = *((ThreadState**)raw_context);
|
||||
DPRINT("store.v128 %.8X = [%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X]\n",
|
||||
address, poly::m128_f32<0>(value), poly::m128_f32<1>(value),
|
||||
poly::m128_f32<2>(value), poly::m128_f32<3>(value),
|
||||
poly::m128_i32<0>(value), poly::m128_i32<1>(value),
|
||||
poly::m128_i32<2>(value), poly::m128_i32<3>(value));
|
||||
address, xe::m128_f32<0>(value), xe::m128_f32<1>(value),
|
||||
xe::m128_f32<2>(value), xe::m128_f32<3>(value), xe::m128_i32<0>(value),
|
||||
xe::m128_i32<1>(value), xe::m128_i32<2>(value),
|
||||
xe::m128_i32<3>(value));
|
||||
}
|
||||
|
||||
} // namespace x64
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/base/arena.h"
|
||||
#include "xenia/cpu/hir/hir_builder.h"
|
||||
#include "poly/arena.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -34,7 +34,7 @@ class Compiler {
|
|||
~Compiler();
|
||||
|
||||
Runtime* runtime() const { return runtime_; }
|
||||
poly::Arena* scratch_arena() { return &scratch_arena_; }
|
||||
Arena* scratch_arena() { return &scratch_arena_; }
|
||||
|
||||
void AddPass(std::unique_ptr<CompilerPass> pass);
|
||||
|
||||
|
@ -44,7 +44,7 @@ class Compiler {
|
|||
|
||||
private:
|
||||
Runtime* runtime_;
|
||||
poly::Arena scratch_arena_;
|
||||
Arena scratch_arena_;
|
||||
|
||||
std::vector<std::unique_ptr<CompilerPass>> passes_;
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@ int CompilerPass::Initialize(Compiler* compiler) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
poly::Arena* CompilerPass::scratch_arena() const {
|
||||
Arena* CompilerPass::scratch_arena() const {
|
||||
return compiler_->scratch_arena();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#ifndef XENIA_COMPILER_COMPILER_PASS_H_
|
||||
#define XENIA_COMPILER_COMPILER_PASS_H_
|
||||
|
||||
#include "xenia/base/arena.h"
|
||||
#include "xenia/cpu/hir/hir_builder.h"
|
||||
#include "poly/arena.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -35,7 +35,7 @@ class CompilerPass {
|
|||
virtual int Run(hir::HIRBuilder* builder) = 0;
|
||||
|
||||
protected:
|
||||
poly::Arena* scratch_arena() const;
|
||||
Arena* scratch_arena() const;
|
||||
|
||||
protected:
|
||||
Runtime* runtime_;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "xenia/cpu/compiler/passes/constant_propagation_pass.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/cpu/function.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#ifndef XENIA_COMPILER_PASSES_CONTEXT_PROMOTION_PASS_H_
|
||||
#define XENIA_COMPILER_PASSES_CONTEXT_PROMOTION_PASS_H_
|
||||
|
||||
#include "poly/platform.h"
|
||||
#include "xenia/base/platform.h"
|
||||
#include "xenia/cpu/compiler/compiler_pass.h"
|
||||
|
||||
#if XE_COMPILER_MSVC
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
#include "xenia/cpu/compiler/passes/data_flow_analysis_pass.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/platform.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/platform.h"
|
||||
#include "xenia/cpu/backend/backend.h"
|
||||
#include "xenia/cpu/compiler/compiler.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
namespace xe {
|
||||
|
@ -61,7 +61,7 @@ RegisterAllocationPass::RegisterAllocationPass(const MachineInfo* machine_info)
|
|||
}
|
||||
|
||||
RegisterAllocationPass::~RegisterAllocationPass() {
|
||||
for (size_t n = 0; n < poly::countof(usage_sets_.all_sets); n++) {
|
||||
for (size_t n = 0; n < xe::countof(usage_sets_.all_sets); n++) {
|
||||
if (!usage_sets_.all_sets[n]) {
|
||||
break;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ int RegisterAllocationPass::Run(HIRBuilder* builder) {
|
|||
void RegisterAllocationPass::DumpUsage(const char* name) {
|
||||
#if 0
|
||||
fprintf(stdout, "\n%s:\n", name);
|
||||
for (size_t i = 0; i < poly::countof(usage_sets_.all_sets); ++i) {
|
||||
for (size_t i = 0; i < xe::countof(usage_sets_.all_sets); ++i) {
|
||||
auto usage_set = usage_sets_.all_sets[i];
|
||||
if (usage_set) {
|
||||
fprintf(stdout, "set %s:\n", usage_set->set->name);
|
||||
|
@ -194,7 +194,7 @@ void RegisterAllocationPass::DumpUsage(const char* name) {
|
|||
}
|
||||
|
||||
void RegisterAllocationPass::PrepareBlockState() {
|
||||
for (size_t i = 0; i < poly::countof(usage_sets_.all_sets); ++i) {
|
||||
for (size_t i = 0; i < xe::countof(usage_sets_.all_sets); ++i) {
|
||||
auto usage_set = usage_sets_.all_sets[i];
|
||||
if (usage_set) {
|
||||
usage_set->availability.set();
|
||||
|
@ -205,7 +205,7 @@ void RegisterAllocationPass::PrepareBlockState() {
|
|||
}
|
||||
|
||||
void RegisterAllocationPass::AdvanceUses(Instr* instr) {
|
||||
for (size_t i = 0; i < poly::countof(usage_sets_.all_sets); ++i) {
|
||||
for (size_t i = 0; i < xe::countof(usage_sets_.all_sets); ++i) {
|
||||
auto usage_set = usage_sets_.all_sets[i];
|
||||
if (!usage_set) {
|
||||
break;
|
||||
|
@ -310,7 +310,7 @@ bool RegisterAllocationPass::TryAllocateRegister(Value* value) {
|
|||
// Find the first free register, if any.
|
||||
// We have to ensure it's a valid one (in our count).
|
||||
uint32_t first_unused = 0;
|
||||
bool none_used = poly::bit_scan_forward(
|
||||
bool none_used = xe::bit_scan_forward(
|
||||
static_cast<uint32_t>(usage_set->availability.to_ulong()), &first_unused);
|
||||
if (none_used && first_unused < usage_set->count) {
|
||||
// Available! Use it!
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "xenia/cpu/compiler/passes/validation_pass.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/cpu/backend/backend.h"
|
||||
#include "xenia/cpu/compiler/compiler.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "xenia/cpu/compiler/passes/value_reduction_pass.h"
|
||||
|
||||
#include "poly/platform.h"
|
||||
#include "xenia/base/platform.h"
|
||||
#include "xenia/cpu/backend/backend.h"
|
||||
#include "xenia/cpu/compiler/compiler.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "poly/delegate.h"
|
||||
#include "xenia/base/delegate.h"
|
||||
#include "xenia/cpu/thread_state.h"
|
||||
|
||||
namespace xe {
|
||||
|
@ -104,7 +104,7 @@ class Debugger {
|
|||
void OnBreakpointHit(ThreadState* thread_state, Breakpoint* breakpoint);
|
||||
|
||||
public:
|
||||
poly::Delegate<BreakpointHitEvent> breakpoint_hit;
|
||||
Delegate<BreakpointHitEvent> breakpoint_hit;
|
||||
|
||||
private:
|
||||
Runtime* runtime_;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "xenia/cpu/entry_table.h"
|
||||
|
||||
#include "poly/threading.h"
|
||||
#include "xenia/base/threading.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
namespace xe {
|
||||
|
@ -53,7 +53,7 @@ Entry::Status EntryTable::GetOrCreate(uint32_t address, Entry** out_entry) {
|
|||
do {
|
||||
lock_.unlock();
|
||||
// TODO(benvanik): sleep for less time?
|
||||
poly::threading::Sleep(std::chrono::microseconds(10));
|
||||
xe::threading::Sleep(std::chrono::microseconds(10));
|
||||
lock_.lock();
|
||||
} while (entry->status == Entry::STATUS_COMPILING);
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
#include "xenia/cpu/export_resolver.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/math.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#include "poly/vec128.h"
|
||||
#include "xenia/base/vec128.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -25,8 +25,6 @@ namespace xe {
|
|||
namespace cpu {
|
||||
namespace frontend {
|
||||
|
||||
using vec128_t = poly::vec128_t;
|
||||
|
||||
// Map:
|
||||
// 0-31: GPR
|
||||
// 32-63: FPR
|
||||
|
|
|
@ -9,63 +9,63 @@
|
|||
|
||||
#include "xenia/cpu/frontend/ppc_disasm.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/math.h"
|
||||
#include "poly/string_buffer.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/string_buffer.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
namespace frontend {
|
||||
|
||||
void Disasm_0(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_0(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s ???", i.type->name);
|
||||
}
|
||||
|
||||
void Disasm__(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm__(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s", i.type->name);
|
||||
}
|
||||
|
||||
void Disasm_X_FRT_FRB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_X_FRT_FRB(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%*s%s f%d, f%d", i.X.Rc ? -7 : -8, i.type->name,
|
||||
i.X.Rc ? "." : "", i.X.RT, i.X.RB);
|
||||
}
|
||||
void Disasm_A_FRT_FRB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_A_FRT_FRB(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%*s%s f%d, f%d", i.A.Rc ? -7 : -8, i.type->name,
|
||||
i.A.Rc ? "." : "", i.A.FRT, i.A.FRB);
|
||||
}
|
||||
void Disasm_A_FRT_FRA_FRB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_A_FRT_FRA_FRB(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%*s%s f%d, f%d, f%d", i.A.Rc ? -7 : -8, i.type->name,
|
||||
i.A.Rc ? "." : "", i.A.FRT, i.A.FRA, i.A.FRB);
|
||||
}
|
||||
void Disasm_A_FRT_FRA_FRB_FRC(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_A_FRT_FRA_FRB_FRC(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%*s%s f%d, f%d, f%d, f%d", i.A.Rc ? -7 : -8, i.type->name,
|
||||
i.A.Rc ? "." : "", i.A.FRT, i.A.FRA, i.A.FRB, i.A.FRC);
|
||||
}
|
||||
void Disasm_X_RT_RA_RB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_X_RT_RA_RB(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s r%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, i.X.RB);
|
||||
}
|
||||
void Disasm_X_RT_RA0_RB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_X_RT_RA0_RB(InstrData& i, StringBuffer* str) {
|
||||
if (i.X.RA) {
|
||||
str->Append("%-8s r%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, i.X.RB);
|
||||
} else {
|
||||
str->Append("%-8s r%d, 0, r%d", i.type->name, i.X.RT, i.X.RB);
|
||||
}
|
||||
}
|
||||
void Disasm_X_FRT_RA_RB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_X_FRT_RA_RB(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s f%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, i.X.RB);
|
||||
}
|
||||
void Disasm_X_FRT_RA0_RB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_X_FRT_RA0_RB(InstrData& i, StringBuffer* str) {
|
||||
if (i.X.RA) {
|
||||
str->Append("%-8s f%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, i.X.RB);
|
||||
} else {
|
||||
str->Append("%-8s f%d, 0, r%d", i.type->name, i.X.RT, i.X.RB);
|
||||
}
|
||||
}
|
||||
void Disasm_D_RT_RA_I(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_D_RT_RA_I(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s r%d, r%d, %d", i.type->name, i.D.RT, i.D.RA,
|
||||
(int32_t)(int16_t) XEEXTS16(i.D.DS));
|
||||
}
|
||||
void Disasm_D_RT_RA0_I(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_D_RT_RA0_I(InstrData& i, StringBuffer* str) {
|
||||
if (i.D.RA) {
|
||||
str->Append("%-8s r%d, r%d, %d", i.type->name, i.D.RT, i.D.RA,
|
||||
(int32_t)(int16_t) XEEXTS16(i.D.DS));
|
||||
|
@ -74,11 +74,11 @@ void Disasm_D_RT_RA0_I(InstrData& i, poly::StringBuffer* str) {
|
|||
(int32_t)(int16_t) XEEXTS16(i.D.DS));
|
||||
}
|
||||
}
|
||||
void Disasm_D_FRT_RA_I(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_D_FRT_RA_I(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s f%d, r%d, %d", i.type->name, i.D.RT, i.D.RA,
|
||||
(int32_t)(int16_t) XEEXTS16(i.D.DS));
|
||||
}
|
||||
void Disasm_D_FRT_RA0_I(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_D_FRT_RA0_I(InstrData& i, StringBuffer* str) {
|
||||
if (i.D.RA) {
|
||||
str->Append("%-8s f%d, r%d, %d", i.type->name, i.D.RT, i.D.RA,
|
||||
(int32_t)(int16_t) XEEXTS16(i.D.DS));
|
||||
|
@ -87,11 +87,11 @@ void Disasm_D_FRT_RA0_I(InstrData& i, poly::StringBuffer* str) {
|
|||
(int32_t)(int16_t) XEEXTS16(i.D.DS));
|
||||
}
|
||||
}
|
||||
void Disasm_DS_RT_RA_I(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_DS_RT_RA_I(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s r%d, r%d, %d", i.type->name, i.DS.RT, i.DS.RA,
|
||||
(int32_t)(int16_t) XEEXTS16(i.DS.DS << 2));
|
||||
}
|
||||
void Disasm_DS_RT_RA0_I(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_DS_RT_RA0_I(InstrData& i, StringBuffer* str) {
|
||||
if (i.DS.RA) {
|
||||
str->Append("%-8s r%d, r%d, %d", i.type->name, i.DS.RT, i.DS.RA,
|
||||
(int32_t)(int16_t) XEEXTS16(i.DS.DS << 2));
|
||||
|
@ -100,29 +100,29 @@ void Disasm_DS_RT_RA0_I(InstrData& i, poly::StringBuffer* str) {
|
|||
(int32_t)(int16_t) XEEXTS16(i.DS.DS << 2));
|
||||
}
|
||||
}
|
||||
void Disasm_D_RA(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_D_RA(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s r%d", i.type->name, i.D.RA);
|
||||
}
|
||||
void Disasm_X_RA_RB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_X_RA_RB(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s r%d, r%d", i.type->name, i.X.RA, i.X.RB);
|
||||
}
|
||||
void Disasm_XO_RT_RA_RB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_XO_RT_RA_RB(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%*s%s%s r%d, r%d, r%d", i.XO.Rc ? -7 : -8, i.type->name,
|
||||
i.XO.OE ? "o" : "", i.XO.Rc ? "." : "", i.XO.RT, i.XO.RA,
|
||||
i.XO.RB);
|
||||
}
|
||||
void Disasm_XO_RT_RA(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_XO_RT_RA(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%*s%s%s r%d, r%d", i.XO.Rc ? -7 : -8, i.type->name,
|
||||
i.XO.OE ? "o" : "", i.XO.Rc ? "." : "", i.XO.RT, i.XO.RA);
|
||||
}
|
||||
void Disasm_X_RA_RT_RB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_X_RA_RT_RB(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%*s%s r%d, r%d, r%d", i.X.Rc ? -7 : -8, i.type->name,
|
||||
i.X.Rc ? "." : "", i.X.RA, i.X.RT, i.X.RB);
|
||||
}
|
||||
void Disasm_D_RA_RT_I(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_D_RA_RT_I(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-7s. r%d, r%d, %.4Xh", i.type->name, i.D.RA, i.D.RT, i.D.DS);
|
||||
}
|
||||
void Disasm_X_RA_RT(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_X_RA_RT(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%*s%s r%d, r%d", i.X.Rc ? -7 : -8, i.type->name,
|
||||
i.X.Rc ? "." : "", i.X.RA, i.X.RT);
|
||||
}
|
||||
|
@ -161,14 +161,14 @@ void Disasm_X_RA_RT(InstrData& i, poly::StringBuffer* str) {
|
|||
(i.VX128_R.VA128l | (i.VX128_R.VA128h << 5) | (i.VX128_R.VA128H << 6))
|
||||
#define VX128_R_VB128 (i.VX128_R.VB128l | (i.VX128_R.VB128h << 5))
|
||||
|
||||
void Disasm_X_VX_RA0_RB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_X_VX_RA0_RB(InstrData& i, StringBuffer* str) {
|
||||
if (i.X.RA) {
|
||||
str->Append("%-8s v%d, r%d, r%d", i.type->name, i.X.RT, i.X.RA, i.X.RB);
|
||||
} else {
|
||||
str->Append("%-8s v%d, 0, r%d", i.type->name, i.X.RT, i.X.RB);
|
||||
}
|
||||
}
|
||||
void Disasm_VX1281_VD_RA0_RB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_VX1281_VD_RA0_RB(InstrData& i, StringBuffer* str) {
|
||||
const uint32_t vd = VX128_1_VD128;
|
||||
if (i.VX128_1.RA) {
|
||||
str->Append("%-8s v%d, r%d, r%d", i.type->name, vd, i.VX128_1.RA,
|
||||
|
@ -177,45 +177,45 @@ void Disasm_VX1281_VD_RA0_RB(InstrData& i, poly::StringBuffer* str) {
|
|||
str->Append("%-8s v%d, 0, r%d", i.type->name, vd, i.VX128_1.RB);
|
||||
}
|
||||
}
|
||||
void Disasm_VX1283_VD_VB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_VX1283_VD_VB(InstrData& i, StringBuffer* str) {
|
||||
const uint32_t vd = VX128_3_VD128;
|
||||
const uint32_t vb = VX128_3_VB128;
|
||||
str->Append("%-8s v%d, v%d", i.type->name, vd, vb);
|
||||
}
|
||||
void Disasm_VX1283_VD_VB_I(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_VX1283_VD_VB_I(InstrData& i, StringBuffer* str) {
|
||||
const uint32_t vd = VX128_VD128;
|
||||
const uint32_t va = VX128_VA128;
|
||||
const uint32_t uimm = i.VX128_3.IMM;
|
||||
str->Append("%-8s v%d, v%d, %.2Xh", i.type->name, vd, va, uimm);
|
||||
}
|
||||
void Disasm_VX_VD_VA_VB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_VX_VD_VA_VB(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s v%d, v%d, v%d", i.type->name, i.VX.VD, i.VX.VA, i.VX.VB);
|
||||
}
|
||||
void Disasm_VX128_VD_VA_VB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_VX128_VD_VA_VB(InstrData& i, StringBuffer* str) {
|
||||
const uint32_t vd = VX128_VD128;
|
||||
const uint32_t va = VX128_VA128;
|
||||
const uint32_t vb = VX128_VB128;
|
||||
str->Append("%-8s v%d, v%d, v%d", i.type->name, vd, va, vb);
|
||||
}
|
||||
void Disasm_VX128_VD_VA_VD_VB(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_VX128_VD_VA_VD_VB(InstrData& i, StringBuffer* str) {
|
||||
const uint32_t vd = VX128_VD128;
|
||||
const uint32_t va = VX128_VA128;
|
||||
const uint32_t vb = VX128_VB128;
|
||||
str->Append("%-8s v%d, v%d, v%d, v%d", i.type->name, vd, va, vd, vb);
|
||||
}
|
||||
void Disasm_VX1282_VD_VA_VB_VC(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_VX1282_VD_VA_VB_VC(InstrData& i, StringBuffer* str) {
|
||||
const uint32_t vd = VX128_2_VD128;
|
||||
const uint32_t va = VX128_2_VA128;
|
||||
const uint32_t vb = VX128_2_VB128;
|
||||
const uint32_t vc = i.VX128_2.VC;
|
||||
str->Append("%-8s v%d, v%d, v%d, v%d", i.type->name, vd, va, vb, vc);
|
||||
}
|
||||
void Disasm_VXA_VD_VA_VB_VC(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_VXA_VD_VA_VB_VC(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s v%d, v%d, v%d, v%d", i.type->name, i.VXA.VD, i.VXA.VA,
|
||||
i.VXA.VB, i.VXA.VC);
|
||||
}
|
||||
|
||||
void Disasm_sync(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_sync(InstrData& i, StringBuffer* str) {
|
||||
const char* name;
|
||||
int L = i.X.RT & 3;
|
||||
switch (L) {
|
||||
|
@ -234,7 +234,7 @@ void Disasm_sync(InstrData& i, poly::StringBuffer* str) {
|
|||
str->Append("%-8s %.2X", name, L);
|
||||
}
|
||||
|
||||
void Disasm_dcbf(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_dcbf(InstrData& i, StringBuffer* str) {
|
||||
const char* name;
|
||||
switch (i.X.RT & 3) {
|
||||
case 0:
|
||||
|
@ -256,7 +256,7 @@ void Disasm_dcbf(InstrData& i, poly::StringBuffer* str) {
|
|||
str->Append("%-8s r%d, r%d", name, i.X.RA, i.X.RB);
|
||||
}
|
||||
|
||||
void Disasm_dcbz(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_dcbz(InstrData& i, StringBuffer* str) {
|
||||
// or dcbz128 0x7C2007EC
|
||||
if (i.X.RA) {
|
||||
str->Append("%-8s r%d, r%d", i.type->name, i.X.RA, i.X.RB);
|
||||
|
@ -265,16 +265,16 @@ void Disasm_dcbz(InstrData& i, poly::StringBuffer* str) {
|
|||
}
|
||||
}
|
||||
|
||||
void Disasm_fcmp(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_fcmp(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s cr%d, f%d, f%d", i.type->name, i.X.RT >> 2, i.X.RA, i.X.RB);
|
||||
}
|
||||
|
||||
void Disasm_mffsx(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_mffsx(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%*s%s f%d, FPSCR", i.X.Rc ? -7 : -8, i.type->name,
|
||||
i.X.Rc ? "." : "", i.X.RT);
|
||||
}
|
||||
|
||||
void Disasm_bx(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_bx(InstrData& i, StringBuffer* str) {
|
||||
const char* name = i.I.LK ? "bl" : "b";
|
||||
uint32_t nia;
|
||||
if (i.I.AA) {
|
||||
|
@ -285,7 +285,7 @@ void Disasm_bx(InstrData& i, poly::StringBuffer* str) {
|
|||
str->Append("%-8s %.8X", name, nia);
|
||||
// TODO(benvanik): resolve target name?
|
||||
}
|
||||
void Disasm_bcx(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_bcx(InstrData& i, StringBuffer* str) {
|
||||
const char* s0 = i.B.LK ? "lr, " : "";
|
||||
const char* s1;
|
||||
if (!select_bits(i.B.BO, 2, 2)) {
|
||||
|
@ -295,7 +295,7 @@ void Disasm_bcx(InstrData& i, poly::StringBuffer* str) {
|
|||
}
|
||||
char s2[8] = {0};
|
||||
if (!select_bits(i.B.BO, 4, 4)) {
|
||||
snprintf(s2, poly::countof(s2), "cr%d, ", i.B.BI >> 2);
|
||||
snprintf(s2, xe::countof(s2), "cr%d, ", i.B.BI >> 2);
|
||||
}
|
||||
uint32_t nia;
|
||||
if (i.B.AA) {
|
||||
|
@ -306,17 +306,17 @@ void Disasm_bcx(InstrData& i, poly::StringBuffer* str) {
|
|||
str->Append("%-8s %s%s%s%.8X", i.type->name, s0, s1, s2, nia);
|
||||
// TODO(benvanik): resolve target name?
|
||||
}
|
||||
void Disasm_bcctrx(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_bcctrx(InstrData& i, StringBuffer* str) {
|
||||
// TODO(benvanik): mnemonics
|
||||
const char* s0 = i.XL.LK ? "lr, " : "";
|
||||
char s2[8] = {0};
|
||||
if (!select_bits(i.XL.BO, 4, 4)) {
|
||||
snprintf(s2, poly::countof(s2), "cr%d, ", i.XL.BI >> 2);
|
||||
snprintf(s2, xe::countof(s2), "cr%d, ", i.XL.BI >> 2);
|
||||
}
|
||||
str->Append("%-8s %s%sctr", i.type->name, s0, s2);
|
||||
// TODO(benvanik): resolve target name?
|
||||
}
|
||||
void Disasm_bclrx(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_bclrx(InstrData& i, StringBuffer* str) {
|
||||
const char* name = "bclr";
|
||||
if (i.code == 0x4E800020) {
|
||||
name = "blr";
|
||||
|
@ -329,12 +329,12 @@ void Disasm_bclrx(InstrData& i, poly::StringBuffer* str) {
|
|||
}
|
||||
char s2[8] = {0};
|
||||
if (!select_bits(i.XL.BO, 4, 4)) {
|
||||
snprintf(s2, poly::countof(s2), "cr%d, ", i.XL.BI >> 2);
|
||||
snprintf(s2, xe::countof(s2), "cr%d, ", i.XL.BI >> 2);
|
||||
}
|
||||
str->Append("%-8s %s%s", name, s1, s2);
|
||||
}
|
||||
|
||||
void Disasm_mfcr(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_mfcr(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s r%d, cr", i.type->name, i.X.RT);
|
||||
}
|
||||
const char* Disasm_spr_name(uint32_t n) {
|
||||
|
@ -352,40 +352,40 @@ const char* Disasm_spr_name(uint32_t n) {
|
|||
}
|
||||
return reg;
|
||||
}
|
||||
void Disasm_mfspr(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_mfspr(InstrData& i, StringBuffer* str) {
|
||||
const uint32_t n = ((i.XFX.spr & 0x1F) << 5) | ((i.XFX.spr >> 5) & 0x1F);
|
||||
const char* reg = Disasm_spr_name(n);
|
||||
str->Append("%-8s r%d, %s", i.type->name, i.XFX.RT, reg);
|
||||
}
|
||||
void Disasm_mtspr(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_mtspr(InstrData& i, StringBuffer* str) {
|
||||
const uint32_t n = ((i.XFX.spr & 0x1F) << 5) | ((i.XFX.spr >> 5) & 0x1F);
|
||||
const char* reg = Disasm_spr_name(n);
|
||||
str->Append("%-8s %s, r%d", i.type->name, reg, i.XFX.RT);
|
||||
}
|
||||
void Disasm_mftb(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_mftb(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s r%d, tb", i.type->name, i.XFX.RT);
|
||||
}
|
||||
void Disasm_mfmsr(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_mfmsr(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s r%d", i.type->name, i.X.RT);
|
||||
}
|
||||
void Disasm_mtmsr(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_mtmsr(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s r%d, %d", i.type->name, i.X.RT, (i.X.RA & 16) ? 1 : 0);
|
||||
}
|
||||
|
||||
void Disasm_cmp(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_cmp(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s cr%d, %.2X, r%d, r%d", i.type->name, i.X.RT >> 2,
|
||||
i.X.RT & 1, i.X.RA, i.X.RB);
|
||||
}
|
||||
void Disasm_cmpi(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_cmpi(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s cr%d, %.2X, r%d, %d", i.type->name, i.D.RT >> 2, i.D.RT & 1,
|
||||
i.D.RA, XEEXTS16(i.D.DS));
|
||||
}
|
||||
void Disasm_cmpli(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_cmpli(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s cr%d, %.2X, r%d, %.2X", i.type->name, i.D.RT >> 2,
|
||||
i.D.RT & 1, i.D.RA, XEEXTS16(i.D.DS));
|
||||
}
|
||||
|
||||
void Disasm_rld(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_rld(InstrData& i, StringBuffer* str) {
|
||||
if (i.MD.idx == 0) {
|
||||
// XEDISASMR(rldiclx, 0x78000000, MD )
|
||||
str->Append("%*s%s r%d, r%d, %d, %d", i.MD.Rc ? -7 : -8, "rldicl",
|
||||
|
@ -422,75 +422,75 @@ void Disasm_rld(InstrData& i, poly::StringBuffer* str) {
|
|||
assert_always();
|
||||
}
|
||||
}
|
||||
void Disasm_rlwim(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_rlwim(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%*s%s r%d, r%d, %d, %d, %d", i.M.Rc ? -7 : -8, i.type->name,
|
||||
i.M.Rc ? "." : "", i.M.RA, i.M.RT, i.M.SH, i.M.MB, i.M.ME);
|
||||
}
|
||||
void Disasm_rlwnmx(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_rlwnmx(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%*s%s r%d, r%d, r%d, %d, %d", i.M.Rc ? -7 : -8, i.type->name,
|
||||
i.M.Rc ? "." : "", i.M.RA, i.M.RT, i.M.SH, i.M.MB, i.M.ME);
|
||||
}
|
||||
void Disasm_srawix(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_srawix(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%*s%s r%d, r%d, %d", i.X.Rc ? -7 : -8, i.type->name,
|
||||
i.X.Rc ? "." : "", i.X.RA, i.X.RT, i.X.RB);
|
||||
}
|
||||
void Disasm_sradix(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_sradix(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%*s%s r%d, r%d, %d", i.XS.Rc ? -7 : -8, i.type->name,
|
||||
i.XS.Rc ? "." : "", i.XS.RA, i.XS.RT, (i.XS.SH5 << 5) | i.XS.SH);
|
||||
}
|
||||
|
||||
void Disasm_vpermwi128(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_vpermwi128(InstrData& i, StringBuffer* str) {
|
||||
const uint32_t vd = i.VX128_P.VD128l | (i.VX128_P.VD128h << 5);
|
||||
const uint32_t vb = i.VX128_P.VB128l | (i.VX128_P.VB128h << 5);
|
||||
str->Append("%-8s v%d, v%d, %.2X", i.type->name, vd, vb,
|
||||
i.VX128_P.PERMl | (i.VX128_P.PERMh << 5));
|
||||
}
|
||||
void Disasm_vrfin128(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_vrfin128(InstrData& i, StringBuffer* str) {
|
||||
const uint32_t vd = VX128_3_VD128;
|
||||
const uint32_t vb = VX128_3_VB128;
|
||||
str->Append("%-8s v%d, v%d", i.type->name, vd, vb);
|
||||
}
|
||||
void Disasm_vrlimi128(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_vrlimi128(InstrData& i, StringBuffer* str) {
|
||||
const uint32_t vd = VX128_4_VD128;
|
||||
const uint32_t vb = VX128_4_VB128;
|
||||
str->Append("%-8s v%d, v%d, %.2X, %.2X", i.type->name, vd, vb, i.VX128_4.IMM,
|
||||
i.VX128_4.z);
|
||||
}
|
||||
void Disasm_vsldoi128(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_vsldoi128(InstrData& i, StringBuffer* str) {
|
||||
const uint32_t vd = VX128_5_VD128;
|
||||
const uint32_t va = VX128_5_VA128;
|
||||
const uint32_t vb = VX128_5_VB128;
|
||||
const uint32_t sh = i.VX128_5.SH;
|
||||
str->Append("%-8s v%d, v%d, v%d, %.2X", i.type->name, vd, va, vb, sh);
|
||||
}
|
||||
void Disasm_vspltb(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_vspltb(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s v%d, v%d, %.2X", i.type->name, i.VX.VD, i.VX.VB,
|
||||
i.VX.VA & 0xF);
|
||||
}
|
||||
void Disasm_vsplth(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_vsplth(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s v%d, v%d, %.2X", i.type->name, i.VX.VD, i.VX.VB,
|
||||
i.VX.VA & 0x7);
|
||||
}
|
||||
void Disasm_vspltw(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_vspltw(InstrData& i, StringBuffer* str) {
|
||||
str->Append("%-8s v%d, v%d, %.2X", i.type->name, i.VX.VD, i.VX.VB, i.VX.VA);
|
||||
}
|
||||
void Disasm_vspltisb(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_vspltisb(InstrData& i, StringBuffer* str) {
|
||||
// 5bit -> 8bit sign extend
|
||||
int8_t simm = (i.VX.VA & 0x10) ? (i.VX.VA | 0xF0) : i.VX.VA;
|
||||
str->Append("%-8s v%d, %.2X", i.type->name, i.VX.VD, simm);
|
||||
}
|
||||
void Disasm_vspltish(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_vspltish(InstrData& i, StringBuffer* str) {
|
||||
// 5bit -> 16bit sign extend
|
||||
int16_t simm = (i.VX.VA & 0x10) ? (i.VX.VA | 0xFFF0) : i.VX.VA;
|
||||
str->Append("%-8s v%d, %.4X", i.type->name, i.VX.VD, simm);
|
||||
}
|
||||
void Disasm_vspltisw(InstrData& i, poly::StringBuffer* str) {
|
||||
void Disasm_vspltisw(InstrData& i, StringBuffer* str) {
|
||||
// 5bit -> 32bit sign extend
|
||||
int32_t simm = (i.VX.VA & 0x10) ? (i.VX.VA | 0xFFFFFFF0) : i.VX.VA;
|
||||
str->Append("%-8s v%d, %.8X", i.type->name, i.VX.VD, simm);
|
||||
}
|
||||
|
||||
int DisasmPPC(InstrData& i, poly::StringBuffer* str) {
|
||||
int DisasmPPC(InstrData& i, StringBuffer* str) {
|
||||
if (!i.type) {
|
||||
str->Append("???");
|
||||
} else {
|
||||
|
|
|
@ -10,14 +10,14 @@
|
|||
#ifndef XENIA_FRONTEND_PPC_DISASM_H_
|
||||
#define XENIA_FRONTEND_PPC_DISASM_H_
|
||||
|
||||
#include "xenia/base/string_buffer.h"
|
||||
#include "xenia/cpu/frontend/ppc_instr.h"
|
||||
#include "poly/string_buffer.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
namespace frontend {
|
||||
|
||||
int DisasmPPC(InstrData& i, poly::StringBuffer* str);
|
||||
int DisasmPPC(InstrData& i, StringBuffer* str);
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace cpu
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "xenia/cpu/frontend/ppc_emit-private.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/cpu/frontend/ppc_context.h"
|
||||
#include "xenia/cpu/frontend/ppc_hir_builder.h"
|
||||
|
||||
|
@ -19,10 +19,6 @@ namespace frontend {
|
|||
|
||||
// TODO(benvanik): remove when enums redefined.
|
||||
using namespace xe::cpu::hir;
|
||||
using poly::vec128b;
|
||||
using poly::vec128f;
|
||||
using poly::vec128i;
|
||||
using poly::vec128s;
|
||||
|
||||
using xe::cpu::hir::Value;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "xenia/cpu/frontend/ppc_emit-private.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/cpu/frontend/ppc_context.h"
|
||||
#include "xenia/cpu/frontend/ppc_hir_builder.h"
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "xenia/cpu/frontend/ppc_emit-private.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/cpu/frontend/ppc_context.h"
|
||||
#include "xenia/cpu/frontend/ppc_hir_builder.h"
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "xenia/cpu/frontend/ppc_emit-private.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/cpu/frontend/ppc_context.h"
|
||||
#include "xenia/cpu/frontend/ppc_hir_builder.h"
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "xenia/cpu/frontend/ppc_emit-private.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/cpu/frontend/ppc_context.h"
|
||||
#include "xenia/cpu/frontend/ppc_hir_builder.h"
|
||||
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "poly/type_pool.h"
|
||||
#include "xenia/base/type_pool.h"
|
||||
#include "xenia/cpu/frontend/context_info.h"
|
||||
#include "xenia/memory.h"
|
||||
#include "xenia/cpu/function.h"
|
||||
#include "xenia/cpu/symbol_info.h"
|
||||
#include "xenia/memory.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -58,7 +58,7 @@ class PPCFrontend {
|
|||
Runtime* runtime_;
|
||||
std::unique_ptr<ContextInfo> context_info_;
|
||||
PPCBuiltins builtins_;
|
||||
poly::TypePool<PPCTranslator, PPCFrontend*> translator_pool_;
|
||||
TypePool<PPCTranslator, PPCFrontend*> translator_pool_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
|
||||
#include "xenia/cpu/frontend/ppc_hir_builder.h"
|
||||
|
||||
#include "poly/byte_order.h"
|
||||
#include "poly/memory.h"
|
||||
#include "xenia/base/byte_order.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/memory.h"
|
||||
#include "xenia/cpu/cpu-private.h"
|
||||
#include "xenia/cpu/frontend/ppc_context.h"
|
||||
#include "xenia/cpu/frontend/ppc_disasm.h"
|
||||
|
@ -18,7 +19,6 @@
|
|||
#include "xenia/cpu/frontend/ppc_instr.h"
|
||||
#include "xenia/cpu/hir/label.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
namespace xe {
|
||||
|
@ -82,7 +82,7 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info, uint32_t flags) {
|
|||
for (uint32_t address = start_address, offset = 0; address <= end_address;
|
||||
address += 4, offset++) {
|
||||
i.address = address;
|
||||
i.code = poly::load_and_swap<uint32_t>(memory->TranslateVirtual(address));
|
||||
i.code = xe::load_and_swap<uint32_t>(memory->TranslateVirtual(address));
|
||||
// TODO(benvanik): find a way to avoid using the opcode tables.
|
||||
i.type = GetInstrType(i.code);
|
||||
trace_info_.dest_count = 0;
|
||||
|
@ -170,7 +170,7 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info, uint32_t flags) {
|
|||
|
||||
void PPCHIRBuilder::AnnotateLabel(uint32_t address, Label* label) {
|
||||
char name_buffer[13];
|
||||
snprintf(name_buffer, poly::countof(name_buffer), "loc_%.8X", address);
|
||||
snprintf(name_buffer, xe::countof(name_buffer), "loc_%.8X", address);
|
||||
label->name = (char*)arena_->Alloc(sizeof(name_buffer));
|
||||
memcpy(label->name, name_buffer, sizeof(name_buffer));
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#ifndef XENIA_FRONTEND_PPC_HIR_BUILDER_H_
|
||||
#define XENIA_FRONTEND_PPC_HIR_BUILDER_H_
|
||||
|
||||
#include "xenia/base/string_buffer.h"
|
||||
#include "xenia/cpu/hir/hir_builder.h"
|
||||
#include "xenia/cpu/function.h"
|
||||
#include "xenia/cpu/symbol_info.h"
|
||||
#include "poly/string_buffer.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -91,7 +91,7 @@ class PPCHIRBuilder : public hir::HIRBuilder {
|
|||
PPCFrontend* frontend_;
|
||||
|
||||
// Reset whenever needed:
|
||||
poly::StringBuffer comment_buffer_;
|
||||
StringBuffer comment_buffer_;
|
||||
|
||||
// Reset each Emit:
|
||||
bool with_debug_info_;
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/math.h"
|
||||
#include "poly/string_buffer.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/string_buffer.h"
|
||||
#include "xenia/cpu/frontend/ppc_instr_tables.h"
|
||||
|
||||
namespace xe {
|
||||
|
@ -24,7 +24,7 @@ namespace frontend {
|
|||
std::vector<InstrType*> all_instrs_;
|
||||
|
||||
void DumpAllInstrCounts() {
|
||||
poly::StringBuffer sb;
|
||||
StringBuffer sb;
|
||||
sb.Append("Instruction translation counts:\n");
|
||||
for (auto instr_type : all_instrs_) {
|
||||
if (instr_type->translation_count) {
|
||||
|
@ -42,7 +42,7 @@ void InstrOperand::Dump(std::string& out_str) {
|
|||
}
|
||||
|
||||
char buffer[32];
|
||||
const size_t max_count = poly::countof(buffer);
|
||||
const size_t max_count = xe::countof(buffer);
|
||||
switch (type) {
|
||||
case InstrOperand::kRegister:
|
||||
switch (reg.set) {
|
||||
|
@ -380,7 +380,7 @@ InstrType* GetInstrType(uint32_t code) {
|
|||
|
||||
// Slow lookup via linear scan.
|
||||
// This is primarily due to laziness. It could be made fast like the others.
|
||||
for (size_t n = 0; n < poly::countof(tables::instr_table_scan); n++) {
|
||||
for (size_t n = 0; n < xe::countof(tables::instr_table_scan); n++) {
|
||||
slot = &(tables::instr_table_scan[n]);
|
||||
if (slot->opcode == (code & slot->opcode_mask)) {
|
||||
return slot;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "poly/string_buffer.h"
|
||||
#include "xenia/base/string_buffer.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -547,7 +547,7 @@ class InstrDisasm {
|
|||
void Dump(std::string& out_str, size_t pad = 13);
|
||||
};
|
||||
|
||||
typedef void (*InstrDisasmFn)(InstrData& i, poly::StringBuffer* str);
|
||||
typedef void (*InstrDisasmFn)(InstrData& i, StringBuffer* str);
|
||||
typedef void* InstrEmitFn;
|
||||
|
||||
class InstrType {
|
||||
|
|
|
@ -12,84 +12,84 @@
|
|||
|
||||
#include <cmath>
|
||||
|
||||
#include "poly/math.h"
|
||||
#include "poly/string_buffer.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/string_buffer.h"
|
||||
#include "xenia/cpu/frontend/ppc_instr.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
namespace frontend {
|
||||
|
||||
void Disasm_0(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm__(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_X_FRT_FRB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_A_FRT_FRB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_A_FRT_FRA_FRB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_A_FRT_FRA_FRB_FRC(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_X_RT_RA_RB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_X_RT_RA0_RB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_X_FRT_RA_RB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_X_FRT_RA0_RB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_D_RT_RA_I(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_D_RT_RA0_I(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_D_FRT_RA_I(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_D_FRT_RA0_I(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_DS_RT_RA_I(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_DS_RT_RA0_I(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_D_RA(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_X_RA_RB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_XO_RT_RA_RB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_XO_RT_RA(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_X_RA_RT_RB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_D_RA_RT_I(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_X_RA_RT(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_X_VX_RA0_RB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_VX1281_VD_RA0_RB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_VX1283_VD_VB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_VX1283_VD_VB_I(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_VX_VD_VA_VB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_VX128_VD_VA_VB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_VX128_VD_VA_VD_VB(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_VX1282_VD_VA_VB_VC(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_VXA_VD_VA_VB_VC(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_0(InstrData& i, StringBuffer* str);
|
||||
void Disasm__(InstrData& i, StringBuffer* str);
|
||||
void Disasm_X_FRT_FRB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_A_FRT_FRB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_A_FRT_FRA_FRB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_A_FRT_FRA_FRB_FRC(InstrData& i, StringBuffer* str);
|
||||
void Disasm_X_RT_RA_RB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_X_RT_RA0_RB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_X_FRT_RA_RB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_X_FRT_RA0_RB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_D_RT_RA_I(InstrData& i, StringBuffer* str);
|
||||
void Disasm_D_RT_RA0_I(InstrData& i, StringBuffer* str);
|
||||
void Disasm_D_FRT_RA_I(InstrData& i, StringBuffer* str);
|
||||
void Disasm_D_FRT_RA0_I(InstrData& i, StringBuffer* str);
|
||||
void Disasm_DS_RT_RA_I(InstrData& i, StringBuffer* str);
|
||||
void Disasm_DS_RT_RA0_I(InstrData& i, StringBuffer* str);
|
||||
void Disasm_D_RA(InstrData& i, StringBuffer* str);
|
||||
void Disasm_X_RA_RB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_XO_RT_RA_RB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_XO_RT_RA(InstrData& i, StringBuffer* str);
|
||||
void Disasm_X_RA_RT_RB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_D_RA_RT_I(InstrData& i, StringBuffer* str);
|
||||
void Disasm_X_RA_RT(InstrData& i, StringBuffer* str);
|
||||
void Disasm_X_VX_RA0_RB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_VX1281_VD_RA0_RB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_VX1283_VD_VB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_VX1283_VD_VB_I(InstrData& i, StringBuffer* str);
|
||||
void Disasm_VX_VD_VA_VB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_VX128_VD_VA_VB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_VX128_VD_VA_VD_VB(InstrData& i, StringBuffer* str);
|
||||
void Disasm_VX1282_VD_VA_VB_VC(InstrData& i, StringBuffer* str);
|
||||
void Disasm_VXA_VD_VA_VB_VC(InstrData& i, StringBuffer* str);
|
||||
|
||||
void Disasm_sync(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_dcbf(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_dcbz(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_fcmp(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_sync(InstrData& i, StringBuffer* str);
|
||||
void Disasm_dcbf(InstrData& i, StringBuffer* str);
|
||||
void Disasm_dcbz(InstrData& i, StringBuffer* str);
|
||||
void Disasm_fcmp(InstrData& i, StringBuffer* str);
|
||||
|
||||
void Disasm_bx(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_bcx(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_bcctrx(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_bclrx(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_bx(InstrData& i, StringBuffer* str);
|
||||
void Disasm_bcx(InstrData& i, StringBuffer* str);
|
||||
void Disasm_bcctrx(InstrData& i, StringBuffer* str);
|
||||
void Disasm_bclrx(InstrData& i, StringBuffer* str);
|
||||
|
||||
void Disasm_mfcr(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_mfspr(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_mtspr(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_mftb(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_mfmsr(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_mtmsr(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_mfcr(InstrData& i, StringBuffer* str);
|
||||
void Disasm_mfspr(InstrData& i, StringBuffer* str);
|
||||
void Disasm_mtspr(InstrData& i, StringBuffer* str);
|
||||
void Disasm_mftb(InstrData& i, StringBuffer* str);
|
||||
void Disasm_mfmsr(InstrData& i, StringBuffer* str);
|
||||
void Disasm_mtmsr(InstrData& i, StringBuffer* str);
|
||||
|
||||
void Disasm_cmp(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_cmpi(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_cmpli(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_cmp(InstrData& i, StringBuffer* str);
|
||||
void Disasm_cmpi(InstrData& i, StringBuffer* str);
|
||||
void Disasm_cmpli(InstrData& i, StringBuffer* str);
|
||||
|
||||
void Disasm_rld(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_rlwim(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_rlwnmx(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_srawix(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_sradix(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_rld(InstrData& i, StringBuffer* str);
|
||||
void Disasm_rlwim(InstrData& i, StringBuffer* str);
|
||||
void Disasm_rlwnmx(InstrData& i, StringBuffer* str);
|
||||
void Disasm_srawix(InstrData& i, StringBuffer* str);
|
||||
void Disasm_sradix(InstrData& i, StringBuffer* str);
|
||||
|
||||
void Disasm_vpermwi128(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_vrfin128(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_vrlimi128(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_vsldoi128(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_vspltb(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_vsplth(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_vspltw(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_vspltisb(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_vspltish(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_vspltisw(InstrData& i, poly::StringBuffer* str);
|
||||
void Disasm_vpermwi128(InstrData& i, StringBuffer* str);
|
||||
void Disasm_vrfin128(InstrData& i, StringBuffer* str);
|
||||
void Disasm_vrlimi128(InstrData& i, StringBuffer* str);
|
||||
void Disasm_vsldoi128(InstrData& i, StringBuffer* str);
|
||||
void Disasm_vspltb(InstrData& i, StringBuffer* str);
|
||||
void Disasm_vsplth(InstrData& i, StringBuffer* str);
|
||||
void Disasm_vspltw(InstrData& i, StringBuffer* str);
|
||||
void Disasm_vspltisb(InstrData& i, StringBuffer* str);
|
||||
void Disasm_vspltish(InstrData& i, StringBuffer* str);
|
||||
void Disasm_vspltisw(InstrData& i, StringBuffer* str);
|
||||
|
||||
namespace tables {
|
||||
|
||||
|
@ -364,7 +364,7 @@ static InstrType instr_table_4_unprep[] = {
|
|||
"Vector Logical XOR"),
|
||||
};
|
||||
static InstrType** instr_table_4 = instr_table_prep(
|
||||
instr_table_4_unprep, poly::countof(instr_table_4_unprep), 0, 11);
|
||||
instr_table_4_unprep, xe::countof(instr_table_4_unprep), 0, 11);
|
||||
|
||||
// Opcode = 19, index = bits 10-1 (10)
|
||||
static InstrType instr_table_19_unprep[] = {
|
||||
|
@ -384,7 +384,7 @@ static InstrType instr_table_19_unprep[] = {
|
|||
"Branch Conditional to Count Register"),
|
||||
};
|
||||
static InstrType** instr_table_19 = instr_table_prep(
|
||||
instr_table_19_unprep, poly::countof(instr_table_19_unprep), 1, 10);
|
||||
instr_table_19_unprep, xe::countof(instr_table_19_unprep), 1, 10);
|
||||
|
||||
// Opcode = 30, index = bits 4-1 (4)
|
||||
static InstrType instr_table_30_unprep[] = {
|
||||
|
@ -400,7 +400,7 @@ static InstrType instr_table_30_unprep[] = {
|
|||
// INSTRUCTION(rldcrx, 0x78000012, MDS, General , 0),
|
||||
};
|
||||
static InstrType** instr_table_30 = instr_table_prep(
|
||||
instr_table_30_unprep, poly::countof(instr_table_30_unprep), 0, 0);
|
||||
instr_table_30_unprep, xe::countof(instr_table_30_unprep), 0, 0);
|
||||
|
||||
// Opcode = 31, index = bits 10-1 (10)
|
||||
static InstrType instr_table_31_unprep[] = {
|
||||
|
@ -651,7 +651,7 @@ static InstrType instr_table_31_unprep[] = {
|
|||
"Store Vector Right Indexed LRU"),
|
||||
};
|
||||
static InstrType** instr_table_31 = instr_table_prep(
|
||||
instr_table_31_unprep, poly::countof(instr_table_31_unprep), 1, 10);
|
||||
instr_table_31_unprep, xe::countof(instr_table_31_unprep), 1, 10);
|
||||
|
||||
// Opcode = 58, index = bits 1-0 (2)
|
||||
static InstrType instr_table_58_unprep[] = {
|
||||
|
@ -662,7 +662,7 @@ static InstrType instr_table_58_unprep[] = {
|
|||
"Load Word Algebraic"),
|
||||
};
|
||||
static InstrType** instr_table_58 = instr_table_prep(
|
||||
instr_table_58_unprep, poly::countof(instr_table_58_unprep), 0, 1);
|
||||
instr_table_58_unprep, xe::countof(instr_table_58_unprep), 0, 1);
|
||||
|
||||
// Opcode = 59, index = bits 5-1 (5)
|
||||
static InstrType instr_table_59_unprep[] = {
|
||||
|
@ -688,7 +688,7 @@ static InstrType instr_table_59_unprep[] = {
|
|||
"Floating Negative Multiply-Add [Single]"),
|
||||
};
|
||||
static InstrType** instr_table_59 = instr_table_prep(
|
||||
instr_table_59_unprep, poly::countof(instr_table_59_unprep), 1, 5);
|
||||
instr_table_59_unprep, xe::countof(instr_table_59_unprep), 1, 5);
|
||||
|
||||
// Opcode = 62, index = bits 1-0 (2)
|
||||
static InstrType instr_table_62_unprep[] = {
|
||||
|
@ -697,7 +697,7 @@ static InstrType instr_table_62_unprep[] = {
|
|||
"Store Doubleword with Update"),
|
||||
};
|
||||
static InstrType** instr_table_62 = instr_table_prep(
|
||||
instr_table_62_unprep, poly::countof(instr_table_62_unprep), 0, 1);
|
||||
instr_table_62_unprep, xe::countof(instr_table_62_unprep), 0, 1);
|
||||
|
||||
// Opcode = 63, index = bits 10-1 (10)
|
||||
// NOTE: the A format instructions need some special handling because
|
||||
|
@ -757,7 +757,7 @@ static InstrType instr_table_63_unprep[] = {
|
|||
"Floating Convert From Integer Doubleword"),
|
||||
};
|
||||
static InstrType** instr_table_63 = instr_table_prep_63(
|
||||
instr_table_63_unprep, poly::countof(instr_table_63_unprep), 1, 10);
|
||||
instr_table_63_unprep, xe::countof(instr_table_63_unprep), 1, 10);
|
||||
|
||||
// Main table, index = bits 31-26 (6) : (code >> 26)
|
||||
static InstrType instr_table_unprep[64] = {
|
||||
|
@ -837,7 +837,7 @@ static InstrType instr_table_unprep[64] = {
|
|||
"Store Floating-Point Double with Update"),
|
||||
};
|
||||
static InstrType** instr_table = instr_table_prep(
|
||||
instr_table_unprep, poly::countof(instr_table_unprep), 26, 31);
|
||||
instr_table_unprep, xe::countof(instr_table_unprep), 26, 31);
|
||||
|
||||
// Altivec instructions.
|
||||
// TODO(benvanik): build a table like the other instructions.
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
#include <algorithm>
|
||||
#include <map>
|
||||
|
||||
#include "poly/memory.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/memory.h"
|
||||
#include "xenia/cpu/frontend/ppc_frontend.h"
|
||||
#include "xenia/cpu/frontend/ppc_instr.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
#if 0
|
||||
|
@ -63,7 +63,7 @@ int PPCScanner::FindExtents(FunctionInfo* symbol_info) {
|
|||
InstrData i;
|
||||
while (true) {
|
||||
i.address = address;
|
||||
i.code = poly::load_and_swap<uint32_t>(memory->TranslateVirtual(address));
|
||||
i.code = xe::load_and_swap<uint32_t>(memory->TranslateVirtual(address));
|
||||
|
||||
// If we fetched 0 assume that we somehow hit one of the awesome
|
||||
// 'no really we meant to end after that bl' functions.
|
||||
|
@ -290,7 +290,7 @@ std::vector<BlockInfo> PPCScanner::FindBlocks(FunctionInfo* symbol_info) {
|
|||
InstrData i;
|
||||
for (uint32_t address = start_address; address <= end_address; address += 4) {
|
||||
i.address = address;
|
||||
i.code = poly::load_and_swap<uint32_t>(memory->TranslateVirtual(address));
|
||||
i.code = xe::load_and_swap<uint32_t>(memory->TranslateVirtual(address));
|
||||
if (!i.code) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
#include "xenia/cpu/frontend/ppc_translator.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/byte_order.h"
|
||||
#include "poly/memory.h"
|
||||
#include "poly/reset_scope.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/byte_order.h"
|
||||
#include "xenia/base/memory.h"
|
||||
#include "xenia/base/reset_scope.h"
|
||||
#include "xenia/cpu/compiler/compiler_passes.h"
|
||||
#include "xenia/cpu/cpu-private.h"
|
||||
#include "xenia/cpu/frontend/ppc_disasm.h"
|
||||
|
@ -92,10 +92,10 @@ int PPCTranslator::Translate(FunctionInfo* symbol_info,
|
|||
SCOPE_profile_cpu_f("cpu");
|
||||
|
||||
// Reset() all caching when we leave.
|
||||
poly::make_reset_scope(builder_);
|
||||
poly::make_reset_scope(compiler_);
|
||||
poly::make_reset_scope(assembler_);
|
||||
poly::make_reset_scope(&string_buffer_);
|
||||
xe::make_reset_scope(builder_);
|
||||
xe::make_reset_scope(compiler_);
|
||||
xe::make_reset_scope(assembler_);
|
||||
xe::make_reset_scope(&string_buffer_);
|
||||
|
||||
// Scan the function to find its extents. We only need to do this if we
|
||||
// haven't already been provided with them from some other source.
|
||||
|
@ -176,7 +176,7 @@ int PPCTranslator::Translate(FunctionInfo* symbol_info,
|
|||
};
|
||||
|
||||
void PPCTranslator::DumpSource(FunctionInfo* symbol_info,
|
||||
poly::StringBuffer* string_buffer) {
|
||||
StringBuffer* string_buffer) {
|
||||
Memory* memory = frontend_->memory();
|
||||
|
||||
string_buffer->Append("%s fn %.8X-%.8X %s\n",
|
||||
|
@ -193,7 +193,7 @@ void PPCTranslator::DumpSource(FunctionInfo* symbol_info,
|
|||
for (uint32_t address = start_address, offset = 0; address <= end_address;
|
||||
address += 4, offset++) {
|
||||
i.address = address;
|
||||
i.code = poly::load_and_swap<uint32_t>(memory->TranslateVirtual(address));
|
||||
i.code = xe::load_and_swap<uint32_t>(memory->TranslateVirtual(address));
|
||||
// TODO(benvanik): find a way to avoid using the opcode tables.
|
||||
i.type = GetInstrType(i.code);
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "xenia/base/string_buffer.h"
|
||||
#include "xenia/cpu/backend/assembler.h"
|
||||
#include "xenia/cpu/compiler/compiler.h"
|
||||
#include "xenia/cpu/symbol_info.h"
|
||||
#include "poly/string_buffer.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -34,7 +34,7 @@ class PPCTranslator {
|
|||
uint32_t trace_flags, Function** out_function);
|
||||
|
||||
private:
|
||||
void DumpSource(FunctionInfo* symbol_info, poly::StringBuffer* string_buffer);
|
||||
void DumpSource(FunctionInfo* symbol_info, StringBuffer* string_buffer);
|
||||
|
||||
private:
|
||||
PPCFrontend* frontend_;
|
||||
|
@ -43,7 +43,7 @@ class PPCTranslator {
|
|||
std::unique_ptr<compiler::Compiler> compiler_;
|
||||
std::unique_ptr<backend::Assembler> assembler_;
|
||||
|
||||
poly::StringBuffer string_buffer_;
|
||||
StringBuffer string_buffer_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "poly/main.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/main.h"
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/cpu/cpu.h"
|
||||
#include "xenia/cpu/backend/x64/x64_backend.h"
|
||||
#include "xenia/cpu/frontend/ppc_context.h"
|
||||
#include "xenia/cpu/frontend/ppc_frontend.h"
|
||||
#include "xenia/cpu/raw_module.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
#if !XE_PLATFORM_WIN32
|
||||
#include <dirent.h>
|
||||
|
@ -48,11 +48,11 @@ struct TestCase {
|
|||
class TestSuite {
|
||||
public:
|
||||
TestSuite(const std::wstring& src_file_path) : src_file_path(src_file_path) {
|
||||
name = src_file_path.substr(
|
||||
src_file_path.find_last_of(poly::path_separator) + 1);
|
||||
name = src_file_path.substr(src_file_path.find_last_of(xe::path_separator) +
|
||||
1);
|
||||
name = ReplaceExtension(name, L"");
|
||||
map_file_path = poly::to_wstring(FLAGS_test_bin_path) + name + L".map";
|
||||
bin_file_path = poly::to_wstring(FLAGS_test_bin_path) + name + L".bin";
|
||||
map_file_path = xe::to_wstring(FLAGS_test_bin_path) + name + L".map";
|
||||
bin_file_path = xe::to_wstring(FLAGS_test_bin_path) + name + L".bin";
|
||||
}
|
||||
|
||||
bool Load() {
|
||||
|
@ -92,7 +92,7 @@ class TestSuite {
|
|||
}
|
||||
|
||||
bool ReadMap(const std::wstring& map_file_path) {
|
||||
FILE* f = fopen(poly::to_string(map_file_path).c_str(), "r");
|
||||
FILE* f = fopen(xe::to_string(map_file_path).c_str(), "r");
|
||||
if (!f) {
|
||||
return false;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ class TestSuite {
|
|||
|
||||
bool ReadAnnotations(const std::wstring& src_file_path) {
|
||||
TestCase* current_test_case = nullptr;
|
||||
FILE* f = fopen(poly::to_string(src_file_path).c_str(), "r");
|
||||
FILE* f = fopen(xe::to_string(src_file_path).c_str(), "r");
|
||||
if (!f) {
|
||||
return false;
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ class TestRunner {
|
|||
auto reg_value = it.second.substr(space_pos + 1);
|
||||
if (!ppc_state->CompareRegWithString(reg_name.c_str(),
|
||||
reg_value.c_str(), actual_value,
|
||||
poly::countof(actual_value))) {
|
||||
xe::countof(actual_value))) {
|
||||
any_failed = true;
|
||||
printf("Register %s assert failed:\n", reg_name.c_str());
|
||||
printf(" Expected: %s == %s\n", reg_name.c_str(), reg_value.c_str());
|
||||
|
@ -373,7 +373,7 @@ bool RunTests(const std::wstring& test_name) {
|
|||
int passed_count = 0;
|
||||
|
||||
auto test_path_root =
|
||||
poly::fix_path_separators(poly::to_wstring(FLAGS_test_path));
|
||||
xe::fix_path_separators(xe::to_wstring(FLAGS_test_path));
|
||||
std::vector<std::wstring> test_files;
|
||||
if (!DiscoverTests(test_path_root, test_files)) {
|
||||
return false;
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#include "xenia/cpu/function.h"
|
||||
|
||||
#include "xdb/protocol.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/cpu/debugger.h"
|
||||
#include "xenia/cpu/symbol_info.h"
|
||||
#include "xenia/cpu/thread_state.h"
|
||||
#include "xenia/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "xenia/cpu/hir/block.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/cpu/hir/instr.h"
|
||||
|
||||
namespace xe {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#ifndef XENIA_HIR_BLOCK_H_
|
||||
#define XENIA_HIR_BLOCK_H_
|
||||
|
||||
#include "poly/arena.h"
|
||||
#include "xenia/base/arena.h"
|
||||
|
||||
namespace llvm {
|
||||
class BitVector;
|
||||
|
@ -46,7 +46,7 @@ class Edge {
|
|||
|
||||
class Block {
|
||||
public:
|
||||
poly::Arena* arena;
|
||||
Arena* arena;
|
||||
|
||||
Block* next;
|
||||
Block* prev;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "xenia/cpu/hir/hir_builder.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/cpu/hir/block.h"
|
||||
#include "xenia/cpu/hir/instr.h"
|
||||
#include "xenia/cpu/hir/label.h"
|
||||
|
@ -29,7 +29,7 @@ namespace hir {
|
|||
assert_true((value1->type) == (value2->type))
|
||||
|
||||
HIRBuilder::HIRBuilder() {
|
||||
arena_ = new poly::Arena();
|
||||
arena_ = new Arena();
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ int HIRBuilder::Finalize() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void HIRBuilder::DumpValue(poly::StringBuffer* str, Value* value) {
|
||||
void HIRBuilder::DumpValue(StringBuffer* str, Value* value) {
|
||||
if (value->IsConstant()) {
|
||||
switch (value->type) {
|
||||
case INT8_TYPE:
|
||||
|
@ -128,7 +128,7 @@ void HIRBuilder::DumpValue(poly::StringBuffer* str, Value* value) {
|
|||
}
|
||||
}
|
||||
|
||||
void HIRBuilder::DumpOp(poly::StringBuffer* str, OpcodeSignatureType sig_type,
|
||||
void HIRBuilder::DumpOp(StringBuffer* str, OpcodeSignatureType sig_type,
|
||||
Instr::Op* op) {
|
||||
switch (sig_type) {
|
||||
case OPCODE_SIG_TYPE_X:
|
||||
|
@ -155,7 +155,7 @@ void HIRBuilder::DumpOp(poly::StringBuffer* str, OpcodeSignatureType sig_type,
|
|||
}
|
||||
}
|
||||
|
||||
void HIRBuilder::Dump(poly::StringBuffer* str) {
|
||||
void HIRBuilder::Dump(StringBuffer* str) {
|
||||
if (attributes_) {
|
||||
str->Append("; attributes = %.8X\n", attributes_);
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "xenia/base/arena.h"
|
||||
#include "xenia/base/string_buffer.h"
|
||||
#include "xenia/cpu/hir/block.h"
|
||||
#include "xenia/cpu/hir/instr.h"
|
||||
#include "xenia/cpu/hir/label.h"
|
||||
#include "xenia/cpu/hir/opcodes.h"
|
||||
#include "xenia/cpu/hir/value.h"
|
||||
#include "poly/arena.h"
|
||||
#include "poly/string_buffer.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -36,10 +36,10 @@ class HIRBuilder {
|
|||
virtual void Reset();
|
||||
virtual int Finalize();
|
||||
|
||||
void Dump(poly::StringBuffer* str);
|
||||
void Dump(StringBuffer* str);
|
||||
void AssertNoCycles();
|
||||
|
||||
poly::Arena* arena() const { return arena_; }
|
||||
Arena* arena() const { return arena_; }
|
||||
|
||||
uint32_t attributes() const { return attributes_; }
|
||||
void set_attributes(uint32_t value) { attributes_ = value; }
|
||||
|
@ -229,9 +229,8 @@ class HIRBuilder {
|
|||
Value* AtomicSub(Value* address, Value* value);
|
||||
|
||||
protected:
|
||||
void DumpValue(poly::StringBuffer* str, Value* value);
|
||||
void DumpOp(poly::StringBuffer* str, OpcodeSignatureType sig_type,
|
||||
Instr::Op* op);
|
||||
void DumpValue(StringBuffer* str, Value* value);
|
||||
void DumpOp(StringBuffer* str, OpcodeSignatureType sig_type, Instr::Op* op);
|
||||
|
||||
Value* AllocValue(TypeName type = INT64_TYPE);
|
||||
Value* CloneValue(Value* source);
|
||||
|
@ -246,7 +245,7 @@ class HIRBuilder {
|
|||
TypeName part_type);
|
||||
|
||||
protected:
|
||||
poly::Arena* arena_;
|
||||
Arena* arena_;
|
||||
|
||||
uint32_t attributes_;
|
||||
|
||||
|
|
|
@ -11,15 +11,15 @@
|
|||
|
||||
#include <cmath>
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/byte_order.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/byte_order.h"
|
||||
#include "xenia/base/math.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
namespace hir {
|
||||
|
||||
Value::Use* Value::AddUse(poly::Arena* arena, Instr* instr) {
|
||||
Value::Use* Value::AddUse(Arena* arena, Instr* instr) {
|
||||
Use* use = arena->Alloc<Use>();
|
||||
use->instr = instr;
|
||||
use->prev = NULL;
|
||||
|
@ -587,17 +587,17 @@ void Value::ByteSwap() {
|
|||
constant.i8 = constant.i8;
|
||||
break;
|
||||
case INT16_TYPE:
|
||||
constant.i16 = poly::byte_swap(constant.i16);
|
||||
constant.i16 = xe::byte_swap(constant.i16);
|
||||
break;
|
||||
case INT32_TYPE:
|
||||
constant.i32 = poly::byte_swap(constant.i32);
|
||||
constant.i32 = xe::byte_swap(constant.i32);
|
||||
break;
|
||||
case INT64_TYPE:
|
||||
constant.i64 = poly::byte_swap(constant.i64);
|
||||
constant.i64 = xe::byte_swap(constant.i64);
|
||||
break;
|
||||
case VEC128_TYPE:
|
||||
for (int n = 0; n < 4; n++) {
|
||||
constant.v128.u32[n] = poly::byte_swap(constant.v128.u32[n]);
|
||||
constant.v128.u32[n] = xe::byte_swap(constant.v128.u32[n]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -609,16 +609,16 @@ void Value::ByteSwap() {
|
|||
void Value::CountLeadingZeros(const Value* other) {
|
||||
switch (other->type) {
|
||||
case INT8_TYPE:
|
||||
constant.i8 = poly::lzcnt(constant.i8);
|
||||
constant.i8 = xe::lzcnt(constant.i8);
|
||||
break;
|
||||
case INT16_TYPE:
|
||||
constant.i8 = poly::lzcnt(constant.i16);
|
||||
constant.i8 = xe::lzcnt(constant.i16);
|
||||
break;
|
||||
case INT32_TYPE:
|
||||
constant.i8 = poly::lzcnt(constant.i32);
|
||||
constant.i8 = xe::lzcnt(constant.i32);
|
||||
break;
|
||||
case INT64_TYPE:
|
||||
constant.i8 = poly::lzcnt(constant.i64);
|
||||
constant.i8 = xe::lzcnt(constant.i64);
|
||||
break;
|
||||
default:
|
||||
assert_unhandled_case(type);
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#ifndef XENIA_HIR_VALUE_H_
|
||||
#define XENIA_HIR_VALUE_H_
|
||||
|
||||
#include "poly/arena.h"
|
||||
#include "poly/assert.h"
|
||||
#include "poly/vec128.h"
|
||||
#include "xenia/base/arena.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/vec128.h"
|
||||
#include "xenia/cpu/backend/machine_info.h"
|
||||
#include "xenia/cpu/hir/opcodes.h"
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace hir {
|
|||
|
||||
class Instr;
|
||||
|
||||
using vec128_t = poly::vec128_t;
|
||||
using vec128_t = xe::vec128_t;
|
||||
|
||||
enum TypeName {
|
||||
// Many tables rely on this ordering.
|
||||
|
@ -102,7 +102,7 @@ class Value {
|
|||
// TODO(benvanik): remove to shrink size.
|
||||
void* tag;
|
||||
|
||||
Use* AddUse(poly::Arena* arena, Instr* instr);
|
||||
Use* AddUse(Arena* arena, Instr* instr);
|
||||
void RemoveUse(Use* use);
|
||||
|
||||
int8_t get_constant(int8_t) const { return constant.i8; }
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
#include "xenia/cpu/mmio_handler.h"
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "poly/byte_order.h"
|
||||
#include "poly/math.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/byte_order.h"
|
||||
#include "xenia/base/math.h"
|
||||
|
||||
namespace BE {
|
||||
#include <beaengine/BeaEngine.h>
|
||||
|
@ -230,7 +230,7 @@ bool MMIOHandler::HandleAccessFault(void* thread_state,
|
|||
// register.
|
||||
uint64_t value = range->read(range->context, fault_address & 0xFFFFFFFF);
|
||||
uint32_t be_reg_index;
|
||||
if (!poly::bit_scan_forward(arg1_type & 0xFFFF, &be_reg_index)) {
|
||||
if (!xe::bit_scan_forward(arg1_type & 0xFFFF, &be_reg_index)) {
|
||||
be_reg_index = 0;
|
||||
}
|
||||
uint64_t* reg_ptr = GetThreadStateRegPtr(thread_state, be_reg_index);
|
||||
|
@ -239,13 +239,13 @@ bool MMIOHandler::HandleAccessFault(void* thread_state,
|
|||
*reg_ptr = static_cast<uint8_t>(value);
|
||||
break;
|
||||
case 16:
|
||||
*reg_ptr = poly::byte_swap(static_cast<uint16_t>(value));
|
||||
*reg_ptr = xe::byte_swap(static_cast<uint16_t>(value));
|
||||
break;
|
||||
case 32:
|
||||
*reg_ptr = poly::byte_swap(static_cast<uint32_t>(value));
|
||||
*reg_ptr = xe::byte_swap(static_cast<uint32_t>(value));
|
||||
break;
|
||||
case 64:
|
||||
*reg_ptr = poly::byte_swap(static_cast<uint64_t>(value));
|
||||
*reg_ptr = xe::byte_swap(static_cast<uint64_t>(value));
|
||||
break;
|
||||
}
|
||||
} else if (is_store) {
|
||||
|
@ -253,7 +253,7 @@ bool MMIOHandler::HandleAccessFault(void* thread_state,
|
|||
uint64_t value;
|
||||
if ((arg2_type & BE::REGISTER_TYPE) == BE::REGISTER_TYPE) {
|
||||
uint32_t be_reg_index;
|
||||
if (!poly::bit_scan_forward(arg2_type & 0xFFFF, &be_reg_index)) {
|
||||
if (!xe::bit_scan_forward(arg2_type & 0xFFFF, &be_reg_index)) {
|
||||
be_reg_index = 0;
|
||||
}
|
||||
uint64_t* reg_ptr = GetThreadStateRegPtr(thread_state, be_reg_index);
|
||||
|
@ -269,13 +269,13 @@ bool MMIOHandler::HandleAccessFault(void* thread_state,
|
|||
value = static_cast<uint8_t>(value);
|
||||
break;
|
||||
case 16:
|
||||
value = poly::byte_swap(static_cast<uint16_t>(value));
|
||||
value = xe::byte_swap(static_cast<uint16_t>(value));
|
||||
break;
|
||||
case 32:
|
||||
value = poly::byte_swap(static_cast<uint32_t>(value));
|
||||
value = xe::byte_swap(static_cast<uint32_t>(value));
|
||||
break;
|
||||
case 64:
|
||||
value = poly::byte_swap(static_cast<uint64_t>(value));
|
||||
value = xe::byte_swap(static_cast<uint64_t>(value));
|
||||
break;
|
||||
}
|
||||
range->write(range->context, fault_address & 0xFFFFFFFF, value);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include <thread>
|
||||
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/base/logging.h"
|
||||
|
||||
// Mach internal function, not defined in any header.
|
||||
// http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/exc_server.html
|
||||
|
@ -117,7 +117,7 @@ void MachMMIOHandler::ThreadEntry() {
|
|||
listen_port_, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
|
||||
if (ret != MACH_MSG_SUCCESS) {
|
||||
XELOGE("mach_msg receive failed with %d %s", ret, mach_error_string(ret));
|
||||
poly::debugging::Break();
|
||||
xe::debugging::Break();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ void MachMMIOHandler::ThreadEntry() {
|
|||
MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE,
|
||||
MACH_PORT_NULL) != MACH_MSG_SUCCESS) {
|
||||
XELOGE("mach_msg reply send failed");
|
||||
poly::debugging::Break();
|
||||
xe::debugging::Break();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ kern_return_t CatchExceptionRaise(mach_port_t thread) {
|
|||
XELOGE("MMIO unhandled bad access for %llx, bubbling", fault_address);
|
||||
// TODO(benvanik): manipulate stack so that we can rip = break_handler or
|
||||
// something and have the stack trace be valid.
|
||||
poly::debugging::Break();
|
||||
xe::debugging::Break();
|
||||
|
||||
// When the thread resumes, kill it.
|
||||
thread_state.__rip = reinterpret_cast<uint64_t>(FailBadAccess);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "poly/threading.h"
|
||||
#include "xenia/base/threading.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
|
@ -37,7 +37,7 @@ SymbolInfo* Module::LookupSymbol(uint32_t address, bool wait) {
|
|||
do {
|
||||
lock_.unlock();
|
||||
// TODO(benvanik): sleep for less time?
|
||||
poly::threading::Sleep(std::chrono::microseconds(100));
|
||||
xe::threading::Sleep(std::chrono::microseconds(100));
|
||||
lock_.lock();
|
||||
} while (symbol_info->status() == SymbolInfo::STATUS_DECLARING);
|
||||
} else {
|
||||
|
@ -70,7 +70,7 @@ SymbolInfo::Status Module::DeclareSymbol(SymbolInfo::Type type,
|
|||
do {
|
||||
lock_.unlock();
|
||||
// TODO(benvanik): sleep for less time?
|
||||
poly::threading::Sleep(std::chrono::microseconds(100));
|
||||
xe::threading::Sleep(std::chrono::microseconds(100));
|
||||
lock_.lock();
|
||||
} while (symbol_info->status() == SymbolInfo::STATUS_DECLARING);
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ SymbolInfo::Status Module::DefineSymbol(SymbolInfo* symbol_info) {
|
|||
do {
|
||||
lock_.unlock();
|
||||
// TODO(benvanik): sleep for less time?
|
||||
poly::threading::Sleep(std::chrono::microseconds(100));
|
||||
xe::threading::Sleep(std::chrono::microseconds(100));
|
||||
lock_.lock();
|
||||
} while (symbol_info->status() == SymbolInfo::STATUS_DEFINING);
|
||||
status = symbol_info->status();
|
||||
|
|
|
@ -9,14 +9,14 @@
|
|||
|
||||
#include "xenia/cpu/processor.h"
|
||||
|
||||
#include "poly/atomic.h"
|
||||
#include "poly/byte_order.h"
|
||||
#include "poly/memory.h"
|
||||
#include "xenia/base/atomic.h"
|
||||
#include "xenia/base/byte_order.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/memory.h"
|
||||
#include "xenia/cpu/cpu-private.h"
|
||||
#include "xenia/cpu/export_resolver.h"
|
||||
#include "xenia/cpu/runtime.h"
|
||||
#include "xenia/cpu/xex_module.h"
|
||||
#include "xenia/logging.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
namespace xe {
|
||||
|
@ -151,12 +151,12 @@ uint64_t Processor::Execute(ThreadState* thread_state, uint32_t address,
|
|||
|
||||
Irql Processor::RaiseIrql(Irql new_value) {
|
||||
return static_cast<Irql>(
|
||||
poly::atomic_exchange(static_cast<uint32_t>(new_value),
|
||||
xe::atomic_exchange(static_cast<uint32_t>(new_value),
|
||||
reinterpret_cast<volatile uint32_t*>(&irql_)));
|
||||
}
|
||||
|
||||
void Processor::LowerIrql(Irql old_value) {
|
||||
poly::atomic_exchange(static_cast<uint32_t>(old_value),
|
||||
xe::atomic_exchange(static_cast<uint32_t>(old_value),
|
||||
reinterpret_cast<volatile uint32_t*>(&irql_));
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ uint64_t Processor::ExecuteInterrupt(uint32_t cpu, uint32_t address,
|
|||
std::lock_guard<std::mutex> lock(interrupt_thread_lock_);
|
||||
|
||||
// Set 0x10C(r13) to the current CPU ID.
|
||||
poly::store_and_swap<uint8_t>(
|
||||
xe::store_and_swap<uint8_t>(
|
||||
memory_->TranslateVirtual(interrupt_thread_block_ + 0x10C), cpu);
|
||||
|
||||
// Execute interrupt.
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
#include "xenia/cpu/raw_module.h"
|
||||
|
||||
#include "poly/platform.h"
|
||||
#include "poly/string.h"
|
||||
#include "xenia/base/platform.h"
|
||||
#include "xenia/base/string.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
@ -21,7 +21,7 @@ RawModule::RawModule(Runtime* runtime)
|
|||
RawModule::~RawModule() {}
|
||||
|
||||
int RawModule::LoadFile(uint32_t base_address, const std::wstring& path) {
|
||||
auto fixed_path = poly::to_string(poly::fix_path_separators(path));
|
||||
auto fixed_path = xe::to_string(xe::fix_path_separators(path));
|
||||
FILE* file = fopen(fixed_path.c_str(), "rb");
|
||||
fseek(file, 0, SEEK_END);
|
||||
uint32_t file_length = static_cast<uint32_t>(ftell(file));
|
||||
|
@ -39,7 +39,7 @@ int RawModule::LoadFile(uint32_t base_address, const std::wstring& path) {
|
|||
fclose(file);
|
||||
|
||||
// Setup debug info.
|
||||
auto last_slash = fixed_path.find_last_of(poly::path_separator);
|
||||
auto last_slash = fixed_path.find_last_of(xe::path_separator);
|
||||
if (last_slash != std::string::npos) {
|
||||
name_ = fixed_path.substr(last_slash + 1);
|
||||
} else {
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include "poly/assert.h"
|
||||
#include "xdb/protocol.h"
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/cpu/frontend/ppc_frontend.h"
|
||||
#include "xenia/cpu/module.h"
|
||||
#include "xenia/cpu/thread_state.h"
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue