mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 16:41:06 +03:00
Merge branch 'llvm3.0' into merge-3.0
Conflicts: gen/configfile.cpp
This commit is contained in:
commit
fe19ee84f5
15 changed files with 73 additions and 68 deletions
|
@ -455,7 +455,7 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit)
|
||||||
|
|
||||||
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
|
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
|
||||||
|
|
||||||
LLConstant* gep = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
|
LLConstant* gep = llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true);
|
||||||
gep = llvm::ConstantExpr::getBitCast(gvar, getPtrToType(llelemty));
|
gep = llvm::ConstantExpr::getBitCast(gvar, getPtrToType(llelemty));
|
||||||
|
|
||||||
return DtoConstSlice(DtoConstSize_t(arrlen), gep, arrty);
|
return DtoConstSlice(DtoConstSize_t(arrlen), gep, arrty);
|
||||||
|
|
|
@ -2088,7 +2088,7 @@ namespace AsmParserx8632
|
||||||
Logger::cout() << "baseReg: " << operand->baseReg << '\n';
|
Logger::cout() << "baseReg: " << operand->baseReg << '\n';
|
||||||
Logger::cout() << "segmentPrefix: " << operand->segmentPrefix << '\n';
|
Logger::cout() << "segmentPrefix: " << operand->segmentPrefix << '\n';
|
||||||
Logger::cout() << "constDisplacement: " << operand->constDisplacement << '\n';
|
Logger::cout() << "constDisplacement: " << operand->constDisplacement << '\n';
|
||||||
for (int i = 0; i < operand->symbolDisplacement.dim; i++) {
|
for (unsigned i = 0; i < operand->symbolDisplacement.dim; i++) {
|
||||||
Expression* expr = (Expression*) operand->symbolDisplacement.data[i];
|
Expression* expr = (Expression*) operand->symbolDisplacement.data[i];
|
||||||
Logger::cout() << "symbolDisplacement[" << i << "] = " << expr->toChars() << '\n';
|
Logger::cout() << "symbolDisplacement[" << i << "] = " << expr->toChars() << '\n';
|
||||||
}
|
}
|
||||||
|
|
|
@ -2243,7 +2243,7 @@ namespace AsmParserx8664
|
||||||
Logger::cout() << "baseReg: " << operand->baseReg << '\n';
|
Logger::cout() << "baseReg: " << operand->baseReg << '\n';
|
||||||
Logger::cout() << "segmentPrefix: " << operand->segmentPrefix << '\n';
|
Logger::cout() << "segmentPrefix: " << operand->segmentPrefix << '\n';
|
||||||
Logger::cout() << "constDisplacement: " << operand->constDisplacement << '\n';
|
Logger::cout() << "constDisplacement: " << operand->constDisplacement << '\n';
|
||||||
for (int i = 0; i < operand->symbolDisplacement.dim; i++) {
|
for (unsigned i = 0; i < operand->symbolDisplacement.dim; i++) {
|
||||||
Expression* expr = (Expression*) operand->symbolDisplacement.data[i];
|
Expression* expr = (Expression*) operand->symbolDisplacement.data[i];
|
||||||
Logger::cout() << "symbolDisplacement[" << i << "] = " << expr->toChars() << '\n';
|
Logger::cout() << "symbolDisplacement[" << i << "] = " << expr->toChars() << '\n';
|
||||||
}
|
}
|
||||||
|
|
|
@ -534,7 +534,7 @@ void AsmBlockStatement::toIR(IRState* p)
|
||||||
p->asmBlock = asmblock;
|
p->asmBlock = asmblock;
|
||||||
|
|
||||||
// do asm statements
|
// do asm statements
|
||||||
for (int i=0; i<statements->dim; i++)
|
for (unsigned i=0; i<statements->dim; i++)
|
||||||
{
|
{
|
||||||
Statement* s = (Statement*)statements->data[i];
|
Statement* s = (Statement*)statements->data[i];
|
||||||
if (s) {
|
if (s) {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "llvm/Support/FileSystem.h"
|
||||||
#include "llvm/Support/Path.h"
|
#include "llvm/Support/Path.h"
|
||||||
|
|
||||||
#include "libconfig.h++"
|
#include "libconfig.h++"
|
||||||
|
@ -31,14 +32,14 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c
|
||||||
// try the current working dir
|
// try the current working dir
|
||||||
p = sys::Path::GetCurrentDirectory();
|
p = sys::Path::GetCurrentDirectory();
|
||||||
p.appendComponent(filename);
|
p.appendComponent(filename);
|
||||||
if (p.exists())
|
if (sys::fs::exists(p.str()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// try next to the executable
|
// try next to the executable
|
||||||
p = sys::Path::GetMainExecutable(argv0, mainAddr);
|
p = sys::Path::GetMainExecutable(argv0, mainAddr);
|
||||||
p.eraseComponent();
|
p.eraseComponent();
|
||||||
p.appendComponent(filename);
|
p.appendComponent(filename);
|
||||||
if (p.exists())
|
if (sys::fs::exists(p.str()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// user configuration
|
// user configuration
|
||||||
|
@ -47,14 +48,14 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c
|
||||||
p = sys::Path::GetUserHomeDirectory();
|
p = sys::Path::GetUserHomeDirectory();
|
||||||
p.appendComponent(".ldc");
|
p.appendComponent(".ldc");
|
||||||
p.appendComponent(filename);
|
p.appendComponent(filename);
|
||||||
if (p.exists())
|
if (sys::fs::exists(p.str()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
// try home dir
|
// try home dir
|
||||||
p = sys::Path::GetUserHomeDirectory();
|
p = sys::Path::GetUserHomeDirectory();
|
||||||
p.appendComponent(filename);
|
p.appendComponent(filename);
|
||||||
if (p.exists())
|
if (sys::fs::exists(p.str()))
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -64,14 +65,14 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c
|
||||||
// try the install-prefix
|
// try the install-prefix
|
||||||
p = sys::Path(LDC_INSTALL_PREFIX);
|
p = sys::Path(LDC_INSTALL_PREFIX);
|
||||||
p.appendComponent(filename);
|
p.appendComponent(filename);
|
||||||
if (p.exists())
|
if (sys::fs::exists(p.str()))
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
// try the install-prefix/etc
|
// try the install-prefix/etc
|
||||||
p = sys::Path(LDC_INSTALL_PREFIX);
|
p = sys::Path(LDC_INSTALL_PREFIX);
|
||||||
p.appendComponent("etc");
|
p.appendComponent("etc");
|
||||||
p.appendComponent(filename);
|
p.appendComponent(filename);
|
||||||
if (p.exists())
|
if (sys::fs::exists(p.str()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// try the install-prefix/etc/ldc
|
// try the install-prefix/etc/ldc
|
||||||
|
@ -79,19 +80,19 @@ bool ConfigFile::locate(sys::Path& p, const char* argv0, void* mainAddr, const c
|
||||||
p.appendComponent("etc");
|
p.appendComponent("etc");
|
||||||
p.appendComponent("ldc");
|
p.appendComponent("ldc");
|
||||||
p.appendComponent(filename);
|
p.appendComponent(filename);
|
||||||
if (p.exists())
|
if (sys::fs::exists(p.str()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// try /etc (absolute path)
|
// try /etc (absolute path)
|
||||||
p = sys::Path("/etc");
|
p = sys::Path("/etc");
|
||||||
p.appendComponent(filename);
|
p.appendComponent(filename);
|
||||||
if (p.exists())
|
if (sys::fs::exists(p.str()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// try /etc/ldc (absolute path)
|
// try /etc/ldc (absolute path)
|
||||||
p = sys::Path("/etc/ldc");
|
p = sys::Path("/etc/ldc");
|
||||||
p.appendComponent(filename);
|
p.appendComponent(filename);
|
||||||
if (p.exists())
|
if (sys::fs::exists(p.str()))
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ bool ConfigFile::read(const char* argv0, void* mainAddr, const char* filename)
|
||||||
{
|
{
|
||||||
std::string binpathkey = "%%ldcbinarypath%%";
|
std::string binpathkey = "%%ldcbinarypath%%";
|
||||||
|
|
||||||
std::string binpath = sys::Path::GetMainExecutable(argv0, mainAddr).getDirname();
|
std::string binpath = sys::path::parent_path(sys::Path::GetMainExecutable(argv0, mainAddr).str());
|
||||||
|
|
||||||
libconfig::Setting& arr = cfg->lookup("default.switches");
|
libconfig::Setting& arr = cfg->lookup("default.switches");
|
||||||
int len = arr.getLength();
|
int len = arr.getLength();
|
||||||
|
|
|
@ -221,7 +221,7 @@ void TemplateInstance::codegen(Ir* p)
|
||||||
#endif
|
#endif
|
||||||
if (!errors && members)
|
if (!errors && members)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < members->dim; i++)
|
for (unsigned i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||||
s->codegen(p);
|
s->codegen(p);
|
||||||
|
@ -235,7 +235,7 @@ void TemplateMixin::codegen(Ir* p)
|
||||||
{
|
{
|
||||||
if (!errors && members)
|
if (!errors && members)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < members->dim; i++)
|
for (unsigned i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||||
if (s->isVarDeclaration())
|
if (s->isVarDeclaration())
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "gen/linker.h"
|
#include "gen/linker.h"
|
||||||
#include "gen/llvm.h"
|
#include "gen/llvm.h"
|
||||||
#include "llvm/Linker.h"
|
#include "llvm/Linker.h"
|
||||||
|
#include "llvm/Support/FileSystem.h"
|
||||||
#include "llvm/Support/Program.h"
|
#include "llvm/Support/Program.h"
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
#include "llvm/Support/SystemUtils.h"
|
#include "llvm/Support/SystemUtils.h"
|
||||||
|
@ -96,9 +97,8 @@ int linkExecutable(const char* argv0)
|
||||||
assert(gExePath.isValid());
|
assert(gExePath.isValid());
|
||||||
|
|
||||||
// create path to exe
|
// create path to exe
|
||||||
llvm::sys::Path exedir(gExePath);
|
llvm::sys::Path exedir(llvm::sys::path::parent_path(gExePath.str()));
|
||||||
exedir.set(gExePath.getDirname());
|
if (!llvm::sys::fs::exists(exedir.str()))
|
||||||
if (!exedir.exists())
|
|
||||||
{
|
{
|
||||||
exedir.createDirectoryOnDisk(true, &errstr);
|
exedir.createDirectoryOnDisk(true, &errstr);
|
||||||
if (!errstr.empty())
|
if (!errstr.empty())
|
||||||
|
@ -145,7 +145,7 @@ int linkExecutable(const char* argv0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// additional linker switches
|
// additional linker switches
|
||||||
for (int i = 0; i < global.params.linkswitches->dim; i++)
|
for (unsigned i = 0; i < global.params.linkswitches->dim; i++)
|
||||||
{
|
{
|
||||||
char *p = (char *)global.params.linkswitches->data[i];
|
char *p = (char *)global.params.linkswitches->data[i];
|
||||||
args.push_back(p);
|
args.push_back(p);
|
||||||
|
@ -156,7 +156,7 @@ int linkExecutable(const char* argv0)
|
||||||
|
|
||||||
|
|
||||||
// user libs
|
// user libs
|
||||||
for (int i = 0; i < global.params.libfiles->dim; i++)
|
for (unsigned i = 0; i < global.params.libfiles->dim; i++)
|
||||||
{
|
{
|
||||||
char *p = (char *)global.params.libfiles->data[i];
|
char *p = (char *)global.params.libfiles->data[i];
|
||||||
args.push_back(p);
|
args.push_back(p);
|
||||||
|
@ -180,7 +180,7 @@ int linkExecutable(const char* argv0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// object files
|
// object files
|
||||||
for (int i = 0; i < global.params.objfiles->dim; i++)
|
for (unsigned i = 0; i < global.params.objfiles->dim; i++)
|
||||||
{
|
{
|
||||||
char *p = (char *)global.params.objfiles->data[i];
|
char *p = (char *)global.params.objfiles->data[i];
|
||||||
args.push_back(p);
|
args.push_back(p);
|
||||||
|
@ -232,7 +232,7 @@ int linkObjToExecutable(const char* argv0)
|
||||||
args.push_back(gccStr);
|
args.push_back(gccStr);
|
||||||
|
|
||||||
// object files
|
// object files
|
||||||
for (int i = 0; i < global.params.objfiles->dim; i++)
|
for (unsigned i = 0; i < global.params.objfiles->dim; i++)
|
||||||
{
|
{
|
||||||
char *p = (char *)global.params.objfiles->data[i];
|
char *p = (char *)global.params.objfiles->data[i];
|
||||||
args.push_back(p);
|
args.push_back(p);
|
||||||
|
@ -265,9 +265,8 @@ int linkObjToExecutable(const char* argv0)
|
||||||
assert(gExePath.isValid());
|
assert(gExePath.isValid());
|
||||||
|
|
||||||
// create path to exe
|
// create path to exe
|
||||||
llvm::sys::Path exedir(gExePath);
|
llvm::sys::Path exedir(llvm::sys::path::parent_path(gExePath.str()));
|
||||||
exedir.set(gExePath.getDirname());
|
if (!llvm::sys::fs::exists(exedir.str()))
|
||||||
if (!exedir.exists())
|
|
||||||
{
|
{
|
||||||
exedir.createDirectoryOnDisk(true, &errstr);
|
exedir.createDirectoryOnDisk(true, &errstr);
|
||||||
if (!errstr.empty())
|
if (!errstr.empty())
|
||||||
|
@ -278,14 +277,14 @@ int linkObjToExecutable(const char* argv0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// additional linker switches
|
// additional linker switches
|
||||||
for (int i = 0; i < global.params.linkswitches->dim; i++)
|
for (unsigned i = 0; i < global.params.linkswitches->dim; i++)
|
||||||
{
|
{
|
||||||
char *p = (char *)global.params.linkswitches->data[i];
|
char *p = (char *)global.params.linkswitches->data[i];
|
||||||
args.push_back(p);
|
args.push_back(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// user libs
|
// user libs
|
||||||
for (int i = 0; i < global.params.libfiles->dim; i++)
|
for (unsigned i = 0; i < global.params.libfiles->dim; i++)
|
||||||
{
|
{
|
||||||
char *p = (char *)global.params.libfiles->data[i];
|
char *p = (char *)global.params.libfiles->data[i];
|
||||||
args.push_back(p);
|
args.push_back(p);
|
||||||
|
@ -363,7 +362,8 @@ void deleteExecutable()
|
||||||
if (!gExePath.isEmpty())
|
if (!gExePath.isEmpty())
|
||||||
{
|
{
|
||||||
assert(gExePath.isValid());
|
assert(gExePath.isValid());
|
||||||
assert(!gExePath.isDirectory());
|
bool is_directory;
|
||||||
|
assert(!(!llvm::sys::fs::is_directory(gExePath.str(), is_directory) && is_directory));
|
||||||
gExePath.eraseFromDisk(false);
|
gExePath.eraseFromDisk(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,11 @@ int runExecutable()
|
||||||
int status = llvm::sys::Program::ExecuteAndWait(gExePath, &args[0], NULL, NULL, 0,0, &errstr);
|
int status = llvm::sys::Program::ExecuteAndWait(gExePath, &args[0], NULL, NULL, 0,0, &errstr);
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
{
|
{
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
error("program received signal %d", -status);
|
||||||
|
#else
|
||||||
error("program received signal %d (%s)", -status, strsignal(-status));
|
error("program received signal %d (%s)", -status, strsignal(-status));
|
||||||
|
#endif
|
||||||
return -status;
|
return -status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1137,7 +1137,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration)
|
||||||
// choose the right set in case this is a conditional declaration
|
// choose the right set in case this is a conditional declaration
|
||||||
Array *d = a->include(NULL, NULL);
|
Array *d = a->include(NULL, NULL);
|
||||||
if (d)
|
if (d)
|
||||||
for (int i=0; i < d->dim; ++i)
|
for (unsigned i=0; i < d->dim; ++i)
|
||||||
{
|
{
|
||||||
DtoDeclarationExp((Dsymbol*)d->data[i]);
|
DtoDeclarationExp((Dsymbol*)d->data[i]);
|
||||||
}
|
}
|
||||||
|
@ -1146,7 +1146,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration)
|
||||||
else if (TemplateMixin* m = declaration->isTemplateMixin())
|
else if (TemplateMixin* m = declaration->isTemplateMixin())
|
||||||
{
|
{
|
||||||
Logger::println("TemplateMixin");
|
Logger::println("TemplateMixin");
|
||||||
for (int i=0; i < m->members->dim; ++i)
|
for (unsigned i=0; i < m->members->dim; ++i)
|
||||||
{
|
{
|
||||||
Dsymbol* mdsym = (Dsymbol*)m->members->data[i];
|
Dsymbol* mdsym = (Dsymbol*)m->members->data[i];
|
||||||
DtoDeclarationExp(mdsym);
|
DtoDeclarationExp(mdsym);
|
||||||
|
@ -1162,7 +1162,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(tupled->objects);
|
assert(tupled->objects);
|
||||||
for (int i=0; i < tupled->objects->dim; ++i)
|
for (unsigned i=0; i < tupled->objects->dim; ++i)
|
||||||
{
|
{
|
||||||
DsymbolExp* exp = (DsymbolExp*)tupled->objects->data[i];
|
DsymbolExp* exp = (DsymbolExp*)tupled->objects->data[i];
|
||||||
DtoDeclarationExp(exp->s);
|
DtoDeclarationExp(exp->s);
|
||||||
|
@ -1640,7 +1640,7 @@ bool hasUnalignedFields(Type* t)
|
||||||
|
|
||||||
// go through all the fields and try to find something unaligned
|
// go through all the fields and try to find something unaligned
|
||||||
ts->unaligned = 2;
|
ts->unaligned = 2;
|
||||||
for (int i = 0; i < sym->fields.dim; i++)
|
for (unsigned i = 0; i < sym->fields.dim; i++)
|
||||||
{
|
{
|
||||||
VarDeclaration* f = (VarDeclaration*)sym->fields.data[i];
|
VarDeclaration* f = (VarDeclaration*)sym->fields.data[i];
|
||||||
unsigned a = f->type->alignsize() - 1;
|
unsigned a = f->type->alignsize() - 1;
|
||||||
|
|
26
gen/main.cpp
26
gen/main.cpp
|
@ -322,7 +322,7 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (libs)
|
if (libs)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < libs->dim; i++)
|
for (unsigned i = 0; i < libs->dim; i++)
|
||||||
{
|
{
|
||||||
char* lib = (char *)libs->data[i];
|
char* lib = (char *)libs->data[i];
|
||||||
char *arg = (char *)mem.malloc(strlen(lib) + 3);
|
char *arg = (char *)mem.malloc(strlen(lib) + 3);
|
||||||
|
@ -664,7 +664,7 @@ int main(int argc, char** argv)
|
||||||
// Build import search path
|
// Build import search path
|
||||||
if (global.params.imppath)
|
if (global.params.imppath)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < global.params.imppath->dim; i++)
|
for (unsigned i = 0; i < global.params.imppath->dim; i++)
|
||||||
{
|
{
|
||||||
char *path = (char *)global.params.imppath->data[i];
|
char *path = (char *)global.params.imppath->data[i];
|
||||||
Strings *a = FileName::splitPath(path);
|
Strings *a = FileName::splitPath(path);
|
||||||
|
@ -681,7 +681,7 @@ int main(int argc, char** argv)
|
||||||
// Build string import search path
|
// Build string import search path
|
||||||
if (global.params.fileImppath)
|
if (global.params.fileImppath)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < global.params.fileImppath->dim; i++)
|
for (unsigned i = 0; i < global.params.fileImppath->dim; i++)
|
||||||
{
|
{
|
||||||
char *path = (char *)global.params.fileImppath->data[i];
|
char *path = (char *)global.params.fileImppath->data[i];
|
||||||
Strings *a = FileName::splitPath(path);
|
Strings *a = FileName::splitPath(path);
|
||||||
|
@ -698,7 +698,7 @@ int main(int argc, char** argv)
|
||||||
// Create Modules
|
// Create Modules
|
||||||
Modules modules;
|
Modules modules;
|
||||||
modules.reserve(files.dim);
|
modules.reserve(files.dim);
|
||||||
for (int i = 0; i < files.dim; i++)
|
for (unsigned i = 0; i < files.dim; i++)
|
||||||
{ Identifier *id;
|
{ Identifier *id;
|
||||||
char *ext;
|
char *ext;
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -805,7 +805,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read files, parse them
|
// Read files, parse them
|
||||||
for (int i = 0; i < modules.dim; i++)
|
for (unsigned i = 0; i < modules.dim; i++)
|
||||||
{
|
{
|
||||||
m = (Module *)modules.data[i];
|
m = (Module *)modules.data[i];
|
||||||
if (global.params.verbose)
|
if (global.params.verbose)
|
||||||
|
@ -840,7 +840,7 @@ int main(int argc, char** argv)
|
||||||
* line switches and what else is imported, they are generated
|
* line switches and what else is imported, they are generated
|
||||||
* before any semantic analysis.
|
* before any semantic analysis.
|
||||||
*/
|
*/
|
||||||
for (int i = 0; i < modules.dim; i++)
|
for (unsigned i = 0; i < modules.dim; i++)
|
||||||
{
|
{
|
||||||
m = (Module *)modules.data[i];
|
m = (Module *)modules.data[i];
|
||||||
if (global.params.verbose)
|
if (global.params.verbose)
|
||||||
|
@ -853,7 +853,7 @@ int main(int argc, char** argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// load all unconditional imports for better symbol resolving
|
// load all unconditional imports for better symbol resolving
|
||||||
for (int i = 0; i < modules.dim; i++)
|
for (unsigned i = 0; i < modules.dim; i++)
|
||||||
{
|
{
|
||||||
m = (Module *)modules.data[i];
|
m = (Module *)modules.data[i];
|
||||||
if (global.params.verbose)
|
if (global.params.verbose)
|
||||||
|
@ -864,7 +864,7 @@ int main(int argc, char** argv)
|
||||||
fatal();
|
fatal();
|
||||||
|
|
||||||
// Do semantic analysis
|
// Do semantic analysis
|
||||||
for (int i = 0; i < modules.dim; i++)
|
for (unsigned i = 0; i < modules.dim; i++)
|
||||||
{
|
{
|
||||||
m = (Module *)modules.data[i];
|
m = (Module *)modules.data[i];
|
||||||
if (global.params.verbose)
|
if (global.params.verbose)
|
||||||
|
@ -878,7 +878,7 @@ int main(int argc, char** argv)
|
||||||
Module::runDeferredSemantic();
|
Module::runDeferredSemantic();
|
||||||
|
|
||||||
// Do pass 2 semantic analysis
|
// Do pass 2 semantic analysis
|
||||||
for (int i = 0; i < modules.dim; i++)
|
for (unsigned i = 0; i < modules.dim; i++)
|
||||||
{
|
{
|
||||||
m = (Module *)modules.data[i];
|
m = (Module *)modules.data[i];
|
||||||
if (global.params.verbose)
|
if (global.params.verbose)
|
||||||
|
@ -889,7 +889,7 @@ int main(int argc, char** argv)
|
||||||
fatal();
|
fatal();
|
||||||
|
|
||||||
// Do pass 3 semantic analysis
|
// Do pass 3 semantic analysis
|
||||||
for (int i = 0; i < modules.dim; i++)
|
for (unsigned i = 0; i < modules.dim; i++)
|
||||||
{
|
{
|
||||||
m = (Module *)modules.data[i];
|
m = (Module *)modules.data[i];
|
||||||
if (global.params.verbose)
|
if (global.params.verbose)
|
||||||
|
@ -919,7 +919,7 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
// Do pass 3 semantic analysis on all imported modules,
|
// Do pass 3 semantic analysis on all imported modules,
|
||||||
// since otherwise functions in them cannot be inlined
|
// since otherwise functions in them cannot be inlined
|
||||||
for (int i = 0; i < Module::amodules.dim; i++)
|
for (unsigned i = 0; i < Module::amodules.dim; i++)
|
||||||
{
|
{
|
||||||
m = (Module *)Module::amodules.data[i];
|
m = (Module *)Module::amodules.data[i];
|
||||||
if (global.params.verbose)
|
if (global.params.verbose)
|
||||||
|
@ -959,7 +959,7 @@ int main(int argc, char** argv)
|
||||||
llvm::LLVMContext& context = llvm::getGlobalContext();
|
llvm::LLVMContext& context = llvm::getGlobalContext();
|
||||||
|
|
||||||
// Generate output files
|
// Generate output files
|
||||||
for (int i = 0; i < modules.dim; i++)
|
for (unsigned i = 0; i < modules.dim; i++)
|
||||||
{
|
{
|
||||||
m = (Module *)modules.data[i];
|
m = (Module *)modules.data[i];
|
||||||
if (global.params.verbose)
|
if (global.params.verbose)
|
||||||
|
@ -1034,7 +1034,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
/* Delete .obj files and .exe file
|
/* Delete .obj files and .exe file
|
||||||
*/
|
*/
|
||||||
for (int i = 0; i < modules.dim; i++)
|
for (unsigned i = 0; i < modules.dim; i++)
|
||||||
{
|
{
|
||||||
m = (Module *)modules.data[i];
|
m = (Module *)modules.data[i];
|
||||||
m->deleteObjFile();
|
m->deleteObjFile();
|
||||||
|
|
|
@ -36,7 +36,7 @@ void CompoundStatement::toIR(IRState* p)
|
||||||
Logger::println("CompoundStatement::toIR(): %s", loc.toChars());
|
Logger::println("CompoundStatement::toIR(): %s", loc.toChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
for (int i=0; i<statements->dim; i++)
|
for (unsigned i=0; i<statements->dim; i++)
|
||||||
{
|
{
|
||||||
Statement* s = (Statement*)statements->data[i];
|
Statement* s = (Statement*)statements->data[i];
|
||||||
if (s) {
|
if (s) {
|
||||||
|
@ -741,7 +741,7 @@ void TryCatchStatement::toIR(IRState* p)
|
||||||
gIR->scope() = IRScope(landingpadbb, endbb);
|
gIR->scope() = IRScope(landingpadbb, endbb);
|
||||||
|
|
||||||
IRLandingPad& pad = gIR->func()->gen->landingPadInfo;
|
IRLandingPad& pad = gIR->func()->gen->landingPadInfo;
|
||||||
for (int i = 0; i < catches->dim; i++)
|
for (unsigned i = 0; i < catches->dim; i++)
|
||||||
{
|
{
|
||||||
Catch *c = (Catch *)catches->data[i];
|
Catch *c = (Catch *)catches->data[i];
|
||||||
pad.addCatch(c, endbb);
|
pad.addCatch(c, endbb);
|
||||||
|
@ -870,7 +870,7 @@ void SwitchStatement::toIR(IRState* p)
|
||||||
llvm::BasicBlock* oldend = gIR->scopeend();
|
llvm::BasicBlock* oldend = gIR->scopeend();
|
||||||
|
|
||||||
// clear data from previous passes... :/
|
// clear data from previous passes... :/
|
||||||
for (int i=0; i<cases->dim; ++i)
|
for (unsigned i=0; i<cases->dim; ++i)
|
||||||
{
|
{
|
||||||
CaseStatement* cs = (CaseStatement*)cases->data[i];
|
CaseStatement* cs = (CaseStatement*)cases->data[i];
|
||||||
cs->bodyBB = NULL;
|
cs->bodyBB = NULL;
|
||||||
|
@ -881,7 +881,7 @@ void SwitchStatement::toIR(IRState* p)
|
||||||
// 'switch' instruction (that can happen because D2 allows to
|
// 'switch' instruction (that can happen because D2 allows to
|
||||||
// initialize a global variable in a static constructor).
|
// initialize a global variable in a static constructor).
|
||||||
bool useSwitchInst = true;
|
bool useSwitchInst = true;
|
||||||
for (int i=0; i<cases->dim; ++i)
|
for (unsigned i=0; i<cases->dim; ++i)
|
||||||
{
|
{
|
||||||
CaseStatement* cs = (CaseStatement*)cases->data[i];
|
CaseStatement* cs = (CaseStatement*)cases->data[i];
|
||||||
VarDeclaration* vd = 0;
|
VarDeclaration* vd = 0;
|
||||||
|
@ -928,7 +928,7 @@ void SwitchStatement::toIR(IRState* p)
|
||||||
Logger::println("is string switch");
|
Logger::println("is string switch");
|
||||||
// build array of the stringexpS
|
// build array of the stringexpS
|
||||||
caseArray.reserve(cases->dim);
|
caseArray.reserve(cases->dim);
|
||||||
for (int i=0; i<cases->dim; ++i)
|
for (unsigned i=0; i<cases->dim; ++i)
|
||||||
{
|
{
|
||||||
CaseStatement* cs = (CaseStatement*)cases->data[i];
|
CaseStatement* cs = (CaseStatement*)cases->data[i];
|
||||||
|
|
||||||
|
@ -980,7 +980,7 @@ void SwitchStatement::toIR(IRState* p)
|
||||||
|
|
||||||
// create switch and add the cases
|
// create switch and add the cases
|
||||||
llvm::SwitchInst* si = llvm::SwitchInst::Create(condVal, defbb ? defbb : endbb, cases->dim, p->scopebb());
|
llvm::SwitchInst* si = llvm::SwitchInst::Create(condVal, defbb ? defbb : endbb, cases->dim, p->scopebb());
|
||||||
for (int i=0; i<cases->dim; ++i)
|
for (unsigned i=0; i<cases->dim; ++i)
|
||||||
{
|
{
|
||||||
CaseStatement* cs = (CaseStatement*)cases->data[i];
|
CaseStatement* cs = (CaseStatement*)cases->data[i];
|
||||||
si->addCase(isaConstantInt(cs->llvmIdx), cs->bodyBB);
|
si->addCase(isaConstantInt(cs->llvmIdx), cs->bodyBB);
|
||||||
|
@ -995,7 +995,7 @@ void SwitchStatement::toIR(IRState* p)
|
||||||
llvm::BranchInst::Create(nextbb, p->scopebb());
|
llvm::BranchInst::Create(nextbb, p->scopebb());
|
||||||
|
|
||||||
p->scope() = IRScope(nextbb, endbb);
|
p->scope() = IRScope(nextbb, endbb);
|
||||||
for (int i=0; i<cases->dim; ++i)
|
for (unsigned i=0; i<cases->dim; ++i)
|
||||||
{
|
{
|
||||||
CaseStatement* cs = (CaseStatement*)cases->data[i];
|
CaseStatement* cs = (CaseStatement*)cases->data[i];
|
||||||
|
|
||||||
|
|
14
gen/toir.cpp
14
gen/toir.cpp
|
@ -478,7 +478,7 @@ DValue* StringExp::toElem(IRState* p)
|
||||||
|
|
||||||
llvm::ConstantInt* zero = LLConstantInt::get(LLType::getInt32Ty(gIR->context()), 0, false);
|
llvm::ConstantInt* zero = LLConstantInt::get(LLType::getInt32Ty(gIR->context()), 0, false);
|
||||||
LLConstant* idxs[2] = { zero, zero };
|
LLConstant* idxs[2] = { zero, zero };
|
||||||
LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
|
LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true);
|
||||||
|
|
||||||
if (dtype->ty == Tarray) {
|
if (dtype->ty == Tarray) {
|
||||||
LLConstant* clen = LLConstantInt::get(DtoSize_t(),len,false);
|
LLConstant* clen = LLConstantInt::get(DtoSize_t(),len,false);
|
||||||
|
@ -554,7 +554,7 @@ LLConstant* StringExp::toConstElem(IRState* p)
|
||||||
|
|
||||||
llvm::ConstantInt* zero = LLConstantInt::get(LLType::getInt32Ty(gIR->context()), 0, false);
|
llvm::ConstantInt* zero = LLConstantInt::get(LLType::getInt32Ty(gIR->context()), 0, false);
|
||||||
LLConstant* idxs[2] = { zero, zero };
|
LLConstant* idxs[2] = { zero, zero };
|
||||||
LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
|
LLConstant* arrptr = llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true);
|
||||||
|
|
||||||
if (t->ty == Tpointer) {
|
if (t->ty == Tpointer) {
|
||||||
return arrptr;
|
return arrptr;
|
||||||
|
@ -1074,7 +1074,7 @@ LLConstant* CastExp::toConstElem(IRState* p)
|
||||||
Type *type = vd->type->toBasetype();
|
Type *type = vd->type->toBasetype();
|
||||||
if (type->ty == Tarray || type->ty == Tdelegate) {
|
if (type->ty == Tarray || type->ty == Tdelegate) {
|
||||||
LLConstant* idxs[2] = { DtoConstSize_t(0), DtoConstSize_t(1) };
|
LLConstant* idxs[2] = { DtoConstSize_t(0), DtoConstSize_t(1) };
|
||||||
value = llvm::ConstantExpr::getGetElementPtr(value, idxs, 2);
|
value = llvm::ConstantExpr::getGetElementPtr(value, idxs, true);
|
||||||
}
|
}
|
||||||
return DtoBitCast(value, DtoType(tb));
|
return DtoBitCast(value, DtoType(tb));
|
||||||
}
|
}
|
||||||
|
@ -1206,7 +1206,7 @@ LLConstant* AddrExp::toConstElem(IRState* p)
|
||||||
LLConstant* idxs[2] = { DtoConstSize_t(0), index };
|
LLConstant* idxs[2] = { DtoConstSize_t(0), index };
|
||||||
LLConstant *val = isaConstant(vd->ir.irGlobal->value);
|
LLConstant *val = isaConstant(vd->ir.irGlobal->value);
|
||||||
val = DtoBitCast(val, DtoType(vd->type->pointerTo()));
|
val = DtoBitCast(val, DtoType(vd->type->pointerTo()));
|
||||||
LLConstant* gep = llvm::ConstantExpr::getGetElementPtr(val, idxs, 2);
|
LLConstant* gep = llvm::ConstantExpr::getGetElementPtr(val, idxs, true);
|
||||||
|
|
||||||
// bitcast to requested type
|
// bitcast to requested type
|
||||||
assert(type->toBasetype()->ty == Tpointer);
|
assert(type->toBasetype()->ty == Tpointer);
|
||||||
|
@ -2751,7 +2751,7 @@ LLConstant* ArrayLiteralExp::toConstElem(IRState* p)
|
||||||
|
|
||||||
// build a constant dynamic array reference with the .ptr field pointing into globalstore
|
// build a constant dynamic array reference with the .ptr field pointing into globalstore
|
||||||
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
|
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
|
||||||
LLConstant* globalstorePtr = llvm::ConstantExpr::getGetElementPtr(globalstore, idxs, 2);
|
LLConstant* globalstorePtr = llvm::ConstantExpr::getGetElementPtr(globalstore, idxs, true);
|
||||||
|
|
||||||
return DtoConstSlice(DtoConstSize_t(elements->dim), globalstorePtr);
|
return DtoConstSlice(DtoConstSize_t(elements->dim), globalstorePtr);
|
||||||
}
|
}
|
||||||
|
@ -2975,14 +2975,14 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p)
|
||||||
LLArrayType* arrtype = LLArrayType::get(DtoType(indexType), keys->dim);
|
LLArrayType* arrtype = LLArrayType::get(DtoType(indexType), keys->dim);
|
||||||
LLConstant* initval = LLConstantArray::get(arrtype, keysInits);
|
LLConstant* initval = LLConstantArray::get(arrtype, keysInits);
|
||||||
LLConstant* globalstore = new LLGlobalVariable(*gIR->module, arrtype, false, LLGlobalValue::InternalLinkage, initval, ".aaKeysStorage");
|
LLConstant* globalstore = new LLGlobalVariable(*gIR->module, arrtype, false, LLGlobalValue::InternalLinkage, initval, ".aaKeysStorage");
|
||||||
LLConstant* slice = llvm::ConstantExpr::getGetElementPtr(globalstore, idxs, 2);
|
LLConstant* slice = llvm::ConstantExpr::getGetElementPtr(globalstore, idxs, true);
|
||||||
slice = DtoConstSlice(DtoConstSize_t(keys->dim), slice);
|
slice = DtoConstSlice(DtoConstSize_t(keys->dim), slice);
|
||||||
LLValue* keysArray = DtoAggrPaint(slice, funcTy->getParamType(1));
|
LLValue* keysArray = DtoAggrPaint(slice, funcTy->getParamType(1));
|
||||||
|
|
||||||
arrtype = LLArrayType::get(DtoType(vtype), values->dim);
|
arrtype = LLArrayType::get(DtoType(vtype), values->dim);
|
||||||
initval = LLConstantArray::get(arrtype, valuesInits);
|
initval = LLConstantArray::get(arrtype, valuesInits);
|
||||||
globalstore = new LLGlobalVariable(*gIR->module, arrtype, false, LLGlobalValue::InternalLinkage, initval, ".aaValuesStorage");
|
globalstore = new LLGlobalVariable(*gIR->module, arrtype, false, LLGlobalValue::InternalLinkage, initval, ".aaValuesStorage");
|
||||||
slice = llvm::ConstantExpr::getGetElementPtr(globalstore, idxs, 2);
|
slice = llvm::ConstantExpr::getGetElementPtr(globalstore, idxs, true);
|
||||||
slice = DtoConstSlice(DtoConstSize_t(keys->dim), slice);
|
slice = DtoConstSlice(DtoConstSize_t(keys->dim), slice);
|
||||||
LLValue* valuesArray = DtoAggrPaint(slice, funcTy->getParamType(2));
|
LLValue* valuesArray = DtoAggrPaint(slice, funcTy->getParamType(2));
|
||||||
|
|
||||||
|
|
|
@ -447,7 +447,7 @@ LLValue* DtoGEPi(LLValue* ptr, unsigned i0, unsigned i1, const char* var, llvm::
|
||||||
LLConstant* DtoGEPi(LLConstant* ptr, unsigned i0, unsigned i1)
|
LLConstant* DtoGEPi(LLConstant* ptr, unsigned i0, unsigned i1)
|
||||||
{
|
{
|
||||||
LLValue* v[2] = { DtoConstUint(i0), DtoConstUint(i1) };
|
LLValue* v[2] = { DtoConstUint(i0), DtoConstUint(i1) };
|
||||||
return llvm::ConstantExpr::getGetElementPtr(ptr, v, 2);
|
return llvm::ConstantExpr::getGetElementPtr(ptr, v, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -596,7 +596,7 @@ LLConstant* DtoConstString(const char* str)
|
||||||
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
|
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
|
||||||
return DtoConstSlice(
|
return DtoConstSlice(
|
||||||
DtoConstSize_t(s.size()),
|
DtoConstSize_t(s.size()),
|
||||||
llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2),
|
llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true),
|
||||||
Type::tchar->arrayOf()
|
Type::tchar->arrayOf()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -608,7 +608,7 @@ LLConstant* DtoConstStringPtr(const char* str, const char* section)
|
||||||
*gIR->module, init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str");
|
*gIR->module, init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str");
|
||||||
if (section) gvar->setSection(section);
|
if (section) gvar->setSection(section);
|
||||||
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
|
LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
|
||||||
return llvm::ConstantExpr::getGetElementPtr(gvar,idxs,2);
|
return llvm::ConstantExpr::getGetElementPtr(gvar, idxs, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -134,7 +134,7 @@ llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir)
|
||||||
LLVM_D_InitRuntime();
|
LLVM_D_InitRuntime();
|
||||||
|
|
||||||
// process module members
|
// process module members
|
||||||
for (int k=0; k < members->dim; k++) {
|
for (unsigned k=0; k < members->dim; k++) {
|
||||||
Dsymbol* dsym = (Dsymbol*)(members->data[k]);
|
Dsymbol* dsym = (Dsymbol*)(members->data[k]);
|
||||||
assert(dsym);
|
assert(dsym);
|
||||||
dsym->codegen(sir);
|
dsym->codegen(sir);
|
||||||
|
@ -275,7 +275,7 @@ void writeModule(llvm::Module* m, std::string filename)
|
||||||
Logger::println("Writing object file to: %s\n", objpath.c_str());
|
Logger::println("Writing object file to: %s\n", objpath.c_str());
|
||||||
std::string err;
|
std::string err;
|
||||||
{
|
{
|
||||||
llvm::raw_fd_ostream out(objpath.c_str(), err);
|
llvm::raw_fd_ostream out(objpath.c_str(), err, llvm::raw_fd_ostream::F_Binary);
|
||||||
if (err.empty())
|
if (err.empty())
|
||||||
{
|
{
|
||||||
emit_file(*gTargetMachine, *m, out, llvm::TargetMachine::CGFT_ObjectFile);
|
emit_file(*gTargetMachine, *m, out, llvm::TargetMachine::CGFT_ObjectFile);
|
||||||
|
|
|
@ -711,7 +711,7 @@ void TypeInfoStructDeclaration::llvmDefine()
|
||||||
{
|
{
|
||||||
TypeTuple *tup = tc->toArgTypes();
|
TypeTuple *tup = tc->toArgTypes();
|
||||||
assert(tup->arguments->dim <= 2);
|
assert(tup->arguments->dim <= 2);
|
||||||
for (int i = 0; i < 2; i++)
|
for (unsigned i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
if (i < tup->arguments->dim)
|
if (i < tup->arguments->dim)
|
||||||
{
|
{
|
||||||
|
|
|
@ -377,7 +377,7 @@ llvm::GlobalVariable * IrStruct::getInterfaceVtbl(BaseClass * b, bool new_instan
|
||||||
};
|
};
|
||||||
|
|
||||||
llvm::Constant* c = llvm::ConstantExpr::getGetElementPtr(
|
llvm::Constant* c = llvm::ConstantExpr::getGetElementPtr(
|
||||||
getInterfaceArraySymbol(), idxs, 2);
|
getInterfaceArraySymbol(), idxs, true);
|
||||||
|
|
||||||
constants.push_back(c);
|
constants.push_back(c);
|
||||||
|
|
||||||
|
@ -533,7 +533,7 @@ LLConstant * IrStruct::getClassInfoInterfaces()
|
||||||
};
|
};
|
||||||
|
|
||||||
LLConstant* ptr = llvm::ConstantExpr::getGetElementPtr(
|
LLConstant* ptr = llvm::ConstantExpr::getGetElementPtr(
|
||||||
classInterfacesArray, idxs, 2);
|
classInterfacesArray, idxs, true);
|
||||||
|
|
||||||
// return as a slice
|
// return as a slice
|
||||||
return DtoConstSlice( DtoConstSize_t(cd->vtblInterfaces->dim), ptr );
|
return DtoConstSlice( DtoConstSize_t(cd->vtblInterfaces->dim), ptr );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue