-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce7a538
commit bd7fddb
Showing
10 changed files
with
206 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
set (SOURCES | ||
LLVMCompatibility.cpp | ||
LLVMCompatibility.h | ||
) | ||
|
||
add_library(LLVMCompatibility OBJECT ${SOURCES}) | ||
set_target_properties(LLVMCompatibility PROPERTIES | ||
COMPILE_FLAGS ${MULL_CXX_FLAGS} | ||
) | ||
target_include_directories(LLVMCompatibility SYSTEM PUBLIC | ||
${LLVM_INCLUDE_DIRS} | ||
) | ||
add_dependencies(LLVMCompatibility ${MULL_LLVM_COMPATIBILITY_LIBRARIES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "LLVMCompatibility.h" | ||
|
||
#include <llvm/Bitcode/BitcodeWriter.h> | ||
#include <llvm/Demangle/Demangle.h> | ||
#include <llvm/IR/DebugInfoMetadata.h> | ||
#include <llvm/IR/DebugLoc.h> | ||
#include <llvm/IR/Module.h> | ||
#include <llvm/Object/ObjectFile.h> | ||
#include <llvm/Target/TargetMachine.h> | ||
|
||
using namespace llvm; | ||
|
||
namespace llvm_compat { | ||
|
||
StringRef getSectionContent(const object::SectionRef §ion) { | ||
Expected<StringRef> content = section.getContents(); | ||
if (!content) { | ||
return {}; | ||
} | ||
return content.get(); | ||
} | ||
|
||
StringRef getSectionName(const object::SectionRef §ion) { | ||
Expected<StringRef> name = section.getName(); | ||
if (!name) { | ||
return {}; | ||
} | ||
return name.get(); | ||
} | ||
|
||
DICompileUnit *getUnit(const DebugLoc &debugLocation) { | ||
DIScope *scope = debugLocation->getScope(); | ||
while (!llvm::isa<llvm::DISubprogram>(scope) && scope != nullptr) { | ||
scope = scope->getScope(); | ||
} | ||
return scope ? llvm::cast<llvm::DISubprogram>(scope)->getUnit() : nullptr; | ||
} | ||
|
||
std::string demangle(const std::string &MangledName) { | ||
return llvm::demangle(MangledName); | ||
} | ||
|
||
llvm::Value *getOrInsertFunction(llvm::Module *module, StringRef name, FunctionType *type) { | ||
return module->getOrInsertFunction(name, type).getCallee(); | ||
} | ||
|
||
void writeBitcodeToFile(const llvm::Module &module, llvm::raw_fd_ostream &stream) { | ||
llvm::WriteBitcodeToFile(module, stream); | ||
} | ||
bool addPassesToEmitObjectFile(TargetMachine *targetMachine, legacy::PassManagerBase &passManager, | ||
raw_pwrite_stream &out) { | ||
return targetMachine->addPassesToEmitFile(passManager, out, nullptr, llvm::CGFT_ObjectFile); | ||
} | ||
} // namespace llvm_compat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
|
||
#include <llvm/ADT/StringRef.h> | ||
|
||
namespace llvm { | ||
|
||
class DICompileUnit; | ||
class DebugLoc; | ||
class TargetMachine; | ||
class FunctionType; | ||
class Value; | ||
class Module; | ||
class raw_pwrite_stream; | ||
class raw_fd_ostream; | ||
|
||
namespace object { | ||
class SectionRef; | ||
} | ||
|
||
namespace legacy { | ||
class PassManagerBase; | ||
} | ||
} // namespace llvm | ||
|
||
namespace llvm_compat { | ||
llvm::StringRef getSectionContent(const llvm::object::SectionRef §ion); | ||
llvm::StringRef getSectionName(const llvm::object::SectionRef §ion); | ||
llvm::DICompileUnit *getUnit(const llvm::DebugLoc &debugLocation); | ||
std::string demangle(const std::string &MangledName); | ||
llvm::Value *getOrInsertFunction(llvm::Module *module, llvm::StringRef name, | ||
llvm::FunctionType *type); | ||
void writeBitcodeToFile(const llvm::Module &module, llvm::raw_fd_ostream &stream); | ||
bool addPassesToEmitObjectFile(llvm::TargetMachine *targetMachine, | ||
llvm::legacy::PassManagerBase &passManager, | ||
llvm::raw_pwrite_stream &out); | ||
} // namespace llvm_compat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule libirm
updated
6 files
+2 −2 | .github/workflows/macos-10.14.yml | |
+1 −1 | .github/workflows/ubuntu-20.04.yaml | |
+0 −2 | CMakeLists.txt | |
+0 −4 | build-system/compilation-flags.cmake | |
+15 −0 | build-system/vendor/llvm.cmake | |
+7 −0 | ci/variables.yaml |