Compile LDC2 with VS2010 64bit (LDC changes only).

Contains all changes necessary to LDC specific source to compile LDC2 with VS2010. See https://github.com/D-Programming-Language/dmd/pull/516 for necessary changes to DMDFE.
This commit is contained in:
kai
2012-01-11 07:49:21 +01:00
parent 43057c64ec
commit 6726b5da13
9 changed files with 93 additions and 15 deletions

View File

@@ -41,7 +41,7 @@ struct VarDeclaration;
struct dt_t;
#if IN_LLVM
class ClassInfoDeclaration;
struct ClassInfoDeclaration;
namespace llvm
{
class Type;

View File

@@ -2,6 +2,9 @@
// Released under the Artistic License found in dmd/artistic.txt
#include "id.h"
#if defined(_MSC_VER)
#include <ctype.h>
#endif
namespace AsmParserx8632
{
@@ -1254,7 +1257,11 @@ namespace AsmParserx8632
{
strncpy ( buf, regInfo[i].name, sizeof ( buf ) - 1 );
for ( p = buf; *p; p++ )
#if defined(_MSC_VER)
*p = tolower ( *p );
#else
*p = std::tolower ( *p );
#endif
regInfo[i].gccName = std::string ( buf, p - buf );
if ( ( i <= Reg_ST || i > Reg_ST7 ) && i != Reg_EFLAGS )
regInfo[i].ident = Lexer::idPool ( regInfo[i].name );

View File

@@ -2,6 +2,9 @@
// Released under the Artistic License found in dmd/artistic.txt
#include "id.h"
#if defined(_MSC_VER)
#include <ctype.h>
#endif
namespace AsmParserx8664
{
@@ -1367,7 +1370,11 @@ namespace AsmParserx8664
{
strncpy ( buf, regInfo[i].name, sizeof ( buf ) - 1 );
for ( p = buf; *p; p++ )
#if defined(_MSC_VER)
*p = tolower ( *p );
#else
*p = std::tolower ( *p );
#endif
regInfo[i].gccName = std::string ( buf, p - buf );
if ( ( i <= Reg_ST || i > Reg_ST7 ) && i != Reg_EFLAGS )
regInfo[i].ident = Lexer::idPool ( regInfo[i].name );

View File

@@ -62,12 +62,35 @@ namespace Logger
else
return 0;
}
#if defined(_MSC_VER)
static inline void
search_and_replace(std::string& str, const std::string& what, const std::string& replacement)
{
assert(!what.empty());
size_t pos = str.find(what);
while (pos != std::string::npos)
{
str.replace(pos, what.size(), replacement);
pos = str.find(what, pos + replacement.size());
}
}
#define WORKAROUND_C99_SPECIFIERS_BUG(f) \
std::string tmp = f; \
search_and_replace(tmp, std::string("%z"), std::string("%I")); \
f = tmp.c_str();
#else
#define WORKAROUND_C99_SPECIFIERS_BUG(f)
#endif
void println(const char* fmt,...)
{
if (_enabled) {
printf("%s", indent_str.c_str());
va_list va;
va_start(va,fmt);
WORKAROUND_C99_SPECIFIERS_BUG(fmt);
vprintf(fmt,va);
va_end(va);
printf("\n");
@@ -79,6 +102,7 @@ namespace Logger
printf("%s", indent_str.c_str());
va_list va;
va_start(va,fmt);
WORKAROUND_C99_SPECIFIERS_BUG(fmt);
vprintf(fmt,va);
va_end(va);
}

View File

@@ -18,12 +18,6 @@
#include <assert.h>
#include <limits.h>
#if POSIX
#include <errno.h>
#elif _WIN32
#include <windows.h>
#endif
#include "rmem.h"
#include "root.h"
@@ -49,6 +43,12 @@ using namespace opts;
#include "gen/configfile.h"
#if POSIX
#include <errno.h>
#elif _WIN32
#include <windows.h>
#endif
#if DMDV1
typedef Array Modules;
#endif
@@ -127,7 +127,7 @@ static void initFromString(char*& dest, const cl::opt<std::string>& src) {
}
}
#if _WIN32
#if _WIN32 && __DMC__
extern "C"
{
extern int _xi_a;
@@ -139,7 +139,7 @@ int main(int argc, char** argv)
{
mem.init(); // initialize storage allocator
mem.setStackBottom(&argv);
#if _WIN32
#if _WIN32 && __DMC__
mem.addroots((char *)&_xi_a, (char *)&_end);
#endif

View File

@@ -50,7 +50,10 @@ llvm::CallingConv::ID DtoCallingConv(Loc loc, LINK l)
return llvm::CallingConv::Fast;
}
// on the other hand, here, it's exactly what we want!!! TODO: right?
else if (l == LINKwindows || l == LINKpascal)
// On Windows 64bit, there is only one calling convention!
else if (l == LINKwindows)
return global.params.cpu == ARCHx86_64 ? llvm::CallingConv::C : llvm::CallingConv::X86_StdCall;
else if (l == LINKpascal)
return llvm::CallingConv::X86_StdCall;
else
{
@@ -617,8 +620,8 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
// repaint the type if necessary
if (resulttype)
{
Type* rbase = stripModifiers(resulttype->toBasetype());
Type* nextbase = stripModifiers(tf->nextOf()->toBasetype());
Type* rbase = stripModifiers(resulttype->toBasetype());
Type* nextbase = stripModifiers(tf->nextOf()->toBasetype());
if (!rbase->equals(nextbase))
{
Logger::println("repainting return value from '%s' to '%s'", tf->nextOf()->toChars(), rbase->toChars());

View File

@@ -14,7 +14,7 @@ struct IrVar;
struct Dsymbol;
namespace llvm {
struct Value;
class Value;
}
struct IrDsymbol

View File

@@ -84,6 +84,7 @@ struct IrFuncTy : IrBase
IrFuncTy()
: ret(NULL),
args(),
arg_sret(NULL),
arg_this(NULL),
arg_nest(NULL),
@@ -93,11 +94,47 @@ struct IrFuncTy : IrBase
reverseParams(false),
is_arg_this_ref(false)
{}
#if defined(_MSC_VER)
// Copy constructor and operator= seems to be requreid for MSC
IrFuncTy(const IrFuncTy& rhs)
: ret(rhs.ret),
args(IrFuncTy::ArgList(rhs.args)),
arg_sret(rhs.arg_sret),
arg_this(rhs.arg_this),
arg_nest(rhs.arg_nest),
arg_arguments(rhs.arg_arguments),
arg_argptr(rhs.arg_argptr),
c_vararg(rhs.c_vararg),
reverseParams(rhs.reverseParams),
is_arg_this_ref(rhs.is_arg_this_ref)
{}
IrFuncTy& operator=(const IrFuncTy& rhs)
{
ret = rhs.ret;
args = IrFuncTy::ArgList(rhs.args);
arg_sret = rhs.arg_sret;
arg_this = rhs.arg_this;
arg_nest = rhs.arg_nest;
arg_arguments = rhs.arg_arguments;
arg_argptr = rhs.arg_argptr;
c_vararg = rhs.c_vararg;
reverseParams = rhs.reverseParams;
is_arg_this_ref = rhs.is_arg_this_ref;
return *this;
}
#endif
void reset() {
ret = NULL;
arg_sret = arg_this = arg_nest = arg_arguments = arg_argptr = NULL;
#if defined(_MSC_VER)
args = IrFuncTy::ArgList();
#else
args.clear();
#endif
c_vararg = false;
reverseParams = false;
}

View File

@@ -12,7 +12,7 @@
//////////////////////////////////////////////////////////////////////////////
extern LLType* DtoType(Type* dt);
extern LLType* DtoSize_t();
extern LLIntegerType* DtoSize_t();
//////////////////////////////////////////////////////////////////////////////