clang-format

This commit is contained in:
Ivan 2018-02-15 21:50:46 +03:00
parent c6ec90e8ef
commit 938ac0e4bf
5 changed files with 45 additions and 57 deletions

View file

@ -26,9 +26,7 @@
namespace { namespace {
enum { enum { ApiVersion = LDC_DYNAMIC_COMPILE_API_VERSION };
ApiVersion = LDC_DYNAMIC_COMPILE_API_VERSION
};
const char *DynamicCompileModulesHeadName = "dynamiccompile_modules_head"; const char *DynamicCompileModulesHeadName = "dynamiccompile_modules_head";
@ -577,8 +575,7 @@ llvm::GlobalVariable *generateModuleListElem(IRState *irs, const Types &types,
auto symListInit = generateSymList(irs, types, globalVals); auto symListInit = generateSymList(irs, types, globalVals);
auto varlistInit = generateVarList(irs, types); auto varlistInit = generateVarList(irs, types);
llvm::Constant *fields[] = { llvm::Constant *fields[] = {
llvm::ConstantInt::get(irs->context(), llvm::ConstantInt::get(irs->context(), APInt(32, ApiVersion)), // version
APInt(32, ApiVersion)), // version
llvm::ConstantPointerNull::get(llvm::dyn_cast<llvm::PointerType>( llvm::ConstantPointerNull::get(llvm::dyn_cast<llvm::PointerType>(
elem_type->getElementType(1))), // next elem_type->getElementType(1))), // next
irData->getInitializer(), // irdata irData->getInitializer(), // irdata

View file

@ -186,10 +186,8 @@ public:
llvm::sys::getHostCPUName(), getHostAttrs())), llvm::sys::getHostCPUName(), getHostAttrs())),
dataLayout(targetmachine->createDataLayout()), dataLayout(targetmachine->createDataLayout()),
#if LDC_LLVM_VER >= 700 #if LDC_LLVM_VER >= 700
execSession(stringPool), execSession(stringPool), resolver(createResolver()),
resolver(createResolver()), objectLayer(execSession,
objectLayer(
execSession,
[](llvm::orc::VModuleKey) { [](llvm::orc::VModuleKey) {
return std::make_shared<llvm::SectionMemoryManager>(); return std::make_shared<llvm::SectionMemoryManager>();
}, },
@ -256,14 +254,12 @@ private:
} }
#if LDC_LLVM_VER >= 700 #if LDC_LLVM_VER >= 700
std::shared_ptr<llvm::orc::SymbolResolver> std::shared_ptr<llvm::orc::SymbolResolver> createResolver() {
createResolver() {
return llvm::orc::createLegacyLookupResolver( return llvm::orc::createLegacyLookupResolver(
[this](const std::string &name) -> llvm::JITSymbol { [this](const std::string &name) -> llvm::JITSymbol {
if (auto Sym = compileLayer.findSymbol(name, false)) { if (auto Sym = compileLayer.findSymbol(name, false)) {
return Sym; return Sym;
} } else if (auto Err = Sym.takeError()) {
else if (auto Err = Sym.takeError()) {
return std::move(Err); return std::move(Err);
} }
auto it = symMap.find(name); auto it = symMap.find(name);
@ -277,12 +273,12 @@ private:
} }
return nullptr; return nullptr;
}, },
[](llvm::Error Err) { llvm::cantFail(std::move(Err), [](llvm::Error Err) {
"lookupFlags failed"); }); llvm::cantFail(std::move(Err), "lookupFlags failed");
});
} }
#else #else
std::shared_ptr<llvm::JITSymbolResolver> std::shared_ptr<llvm::JITSymbolResolver> createResolver() {
createResolver() {
// Build our symbol resolver: // Build our symbol resolver:
// Lambda 1: Look back into the JIT itself to find symbols that are part of // Lambda 1: Look back into the JIT itself to find symbols that are part of
// the same "logical dylib". // the same "logical dylib".
@ -381,8 +377,7 @@ struct JitFinaliser final {
template <typename F> template <typename F>
void enumModules(const RtCompileModuleList *modlist_head, void enumModules(const RtCompileModuleList *modlist_head,
const Context& context, const Context &context, F &&fun) {
F &&fun) {
auto current = modlist_head; auto current = modlist_head;
while (current != nullptr) { while (current != nullptr) {
interruptPoint(context, "check version"); interruptPoint(context, "check version");
@ -516,8 +511,8 @@ __declspec(dllexport)
#else #else
__attribute__ ((visibility ("default"))) __attribute__ ((visibility ("default")))
#endif #endif
void JIT_API_ENTRYPOINT(const void *modlist_head, void JIT_API_ENTRYPOINT(const void *modlist_head, const Context *context,
const Context *context, size_t contextSize) { size_t contextSize) {
assert(nullptr != context); assert(nullptr != context);
assert(sizeof(*context) == contextSize); assert(sizeof(*context) == contextSize);
rtCompileProcessImplSoInternal( rtCompileProcessImplSoInternal(

View file

@ -23,15 +23,13 @@ enum class DumpStage : int {
FinalAsm = 3 FinalAsm = 3
}; };
enum { enum { ApiVersion = LDC_DYNAMIC_COMPILE_API_VERSION };
ApiVersion = LDC_DYNAMIC_COMPILE_API_VERSION
};
#define MAKE_JIT_API_CALL_IMPL(prefix, version) prefix##version #define MAKE_JIT_API_CALL_IMPL(prefix, version) prefix##version
#define MAKE_JIT_API_CALL(prefix, version) \ #define MAKE_JIT_API_CALL(prefix, version) \
MAKE_JIT_API_CALL_IMPL(prefix, version) MAKE_JIT_API_CALL_IMPL(prefix, version)
#define JIT_API_ENTRYPOINT MAKE_JIT_API_CALL(rtCompileProcessImplSo, \ #define JIT_API_ENTRYPOINT \
LDC_DYNAMIC_COMPILE_API_VERSION) MAKE_JIT_API_CALL(rtCompileProcessImplSo, LDC_DYNAMIC_COMPILE_API_VERSION)
typedef void (*InterruptPointHandlerT)(void *, const char *action, typedef void (*InterruptPointHandlerT)(void *, const char *action,
const char *object); const char *object);

View file

@ -200,8 +200,7 @@ public:
} }
}; };
void processRelocations(SymTable &symTable, void processRelocations(SymTable &symTable, uint64_t offset,
uint64_t offset,
const llvm::object::ObjectFile &object, const llvm::object::ObjectFile &object,
const llvm::object::SectionRef &sec) { const llvm::object::SectionRef &sec) {
for (const auto &reloc : sec.relocations()) { for (const auto &reloc : sec.relocations()) {
@ -336,8 +335,7 @@ void disassemble(const llvm::TargetMachine &tm,
} }
} }
llvm::ArrayRef<uint8_t> buff( llvm::ArrayRef<uint8_t> buff(
reinterpret_cast<const uint8_t *>(data.data() + offset), reinterpret_cast<const uint8_t *>(data.data() + offset), size);
size);
printFunction(*disasm, *mcia, buff, symTable, *sti, *asmStreamer); printFunction(*disasm, *mcia, buff, symTable, *sti, *asmStreamer);
asmStreamer->EmitRawText(""); asmStreamer->EmitRawText("");

View file

@ -19,8 +19,8 @@ struct Context;
#define MAKE_JIT_API_CALL_IMPL(prefix, version) prefix##version #define MAKE_JIT_API_CALL_IMPL(prefix, version) prefix##version
#define MAKE_JIT_API_CALL(prefix, version) \ #define MAKE_JIT_API_CALL(prefix, version) \
MAKE_JIT_API_CALL_IMPL(prefix, version) MAKE_JIT_API_CALL_IMPL(prefix, version)
#define JIT_API_ENTRYPOINT MAKE_JIT_API_CALL(rtCompileProcessImplSo, \ #define JIT_API_ENTRYPOINT \
LDC_DYNAMIC_COMPILE_API_VERSION) MAKE_JIT_API_CALL(rtCompileProcessImplSo, LDC_DYNAMIC_COMPILE_API_VERSION)
extern "C" { extern "C" {