Merge pull request #83 from inolen/macosx

misc build fixes for compiling with clang
This commit is contained in:
Ben Vanik 2014-05-21 10:15:10 -07:00
commit ced1d799ca
22 changed files with 91 additions and 49 deletions

View File

@ -81,7 +81,7 @@ int IVMAssembler::Assemble(
size_t type_size = GetTypeSize(slot->type); size_t type_size = GetTypeSize(slot->type);
// Align to natural size. // Align to natural size.
stack_offset = XEALIGN(stack_offset, type_size); stack_offset = XEALIGN(stack_offset, type_size);
slot->set_constant(stack_offset); slot->set_constant((uint32_t)stack_offset);
stack_offset += type_size; stack_offset += type_size;
} }
// Ensure 16b alignment. // Ensure 16b alignment.
@ -109,7 +109,7 @@ int IVMAssembler::Assemble(
// Fixup label references. // Fixup label references.
LabelRef* label_ref = ctx.label_ref_head; LabelRef* label_ref = ctx.label_ref_head;
while (label_ref) { while (label_ref) {
label_ref->instr->src1_reg = (uint32_t)label_ref->label->tag & ~0x80000000; label_ref->instr->src1_reg = (uint32_t)(intptr_t)label_ref->label->tag & ~0x80000000;
label_ref = label_ref->next; label_ref = label_ref->next;
} }

View File

@ -32,17 +32,17 @@ public:
ALLOY_BACKEND_IVM_ASSEMBLER_DEINIT = ALLOY_BACKEND_IVM_ASSEMBLER | (2), ALLOY_BACKEND_IVM_ASSEMBLER_DEINIT = ALLOY_BACKEND_IVM_ASSEMBLER | (2),
}; };
typedef struct { typedef struct Init_s {
static const uint32_t event_type = ALLOY_BACKEND_IVM_INIT; static const uint32_t event_type = ALLOY_BACKEND_IVM_INIT;
} Init; } Init;
typedef struct { typedef struct Deinit_s {
static const uint32_t event_type = ALLOY_BACKEND_IVM_DEINIT; static const uint32_t event_type = ALLOY_BACKEND_IVM_DEINIT;
} Deinit; } Deinit;
typedef struct { typedef struct AssemblerInit_s {
static const uint32_t event_type = ALLOY_BACKEND_IVM_ASSEMBLER_INIT; static const uint32_t event_type = ALLOY_BACKEND_IVM_ASSEMBLER_INIT;
} AssemblerInit; } AssemblerInit;
typedef struct { typedef struct AssemblerDeinit_s {
static const uint32_t event_type = ALLOY_BACKEND_IVM_ASSEMBLER_DEINIT; static const uint32_t event_type = ALLOY_BACKEND_IVM_ASSEMBLER_DEINIT;
} AssemblerDeinit; } AssemblerDeinit;
}; };

View File

@ -12,6 +12,22 @@
#include <alloy/core.h> #include <alloy/core.h>
#if XE_LIKE_WIN32
#include <xmmintrin.h>
#else
typedef union __declspec(align(16)) __m128 {
float m128_f32[4];
uint64_t m128_u64[2];
int8_t m128_i8[16];
int16_t m128_i16[8];
int32_t m128_i32[4];
int64_t m128_i64[2];
uint8_t m128_u8[16];
uint16_t m128_u16[8];
uint32_t m128_u32[4];
} __m128;
#endif
namespace alloy { namespace alloy {
namespace backend { namespace backend {

View File

@ -32,17 +32,17 @@ public:
ALLOY_BACKEND_X64_ASSEMBLER_DEINIT = ALLOY_BACKEND_X64_ASSEMBLER | (2), ALLOY_BACKEND_X64_ASSEMBLER_DEINIT = ALLOY_BACKEND_X64_ASSEMBLER | (2),
}; };
typedef struct { typedef struct Init_s {
static const uint32_t event_type = ALLOY_BACKEND_X64_INIT; static const uint32_t event_type = ALLOY_BACKEND_X64_INIT;
} Init; } Init;
typedef struct { typedef struct Deinit_s {
static const uint32_t event_type = ALLOY_BACKEND_X64_DEINIT; static const uint32_t event_type = ALLOY_BACKEND_X64_DEINIT;
} Deinit; } Deinit;
typedef struct { typedef struct AssemblerInit_s {
static const uint32_t event_type = ALLOY_BACKEND_X64_ASSEMBLER_INIT; static const uint32_t event_type = ALLOY_BACKEND_X64_ASSEMBLER_INIT;
} AssemblerInit; } AssemblerInit;
typedef struct { typedef struct AssemblerDeinit_s {
static const uint32_t event_type = ALLOY_BACKEND_X64_ASSEMBLER_DEINIT; static const uint32_t event_type = ALLOY_BACKEND_X64_ASSEMBLER_DEINIT;
} AssemblerDeinit; } AssemblerDeinit;
}; };

