1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Add instruction combining pass

Rename -mergecons to -constmerge

llvm-svn: 1478
This commit is contained in:
Chris Lattner 2001-12-14 16:50:35 +00:00
parent 59918ae040
commit 085560caa2

View File

@ -18,19 +18,20 @@
#include "llvm/Transforms/SwapStructContents.h" #include "llvm/Transforms/SwapStructContents.h"
#include "llvm/Transforms/IPO/GlobalDCE.h" #include "llvm/Transforms/IPO/GlobalDCE.h"
#include "llvm/Transforms/Scalar/IndVarSimplify.h" #include "llvm/Transforms/Scalar/IndVarSimplify.h"
#include "llvm/Transforms/Scalar/InstructionCombining.h"
#include "Support/CommandLine.h" #include "Support/CommandLine.h"
#include <fstream> #include <fstream>
#include <memory> #include <memory>
enum Opts { enum Opts {
// Basic optimizations // Basic optimizations
dce, constprop, inlining, mergecons, strip, mstrip, dce, constprop, inlining, constmerge, strip, mstrip,
// Miscellaneous Transformations // Miscellaneous Transformations
trace, tracem, print, cleangcc, trace, tracem, print, cleangcc,
// More powerful optimizations // More powerful optimizations
indvars, sccp, adce, raise, indvars, instcombine, sccp, adce, raise,
// Interprocedural optimizations... // Interprocedural optimizations...
globaldce, swapstructs, globaldce, swapstructs,
@ -41,20 +42,21 @@ struct {
Pass *ThePass; Pass *ThePass;
} OptTable[] = { } OptTable[] = {
{ swapstructs, 0 }, { swapstructs, 0 },
{ dce , new opt::DeadCodeElimination() }, { dce , new opt::DeadCodeElimination() },
{ constprop, new opt::ConstantPropogation() }, { constprop , new opt::ConstantPropogation() },
{ inlining , new opt::MethodInlining() }, { inlining , new opt::MethodInlining() },
{ mergecons, new ConstantMerge() }, { constmerge , new ConstantMerge() },
{ strip , new opt::SymbolStripping() }, { strip , new opt::SymbolStripping() },
{ mstrip , new opt::FullSymbolStripping() }, { mstrip , new opt::FullSymbolStripping() },
{ indvars , new InductionVariableSimplify() }, { indvars , new InductionVariableSimplify() },
{ sccp , new opt::SCCPPass() }, { instcombine, new InstructionCombining() },
{ adce , new opt::AgressiveDCE() }, { sccp , new opt::SCCPPass() },
{ raise , new RaisePointerReferences() }, { adce , new opt::AgressiveDCE() },
{ trace , new InsertTraceCode(true, true) }, { raise , new RaisePointerReferences() },
{ tracem , new InsertTraceCode(false, true) }, { trace , new InsertTraceCode(true, true) },
{ print , new PrintModulePass("Current Method: \n",&cerr) }, { tracem , new InsertTraceCode(false, true) },
{ cleangcc , new CleanupGCCOutput() }, { print , new PrintModulePass("Current Method: \n",&cerr) },
{ cleangcc , new CleanupGCCOutput() },
}; };
cl::String InputFilename ("", "Load <arg> file to optimize", cl::NoFlags, "-"); cl::String InputFilename ("", "Load <arg> file to optimize", cl::NoFlags, "-");
@ -63,24 +65,25 @@ cl::Flag Force ("f", "Overwrite output files", cl::NoFlags, false);
cl::Flag Quiet ("q", "Don't print modifying pass names", 0, false); cl::Flag Quiet ("q", "Don't print modifying pass names", 0, false);
cl::Alias QuietA ("quiet", "Alias for -q", cl::NoFlags, Quiet); cl::Alias QuietA ("quiet", "Alias for -q", cl::NoFlags, Quiet);
cl::EnumList<enum Opts> OptimizationList(cl::NoFlags, cl::EnumList<enum Opts> OptimizationList(cl::NoFlags,
clEnumVal(dce , "Dead Code Elimination"), clEnumVal(dce , "Dead Code Elimination"),
clEnumVal(constprop, "Simple Constant Propogation"), clEnumVal(constprop , "Simple Constant Propogation"),
clEnumValN(inlining , "inline", "Method Integration"), clEnumValN(inlining , "inline", "Method Integration"),
clEnumVal(mergecons, "Merge identical global constants"), clEnumVal(constmerge , "Merge identical global constants"),
clEnumVal(strip , "Strip Symbols"), clEnumVal(strip , "Strip Symbols"),
clEnumVal(mstrip , "Strip Module Symbols"), clEnumVal(mstrip , "Strip Module Symbols"),
clEnumVal(indvars , "Simplify Induction Variables"), clEnumVal(indvars , "Simplify Induction Variables"),
clEnumVal(sccp , "Sparse Conditional Constant Propogation"), clEnumVal(instcombine, "Simplify Induction Variables"),
clEnumVal(adce , "Agressive DCE"), clEnumVal(sccp , "Sparse Conditional Constant Propogation"),
clEnumVal(adce , "Agressive DCE"),
clEnumVal(globaldce, "Remove unreachable globals"), clEnumVal(globaldce , "Remove unreachable globals"),
clEnumVal(swapstructs, "Swap structure types around"), clEnumVal(swapstructs, "Swap structure types around"),
clEnumVal(cleangcc , "Cleanup GCC Output"), clEnumVal(cleangcc , "Cleanup GCC Output"),
clEnumVal(raise , "Raise to Higher Level"), clEnumVal(raise , "Raise to Higher Level"),
clEnumVal(trace , "Insert BB & Method trace code"), clEnumVal(trace , "Insert BB & Method trace code"),
clEnumVal(tracem , "Insert Method trace code only"), clEnumVal(tracem , "Insert Method trace code only"),
clEnumVal(print , "Print working method to stderr"), clEnumVal(print , "Print working method to stderr"),
0); 0);
static void RunOptimization(Module *M, enum Opts Opt) { static void RunOptimization(Module *M, enum Opts Opt) {