Skip to content

Commit

Permalink
Compile LDC2 with VS2010 64bit (LDC changes only).
Browse files Browse the repository at this point in the history
Contains all changes necessary to LDC specific source to compile LDC2 with VS2010. See dlang/dmd#516 for necessary changes to DMDFE.
  • Loading branch information
redstar committed Jan 11, 2012
1 parent 43057c6 commit 6726b5d
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dmd2/aggregate.h
Expand Up @@ -41,7 +41,7 @@ struct VarDeclaration;
struct dt_t;

#if IN_LLVM
class ClassInfoDeclaration;
struct ClassInfoDeclaration;
namespace llvm
{
class Type;
Expand Down
7 changes: 7 additions & 0 deletions gen/asm-x86-32.h
Expand Up @@ -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
{
Expand Down Expand Up @@ -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 );
Expand Down
7 changes: 7 additions & 0 deletions gen/asm-x86-64.h
Expand Up @@ -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
{
Expand Down Expand Up @@ -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 );
Expand Down
24 changes: 24 additions & 0 deletions gen/logger.cpp
Expand Up @@ -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");
Expand All @@ -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);
}
Expand Down
16 changes: 8 additions & 8 deletions gen/main.cpp
Expand Up @@ -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"

Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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

Expand Down
9 changes: 6 additions & 3 deletions gen/tocall.cpp
Expand Up @@ -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
{
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion ir/irdsymbol.h
Expand Up @@ -14,7 +14,7 @@ struct IrVar;
struct Dsymbol;

namespace llvm {
struct Value;
class Value;
}

struct IrDsymbol
Expand Down
39 changes: 38 additions & 1 deletion ir/irfuncty.h
Expand Up @@ -84,6 +84,7 @@ struct IrFuncTy : IrBase

IrFuncTy()
: ret(NULL),
args(),
arg_sret(NULL),
arg_this(NULL),
arg_nest(NULL),
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion ir/irtype.cpp
Expand Up @@ -12,7 +12,7 @@
//////////////////////////////////////////////////////////////////////////////

extern LLType* DtoType(Type* dt);
extern LLType* DtoSize_t();
extern LLIntegerType* DtoSize_t();

//////////////////////////////////////////////////////////////////////////////

Expand Down

0 comments on commit 6726b5d

Please sign in to comment.