View File

@ -83,6 +83,7 @@ int X64Assembler::Assemble(
string_buffer_.Reset(); string_buffer_.Reset();
} }
{
X64Function* fn = new X64Function(symbol_info); X64Function* fn = new X64Function(symbol_info);
fn->set_debug_info(debug_info); fn->set_debug_info(debug_info);
fn->Setup(machine_code, code_size); fn->Setup(machine_code, code_size);
@ -90,6 +91,7 @@ int X64Assembler::Assemble(
*out_function = fn; *out_function = fn;
result = 0; result = 0;
}
XECLEANUP: XECLEANUP:
Reset(); Reset();

View File

@ -117,7 +117,7 @@ int X64Emitter::Emit(HIRBuilder* builder, size_t& out_stack_size) {
size_t type_size = GetTypeSize(slot->type); size_t type_size = GetTypeSize(slot->type);
// Align to natural size. // Align to natural size.
stack_offset = XEALIGN(stack_offset, type_size); stack_offset = XEALIGN(stack_offset, type_size);
slot->set_constant(stack_offset); slot->set_constant((uint32_t)stack_offset);
stack_offset += type_size; stack_offset += type_size;
} }
// Ensure 16b alignment. // Ensure 16b alignment.

View File

@ -44,9 +44,9 @@ int FinalizationPass::Run(HIRBuilder* builder) {
auto label = block->label_head; auto label = block->label_head;
while (label) { while (label) {
if (!label->name) { if (!label->name) {
char* name = (char*)arena->Alloc(6 + 4 + 1); const size_t label_len = 6 + 4 + 1;
xestrcpya(name, 6 + 1, "_label"); char* name = (char*)arena->Alloc(label_len);
char* part = _itoa(label->id, name + 6, 10); xesnprintf(name, label_len, "_label%d", label->id);
label->name = name; label->name = name;
} }
label = label->next; label = label->next;

View File

@ -27,10 +27,10 @@ public:
ALLOY_COMPILER_DEINIT = ALLOY_COMPILER | (2), ALLOY_COMPILER_DEINIT = ALLOY_COMPILER | (2),
}; };
typedef struct { typedef struct Init_s {
static const uint32_t event_type = ALLOY_COMPILER_INIT; static const uint32_t event_type = ALLOY_COMPILER_INIT;
} Init; } Init;
typedef struct { typedef struct Deinit_s {
static const uint32_t event_type = ALLOY_COMPILER_DEINIT; static const uint32_t event_type = ALLOY_COMPILER_DEINIT;
} Deinit; } Deinit;
}; };

View File

@ -11,6 +11,7 @@
#define ALLOY_DELEGATE_H_ #define ALLOY_DELEGATE_H_
#include <functional> #include <functional>
#include <vector>
#include <alloy/core.h> #include <alloy/core.h>
#include <alloy/mutex.h> #include <alloy/mutex.h>

View File

