mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 08:30:47 +03:00
License headers and style fixes
This commit is contained in:
parent
e8ba51fb84
commit
abcfc7a451
15 changed files with 192 additions and 30 deletions
3
LICENSE
3
LICENSE
|
@ -23,6 +23,9 @@ Libraries (lib/ and import/ in binary packages):
|
|||
Phobos (runtime/phobos), is distributed under the terms of the Boost
|
||||
Software License. See the individual source files for author information.
|
||||
|
||||
- The jit runtime library is distributed under the terms of the Boost
|
||||
Software License.
|
||||
|
||||
- The profile-rt runtime library (runtime/profile-rt) is a copy of LLVM's
|
||||
compiler-rt/profile library with a small D source addition. It is dual
|
||||
licensed under the University of Illinois Open Source License and under the
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
#include "runtimecompile.h"
|
||||
//===-- runtimecompile.cpp ------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "gen/runtimecompile.h"
|
||||
|
||||
#if defined(LDC_RUNTIME_COMPILE)
|
||||
|
||||
|
@ -797,6 +806,7 @@ void addRuntimeCompiledVar(IRState *irs, IrGlobal *var) {
|
|||
}
|
||||
|
||||
#else // defined(LDC_RUNTIME_COMPILE)
|
||||
|
||||
void generateBitcodeForRuntimeCompile(IRState *) {
|
||||
// nothing
|
||||
}
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
#ifndef RUNTIMECOMPILE_H
|
||||
#define RUNTIMECOMPILE_H
|
||||
//===-- gen/runtimecompile.h - jit support ----------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Jit routines.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LDC_GEN_RUNTIMECOMPILE_H
|
||||
#define LDC_GEN_RUNTIMECOMPILE_H
|
||||
|
||||
struct IRState;
|
||||
struct IrFunction;
|
||||
|
@ -10,4 +23,4 @@ void declareRuntimeCompiledFunction(IRState *irs, IrFunction *func);
|
|||
void defineRuntimeCompiledFunction(IRState *irs, IrFunction *func);
|
||||
void addRuntimeCompiledVar(IRState *irs, IrGlobal *var);
|
||||
|
||||
#endif // RUNTIMECOMPILE_H
|
||||
#endif // LDC_GEN_RUNTIMECOMPILE_H
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
//===-- callback_ostream.cpp ----------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the Boost Software License. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "callback_ostream.h"
|
||||
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
//===-- callback_ostream.h - jit support ------------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the Boost Software License. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Simple llvm::raw_ostream implementation which sink all input to provided
|
||||
// callback. It uses llvm::function_ref so user must ensure callback lifetime.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef CALLBACK_OSTREAM_H
|
||||
#define CALLBACK_OSTREAM_H
|
||||
|
||||
|
@ -9,7 +23,6 @@ class CallbackOstream : public llvm::raw_ostream {
|
|||
CallbackT callback;
|
||||
uint64_t currentPos = 0;
|
||||
|
||||
/// See raw_ostream::write_impl.
|
||||
void write_impl(const char *Ptr, size_t Size) override;
|
||||
|
||||
uint64_t current_pos() const override;
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
//===-- compile.cpp -------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the Boost Software License. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Jit runtime - shared library part.
|
||||
// Defines jit runtime entry point and main compilation routines.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
|
@ -266,33 +279,34 @@ void dumpModule(const Context &context, const llvm::Module &module,
|
|||
}
|
||||
}
|
||||
|
||||
void dumpModuleAsm(const Context &context, const llvm::Module &module,
|
||||
llvm::TargetMachine &TM) {
|
||||
if (nullptr != context.dumpHandler) {
|
||||
auto callback = [&](const char *str, size_t len) {
|
||||
context.dumpHandler(context.dumpHandlerData, DumpStage::FinalAsm, str,
|
||||
len);
|
||||
};
|
||||
// Asm dump is disabled for now
|
||||
// void dumpModuleAsm(const Context &context, const llvm::Module &module,
|
||||
// llvm::TargetMachine &TM) {
|
||||
// if (nullptr != context.dumpHandler) {
|
||||
// auto callback = [&](const char *str, size_t len) {
|
||||
// context.dumpHandler(context.dumpHandlerData, DumpStage::FinalAsm, str,
|
||||
// len);
|
||||
// };
|
||||
|
||||
// TODO: I am not sure if passes added by addPassesToEmitFile can modify
|
||||
// module, so clone source module to be sure, also, it allow preserve
|
||||
// constness
|
||||
auto newModule = llvm::CloneModule(&module);
|
||||
// // TODO: I am not sure if passes added by addPassesToEmitFile can modify
|
||||
// // module, so clone source module to be sure, also, it allow preserve
|
||||
// // constness
|
||||
// auto newModule = llvm::CloneModule(&module);
|
||||
|
||||
llvm::legacy::PassManager PM;
|
||||
// llvm::legacy::PassManager PM;
|
||||
|
||||
llvm::SmallVector<char, 0> asmBufferSV;
|
||||
llvm::raw_svector_ostream asmStream(asmBufferSV);
|
||||
// llvm::SmallVector<char, 0> asmBufferSV;
|
||||
// llvm::raw_svector_ostream asmStream(asmBufferSV);
|
||||
|
||||
if (TM.addPassesToEmitFile(PM, asmStream,
|
||||
llvm::TargetMachine::CGFT_AssemblyFile)) {
|
||||
fatal(context, "Target does not support asm emission.");
|
||||
}
|
||||
PM.run(*newModule);
|
||||
// if (TM.addPassesToEmitFile(PM, asmStream,
|
||||
// llvm::TargetMachine::CGFT_AssemblyFile)) {
|
||||
// fatal(context, "Target does not support asm emission.");
|
||||
// }
|
||||
// PM.run(*newModule);
|
||||
|
||||
callback(asmBufferSV.data(), asmBufferSV.size());
|
||||
}
|
||||
}
|
||||
// callback(asmBufferSV.data(), asmBufferSV.size());
|
||||
// }
|
||||
//}
|
||||
|
||||
void setFunctionsTarget(llvm::Module &module, llvm::TargetMachine &TM) {
|
||||
// Set function target cpu to host if it wasn't set explicitly
|
||||
|
@ -396,7 +410,7 @@ void rtCompileProcessImplSoInternal(const RtCompileModuleList *modlist_head,
|
|||
verifyModule(context, *finalModule);
|
||||
|
||||
dumpModule(context, *finalModule, DumpStage::OptimizedModule);
|
||||
// dumpModuleAsm(context, *finalModule, myJit.getTargetMachine());
|
||||
// dumpModuleAsm(context, *finalModule, myJit.getTargetMachine());
|
||||
|
||||
interruptPoint(context, "Codegen final module");
|
||||
if (myJit.addModule(std::move(finalModule), symMap)) {
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
//===-- context.h - jit support ---------------------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the Boost Software License. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Jit compilation context, must be in sync with runtimecompile.d.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef CONTEXT_H
|
||||
#define CONTEXT_H
|
||||
|
||||
#include <cstddef> //size_t
|
||||
|
||||
// must be synchronized with D source
|
||||
enum class DumpStage : int {
|
||||
OriginalModule = 0,
|
||||
MergedModule = 1,
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
//===-- optimizer.cpp -----------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the Boost Software License. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "optimizer.h"
|
||||
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
//===-- optimizer.h - jit support -------------------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the Boost Software License. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Jit runtime - jit optimizer.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef OPTIMIZER_HPP
|
||||
#define OPTIMIZER_HPP
|
||||
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
//===-- utils.cpp ---------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the Boost Software License. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#include <cassert>
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
//===-- utils.h - jit support -----------------------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the Boost Software License. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Jit runtime - misc routines.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef UTILS_HPP
|
||||
#define UTILS_HPP
|
||||
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
//===-- valueparser.cpp ---------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the Boost Software License. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "valueparser.h"
|
||||
|
||||
#include <cassert>
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
//===-- valueparser.h - jit support -----------------------------*- C++ -*-===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the Boost Software License. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Jit runtime - value parser.
|
||||
// Reads data from host process and generates llvm::Constant suitable
|
||||
// as initializer.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef VALUEPARSER_H
|
||||
#define VALUEPARSER_H
|
||||
|
||||
|
|
|
@ -1,4 +1,18 @@
|
|||
#include <cstddef>
|
||||
//===-- compile.cpp -------------------------------------------------------===//
|
||||
//
|
||||
// LDC – the LLVM D compiler
|
||||
//
|
||||
// This file is distributed under the Boost Software License. See the LICENSE
|
||||
// file for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Jit runtime - executable part.
|
||||
// Defines jit modules list head and and access jit shared library entry point.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <cstddef> // size_t
|
||||
|
||||
struct Context;
|
||||
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/**
|
||||
* Contains jit API.
|
||||
*
|
||||
* Copyright: Authors 2017
|
||||
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
|
||||
*/
|
||||
|
||||
module ldc.runtimecompile;
|
||||
|
||||
version(LDC_RuntimeCompilation):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue