mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-28 09:31:03 +00:00
[PM] Add an enum for describing the desired output strategy, and run
that through the interface rather than a simple bool. This should allow starting to wire up real output to round-trip IR through opt with the new pass manager. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199071 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
63735e79ff
commit
4a76032da6
@ -23,10 +23,11 @@
|
|||||||
#include "llvm/Support/ToolOutputFile.h"
|
#include "llvm/Support/ToolOutputFile.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
using namespace opt_tool;
|
||||||
|
|
||||||
bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
|
bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
|
||||||
tool_output_file *Out, StringRef PassPipeline,
|
tool_output_file *Out, StringRef PassPipeline,
|
||||||
bool NoOutput) {
|
OutputKind OK) {
|
||||||
// Before executing passes, print the final values of the LLVM options.
|
// Before executing passes, print the final values of the LLVM options.
|
||||||
cl::PrintOptionValues();
|
cl::PrintOptionValues();
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ bool llvm::runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
|
|||||||
MPM.run(&M);
|
MPM.run(&M);
|
||||||
|
|
||||||
// Declare success.
|
// Declare success.
|
||||||
if (!NoOutput)
|
if (OK != OK_NoOutput)
|
||||||
Out->keep();
|
Out->keep();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,14 @@ class LLVMContext;
|
|||||||
class Module;
|
class Module;
|
||||||
class tool_output_file;
|
class tool_output_file;
|
||||||
|
|
||||||
|
namespace opt_tool {
|
||||||
|
enum OutputKind {
|
||||||
|
OK_NoOutput,
|
||||||
|
OK_OutputAssembly,
|
||||||
|
OK_OutputBitcode
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// \brief Driver function to run the new pass manager over a module.
|
/// \brief Driver function to run the new pass manager over a module.
|
||||||
///
|
///
|
||||||
/// This function only exists factored away from opt.cpp in order to prevent
|
/// This function only exists factored away from opt.cpp in order to prevent
|
||||||
@ -36,7 +44,7 @@ class tool_output_file;
|
|||||||
/// when the transition finishes.
|
/// when the transition finishes.
|
||||||
bool runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
|
bool runPassPipeline(StringRef Arg0, LLVMContext &Context, Module &M,
|
||||||
tool_output_file *Out, StringRef PassPipeline,
|
tool_output_file *Out, StringRef PassPipeline,
|
||||||
bool NoOutput);
|
opt_tool::OutputKind OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
using namespace opt_tool;
|
||||||
|
|
||||||
// The OptimizationList is automatically populated with registered Passes by the
|
// The OptimizationList is automatically populated with registered Passes by the
|
||||||
// PassNameParser.
|
// PassNameParser.
|
||||||
@ -670,14 +671,19 @@ int main(int argc, char **argv) {
|
|||||||
if (CheckBitcodeOutputToConsole(Out->os(), !Quiet))
|
if (CheckBitcodeOutputToConsole(Out->os(), !Quiet))
|
||||||
NoOutput = true;
|
NoOutput = true;
|
||||||
|
|
||||||
if (PassPipeline.getNumOccurrences() > 0)
|
if (PassPipeline.getNumOccurrences() > 0) {
|
||||||
|
OutputKind OK = OK_NoOutput;
|
||||||
|
if (!NoOutput)
|
||||||
|
OK = OutputAssembly ? OK_OutputAssembly : OK_OutputBitcode;
|
||||||
|
|
||||||
// The user has asked to use the new pass manager and provided a pipeline
|
// The user has asked to use the new pass manager and provided a pipeline
|
||||||
// string. Hand off the rest of the functionality to the new code for that
|
// string. Hand off the rest of the functionality to the new code for that
|
||||||
// layer.
|
// layer.
|
||||||
return runPassPipeline(argv[0], Context, *M.get(), Out.get(), PassPipeline,
|
return runPassPipeline(argv[0], Context, *M.get(), Out.get(), PassPipeline,
|
||||||
NoOutput)
|
OK)
|
||||||
? 0
|
? 0
|
||||||
: 1;
|
: 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a PassManager to hold and optimize the collection of passes we are
|
// Create a PassManager to hold and optimize the collection of passes we are
|
||||||
// about to build.
|
// about to build.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user