@ -105,6 +105,10 @@ Value* CalculateEA_0(PPCHIRBuilder& f, uint32_t ra, uint32_t rb);
// } // }
unsigned int xerotl(unsigned int value, unsigned int shift) {
XEASSERT(shift < 32);
return shift == 0 ? value : ((value << shift) | (value >> (32 - shift)));
}
XEEMITTER(dst, 0x7C0002AC, XDSS)(PPCHIRBuilder& f, InstrData& i) { XEEMITTER(dst, 0x7C0002AC, XDSS)(PPCHIRBuilder& f, InstrData& i) {
XEINSTRNOTIMPLEMENTED(); XEINSTRNOTIMPLEMENTED();
@ -1797,7 +1801,7 @@ XEEMITTER(vpkd3d128, VX128_4(6, 1552), VX128_4)(PPCHIRBuilder& f, InstrData
// http://hlssmod.net/he_code/public/pixelwriter.h // http://hlssmod.net/he_code/public/pixelwriter.h
// control = prev:0123 | new:4567 // control = prev:0123 | new:4567
uint32_t control = 0x00010203; // original uint32_t control = 0x00010203; // original
uint32_t src = _rotl(0x04050607, shift * 8); uint32_t src = xerotl(0x04050607, shift * 8);
uint32_t mask = 0; uint32_t mask = 0;
switch (pack) { switch (pack) {
case 1: // VPACK_32 case 1: // VPACK_32

View File

@ -27,10 +27,10 @@ public:
ALLOY_FRONTEND_DEINIT = ALLOY_FRONTEND | (2), ALLOY_FRONTEND_DEINIT = ALLOY_FRONTEND | (2),
}; };
typedef struct { typedef struct Init_s {
static const uint32_t event_type = ALLOY_FRONTEND_INIT; static const uint32_t event_type = ALLOY_FRONTEND_INIT;
} Init; } Init;
typedef struct { typedef struct Deinit_s {
static const uint32_t event_type = ALLOY_FRONTEND_DEINIT; static const uint32_t event_type = ALLOY_FRONTEND_DEINIT;
} Deinit; } Deinit;
}; };

View File

@ -9,14 +9,22 @@
#include <alloy/memory.h> #include <alloy/memory.h>
#if !XE_LIKE_WIN32
#include <unistd.h>
#endif
using namespace alloy; using namespace alloy;
Memory::Memory() : Memory::Memory() :
membase_(0), reserve_address_(0) { membase_(0), reserve_address_(0) {
#if XE_LIKE_WIN32
SYSTEM_INFO si; SYSTEM_INFO si;
GetSystemInfo(&si); GetSystemInfo(&si);
system_page_size_ = si.dwPageSize; system_page_size_ = si.dwPageSize;
#else
system_page_size_ = getpagesize();
#endif
} }
Memory::~Memory() { Memory::~Memory() {

View File

@ -47,7 +47,7 @@ public:
private: private:
// TODO(benvanik): replace with a better data structure. // TODO(benvanik): replace with a better data structure.
Mutex* lock_; Mutex* lock_;
typedef std::tr1::unordered_map<uint64_t, Entry*> EntryMap; typedef std::unordered_map<uint64_t, Entry*> EntryMap;
EntryMap map_; EntryMap map_;
}; };

View File

@ -62,7 +62,7 @@ protected:
private: private:
// TODO(benvanik): replace with a better data structure. // TODO(benvanik): replace with a better data structure.
Mutex* lock_; Mutex* lock_;
typedef std::tr1::unordered_map<uint64_t, SymbolInfo*> SymbolMap; typedef std::unordered_map<uint64_t, SymbolInfo*> SymbolMap;
SymbolMap map_; SymbolMap map_;
typedef std::vector<SymbolInfo*> SymbolList; typedef std::vector<SymbolInfo*> SymbolList;
SymbolList list_; SymbolList list_;

View File

@ -40,46 +40,46 @@ public:
ALLOY_RUNTIME_MEMORY_HEAP_FREE = ALLOY_RUNTIME_MEMORY | (4), ALLOY_RUNTIME_MEMORY_HEAP_FREE = ALLOY_RUNTIME_MEMORY | (4),
}; };
typedef struct { typedef struct Init_s {
static const uint32_t event_type = ALLOY_RUNTIME_INIT; static const uint32_t event_type = ALLOY_RUNTIME_INIT;
} Init; } Init;
typedef struct { typedef struct Deinit_s {
static const uint32_t event_type = ALLOY_RUNTIME_DEINIT; static const uint32_t event_type = ALLOY_RUNTIME_DEINIT;
} Deinit; } Deinit;
typedef struct { typedef struct ThreadInit_s {
static const uint32_t event_type = ALLOY_RUNTIME_THREAD_INIT; static const uint32_t event_type = ALLOY_RUNTIME_THREAD_INIT;
} ThreadInit; } ThreadInit;
typedef struct { typedef struct ThreadDeinit_s {
static const uint32_t event_type = ALLOY_RUNTIME_THREAD_DEINIT; static const uint32_t event_type = ALLOY_RUNTIME_THREAD_DEINIT;
} ThreadDeinit; } ThreadDeinit;
typedef struct { typedef struct MemoryInit_s {
static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_INIT; static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_INIT;
// map of memory, etc? // map of memory, etc?
} MemoryInit; } MemoryInit;
typedef struct { typedef struct MemoryDeinit_s {
static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_DEINIT; static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_DEINIT;
} MemoryDeinit; } MemoryDeinit;
typedef struct { typedef struct MemoryHeapInit_s {
static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_HEAP_INIT; static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_HEAP_INIT;
uint32_t heap_id; uint32_t heap_id;
uint64_t low_address; uint64_t low_address;
uint64_t high_address; uint64_t high_address;
uint32_t is_physical; uint32_t is_physical;
} MemoryHeapInit; } MemoryHeapInit;
typedef struct { typedef struct MemoryHeapDeinit_s {
static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_HEAP_DEINIT; static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_HEAP_DEINIT;
uint32_t heap_id; uint32_t heap_id;
} MemoryHeapDeinit; } MemoryHeapDeinit;
typedef struct { typedef struct MemoryHeapAlloc_s {
static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_HEAP_ALLOC; static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_HEAP_ALLOC;
uint32_t heap_id; uint32_t heap_id;
uint32_t flags; uint32_t flags;
uint64_t address; uint64_t address;
size_t size; size_t size;
} MemoryHeapAlloc; } MemoryHeapAlloc;
typedef struct { typedef struct MemoryHeapFree_s {
static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_HEAP_FREE; static const uint32_t event_type = ALLOY_RUNTIME_MEMORY_HEAP_FREE;
uint32_t heap_id; uint32_t heap_id;
uint64_t address; uint64_t address;

View File

@ -33,10 +33,10 @@ public:
USER = (1 << 31), USER = (1 << 31),
}; };
typedef struct { typedef struct TraceInit_s {
static const uint32_t event_type = ALLOY_TRACE_INIT; static const uint32_t event_type = ALLOY_TRACE_INIT;
} TraceInit; } TraceInit;
typedef struct { typedef struct TraceEOF_s {
static const uint32_t event_type = ALLOY_TRACE_EOF; static const uint32_t event_type = ALLOY_TRACE_EOF;
} TraceEOF; } TraceEOF;
}; };

