mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-31 03:53:14 +01:00
Merge pre-release cleanup changes.
This commit is contained in:
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.gitattributes export-ignore
|
||||
.travis.yml export-ignore
|
||||
51
.hgignore
51
.hgignore
@@ -1,51 +0,0 @@
|
||||
syntax: glob
|
||||
*.bc
|
||||
*.diff
|
||||
*.o
|
||||
*.obj
|
||||
*.orig
|
||||
*.patch
|
||||
*.a
|
||||
*.s
|
||||
*.so
|
||||
*.swp
|
||||
*.rej
|
||||
*~
|
||||
Makefile
|
||||
CMakeFiles
|
||||
CMakeCache.txt
|
||||
cmake_install.cmake
|
||||
.DS_Store
|
||||
CMakeLists.txt.user*
|
||||
.directory
|
||||
druntime
|
||||
phobos
|
||||
druntime-orig
|
||||
phobos-orig
|
||||
|
||||
syntax: regexp
|
||||
^obj/
|
||||
^tests/dstress/
|
||||
^tests/reference/
|
||||
^tango/
|
||||
^druntime/
|
||||
^phobos/
|
||||
^import/
|
||||
^bin/ldc2?$
|
||||
^bin/ldc2?\.conf$
|
||||
^bin/ldc2?\.rebuild\.conf$
|
||||
^idgen\.make$
|
||||
^impcnvgen\.make$
|
||||
^ldc\.make$
|
||||
^revisions\.pl$
|
||||
^gen/revisions\.h$
|
||||
^gen/llvm-version\.h$
|
||||
^dmd2?/idgen$
|
||||
^dmd2?/impcnvgen$
|
||||
^dmd2?/impcnvtab\.c$
|
||||
^dmd2?/id\.c$
|
||||
^dmd2?/id\.h$
|
||||
^tests/runminitest$
|
||||
^tests/findregressions$
|
||||
^tests/makewebstatistics$
|
||||
^tests/mini/obj/
|
||||
16
README
16
README
@@ -10,8 +10,8 @@ and relies on the LLVM Core libraries for code generation.
|
||||
LDC is fully Open Source; the parts of the code not taken/adapted from
|
||||
other projects are BSD-licensed (see the LICENSE file for details).
|
||||
|
||||
Please consult the project website for further information:
|
||||
http://ldc-developers.github.com
|
||||
Please consult the D wiki for further information:
|
||||
http://wiki.dlang.org/LDC
|
||||
|
||||
|
||||
Installation
|
||||
@@ -20,14 +20,14 @@ Installation
|
||||
In-depth material on building and installing LDC and the standard
|
||||
libraries, including experimental instructions for running LDC on
|
||||
Windows, is available on the project wiki, at
|
||||
https://github.com/ldc-developers/ldc/wiki/Installation.
|
||||
http://wiki.dlang.org/Building_LDC_from_source.
|
||||
|
||||
For the impatient, a quick guide for building on *nix systems:
|
||||
|
||||
1) Make sure your system has the necessary prerequisites:
|
||||
- a working C++ build environment,
|
||||
- CMake,
|
||||
- LLVM 3.0+ (3.1 preferred),
|
||||
- LLVM 3.0+ (3.2 preferred),
|
||||
- libconfig++ (http://hyperrealm.com/libconfig/libconfig.html).
|
||||
|
||||
2) Check out the library submodules, if you have not already:
|
||||
@@ -51,8 +51,10 @@ Contact
|
||||
-------
|
||||
|
||||
The best way to get in touch with the developers is either via the
|
||||
mailing list at ldc-dev@googlegroups.com, or the #ldc IRC channel on
|
||||
FreeNode. We can usually be found on the main (Digital Mars) language
|
||||
newsgroups (http://forum.dlang.org) as well.
|
||||
digitalmars.D.ldc forum/newsgroup/mailing list (http://forum.dlang.org)
|
||||
or the #ldc IRC channel on FreeNode.
|
||||
|
||||
For further documentation, contributor information, etc. please see the
|
||||
D wiki: http://wiki.dlang.org/LDC
|
||||
|
||||
Feedback of any kind is very much appreciated!
|
||||
|
||||
@@ -53,7 +53,6 @@ Dsymbol::Dsymbol()
|
||||
this->errors = false;
|
||||
#if IN_LLVM
|
||||
this->llvmInternal = LLVMnone;
|
||||
this->irsym = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -73,7 +72,6 @@ Dsymbol::Dsymbol(Identifier *ident)
|
||||
this->errors = false;
|
||||
#if IN_LLVM
|
||||
this->llvmInternal = LLVMnone;
|
||||
this->irsym = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ struct Classsym;
|
||||
|
||||
#if IN_LLVM
|
||||
class Ir;
|
||||
class IrSymbol;
|
||||
namespace llvm
|
||||
{
|
||||
class Value;
|
||||
@@ -284,7 +283,6 @@ struct Dsymbol : Object
|
||||
int llvmInternal;
|
||||
|
||||
IrDsymbol ir;
|
||||
IrSymbol* irsym;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ Global::Global()
|
||||
copyright = "Copyright (c) 1999-2012 by Digital Mars and Tomas Lindquist Olsen";
|
||||
written = "written by Walter Bright and Tomas Lindquist Olsen";
|
||||
version = "v1.075";
|
||||
ldc_version = "LDC trunk";
|
||||
ldc_version = "trunk";
|
||||
llvm_version = "LLVM "LDC_LLVM_VERSION_STRING;
|
||||
global.structalign = STRUCTALIGN_DEFAULT;
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ Dsymbol::Dsymbol()
|
||||
|
||||
#if IN_LLVM
|
||||
this->llvmInternal = LLVMnone;
|
||||
this->irsym = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -75,7 +74,6 @@ Dsymbol::Dsymbol(Identifier *ident)
|
||||
|
||||
#if IN_LLVM
|
||||
this->llvmInternal = LLVMnone;
|
||||
this->irsym = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,6 @@ struct TYPE;
|
||||
|
||||
#if IN_LLVM
|
||||
class Ir;
|
||||
class IrSymbol;
|
||||
namespace llvm
|
||||
{
|
||||
class Value;
|
||||
@@ -290,7 +289,6 @@ struct Dsymbol : Object
|
||||
int llvmInternal;
|
||||
|
||||
IrDsymbol ir;
|
||||
IrSymbol* irsym;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ Global::Global()
|
||||
;
|
||||
version = "v2.060";
|
||||
#if IN_LLVM
|
||||
ldc_version = "LDC trunk";
|
||||
ldc_version = "trunk";
|
||||
llvm_version = "LLVM "LDC_LLVM_VERSION_STRING;
|
||||
#endif
|
||||
global.structalign = STRUCTALIGN_DEFAULT;
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- cl_options.cpp ----------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "driver/cl_options.h"
|
||||
#include "gen/cl_helpers.h"
|
||||
|
||||
@@ -249,7 +258,7 @@ static cl::list<std::string, StringsAdapter> linkerSwitches("L",
|
||||
cl::opt<std::string> moduleDepsFile("deps",
|
||||
cl::desc("Write module dependencies to filename"),
|
||||
cl::value_desc("filename"));
|
||||
|
||||
|
||||
|
||||
cl::opt<std::string> mArch("march",
|
||||
cl::desc("Architecture to generate code for:"));
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
//===-- driver/cl_options.h - LDC command line options ----------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Defines the LDC command line options as handled using the LLVM command
|
||||
// line parsing library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_CL_OPTIONS_H
|
||||
#define LDC_CL_OPTIONS_H
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- configfile.cpp ----------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- driver/configfile.h - LDC config file handling ----------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Handles reading and parsing of an LDC config file (ldc.conf/ldc2.conf).
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_CONF_CONFIGFILE_H
|
||||
#define LDC_CONF_CONFIGFILE_H
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
/**
|
||||
* Wrapper allowing use of LDC as drop-in replacement for DMD.
|
||||
*
|
||||
* Copyright (c) 2012 by the LDC Team.
|
||||
*
|
||||
* Command line parsing code originally
|
||||
* Copyright (c) 1999-2012 by Digital Mars.
|
||||
*/
|
||||
//===-- ldmd.cpp - Drop-in DMD replacement wrapper for LDC ----------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license, except for the
|
||||
// command line handling code, which originated from DMD. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Wrapper allowing use of LDC as drop-in replacement for DMD.
|
||||
//
|
||||
// The reason why full command line parsing is required instead of just
|
||||
// rewriting the names of a few switches is an annoying impedance mismatch
|
||||
// between the way how DMD handles arguments and the LLVM command line library:
|
||||
@@ -37,6 +41,8 @@
|
||||
// Note: This program inherited ugly C-style string handling and memory leaks
|
||||
// from DMD, but this should not be a problem due to the short-livedness of
|
||||
// the process.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_EXE_NAME
|
||||
# error "Please define LDC_EXE_NAME to the name of the LDC executable to use."
|
||||
@@ -147,9 +153,9 @@ Usage:\n\
|
||||
@cmdfile read arguments from cmdfile\n\
|
||||
-c do not link\n"
|
||||
#if 0
|
||||
"-cov do code coverage analysis\n"
|
||||
" -cov do code coverage analysis\n"
|
||||
#endif
|
||||
"-D generate documentation\n\
|
||||
" -D generate documentation\n\
|
||||
-Dddocdir write documentation file to docdir directory\n\
|
||||
-Dffilename write documentation file to filename\n\
|
||||
-d allow deprecated features\n\
|
||||
@@ -177,7 +183,7 @@ Usage:\n\
|
||||
-m64 generate 64 bit code\n\
|
||||
-man open web browser on manual page\n"
|
||||
#if 0
|
||||
"-map generate linker .map file\n"
|
||||
" -map generate linker .map file\n"
|
||||
#endif
|
||||
#if DMDV2
|
||||
" -noboundscheck turns off array bounds checking for all functions\n"
|
||||
@@ -189,9 +195,9 @@ Usage:\n\
|
||||
-offilename name output file to filename\n\
|
||||
-op do not strip paths from source file\n"
|
||||
#if 0
|
||||
"-profile profile runtime performance of generated code\n"
|
||||
" -profile profile runtime performance of generated code\n"
|
||||
#endif
|
||||
"-property enforce property syntax\n\
|
||||
" -property enforce property syntax\n\
|
||||
-quiet suppress unnecessary messages\n\
|
||||
-release compile release version\n\
|
||||
-run srcfile args... run resulting program, passing args\n\
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- linker.cpp --------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
#include "llvm/Linker.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
//===-- driver/linker.h - Linker invocation ---------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Handles locating and executing the system linker for generating
|
||||
// libraries/executables.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_LINKER_H
|
||||
#define LDC_GEN_LINKER_H
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
// Pulled out of dmd/mars.c
|
||||
|
||||
// some things are taken from llvm's llc tool
|
||||
// which uses the llvm license
|
||||
//===-- main.cpp --------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvmcompat.h"
|
||||
#include "gen/llvm.h"
|
||||
@@ -86,15 +90,13 @@ static cl::list<std::string, StringsAdapter> debuglibs("debuglib",
|
||||
cl::CommaSeparated);
|
||||
|
||||
void printVersion() {
|
||||
printf("LLVM D Compiler %s\nbased on DMD %s and %s\n%s\n%s\n",
|
||||
global.ldc_version, global.version, global.llvm_version, global.copyright, global.written);
|
||||
printf("D Language Documentation: http://d-programming-language.org/index.html\n"
|
||||
"LDC Homepage: https://github.com/ldc-developers/ldc\n");
|
||||
printf("\n");
|
||||
printf("LDC - the LLVM D compiler (%s):\n", global.ldc_version);
|
||||
printf(" based on DMD %s and %s\n", global.version, global.llvm_version);
|
||||
printf(" Default target: %s\n", llvm::sys::getDefaultTargetTriple().c_str());
|
||||
std::string CPU = llvm::sys::getHostCPUName();
|
||||
if (CPU == "generic") CPU = "(unknown)";
|
||||
printf(" Host CPU: %s\n", CPU.c_str());
|
||||
printf(" http://dlang.org - http://wiki.dlang.org/LDC\n");
|
||||
printf("\n");
|
||||
|
||||
// Without explicitly flushing here, only the target list is visible when
|
||||
@@ -238,11 +240,12 @@ int main(int argc, char** argv)
|
||||
|
||||
// Handle fixed-up arguments!
|
||||
cl::SetVersionPrinter(&printVersion);
|
||||
#if LDC_LLVM_VER >= 302
|
||||
cl::ParseCommandLineOptions(final_args.size(), const_cast<char**>(&final_args[0]), "LLVM-based D Compiler\n");
|
||||
#else
|
||||
cl::ParseCommandLineOptions(final_args.size(), const_cast<char**>(&final_args[0]), "LLVM-based D Compiler\n", true);
|
||||
cl::ParseCommandLineOptions(final_args.size(), const_cast<char**>(&final_args[0]),
|
||||
"LDC - the LLVM D compiler\n"
|
||||
#if LDC_LLVM_VER < 302
|
||||
, true
|
||||
#endif
|
||||
);
|
||||
|
||||
// Print config file path if -v was passed
|
||||
if (global.params.verbose) {
|
||||
|
||||
292
driver/toobj.cpp
292
driver/toobj.cpp
@@ -1,153 +1,153 @@
|
||||
|
||||
// Copyright (c) 1999-2004 by Digital Mars
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// www.digitalmars.com
|
||||
// License for redistribution is by either the Artistic License
|
||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||
// See the included readme.txt for details.
|
||||
|
||||
#include <cstddef>
|
||||
#include <fstream>
|
||||
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Module.h"
|
||||
#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"
|
||||
|
||||
|
||||
// fwd decl
|
||||
void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& Out,
|
||||
llvm::TargetMachine::CodeGenFileType fileType);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void writeModule(llvm::Module* m, std::string filename)
|
||||
{
|
||||
// run optimizer
|
||||
ldc_optimize_module(m);
|
||||
|
||||
// eventually do our own path stuff, dmd's is a bit strange.
|
||||
typedef llvm::sys::Path LLPath;
|
||||
|
||||
// write LLVM bitcode
|
||||
if (global.params.output_bc) {
|
||||
LLPath bcpath = LLPath(filename);
|
||||
bcpath.eraseSuffix();
|
||||
bcpath.appendSuffix(std::string(global.bc_ext));
|
||||
Logger::println("Writing LLVM bitcode to: %s\n", bcpath.c_str());
|
||||
std::string errinfo;
|
||||
llvm::raw_fd_ostream bos(bcpath.c_str(), errinfo, llvm::raw_fd_ostream::F_Binary);
|
||||
if (bos.has_error())
|
||||
{
|
||||
error("cannot write LLVM bitcode file '%s': %s", bcpath.c_str(), errinfo.c_str());
|
||||
fatal();
|
||||
}
|
||||
llvm::WriteBitcodeToFile(m, bos);
|
||||
}
|
||||
|
||||
// write LLVM IR
|
||||
if (global.params.output_ll) {
|
||||
LLPath llpath = LLPath(filename);
|
||||
llpath.eraseSuffix();
|
||||
llpath.appendSuffix(std::string(global.ll_ext));
|
||||
Logger::println("Writing LLVM asm to: %s\n", llpath.c_str());
|
||||
std::string errinfo;
|
||||
llvm::raw_fd_ostream aos(llpath.c_str(), errinfo);
|
||||
if (aos.has_error())
|
||||
{
|
||||
error("cannot write LLVM asm file '%s': %s", llpath.c_str(), errinfo.c_str());
|
||||
fatal();
|
||||
}
|
||||
m->print(aos, NULL);
|
||||
}
|
||||
|
||||
// write native assembly
|
||||
if (global.params.output_s) {
|
||||
LLPath spath = LLPath(filename);
|
||||
spath.eraseSuffix();
|
||||
spath.appendSuffix(std::string(global.s_ext));
|
||||
Logger::println("Writing native asm to: %s\n", spath.c_str());
|
||||
std::string err;
|
||||
{
|
||||
llvm::raw_fd_ostream out(spath.c_str(), err);
|
||||
if (err.empty())
|
||||
{
|
||||
emit_file(*gTargetMachine, *m, out, llvm::TargetMachine::CGFT_AssemblyFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
error("cannot write native asm: %s", err.c_str());
|
||||
fatal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (global.params.output_o) {
|
||||
LLPath objpath = LLPath(filename);
|
||||
Logger::println("Writing object file to: %s\n", objpath.c_str());
|
||||
std::string err;
|
||||
{
|
||||
llvm::raw_fd_ostream out(objpath.c_str(), err, llvm::raw_fd_ostream::F_Binary);
|
||||
if (err.empty())
|
||||
{
|
||||
emit_file(*gTargetMachine, *m, out, llvm::TargetMachine::CGFT_ObjectFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
error("cannot write object file: %s", err.c_str());
|
||||
fatal();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================================== */
|
||||
|
||||
// based on llc code, University of Illinois Open Source License
|
||||
void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& out,
|
||||
llvm::TargetMachine::CodeGenFileType fileType)
|
||||
{
|
||||
using namespace llvm;
|
||||
|
||||
// Build up all of the passes that we want to do to the module.
|
||||
FunctionPassManager Passes(&m);
|
||||
|
||||
//===-- toobj.cpp ---------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <cstddef>
|
||||
#include <fstream>
|
||||
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Module.h"
|
||||
#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"
|
||||
|
||||
|
||||
// fwd decl
|
||||
void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& Out,
|
||||
llvm::TargetMachine::CodeGenFileType fileType);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void writeModule(llvm::Module* m, std::string filename)
|
||||
{
|
||||
// run optimizer
|
||||
ldc_optimize_module(m);
|
||||
|
||||
// eventually do our own path stuff, dmd's is a bit strange.
|
||||
typedef llvm::sys::Path LLPath;
|
||||
|
||||
// write LLVM bitcode
|
||||
if (global.params.output_bc) {
|
||||
LLPath bcpath = LLPath(filename);
|
||||
bcpath.eraseSuffix();
|
||||
bcpath.appendSuffix(std::string(global.bc_ext));
|
||||
Logger::println("Writing LLVM bitcode to: %s\n", bcpath.c_str());
|
||||
std::string errinfo;
|
||||
llvm::raw_fd_ostream bos(bcpath.c_str(), errinfo, llvm::raw_fd_ostream::F_Binary);
|
||||
if (bos.has_error())
|
||||
{
|
||||
error("cannot write LLVM bitcode file '%s': %s", bcpath.c_str(), errinfo.c_str());
|
||||
fatal();
|
||||
}
|
||||
llvm::WriteBitcodeToFile(m, bos);
|
||||
}
|
||||
|
||||
// write LLVM IR
|
||||
if (global.params.output_ll) {
|
||||
LLPath llpath = LLPath(filename);
|
||||
llpath.eraseSuffix();
|
||||
llpath.appendSuffix(std::string(global.ll_ext));
|
||||
Logger::println("Writing LLVM asm to: %s\n", llpath.c_str());
|
||||
std::string errinfo;
|
||||
llvm::raw_fd_ostream aos(llpath.c_str(), errinfo);
|
||||
if (aos.has_error())
|
||||
{
|
||||
error("cannot write LLVM asm file '%s': %s", llpath.c_str(), errinfo.c_str());
|
||||
fatal();
|
||||
}
|
||||
m->print(aos, NULL);
|
||||
}
|
||||
|
||||
// write native assembly
|
||||
if (global.params.output_s) {
|
||||
LLPath spath = LLPath(filename);
|
||||
spath.eraseSuffix();
|
||||
spath.appendSuffix(std::string(global.s_ext));
|
||||
Logger::println("Writing native asm to: %s\n", spath.c_str());
|
||||
std::string err;
|
||||
{
|
||||
llvm::raw_fd_ostream out(spath.c_str(), err);
|
||||
if (err.empty())
|
||||
{
|
||||
emit_file(*gTargetMachine, *m, out, llvm::TargetMachine::CGFT_AssemblyFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
error("cannot write native asm: %s", err.c_str());
|
||||
fatal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (global.params.output_o) {
|
||||
LLPath objpath = LLPath(filename);
|
||||
Logger::println("Writing object file to: %s\n", objpath.c_str());
|
||||
std::string err;
|
||||
{
|
||||
llvm::raw_fd_ostream out(objpath.c_str(), err, llvm::raw_fd_ostream::F_Binary);
|
||||
if (err.empty())
|
||||
{
|
||||
emit_file(*gTargetMachine, *m, out, llvm::TargetMachine::CGFT_ObjectFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
error("cannot write object file: %s", err.c_str());
|
||||
fatal();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================================== */
|
||||
|
||||
// based on llc code, University of Illinois Open Source License
|
||||
void emit_file(llvm::TargetMachine &Target, llvm::Module& m, llvm::raw_fd_ostream& out,
|
||||
llvm::TargetMachine::CodeGenFileType fileType)
|
||||
{
|
||||
using namespace llvm;
|
||||
|
||||
// Build up all of the passes that we want to do to the module.
|
||||
FunctionPassManager Passes(&m);
|
||||
|
||||
#if LDC_LLVM_VER >= 302
|
||||
if (const DataLayout *DL = Target.getDataLayout())
|
||||
Passes.add(new DataLayout(*DL));
|
||||
else
|
||||
Passes.add(new DataLayout(&m));
|
||||
#else
|
||||
if (const TargetData *TD = Target.getTargetData())
|
||||
Passes.add(new TargetData(*TD));
|
||||
else
|
||||
Passes.add(new TargetData(&m));
|
||||
if (const TargetData *TD = Target.getTargetData())
|
||||
Passes.add(new TargetData(*TD));
|
||||
else
|
||||
Passes.add(new TargetData(&m));
|
||||
#endif
|
||||
|
||||
llvm::formatted_raw_ostream fout(out);
|
||||
if (Target.addPassesToEmitFile(Passes, fout, fileType, codeGenOptLevel()))
|
||||
assert(0 && "no support for asm output");
|
||||
|
||||
Passes.doInitialization();
|
||||
|
||||
// Run our queue of passes all at once now, efficiently.
|
||||
for (llvm::Module::iterator I = m.begin(), E = m.end(); I != E; ++I)
|
||||
if (!I->isDeclaration())
|
||||
Passes.run(*I);
|
||||
|
||||
Passes.doFinalization();
|
||||
|
||||
// release module from module provider so we can delete it ourselves
|
||||
//std::string Err;
|
||||
//llvm::Module* rmod = Provider.releaseModule(&Err);
|
||||
//assert(rmod);
|
||||
}
|
||||
|
||||
llvm::formatted_raw_ostream fout(out);
|
||||
if (Target.addPassesToEmitFile(Passes, fout, fileType, codeGenOptLevel()))
|
||||
assert(0 && "no support for asm output");
|
||||
|
||||
Passes.doInitialization();
|
||||
|
||||
// Run our queue of passes all at once now, efficiently.
|
||||
for (llvm::Module::iterator I = m.begin(), E = m.end(); I != E; ++I)
|
||||
if (!I->isDeclaration())
|
||||
Passes.run(*I);
|
||||
|
||||
Passes.doFinalization();
|
||||
|
||||
// release module from module provider so we can delete it ourselves
|
||||
//std::string Err;
|
||||
//llvm::Module* rmod = Provider.releaseModule(&Err);
|
||||
//assert(rmod);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- driver/toobj.h - Object file emission -------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Handles emission of "finished" LLVM modules to on-disk object files.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_TOOBJ_H
|
||||
#define LDC_GEN_TOOBJ_H
|
||||
|
||||
|
||||
13
gen/aa.cpp
13
gen/aa.cpp
@@ -1,3 +1,12 @@
|
||||
//===-- aa.cpp ------------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
|
||||
#include "mtype.h"
|
||||
@@ -78,7 +87,7 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue)
|
||||
if (lvalue) {
|
||||
// valuesize param
|
||||
LLValue* valsize = DtoConstSize_t(getTypePaddedSize(DtoType(type)));
|
||||
|
||||
|
||||
ret = gIR->CreateCallOrInvoke4(func, aaval, keyti, valsize, pkey, "aa.index").getInstruction();
|
||||
} else {
|
||||
ret = gIR->CreateCallOrInvoke3(func, aaval, keyti, pkey, "aa.index").getInstruction();
|
||||
@@ -266,7 +275,7 @@ LLValue* DtoAAEquals(Loc& loc, TOK op, DValue* l, DValue* r)
|
||||
#else
|
||||
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaEq");
|
||||
LLFunctionType* funcTy = func->getFunctionType();
|
||||
|
||||
|
||||
LLValue* aaval = DtoBitCast(l->getRVal(), funcTy->getParamType(0));
|
||||
LLValue* abval = DtoBitCast(r->getRVal(), funcTy->getParamType(1));
|
||||
LLValue* aaTypeInfo = DtoTypeInfoOf(t);
|
||||
|
||||
14
gen/aa.h
14
gen/aa.h
@@ -1,3 +1,17 @@
|
||||
//===-- gen/aa.h - Associative array codegen helpers ------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Helpers for generating calls to associative array runtime functions.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#ifndef LDC_GEN_AA_H
|
||||
#define LDC_GEN_AA_H
|
||||
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- gen/abi-generic.h - Generic Target ABI helpers ----------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Contains helpers for handling rewrites common to more than one target ABI.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_ABI_GENERIC
|
||||
#define LDC_GEN_ABI_GENERIC
|
||||
|
||||
|
||||
@@ -1,30 +1,37 @@
|
||||
/* TargetABI implementation for x86-64.
|
||||
* Written for LDC by Frits van Bommel in 2009.
|
||||
*
|
||||
* extern(C) implements the C calling convention for x86-64, as found in
|
||||
* http://www.x86-64.org/documentation/abi-0.99.pdf
|
||||
*
|
||||
* Note:
|
||||
* Where a discrepancy was found between llvm-gcc and the ABI documentation,
|
||||
* llvm-gcc behavior was used for compatibility (after it was verified that
|
||||
* regular gcc has the same behavior).
|
||||
*
|
||||
* LLVM gets it right for most types, but complex numbers and structs need some
|
||||
* help. To make sure it gets those right we essentially bitcast small structs
|
||||
* to a type to which LLVM assigns the appropriate registers, and pass that
|
||||
* instead. Structs that are required to be passed in memory are explicitly
|
||||
* marked with the ByVal attribute to ensure no part of them ends up in
|
||||
* registers when only a subset of the desired registers are available.
|
||||
*
|
||||
* We don't perform the same transformation for D-specific types that contain
|
||||
* multiple parts, such as dynamic arrays and delegates. They're passed as if
|
||||
* the parts were passed as separate parameters. This helps make things like
|
||||
* printf("%.*s", o.toString()) work as expected; if we didn't do this that
|
||||
* wouldn't work if there were 4 other integer/pointer arguments before the
|
||||
* toString() call because the string got bumped to memory with one integer
|
||||
* register still free. Keeping it untransformed puts the length in a register
|
||||
* and the pointer in memory, as printf expects it.
|
||||
*/
|
||||
//===-- abi-x86-64.cpp ----------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// extern(C) implements the C calling convention for x86-64, as found in
|
||||
// http://www.x86-64.org/documentation/abi-0.99.pdf
|
||||
//
|
||||
// Note:
|
||||
// Where a discrepancy was found between llvm-gcc and the ABI documentation,
|
||||
// llvm-gcc behavior was used for compatibility (after it was verified that
|
||||
// regular gcc has the same behavior).
|
||||
//
|
||||
// LLVM gets it right for most types, but complex numbers and structs need some
|
||||
// help. To make sure it gets those right we essentially bitcast small structs
|
||||
// to a type to which LLVM assigns the appropriate registers, and pass that
|
||||
// instead. Structs that are required to be passed in memory are explicitly
|
||||
// marked with the ByVal attribute to ensure no part of them ends up in
|
||||
// registers when only a subset of the desired registers are available.
|
||||
//
|
||||
// We don't perform the same transformation for D-specific types that contain
|
||||
// multiple parts, such as dynamic arrays and delegates. They're passed as if
|
||||
// the parts were passed as separate parameters. This helps make things like
|
||||
// printf("%.*s", o.toString()) work as expected; if we didn't do this that
|
||||
// wouldn't work if there were 4 other integer/pointer arguments before the
|
||||
// toString() call because the string got bumped to memory with one integer
|
||||
// register still free. Keeping it untransformed puts the length in a register
|
||||
// and the pointer in memory, as printf expects it.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mtype.h"
|
||||
#include "declaration.h"
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- gen/abi-x86-64.h - x86_64 ABI description ---------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The ABI implementation used for 64 bit x86 (i.e. x86_64/AMD64/x64) targets.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef __LDC_GEN_ABI_X86_64_H__
|
||||
#define __LDC_GEN_ABI_X86_64_H__
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- abi-x86.cpp -------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
|
||||
#include "mars.h"
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- gen/abi-x86.h - x86 ABI description ---------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The ABI implementation used for 32 bit x86 targets.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef __LDC_GEN_ABI_X86_H__
|
||||
#define __LDC_GEN_ABI_X86_H__
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- abi.cpp -----------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
16
gen/abi.h
16
gen/abi.h
@@ -1,3 +1,19 @@
|
||||
//===-- gen/abi.h - Target ABI description for IR generation ----*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This interface is used by the IR generation code to accomodate any
|
||||
// additional transformations necessary for the given target ABI (the direct
|
||||
// LLVM IR representation for C structs unfortunately does not always lead to
|
||||
// the right ABI, for example on x86_64).
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef __LDC_GEN_ABI_H__
|
||||
#define __LDC_GEN_ABI_H__
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- arrays.cpp --------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
|
||||
#include "mtype.h"
|
||||
|
||||
13
gen/arrays.h
13
gen/arrays.h
@@ -1,3 +1,16 @@
|
||||
//===-- gen/arrays.h - D array codegen helpers ------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Helper functions for manipulating D dynamic array (slice) types/values.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVMC_GEN_ARRAYS_H
|
||||
#define LLVMC_GEN_ARRAYS_H
|
||||
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
// Taken from GDC source tree. Original by David Friedman.
|
||||
// Released under the Artistic License found in dmd/artistic.txt
|
||||
//===-- gen/asm-x86-32.h - x86 inline assembler handling --------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file originates from work by David Friedman for GDC released under
|
||||
// the GPL 2 and Artistic licenses. See the LICENSE file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Parses "DMD-style" x86 inline assembly blocks and converts them to
|
||||
// GDC/LLVM inline assembler syntax.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "id.h"
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
// Taken from GDC source tree. Original by David Friedman.
|
||||
// Released under the Artistic License found in dmd/artistic.txt
|
||||
//===-- gen/asm-x86-64.h - x86_64 inline assembler handling -----*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file originates from work by David Friedman for GDC released under
|
||||
// the GPL 2 and Artistic licenses. See the LICENSE file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Parses "DMD-style" x86_64 inline assembly blocks and converts them to
|
||||
// GDC/LLVM inline assembler syntax.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "id.h"
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
// Taken from GDC source tree. Original by David Friedman.
|
||||
// Released under the Artistic License found in dmd/artistic.txt
|
||||
//===-- asmstmt.cpp -------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file originates from work by David Friedman for GDC released under
|
||||
// the GPL 2 and Artistic licenses. See the LICENSE file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
#include "llvm/InlineAsm.h"
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- binops.cpp --------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
|
||||
#include "declaration.h"
|
||||
@@ -17,13 +26,13 @@ DValue* DtoBinAdd(DValue* lhs, DValue* rhs)
|
||||
LLValue *l, *r;
|
||||
l = lhs->getRVal();
|
||||
r = rhs->getRVal();
|
||||
|
||||
|
||||
LLValue* res;
|
||||
if (t->isfloating())
|
||||
res = gIR->ir->CreateFAdd(l, r, "tmp");
|
||||
else
|
||||
res = gIR->ir->CreateAdd(l, r, "tmp");
|
||||
|
||||
|
||||
return new DImValue( t, res );
|
||||
}
|
||||
|
||||
@@ -35,13 +44,13 @@ DValue* DtoBinSub(DValue* lhs, DValue* rhs)
|
||||
LLValue *l, *r;
|
||||
l = lhs->getRVal();
|
||||
r = rhs->getRVal();
|
||||
|
||||
|
||||
LLValue* res;
|
||||
if (t->isfloating())
|
||||
res = gIR->ir->CreateFSub(l, r, "tmp");
|
||||
else
|
||||
res = gIR->ir->CreateSub(l, r, "tmp");
|
||||
|
||||
|
||||
return new DImValue( t, res );
|
||||
}
|
||||
|
||||
@@ -53,7 +62,7 @@ DValue* DtoBinMul(Type* targettype, DValue* lhs, DValue* rhs)
|
||||
LLValue *l, *r;
|
||||
l = lhs->getRVal();
|
||||
r = rhs->getRVal();
|
||||
|
||||
|
||||
LLValue* res;
|
||||
if (t->isfloating())
|
||||
res = gIR->ir->CreateFMul(l, r, "tmp");
|
||||
@@ -70,7 +79,7 @@ DValue* DtoBinDiv(Type* targettype, DValue* lhs, DValue* rhs)
|
||||
LLValue *l, *r;
|
||||
l = lhs->getRVal();
|
||||
r = rhs->getRVal();
|
||||
|
||||
|
||||
LLValue* res;
|
||||
if (t->isfloating())
|
||||
res = gIR->ir->CreateFDiv(l, r, "tmp");
|
||||
@@ -120,7 +129,7 @@ LLValue* DtoBinNumericEquals(Loc loc, DValue* lhs, DValue* rhs, TOK op)
|
||||
Logger::println("floating");
|
||||
res = DtoBinFloatsEquals(loc, lhs, rhs, op);
|
||||
}
|
||||
|
||||
|
||||
assert(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- cl_helpers.cpp ----------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/cl_helpers.h"
|
||||
|
||||
#include "mars.h"
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
//===-- gen/cl_helpers.h - Command line processing helpers ------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Helpers to augment the LLVM command line parsing library with some extra
|
||||
// functionality.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_CL_HELPERS_H
|
||||
#define LDC_CL_HELPERS_H
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- classes.cpp -------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
|
||||
#include "mtype.h"
|
||||
@@ -296,7 +305,7 @@ DValue* DtoCastClass(DValue* val, Type* _to)
|
||||
IrTypeClass* typeclass = stripModifiers(fc)->irtype->isClass();
|
||||
|
||||
// find interface impl
|
||||
|
||||
|
||||
size_t i_index = typeclass->getInterfaceIndex(it);
|
||||
assert(i_index != ~0 && "requesting interface that is not implemented by this class");
|
||||
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
//===-- gen/classes.h - D class code generation -----------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Functions for generating LLVM types and init/TypeInfo/etc. values from D
|
||||
// class declarations and handling class instance values.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_CLASSES_H
|
||||
#define LDC_GEN_CLASSES_H
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- complex.cpp -------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
|
||||
#include "mtype.h"
|
||||
@@ -211,7 +220,7 @@ DValue* DtoComplexAdd(Loc& loc, Type* type, DValue* lhs, DValue* rhs)
|
||||
res_re = lhs_re;
|
||||
else // either rhs_re or no re at all (then use any)
|
||||
res_re = rhs_re;
|
||||
|
||||
|
||||
if(lhs_im && rhs_im)
|
||||
res_im = gIR->ir->CreateFAdd(lhs_im, rhs_im, "tmp");
|
||||
else if(lhs_im)
|
||||
@@ -241,7 +250,7 @@ DValue* DtoComplexSub(Loc& loc, Type* type, DValue* lhs, DValue* rhs)
|
||||
res_re = lhs_re;
|
||||
else // either rhs_re or no re at all (then use any)
|
||||
res_re = gIR->ir->CreateFNeg(rhs_re, "neg");
|
||||
|
||||
|
||||
if(lhs_im && rhs_im)
|
||||
res_im = gIR->ir->CreateFSub(lhs_im, rhs_im, "tmp");
|
||||
else if(lhs_im)
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- gen/cl_helpers.h - Complex number code generation -------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Functions for generating code for D complex number operations.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_COMPLEX_H
|
||||
#define LDC_GEN_COMPLEX_H
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- declarations.cpp --------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
|
||||
#include "aggregate.h"
|
||||
@@ -162,7 +171,7 @@ void VarDeclaration::codegen(Ir* p)
|
||||
#if LDC_LLVM_VER >= 302
|
||||
// FIXME: clang uses a command line option for the thread model
|
||||
LLGlobalVariable* gvar = new LLGlobalVariable(*gIR->module, _type, _isconst,
|
||||
DtoLinkage(this), NULL, _name, 0,
|
||||
DtoLinkage(this), NULL, _name, 0,
|
||||
isThreadlocal() ? LLGlobalVariable::GeneralDynamicTLSModel
|
||||
: LLGlobalVariable::NotThreadLocal);
|
||||
#else
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- dvalue.cpp --------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
|
||||
#include "gen/tollvm.h"
|
||||
|
||||
22
gen/dvalue.h
22
gen/dvalue.h
@@ -1,12 +1,22 @@
|
||||
//===-- gen/dvalue.h - D value abstractions ---------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// These classes are used for generating the IR. They encapsulate an LLVM value
|
||||
// together with a D type and provide an uniform interface for the most common
|
||||
// operations. When more specialize handling is necessary, they hold enough
|
||||
// information to do-the-right-thing (TM).
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_DVALUE_H
|
||||
#define LDC_GEN_DVALUE_H
|
||||
|
||||
/*
|
||||
These classes are used for generating the IR. They encapsulate D values and
|
||||
provide a common interface to the most common operations. When more specialized
|
||||
handling is necessary, they hold enough information to do-the-right-thing (TM)
|
||||
*/
|
||||
|
||||
#include <cassert>
|
||||
#include "root.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- functions.cpp -----------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
#include "llvm/Support/CFG.h"
|
||||
#include "llvm/Intrinsics.h"
|
||||
@@ -268,22 +277,22 @@ LLFunction* DtoInlineIRFunction(FuncDeclaration* fdecl)
|
||||
assert(tinst);
|
||||
|
||||
Objects& objs = tinst->tdtypes;
|
||||
assert(objs.dim == 3);
|
||||
assert(objs.dim == 3);
|
||||
|
||||
Expression* a0 = isExpression(objs[0]);
|
||||
assert(a0);
|
||||
StringExp* strexp = a0->toString();
|
||||
assert(strexp);
|
||||
assert(strexp->sz == 1);
|
||||
std::string code(static_cast<char*>(strexp->string), strexp->len);
|
||||
std::string code(static_cast<char*>(strexp->string), strexp->len);
|
||||
|
||||
Type* ret = isType(objs[1]);
|
||||
assert(ret);
|
||||
|
||||
|
||||
Tuple* a2 = isTuple(objs[2]);
|
||||
assert(a2);
|
||||
Objects& arg_types = a2->objects;
|
||||
|
||||
|
||||
std::string str;
|
||||
llvm::raw_string_ostream stream(str);
|
||||
stream << "define " << *DtoType(ret) << " @" << mangled_name << "(";
|
||||
@@ -294,34 +303,34 @@ LLFunction* DtoInlineIRFunction(FuncDeclaration* fdecl)
|
||||
//assert(ty);
|
||||
if(!ty)
|
||||
{
|
||||
error(tinst->loc,
|
||||
error(tinst->loc,
|
||||
"All parameters of a template defined with pragma llvm_inline_ir, except for the first one, should be types");
|
||||
fatal();
|
||||
}
|
||||
stream << *DtoType(ty);
|
||||
|
||||
|
||||
i++;
|
||||
if(i >= arg_types.dim)
|
||||
break;
|
||||
|
||||
|
||||
stream << ", ";
|
||||
}
|
||||
|
||||
if(ret->ty == Tvoid)
|
||||
code.append("\nret void");
|
||||
|
||||
code.append("\nret void");
|
||||
|
||||
stream << ")\n{\n" << code << "\n}";
|
||||
|
||||
|
||||
llvm::SMDiagnostic err;
|
||||
llvm::ParseAssemblyString(stream.str().c_str(), gIR->module, err, gIR->context());
|
||||
std::string errstr = err.getMessage();
|
||||
if(errstr != "")
|
||||
error(tinst->loc,
|
||||
"can't parse inline LLVM IR:\n%s\n%s\n%s\nThe input string was: \n%s",
|
||||
err.getLineContents().c_str(),
|
||||
(std::string(err.getColumnNo(), ' ') + '^').c_str(),
|
||||
error(tinst->loc,
|
||||
"can't parse inline LLVM IR:\n%s\n%s\n%s\nThe input string was: \n%s",
|
||||
err.getLineContents().c_str(),
|
||||
(std::string(err.getColumnNo(), ' ') + '^').c_str(),
|
||||
errstr.c_str(), stream.str().c_str());
|
||||
|
||||
|
||||
LLFunction* fun = gIR->module->getFunction(mangled_name);
|
||||
fun->setLinkage(llvm::GlobalValue::LinkOnceODRLinkage);
|
||||
#if LDC_LLVM_VER >= 302
|
||||
@@ -580,7 +589,7 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati
|
||||
if (attrs[j].Index == curr.Index) {
|
||||
#if LDC_LLVM_VER >= 302
|
||||
attrs[j].Attrs = llvm::Attributes::get(
|
||||
gIR->context(),
|
||||
gIR->context(),
|
||||
llvm::AttrBuilder(attrs[j].Attrs).addAttributes(curr.Attrs));
|
||||
#else
|
||||
attrs[j].Attrs |= curr.Attrs;
|
||||
@@ -656,7 +665,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
||||
LLFunction* func = vafunc ? vafunc : gIR->module->getFunction(mangled_name);
|
||||
if (!func) {
|
||||
if(fdecl->llvmInternal == LLVMinline_ir)
|
||||
func = DtoInlineIRFunction(fdecl);
|
||||
func = DtoInlineIRFunction(fdecl);
|
||||
else
|
||||
func = LLFunction::Create(functype, DtoLinkage(fdecl), mangled_name, gIR->module);
|
||||
} else if (func->getFunctionType() != functype) {
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- gen/functions.h - D function codegen --------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Code generation for D function types and bodies.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_FUNCTIONS_H
|
||||
#define LDC_GEN_FUNCTIONS_H
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
/* DMDFE backend stubs
|
||||
* This file contains the implementations of the backend routines.
|
||||
* For dmdfe these do nothing but print a message saying the module
|
||||
* has been parsed. Substitute your own behaviors for these routimes.
|
||||
*/
|
||||
//===-- irstate.cpp -------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <cstdarg>
|
||||
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
//===-- gen/irstate.h - Global codegen state --------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains the global state used and modified when generating the
|
||||
// code (i.e. LLVM IR) for a given D module.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_IRSTATE_H
|
||||
#define LDC_GEN_IRSTATE_H
|
||||
|
||||
@@ -58,7 +72,7 @@ struct IRScope
|
||||
|
||||
IRScope();
|
||||
IRScope(llvm::BasicBlock* b, llvm::BasicBlock* e);
|
||||
|
||||
|
||||
const IRScope& operator=(const IRScope& rhs);
|
||||
|
||||
#if DMDV2
|
||||
@@ -75,7 +89,7 @@ struct IRBuilderHelper
|
||||
|
||||
struct IRAsmStmt
|
||||
{
|
||||
IRAsmStmt()
|
||||
IRAsmStmt()
|
||||
: isBranchToLabel(NULL) {}
|
||||
|
||||
std::string code;
|
||||
@@ -188,7 +202,7 @@ struct IRState
|
||||
GatesList sharedGates;
|
||||
#endif
|
||||
FuncDeclList unitTests;
|
||||
|
||||
|
||||
// all template instances that had members emitted
|
||||
// currently only filled for singleobj
|
||||
// used to make sure the complete template instance gets emitted in the
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- linkage.cpp -------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "linkage.h"
|
||||
|
||||
LLGlobalValue::LinkageTypes templateLinkage;
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- gen/linkage.h - Common linkage types --------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Linkage types used for certain constructs (templates, TypeInfo).
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_LINKAGE_H
|
||||
#define LDC_GEN_LINKAGE_H
|
||||
|
||||
|
||||
17
gen/llvm.h
17
gen/llvm.h
@@ -1,3 +1,20 @@
|
||||
//===-- gen/llvm.h - Common LLVM includes and aliases -----------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Pulls in commonly used LLVM headers and provides shorthands for some LLVM
|
||||
// types.
|
||||
//
|
||||
// TODO: Consider removing this file; the aliases mostly make code more
|
||||
// cumbersome to read for people familiar with LLVM anyway.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef GEN_LLVM_H
|
||||
#define GEN_LLVM_H
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
//===-- llvmcompat.cpp ----------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvmcompat.h"
|
||||
#include "llvm/Config/llvm-config.h"
|
||||
@@ -85,7 +93,7 @@ Triple llvm::Triple__get64BitArchVariant(const std::string& triple) {
|
||||
return T;
|
||||
}
|
||||
|
||||
static void appendToGlobalArray(const char *Array,
|
||||
static void appendToGlobalArray(const char *Array,
|
||||
Module &M, Function *F, int Priority) {
|
||||
IRBuilder<> IRB(M.getContext());
|
||||
FunctionType *FnTy = FunctionType::get(IRB.getVoidTy(), false);
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
//===-- gen/llvmcompat.h - LLVM API compatibilty shims ----------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Provides a central place to handle API changes between supported LLVM
|
||||
// versions.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- llvmhelpers.cpp ---------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvmhelpers.h"
|
||||
#include "gen/llvm.h"
|
||||
|
||||
@@ -843,7 +852,7 @@ DValue* DtoCast(Loc& loc, DValue* val, Type* to)
|
||||
if (fromtype->ty == Tvector) {
|
||||
return DtoCastVector(loc, val, to);
|
||||
}
|
||||
else
|
||||
else
|
||||
#endif
|
||||
if (fromtype->isintegral()) {
|
||||
return DtoCastInt(loc, val, to);
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
//===-- gen/llvmhelpers.h - General LLVM codegen helpers --------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// General codegen helper constructs.
|
||||
//
|
||||
// TODO: Merge with gen/tollvm.h, then refactor into sensible parts.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_LLVMHELPERS_H
|
||||
#define LDC_GEN_LLVMHELPERS_H
|
||||
|
||||
@@ -17,7 +32,7 @@ struct EnclosingTryFinally : EnclosingHandler
|
||||
TryFinallyStatement* tf;
|
||||
llvm::BasicBlock* landingPad;
|
||||
void emitCode(IRState* p);
|
||||
EnclosingTryFinally(TryFinallyStatement* _tf, llvm::BasicBlock* _pad)
|
||||
EnclosingTryFinally(TryFinallyStatement* _tf, llvm::BasicBlock* _pad)
|
||||
: tf(_tf), landingPad(_pad) {}
|
||||
};
|
||||
struct EnclosingVolatile : EnclosingHandler
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- logger.cpp --------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
|
||||
14
gen/logger.h
14
gen/logger.h
@@ -1,3 +1,17 @@
|
||||
//===-- gen/logger.h - Codegen debug logging --------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Defines a common interface for logging debug information during code
|
||||
// generation.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _llvmd_gen_logger_h_
|
||||
#define _llvmd_gen_logger_h_
|
||||
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- gen/metadata.h - LDC-specific LLVM metadata definitions -*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Defines the types of LLVM metadata used for D-specific optimization passes.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if USE_METADATA
|
||||
|
||||
#ifndef LDC_GEN_METADATA_H
|
||||
@@ -25,9 +38,9 @@ inline MDNodeField* MD_GetElement(llvm::MDNode* N, unsigned i) {
|
||||
/// (Its name will be TD_PREFIX ~ <Name of TypeInfo global>)
|
||||
enum TypeDataFields {
|
||||
TD_Confirm, /// The TypeInfo this node is for.
|
||||
|
||||
|
||||
TD_Type, /// A value of the LLVM type corresponding to this D type
|
||||
|
||||
|
||||
// Must be kept last:
|
||||
TD_NumFields /// The number of fields in TypeInfo metadata
|
||||
};
|
||||
@@ -42,7 +55,7 @@ enum ClassDataFields {
|
||||
CD_BodyType, /// A value of the LLVM type corresponding to the class body.
|
||||
CD_Finalize, /// True if this class (or a base class) has a destructor.
|
||||
CD_CustomDelete,/// True if this class has an overridden delete operator.
|
||||
|
||||
|
||||
// Must be kept last
|
||||
CD_NumFields /// The number of fields in ClassInfo metadata
|
||||
};
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- module.cpp --------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Module.h"
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- naked.cpp ---------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
#include "llvm/InlineAsm.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- nested.cpp --------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/nested.h"
|
||||
|
||||
#include "gen/dvalue.h"
|
||||
|
||||
14
gen/nested.h
14
gen/nested.h
@@ -1,3 +1,17 @@
|
||||
//===-- gen/nested.h - Nested context handling ------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Functions for creating nested contexts for nested D types/functions and
|
||||
// extracting the values from them.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_NESTED_H
|
||||
#define LDC_GEN_NESTED_H
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- optimizer.cpp -----------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/optimizer.h"
|
||||
#include "gen/cl_helpers.h"
|
||||
#include "gen/logger.h"
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
//===-- gen/optimizer.h - LLVM IR optimization ------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Handles the optimization of the generated LLVM modules according to the
|
||||
// specified optimization level.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_OPTIMIZER_H
|
||||
#define LDC_GEN_OPTIMIZER_H
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#if USE_METADATA
|
||||
|
||||
//===- GarbageCollect2Stack - Optimize calls to the D garbage collector ---===//
|
||||
//===-- GarbageCollect2Stack.cpp - Promote or remove GC allocations -------===//
|
||||
//
|
||||
// The LLVM D Compiler
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
@@ -52,7 +52,7 @@ namespace {
|
||||
const Module& M;
|
||||
CallGraph* CG;
|
||||
CallGraphNode* CGNode;
|
||||
|
||||
|
||||
const Type* getTypeFor(Value* typeinfo) const;
|
||||
};
|
||||
}
|
||||
@@ -64,14 +64,14 @@ namespace {
|
||||
void EmitMemSet(IRBuilder<>& B, Value* Dst, Value* Val, Value* Len,
|
||||
const Analysis& A) {
|
||||
Dst = B.CreateBitCast(Dst, PointerType::getUnqual(B.getInt8Ty()));
|
||||
|
||||
|
||||
Module *M = B.GetInsertBlock()->getParent()->getParent();
|
||||
const Type* intTy = Len->getType();
|
||||
const Type *VoidPtrTy = PointerType::getUnqual(B.getInt8Ty());
|
||||
const Type *Tys[2] ={VoidPtrTy, intTy};
|
||||
Function *MemSet = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2);
|
||||
Value *Align = ConstantInt::get(B.getInt32Ty(), 1);
|
||||
|
||||
|
||||
CallSite CS = B.CreateCall5(MemSet, Dst, Val, Len, Align, B.getFalse());
|
||||
if (A.CGNode)
|
||||
A.CGNode->addCalledFunction(CS, A.CG->getOrInsertFunction(MemSet));
|
||||
@@ -91,11 +91,11 @@ namespace {
|
||||
class FunctionInfo {
|
||||
protected:
|
||||
const Type* Ty;
|
||||
|
||||
|
||||
public:
|
||||
unsigned TypeInfoArgNr;
|
||||
bool SafeToDelete;
|
||||
|
||||
|
||||
// Analyze the current call, filling in some fields. Returns true if
|
||||
// this is an allocation we can stack-allocate.
|
||||
virtual bool analyze(CallSite CS, const Analysis& A) {
|
||||
@@ -103,25 +103,25 @@ namespace {
|
||||
Ty = A.getTypeFor(TypeInfo);
|
||||
return (Ty != NULL);
|
||||
}
|
||||
|
||||
|
||||
// Returns the alloca to replace this call.
|
||||
// It will always be inserted before the call.
|
||||
virtual AllocaInst* promote(CallSite CS, IRBuilder<>& B, const Analysis& A) {
|
||||
NumGcToStack++;
|
||||
|
||||
|
||||
Instruction* Begin = CS.getCaller()->getEntryBlock().begin();
|
||||
return new AllocaInst(Ty, ".nongc_mem", Begin); // FIXME: align?
|
||||
}
|
||||
|
||||
|
||||
FunctionInfo(unsigned typeInfoArgNr, bool safeToDelete)
|
||||
: TypeInfoArgNr(typeInfoArgNr), SafeToDelete(safeToDelete) {}
|
||||
};
|
||||
|
||||
|
||||
class ArrayFI : public FunctionInfo {
|
||||
Value* arrSize;
|
||||
int ArrSizeArgNr;
|
||||
bool Initialized;
|
||||
|
||||
|
||||
public:
|
||||
ArrayFI(unsigned tiArgNr, bool safeToDelete, bool initialized,
|
||||
unsigned arrSizeArgNr)
|
||||
@@ -129,11 +129,11 @@ namespace {
|
||||
ArrSizeArgNr(arrSizeArgNr),
|
||||
Initialized(initialized)
|
||||
{}
|
||||
|
||||
|
||||
virtual bool analyze(CallSite CS, const Analysis& A) {
|
||||
if (!FunctionInfo::analyze(CS, A))
|
||||
return false;
|
||||
|
||||
|
||||
arrSize = CS.getArgument(ArrSizeArgNr);
|
||||
const IntegerType* SizeType =
|
||||
dyn_cast<IntegerType>(arrSize->getType());
|
||||
@@ -158,7 +158,7 @@ namespace {
|
||||
Ty = PtrTy->getElementType();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual AllocaInst* promote(CallSite CS, IRBuilder<>& B, const Analysis& A) {
|
||||
IRBuilder<> Builder = B;
|
||||
// If the allocation is of constant size it's best to put it in the
|
||||
@@ -174,11 +174,11 @@ namespace {
|
||||
} else {
|
||||
NumToDynSize++;
|
||||
}
|
||||
|
||||
|
||||
// Convert array size to 32 bits if necessary
|
||||
Value* count = Builder.CreateIntCast(arrSize, Builder.getInt32Ty(), false);
|
||||
AllocaInst* alloca = Builder.CreateAlloca(Ty, count, ".nongc_mem"); // FIXME: align?
|
||||
|
||||
|
||||
if (Initialized) {
|
||||
// For now, only zero-init is supported.
|
||||
uint64_t size = A.TD.getTypeStoreSize(Ty);
|
||||
@@ -188,11 +188,11 @@ namespace {
|
||||
Value* Size = B.CreateMul(TypeSize, arrSize);
|
||||
EmitMemZero(B, alloca, Size, A);
|
||||
}
|
||||
|
||||
|
||||
return alloca;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// FunctionInfo for _d_allocclass
|
||||
class AllocClassFI : public FunctionInfo {
|
||||
public:
|
||||
@@ -226,17 +226,17 @@ namespace {
|
||||
Constant* hasCustomDelete = dyn_cast<Constant>(MD_GetElement(node, CD_CustomDelete));
|
||||
if (hasDestructor == NULL || hasCustomDelete == NULL)
|
||||
return false;
|
||||
|
||||
|
||||
if (ConstantExpr::getOr(hasDestructor, hasCustomDelete)
|
||||
!= ConstantInt::getFalse(A.M.getContext()))
|
||||
return false;
|
||||
|
||||
|
||||
Ty = MD_GetElement(node, CD_BodyType)->getType();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// The default promote() should be fine.
|
||||
|
||||
|
||||
AllocClassFI() : FunctionInfo(~0u, true) {}
|
||||
};
|
||||
}
|
||||
@@ -252,27 +252,27 @@ namespace {
|
||||
class LLVM_LIBRARY_VISIBILITY GarbageCollect2Stack : public FunctionPass {
|
||||
StringMap<FunctionInfo*> KnownFunctions;
|
||||
Module* M;
|
||||
|
||||
|
||||
FunctionInfo AllocMemoryT;
|
||||
ArrayFI NewArrayVT;
|
||||
ArrayFI NewArrayT;
|
||||
AllocClassFI AllocClass;
|
||||
|
||||
|
||||
public:
|
||||
static char ID; // Pass identification
|
||||
GarbageCollect2Stack();
|
||||
|
||||
|
||||
bool doInitialization(Module &M) {
|
||||
this->M = &M;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool runOnFunction(Function &F);
|
||||
|
||||
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired<TargetData>();
|
||||
AU.addRequired<DominatorTree>();
|
||||
|
||||
|
||||
AU.addPreserved<CallGraph>();
|
||||
AU.addPreserved<DominatorTree>();
|
||||
}
|
||||
@@ -285,7 +285,7 @@ X("dgc2stack", "Promote (GC'ed) heap allocations to stack");
|
||||
|
||||
// Public interface to the pass.
|
||||
FunctionPass *createGarbageCollect2Stack() {
|
||||
return new GarbageCollect2Stack();
|
||||
return new GarbageCollect2Stack();
|
||||
}
|
||||
|
||||
GarbageCollect2Stack::GarbageCollect2Stack()
|
||||
@@ -305,7 +305,7 @@ static void RemoveCall(CallSite CS, const Analysis& A) {
|
||||
InvokeInst* Invoke = cast<InvokeInst>(CS.getInstruction());
|
||||
// If this was an invoke instruction, we need to do some extra
|
||||
// work to preserve the control flow.
|
||||
|
||||
|
||||
// Create a "conditional" branch that -simplifycfg can clean up, so we
|
||||
// can keep using the DominatorTree without updating it.
|
||||
BranchInst::Create(Invoke->getNormalDest(), Invoke->getUnwindDest(),
|
||||
@@ -323,18 +323,18 @@ static bool isSafeToStackAllocate(Instruction* Alloc, DominatorTree& DT);
|
||||
///
|
||||
bool GarbageCollect2Stack::runOnFunction(Function &F) {
|
||||
DEBUG(errs() << "\nRunning -dgc2stack on function " << F.getName() << '\n');
|
||||
|
||||
|
||||
TargetData& TD = getAnalysis<TargetData>();
|
||||
DominatorTree& DT = getAnalysis<DominatorTree>();
|
||||
CallGraph* CG = getAnalysisIfAvailable<CallGraph>();
|
||||
CallGraphNode* CGNode = CG ? (*CG)[&F] : NULL;
|
||||
|
||||
|
||||
Analysis A = { TD, *M, CG, CGNode };
|
||||
|
||||
|
||||
BasicBlock& Entry = F.getEntryBlock();
|
||||
|
||||
|
||||
IRBuilder<> AllocaBuilder(&Entry, Entry.begin());
|
||||
|
||||
|
||||
bool Changed = false;
|
||||
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
|
||||
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ) {
|
||||
@@ -343,53 +343,53 @@ bool GarbageCollect2Stack::runOnFunction(Function &F) {
|
||||
CallSite CS = CallSite::get(Inst);
|
||||
if (!CS.getInstruction())
|
||||
continue;
|
||||
|
||||
|
||||
// Ignore indirect calls and calls to non-external functions.
|
||||
Function *Callee = CS.getCalledFunction();
|
||||
if (Callee == 0 || !Callee->isDeclaration() ||
|
||||
!(Callee->hasExternalLinkage() || Callee->hasDLLImportLinkage()))
|
||||
continue;
|
||||
|
||||
|
||||
// Ignore unknown calls.
|
||||
StringMap<FunctionInfo*>::iterator OMI =
|
||||
KnownFunctions.find(Callee->getName());
|
||||
if (OMI == KnownFunctions.end()) continue;
|
||||
|
||||
|
||||
assert(isa<PointerType>(Inst->getType())
|
||||
&& "GC function doesn't return a pointer?");
|
||||
|
||||
|
||||
FunctionInfo* info = OMI->getValue();
|
||||
|
||||
|
||||
if (Inst->use_empty() && info->SafeToDelete) {
|
||||
Changed = true;
|
||||
NumDeleted++;
|
||||
RemoveCall(CS, A);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
DEBUG(errs() << "GarbageCollect2Stack inspecting: " << *Inst);
|
||||
|
||||
|
||||
if (!info->analyze(CS, A) || !isSafeToStackAllocate(Inst, DT))
|
||||
continue;
|
||||
|
||||
|
||||
// Let's alloca this!
|
||||
Changed = true;
|
||||
|
||||
|
||||
IRBuilder<> Builder(BB, Inst);
|
||||
Value* newVal = info->promote(CS, Builder, A);
|
||||
|
||||
|
||||
DEBUG(errs() << "Promoted to: " << *newVal);
|
||||
|
||||
|
||||
// Make sure the type is the same as it was before, and replace all
|
||||
// uses of the runtime call with the alloca.
|
||||
if (newVal->getType() != Inst->getType())
|
||||
newVal = Builder.CreateBitCast(newVal, Inst->getType());
|
||||
Inst->replaceAllUsesWith(newVal);
|
||||
|
||||
|
||||
RemoveCall(CS, A);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Changed;
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ const Type* Analysis::getTypeFor(Value* typeinfo) const {
|
||||
GlobalVariable* ti_global = dyn_cast<GlobalVariable>(typeinfo->stripPointerCasts());
|
||||
if (!ti_global)
|
||||
return NULL;
|
||||
|
||||
|
||||
std::string metaname = TD_PREFIX;
|
||||
metaname += ti_global->getName();
|
||||
|
||||
@@ -414,7 +414,7 @@ const Type* Analysis::getTypeFor(Value* typeinfo) const {
|
||||
if (TD_Confirm >= 0 && (!MD_GetElement(node, TD_Confirm) ||
|
||||
MD_GetElement(node, TD_Confirm)->stripPointerCasts() != ti_global))
|
||||
return NULL;
|
||||
|
||||
|
||||
return MD_GetElement(node, TD_Type)->getType();
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ const Type* Analysis::getTypeFor(Value* typeinfo) const {
|
||||
/// (without executing Def again).
|
||||
static bool mayBeUsedAfterRealloc(Instruction* Def, Instruction* Alloc, DominatorTree& DT) {
|
||||
DEBUG(errs() << "### mayBeUsedAfterRealloc()\n" << *Def << *Alloc);
|
||||
|
||||
|
||||
// If the definition isn't used it obviously won't be used after the
|
||||
// allocation.
|
||||
// If it does not dominate the allocation, there's no way for it to be used
|
||||
@@ -432,12 +432,12 @@ static bool mayBeUsedAfterRealloc(Instruction* Def, Instruction* Alloc, Dominato
|
||||
DEBUG(errs() << "### No uses or does not dominate allocation\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
DEBUG(errs() << "### Def dominates Alloc\n");
|
||||
|
||||
|
||||
BasicBlock* DefBlock = Def->getParent();
|
||||
BasicBlock* AllocBlock = Alloc->getParent();
|
||||
|
||||
|
||||
// Create a set of users and one of blocks containing users.
|
||||
SmallSet<User*, 16> Users;
|
||||
SmallSet<BasicBlock*, 16> UserBlocks;
|
||||
@@ -446,7 +446,7 @@ static bool mayBeUsedAfterRealloc(Instruction* Def, Instruction* Alloc, Dominato
|
||||
Instruction* User = cast<Instruction>(*UI);
|
||||
DEBUG(errs() << "USER: " << *User);
|
||||
BasicBlock* UserBlock = User->getParent();
|
||||
|
||||
|
||||
// This dominance check is not performed if they're in the same block
|
||||
// because it will just walk the instruction list to figure it out.
|
||||
// We will instead do that ourselves in the first iteration (for all
|
||||
@@ -457,34 +457,34 @@ static bool mayBeUsedAfterRealloc(Instruction* Def, Instruction* Alloc, Dominato
|
||||
DEBUG(errs() << "### Alloc dominates user " << *User);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Phi nodes are checked separately, so no need to enter them here.
|
||||
if (!isa<PHINode>(User)) {
|
||||
Users.insert(User);
|
||||
UserBlocks.insert(UserBlock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Contains first instruction of block to inspect.
|
||||
typedef std::pair<BasicBlock*, BasicBlock::iterator> StartPoint;
|
||||
SmallVector<StartPoint, 16> Worklist;
|
||||
// Keeps track of successors that have been added to the work list.
|
||||
SmallSet<BasicBlock*, 16> Visited;
|
||||
|
||||
|
||||
// Start just after the allocation.
|
||||
// Note that we don't insert AllocBlock into the Visited set here so the
|
||||
// start of the block will get inspected if it's reachable.
|
||||
BasicBlock::iterator Start = Alloc;
|
||||
++Start;
|
||||
Worklist.push_back(StartPoint(AllocBlock, Start));
|
||||
|
||||
|
||||
while (!Worklist.empty()) {
|
||||
StartPoint sp = Worklist.pop_back_val();
|
||||
BasicBlock* B = sp.first;
|
||||
BasicBlock::iterator BBI = sp.second;
|
||||
// BBI is either just after the allocation (in the first iteration)
|
||||
// or just after the last phi node in B (in subsequent iterations) here.
|
||||
|
||||
|
||||
// This whole 'if' is just a way to avoid performing the inner 'for'
|
||||
// loop when it can be determined not to be necessary, avoiding
|
||||
// potentially expensive walks of the instruction list.
|
||||
@@ -517,7 +517,7 @@ static bool mayBeUsedAfterRealloc(Instruction* Def, Instruction* Alloc, Dominato
|
||||
// No users and no definition or allocation after the start point,
|
||||
// so just keep going.
|
||||
}
|
||||
|
||||
|
||||
// All instructions after the starting point in this block have been
|
||||
// accounted for. Look for successors to add to the work list.
|
||||
TerminatorInst* Term = B->getTerminator();
|
||||
@@ -555,32 +555,32 @@ static bool mayBeUsedAfterRealloc(Instruction* Def, Instruction* Alloc, Dominato
|
||||
/// escape from the function and no derived pointers are live at the call site
|
||||
/// (i.e. if it's in a loop then the function can't use any pointer returned
|
||||
/// from an earlier call after a new call has been made)
|
||||
///
|
||||
///
|
||||
/// This is currently conservative where loops are involved: it can handle
|
||||
/// simple loops, but returns false if any derived pointer is used in a
|
||||
/// subsequent iteration.
|
||||
///
|
||||
///
|
||||
/// Based on LLVM's PointerMayBeCaptured(), which only does escape analysis but
|
||||
/// doesn't care about loops.
|
||||
bool isSafeToStackAllocate(Instruction* Alloc, DominatorTree& DT) {
|
||||
assert(isa<PointerType>(Alloc->getType()) && "Allocation is not a pointer?");
|
||||
Value* V = Alloc;
|
||||
|
||||
|
||||
SmallVector<Use*, 16> Worklist;
|
||||
SmallSet<Use*, 16> Visited;
|
||||
|
||||
|
||||
for (Value::use_iterator UI = V->use_begin(), UE = V->use_end();
|
||||
UI != UE; ++UI) {
|
||||
Use *U = &UI.getUse();
|
||||
Visited.insert(U);
|
||||
Worklist.push_back(U);
|
||||
}
|
||||
|
||||
|
||||
while (!Worklist.empty()) {
|
||||
Use *U = Worklist.pop_back_val();
|
||||
Instruction *I = cast<Instruction>(U->getUser());
|
||||
V = U->get();
|
||||
|
||||
|
||||
switch (I->getOpcode()) {
|
||||
case Instruction::Call:
|
||||
case Instruction::Invoke: {
|
||||
@@ -591,7 +591,7 @@ bool isSafeToStackAllocate(Instruction* Alloc, DominatorTree& DT) {
|
||||
if (CS.onlyReadsMemory() && CS.doesNotThrow() &&
|
||||
I->getType() == Type::getVoidTy(I->getContext()))
|
||||
break;
|
||||
|
||||
|
||||
// Not captured if only passed via 'nocapture' arguments. Note that
|
||||
// calling a function pointer does not in itself cause the pointer to
|
||||
// be captured. This is a subtle point considering that (for example)
|
||||
@@ -628,7 +628,7 @@ bool isSafeToStackAllocate(Instruction* Alloc, DominatorTree& DT) {
|
||||
// the original allocation.
|
||||
if (mayBeUsedAfterRealloc(I, Alloc, DT))
|
||||
return false;
|
||||
|
||||
|
||||
// The original value is not captured via this if the new value isn't.
|
||||
for (Instruction::use_iterator UI = I->use_begin(), UE = I->use_end();
|
||||
UI != UE; ++UI) {
|
||||
@@ -642,7 +642,7 @@ bool isSafeToStackAllocate(Instruction* Alloc, DominatorTree& DT) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// All uses examined - not captured or live across original allocation.
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- gen/passes/Passes.h - LDC-specific LLVM passes ----------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Functions for creating the LDC-specific LLVM optimizer passes.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_PASSES_H
|
||||
#define LDC_PASSES_H
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//===- SimplifyDRuntimeCalls - Optimize calls to the D runtime library ----===//
|
||||
//===-- SimplifyDRuntimeCalls.cpp - Optimize druntime calls ---------------===//
|
||||
//
|
||||
// The LLVM D Compiler
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
// License. See the LICENSE file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//===-- StripExternals.cpp - Strip available_externally symbols -----------===//
|
||||
//
|
||||
// The LLVM D Compiler
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- pragma.cpp --------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "pragma.h"
|
||||
#include "attrib.h"
|
||||
#include "id.h"
|
||||
|
||||
13
gen/pragma.h
13
gen/pragma.h
@@ -1,3 +1,16 @@
|
||||
//===-- gen/pragma.h - LDC-specific pragma handling -------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Code for handling the LDC-specific pragmas.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef PRAGMA_H
|
||||
#define PRAGMA_H
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- programs.cpp ------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/programs.h"
|
||||
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- gen/programs.h - External tool discovery ----------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Functions for discovering the external tools used for linking, etc.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_PROGRAMS_H
|
||||
#define LDC_GEN_PROGRAMS_H
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- rttibuilder.cpp ---------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
|
||||
#include "aggregate.h"
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
//===-- gen/rttibuilder.h - TypeInfo generation helper ----------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This class is used to build the global TypeInfo/ClassInfo/... constants
|
||||
// required for the D runtime type information system.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef __LDC_GEN_RTTIBUILDER_H__
|
||||
#define __LDC_GEN_RTTIBUILDER_H__
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- runtime.cpp -------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Attributes.h"
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- gen/runtime.h - D runtime function handlers -------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Code for handling the compiler support functions from the D runtime library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_RUNTIME_H_
|
||||
#define LDC_GEN_RUNTIME_H_
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
// Statements: D -> LLVM glue
|
||||
//===-- statements.cpp ----------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- structs.cpp -------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "gen/llvm.h"
|
||||
@@ -178,7 +187,7 @@ std::vector<llvm::Value*> DtoStructLiteralValues(const StructDeclaration* sd,
|
||||
const std::vector<llvm::Value*>& inits,
|
||||
bool isConst)
|
||||
{
|
||||
// get arrays
|
||||
// get arrays
|
||||
size_t nvars = sd->fields.dim;
|
||||
VarDeclaration** vars = (VarDeclaration**)sd->fields.data;
|
||||
|
||||
@@ -338,7 +347,7 @@ std::vector<llvm::Value*> DtoStructLiteralValues(const StructDeclaration* sd,
|
||||
/// Union types will get expanded into a struct, with a type for each member.
|
||||
LLType* DtoUnpaddedStructType(Type* dty) {
|
||||
assert(dty->ty == Tstruct);
|
||||
|
||||
|
||||
typedef llvm::DenseMap<Type*, llvm::StructType*> CacheT;
|
||||
static llvm::ManagedStatic<CacheT> cache;
|
||||
CacheT::iterator it = cache->find(dty);
|
||||
@@ -374,9 +383,9 @@ LLValue* DtoUnpaddedStruct(Type* dty, LLValue* v) {
|
||||
assert(dty->ty == Tstruct);
|
||||
TypeStruct* sty = static_cast<TypeStruct*>(dty);
|
||||
Array& fields = sty->sym->fields;
|
||||
|
||||
|
||||
LLValue* newval = llvm::UndefValue::get(DtoUnpaddedStructType(dty));
|
||||
|
||||
|
||||
for (unsigned i = 0; i < fields.dim; i++) {
|
||||
VarDeclaration* vd = static_cast<VarDeclaration*>(fields.data[i]);
|
||||
LLValue* fieldptr = DtoIndexStruct(v, sty->sym, vd);
|
||||
@@ -397,7 +406,7 @@ void DtoPaddedStruct(Type* dty, LLValue* v, LLValue* lval) {
|
||||
assert(dty->ty == Tstruct);
|
||||
TypeStruct* sty = static_cast<TypeStruct*>(dty);
|
||||
Array& fields = sty->sym->fields;
|
||||
|
||||
|
||||
for (unsigned i = 0; i < fields.dim; i++) {
|
||||
VarDeclaration* vd = static_cast<VarDeclaration*>(fields.data[i]);
|
||||
LLValue* fieldptr = DtoIndexStruct(lval, sty->sym, vd);
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- gen/structs.h - D struct codegen ------------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Functions for D struct codegen.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVMD_GEN_STRUCTS_H
|
||||
#define LLVMD_GEN_STRUCTS_H
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- tocall.cpp --------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
|
||||
#include "mtype.h"
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- todebug.cpp -------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||
#include "llvm/Support/Dwarf.h"
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- gen/todebug.h - Symbolic debug information generation ---*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Handles generation of symbolic debug information using LLVM's DWARF support.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_TODEBUG_H
|
||||
#define LDC_GEN_TODEBUG_H
|
||||
|
||||
|
||||
15
gen/toir.cpp
15
gen/toir.cpp
@@ -1,10 +1,11 @@
|
||||
// Backend stubs
|
||||
|
||||
/* DMDFE backend stubs
|
||||
* This file contains the implementations of the backend routines.
|
||||
* For dmdfe these do nothing but print a message saying the module
|
||||
* has been parsed. Substitute your own behaviors for these routimes.
|
||||
*/
|
||||
//===-- toir.cpp ----------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
//===-- tollvm.cpp --------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
|
||||
|
||||
15
gen/tollvm.h
15
gen/tollvm.h
@@ -1,3 +1,18 @@
|
||||
//===-- gen/tollvm.h - General LLVM codegen helpers -------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// General codegen helper constructs.
|
||||
//
|
||||
// TODO: Merge with gen/llvmhelpers.h, then refactor into sensible parts.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_TOLLVM_H
|
||||
#define LDC_GEN_TOLLVM_H
|
||||
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
//===-- gen/typinf.h - TypeInfo declaration codegen -------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Codegen for the TypeInfo types/constants required by the D run-time type
|
||||
// information system.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_TYPEINF_H
|
||||
#define LDC_GEN_TYPEINF_H
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
|
||||
//===-- typinf.cpp --------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file mostly consists of code under the BSD-style LDC license, but some
|
||||
// parts have been derived from DMD as noted below. See the LICENSE file for
|
||||
// details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Copyright (c) 1999-2004 by Digital Mars
|
||||
// All Rights Reserved
|
||||
|
||||
13
gen/utils.h
13
gen/utils.h
@@ -1,3 +1,16 @@
|
||||
//===-- gen/utils.h - Utilities for handling frontend types -----*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Some utilities for handling front-end types in a more C++-like fashion.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef __LDC_GEN_UTILS_H__
|
||||
#define __LDC_GEN_UTILS_H__
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- warnings.cpp ------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mars.h"
|
||||
#include "mtype.h"
|
||||
#include "expression.h"
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- gen/warnings.h - LDC-specific warning handling ----------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Functionality for emitting additional warnings during codegen.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef __LDC_GEN_WARNINGS_H__
|
||||
#define __LDC_GEN_WARNINGS_H__
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- ir.cpp ------------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#if LDC_LLVM_VER >= 302
|
||||
#include "llvm/DataLayout.h"
|
||||
#else
|
||||
|
||||
15
ir/ir.h
15
ir/ir.h
@@ -1,4 +1,17 @@
|
||||
// this head contains stuff used by all the IR
|
||||
//===-- ir/ir.h - Base definitions for codegen metadata ---------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Declares the base class for all codegen info classes and the top-level Ir
|
||||
// class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#ifndef LDC_IR_IR_H
|
||||
#define LDC_IR_IR_H
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- irclass.cpp -------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- irdsymbol.cpp -----------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
#include "ir/ir.h"
|
||||
#include "ir/irdsymbol.h"
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
//===-- ir/irdsymbol.h - Codegen state for D symbols ------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Represents the status of a D symbol on its way though the codegen process.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_IR_IRDSYMBOL_H
|
||||
#define LDC_IR_IRDSYMBOL_H
|
||||
|
||||
|
||||
14
ir/irforw.h
14
ir/irforw.h
@@ -1,3 +1,17 @@
|
||||
//===-- ir/irforw.h - Forward declarations used in ir/ code ----*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Some common forward declarations for use in ir/ headers.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#ifndef LDC_IR_IRFORW_H
|
||||
#define LDC_IR_IRFORW_H
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
//===-- irfunction.cpp ----------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
#include "gen/tollvm.h"
|
||||
@@ -150,7 +158,7 @@ IrFunction::IrFunction(FuncDeclaration* fd)
|
||||
frameType = NULL;
|
||||
depth = -1;
|
||||
nestedContextCreated = false;
|
||||
|
||||
|
||||
_arguments = NULL;
|
||||
_argptr = NULL;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
//===-- ir/irfunction.h - Codegen state for D functions ---------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Represents the status of a D function/method/... on its way through the
|
||||
// codegen process.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#ifndef LDC_IR_IRFUNCTION_H
|
||||
#define LDC_IR_IRFUNCTION_H
|
||||
|
||||
@@ -18,10 +33,10 @@ struct IRTargetScope
|
||||
{
|
||||
// generating statement
|
||||
Statement* s;
|
||||
|
||||
|
||||
// the try of a TryFinally that encloses the loop
|
||||
EnclosingHandler* enclosinghandler;
|
||||
|
||||
|
||||
llvm::BasicBlock* breakTarget;
|
||||
llvm::BasicBlock* continueTarget;
|
||||
|
||||
@@ -69,7 +84,7 @@ struct IrFunction : IrBase
|
||||
{
|
||||
// constructor
|
||||
IrFunction(FuncDeclaration* fd);
|
||||
|
||||
|
||||
// annotations
|
||||
void setNeverInline();
|
||||
void setAlwaysInline();
|
||||
@@ -83,21 +98,21 @@ struct IrFunction : IrBase
|
||||
|
||||
bool queued;
|
||||
bool defined;
|
||||
|
||||
|
||||
llvm::Value* retArg; // return in ptr arg
|
||||
llvm::Value* thisArg; // class/struct 'this' arg
|
||||
llvm::Value* nestArg; // nested function 'this' arg
|
||||
|
||||
|
||||
llvm::Value* nestedVar; // nested var alloca
|
||||
llvm::StructType* frameType; // type of nested context (not for -nested-ctx=array)
|
||||
// number of enclosing functions with variables accessed by nested functions
|
||||
// (-1 if neither this function nor any enclosing ones access variables from enclosing functions)
|
||||
int depth;
|
||||
bool nestedContextCreated; // holds whether nested context is created
|
||||
|
||||
|
||||
llvm::Value* _arguments;
|
||||
llvm::Value* _argptr;
|
||||
|
||||
|
||||
llvm::DISubprogram diSubprogram;
|
||||
std::stack<llvm::DILexicalBlock> diLexicalBlocks;
|
||||
};
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
//===-- ir/irfuncty.h - Function type codegen metadata ----------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Additional information attached to a function type during codegen. Handles
|
||||
// LLVM attributes attached to a function and its parameters, etc.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#ifndef LDC_IR_IRFUNCTY_H
|
||||
#define LDC_IR_IRFUNCTY_H
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
//===-- irlandingpad.cpp --------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/llvm.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "gen/irstate.h"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user