From 7e25c57d060e63649fbdf1f4c5810acb83d0b52c Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 31 Dec 2017 12:52:55 +0800 Subject: Trans - Draft ARM32 support --- src/hir/deserialise.cpp | 2 +- src/main.cpp | 30 ++++++++++++++++++++++-------- src/trans/target.cpp | 19 +++++++++++++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/hir/deserialise.cpp b/src/hir/deserialise.cpp index b7cba83b..326debd7 100644 --- a/src/hir/deserialise.cpp +++ b/src/hir/deserialise.cpp @@ -752,7 +752,7 @@ namespace { _(Array, { deserialise_ptr< ::HIR::TypeRef>(), nullptr, - m_in.read_u64c() & SIZE_MAX + static_cast(m_in.read_u64c() & SIZE_MAX) }) _(Slice, { deserialise_ptr< ::HIR::TypeRef>() diff --git a/src/main.cpp b/src/main.cpp index b23bb9e9..2b5b2234 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,17 +29,31 @@ // Hacky default target #ifdef _MSC_VER -#define DEFAULT_TARGET_NAME "x86-windows-msvc" -#elif defined(__GNU__) -# if defined(__linux__) -#define DEFAULT_TARGET_NAME "x86_64-linux-gnu" -# elif defined(_WIN64) -#define DEFAULT_TARGET_NAME "x86_64-windows-gnu" +# if defined(_X64) +# define DEFAULT_TARGET_NAME "x86_64-windows-msvc" # else -#define DEFAULT_TARGET_NAME "x86_64-windows-gnu" +# define DEFAULT_TARGET_NAME "x86-windows-msvc" +# endif +#elif defined(__linux__) +# if defined(__amd64__) +# define DEFAULT_TARGET_NAME "x86_64-linux-gnu" +# elif defined(__aarch64__) +# define DEFAULT_TARGET_NAME "arm64-linux-gnu" +# elif defined(__arm__) +# define DEFAULT_TARGET_NAME "arm-linux-gnu" +# elif defined(__i386__) +# define DEFAULT_TARGET_NAME "i586-linux-gnu" +# else +# error "Unable to detect a suitable default target (linux-gnu)" +# endif +#elif defined(__MINGW32__) +# if defined(_WIN64) +# define DEFAULT_TARGET_NAME "x86_64-windows-gnu" +# else +# define DEFAULT_TARGET_NAME "i586-windows-gnu" # endif #else -#define DEFAULT_TARGET_NAME "x86_64-linux-gnu" +# error "Unable to detect a suitable default target" #endif int g_debug_indent_level = 0; diff --git a/src/trans/target.cpp b/src/trans/target.cpp index f13b20a3..c4aa5d55 100644 --- a/src/trans/target.cpp +++ b/src/trans/target.cpp @@ -23,6 +23,11 @@ TargetArch ARCH_X86 = { 32, false, { /*atomic(u8)=*/true, false, true, false, true } }; +TargetArch ARCH_ARM32 = { + "arm32", + 32, false, + { /*atomic(u8)=*/true, false, true, false, true } +}; TargetSpec g_target; @@ -40,6 +45,13 @@ namespace { return load_spec_from_file(target_name); } + else if(target_name == "i586-linux-gnu") + { + return TargetSpec { + "unix", "linux", "gnu", CodegenMode::Gnu11, + ARCH_X86 + }; + } else if(target_name == "x86_64-linux-gnu") { return TargetSpec { @@ -47,6 +59,13 @@ namespace ARCH_X86_64 }; } + else if(target_name == "arm-linux-gnu") + { + return TargetSpec { + "unix", "linux", "gnu", CodegenMode::Gnu11, + ARCH_ARM32 + }; + } else if(target_name == "x86_64-windows-gnu") { return TargetSpec { -- cgit v1.2.3