Move triples to the Options class
This commit is contained in:
parent
e9012b7583
commit
7fb2125c4b
|
@ -16,7 +16,7 @@ AlignEscapedNewlines: Left
|
||||||
AlwaysBreakTemplateDeclarations: Yes
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
IncludeBlocks: Regroup
|
IncludeBlocks: Regroup
|
||||||
IncludeCategories:
|
IncludeCategories:
|
||||||
- Regex: '^"(serene)/'
|
- Regex: '^"'
|
||||||
Priority: 1
|
Priority: 1
|
||||||
SortPriority: 1
|
SortPriority: 1
|
||||||
CaseSensitive: true
|
CaseSensitive: true
|
||||||
|
|
|
@ -18,12 +18,19 @@ repos:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: mixed-line-ending
|
- id: mixed-line-ending
|
||||||
|
|
||||||
|
# - repo: local
|
||||||
|
# hooks:
|
||||||
|
# - id: include-fixer
|
||||||
|
# name: Fixing 'serene' includes
|
||||||
|
# language: script
|
||||||
|
# entry: ./scripts/include-fixer.sh
|
||||||
|
# files: ".*.(h|cpp)"
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
- id: include-fixer
|
- id: include-fixer py
|
||||||
name: Fixing 'serene' includes
|
name: Fixing local includes
|
||||||
language: script
|
language: python
|
||||||
entry: ./scripts/include-fixer.sh
|
entry: ./scripts/include-fixer.py
|
||||||
files: ".*.(h|cpp)"
|
files: ".*.(h|cpp)"
|
||||||
|
|
||||||
- repo: https://github.com/pocc/pre-commit-hooks
|
- repo: https://github.com/pocc/pre-commit-hooks
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <commands/commands.h>
|
#include "commands/commands.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
|
@ -16,22 +16,36 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <jit/jit.h>
|
#include "jit/jit.h"
|
||||||
#include <system_error> // for error_code
|
|
||||||
|
|
||||||
#include <llvm/ADT/StringMapEntry.h> // for StringMapEntry
|
#include "options.h" // for Options
|
||||||
#include <llvm/ADT/iterator.h> // for iterator_facade_base
|
|
||||||
#include <llvm/ExecutionEngine/JITEventListener.h> // for JITEventListener
|
#include <__type_traits/remove_reference.h> // for remov...
|
||||||
#include <llvm/ExecutionEngine/Orc/LLJIT.h> // IWYU pragma: keep
|
#include <__utility/move.h> // for move
|
||||||
|
#include <system_error> // for error_code
|
||||||
|
|
||||||
|
#include <llvm/ADT/StringMapEntry.h> // for StringMapEntry
|
||||||
|
#include <llvm/ADT/iterator.h> // for iterator_facade_base
|
||||||
|
#include <llvm/ExecutionEngine/JITEventListener.h> // for JITEventListener
|
||||||
|
#include <llvm/ExecutionEngine/Orc/CompileUtils.h> // for TMOwn...
|
||||||
|
#include <llvm/ExecutionEngine/Orc/Core.h> // for JITDy...
|
||||||
|
#include <llvm/ExecutionEngine/Orc/DebugUtils.h> // for opera...
|
||||||
|
#include <llvm/ExecutionEngine/Orc/ExecutionUtils.h> // for Dynam...
|
||||||
|
#include <llvm/ExecutionEngine/Orc/IRCompileLayer.h> // for IRCom...
|
||||||
|
#include <llvm/ExecutionEngine/Orc/LLJIT.h> // IWYU pragma: keep
|
||||||
|
#include <llvm/ExecutionEngine/Orc/Layer.h> // for Objec...
|
||||||
#include <llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h>
|
#include <llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h>
|
||||||
|
#include <llvm/ExecutionEngine/Orc/ThreadSafeModule.h> // for Threa...
|
||||||
#include <llvm/ExecutionEngine/SectionMemoryManager.h>
|
#include <llvm/ExecutionEngine/SectionMemoryManager.h>
|
||||||
|
#include <llvm/IR/DataLayout.h> // for DataL...
|
||||||
|
#include <llvm/IR/LLVMContext.h> // for LLVMC...
|
||||||
#include <llvm/IR/Module.h> // for Module
|
#include <llvm/IR/Module.h> // for Module
|
||||||
#include <llvm/Support/FileSystem.h> // for OpenFlags
|
#include <llvm/Support/FileSystem.h> // for OpenFlags
|
||||||
#include <llvm/Support/ToolOutputFile.h> // for ToolOutputFile
|
#include <llvm/Support/ToolOutputFile.h> // for ToolOutputFile
|
||||||
|
#include <llvm/TargetParser/Triple.h> // for Triple
|
||||||
|
|
||||||
#include <assert.h> // for assert
|
#include <assert.h> // for assert
|
||||||
#include <options.h> // for Options
|
#include <string> // for operator+, char_t...
|
||||||
#include <string> // for operator+, char_t...
|
|
||||||
|
|
||||||
namespace serene::jit {
|
namespace serene::jit {
|
||||||
|
|
||||||
|
@ -213,7 +227,7 @@ MaybeJIT JIT::make(llvm::orc::JITTargetMachineBuilder &&jtmb,
|
||||||
// exported symbol visibility.
|
// exported symbol visibility.
|
||||||
// cf llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
|
// cf llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
|
||||||
// LLJIT::createObjectLinkingLayer
|
// LLJIT::createObjectLinkingLayer
|
||||||
if (jitEngine->hostTriple.isOSBinFormatCOFF()) {
|
if (jitEngine->options->hostTriple.isOSBinFormatCOFF()) {
|
||||||
objectLayer->setOverrideObjectFlagsWithResponsibilityFlags(true);
|
objectLayer->setOverrideObjectFlagsWithResponsibilityFlags(true);
|
||||||
objectLayer->setAutoClaimResponsibilityForObjectSymbols(true);
|
objectLayer->setAutoClaimResponsibilityForObjectSymbols(true);
|
||||||
}
|
}
|
||||||
|
@ -278,4 +292,15 @@ MaybeJIT JIT::make(llvm::orc::JITTargetMachineBuilder &&jtmb,
|
||||||
|
|
||||||
return MaybeJIT(std::move(jitEngine));
|
return MaybeJIT(std::move(jitEngine));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MaybeJIT makeJIT(std::unique_ptr<Options> opts) {
|
||||||
|
llvm::orc::JITTargetMachineBuilder jtmb(opts->hostTriple);
|
||||||
|
auto maybeJIT = JIT::make(std::move(jtmb), std::move(opts));
|
||||||
|
|
||||||
|
if (!maybeJIT) {
|
||||||
|
return maybeJIT.takeError();
|
||||||
|
}
|
||||||
|
|
||||||
|
return maybeJIT;
|
||||||
|
};
|
||||||
} // namespace serene::jit
|
} // namespace serene::jit
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#ifndef JIT_JIT_H
|
#ifndef JIT_JIT_H
|
||||||
#define JIT_JIT_H
|
#define JIT_JIT_H
|
||||||
|
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
#include <__memory/unique_ptr.h>
|
#include <__memory/unique_ptr.h>
|
||||||
|
|
||||||
#include <llvm/ADT/ArrayRef.h>
|
#include <llvm/ADT/ArrayRef.h>
|
||||||
|
@ -43,6 +45,7 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class JITEventListener;
|
class JITEventListener;
|
||||||
|
@ -55,9 +58,6 @@ class JITDylib;
|
||||||
class LLJIT;
|
class LLJIT;
|
||||||
class LLLazyJIT;
|
class LLLazyJIT;
|
||||||
} // namespace llvm::orc
|
} // namespace llvm::orc
|
||||||
namespace serene {
|
|
||||||
struct Options;
|
|
||||||
} // namespace serene
|
|
||||||
|
|
||||||
#define MAIN_PROCESS_JD_NAME "*main*"
|
#define MAIN_PROCESS_JD_NAME "*main*"
|
||||||
#define HALLEY_LOG(...) \
|
#define HALLEY_LOG(...) \
|
||||||
|
@ -130,20 +130,6 @@ class JIT {
|
||||||
llvm::Error createCurrentProcessJD();
|
llvm::Error createCurrentProcessJD();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// We will use this triple to generate code that will endup in the binary
|
|
||||||
// for the target platform. If we're not cross compiling, `targetTriple`
|
|
||||||
// will be the same as `hostTriple`.
|
|
||||||
const llvm::Triple targetTriple;
|
|
||||||
|
|
||||||
// This triple will be used in code generation for the host platform in
|
|
||||||
// complie time. For example any function that will be called during
|
|
||||||
// the compile time has to run on the host. So we need to generate
|
|
||||||
// appropriate code for the host. If the same function has to be part
|
|
||||||
// of the runtime, then we use `targetTriple` again to generate the code
|
|
||||||
// for the target platform. So, we might end up with two version of the
|
|
||||||
// same function
|
|
||||||
const llvm::Triple hostTriple;
|
|
||||||
|
|
||||||
JIT(llvm::orc::JITTargetMachineBuilder &&jtmb, std::unique_ptr<Options> opts);
|
JIT(llvm::orc::JITTargetMachineBuilder &&jtmb, std::unique_ptr<Options> opts);
|
||||||
static MaybeJIT make(llvm::orc::JITTargetMachineBuilder &&jtmb,
|
static MaybeJIT make(llvm::orc::JITTargetMachineBuilder &&jtmb,
|
||||||
std::unique_ptr<Options> opts);
|
std::unique_ptr<Options> opts);
|
||||||
|
@ -177,6 +163,6 @@ public:
|
||||||
llvm::ArrayRef<const char *> getLoadPaths() { return loadPaths; };
|
llvm::ArrayRef<const char *> getLoadPaths() { return loadPaths; };
|
||||||
};
|
};
|
||||||
|
|
||||||
MaybeJIT makeJIT();
|
MaybeJIT makeJIT(std::unique_ptr<Options> opts);
|
||||||
} // namespace serene::jit
|
} // namespace serene::jit
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#ifndef OPTIONS_H
|
#ifndef OPTIONS_H
|
||||||
#define OPTIONS_H
|
#define OPTIONS_H
|
||||||
|
|
||||||
|
#include <llvm/TargetParser/Triple.h> // for Triple
|
||||||
|
|
||||||
namespace serene {
|
namespace serene {
|
||||||
/// This enum describes the different operational phases for the compiler
|
/// This enum describes the different operational phases for the compiler
|
||||||
/// in order. Anything below `NoOptimization` is considered only for debugging
|
/// in order. Anything below `NoOptimization` is considered only for debugging
|
||||||
|
@ -50,6 +52,20 @@ struct Options {
|
||||||
bool JITenablePerfNotificationListener = true;
|
bool JITenablePerfNotificationListener = true;
|
||||||
bool JITLazy = false;
|
bool JITLazy = false;
|
||||||
|
|
||||||
|
// We will use this triple to generate code that will endup in the binary
|
||||||
|
// for the target platform. If we're not cross compiling, `targetTriple`
|
||||||
|
// will be the same as `hostTriple`.
|
||||||
|
const llvm::Triple targetTriple;
|
||||||
|
|
||||||
|
// This triple will be used in code generation for the host platform in
|
||||||
|
// complie time. For example any function that will be called during
|
||||||
|
// the compile time has to run on the host. So we need to generate
|
||||||
|
// appropriate code for the host. If the same function has to be part
|
||||||
|
// of the runtime, then we use `targetTriple` again to generate the code
|
||||||
|
// for the target platform. So, we might end up with two version of the
|
||||||
|
// same function
|
||||||
|
const llvm::Triple hostTriple;
|
||||||
|
|
||||||
CompilationPhase compilationPhase = CompilationPhase::NoOptimization;
|
CompilationPhase compilationPhase = CompilationPhase::NoOptimization;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "serene/config.h" // for SERENE_VERSION
|
|
||||||
|
|
||||||
#include "commands/commands.h" // for cc, run
|
#include "commands/commands.h" // for cc, run
|
||||||
|
#include "serene/config.h" // for SERENE_VERSION
|
||||||
|
//
|
||||||
#include <__fwd/string.h> // for string
|
#include <__fwd/string.h> // for string
|
||||||
|
|
||||||
#include <llvm/ADT/StringRef.h> // for StringRef
|
#include <llvm/ADT/StringRef.h> // for StringRef
|
||||||
|
|
Loading…
Reference in New Issue