Merge pull request #283 from klickverbot/master

Cleanup.
This commit is contained in:
David Nadlinger
2013-02-07 13:10:09 -08:00
96 changed files with 725 additions and 800 deletions

View File

@@ -20,9 +20,9 @@
#include <map>
#include <string>
#if LDC_LLVM_VER >= 302
#include <llvm/DebugInfo.h>
#include "llvm/DebugInfo.h"
#else
#include <llvm/Analysis/DebugInfo.h>
#include "llvm/Analysis/DebugInfo.h"
#endif
#endif

View File

@@ -140,18 +140,7 @@ the target object file format:
struct OutBuffer;
// LDC
enum ARCH
{
ARCHinvalid = llvm::Triple::UnknownArch,
ARCHx86 = llvm::Triple::x86,
ARCHx86_64 = llvm::Triple::x86_64,
ARCHppc = llvm::Triple::ppc,
ARCHppc_64 = llvm::Triple::ppc64,
ARCHarm = llvm::Triple::arm,
ARCHthumb = llvm::Triple::thumb,
};
#if IN_LLVM
enum OUTPUTFLAG
{
OUTPUTFLAGno,
@@ -169,6 +158,7 @@ enum OS
OSFreeBSD = llvm::Triple::FreeBSD,
OSSolaris = llvm::Triple::Solaris,
};
#endif
typedef unsigned char ubyte;
@@ -191,10 +181,7 @@ struct Param
#endif
char vtls; // identify thread local variables
// KN Start merge conflict
ARCH cpu; // target CPU
OS os; // target OS
bool is64bit; // generate 64 bit code
bool isLE; // generate little endian code
bool useDeprecated; // allow use of deprecated features
bool useAssert; // generate runtime code for assert()'s
bool useInvariants; // generate class invariant checks

View File

@@ -168,6 +168,7 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
#endif
}
#if IN_LLVM
File* Module::buildFilePath(const char* forcename, const char* path, const char* ext)
{
const char *argobj;
@@ -219,7 +220,6 @@ File* Module::buildFilePath(const char* forcename, const char* path, const char*
return new File(FileName::forceExt(argobj, ext));
}
// LDC
static void check_and_add_output_file(Module* NewMod, const std::string& str)
{
typedef std::map<std::string, Module*> map_t;
@@ -252,7 +252,8 @@ void Module::buildTargetFiles(bool singleObj)
else if (global.params.output_s)
objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.s_ext);
else
objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.params.os == OSWindows ? global.obj_ext_alt : global.obj_ext);
objfile = Module::buildFilePath(global.params.objname, global.params.objdir,
global.params.targetTriple.isOSWindows() ? global.obj_ext_alt : global.obj_ext);
}
if(doDocComment && !docfile)
docfile = Module::buildFilePath(global.params.docname, global.params.docdir, global.doc_ext);
@@ -285,6 +286,7 @@ void Module::buildTargetFiles(bool singleObj)
if (hdrfile)
check_and_add_output_file(this, hdrfile->name->str);
}
#endif
void Module::deleteObjFile()
{

View File

@@ -276,12 +276,12 @@ void Type::init()
}
// set real size and padding
if (global.params.cpu == ARCHx86)
if (global.params.targetTriple.getArch() == llvm::Triple::x86)
{
REALSIZE = 12;
REALPAD = 2;
}
else if (global.params.cpu == ARCHx86_64)
else if (global.params.targetTriple.getArch() == llvm::Triple::x86_64)
{
REALSIZE = 16;
REALPAD = 6;
@@ -1175,8 +1175,11 @@ unsigned TypeBasic::alignsize()
#if IN_LLVM
unsigned TypeBasic::memalign(unsigned salign)
{
if (global.params.cpu == ARCHx86_64 && (ty == Tfloat80 || ty == Timaginary80))
if (global.params.targetTriple.getArch() == llvm::Triple::x86_64 &&
(ty == Tfloat80 || ty == Timaginary80))
{
return 16;
}
return Type::memalign(salign);
}
#endif

View File

@@ -671,11 +671,18 @@ enum LINK Parser::parseLinkage()
}
else if (id == Id::System)
{
// LDC we configure target at runtime
if (global.params.os == OSWindows)
#if IN_LLVM
if (global.params.targetTriple.isOSWindows())
link = LINKwindows;
else
link = LINKc;
#else
#if _WIN32
link = LINKwindows;
#else
link = LINKc;
#endif
#endif
}
else
{

View File

@@ -47,9 +47,9 @@ int os_critsecsize()
// Return sizeof(RTL_CRITICAL_SECTION)
return global.params.is64bit ? 40 : 24;
#else
if (global.params.os == OSWindows)
if (global.params.targetTriple.isOSWindows())
return global.params.is64bit ? 40 : 24;
else if (global.params.os == OSFreeBSD)
else if (global.params.targetTriple.getOS() == llvm::Triple::FreeBSD)
return sizeof(size_t);
else
return sizeof(pthread_mutex_t);

View File

@@ -20,9 +20,9 @@
#include <map>
#include <string>
#if LDC_LLVM_VER >= 302
#include <llvm/DebugInfo.h>
#include "llvm/DebugInfo.h"
#else
#include <llvm/Analysis/DebugInfo.h>
#include "llvm/Analysis/DebugInfo.h"
#endif
#endif

View File

@@ -147,17 +147,6 @@ typedef ArrayBase<struct Identifier> Identifiers;
typedef ArrayBase<char> Strings;
#if IN_LLVM
enum ARCH
{
ARCHinvalid = llvm::Triple::UnknownArch,
ARCHx86 = llvm::Triple::x86,
ARCHx86_64 = llvm::Triple::x86_64,
ARCHppc = llvm::Triple::ppc,
ARCHppc_64 = llvm::Triple::ppc64,
ARCHarm = llvm::Triple::arm,
ARCHthumb = llvm::Triple::thumb,
};
enum OUTPUTFLAG
{
OUTPUTFLAGno,
@@ -165,17 +154,6 @@ enum OUTPUTFLAG
OUTPUTFLAGset // for -output
};
enum OS
{
OSinvalid = llvm::Triple::UnknownOS,
OSLinux = llvm::Triple::Linux,
OSHaiku = llvm::Triple::Haiku,
OSWindows = llvm::Triple::Win32,
OSMacOSX = llvm::Triple::MacOSX,
OSFreeBSD = llvm::Triple::FreeBSD,
OSSolaris = llvm::Triple::Solaris,
};
typedef unsigned char ubyte;
#endif
@@ -200,12 +178,8 @@ struct Param
char optimize; // run optimizer
#endif
char map; // generate linker .map file
ARCH cpu; // target CPU
bool isLE; // generate little endian code
bool is64bit; // generate 64 bit code
#if IN_LLVM
OS os;
#else
#if !IN_LLVM
char isLinux; // generate code for linux
char isOSX; // generate code for Mac OSX
char isWindows; // generate code for Windows

View File

@@ -357,7 +357,8 @@ void Module::buildTargetFiles(bool singleObj)
if(!objfile)
{
if (global.params.output_o)
objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.params.os == OSWindows ? global.obj_ext_alt : global.obj_ext);
objfile = Module::buildFilePath(global.params.objname, global.params.objdir,
global.params.targetTriple.isOSWindows() ? global.obj_ext_alt : global.obj_ext);
else if (global.params.output_bc)
objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.bc_ext);
else if (global.params.output_ll)

View File

@@ -2923,8 +2923,11 @@ unsigned TypeBasic::alignsize()
#if IN_LLVM
unsigned TypeBasic::alignment()
{
if (global.params.cpu == ARCHx86_64 && (ty == Tfloat80 || ty == Timaginary80))
if (global.params.targetTriple.getArch() == llvm::Triple::x86_64 &&
(ty == Tfloat80 || ty == Timaginary80))
{
return 16;
}
return Type::alignment();
}
#endif

View File

