aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-06-30 04:34:07 +0000
committerChris Lattner <sabre@nondot.org>2001-06-30 04:34:07 +0000
commit50d0b7ec3f58d13ea5613dde60a15b07532de56e (patch)
treec5dea80de4b30c86b776e25f11da2e07e433c6dc
parent2b05880476693393ebebba777c70ca3cbb043fc3 (diff)
downloadexternal_llvm-50d0b7ec3f58d13ea5613dde60a15b07532de56e.zip
external_llvm-50d0b7ec3f58d13ea5613dde60a15b07532de56e.tar.gz
external_llvm-50d0b7ec3f58d13ea5613dde60a15b07532de56e.tar.bz2
Split AllOpts.h into lots of little .h files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ConstantHandling.h3
-rw-r--r--include/llvm/Optimizations/AllOpts.h119
-rw-r--r--include/llvm/Transforms/FunctionInlining.h40
-rw-r--r--include/llvm/Transforms/Scalar/ConstantProp.h65
-rw-r--r--include/llvm/Transforms/Scalar/DCE.h35
-rw-r--r--include/llvm/Transforms/Scalar/InductionVars.h24
-rw-r--r--include/llvm/Transforms/Scalar/SymbolStripping.h33
-rw-r--r--lib/VMCore/ConstantFold.h3
-rw-r--r--lib/VMCore/ConstantFolding.h3
9 files changed, 214 insertions, 111 deletions
diff --git a/include/llvm/ConstantHandling.h b/include/llvm/ConstantHandling.h
index 4facdc3..cf18ef8 100644
--- a/include/llvm/ConstantHandling.h
+++ b/include/llvm/ConstantHandling.h
@@ -39,6 +39,8 @@
#include "llvm/Instruction.h"
#include "llvm/Type.h"
+namespace opt {
+
//===----------------------------------------------------------------------===//
// Implement == directly...
//===----------------------------------------------------------------------===//
@@ -174,4 +176,5 @@ inline ConstPoolVal *ConstantFoldBinaryInstruction(unsigned Opcode,
return 0;
}
+} // end namespace opt
#endif
diff --git a/include/llvm/Optimizations/AllOpts.h b/include/llvm/Optimizations/AllOpts.h
index 1035b20..bbe9af6 100644
--- a/include/llvm/Optimizations/AllOpts.h
+++ b/include/llvm/Optimizations/AllOpts.h
@@ -1,4 +1,4 @@
-//===-- llvm/AllOpts.h - Header file to get all opt passes -------*- C++ -*--=//
+//===-- llvm/Opt/AllOpts.h - Header file to get all opt passes ---*- C++ -*--=//
//
// This file #include's all of the small optimization header files.
//
@@ -10,136 +10,33 @@
#ifndef LLVM_OPT_ALLOPTS_H
#define LLVM_OPT_ALLOPTS_H
-#include "llvm/Module.h"
-#include "llvm/BasicBlock.h"
-#include "llvm/Tools/STLExtras.h"
-class Method;
-class CallInst;
-class TerminatorInst;
//===----------------------------------------------------------------------===//
-// Helper functions
+// Dead Code Elimination
//
-
-static inline bool ApplyOptToAllMethods(Module *C, bool (*Opt)(Method*)) {
- return reduce_apply_bool(C->begin(), C->end(), ptr_fun(Opt));
-}
-
-
-//===----------------------------------------------------------------------===//
-// Dead Code Elimination Pass
-//
-
-bool DoDeadCodeElimination(Method *M); // DCE a method
-bool DoRemoveUnusedConstants(SymTabValue *S); // RUC a method or module
-bool DoDeadCodeElimination(Module *C); // DCE & RUC a whole module
+#include "llvm/Optimizations/DCE.h"
//===----------------------------------------------------------------------===//
-// Constant Propogation Pass
-//
-
-bool DoConstantPropogation(Method *M);
-
-static inline bool DoConstantPropogation(Module *C) {
- return ApplyOptToAllMethods(C, DoConstantPropogation);
-}
-
-// ConstantFoldTerminator - If a terminator instruction is predicated on a
-// constant value, convert it into an unconditional branch to the constant
-// destination.
+// Constant Propogation
//
-bool ConstantFoldTerminator(TerminatorInst *T);
-
-
-//===----------------------------------------------------------------------===//
-// Constant Pool Merging Pass
-//
-// This function merges all constants in the specified constant pool that have
-// identical types and values. This is useful for passes that generate lots of
-// constants as a side effect of running.
-//
-bool DoConstantPoolMerging(ConstantPool &CP);
-bool DoConstantPoolMerging(Method *M);
-static inline bool DoConstantPoolMerging(Module *M) {
- return ApplyOptToAllMethods(M, DoConstantPoolMerging) |
- DoConstantPoolMerging(M->getConstantPool());
-}
-
-
-//===----------------------------------------------------------------------===//
-// Sparse Conditional Constant Propogation Pass
-//
-
-bool DoSparseConditionalConstantProp(Method *M);
-
-static inline bool DoSparseConditionalConstantProp(Module *M) {
- return ApplyOptToAllMethods(M, DoSparseConditionalConstantProp);
-}
-
-// Define a shorter version of the name...
-template <class Unit> bool DoSCCP(Unit *M) {
- return DoSparseConditionalConstantProp(M);
-}
+#include "llvm/Optimizations/ConstantProp.h"
//===----------------------------------------------------------------------===//
// Method Inlining Pass
//
-
-// DoMethodInlining - Use a heuristic based approach to inline methods that seem
-// to look good.
-//
-bool DoMethodInlining(Method *M);
-
-static inline bool DoMethodInlining(Module *C) {
- return ApplyOptToAllMethods(C, DoMethodInlining);
-}
-
-// InlineMethod - This function forcibly inlines the called method into the
-// basic block of the caller. This returns true if it is not possible to inline
-// this call. The program is still in a well defined state if this occurs
-// though.
-//
-// Note that this only does one level of inlining. For example, if the
-// instruction 'call B' is inlined, and 'B' calls 'C', then the call to 'C' now
-// exists in the instruction stream. Similiarly this will inline a recursive
-// method by one level.
-//
-bool InlineMethod(CallInst *C);
-bool InlineMethod(BasicBlock::iterator CI); // *CI must be CallInst
-
+#include "llvm/Optimizations/MethodInlining.h"
//===----------------------------------------------------------------------===//
// Symbol Stripping Pass
//
-
-// DoSymbolStripping - Remove all symbolic information from a method
-//
-bool DoSymbolStripping(Method *M);
-
-// DoSymbolStripping - Remove all symbolic information from all methods in a
-// module
-//
-static inline bool DoSymbolStripping(Module *M) {
- return ApplyOptToAllMethods(M, DoSymbolStripping);
-}
-
-// DoFullSymbolStripping - Remove all symbolic information from all methods
-// in a module, and all module level symbols. (method names, etc...)
-//
-bool DoFullSymbolStripping(Module *M);
-
+#include "llvm/Optimizations/SymbolStripping.h"
//===----------------------------------------------------------------------===//
// Induction Variable Cannonicalization
//
-// DoInductionVariableCannonicalize - Simplify induction variables in loops
-//
-bool DoInductionVariableCannonicalize(Method *M);
-static inline bool DoInductionVariableCannonicalize(Module *M) {
- return ApplyOptToAllMethods(M, DoInductionVariableCannonicalize);
-}
+#include "llvm/Optimizations/InductionVars.h"
#endif
diff --git a/include/llvm/Transforms/FunctionInlining.h b/include/llvm/Transforms/FunctionInlining.h
new file mode 100644
index 0000000..b314b97
--- /dev/null
+++ b/include/llvm/Transforms/FunctionInlining.h
@@ -0,0 +1,40 @@
+//===-- MethodInlining.h - Functions that perform Inlining -------*- C++ -*--=//
+//
+// This family of functions is useful for performing method inlining.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_OPT_METHOD_INLINING_H
+#define LLVM_OPT_METHOD_INLINING_H
+
+#include "llvm/Module.h"
+#include "llvm/BasicBlock.h"
+class CallInst;
+
+namespace opt {
+
+// DoMethodInlining - Use a heuristic based approach to inline methods that seem
+// to look good.
+//
+bool DoMethodInlining(Method *M);
+
+static inline bool DoMethodInlining(Module *M) {
+ return M->reduceApply(DoMethodInlining);
+}
+
+// InlineMethod - This function forcibly inlines the called method into the
+// basic block of the caller. This returns true if it is not possible to inline
+// this call. The program is still in a well defined state if this occurs
+// though.
+//
+// Note that this only does one level of inlining. For example, if the
+// instruction 'call B' is inlined, and 'B' calls 'C', then the call to 'C' now
+// exists in the instruction stream. Similiarly this will inline a recursive
+// method by one level.
+//
+bool InlineMethod(CallInst *C);
+bool InlineMethod(BasicBlock::iterator CI); // *CI must be CallInst
+
+} // end namespace opt
+
+#endif
diff --git a/include/llvm/Transforms/Scalar/ConstantProp.h b/include/llvm/Transforms/Scalar/ConstantProp.h
new file mode 100644
index 0000000..bbcd609
--- /dev/null
+++ b/include/llvm/Transforms/Scalar/ConstantProp.h
@@ -0,0 +1,65 @@
+//===-- ConstantProp.h - Functions for Constant Propogation ------*- C++ -*--=//
+//
+// This family of functions are useful for performing constant propogation.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_OPT_CONSTANT_PROPOGATION_H
+#define LLVM_OPT_CONSTANT_PROPOGATION_H
+
+#include "llvm/Module.h"
+class Method;
+class TerminatorInst;
+class ConstantPool;
+
+namespace opt {
+
+// DoConstantPropogation - Do trivial constant propogation and expression
+// folding
+bool DoConstantPropogation(Method *M);
+
+static inline bool DoConstantPropogation(Module *M) {
+ return M->reduceApply(DoConstantPropogation);
+}
+
+
+// ConstantFoldTerminator - If a terminator instruction is predicated on a
+// constant value, convert it into an unconditional branch to the constant
+// destination.
+//
+bool ConstantFoldTerminator(TerminatorInst *T);
+
+
+//===----------------------------------------------------------------------===//
+// Constant Pool Merging Pass
+//
+// This function merges all constants in the specified constant pool that have
+// identical types and values. This is useful for passes that generate lots of
+// constants as a side effect of running.
+//
+bool DoConstantPoolMerging(ConstantPool &CP);
+bool DoConstantPoolMerging(Method *M);
+
+static inline bool DoConstantPoolMerging(Module *M) {
+ return M->reduceApply(DoConstantPoolMerging) |
+ DoConstantPoolMerging(M->getConstantPool());
+}
+
+//===----------------------------------------------------------------------===//
+// Sparse Conditional Constant Propogation Pass
+//
+
+bool DoSparseConditionalConstantProp(Method *M);
+
+static inline bool DoSparseConditionalConstantProp(Module *M) {
+ return M->reduceApply(DoSparseConditionalConstantProp);
+}
+
+// Define a shorter version of the name...
+template <class Unit> bool DoSCCP(Unit *M) {
+ return DoSparseConditionalConstantProp(M);
+}
+
+} // End Namespace opt
+
+#endif
diff --git a/include/llvm/Transforms/Scalar/DCE.h b/include/llvm/Transforms/Scalar/DCE.h
new file mode 100644
index 0000000..362e146
--- /dev/null
+++ b/include/llvm/Transforms/Scalar/DCE.h
@@ -0,0 +1,35 @@
+//===-- DCE.h - Functions that perform Dead Code Elimination -----*- C++ -*--=//
+//
+// This family of functions is useful for performing dead code elimination of
+// various sorts.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_OPT_DCE_H
+#define LLVM_OPT_DCE_H
+
+#include "llvm/Method.h"
+class Module;
+class SymTabValue;
+class BasicBlock;
+
+namespace opt {
+
+bool DoDeadCodeElimination(Method *M); // DCE a method
+bool DoRemoveUnusedConstants(SymTabValue *S); // RUC a method or module
+bool DoDeadCodeElimination(Module *C); // DCE & RUC a whole module
+
+// SimplifyCFG - This function is used to do simplification of a CFG. For
+// example, it adjusts branches to branches to eliminate the extra hop, it
+// eliminates unreachable basic blocks, and does other "peephole" optimization
+// of the CFG. It returns true if a modification was made, and returns an
+// iterator that designates the first element remaining after the block that
+// was deleted.
+//
+// WARNING: The entry node of a method may not be simplified.
+//
+bool SimplifyCFG(Method::iterator &BBIt);
+
+} // End namespace opt
+
+#endif
diff --git a/include/llvm/Transforms/Scalar/InductionVars.h b/include/llvm/Transforms/Scalar/InductionVars.h
new file mode 100644
index 0000000..4e8d4a6
--- /dev/null
+++ b/include/llvm/Transforms/Scalar/InductionVars.h
@@ -0,0 +1,24 @@
+//===-- InductionVars.h - Induction Variable Recognition ---------*- C++ -*--=//
+//
+// This family of functions is useful for Induction variable recognition,
+// removal and optimizations.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_OPT_INDUCTION_VARS_H
+#define LLVM_OPT_INDUCTION_VARS_H
+
+#include "llvm/Module.h"
+
+namespace opt {
+
+// DoInductionVariableCannonicalize - Simplify induction variables in loops
+//
+bool DoInductionVariableCannonicalize(Method *M);
+static inline bool DoInductionVariableCannonicalize(Module *M) {
+ return M->reduceApply(DoInductionVariableCannonicalize);
+}
+
+} // end namespace opt
+
+#endif
diff --git a/include/llvm/Transforms/Scalar/SymbolStripping.h b/include/llvm/Transforms/Scalar/SymbolStripping.h
new file mode 100644
index 0000000..1b26685
--- /dev/null
+++ b/include/llvm/Transforms/Scalar/SymbolStripping.h
@@ -0,0 +1,33 @@
+//===-- SymbolStripping.h - Functions that Strip Symbol Tables ---*- C++ -*--=//
+//
+// This family of functions removes symbols from the symbol tables of methods
+// and classes.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_OPT_SYMBOL_STRIPPING_H
+#define LLVM_OPT_SYMBOL_STRIPPING_H
+
+class Method;
+class Module;
+
+namespace opt {
+
+// DoSymbolStripping - Remove all symbolic information from a method
+//
+bool DoSymbolStripping(Method *M);
+
+// DoSymbolStripping - Remove all symbolic information from all methods in a
+// module
+//
+static inline bool DoSymbolStripping(Module *M) {
+ return M->reduceApply(DoSymbolStripping);
+}
+
+// DoFullSymbolStripping - Remove all symbolic information from all methods
+// in a module, and all module level symbols. (method names, etc...)
+//
+bool DoFullSymbolStripping(Module *M);
+
+} // End namespace opt
+#endif
diff --git a/lib/VMCore/ConstantFold.h b/lib/VMCore/ConstantFold.h
index 4facdc3..cf18ef8 100644
--- a/lib/VMCore/ConstantFold.h
+++ b/lib/VMCore/ConstantFold.h
@@ -39,6 +39,8 @@
#include "llvm/Instruction.h"
#include "llvm/Type.h"
+namespace opt {
+
//===----------------------------------------------------------------------===//
// Implement == directly...
//===----------------------------------------------------------------------===//
@@ -174,4 +176,5 @@ inline ConstPoolVal *ConstantFoldBinaryInstruction(unsigned Opcode,
return 0;
}
+} // end namespace opt
#endif
diff --git a/lib/VMCore/ConstantFolding.h b/lib/VMCore/ConstantFolding.h
index 4facdc3..cf18ef8 100644
--- a/lib/VMCore/ConstantFolding.h
+++ b/lib/VMCore/ConstantFolding.h
@@ -39,6 +39,8 @@
#include "llvm/Instruction.h"
#include "llvm/Type.h"
+namespace opt {
+
//===----------------------------------------------------------------------===//
// Implement == directly...
//===----------------------------------------------------------------------===//
@@ -174,4 +176,5 @@ inline ConstPoolVal *ConstantFoldBinaryInstruction(unsigned Opcode,
return 0;
}
+} // end namespace opt
#endif