From 59395318f360b662c49c8c9fd1062430a8854a90 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 22 Mar 2015 22:12:37 -0700 Subject: [PATCH] Moving some util types into poly. --- src/alloy/backend/x64/x64_assembler.cc | 6 +- src/alloy/backend/x64/x64_assembler.h | 6 +- src/alloy/backend/x64/x64_emitter.cc | 5 + src/alloy/backend/x64/x64_emitter.h | 5 +- src/alloy/backend/x64/x64_sequences.cc | 2 + src/alloy/compiler/compiler.h | 5 +- src/alloy/compiler/compiler_pass.cc | 2 +- src/alloy/compiler/compiler_pass.h | 3 +- src/alloy/frontend/ppc/ppc_context.h | 4 +- src/alloy/frontend/ppc/ppc_disasm.cc | 134 ++++++++++----------- src/alloy/frontend/ppc/ppc_disasm.h | 3 +- src/alloy/frontend/ppc/ppc_emit_altivec.cc | 4 + src/alloy/frontend/ppc/ppc_frontend.h | 4 +- src/alloy/frontend/ppc/ppc_hir_builder.h | 4 +- src/alloy/frontend/ppc/ppc_instr.cc | 4 +- src/alloy/frontend/ppc/ppc_instr.h | 6 +- src/alloy/frontend/ppc/ppc_instr_tables.h | 129 ++++++++++---------- src/alloy/frontend/ppc/ppc_translator.cc | 12 +- src/alloy/frontend/ppc/ppc_translator.h | 6 +- src/alloy/hir/block.h | 4 +- src/alloy/hir/hir_builder.cc | 21 ++-- src/alloy/hir/hir_builder.h | 17 ++- src/alloy/hir/value.cc | 2 +- src/alloy/hir/value.h | 8 +- src/alloy/runtime/function.cc | 1 + src/alloy/runtime/test_module.cc | 6 +- src/alloy/sources.gypi | 7 -- src/alloy/test/test_byte_swap.cc | 1 + src/alloy/test/test_extract.cc | 1 + src/alloy/test/test_insert.cc | 1 + src/alloy/test/test_load_vector_shl_shr.cc | 1 + src/alloy/test/test_pack.cc | 1 + src/alloy/test/test_permute.cc | 1 + src/alloy/test/test_shr.cc | 1 + src/alloy/test/test_swizzle.cc | 1 + src/alloy/test/test_unpack.cc | 1 + src/alloy/test/test_vector_add.cc | 1 + src/alloy/test/test_vector_max.cc | 1 + src/alloy/test/test_vector_min.cc | 1 + src/alloy/test/test_vector_rotate_left.cc | 1 + src/alloy/test/test_vector_sha.cc | 1 + src/alloy/test/test_vector_shl.cc | 1 + src/alloy/test/test_vector_shr.cc | 1 + src/{alloy => poly}/arena.cc | 14 ++- src/{alloy => poly}/arena.h | 10 +- src/poly/poly.h | 1 + src/{alloy => poly}/reset_scope.h | 10 +- src/poly/sources.gypi | 7 ++ src/{alloy => poly}/string_buffer.cc | 10 +- src/{alloy => poly}/string_buffer.h | 10 +- src/{alloy => poly}/type_pool.h | 10 +- src/{alloy => poly}/vec128.h | 12 +- src/xdb/protocol.h | 8 +- src/xenia/gpu/gl4/gl4_shader_translator.h | 4 +- 54 files changed, 280 insertions(+), 242 deletions(-) rename src/{alloy => poly}/arena.cc (91%) rename src/{alloy => poly}/arena.h (90%) rename src/{alloy => poly}/reset_scope.h (87%) rename src/{alloy => poly}/string_buffer.cc (92%) rename src/{alloy => poly}/string_buffer.h (88%) rename src/{alloy => poly}/type_pool.h (90%) rename src/{alloy => poly}/vec128.h (97%) diff --git a/src/alloy/backend/x64/x64_assembler.cc b/src/alloy/backend/x64/x64_assembler.cc index e57e85ef2..145191dfb 100644 --- a/src/alloy/backend/x64/x64_assembler.cc +++ b/src/alloy/backend/x64/x64_assembler.cc @@ -9,13 +9,13 @@ #include "alloy/backend/x64/x64_assembler.h" -#include "alloy/reset_scope.h" #include "alloy/backend/x64/x64_backend.h" #include "alloy/backend/x64/x64_emitter.h" #include "alloy/backend/x64/x64_function.h" #include "alloy/hir/hir_builder.h" #include "alloy/hir/label.h" #include "alloy/runtime/runtime.h" +#include "poly/reset_scope.h" #include "xenia/profiling.h" namespace BE { @@ -67,7 +67,7 @@ int X64Assembler::Assemble(FunctionInfo* symbol_info, HIRBuilder* builder, SCOPE_profile_cpu_f("alloy"); // Reset when we leave. - make_reset_scope(this); + poly::make_reset_scope(this); // Lower HIR -> x64. void* machine_code = 0; @@ -97,7 +97,7 @@ int X64Assembler::Assemble(FunctionInfo* symbol_info, HIRBuilder* builder, } void X64Assembler::DumpMachineCode(DebugInfo* debug_info, void* machine_code, - size_t code_size, StringBuffer* str) { + size_t code_size, poly::StringBuffer* str) { BE::DISASM disasm = {0}; disasm.Archi = 64; disasm.Options = BE::Tabulation + BE::MasmSyntax + BE::PrefixedNumeral; diff --git a/src/alloy/backend/x64/x64_assembler.h b/src/alloy/backend/x64/x64_assembler.h index 0eb9ad85e..fc94df4de 100644 --- a/src/alloy/backend/x64/x64_assembler.h +++ b/src/alloy/backend/x64/x64_assembler.h @@ -13,7 +13,7 @@ #include #include "alloy/backend/assembler.h" -#include "alloy/string_buffer.h" +#include "poly/string_buffer.h" namespace alloy { namespace backend { @@ -39,14 +39,14 @@ class X64Assembler : public Assembler { private: void DumpMachineCode(runtime::DebugInfo* debug_info, void* machine_code, - size_t code_size, StringBuffer* str); + size_t code_size, poly::StringBuffer* str); private: X64Backend* x64_backend_; std::unique_ptr emitter_; std::unique_ptr allocator_; - StringBuffer string_buffer_; + poly::StringBuffer string_buffer_; }; } // namespace x64 diff --git a/src/alloy/backend/x64/x64_emitter.cc b/src/alloy/backend/x64/x64_emitter.cc index 19b550271..d96192d84 100644 --- a/src/alloy/backend/x64/x64_emitter.cc +++ b/src/alloy/backend/x64/x64_emitter.cc @@ -20,6 +20,7 @@ #include "alloy/runtime/runtime.h" #include "alloy/runtime/symbol_info.h" #include "alloy/runtime/thread_state.h" +#include "poly/vec128.h" #include "xdb/protocol.h" #include "xenia/profiling.h" @@ -31,6 +32,10 @@ namespace x64 { using namespace alloy::hir; using namespace alloy::runtime; +using poly::vec128b; +using poly::vec128f; +using poly::vec128i; + using namespace Xbyak; using alloy::hir::HIRBuilder; using alloy::hir::Instr; diff --git a/src/alloy/backend/x64/x64_emitter.h b/src/alloy/backend/x64/x64_emitter.h index 7cb529684..1dd16d152 100644 --- a/src/alloy/backend/x64/x64_emitter.h +++ b/src/alloy/backend/x64/x64_emitter.h @@ -11,6 +11,7 @@ #define ALLOY_BACKEND_X64_X64_EMITTER_H_ #include "alloy/hir/value.h" +#include "poly/arena.h" #include "third_party/xbyak/xbyak/xbyak.h" namespace alloy { @@ -30,6 +31,8 @@ namespace alloy { namespace backend { namespace x64 { +using vec128_t = poly::vec128_t; + class X64Backend; class X64CodeCache; @@ -193,7 +196,7 @@ class X64Emitter : public Xbyak::CodeGenerator { hir::Instr* current_instr_; size_t source_map_count_; - Arena source_map_arena_; + poly::Arena source_map_arena_; size_t stack_size_; diff --git a/src/alloy/backend/x64/x64_sequences.cc b/src/alloy/backend/x64/x64_sequences.cc index c4e58df0d..f213658be 100644 --- a/src/alloy/backend/x64/x64_sequences.cc +++ b/src/alloy/backend/x64/x64_sequences.cc @@ -39,6 +39,8 @@ using namespace Xbyak; using namespace alloy::hir; using namespace alloy::runtime; +using poly::vec128b; + typedef bool (*SequenceSelectFn)(X64Emitter&, const Instr*, const Instr**); std::unordered_multimap sequence_table; diff --git a/src/alloy/compiler/compiler.h b/src/alloy/compiler/compiler.h index 15188f4d7..b0f2d2367 100644 --- a/src/alloy/compiler/compiler.h +++ b/src/alloy/compiler/compiler.h @@ -14,6 +14,7 @@ #include #include "alloy/hir/hir_builder.h" +#include "poly/arena.h" namespace alloy { namespace runtime { @@ -32,7 +33,7 @@ class Compiler { ~Compiler(); runtime::Runtime* runtime() const { return runtime_; } - Arena* scratch_arena() { return &scratch_arena_; } + poly::Arena* scratch_arena() { return &scratch_arena_; } void AddPass(std::unique_ptr pass); @@ -42,7 +43,7 @@ class Compiler { private: runtime::Runtime* runtime_; - Arena scratch_arena_; + poly::Arena scratch_arena_; std::vector> passes_; }; diff --git a/src/alloy/compiler/compiler_pass.cc b/src/alloy/compiler/compiler_pass.cc index bc6e580f7..c616129f2 100644 --- a/src/alloy/compiler/compiler_pass.cc +++ b/src/alloy/compiler/compiler_pass.cc @@ -24,7 +24,7 @@ int CompilerPass::Initialize(Compiler* compiler) { return 0; } -Arena* CompilerPass::scratch_arena() const { +poly::Arena* CompilerPass::scratch_arena() const { return compiler_->scratch_arena(); } diff --git a/src/alloy/compiler/compiler_pass.h b/src/alloy/compiler/compiler_pass.h index 14831665d..a3ff2a11e 100644 --- a/src/alloy/compiler/compiler_pass.h +++ b/src/alloy/compiler/compiler_pass.h @@ -11,6 +11,7 @@ #define ALLOY_COMPILER_COMPILER_PASS_H_ #include "alloy/hir/hir_builder.h" +#include "poly/arena.h" namespace alloy { namespace runtime { @@ -33,7 +34,7 @@ class CompilerPass { virtual int Run(hir::HIRBuilder* builder) = 0; protected: - Arena* scratch_arena() const; + poly::Arena* scratch_arena() const; protected: runtime::Runtime* runtime_; diff --git a/src/alloy/frontend/ppc/ppc_context.h b/src/alloy/frontend/ppc/ppc_context.h index a5c5f3719..2945d16a3 100644 --- a/src/alloy/frontend/ppc/ppc_context.h +++ b/src/alloy/frontend/ppc/ppc_context.h @@ -10,8 +10,8 @@ #ifndef ALLOY_FRONTEND_PPC_PPC_CONTEXT_H_ #define ALLOY_FRONTEND_PPC_PPC_CONTEXT_H_ -#include "alloy/vec128.h" #include "poly/poly.h" +#include "poly/vec128.h" namespace alloy { namespace runtime { class Runtime; @@ -22,7 +22,7 @@ namespace alloy { namespace frontend { namespace ppc { -using vec128_t = alloy::vec128_t; +using vec128_t = poly::vec128_t; // Map: // 0-31: GPR diff --git a/src/alloy/frontend/ppc/ppc_disasm.cc b/src/alloy/frontend/ppc/ppc_disasm.cc index e5ab6a12e..42b919499 100644 --- a/src/alloy/frontend/ppc/ppc_disasm.cc +++ b/src/alloy/frontend/ppc/ppc_disasm.cc @@ -10,61 +10,61 @@ #include "alloy/frontend/ppc/ppc_disasm.h" #include "poly/poly.h" -#include "alloy/string_buffer.h" +#include "poly/string_buffer.h" namespace alloy { namespace frontend { namespace ppc { -void Disasm_0(InstrData& i, StringBuffer* str) { +void Disasm_0(InstrData& i, poly::StringBuffer* str) { str->Append("%-8s ???", i.type->name); } -void Disasm__(InstrData& i, StringBuffer* str) { +void Disasm__(InstrData& i, poly::StringBuffer* str) { str->Append("%-8s", i.type->name); } -void Disasm_X_FRT_FRB(InstrData& i, StringBuffer* str) { +void Disasm_X_FRT_FRB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_A_FRT_FRB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_A_FRT_FRA_FRB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_A_FRT_FRA_FRB_FRC(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_X_RT_RA_RB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_X_RT_RA0_RB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_X_FRT_RA_RB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_X_FRT_RA0_RB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_D_RT_RA_I(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_D_RT_RA0_I(InstrData& i, poly::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)); @@ -73,11 +73,11 @@ void Disasm_D_RT_RA0_I(InstrData& i, StringBuffer* str) { (int32_t)(int16_t)XEEXTS16(i.D.DS)); } } -void Disasm_D_FRT_RA_I(InstrData& i, StringBuffer* str) { +void Disasm_D_FRT_RA_I(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_D_FRT_RA0_I(InstrData& i, poly::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)); @@ -86,11 +86,11 @@ void Disasm_D_FRT_RA0_I(InstrData& i, StringBuffer* str) { (int32_t)(int16_t)XEEXTS16(i.D.DS)); } } -void Disasm_DS_RT_RA_I(InstrData& i, StringBuffer* str) { +void Disasm_DS_RT_RA_I(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_DS_RT_RA0_I(InstrData& i, poly::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)); @@ -99,29 +99,29 @@ void Disasm_DS_RT_RA0_I(InstrData& i, StringBuffer* str) { (int32_t)(int16_t)XEEXTS16(i.DS.DS << 2)); } } -void Disasm_D_RA(InstrData& i, StringBuffer* str) { +void Disasm_D_RA(InstrData& i, poly::StringBuffer* str) { str->Append("%-8s r%d", i.type->name, i.D.RA); } -void Disasm_X_RA_RB(InstrData& i, StringBuffer* str) { +void Disasm_X_RA_RB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_XO_RT_RA_RB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_XO_RT_RA(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_X_RA_RT_RB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_D_RA_RT_I(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_X_RA_RT(InstrData& i, poly::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); } @@ -160,14 +160,14 @@ void Disasm_X_RA_RT(InstrData& i, 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, StringBuffer* str) { +void Disasm_X_VX_RA0_RB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_VX1281_VD_RA0_RB(InstrData& i, poly::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, @@ -176,45 +176,45 @@ void Disasm_VX1281_VD_RA0_RB(InstrData& i, 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, StringBuffer* str) { +void Disasm_VX1283_VD_VB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_VX1283_VD_VB_I(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_VX_VD_VA_VB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_VX128_VD_VA_VB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_VX128_VD_VA_VD_VB(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_VX1282_VD_VA_VB_VC(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_VXA_VD_VA_VB_VC(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_sync(InstrData& i, poly::StringBuffer* str) { const char* name; int L = i.X.RT & 3; switch (L) { @@ -233,7 +233,7 @@ void Disasm_sync(InstrData& i, StringBuffer* str) { str->Append("%-8s %.2X", name, L); } -void Disasm_dcbf(InstrData& i, StringBuffer* str) { +void Disasm_dcbf(InstrData& i, poly::StringBuffer* str) { const char* name; switch (i.X.RT & 3) { case 0: @@ -255,7 +255,7 @@ void Disasm_dcbf(InstrData& i, StringBuffer* str) { str->Append("%-8s r%d, r%d", name, i.X.RA, i.X.RB); } -void Disasm_dcbz(InstrData& i, StringBuffer* str) { +void Disasm_dcbz(InstrData& i, poly::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); @@ -264,16 +264,16 @@ void Disasm_dcbz(InstrData& i, StringBuffer* str) { } } -void Disasm_fcmp(InstrData& i, StringBuffer* str) { +void Disasm_fcmp(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_mffsx(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_bx(InstrData& i, poly::StringBuffer* str) { const char* name = i.I.LK ? "bl" : "b"; uint32_t nia; if (i.I.AA) { @@ -284,7 +284,7 @@ void Disasm_bx(InstrData& i, StringBuffer* str) { str->Append("%-8s %.8X", name, nia); // TODO(benvanik): resolve target name? } -void Disasm_bcx(InstrData& i, StringBuffer* str) { +void Disasm_bcx(InstrData& i, poly::StringBuffer* str) { const char* s0 = i.B.LK ? "lr, " : ""; const char* s1; if (!select_bits(i.B.BO, 2, 2)) { @@ -305,7 +305,7 @@ void Disasm_bcx(InstrData& i, 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, StringBuffer* str) { +void Disasm_bcctrx(InstrData& i, poly::StringBuffer* str) { // TODO(benvanik): mnemonics const char* s0 = i.XL.LK ? "lr, " : ""; char s2[8] = {0}; @@ -315,7 +315,7 @@ void Disasm_bcctrx(InstrData& i, StringBuffer* str) { str->Append("%-8s %s%sctr", i.type->name, s0, s2); // TODO(benvanik): resolve target name? } -void Disasm_bclrx(InstrData& i, StringBuffer* str) { +void Disasm_bclrx(InstrData& i, poly::StringBuffer* str) { const char* name = "bclr"; if (i.code == 0x4E800020) { name = "blr"; @@ -333,7 +333,7 @@ void Disasm_bclrx(InstrData& i, StringBuffer* str) { str->Append("%-8s %s%s", name, s1, s2); } -void Disasm_mfcr(InstrData& i, StringBuffer* str) { +void Disasm_mfcr(InstrData& i, poly::StringBuffer* str) { str->Append("%-8s r%d, cr", i.type->name, i.X.RT); } const char* Disasm_spr_name(uint32_t n) { @@ -351,40 +351,40 @@ const char* Disasm_spr_name(uint32_t n) { } return reg; } -void Disasm_mfspr(InstrData& i, StringBuffer* str) { +void Disasm_mfspr(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_mtspr(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_mftb(InstrData& i, poly::StringBuffer* str) { str->Append("%-8s r%d, tb", i.type->name, i.XFX.RT); } -void Disasm_mfmsr(InstrData& i, StringBuffer* str) { +void Disasm_mfmsr(InstrData& i, poly::StringBuffer* str) { str->Append("%-8s r%d", i.type->name, i.X.RT); } -void Disasm_mtmsr(InstrData& i, StringBuffer* str) { +void Disasm_mtmsr(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_cmp(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_cmpi(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_cmpli(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_rld(InstrData& i, poly::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", @@ -421,75 +421,75 @@ void Disasm_rld(InstrData& i, StringBuffer* str) { assert_always(); } } -void Disasm_rlwim(InstrData& i, StringBuffer* str) { +void Disasm_rlwim(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_rlwnmx(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_srawix(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_sradix(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_vpermwi128(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_vrfin128(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_vrlimi128(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_vsldoi128(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_vspltb(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_vsplth(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_vspltw(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_vspltisb(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_vspltish(InstrData& i, poly::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, StringBuffer* str) { +void Disasm_vspltisw(InstrData& i, poly::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, StringBuffer* str) { +int DisasmPPC(InstrData& i, poly::StringBuffer* str) { if (!i.type) { str->Append("???"); } else { diff --git a/src/alloy/frontend/ppc/ppc_disasm.h b/src/alloy/frontend/ppc/ppc_disasm.h index 89e232349..a43dbf4fa 100644 --- a/src/alloy/frontend/ppc/ppc_disasm.h +++ b/src/alloy/frontend/ppc/ppc_disasm.h @@ -11,12 +11,13 @@ #define ALLOY_FRONTEND_PPC_PPC_DISASM_H_ #include "alloy/frontend/ppc/ppc_instr.h" +#include "poly/string_buffer.h" namespace alloy { namespace frontend { namespace ppc { -int DisasmPPC(InstrData& i, StringBuffer* str); +int DisasmPPC(InstrData& i, poly::StringBuffer* str); } // namespace ppc } // namespace frontend diff --git a/src/alloy/frontend/ppc/ppc_emit_altivec.cc b/src/alloy/frontend/ppc/ppc_emit_altivec.cc index 0f8dce4ac..81c8444e2 100644 --- a/src/alloy/frontend/ppc/ppc_emit_altivec.cc +++ b/src/alloy/frontend/ppc/ppc_emit_altivec.cc @@ -18,6 +18,10 @@ namespace ppc { // TODO(benvanik): remove when enums redefined. using namespace alloy::hir; +using poly::vec128b; +using poly::vec128f; +using poly::vec128i; +using poly::vec128s; using alloy::hir::Value; diff --git a/src/alloy/frontend/ppc/ppc_frontend.h b/src/alloy/frontend/ppc/ppc_frontend.h index cec21f286..99b9a8ae1 100644 --- a/src/alloy/frontend/ppc/ppc_frontend.h +++ b/src/alloy/frontend/ppc/ppc_frontend.h @@ -13,7 +13,7 @@ #include #include "alloy/frontend/frontend.h" -#include "alloy/type_pool.h" +#include "poly/type_pool.h" namespace alloy { namespace frontend { @@ -43,7 +43,7 @@ class PPCFrontend : public Frontend { runtime::Function** out_function) override; private: - TypePool translator_pool_; + poly::TypePool translator_pool_; PPCBuiltins builtins_; }; diff --git a/src/alloy/frontend/ppc/ppc_hir_builder.h b/src/alloy/frontend/ppc/ppc_hir_builder.h index 59c694ef9..440f8d2d9 100644 --- a/src/alloy/frontend/ppc/ppc_hir_builder.h +++ b/src/alloy/frontend/ppc/ppc_hir_builder.h @@ -13,7 +13,7 @@ #include "alloy/hir/hir_builder.h" #include "alloy/runtime/function.h" #include "alloy/runtime/symbol_info.h" -#include "alloy/string_buffer.h" +#include "poly/string_buffer.h" namespace alloy { namespace frontend { @@ -91,7 +91,7 @@ class PPCHIRBuilder : public hir::HIRBuilder { PPCFrontend* frontend_; // Reset whenever needed: - StringBuffer comment_buffer_; + poly::StringBuffer comment_buffer_; // Reset each Emit: bool with_debug_info_; diff --git a/src/alloy/frontend/ppc/ppc_instr.cc b/src/alloy/frontend/ppc/ppc_instr.cc index 5551d9cd0..9c03171a2 100644 --- a/src/alloy/frontend/ppc/ppc_instr.cc +++ b/src/alloy/frontend/ppc/ppc_instr.cc @@ -13,8 +13,8 @@ #include #include "alloy/frontend/ppc/ppc_instr_tables.h" -#include "alloy/string_buffer.h" #include "poly/poly.h" +#include "poly/string_buffer.h" namespace alloy { namespace frontend { @@ -23,7 +23,7 @@ namespace ppc { std::vector all_instrs_; void DumpAllInstrCounts() { - StringBuffer sb; + poly::StringBuffer sb; sb.Append("Instruction translation counts:\n"); for (auto instr_type : all_instrs_) { if (instr_type->translation_count) { diff --git a/src/alloy/frontend/ppc/ppc_instr.h b/src/alloy/frontend/ppc/ppc_instr.h index 709d552c1..6f5ce2a12 100644 --- a/src/alloy/frontend/ppc/ppc_instr.h +++ b/src/alloy/frontend/ppc/ppc_instr.h @@ -14,9 +14,7 @@ #include #include -namespace alloy { -class StringBuffer; -} // namespace alloy +#include "poly/string_buffer.h" namespace alloy { namespace frontend { @@ -549,7 +547,7 @@ class InstrDisasm { void Dump(std::string& out_str, size_t pad = 13); }; -typedef void (*InstrDisasmFn)(InstrData& i, StringBuffer* str); +typedef void (*InstrDisasmFn)(InstrData& i, poly::StringBuffer* str); typedef void* InstrEmitFn; class InstrType { diff --git a/src/alloy/frontend/ppc/ppc_instr_tables.h b/src/alloy/frontend/ppc/ppc_instr_tables.h index 26fa9815b..6349e0b38 100644 --- a/src/alloy/frontend/ppc/ppc_instr_tables.h +++ b/src/alloy/frontend/ppc/ppc_instr_tables.h @@ -14,81 +14,82 @@ #include "alloy/frontend/ppc/ppc_instr.h" #include "poly/poly.h" +#include "poly/string_buffer.h" namespace alloy { namespace frontend { namespace ppc { -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_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_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_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_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_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_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_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_cmp(InstrData& i, StringBuffer* str); -void Disasm_cmpi(InstrData& i, StringBuffer* str); -void Disasm_cmpli(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_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_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_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); +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); namespace tables { diff --git a/src/alloy/frontend/ppc/ppc_translator.cc b/src/alloy/frontend/ppc/ppc_translator.cc index 8b3fc152f..4a6f2d1bd 100644 --- a/src/alloy/frontend/ppc/ppc_translator.cc +++ b/src/alloy/frontend/ppc/ppc_translator.cc @@ -16,8 +16,8 @@ #include "alloy/frontend/ppc/ppc_hir_builder.h" #include "alloy/frontend/ppc/ppc_instr.h" #include "alloy/frontend/ppc/ppc_scanner.h" -#include "alloy/reset_scope.h" #include "alloy/runtime/runtime.h" +#include "poly/reset_scope.h" #include "xenia/profiling.h" namespace alloy { @@ -91,10 +91,10 @@ int PPCTranslator::Translate(FunctionInfo* symbol_info, SCOPE_profile_cpu_f("alloy"); // Reset() all caching when we leave. - make_reset_scope(builder_); - make_reset_scope(compiler_); - make_reset_scope(assembler_); - make_reset_scope(&string_buffer_); + poly::make_reset_scope(builder_); + poly::make_reset_scope(compiler_); + poly::make_reset_scope(assembler_); + poly::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. @@ -175,7 +175,7 @@ int PPCTranslator::Translate(FunctionInfo* symbol_info, }; void PPCTranslator::DumpSource(runtime::FunctionInfo* symbol_info, - StringBuffer* string_buffer) { + poly::StringBuffer* string_buffer) { Memory* memory = frontend_->memory(); const uint8_t* p = memory->membase(); diff --git a/src/alloy/frontend/ppc/ppc_translator.h b/src/alloy/frontend/ppc/ppc_translator.h index d18dbb1a6..0258939c5 100644 --- a/src/alloy/frontend/ppc/ppc_translator.h +++ b/src/alloy/frontend/ppc/ppc_translator.h @@ -15,7 +15,7 @@ #include "alloy/backend/assembler.h" #include "alloy/compiler/compiler.h" #include "alloy/runtime/symbol_info.h" -#include "alloy/string_buffer.h" +#include "poly/string_buffer.h" namespace alloy { namespace frontend { @@ -35,7 +35,7 @@ class PPCTranslator { private: void DumpSource(runtime::FunctionInfo* symbol_info, - StringBuffer* string_buffer); + poly::StringBuffer* string_buffer); private: PPCFrontend* frontend_; @@ -44,7 +44,7 @@ class PPCTranslator { std::unique_ptr compiler_; std::unique_ptr assembler_; - StringBuffer string_buffer_; + poly::StringBuffer string_buffer_; }; } // namespace ppc diff --git a/src/alloy/hir/block.h b/src/alloy/hir/block.h index 668b5e7f7..83ec23f06 100644 --- a/src/alloy/hir/block.h +++ b/src/alloy/hir/block.h @@ -10,7 +10,7 @@ #ifndef ALLOY_HIR_BLOCK_H_ #define ALLOY_HIR_BLOCK_H_ -#include "alloy/arena.h" +#include "poly/arena.h" namespace llvm { class BitVector; @@ -45,7 +45,7 @@ class Edge { class Block { public: - Arena* arena; + poly::Arena* arena; Block* next; Block* prev; diff --git a/src/alloy/hir/hir_builder.cc b/src/alloy/hir/hir_builder.cc index 6eb3f5cc2..96c7fe526 100644 --- a/src/alloy/hir/hir_builder.cc +++ b/src/alloy/hir/hir_builder.cc @@ -13,7 +13,6 @@ #include "alloy/hir/instr.h" #include "alloy/hir/label.h" #include "alloy/runtime/symbol_info.h" -#include "alloy/string_buffer.h" #include "xenia/profiling.h" namespace alloy { @@ -30,7 +29,7 @@ using alloy::runtime::FunctionInfo; assert_true((value1->type) == (value2->type)) HIRBuilder::HIRBuilder() { - arena_ = new Arena(); + arena_ = new poly::Arena(); Reset(); } @@ -90,7 +89,7 @@ int HIRBuilder::Finalize() { return 0; } -void HIRBuilder::DumpValue(StringBuffer* str, Value* value) { +void HIRBuilder::DumpValue(poly::StringBuffer* str, Value* value) { if (value->IsConstant()) { switch (value->type) { case INT8_TYPE: @@ -131,7 +130,7 @@ void HIRBuilder::DumpValue(StringBuffer* str, Value* value) { } } -void HIRBuilder::DumpOp(StringBuffer* str, OpcodeSignatureType sig_type, +void HIRBuilder::DumpOp(poly::StringBuffer* str, OpcodeSignatureType sig_type, Instr::Op* op) { switch (sig_type) { case OPCODE_SIG_TYPE_X: @@ -158,7 +157,7 @@ void HIRBuilder::DumpOp(StringBuffer* str, OpcodeSignatureType sig_type, } } -void HIRBuilder::Dump(StringBuffer* str) { +void HIRBuilder::Dump(poly::StringBuffer* str) { SCOPE_profile_cpu_f("alloy"); if (attributes_) { @@ -1910,12 +1909,12 @@ Value* HIRBuilder::Pack(Value* value1, Value* value2, uint32_t pack_flags) { ASSERT_VECTOR_TYPE(value1); ASSERT_VECTOR_TYPE(value2); switch (pack_flags & PACK_TYPE_MODE) { - case PACK_TYPE_D3DCOLOR: - case PACK_TYPE_FLOAT16_2: - case PACK_TYPE_FLOAT16_4: - case PACK_TYPE_SHORT_2: - assert_true(value2->IsConstantZero()); - break; + case PACK_TYPE_D3DCOLOR: + case PACK_TYPE_FLOAT16_2: + case PACK_TYPE_FLOAT16_4: + case PACK_TYPE_SHORT_2: + assert_true(value2->IsConstantZero()); + break; } Instr* i = AppendInstr(OPCODE_PACK_info, pack_flags, AllocValue(VEC128_TYPE)); i->set_src1(value1); diff --git a/src/alloy/hir/hir_builder.h b/src/alloy/hir/hir_builder.h index aac4b9c99..97da4aaa5 100644 --- a/src/alloy/hir/hir_builder.h +++ b/src/alloy/hir/hir_builder.h @@ -17,10 +17,8 @@ #include "alloy/hir/label.h" #include "alloy/hir/opcodes.h" #include "alloy/hir/value.h" - -namespace alloy { -class StringBuffer; -} // namespace alloy +#include "poly/arena.h" +#include "poly/string_buffer.h" namespace alloy { namespace hir { @@ -37,10 +35,10 @@ class HIRBuilder { virtual void Reset(); virtual int Finalize(); - void Dump(StringBuffer* str); + void Dump(poly::StringBuffer* str); void AssertNoCycles(); - Arena* arena() const { return arena_; } + poly::Arena* arena() const { return arena_; } uint32_t attributes() const { return attributes_; } void set_attributes(uint32_t value) { attributes_ = value; } @@ -230,8 +228,9 @@ class HIRBuilder { Value* AtomicSub(Value* address, Value* value); protected: - void DumpValue(StringBuffer* str, Value* value); - void DumpOp(StringBuffer* str, OpcodeSignatureType sig_type, Instr::Op* op); + void DumpValue(poly::StringBuffer* str, Value* value); + void DumpOp(poly::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: - Arena* arena_; + poly::Arena* arena_; uint32_t attributes_; diff --git a/src/alloy/hir/value.cc b/src/alloy/hir/value.cc index b118bcf31..6c443e575 100644 --- a/src/alloy/hir/value.cc +++ b/src/alloy/hir/value.cc @@ -14,7 +14,7 @@ namespace alloy { namespace hir { -Value::Use* Value::AddUse(Arena* arena, Instr* instr) { +Value::Use* Value::AddUse(poly::Arena* arena, Instr* instr) { Use* use = arena->Alloc(); use->instr = instr; use->prev = NULL; diff --git a/src/alloy/hir/value.h b/src/alloy/hir/value.h index 58ada49f3..634bb61c1 100644 --- a/src/alloy/hir/value.h +++ b/src/alloy/hir/value.h @@ -10,17 +10,19 @@ #ifndef ALLOY_HIR_VALUE_H_ #define ALLOY_HIR_VALUE_H_ -#include "alloy/arena.h" #include "alloy/backend/machine_info.h" #include "alloy/hir/opcodes.h" -#include "alloy/vec128.h" +#include "poly/arena.h" #include "poly/poly.h" +#include "poly/vec128.h" namespace alloy { namespace hir { class Instr; +using vec128_t = poly::vec128_t; + enum TypeName { // Many tables rely on this ordering. INT8_TYPE = 0, @@ -99,7 +101,7 @@ class Value { // TODO(benvanik): remove to shrink size. void* tag; - Use* AddUse(Arena* arena, Instr* instr); + Use* AddUse(poly::Arena* arena, Instr* instr); void RemoveUse(Use* use); int8_t get_constant(int8_t) const { return constant.i8; } diff --git a/src/alloy/runtime/function.cc b/src/alloy/runtime/function.cc index 2fee66490..41141f218 100644 --- a/src/alloy/runtime/function.cc +++ b/src/alloy/runtime/function.cc @@ -12,6 +12,7 @@ #include "alloy/runtime/debugger.h" #include "alloy/runtime/symbol_info.h" #include "alloy/runtime/thread_state.h" +#include "poly/logging.h" #include "xdb/protocol.h" namespace alloy { diff --git a/src/alloy/runtime/test_module.cc b/src/alloy/runtime/test_module.cc index ce204ff65..8793e448d 100644 --- a/src/alloy/runtime/test_module.cc +++ b/src/alloy/runtime/test_module.cc @@ -10,9 +10,9 @@ #include "alloy/runtime/test_module.h" #include "alloy/compiler/compiler_passes.h" -#include "alloy/reset_scope.h" #include "alloy/runtime/runtime.h" #include "poly/platform.h" +#include "poly/reset_scope.h" #include "poly/string.h" namespace alloy { @@ -79,8 +79,8 @@ SymbolInfo::Status TestModule::DeclareFunction(uint64_t address, auto symbol_info = *out_symbol_info; // Reset() all caching when we leave. - make_reset_scope(compiler_); - make_reset_scope(assembler_); + poly::make_reset_scope(compiler_); + poly::make_reset_scope(assembler_); if (!generate_(*builder_.get())) { symbol_info->set_status(SymbolInfo::STATUS_FAILED); diff --git a/src/alloy/sources.gypi b/src/alloy/sources.gypi index 18b7c409f..cea450cc8 100644 --- a/src/alloy/sources.gypi +++ b/src/alloy/sources.gypi @@ -4,15 +4,8 @@ 'alloy-private.h', 'alloy.cc', 'alloy.h', - 'arena.cc', - 'arena.h', 'memory.cc', 'memory.h', - 'reset_scope.h', - 'string_buffer.cc', - 'string_buffer.h', - 'type_pool.h', - 'vec128.h', ], 'conditions': [ diff --git a/src/alloy/test/test_byte_swap.cc b/src/alloy/test/test_byte_swap.cc index 74154275b..9ea221f48 100644 --- a/src/alloy/test/test_byte_swap.cc +++ b/src/alloy/test/test_byte_swap.cc @@ -14,6 +14,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("BYTE_SWAP_V128", "[instr]") { TestFunction([](hir::HIRBuilder& b) { diff --git a/src/alloy/test/test_extract.cc b/src/alloy/test/test_extract.cc index 3dacd2e89..2e289709a 100644 --- a/src/alloy/test/test_extract.cc +++ b/src/alloy/test/test_extract.cc @@ -16,6 +16,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("EXTRACT_INT8", "[instr]") { TestFunction test([](hir::HIRBuilder& b) { diff --git a/src/alloy/test/test_insert.cc b/src/alloy/test/test_insert.cc index 811a6b93a..619602b00 100644 --- a/src/alloy/test/test_insert.cc +++ b/src/alloy/test/test_insert.cc @@ -16,6 +16,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("INSERT_INT8", "[instr]") { for (int i = 0; i < 16; ++i) { diff --git a/src/alloy/test/test_load_vector_shl_shr.cc b/src/alloy/test/test_load_vector_shl_shr.cc index 9d6d790db..678144afb 100644 --- a/src/alloy/test/test_load_vector_shl_shr.cc +++ b/src/alloy/test/test_load_vector_shl_shr.cc @@ -14,6 +14,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("LOAD_VECTOR_SHL", "[instr]") { TestFunction test([](hir::HIRBuilder& b) { diff --git a/src/alloy/test/test_pack.cc b/src/alloy/test/test_pack.cc index c6547b557..2d7b6fab7 100644 --- a/src/alloy/test/test_pack.cc +++ b/src/alloy/test/test_pack.cc @@ -14,6 +14,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("PACK_D3DCOLOR", "[instr]") { TestFunction test([](hir::HIRBuilder& b) { diff --git a/src/alloy/test/test_permute.cc b/src/alloy/test/test_permute.cc index 58192331d..3432b0817 100644 --- a/src/alloy/test/test_permute.cc +++ b/src/alloy/test/test_permute.cc @@ -14,6 +14,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("PERMUTE_V128_BY_INT32_CONSTANT", "[instr]") { { diff --git a/src/alloy/test/test_shr.cc b/src/alloy/test/test_shr.cc index 81bd55afc..bed3cf549 100644 --- a/src/alloy/test/test_shr.cc +++ b/src/alloy/test/test_shr.cc @@ -14,6 +14,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("SHR_I8", "[instr]") { TestFunction test([](hir::HIRBuilder& b) { diff --git a/src/alloy/test/test_swizzle.cc b/src/alloy/test/test_swizzle.cc index be6874701..341fcc9ae 100644 --- a/src/alloy/test/test_swizzle.cc +++ b/src/alloy/test/test_swizzle.cc @@ -14,6 +14,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("SWIZZLE_V128", "[instr]") { TestFunction([](hir::HIRBuilder& b) { diff --git a/src/alloy/test/test_unpack.cc b/src/alloy/test/test_unpack.cc index 14557124c..5a8de821b 100644 --- a/src/alloy/test/test_unpack.cc +++ b/src/alloy/test/test_unpack.cc @@ -14,6 +14,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("UNPACK_D3DCOLOR", "[instr]") { TestFunction test([](hir::HIRBuilder& b) { diff --git a/src/alloy/test/test_vector_add.cc b/src/alloy/test/test_vector_add.cc index b23cc7ac1..5ff7095ce 100644 --- a/src/alloy/test/test_vector_add.cc +++ b/src/alloy/test/test_vector_add.cc @@ -16,6 +16,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("VECTOR_ADD_I8", "[instr]") { TestFunction test([](hir::HIRBuilder& b) { diff --git a/src/alloy/test/test_vector_max.cc b/src/alloy/test/test_vector_max.cc index 0d7ddfd71..2aa4cda2e 100644 --- a/src/alloy/test/test_vector_max.cc +++ b/src/alloy/test/test_vector_max.cc @@ -16,6 +16,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("VECTOR_MAX_I8_SIGNED", "[instr]") { TestFunction test([](hir::HIRBuilder& b) { diff --git a/src/alloy/test/test_vector_min.cc b/src/alloy/test/test_vector_min.cc index 6f981badf..31cf3c18f 100644 --- a/src/alloy/test/test_vector_min.cc +++ b/src/alloy/test/test_vector_min.cc @@ -16,6 +16,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("VECTOR_MIN_I8_SIGNED", "[instr]") { TestFunction test([](hir::HIRBuilder& b) { diff --git a/src/alloy/test/test_vector_rotate_left.cc b/src/alloy/test/test_vector_rotate_left.cc index 9d46ad7b9..80ba706c3 100644 --- a/src/alloy/test/test_vector_rotate_left.cc +++ b/src/alloy/test/test_vector_rotate_left.cc @@ -15,6 +15,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("VECTOR_ROTATE_LEFT_I8", "[instr]") { TestFunction test([](hir::HIRBuilder& b) { diff --git a/src/alloy/test/test_vector_sha.cc b/src/alloy/test/test_vector_sha.cc index 38a2accb6..97c7fa2ea 100644 --- a/src/alloy/test/test_vector_sha.cc +++ b/src/alloy/test/test_vector_sha.cc @@ -14,6 +14,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("VECTOR_SHA_I8", "[instr]") { TestFunction test([](hir::HIRBuilder& b) { diff --git a/src/alloy/test/test_vector_shl.cc b/src/alloy/test/test_vector_shl.cc index cda54e5b7..bdb0f3b9d 100644 --- a/src/alloy/test/test_vector_shl.cc +++ b/src/alloy/test/test_vector_shl.cc @@ -14,6 +14,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("VECTOR_SHL_I8", "[instr]") { TestFunction test([](hir::HIRBuilder& b) { diff --git a/src/alloy/test/test_vector_shr.cc b/src/alloy/test/test_vector_shr.cc index 1a73b9ec8..e0666e830 100644 --- a/src/alloy/test/test_vector_shr.cc +++ b/src/alloy/test/test_vector_shr.cc @@ -14,6 +14,7 @@ using namespace alloy::hir; using namespace alloy::runtime; using namespace alloy::test; using alloy::frontend::ppc::PPCContext; +using namespace poly; TEST_CASE("VECTOR_SHR_I8", "[instr]") { TestFunction test([](hir::HIRBuilder& b) { diff --git a/src/alloy/arena.cc b/src/poly/arena.cc similarity index 91% rename from src/alloy/arena.cc rename to src/poly/arena.cc index b80c60a33..ea655882a 100644 --- a/src/alloy/arena.cc +++ b/src/poly/arena.cc @@ -7,11 +7,13 @@ ****************************************************************************** */ -#include "alloy/arena.h" +#include "poly/arena.h" -#include "poly/poly.h" +#include -namespace alloy { +#include "poly/assert.h" + +namespace poly { Arena::Arena(size_t chunk_size) : chunk_size_(chunk_size), head_chunk_(nullptr), active_chunk_(nullptr) {} @@ -37,7 +39,7 @@ void Arena::Reset() { void Arena::DebugFill() { auto chunk = head_chunk_; while (chunk) { - memset(chunk->buffer, 0xCD, chunk->capacity); + std::memset(chunk->buffer, 0xCD, chunk->capacity); chunk = chunk->next; } } @@ -77,7 +79,7 @@ void* Arena::CloneContents() { uint8_t* p = (uint8_t*)result; chunk = head_chunk_; while (chunk) { - memcpy(p, chunk->buffer, chunk->offset); + std::memcpy(p, chunk->buffer, chunk->offset); p += chunk->offset; if (chunk == active_chunk_) { break; @@ -98,4 +100,4 @@ Arena::Chunk::~Chunk() { } } -} // namespace alloy +} // namespace poly diff --git a/src/alloy/arena.h b/src/poly/arena.h similarity index 90% rename from src/alloy/arena.h rename to src/poly/arena.h index 764dd31bf..1cc71df63 100644 --- a/src/alloy/arena.h +++ b/src/poly/arena.h @@ -7,13 +7,13 @@ ****************************************************************************** */ -#ifndef ALLOY_ARENA_H_ -#define ALLOY_ARENA_H_ +#ifndef POLY_ARENA_H_ +#define POLY_ARENA_H_ #include #include -namespace alloy { +namespace poly { class Arena { public: @@ -50,6 +50,6 @@ class Arena { Chunk* active_chunk_; }; -} // namespace alloy +} // namespace poly -#endif // ALLOY_ARENA_H_ +#endif // POLY_ARENA_H_ diff --git a/src/poly/poly.h b/src/poly/poly.h index c379d6697..a996ca06d 100644 --- a/src/poly/poly.h +++ b/src/poly/poly.h @@ -23,6 +23,7 @@ #include "poly/platform.h" #include "poly/string.h" #include "poly/threading.h" +#include "poly/vec128.h" namespace poly {} // namespace poly diff --git a/src/alloy/reset_scope.h b/src/poly/reset_scope.h similarity index 87% rename from src/alloy/reset_scope.h rename to src/poly/reset_scope.h index 1007b1e25..caff320b8 100644 --- a/src/alloy/reset_scope.h +++ b/src/poly/reset_scope.h @@ -7,12 +7,12 @@ ****************************************************************************** */ -#ifndef ALLOY_RESET_SCOPE_H_ -#define ALLOY_RESET_SCOPE_H_ +#ifndef POLY_RESET_SCOPE_H_ +#define POLY_RESET_SCOPE_H_ #include -namespace alloy { +namespace poly { template class ResetScope { @@ -38,6 +38,6 @@ inline ResetScope make_reset_scope(const std::unique_ptr& value) { return ResetScope(value.get()); } -} // namespace alloy +} // namespace poly -#endif // ALLOY_RESET_SCOPE_H_ +#endif // POLY_RESET_SCOPE_H_ diff --git a/src/poly/sources.gypi b/src/poly/sources.gypi index 031932879..e41d21672 100644 --- a/src/poly/sources.gypi +++ b/src/poly/sources.gypi @@ -1,6 +1,8 @@ # Copyright 2014 Ben Vanik. All Rights Reserved. { 'sources': [ + 'arena.cc', + 'arena.h', 'assert.h', 'atomic.h', 'byte_order.h', @@ -20,10 +22,15 @@ 'memory.h', 'platform.h', 'poly.h', + 'reset_scope.h', 'string.cc', 'string.h', + 'string_buffer.cc', + 'string_buffer.h', 'threading.cc', 'threading.h', + 'type_pool.h', + 'vec128.h', ], 'conditions': [ diff --git a/src/alloy/string_buffer.cc b/src/poly/string_buffer.cc similarity index 92% rename from src/alloy/string_buffer.cc rename to src/poly/string_buffer.cc index bd2f9d35b..44613ea71 100644 --- a/src/alloy/string_buffer.cc +++ b/src/poly/string_buffer.cc @@ -7,12 +7,12 @@ ****************************************************************************** */ -#include "alloy/string_buffer.h" +#include "poly/string_buffer.h" #include #include -namespace alloy { +namespace poly { StringBuffer::StringBuffer(size_t initial_capacity) { buffer_.reserve(std::max(initial_capacity, static_cast(1024))); @@ -62,8 +62,10 @@ void StringBuffer::AppendBytes(const uint8_t* buffer, size_t length) { const char* StringBuffer::GetString() const { return buffer_.data(); } -std::string StringBuffer::to_string() { return std::string(buffer_.data(), buffer_.size()); } +std::string StringBuffer::to_string() { + return std::string(buffer_.data(), buffer_.size()); +} char* StringBuffer::ToString() { return strdup(buffer_.data()); } -} // namespace alloy +} // namespace poly diff --git a/src/alloy/string_buffer.h b/src/poly/string_buffer.h similarity index 88% rename from src/alloy/string_buffer.h rename to src/poly/string_buffer.h index 549ddfe7a..bdc1f7a3e 100644 --- a/src/alloy/string_buffer.h +++ b/src/poly/string_buffer.h @@ -7,14 +7,14 @@ ****************************************************************************** */ -#ifndef ALLOY_STRING_BUFFER_H_ -#define ALLOY_STRING_BUFFER_H_ +#ifndef POLY_STRING_BUFFER_H_ +#define POLY_STRING_BUFFER_H_ #include #include #include -namespace alloy { +namespace poly { class StringBuffer { public: @@ -41,6 +41,6 @@ class StringBuffer { std::vector buffer_; }; -} // namespace alloy +} // namespace poly -#endif // ALLOY_STRING_BUFFER_H_ +#endif // POLY_STRING_BUFFER_H_ diff --git a/src/alloy/type_pool.h b/src/poly/type_pool.h similarity index 90% rename from src/alloy/type_pool.h rename to src/poly/type_pool.h index 3ba2bd754..1f29a5c39 100644 --- a/src/alloy/type_pool.h +++ b/src/poly/type_pool.h @@ -7,13 +7,13 @@ ****************************************************************************** */ -#ifndef ALLOY_TYPE_POOL_H_ -#define ALLOY_TYPE_POOL_H_ +#ifndef POLY_TYPE_POOL_H_ +#define POLY_TYPE_POOL_H_ #include #include -namespace alloy { +namespace poly { template class TypePool { @@ -54,6 +54,6 @@ class TypePool { std::vector list_; }; -} // namespace alloy +} // namespace poly -#endif // ALLOY_TYPE_POOL_H_ +#endif // POLY_TYPE_POOL_H_ diff --git a/src/alloy/vec128.h b/src/poly/vec128.h similarity index 97% rename from src/alloy/vec128.h rename to src/poly/vec128.h index 391178550..f317dfa54 100644 --- a/src/alloy/vec128.h +++ b/src/poly/vec128.h @@ -7,12 +7,12 @@ ****************************************************************************** */ -#ifndef ALLOY_VEC128_H_ -#define ALLOY_VEC128_H_ +#ifndef POLY_VEC128_H_ +#define POLY_VEC128_H_ -#include "poly/poly.h" +#include -namespace alloy { +namespace poly { // The first rule of vector programming is to only rely on exact positions // when absolutely required - prefer dumb loops to exact offsets. @@ -191,6 +191,6 @@ static inline vec128_t vec128b(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, return v; } -} // namespace alloy +} // namespace poly -#endif // ALLOY_VEC128_H_ +#endif // POLY_VEC128_H_ diff --git a/src/xdb/protocol.h b/src/xdb/protocol.h index 85536ab9f..585a2b853 100644 --- a/src/xdb/protocol.h +++ b/src/xdb/protocol.h @@ -12,13 +12,13 @@ #include -#include -#include +#include "poly/atomic.h" +#include "poly/vec128.h" namespace xdb { namespace protocol { -using vec128_t = alloy::vec128_t; +using vec128_t = poly::vec128_t; #pragma pack(push, 4) @@ -96,7 +96,7 @@ struct Registers { uint32_t vscr; uint64_t gpr[32]; double fpr[32]; - alloy::vec128_t vr[128]; + poly::vec128_t vr[128]; }; struct ThreadCreateEvent : public Event { diff --git a/src/xenia/gpu/gl4/gl4_shader_translator.h b/src/xenia/gpu/gl4/gl4_shader_translator.h index 8684f3787..ef6032680 100644 --- a/src/xenia/gpu/gl4/gl4_shader_translator.h +++ b/src/xenia/gpu/gl4/gl4_shader_translator.h @@ -12,7 +12,7 @@ #include -#include "alloy/string_buffer.h" +#include "poly/string_buffer.h" #include "xenia/common.h" #include "xenia/gpu/gl4/gl_context.h" #include "xenia/gpu/gl4/gl4_shader.h" @@ -42,7 +42,7 @@ class GL4ShaderTranslator { const uint32_t* dwords_; static const int kOutputCapacity = 64 * 1024; - alloy::StringBuffer output_; + poly::StringBuffer output_; bool is_vertex_shader() const { return shader_type_ == ShaderType::kVertex; } bool is_pixel_shader() const { return shader_type_ == ShaderType::kPixel; }