@@ -980,11 +980,18 @@ enum LINK Parser::parseLinkage()
}
else if (id == Id::System)
{
// LDC we configure target at runtime
if (global.params.os == OSWindows)
#if IN_LLVM
if (global.params.targetTriple.isOSWindows())
link = LINKwindows;
else
link = LINKc;
#else
#if _WIN32
link = LINKwindows;
else
#else
link = LINKc;
#endif
#endif
}
else
{

View File

@@ -44,9 +44,9 @@ int os_critsecsize()
// Return sizeof(RTL_CRITICAL_SECTION)
return global.params.is64bit ? 40 : 24;
#else
if (global.params.os == OSWindows)
if (global.params.targetTriple.isOSWindows())
return global.params.is64bit ? 40 : 24;
else if (global.params.os == OSFreeBSD)
else if (global.params.targetTriple.getOS() == llvm::Triple::FreeBSD)
return sizeof(size_t);
else
return sizeof(pthread_mutex_t);

View File

@@ -9,7 +9,8 @@
#include "driver/cl_options.h"
#include "gen/cl_helpers.h"
#include "gen/logger.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Target/TargetMachine.h"
#if LDC_LLVM_VER >= 303
#include "llvm/IR/DataLayout.h"
@@ -19,10 +20,6 @@
#include "llvm/Target/TargetData.h"
#endif
#include "gen/logger.h"
#include "llvm/Support/CommandLine.h"
namespace opts {
// Positional options first, in order:

View File

@@ -12,17 +12,15 @@
//
//===----------------------------------------------------------------------===//
#ifndef LDC_CL_OPTIONS_H
#define LDC_CL_OPTIONS_H
#ifndef LDC_DRIVER_CL_OPTIONS_H
#define LDC_DRIVER_CL_OPTIONS_H
#include "mars.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/CommandLine.h"
#include <deque>
#include <vector>
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/CodeGen.h"
namespace opts {
namespace cl = llvm::cl;

View File

@@ -7,19 +7,15 @@
//
//===----------------------------------------------------------------------===//
#include <iostream>
#include <string>
#include <cassert>
#include <cstring>
#include "driver/configfile.h"
#include "mars.h"
#include "libconfig.h++"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "libconfig.h++"
#include "driver/configfile.h"
#include "mars.h"
#include <cassert>
#include <cstring>
#include <iostream>
#include <string>
namespace sys = llvm::sys;

View File

@@ -11,11 +11,13 @@
//
//===----------------------------------------------------------------------===//
#ifndef LDC_CONF_CONFIGFILE_H
#define LDC_CONF_CONFIGFILE_H
#ifndef LDC_DRIVER_CONFIGFILE_H
#define LDC_DRIVER_CONFIGFILE_H
#include <vector>
#include <string>
#include <vector>
namespace llvm { namespace sys { class Path; } }
namespace libconfig
{
@@ -48,4 +50,4 @@ private:
s_vector switches;
};
#endif // LDC_CONF_CONFIGFILE_H
#endif // LDC_DRIVER_CONFIGFILE_H

View File

@@ -48,6 +48,10 @@
# error "Please define LDC_EXE_NAME to the name of the LDC executable to use."
#endif
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/SystemUtils.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <cerrno>
#include <climits>
@@ -56,10 +60,6 @@
#include <cstdlib>
#include <numeric>
#include <vector>
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/SystemUtils.h"
#include "llvm/Support/raw_ostream.h"
#ifdef HAVE_SC_ARG_MAX
# include <unistd.h>

View File

@@ -7,27 +7,23 @@
//
//===----------------------------------------------------------------------===//
#include "driver/linker.h"
#include "mars.h"
#include "module.h"
#include "root.h"
#include "driver/cl_options.h"
#include "gen/llvm.h"
#include "llvm/Linker.h"
#include "gen/logger.h"
#include "gen/optimizer.h"
#include "gen/programs.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Linker.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Program.h"
#if _WIN32
#include "llvm/Support/SystemUtils.h"
#endif
#include "root.h"
#include "mars.h"
#include "module.h"
#define NO_COUT_LOGGER
#include "gen/logger.h"
#include "gen/optimizer.h"
#include "gen/programs.h"
#include "driver/linker.h"
#include "driver/cl_options.h"
//////////////////////////////////////////////////////////////////////////////
// Is this useful?
@@ -39,7 +35,7 @@ llvm::cl::opt<bool> quiet("quiet",
//////////////////////////////////////////////////////////////////////////////
bool endsWith(const std::string &str, const std::string &end)
static bool endsWith(const std::string &str, const std::string &end)
{
return (str.length() >= end.length() && std::equal(end.rbegin(), end.rend(), str.rbegin()));
}
@@ -120,9 +116,53 @@ static void CreateDirectoryOnDisk(llvm::StringRef fileName)
//////////////////////////////////////////////////////////////////////////////
static std::string getOutputName(bool const sharedLib)
{
if (!sharedLib && global.params.exefile)
{
return global.params.exefile;
}
if (sharedLib && global.params.objname)
{
return global.params.objname;
}
// Output name is inferred.
std::string result;
// try root module name
if (Module::rootModule)
result = Module::rootModule->toChars();
else if (global.params.objfiles->dim)
result = FileName::removeExt(static_cast<char*>(global.params.objfiles->data[0]));
else
result = "a.out";
if (sharedLib)
{
std::string libExt = std::string(".") + global.dll_ext;
if (!endsWith(result, libExt))
{
if (global.params.targetTriple.getOS() != llvm::Triple::Win32)
result = "lib" + result + libExt;
else
result.append(libExt);
}
}
else if (global.params.targetTriple.isOSWindows() && !endsWith(result, ".exe"))
{
result.append(".exe");
}
return result;
}
//////////////////////////////////////////////////////////////////////////////
static llvm::sys::Path gExePath;
int linkObjToBinaryGcc(bool sharedLib)
static int linkObjToBinaryGcc(bool sharedLib)
{
Logger::println("*** Linking executable ***");
@@ -147,38 +187,7 @@ int linkObjToBinaryGcc(bool sharedLib)
}
// output filename
std::string output;
if (!sharedLib && global.params.exefile)
{ // explicit
output = global.params.exefile;
}
else if (sharedLib && global.params.objname)
{ // explicit
output = global.params.objname;
}
else
{ // inferred
// try root module name
if (Module::rootModule)
output = Module::rootModule->toChars();
else if (global.params.objfiles->dim)
output = FileName::removeExt(static_cast<char*>(global.params.objfiles->data[0]));
else
output = "a.out";
if (sharedLib) {
std::string libExt = std::string(".") + global.dll_ext;
if (!endsWith(output, libExt))
{
if (global.params.os != OSWindows)
output = "lib" + output + libExt;
else
output.append(libExt);
}
} else if (global.params.os == OSWindows && !endsWith(output, ".exe")) {
output.append(".exe");
}
}
std::string output = getOutputName(sharedLib);
if (sharedLib)
args.push_back("-shared");
@@ -207,32 +216,30 @@ int linkObjToBinaryGcc(bool sharedLib)
// default libs
bool addSoname = false;
switch(global.params.os) {
case OSLinux:
switch (global.params.targetTriple.getOS()) {
case llvm::Triple::Linux:
addSoname = true;
args.push_back("-lrt");
// fallthrough
case OSMacOSX:
case llvm::Triple::Darwin:
case llvm::Triple::MacOSX:
args.push_back("-ldl");
// fallthrough
case OSFreeBSD:
case llvm::Triple::FreeBSD:
addSoname = true;
args.push_back("-lpthread");
args.push_back("-lm");
break;
case OSSolaris:
case llvm::Triple::Solaris:
args.push_back("-lm");
args.push_back("-lumem");
// solaris TODO
break;
case OSWindows:
// FIXME: I'd assume kernel32 etc
break;
default:
// OS not yet handled, will probably lead to linker errors.
// FIXME: Win32, MinGW.
break;
}
@@ -264,7 +271,7 @@ int linkObjToBinaryGcc(bool sharedLib)
//////////////////////////////////////////////////////////////////////////////
int linkObjToBinaryWin(bool sharedLib)
static int linkObjToBinaryWin(bool sharedLib)
{
Logger::println("*** Linking executable ***");
@@ -300,38 +307,8 @@ int linkObjToBinaryWin(bool sharedLib)
args.push_back("/DLL");
// output filename
std::string output;
if (!sharedLib && global.params.exefile)
{ // explicit
output = global.params.exefile;
}
else if (sharedLib && global.params.objname)
{ // explicit
output = global.params.objname;
}
else
{ // inferred
// try root module name
if (Module::rootModule)
output = Module::rootModule->toChars();
else if (global.params.objfiles->dim)
output = FileName::removeExt(static_cast<char*>(global.params.objfiles->data[0]));
else
output = "a.out";
std::string output = getOutputName(sharedLib);
if (sharedLib) {
std::string libExt = std::string(".") + global.dll_ext;
if (!endsWith(output, libExt))
{
if (global.params.os != OSWindows)
output = "lib" + output + libExt;
else
output.append(libExt);
}
} else if (global.params.os == OSWindows && !endsWith(output, ".exe")) {
output.append(".exe");
}
}
args.push_back("/OUT:" + output);
// object files

View File

@@ -12,8 +12,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef LDC_GEN_LINKER_H
#define LDC_GEN_LINKER_H
#ifndef LDC_DRIVER_LINKER_H
#define LDC_DRIVER_LINKER_H
#include "llvm/Support/CommandLine.h"
#include <vector>
@@ -55,4 +55,4 @@ void deleteExecutable();
*/
int runExecutable();
#endif // LDC_GEN_LINKER_H
#endif // LDC_DRIVER_LINKER_H

View File

@@ -7,9 +7,33 @@
//
//===----------------------------------------------------------------------===//
#include "gen/llvmcompat.h"
#include "id.h"
#include "json.h"
#include "mars.h"
#include "module.h"
#include "mtype.h"
#include "rmem.h"
#include "root.h"
#include "driver/cl_options.h"
#include "driver/configfile.h"
#include "driver/linker.h"
#include "driver/toobj.h"
#include "gen/cl_helpers.h"
#include "gen/irstate.h"
#include "gen/linkage.h"
#include "gen/llvm.h"
#include "gen/llvmcompat.h"
#include "gen/logger.h"
#include "gen/metadata.h"
#include "gen/optimizer.h"
#include "gen/passes/Passes.h"
#include "llvm/Linker.h"
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#if LDC_LLVM_VER >= 303
#include "llvm/LinkAllIR.h"
#include "llvm/IR/LLVMContext.h"
@@ -17,54 +41,26 @@
#include "llvm/LinkAllVMCore.h"
#include "llvm/LLVMContext.h"
#endif
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/Host.h"
#include "llvm/MC/SubtargetFeature.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include "rmem.h"
#include "root.h"
#include <stdio.h>
#include <stdlib.h>
#if POSIX
#include <errno.h>
#elif _WIN32
#include <windows.h>
#endif
// stricmp
#if __GNUC__ && !_WIN32
#include "gnuc.h"
#endif
#include "mars.h"
#include "module.h"
#include "mtype.h"
#include "id.h"
// Needs Type already declared.
#include "cond.h"
#include "json.h"
#include "gen/logger.h"
#include "gen/linkage.h"
#include "gen/irstate.h"
#include "gen/optimizer.h"
#include "gen/metadata.h"
#include "gen/passes/Passes.h"
#include "driver/linker.h"
#include "driver/cl_options.h"
#include "gen/cl_helpers.h"
using namespace opts;
#include "driver/configfile.h"
#include "driver/toobj.h"
#if POSIX
#include <errno.h>
#elif _WIN32
#include <windows.h>
#endif
extern void getenv_setargv(const char *envvar, int *pargc, char** *pargv);
extern void backend_init();
extern void backend_term();
@@ -588,11 +584,8 @@ int main(int argc, char** argv)
gDataLayout = target->getTargetData();
#endif
global.params.isLE = gDataLayout->isLittleEndian();
// Starting with LLVM 3.1 we could also use global.params.targetTriple.isArch64Bit();
global.params.is64bit = gDataLayout->getPointerSizeInBits(ADDRESS_SPACE) == 64;
global.params.cpu = static_cast<ARCH>(global.params.targetTriple.getArch());
global.params.os = static_cast<OS>(global.params.targetTriple.getOS());
switch (global.params.targetTriple.getArch())
{
@@ -656,7 +649,7 @@ int main(int argc, char** argv)
}
// endianness
if (global.params.isLE) {
if (gDataLayout->isLittleEndian()) {
VersionCondition::addPredefinedGlobalIdent("LittleEndian");
}
else {
@@ -683,7 +676,6 @@ int main(int argc, char** argv)
VersionCondition::addPredefinedGlobalIdent(global.params.is64bit ? "Win64" : "Win32");
break;
case llvm::Triple::MinGW32:
global.params.os = OSWindows; // FIXME: Check source for uses of MinGW32
VersionCondition::addPredefinedGlobalIdent("Windows");
VersionCondition::addPredefinedGlobalIdent(global.params.is64bit ? "Win64" : "Win32");
VersionCondition::addPredefinedGlobalIdent("mingw32"); // For backwards compatibility.
@@ -703,7 +695,6 @@ int main(int argc, char** argv)
VersionCondition::addPredefinedGlobalIdent("Posix");
break;
case llvm::Triple::Darwin:
global.params.os = OSMacOSX;
VersionCondition::addPredefinedGlobalIdent("OSX");
VersionCondition::addPredefinedGlobalIdent("darwin"); // For backwards compatibility.
VersionCondition::addPredefinedGlobalIdent("Posix");
@@ -748,7 +739,7 @@ int main(int argc, char** argv)
#undef XSTR
#undef STR
if (global.params.os == OSWindows) {
if (global.params.targetTriple.isOSWindows()) {
global.dll_ext = "dll";
global.lib_ext = "lib";
} else {

View File

@@ -7,26 +7,24 @@
//
//===----------------------------------------------------------------------===//
#include <cstddef>
#include <fstream>
#include "driver/toobj.h"
#include "gen/irstate.h"
#include "gen/logger.h"
#include "gen/optimizer.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/PassManager.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Program.h"
#include "llvm/Target/TargetMachine.h"
#if LDC_LLVM_VER >= 303
#include "llvm/IR/Module.h"
#else
#include "llvm/Module.h"
#endif
#include "llvm/PassManager.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Target/TargetMachine.h"
#include "gen/irstate.h"
#include "gen/logger.h"
#include "gen/optimizer.h"
#include <cstddef>
#include <fstream>
// fwd decl
void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& Out,

View File

@@ -11,8 +11,12 @@
//
//===----------------------------------------------------------------------===//
#ifndef LDC_GEN_TOOBJ_H
#define LDC_GEN_TOOBJ_H
#ifndef LDC_DRIVER_TOOBJ_H
#define LDC_DRIVER_TOOBJ_H
#include <string>
namespace llvm { class Module; }
void writeModule(llvm::Module* m, std::string filename);

View File

@@ -7,20 +7,18 @@
//
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "mtype.h"
#include "module.h"
#include "declaration.h"
#include "aggregate.h"
#include "gen/aa.h"
#include "gen/runtime.h"
#include "gen/tollvm.h"
#include "aggregate.h"
#include "declaration.h"
#include "module.h"
#include "mtype.h"
#include "gen/dvalue.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/irstate.h"
#include "gen/dvalue.h"
#include "gen/runtime.h"
#include "gen/tollvm.h"
#include "ir/irmodule.h"
#if DMDV2

View File

@@ -11,13 +11,20 @@
//
//===----------------------------------------------------------------------===//
#ifndef LDC_GEN_AA_H
#define LDC_GEN_AA_H
#include "lexer.h"
enum TOK;
struct DValue;
struct Loc;
struct Type;
namespace llvm { class Value; }
DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue);
DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key);
DValue* DtoAARemove(Loc& loc, DValue* aa, DValue* key);
LLValue* DtoAAEquals(Loc& loc, TOK op, DValue* l, DValue* r);
llvm::Value* DtoAAEquals(Loc& loc, TOK op, DValue* l, DValue* r);
#endif // LDC_GEN_AA_H

View File

@@ -11,12 +11,15 @@
//
//===----------------------------------------------------------------------===//
#ifndef LDC_GEN_ABI_GENERIC
#define LDC_GEN_ABI_GENERIC
#ifndef LDC_GEN_ABI_GENERIC_H
#define LDC_GEN_ABI_GENERIC_H
#include "gen/abi.h"
#include "gen/irstate.h"
#include "gen/llvmhelpers.h"
#include "gen/tollvm.h"
#include "gen/logger.h"
#include "gen/structs.h"
#include "gen/tollvm.h"
/// Removes padding fields for (non-union-containing!) structs
struct RemoveStructPadding : ABIRewrite {

View File

@@ -12,11 +12,12 @@
//
//===----------------------------------------------------------------------===//
#include "gen/abi-ppc64.h"
#include "gen/abi.h"
#include "gen/irstate.h"
#include "gen/tollvm.h"
#include "gen/llvmhelpers.h"
#include "gen/dvalue.h"
#include "gen/irstate.h"
#include "gen/llvmhelpers.h"
#include "gen/tollvm.h"
struct PPC64TargetABI : TargetABI {
@@ -56,4 +57,4 @@ struct PPC64TargetABI : TargetABI {
TargetABI* getPPC64TargetABI()
{
return new PPC64TargetABI();
}
}

View File

@@ -11,13 +11,11 @@
//
//===----------------------------------------------------------------------===//
#ifndef __LDC_GEN_ABI_PPC64_H__
#define __LDC_GEN_ABI_PPC64_H__
#include "gen/abi.h"
#ifndef LDC_GEN_ABI_PPC64_H
#define LDC_GEN_ABI_PPC64_H
struct TargetABI;
TargetABI* getPPC64TargetABI();
#endif

View File

@@ -43,21 +43,20 @@
//
//===----------------------------------------------------------------------===//
#include "mtype.h"
#include "declaration.h"
#include "gen/abi-x86-64.h"
#include "aggregate.h"
#include "declaration.h"
#include "mtype.h"
#include "gen/abi-generic.h"
#include "gen/abi-x86-64.h"
#include "gen/abi.h"
#include "gen/dvalue.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/tollvm.h"
#include "gen/logger.h"
#include "gen/dvalue.h"
#include "gen/llvmhelpers.h"
#include "gen/abi.h"
#include "gen/abi-x86-64.h"
#include "gen/abi-generic.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
#include "ir/irfunction.h"
#include <cassert>
#include <map>
#include <string>

View File

@@ -11,13 +11,11 @@
//
//===----------------------------------------------------------------------===//
#ifndef __LDC_GEN_ABI_X86_64_H__
#define __LDC_GEN_ABI_X86_64_H__
#include "gen/abi.h"
#ifndef LDC_GEN_ABI_X86_64_H
#define LDC_GEN_ABI_X86_64_H
struct TargetABI;
TargetABI* getX86_64TargetABI();
#endif

View File

@@ -8,16 +8,14 @@
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "mars.h"
#include "gen/abi-generic.h"
#include "gen/abi.h"
#include "gen/dvalue.h"
#include "gen/irstate.h"
#include "gen/llvmhelpers.h"
#include "gen/tollvm.h"
#include "gen/abi.h"
#include "gen/logger.h"
#include "gen/dvalue.h"
#include "gen/abi-generic.h"
#include "gen/tollvm.h"
#include "ir/irfunction.h"
#include "ir/irfuncty.h"

View File

@@ -11,11 +11,10 @@
//
//===----------------------------------------------------------------------===//
#ifndef __LDC_GEN_ABI_X86_H__
#define __LDC_GEN_ABI_X86_H__
#include "gen/abi.h"
#ifndef LDC_GEN_ABI_X86_H
#define LDC_GEN_ABI_X86_H
struct TargetABI;
TargetABI* getX86TargetABI();
#endif

View File

@@ -7,24 +7,21 @@
//
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include <algorithm>
#include "mars.h"
#include "gen/irstate.h"
#include "gen/llvmhelpers.h"
#include "gen/tollvm.h"
#include "gen/abi.h"
#include "gen/logger.h"
#include "gen/dvalue.h"
#include "mars.h"
#include "gen/abi-generic.h"
#include "gen/abi-ppc64.h"
#include "gen/abi-x86.h"
#include "gen/abi-x86-64.h"
#include "gen/abi-x86.h"
#include "gen/dvalue.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
#include "ir/irfunction.h"
#include "ir/irfuncty.h"
#include <algorithm>
//////////////////////////////////////////////////////////////////////////////
@@ -69,13 +66,13 @@ struct UnknownTargetABI : TargetABI
TargetABI * TargetABI::getTarget()
{
switch(global.params.cpu)
switch (global.params.targetTriple.getArch())
{
case ARCHx86:
case llvm::Triple::x86:
return getX86TargetABI();
case ARCHx86_64:
case llvm::Triple::x86_64:
return getX86_64TargetABI();
case ARCHppc_64:
case llvm::Triple::ppc64:
return getPPC64TargetABI();
default:
Logger::cout() << "WARNING: Unknown ABI, guessing...\n";

View File

@@ -14,8 +14,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __LDC_GEN_ABI_H__
#define __LDC_GEN_ABI_H__
#ifndef LDC_GEN_ABI_H
#define LDC_GEN_ABI_H
#include <vector>

View File

@@ -7,22 +7,20 @@
//
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "mtype.h"
#include "module.h"
#include "dsymbol.h"
#include "gen/arrays.h"
#include "aggregate.h"
#include "declaration.h"
#include "dsymbol.h"
#include "init.h"
#include "gen/irstate.h"
#include "gen/tollvm.h"
#include "gen/llvmhelpers.h"
#include "gen/arrays.h"
#include "gen/runtime.h"
#include "gen/logger.h"
#include "module.h"
#include "mtype.h"
#include "gen/dvalue.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/runtime.h"
#include "gen/tollvm.h"
#include "ir/irmodule.h"
#include "ir/irtypestruct.h"

View File

@@ -11,12 +11,18 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVMC_GEN_ARRAYS_H
#define LLVMC_GEN_ARRAYS_H
#ifndef LDC_GEN_ARRAYS_H
#define LDC_GEN_ARRAYS_H
#include "lexer.h"
#include "gen/llvm.h"
struct ArrayInitializer;
struct DSliceValue;
struct DValue;
struct Expression;
struct Loc;
struct Type;
llvm::StructType* DtoArrayType(Type* arrayTy);
llvm::StructType* DtoArrayType(LLType* elemTy);
@@ -69,4 +75,4 @@ DValue* DtoCastArray(Loc& loc, DValue* val, Type* to);
// generates an array bounds check
void DtoArrayBoundsCheck(Loc& loc, DValue* arr, DValue* index, DValue* lowerBound = 0);
#endif // LLVMC_GEN_ARRAYS_H
#endif // LDC_GEN_ARRAYS_H

View File

@@ -1838,8 +1838,12 @@ namespace AsmParserx8664
}
// osx needs an extra underscore
if ( global.params.os == OSMacOSX || global.params.os == OSWindows )
if ( global.params.targetTriple.getOS() == llvm::Triple::MacOSX ||
global.params.targetTriple.getOS() == llvm::Triple::Darwin ||
global.params.targetTriple.isOSWindows() )
{
insnTemplate << "_";
}
// print out the mangle
insnTemplate << vd->mangle();
@@ -2512,8 +2516,12 @@ namespace AsmParserx8664
use_star = false;
// simply write out the mangle
// on osx and windows, prepend extra _
if ( global.params.os == OSMacOSX || global.params.os == OSWindows )
if ( global.params.targetTriple.getOS() == llvm::Triple::MacOSX ||
global.params.targetTriple.getOS() == llvm::Triple::Darwin ||
global.params.targetTriple.isOSWindows() )
{
insnTemplate << "_";
}
insnTemplate << decl->mangle();
// addOperand2("${", ":c}", Arg_Pointer, e, asmcode);
}

View File

@@ -159,9 +159,11 @@ Statement *AsmStatement::semantic(Scope *sc)
#endif
bool err = false;
if ((global.params.cpu != ARCHx86) && (global.params.cpu != ARCHx86_64))
llvm::Triple const t = global.params.targetTriple;
if (!(t.getArch() == llvm::Triple::x86 || t.getArch() == llvm::Triple::x86_64))
{
error("inline asm is not supported for the \"%s\" architecture", global.params.targetTriple.getArchName().str().c_str());
error("inline asm is not supported for the \"%s\" architecture",
t.getArchName().str().c_str());
err = true;
}
if (!global.params.useInlineAsm)
@@ -185,9 +187,9 @@ Statement *AsmStatement::semantic(Scope *sc)
if (!asmparser)
{
if (global.params.cpu == ARCHx86)
if (t.getArch() == llvm::Triple::x86)
asmparser = new AsmParserx8632::AsmParser;
else if (global.params.cpu == ARCHx86_64)
else if (t.getArch() == llvm::Triple::x86_64)
asmparser = new AsmParserx8664::AsmParser;
}

View File

@@ -8,15 +8,13 @@
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "declaration.h"
#include "gen/irstate.h"
#include "gen/tollvm.h"
#include "gen/dvalue.h"
#include "gen/logger.h"
#include "gen/complex.h"
#include "gen/dvalue.h"
#include "gen/irstate.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
//////////////////////////////////////////////////////////////////////////////

View File

@@ -8,15 +8,13 @@
//===----------------------------------------------------------------------===//
#include "gen/cl_helpers.h"
#include "mars.h"
#include "root.h"
#include "rmem.h"
#include <cctype> // isupper, tolower
#include "root.h"
#include <algorithm>
#include <utility>
#include <cctype> // isupper, tolower
#include <stdarg.h>
#include <utility>
namespace opts {

View File

@@ -12,13 +12,12 @@
//
//===----------------------------------------------------------------------===//
#ifndef LDC_CL_HELPERS_H
#define LDC_CL_HELPERS_H
#include <string>
#ifndef LDC_GEN_CL_HELPERS_H
#define LDC_GEN_CL_HELPERS_H
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include <string>
template <typename TYPE> struct ArrayBase;
typedef ArrayBase<char> Strings;

View File

@@ -8,18 +8,15 @@
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "mtype.h"
#include "aggregate.h"
#include "init.h"
#include "declaration.h"
#include "gen/dvalue.h"
#include "gen/irstate.h"
#include "init.h"
#include "mtype.h"
#include "gen/arrays.h"
#include "gen/classes.h"
#include "gen/dvalue.h"
#include "gen/functions.h"
#include "gen/irstate.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/nested.h"
@@ -28,7 +25,6 @@
#include "gen/structs.h"
#include "gen/tollvm.h"
#include "gen/utils.h"
#include "ir/irstruct.h"
#include "ir/irtypeclass.h"

View File

@@ -17,6 +17,12 @@
#include "gen/structs.h"
struct ClassDeclaration;
struct CtorDeclaration;
struct FuncDeclaration;
struct NewExp;
struct TypeClass;
/// Resolves the llvm type for a class declaration
void DtoResolveClass(ClassDeclaration* cd);
@@ -31,12 +37,12 @@ void DtoDefineClass(ClassDeclaration* cd);
/// Builds the initializer of cd's ClassInfo.
/// FIXME: this should be put into IrStruct and eventually IrClass.
LLConstant* DtoDefineClassInfo(ClassDeclaration* cd);
llvm::Constant* DtoDefineClassInfo(ClassDeclaration* cd);
DValue* DtoNewClass(Loc loc, TypeClass* type, NewExp* newexp);
void DtoInitClass(TypeClass* tc, LLValue* dst);
DValue* DtoCallClassCtor(TypeClass* type, CtorDeclaration* ctor, Array* arguments, LLValue* mem);
void DtoFinalizeClass(LLValue* inst);
void DtoInitClass(TypeClass* tc, llvm::Value* dst);
DValue* DtoCallClassCtor(TypeClass* type, CtorDeclaration* ctor, Array* arguments, llvm::Value* mem);
void DtoFinalizeClass(llvm::Value* inst);
DValue* DtoCastClass(DValue* val, Type* to);
DValue* DtoDynamicCastObject(DValue* val, Type* to);
@@ -44,8 +50,8 @@ DValue* DtoDynamicCastObject(DValue* val, Type* to);
DValue* DtoCastInterfaceToObject(DValue* val, Type* to);
DValue* DtoDynamicCastInterface(DValue* val, Type* to);
LLValue* DtoIndexClass(LLValue* src, ClassDeclaration* sd, VarDeclaration* vd);
llvm::Value* DtoIndexClass(llvm::Value* src, ClassDeclaration* sd, VarDeclaration* vd);
LLValue* DtoVirtualFunctionPointer(DValue* inst, FuncDeclaration* fdecl, char* name);
llvm::Value* DtoVirtualFunctionPointer(DValue* inst, FuncDeclaration* fdecl, char* name);
#endif

View File

@@ -7,17 +7,15 @@
//
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "mtype.h"
#include "declaration.h"
#include "gen/complex.h"
#include "gen/tollvm.h"
#include "gen/llvmhelpers.h"
#include "gen/irstate.h"
#include "declaration.h"
#include "mtype.h"
#include "gen/dvalue.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
//////////////////////////////////////////////////////////////////////////////////////////
@@ -38,10 +36,15 @@ LLType* DtoComplexBaseType(Type* t)
case Tcomplex32: return LLType::getFloatTy(gIR->context());
case Tcomplex64: return LLType::getDoubleTy(gIR->context());
case Tcomplex80:
if ((global.params.cpu == ARCHx86) || (global.params.cpu == ARCHx86_64))
llvm::Triple::ArchType const a = global.params.targetTriple.getArch();
if (a == llvm::Triple::x86 || a == llvm::Triple::x86_64)
{
return LLType::getX86_FP80Ty(gIR->context());
else if (global.params.cpu == ARCHppc || global.params.cpu == ARCHppc_64)
}
else if (a == llvm::Triple::ppc || a == llvm::Triple::ppc64)
{
return LLType::getPPC_FP128Ty(gIR->context());
}
else
return LLType::getDoubleTy(gIR->context());
}

View File

@@ -14,19 +14,33 @@
#ifndef LDC_GEN_COMPLEX_H
#define LDC_GEN_COMPLEX_H
#include "lexer.h"
#include "longdouble.h"
struct DValue;
struct Loc;
struct Type;
namespace llvm
{
class Constant;
class StructType;
class Type;
class Value;
}
llvm::StructType* DtoComplexType(Type* t);
LLType* DtoComplexBaseType(Type* t);
llvm::Type* DtoComplexBaseType(Type* t);
LLConstant* DtoConstComplex(Type* t, longdouble re, longdouble im);
llvm::Constant* DtoConstComplex(Type* t, longdouble re, longdouble im);
LLConstant* DtoComplexShuffleMask(unsigned a, unsigned b);
llvm::Constant* DtoComplexShuffleMask(unsigned a, unsigned b);
DValue* DtoComplex(Loc& loc, Type* to, DValue* val);
void DtoComplexSet(LLValue* c, LLValue* re, LLValue* im);
void DtoComplexSet(llvm::Value* c, llvm::Value* re, llvm::Value* im);
void DtoGetComplexParts(Loc& loc, Type* to, DValue* c, DValue*& re, DValue*& im);
void DtoGetComplexParts(Loc& loc, Type* to, DValue* c, LLValue*& re, LLValue*& im);
void DtoGetComplexParts(Loc& loc, Type* to, DValue* c, llvm::Value*& re, llvm::Value*& im);
DValue* DtoComplexAdd(Loc& loc, Type* type, DValue* lhs, DValue* rhs);
DValue* DtoComplexSub(Loc& loc, Type* type, DValue* lhs, DValue* rhs);
@@ -35,7 +49,7 @@ DValue* DtoComplexDiv(Loc& loc, Type* type, DValue* lhs, DValue* rhs);
DValue* DtoComplexRem(Loc& loc, Type* type, DValue* lhs, DValue* rhs);
DValue* DtoComplexNeg(Loc& loc, Type* type, DValue* val);
LLValue* DtoComplexEquals(Loc& loc, TOK op, DValue* lhs, DValue* rhs);
llvm::Value* DtoComplexEquals(Loc& loc, TOK op, DValue* lhs, DValue* rhs);
DValue* DtoCastComplex(Loc& loc, DValue* val, Type* to);

View File

@@ -7,26 +7,23 @@
//
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "aggregate.h"
#include "declaration.h"
#include "enum.h"
#include "id.h"
#include "init.h"
#include "rmem.h"
#include "template.h"
#include "init.h"
#include "gen/irstate.h"
#include "gen/tollvm.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/todebug.h"
#include "gen/tollvm.h"
#include "ir/ir.h"
#include "ir/irvar.h"
#include "ir/irtype.h"
#include "ir/irtypestruct.h"
#include "ir/irvar.h"
/* ================================================================== */

View File

@@ -7,16 +7,13 @@
//
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "gen/tollvm.h"
#include "gen/irstate.h"
#include "gen/logger.h"
#include "gen/dvalue.h"
#include "gen/llvmhelpers.h"
#include "declaration.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
@@ -95,6 +92,3 @@ LLValue* DConstValue::getRVal()
assert(c);
return c;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -17,8 +17,8 @@
#ifndef LDC_GEN_DVALUE_H
#define LDC_GEN_DVALUE_H
#include <cassert>
#include "root.h"
#include <cassert>
struct Type;
struct Dsymbol;

View File

@@ -7,36 +7,34 @@
//
//===----------------------------------------------------------------------===//
#include "gen/functions.h"
#include "aggregate.h"
#include "declaration.h"
#include "id.h"
#include "init.h"
#include "module.h"
#include "mtype.h"
#include "statement.h"
#include "template.h"
#include "gen/abi.h"
#include "gen/arrays.h"
#include "gen/classes.h"
#include "gen/dvalue.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "llvm/Support/CFG.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/nested.h"
#include "gen/pragma.h"
#include "gen/runtime.h"
#include "gen/todebug.h"
#include "gen/tollvm.h"
#if LDC_LLVM_VER >= 303
#include "llvm/IR/Intrinsics.h"
#else
#include "llvm/Intrinsics.h"
#endif
#include "mtype.h"
#include "aggregate.h"
#include "init.h"
#include "declaration.h"
#include "template.h"
#include "module.h"
#include "statement.h"
#include "id.h"
#include "gen/irstate.h"
#include "gen/tollvm.h"
#include "gen/llvmhelpers.h"
#include "gen/runtime.h"
#include "gen/arrays.h"
#include "gen/logger.h"
#include "gen/functions.h"
#include "gen/todebug.h"
#include "gen/classes.h"
#include "gen/dvalue.h"
#include "gen/abi.h"
#include "gen/nested.h"
#include "gen/pragma.h"
#include "llvm/Support/CFG.h"
#include <iostream>
#if LDC_LLVM_VER < 302
@@ -307,7 +305,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
//////////////////////////////////////////////////////////////////////////////////////////
#include <llvm/Support/raw_ostream.h>
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Assembly/Parser.h"

View File

@@ -16,13 +16,15 @@
#include "mars.h"
struct DValue;
struct Expression;
struct FuncDeclaration;
struct Type;
struct IRAsmBlock;
struct Parameter;
struct Type;
namespace llvm
{
class FunctionType;
class Value;
}

View File

@@ -7,16 +7,13 @@
//
//===----------------------------------------------------------------------===//
#include <cstdarg>
#include "gen/llvm.h"
#include "mtype.h"
#include "declaration.h"
#include "statement.h"
#include "gen/irstate.h"
#include "tollvm.h"
#include "declaration.h"
#include "mtype.h"
#include "statement.h"
#include "gen/llvm.h"
#include "gen/tollvm.h"
#include <cstdarg>
IRState* gIR = 0;
llvm::TargetMachine* gTargetMachine = 0;

View File

@@ -15,17 +15,15 @@
#ifndef LDC_GEN_IRSTATE_H
#define LDC_GEN_IRSTATE_H
#include <vector>
#include <deque>
#include <list>
#include <sstream>
#include "root.h"
#include "aggregate.h"
#include "root.h"
#include "ir/irfunction.h"
#include "ir/irstruct.h"
#include "ir/irvar.h"
#include <deque>
#include <list>
#include <sstream>
#include <vector>
#if LDC_LLVM_VER >= 302
#include "llvm/DIBuilder.h"

View File

@@ -15,8 +15,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef GEN_LLVM_H
#define GEN_LLVM_H
#ifndef LDC_GEN_LLVM_H
#define LDC_GEN_LLVM_H
#if LDC_LLVM_VER >= 303
#include "llvm/IR/Type.h"
@@ -94,4 +94,4 @@ using llvm::IRBuilder;
using llvm::APFloat;
using llvm::APInt;
#endif // GEN_LLVM_H
#endif // LDC_GEN_LLVM_H

View File

@@ -8,8 +8,8 @@
//===----------------------------------------------------------------------===//
#include "gen/llvmcompat.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Config/llvm-config.h"
#if LDC_LLVM_VER >= 303
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"

View File

@@ -8,36 +8,32 @@
//===----------------------------------------------------------------------===//
#include "gen/llvmhelpers.h"
#include "gen/llvm.h"
#include "mars.h"
#include "init.h"
#include "id.h"
#include "expression.h"
#include "template.h"
#include "id.h"
#include "init.h"
#include "mars.h"
#include "module.h"
#include "template.h"
#include "gen/arrays.h"
#include "gen/classes.h"
#include "gen/complex.h"
#include "gen/dvalue.h"
#include "gen/functions.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/llvmcompat.h"
#include "gen/logger.h"
#include "gen/nested.h"
#include "gen/runtime.h"
#include "gen/todebug.h"
#include "gen/tollvm.h"
#include "gen/typeinf.h"
#include "ir/irmodule.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Target/TargetMachine.h"
#if LDC_LLVM_VER >= 301
#include "llvm/Transforms/Utils/ModuleUtils.h"
#endif
#include "gen/tollvm.h"
#include "gen/irstate.h"
#include "gen/runtime.h"
#include "gen/logger.h"
#include "gen/arrays.h"
#include "gen/dvalue.h"
#include "gen/complex.h"
#include "gen/classes.h"
#include "gen/functions.h"
#include "gen/typeinf.h"
#include "gen/todebug.h"
#include "gen/nested.h"
#include "ir/irmodule.h"
#include "gen/llvmcompat.h"
#include <stack>
/****************************************************************************************/

View File

@@ -16,11 +16,10 @@
#ifndef LDC_GEN_LLVMHELPERS_H
#define LDC_GEN_LLVMHELPERS_H
#include "gen/llvm.h"
#include "gen/dvalue.h"
#include "statement.h"
#include "mtype.h"
#include "statement.h"
#include "gen/dvalue.h"
#include "gen/llvm.h"
// this is used for tracking try-finally, synchronized and volatile scopes
struct EnclosingHandler

View File

@@ -7,17 +7,15 @@
//
//===----------------------------------------------------------------------===//
#include "mars.h"
#include "llvm/Support/CommandLine.h"
#include <cassert>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <string>
#include <iostream>
#include "mars.h"
#include "llvm/Support/CommandLine.h"
#include <string>
#if LDC_LLVM_VER >= 303
#include "llvm/IR/GlobalValue.h"

View File

@@ -12,8 +12,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef _llvmd_gen_logger_h_
#define _llvmd_gen_logger_h_
#ifndef LDC_GEN_LOGGER_H
#define LDC_GEN_LOGGER_H
#include <iosfwd>

View File

@@ -7,7 +7,41 @@
//
//===----------------------------------------------------------------------===//
#include "aggregate.h"
#include "attrib.h"
#include "declaration.h"
#include "enum.h"
#include "id.h"
#include "import.h"
#include "init.h"
#include "mars.h"
#include "module.h"
#include "mtype.h"
#include "scope.h"
#include "statement.h"
#include "template.h"
#include "gen/abi.h"
#include "gen/arrays.h"
#include "gen/classes.h"
#include "gen/functions.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/optimizer.h"
#include "gen/programs.h"
#include "gen/rttibuilder.h"
#include "gen/runtime.h"
#include "gen/structs.h"
#include "gen/todebug.h"
#include "gen/tollvm.h"
#include "ir/irdsymbol.h"
#include "ir/irmodule.h"
#include "ir/irtype.h"
#if !MODULEINFO_IS_STRUCT
#include "ir/irtypeclass.h"
#endif
#include "ir/irvar.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/LinkAllPasses.h"
#if LDC_LLVM_VER >= 303
@@ -22,44 +56,6 @@
#endif
#endif
#include "mars.h"
#include "module.h"
#include "mtype.h"
#include "declaration.h"
#include "statement.h"
#include "enum.h"
#include "aggregate.h"
#include "init.h"
#include "attrib.h"
#include "id.h"
#include "import.h"
#include "template.h"
#include "scope.h"
#include "gen/abi.h"
#include "gen/arrays.h"
#include "gen/classes.h"
#include "gen/functions.h"
#include "gen/irstate.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/programs.h"
#include "gen/rttibuilder.h"
#include "gen/runtime.h"
#include "gen/structs.h"
#include "gen/todebug.h"
#include "gen/tollvm.h"
#include "gen/optimizer.h"
#include "ir/irdsymbol.h"
#include "ir/irmodule.h"
#include "ir/irtype.h"
#include "ir/irvar.h"
#if !MODULEINFO_IS_STRUCT
#include "ir/irtypeclass.h"
#endif
#if DMDV2
#define NEW_MODULEINFO_LAYOUT 1
#endif

View File

@@ -7,26 +7,23 @@
//
//===----------------------------------------------------------------------===//
#include "expression.h"
#include "declaration.h"
#include "statement.h"
#include "template.h"
#include "gen/dvalue.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
#if LDC_LLVM_VER >= 303
#include "llvm/IR/InlineAsm.h"
#else
#include "llvm/InlineAsm.h"
#endif
#include "expression.h"
#include "statement.h"
#include "declaration.h"
#include "template.h"
#include <cassert>
#include "gen/logger.h"
#include "gen/irstate.h"
#include "gen/llvmhelpers.h"
#include "gen/tollvm.h"
#include "gen/dvalue.h"
//////////////////////////////////////////////////////////////////////////////////////////
void Statement::toNakedIR(IRState *p)
@@ -127,9 +124,13 @@ void DtoDefineNakedFunction(FuncDeclaration* fd)
const char* mangle = fd->mangle();
std::ostringstream tmpstr;
bool const isWin = global.params.targetTriple.isOSWindows();
bool const isOSX = (global.params.targetTriple.getOS() == llvm::Triple::Darwin ||
global.params.targetTriple.getOS() == llvm::Triple::MacOSX);
// osx is different
// also mangling has an extra underscore prefixed
if (global.params.os == OSMacOSX)
if (isOSX)
{
std::string section = "text";
bool weak = false;
@@ -159,10 +160,11 @@ void DtoDefineNakedFunction(FuncDeclaration* fd)
{
linkage = "weak";
tmpstr << "section\t.gnu.linkonce.t.";
if (global.params.os != OSWindows)
if (!isWin)
{
tmpstr << mangle << ",\"ax\",@progbits";
} else
}
else
{
tmpstr << "_" << mangle << ",\"ax\"";
}
@@ -171,7 +173,7 @@ void DtoDefineNakedFunction(FuncDeclaration* fd)
asmstr << "\t." << section << std::endl;
asmstr << "\t.align\t16" << std::endl;
if (global.params.os == OSWindows)
if (isWin)
{
std::string def = "def";
std::string endef = "endef";
@@ -179,7 +181,8 @@ void DtoDefineNakedFunction(FuncDeclaration* fd)
// hard code these two numbers for now since gas ignores .scl and llvm
// is defaulting to .type 32 for everything I have seen
asmstr << "\t.scl 2; .type 32;\t" << "." << endef << std::endl;
} else
}
else
{
asmstr << "\t." << linkage << "\t" << mangle << std::endl;
asmstr << "\t.type\t" << mangle << ",@function" << std::endl;
@@ -199,7 +202,7 @@ void DtoDefineNakedFunction(FuncDeclaration* fd)
// emit size after body
// llvm does this on linux, but not on osx or Win
if (global.params.os != OSMacOSX && global.params.os != OSWindows)
if (!(isWin || isOSX))
{
asmstr << "\t.size\t" << mangle << ", .-" << mangle << std::endl << std::endl;
}
@@ -227,7 +230,7 @@ void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl)
// It should be able to do this for a greater variety of types.
// x86
if (global.params.cpu == ARCHx86)
if (global.params.targetTriple.getArch() == llvm::Triple::x86)
{
LINK l = fdecl->linkage;
assert((l == LINKd || l == LINKc || l == LINKwindows) && "invalid linkage for asm implicit return");
@@ -301,7 +304,7 @@ void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl)
}
// x86_64
else if (global.params.cpu == ARCHx86_64)
else if (global.params.targetTriple.getArch() == llvm::Triple::x86_64)
{
LINK l = fdecl->linkage;
/* TODO: Check if this works with extern(Windows), completely untested.

View File

@@ -8,15 +8,13 @@
//===----------------------------------------------------------------------===//
#include "gen/nested.h"
#include "gen/dvalue.h"
#include "gen/functions.h"
#include "gen/irstate.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
#include "gen/functions.h"
#include "gen/todebug.h"
#include "gen/tollvm.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Support/CommandLine.h"
namespace cl = llvm::cl;

View File

@@ -8,13 +8,12 @@
//===----------------------------------------------------------------------===//
#include "gen/optimizer.h"
#include "mars.h" // error()
#include "gen/cl_helpers.h"
#include "gen/logger.h"
#include "gen/passes/Passes.h"
#include "llvm/PassManager.h"
#include "llvm/LinkAllPasses.h"
#include "llvm/PassManager.h"
#if LDC_LLVM_VER >= 303
#include "llvm/IR/Module.h"
#include "llvm/IR/DataLayout.h"
@@ -35,8 +34,6 @@
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "mars.h" // error()
using namespace llvm;
// Allow the user to specify specific optimizations to run.

View File

@@ -17,7 +17,6 @@
#define DEBUG_TYPE "simplify-drtcalls"
#include "Passes.h"
#include "llvm/Pass.h"
#if LDC_LLVM_VER >= 303
#include "llvm/IR/Function.h"

View File

@@ -9,11 +9,11 @@
#include "pragma.h"
#include "attrib.h"
#include "id.h"
#include "expression.h"
#include "scope.h"
#include "module.h"
#include "declaration.h"
#include "expression.h"
#include "id.h"
#include "module.h"
#include "scope.h"
#include "template.h"
#include "llvm/Support/CommandLine.h"

View File

@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef PRAGMA_H
#define PRAGMA_H
#ifndef LDC_GEN_PRAGMA_H
#define LDC_GEN_PRAGMA_H
#include <string>
@@ -51,4 +51,4 @@ Pragma DtoGetPragma(Scope *sc, PragmaDeclaration *decl, std::string &arg1str);
void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *sym,
Pragma llvm_internal, const std::string &arg1str);
#endif // PRAGMA_H
#endif // LDC_GEN_PRAGMA_H

View File

@@ -8,13 +8,11 @@
//===----------------------------------------------------------------------===//
#include "gen/programs.h"
#include "mars.h" // fatal()
#include "root.h" // error(char*)
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Program.h"
#include "root.h" // error(char*)
#include "mars.h" // fatal()
using namespace llvm;
static cl::opt<std::string> gcc("gcc",

View File

@@ -7,18 +7,15 @@
//
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "gen/rttibuilder.h"
#include "aggregate.h"
#include "mtype.h"
#include "gen/arrays.h"
#include "gen/irstate.h"
#include "gen/linkage.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/rttibuilder.h"
#include "gen/tollvm.h"
#include "ir/irstruct.h"
RTTIBuilder::RTTIBuilder(AggregateDeclaration* base_class)

View File

@@ -12,22 +12,25 @@
//
//===----------------------------------------------------------------------===//
#ifndef __LDC_GEN_RTTIBUILDER_H__
#define __LDC_GEN_RTTIBUILDER_H__
#ifndef LDC_GEN_RTTIBUILDER_H
#define LDC_GEN_RTTIBUILDER_H
#include "llvm/ADT/SmallVector.h"
#if LDC_LLVM_VER >= 303
#include "llvm/IR/Constant.h"
#else
#include "llvm/Constant.h"
#endif
#include "llvm/ADT/SmallVector.h"
struct ClassDeclaration;
struct AggregateDeclaration;
struct TypeClass;
struct Type;
struct ClassDeclaration;
struct Dsymbol;
struct FuncDeclaration;
struct IrGlobal;
struct IrStruct;
struct Type;
struct TypeClass;
namespace llvm { class StructType; }
struct RTTIBuilder
{
@@ -75,10 +78,10 @@ struct RTTIBuilder
/// Creates the initializer constant and assigns it to the global.
void finalize(IrGlobal* tid);
void finalize(LLType* type, LLValue* value);
void finalize(llvm::Type* type, llvm::Value* value);
/// Creates the initializer constant and assigns it to the global.
llvm::Constant* get_constant(LLStructType *initType);
llvm::Constant* get_constant(llvm::StructType* initType);
};
#endif

View File

@@ -7,7 +7,22 @@
//
//===----------------------------------------------------------------------===//
#include "gen/runtime.h"
#include "aggregate.h"
#include "dsymbol.h"
#include "lexer.h"
#include "mars.h"
#include "module.h"
#include "mtype.h"
#include "root.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
#include "ir/irtype.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MemoryBuffer.h"
#if LDC_LLVM_VER >= 303
#include "llvm/IR/Module.h"
#include "llvm/IR/Attributes.h"
@@ -15,23 +30,6 @@
#include "llvm/Module.h"
#include "llvm/Attributes.h"
#endif
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/CommandLine.h"
#include "root.h"
#include "mars.h"
#include "lexer.h"
#include "dsymbol.h"
#include "mtype.h"
#include "aggregate.h"
#include "module.h"
#include "gen/runtime.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
#include "gen/irstate.h"
#include "ir/irtype.h"
#if LDC_LLVM_VER < 302
using namespace llvm::Attribute;

View File

@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef LDC_GEN_RUNTIME_H_
#define LDC_GEN_RUNTIME_H_
#ifndef LDC_GEN_RUNTIME_H
#define LDC_GEN_RUNTIME_H
namespace llvm
{
@@ -40,4 +40,4 @@ llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(llvm::Module* target, const char*
#define _adCmp "_adCmp2"
#endif
#endif // LDC_GEN_RUNTIME_H_
#endif // LDC_GEN_RUNTIME_H

View File

@@ -7,39 +7,37 @@
//
//===----------------------------------------------------------------------===//
#include <stdio.h>
#include <math.h>
#include <fstream>
#include "init.h"
#include "mars.h"
#include "module.h"
#include "mtype.h"
#include "port.h"
#include "gen/abi.h"
#include "gen/arrays.h"
#include "gen/dvalue.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/runtime.h"
#include "gen/todebug.h"
#include "gen/tollvm.h"
#include "ir/irfunction.h"
#include "ir/irlandingpad.h"
#include "ir/irmodule.h"
#include "llvm/Support/CFG.h"
#if LDC_LLVM_VER >= 303
#include "llvm/IR/InlineAsm.h"
#else
#include "llvm/InlineAsm.h"
#endif
#include "llvm/Support/CFG.h"
#include <fstream>
#include <math.h>
#include <stdio.h>
#include "mars.h"
#include "init.h"
#include "mtype.h"
// Need to include this after the other DMD includes because of missing
// dependencies.
#include "hdrgen.h"
#include "port.h"
#include "module.h"
#include "gen/irstate.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
#include "gen/llvmhelpers.h"
#include "gen/runtime.h"
#include "gen/arrays.h"
#include "gen/todebug.h"
#include "gen/dvalue.h"
#include "gen/abi.h"
#include "ir/irfunction.h"
#include "ir/irmodule.h"
#include "ir/irlandingpad.h"
//////////////////////////////////////////////////////////////////////////////

View File

@@ -7,29 +7,25 @@
//
//===----------------------------------------------------------------------===//
#include <algorithm>
#include "gen/llvm.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Support/ManagedStatic.h"
#include "mtype.h"
#include "aggregate.h"
#include "init.h"
#include "declaration.h"
#include "gen/irstate.h"
#include "gen/tollvm.h"
#include "gen/llvmhelpers.h"
#include "init.h"
#include "mtype.h"
#include "gen/arrays.h"
#include "gen/logger.h"
#include "gen/structs.h"
#include "gen/dvalue.h"
#include "gen/functions.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/structs.h"
#include "gen/tollvm.h"
#include "gen/utils.h"
#include "ir/irstruct.h"
#include "ir/irtypestruct.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Support/ManagedStatic.h"
#include <algorithm>
//////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -11,10 +11,23 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVMD_GEN_STRUCTS_H
#define LLVMD_GEN_STRUCTS_H
#ifndef LDC_GEN_STRUCTS_H
#define LDC_GEN_STRUCTS_H
#include "lexer.h"
#include <vector>
struct DValue;
struct StructDeclaration;
struct StructInitializer;
struct Type;
struct VarDeclaration;
namespace llvm
{
class Constant;
class Type;
class Value;
}
/**
* Sets up codegen metadata and emits global data (.init, etc.), if needed.
@@ -24,31 +37,30 @@ struct StructInitializer;
void DtoResolveStruct(StructDeclaration* sd);
/// Build constant struct initializer.
LLConstant* DtoConstStructInitializer(StructInitializer* si);
llvm::Constant* DtoConstStructInitializer(StructInitializer* si);
/// Build values for a struct literal.
std::vector<llvm::Value*> DtoStructLiteralValues(const StructDeclaration* sd,
const std::vector<llvm::Value*>& inits,
bool isConst = false);
const std::vector<llvm::Value*>& inits, bool isConst = false);
/// Returns a boolean=true if the two structs are equal.
LLValue* DtoStructEquals(TOK op, DValue* lhs, DValue* rhs);
llvm::Value* DtoStructEquals(TOK op, DValue* lhs, DValue* rhs);
/// index a struct one level
LLValue* DtoIndexStruct(LLValue* src, StructDeclaration* sd, VarDeclaration* vd);
llvm::Value* DtoIndexStruct(llvm::Value* src, StructDeclaration* sd, VarDeclaration* vd);
/// Return the type returned by DtoUnpaddedStruct called on a value of the
/// specified type.
/// Union types will get expanded into a struct, with a type for each member.
LLType* DtoUnpaddedStructType(Type* dty);
llvm::Type* DtoUnpaddedStructType(Type* dty);
/// Return the struct value represented by v without the padding fields.
/// Unions will be expanded, with a value for each member.
/// Note: v must be a pointer to a struct, but the return value will be a
/// first-class struct value.
LLValue* DtoUnpaddedStruct(Type* dty, LLValue* v);
llvm::Value* DtoUnpaddedStruct(Type* dty, llvm::Value* v);
/// Undo the transformation performed by DtoUnpaddedStruct, writing to lval.
void DtoPaddedStruct(Type* dty, LLValue* v, LLValue* lval);
void DtoPaddedStruct(Type* dty, llvm::Value* v, llvm::Value* lval);
#endif

View File

@@ -7,21 +7,18 @@
//
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "mtype.h"
#include "declaration.h"
#include "id.h"
#include "gen/tollvm.h"
#include "gen/llvmhelpers.h"
#include "gen/irstate.h"
#include "mtype.h"
#include "gen/abi.h"
#include "gen/dvalue.h"
#include "gen/functions.h"
#include "gen/abi.h"
#include "gen/nested.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/nested.h"
#include "gen/tollvm.h"
//////////////////////////////////////////////////////////////////////////////////////////
@@ -59,21 +56,29 @@ TypeFunction* DtoTypeFunction(DValue* fnval)
llvm::CallingConv::ID DtoCallingConv(Loc loc, LINK l)
{
llvm::Triple::ArchType const arch = global.params.targetTriple.getArch();
if (l == LINKc || l == LINKcpp || l == LINKintrinsic)
return llvm::CallingConv::C;
else if (l == LINKd || l == LINKdefault)
{
//TODO: StdCall is not a good base on Windows due to extra name mangling
// applied there
if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64)
return (global.params.os != OSWindows) ? llvm::CallingConv::X86_StdCall : llvm::CallingConv::C;
if (arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64)
{
return global.params.targetTriple.isOSWindows() ?
llvm::CallingConv::C : llvm::CallingConv::X86_StdCall;
}
else
return llvm::CallingConv::Fast;
}
// on the other hand, here, it's exactly what we want!!! TODO: right?
// 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;
{
return (arch == llvm::Triple::x86_64) ?
llvm::CallingConv::C : llvm::CallingConv::X86_StdCall;
}
else if (l == LINKpascal)
return llvm::CallingConv::X86_StdCall;
else
@@ -92,7 +97,7 @@ DValue* DtoVaArg(Loc& loc, Type* type, Expression* valistArg)
if (DtoIsPassedByRef(type))
llt = getPtrToType(llt);
// issue a warning for broken va_arg instruction.
if (global.params.cpu != ARCHx86)
if (global.params.targetTriple.getArch() != llvm::Triple::x86)
warning(Loc(), "%s: va_arg for C variadic functions is probably broken for anything but x86", loc.toChars());
// done
return new DImValue(type, gIR->ir->CreateVAArg(expelem->getLVal(), llt, "tmp"));

View File

@@ -7,26 +7,23 @@
//
//===----------------------------------------------------------------------===//
#include "gen/todebug.h"
#include "declaration.h"
#include "mars.h"
#include "module.h"
#include "gen/irstate.h"
#include "gen/linkage.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
#include "gen/utils.h"
#include "ir/irmodule.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "declaration.h"
#include "module.h"
#include "mars.h"
#include "gen/todebug.h"
#include "gen/irstate.h"
#include "gen/tollvm.h"
#include "gen/logger.h"
#include "gen/llvmhelpers.h"
#include "gen/linkage.h"
#include "gen/utils.h"
#include "ir/irmodule.h"
using namespace llvm::dwarf;
//////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -14,8 +14,8 @@
#ifndef LDC_GEN_TODEBUG_H
#define LDC_GEN_TODEBUG_H
#include "gen/tollvm.h"
#include "gen/irstate.h"
#include "gen/tollvm.h"
void RegisterDwarfSymbols(llvm::Module* mod);

View File

@@ -7,44 +7,40 @@
//
//===----------------------------------------------------------------------===//
#include <stdio.h>
#include <math.h>
#include <fstream>
#include "gen/llvm.h"
#include "llvm/Support/CommandLine.h"
#include "attrib.h"
#include "enum.h"
#include "hdrgen.h"
#include "id.h"
#include "init.h"
#include "mtype.h"
#include "template.h"
#include "hdrgen.h"
#include "port.h"
#include "rmem.h"
#include "id.h"
#include "enum.h"
#include "gen/irstate.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
#include "gen/llvmhelpers.h"
#include "gen/runtime.h"
#include "template.h"
#include "gen/aa.h"
#include "gen/arrays.h"
#include "gen/structs.h"
#include "gen/classes.h"
#include "gen/typeinf.h"
#include "gen/complex.h"
#include "gen/dvalue.h"
#include "gen/aa.h"
#include "gen/functions.h"
#include "gen/todebug.h"
#include "gen/irstate.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/nested.h"
#include "gen/utils.h"
#include "gen/warnings.h"
#include "gen/optimizer.h"
#include "gen/pragma.h"
#include "gen/runtime.h"
#include "gen/structs.h"
#include "gen/todebug.h"
#include "gen/tollvm.h"
#include "gen/typeinf.h"
#include "gen/utils.h"
#include "gen/warnings.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include <fstream>
#include <math.h>
#include <stdio.h>
llvm::cl::opt<bool> checkPrintf("check-printf-calls",
llvm::cl::desc("Validate printf call format strings against arguments"),
@@ -941,7 +937,7 @@ DValue* CallExp::toElem(IRState* p)
if (LLValue *argptr = gIR->func()->_argptr) {
DtoStore(DtoLoad(argptr), DtoBitCast(arg, getPtrToType(getVoidPtrType())));
return new DImValue(type, arg);
} else if (global.params.cpu == ARCHx86_64) {
} else if (global.params.targetTriple.getArch() == llvm::Triple::x86_64) {
LLValue *va_list = DtoAlloca(exp->type->nextOf());
DtoStore(va_list, arg);
va_list = DtoBitCast(va_list, getVoidPtrType());
@@ -954,7 +950,8 @@ DValue* CallExp::toElem(IRState* p)
}
}
#if DMDV2
else if (fndecl->llvmInternal == LLVMva_copy && global.params.cpu == ARCHx86_64) {
else if (fndecl->llvmInternal == LLVMva_copy &&
global.params.targetTriple.getArch() == llvm::Triple::x86_64) {
if (arguments->dim != 2) {
error("va_copy instruction expects 2 arguments");
return NULL;

View File

@@ -7,30 +7,27 @@
//
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "dsymbol.h"
#include "gen/tollvm.h"
#include "aggregate.h"
#include "declaration.h"
#include "init.h"
#include "dsymbol.h"
#include "id.h"
#include "init.h"
#include "module.h"
#include "gen/tollvm.h"
#include "gen/irstate.h"
#include "gen/logger.h"
#include "gen/runtime.h"
#include "gen/arrays.h"
#include "gen/classes.h"
#include "gen/complex.h"
#include "gen/dvalue.h"
#include "gen/functions.h"
#include "gen/structs.h"
#include "gen/classes.h"
#include "gen/typeinf.h"
#include "gen/complex.h"
#include "gen/llvmhelpers.h"
#include "gen/irstate.h"
#include "gen/linkage.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/pragma.h"
#include "gen/runtime.h"
#include "gen/structs.h"
#include "gen/typeinf.h"
#include "ir/irtype.h"
#include "ir/irtypeclass.h"
#include "ir/irtypefunction.h"
@@ -965,7 +962,7 @@ LLStructType* DtoMutexType()
// The structures defined here must be the same as in druntime/src/rt/critical.c
// Windows
if (global.params.os == OSWindows)
if (global.params.targetTriple.isOSWindows())
{
llvm::Type *VoidPtrTy = llvm::Type::getInt8PtrTy(gIR->context());
llvm::Type *Int32Ty = llvm::Type::getInt32Ty(gIR->context());
@@ -993,7 +990,7 @@ LLStructType* DtoMutexType()
}
// FreeBSD
else if (global.params.os == OSFreeBSD) {
else if (global.params.targetTriple.getOS() == llvm::Triple::FreeBSD) {
// Just a pointer
return LLStructType::get(gIR->context(), DtoSize_t());
}

View File

@@ -16,12 +16,11 @@
#ifndef LDC_GEN_TOLLVM_H
#define LDC_GEN_TOLLVM_H
#include "gen/llvm.h"
#include "lexer.h"
#include "mtype.h"
#include "attrib.h"
#include "declaration.h"
#include "lexer.h"
#include "mtype.h"
#include "gen/llvm.h"
#include "gen/structs.h"
// D->LLVM type handling stuff

View File

@@ -15,6 +15,7 @@
#ifndef LDC_GEN_TYPEINF_H
#define LDC_GEN_TYPEINF_H
struct TypeInfoDeclaration;
void DtoResolveTypeInfo(TypeInfoDeclaration* tid);
void DtoDeclareTypeInfo(TypeInfoDeclaration* tid);
void DtoConstInitTypeInfo(TypeInfoDeclaration* tid);

View File

@@ -20,39 +20,35 @@
// Copyright (c) 2007 by Tomas Lindquist Olsen
// tomas at famolsen dk
#include <cstdio>
#include <cassert>
#include "gen/llvm.h"
#include "aggregate.h"
#include "attrib.h"
#include "declaration.h"
#include "enum.h"
#include "expression.h"
#include "id.h"
#include "import.h"
#include "init.h"
#include "mars.h"
#include "module.h"
#include "mtype.h"
#include "scope.h"
#include "init.h"
#include "expression.h"
#include "attrib.h"
#include "declaration.h"
#include "template.h"
#include "id.h"
#include "enum.h"
#include "import.h"
#include "aggregate.h"
#include "gen/irstate.h"
#include "gen/logger.h"
#include "gen/runtime.h"
#include "gen/tollvm.h"
#include "gen/llvmhelpers.h"
#include "gen/arrays.h"
#include "gen/structs.h"
#include "gen/classes.h"
#include "gen/irstate.h"
#include "gen/linkage.h"
#include "gen/llvm.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/metadata.h"
#include "gen/rttibuilder.h"
#include "ir/irvar.h"
#include "gen/runtime.h"
#include "gen/structs.h"
#include "gen/tollvm.h"
#include "ir/irtype.h"
#include "ir/irvar.h"
#include <cassert>
#include <cstdio>
#include <ir/irtypeclass.h>
/*******************************************
@@ -719,8 +715,8 @@ void TypeInfoStructDeclaration::llvmDefine()
// On x86_64, class TypeInfo_Struct contains 2 additional fields
// (m_arg1/m_arg2) which are used for the X86_64 System V ABI varargs
// implementation. They are not present on any other cpu/os.
assert((global.params.cpu != ARCHx86_64 && tscd->fields.dim == 11) ||
(global.params.cpu == ARCHx86_64 && tscd->fields.dim == 13));
assert((global.params.targetTriple.getArch() != llvm::Triple::x86_64 && tscd->fields.dim == 11) ||
(global.params.targetTriple.getArch() == llvm::Triple::x86_64 && tscd->fields.dim == 13));
//void function(void*) xdtor;
b.push_funcptr(sd->dtor);

View File

@@ -11,8 +11,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef __LDC_GEN_UTILS_H__
#define __LDC_GEN_UTILS_H__
#ifndef LDC_GEN_UTILS_H
#define LDC_GEN_UTILS_H
#include "root.h"

View File

@@ -7,11 +7,8 @@
//
//===----------------------------------------------------------------------===//
#include "mars.h"
#include "mtype.h"
#include "expression.h"
#include "gen/warnings.h"
#include "mtype.h"
void warnInvalidPrintfCall(Loc loc, Expression* arguments, size_t nargs)
{

View File

@@ -11,9 +11,12 @@
//
//===----------------------------------------------------------------------===//
#ifndef __LDC_GEN_WARNINGS_H__
#define __LDC_GEN_WARNINGS_H__
#ifndef LDC_GEN_WARNINGS_H
#define LDC_GEN_WARNINGS_H
#include "expression.h"
#include "mars.h"
void warnInvalidPrintfCall(Loc loc, Expression* arguments, size_t nargs);
#endif // __LDC_GEN_WARNINGS_H__
#endif // LDC_GEN_WARNINGS_H

View File

@@ -16,10 +16,9 @@
#ifndef LDC_IR_IR_H
#define LDC_IR_IR_H
#include <deque>
#include "ir/irforw.h"
#include "root.h"
#include "ir/irforw.h"
#include <deque>
struct IRState;
struct IrFunction;

View File

@@ -8,12 +8,11 @@
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "gen/logger.h"
#include "ir/ir.h"
#include "ir/irdsymbol.h"
#include "ir/irvar.h"
#include "gen/logger.h"
std::set<IrDsymbol*> IrDsymbol::list;
void IrDsymbol::resetAll()

View File

@@ -10,7 +10,6 @@
#include "gen/llvm.h"
#include "gen/tollvm.h"
#include "ir/irfunction.h"
#include <sstream>
FuncGen::FuncGen()

View File

@@ -19,10 +19,9 @@
#include "gen/llvm.h"
#include "ir/ir.h"
#include "ir/irlandingpad.h"
#include <vector>
#include <stack>
#include <map>
#include <stack>
#include <vector>
struct Statement;
struct EnclosingHandler;

View File

@@ -8,13 +8,11 @@
//===----------------------------------------------------------------------===//
#include "ir/irfuncty.h"
#include "mtype.h"
#include "gen/abi.h"
#include "gen/dvalue.h"
#include "gen/logger.h"
#include "gen/llvm.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
#if LDC_LLVM_VER >= 303

View File

@@ -8,13 +8,13 @@
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "gen/tollvm.h"
#include "gen/irstate.h"
#include "gen/runtime.h"
#include "gen/logger.h"
#include "gen/classes.h"
#include "gen/irstate.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/runtime.h"
#include "gen/todebug.h"
#include "gen/tollvm.h"
#include "ir/irlandingpad.h"
IRLandingPadInfo::IRLandingPadInfo(Catch* catchstmt_, llvm::BasicBlock* end_) :

View File

@@ -15,9 +15,8 @@
#ifndef LDC_IR_IRLANDINGPADINFO_H
#define LDC_IR_IRLANDINGPADINFO_H
#include "ir/ir.h"
#include "statement.h"
#include "ir/ir.h"
#include <deque>
#include <stack>

View File

@@ -8,8 +8,8 @@
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "gen/tollvm.h"
#include "gen/irstate.h"
#include "gen/tollvm.h"
#include "ir/irmodule.h"
IrModule::IrModule(Module* module, const char* srcfilename)

View File

@@ -8,21 +8,17 @@
//===----------------------------------------------------------------------===//
#include "gen/llvm.h"
#include "mtype.h"
#include "aggregate.h"
#include "declaration.h"
#include "init.h"
#include "mtype.h"
#include "gen/irstate.h"
#include "gen/tollvm.h"
#include "gen/logger.h"
#include "gen/llvmhelpers.h"
#include "gen/logger.h"
#include "gen/tollvm.h"
#include "gen/utils.h"
#include "ir/irstruct.h"
#include "ir/irtypeclass.h"
#include <algorithm>
//////////////////////////////////////////////////////////////////////////////

View File

@@ -16,9 +16,8 @@
#define LDC_IR_IRSTRUCT_H
#include "ir/ir.h"
#include <vector>
#include <map>
#include <vector>
// DMD forward declarations
struct StructInitializer;

View File

@@ -68,6 +68,9 @@ llvm::Type * IrTypeBasic::basic2llvm(Type* t)
LLType* t2;
llvm::LLVMContext& ctx = llvm::getGlobalContext();
llvm::Triple::ArchType const a = global.params.targetTriple.getArch();
bool const anyX86 = (a == llvm::Triple::x86) || (a == llvm::Triple::x86_64);
bool const anyPPC = (a == llvm::Triple::ppc) || (a == llvm::Triple::ppc64);
switch(t->ty)
{
@@ -110,10 +113,10 @@ llvm::Type * IrTypeBasic::basic2llvm(Type* t)
case Tfloat80:
case Timaginary80:
// only x86 has 80bit float
if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64)
if (anyX86)
return llvm::Type::getX86_FP80Ty(ctx);
// PPC has a special 128bit float
else if (global.params.cpu == ARCHppc || global.params.cpu == ARCHppc_64)
else if (anyPPC)
return llvm::Type::getPPC_FP128Ty(ctx);
// other platforms use 64bit reals
else
@@ -129,11 +132,8 @@ llvm::Type * IrTypeBasic::basic2llvm(Type* t)
return getComplexType(ctx, t2);
case Tcomplex80:
t2 = (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64)
? llvm::Type::getX86_FP80Ty(ctx)
: (global.params.cpu == ARCHppc || global.params.cpu == ARCHppc_64)
? llvm::Type::getPPC_FP128Ty(ctx)
: llvm::Type::getDoubleTy(ctx);
t2 = anyX86 ? llvm::Type::getX86_FP80Ty(ctx)
: (anyPPC ? llvm::Type::getPPC_FP128Ty(ctx) : llvm::Type::getDoubleTy(ctx));
return getComplexType(ctx, t2);
case Tbool:

View File

@@ -16,9 +16,9 @@
#include "ir/irtypestruct.h"
#if LDC_LLVM_VER >= 303
#include <llvm/IR/DerivedTypes.h>
#include "llvm/IR/DerivedTypes.h"
#else
#include <llvm/DerivedTypes.h>
#include "llvm/DerivedTypes.h"
#endif
///

View File

@@ -13,22 +13,20 @@
//
//===----------------------------------------------------------------------===//
#include <map>
#include <string>
#include "llvm/TableGen/Main.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/PathV1.h"
#include "llvm/TableGen/Record.h"
#if LDC_LLVM_VER < 302
#include "llvm/TableGen/TableGenAction.h"
#endif
#include <algorithm>
#include <assert.h>
#include <map>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <llvm/TableGen/Main.h>
#if LDC_LLVM_VER < 302
#include <llvm/TableGen/TableGenAction.h>
#endif
#include <llvm/TableGen/Record.h>
#include <llvm/Support/CommandLine.h>
#include <llvm/Support/PathV1.h>
#include <llvm/ADT/StringRef.h>
#include <string>
using namespace std;
using namespace llvm;