View File

@ -30,7 +30,7 @@ Tracer* GetThreadTracer();
void WriteEvent(uint32_t event_type, size_t size = 0, const void* data = 0); void WriteEvent(uint32_t event_type, size_t size = 0, const void* data = 0);
template<typename T> void WriteEvent(T& ev) { template<typename T> void WriteEvent(const T& ev) {
if (sizeof(T) > 1) { if (sizeof(T) > 1) {
alloy::tracing::WriteEvent(T::event_type, sizeof(T), &ev); alloy::tracing::WriteEvent(T::event_type, sizeof(T), &ev);
} else { } else {

View File

@ -70,7 +70,7 @@ int FileSystem::CreateSymbolicLink(const char* path, const char* target) {
} }
int FileSystem::DeleteSymbolicLink(const char* path) { int FileSystem::DeleteSymbolicLink(const char* path) {
std::tr1::unordered_map<std::string, std::string>::iterator it = std::unordered_map<std::string, std::string>::iterator it =
symlinks_.find(std::string(path)); symlinks_.find(std::string(path));
if (it != symlinks_.end()) { if (it != symlinks_.end()) {
symlinks_.erase(it); symlinks_.erase(it);
@ -93,7 +93,7 @@ Entry* FileSystem::ResolvePath(const char* path) {
// drive path -> device mappings with nothing nested. // drive path -> device mappings with nothing nested.
char full_path[XE_MAX_PATH]; char full_path[XE_MAX_PATH];
XEIGNORE(xestrcpya(full_path, XECOUNT(full_path), path)); XEIGNORE(xestrcpya(full_path, XECOUNT(full_path), path));
for (std::tr1::unordered_map<std::string, std::string>::iterator it = for (std::unordered_map<std::string, std::string>::iterator it =
symlinks_.begin(); it != symlinks_.end(); ++it) { symlinks_.begin(); it != symlinks_.end(); ++it) {
if (xestrcasestra(path, it->first.c_str()) == path) { if (xestrcasestra(path, it->first.c_str()) == path) {
// Found symlink, fixup. // Found symlink, fixup.

View File

@ -43,7 +43,7 @@ public:
private: private:
std::vector<Device*> devices_; std::vector<Device*> devices_;
std::tr1::unordered_map<std::string, std::string> symlinks_; std::unordered_map<std::string, std::string> symlinks_;
}; };

View File

@ -56,13 +56,8 @@
#include <assert.h> #include <assert.h>
#include <stdint.h> #include <stdint.h>
#if XE_COMPILER_MSVC
#include <memory> #include <memory>
#include <unordered_map> #include <unordered_map>
#else
#include <tr1/memory>
#include <tr1/unordered_map>
#endif // MSVC
#endif // XENIA_PLATFORM_INCLUDES_H_ #endif // XENIA_PLATFORM_INCLUDES_H_

View File

@ -16,7 +16,7 @@
namespace xe { namespace xe {
// TODO(benvanik): support other compilers/etc // TODO(benvanik): support other compilers/etc
using std::auto_ptr; using std::auto_ptr;
using std::tr1::shared_ptr; using std::shared_ptr;
} // namespace xe } // namespace xe

View File

@ -96,7 +96,7 @@
'SYMROOT': '<(DEPTH)/build/xenia/', 'SYMROOT': '<(DEPTH)/build/xenia/',
'ALWAYS_SEARCH_USER_PATHS': 'NO', 'ALWAYS_SEARCH_USER_PATHS': 'NO',
'ARCHS': ['x86_64'], 'ARCHS': ['x86_64'],
#'CLANG_CXX_LANGUAGE_STANDARD': 'c++0x', 'CLANG_CXX_LANGUAGE_STANDARD': 'c++11',
'COMBINE_HIDPI_IMAGES': 'YES', 'COMBINE_HIDPI_IMAGES': 'YES',
'GCC_C_LANGUAGE_STANDARD': 'gnu99', 'GCC_C_LANGUAGE_STANDARD': 'gnu99',
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES',
@ -190,6 +190,22 @@
'gflags', 'gflags',
'llvm', 'llvm',
], ],
'conditions': [
['OS == "mac"', {
'xcode_settings': {
'OTHER_CFLAGS': [
'-fno-operator-names',
],
},
}],
['OS == "linux"', {
'cflags': [
'-fno-operator-names',
],
}],
],
'export_dependent_settings': [ 'export_dependent_settings': [
'beaengine', 'beaengine',
'gflags', 'gflags',