diff options
author | John Hodge <tpg@mutabah.net> | 2017-09-09 12:41:06 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2017-09-22 09:55:50 +0800 |
commit | 1cb79ee7f01a198f373e2d85c5ce5ab0bf90dcb6 (patch) | |
tree | c1a85f445656f59d87c1d4f2690339bebed8fdac /src | |
parent | 1af51991c707e59979a244320b9264e8c1230925 (diff) | |
download | mrust-1cb79ee7f01a198f373e2d85c5ce5ab0bf90dcb6.tar.gz |
Trans - MSVC twiddling
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 2 | ||||
-rw-r--r-- | src/trans/codegen_c.cpp | 34 | ||||
-rw-r--r-- | src/trans/target.cpp | 20 |
3 files changed, 48 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp index d2330568..c159ca4b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,7 +29,7 @@ // Hacky default target #ifdef _MSC_VER -#define DEFAULT_TARGET_NAME "x86_64-windows-msvc" +#define DEFAULT_TARGET_NAME "x86-windows-msvc" #elif defined(__GNU__) # if defined(__linux__) #define DEFAULT_TARGET_NAME "x86_64-linux-gnu" diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index b942dae7..b0767ef7 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -520,7 +520,7 @@ namespace { is_windows = true; // TODO: Look up these paths in the registry and use CreateProcess instead of system args.push_back(cache_str( detect_msvc().path_vcvarsall )); - //args.push_back("amd64"); + //args.push_back("amd64"); // NOTE: Doesn't support inline assembly args.push_back("&"); args.push_back("cl.exe"); args.push_back("/nologo"); @@ -584,6 +584,10 @@ namespace { cmd_ss << "&"; } else { + if( is_windows && strchr(arg, ' ') == nullptr ) { + cmd_ss << arg << " "; + continue ; + } cmd_ss << "\"" << FmtShell(arg, is_windows) << "\" "; } } @@ -628,7 +632,15 @@ namespace { void emit_type_id(const ::HIR::TypeRef& ty) override { - m_of << "tTYPEID __typeid_" << Trans_Mangle(ty) << " __attribute__((weak));\n"; + switch(m_compiler) + { + case Compiler::Gcc: + m_of << "tTYPEID __typeid_" << Trans_Mangle(ty) << " __attribute__((weak));\n"; + break; + case Compiler::Msvc: + m_of << "__declspec(selectany) tTYPEID __typeid_" << Trans_Mangle(ty) << ";\n"; + break; + } } void emit_type_proto(const ::HIR::TypeRef& ty) override { @@ -673,7 +685,21 @@ namespace { m_of << "typedef "; // TODO: ABI marker, need an ABI enum? // TODO: Better emit_ctype call for return type. - emit_ctype(*te.m_rettype); m_of << " (*"; emit_ctype(ty); m_of << ")("; + emit_ctype(*te.m_rettype); m_of << " ("; + if( m_compiler == Compiler::Msvc ) + { + if( te.m_abi == ABI_RUST ) + { + } + else if( te.m_abi == "system" ) + { + m_of << "__stdcall"; + } + else + { + } + } + m_of << "*"; emit_ctype(ty); m_of << ")("; if( te.m_arg_types.size() == 0 ) { m_of << "void)"; @@ -1433,6 +1459,8 @@ namespace { m_of << " "; emit_literal(get_inner_type(0, i), e[i], params); } + if(ty.m_data.is_Path() && e.size() == 0 && m_options.disallow_empty_structs) + m_of << "0"; m_of << " }"; if( ty.m_data.is_Array() ) m_of << "}"; diff --git a/src/trans/target.cpp b/src/trans/target.cpp index d4f57107..bb0227fc 100644 --- a/src/trans/target.cpp +++ b/src/trans/target.cpp @@ -15,6 +15,11 @@ TargetArch ARCH_X86_64 = { 64, false, { /*atomic(u8)=*/true, false, true, true, true } }; +TargetArch ARCH_X86 = { + "x86", + 32, false, + { /*atomic(u8)=*/true, false, true, false, true } +}; TargetSpec g_target; namespace @@ -43,13 +48,20 @@ namespace ARCH_X86_64 }; } - else if (target_name == "x86_64-windows-msvc") + else if (target_name == "x86-windows-msvc") { return TargetSpec { - "windows", "windows", "msvd", CodegenMode::Msvc, - ARCH_X86_64 - }; + "windows", "windows", "msvc", CodegenMode::Msvc, + ARCH_X86 + }; } + //else if (target_name == "x86_64-windows-msvc") + //{ + // return TargetSpec { + // "windows", "windows", "msvc", CodegenMode::Msvc, + // ARCH_X86_64 + // }; + //} else { ::std::cerr << "Unknown target name '" << target_name << "'" << ::std::endl; |