mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
MIR Serialization: Connect the machine function analysis pass to the MIR parser.
This commit connects the machine function analysis pass (which creates machine functions) to the MIR parser, which will initialize the machine functions with the state from the MIR file and reconstruct the machine IR. This commit introduces a new interface called 'MachineFunctionInitializer', which can be used to provide custom initialization for the machine functions. This commit also introduces a new diagnostic class called 'DiagnosticInfoMIRParser' which is used for MIR parsing errors. This commit modifies the default diagnostic handling in LLVMContext - now the the diagnostics are printed directly into llvm::errs() so that the MIR parsing errors can be printed with colours. Reviewers: Justin Bogner Differential Revision: http://reviews.llvm.org/D9928 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239753 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -210,6 +210,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
|
||||
// Load the module to be compiled...
|
||||
SMDiagnostic Err;
|
||||
std::unique_ptr<Module> M;
|
||||
std::unique_ptr<MIRParser> MIR;
|
||||
Triple TheTriple;
|
||||
|
||||
bool SkipModule = MCPU == "help" ||
|
||||
@@ -217,9 +218,13 @@ static int compileModule(char **argv, LLVMContext &Context) {
|
||||
|
||||
// If user just wants to list available options, skip module loading
|
||||
if (!SkipModule) {
|
||||
if (StringRef(InputFilename).endswith_lower(".mir"))
|
||||
M = parseMIRFile(InputFilename, Err, Context);
|
||||
else
|
||||
if (StringRef(InputFilename).endswith_lower(".mir")) {
|
||||
MIR = createMIRParserFromFile(InputFilename, Err, Context);
|
||||
if (MIR) {
|
||||
M = MIR->parseLLVMModule();
|
||||
assert(M && "parseLLVMModule should exit on failure");
|
||||
}
|
||||
} else
|
||||
M = parseIRFile(InputFilename, Err, Context);
|
||||
if (!M) {
|
||||
Err.print(argv[0], errs());
|
||||
@@ -350,7 +355,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
|
||||
|
||||
// Ask the target to add backend passes as necessary.
|
||||
if (Target->addPassesToEmitFile(PM, *OS, FileType, NoVerify, StartAfterID,
|
||||
StopAfterID)) {
|
||||
StopAfterID, MIR.get())) {
|
||||
errs() << argv[0] << ": target does not support generation of this"
|
||||
<< " file type!\n";
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user