Split the PHINode class out from the iOther.h file into the iPHINode.h file


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1405 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/iOther.h b/include/llvm/iOther.h
index cba4196..de1532d 100644
--- a/include/llvm/iOther.h
+++ b/include/llvm/iOther.h
@@ -12,74 +12,6 @@
 #include "llvm/Method.h"
 
 //===----------------------------------------------------------------------===//
-//                               PHINode Class
-//===----------------------------------------------------------------------===//
-
-// PHINode - The PHINode class is used to represent the magical mystical PHI
-// node, that can not exist in nature, but can be synthesized in a computer
-// scientist's overactive imagination.
-//
-class PHINode : public Instruction {
-  PHINode(const PHINode &PN);
-public:
-  PHINode(const Type *Ty, const string &Name = "");
-
-  virtual Instruction *clone() const { return new PHINode(*this); }
-  virtual const char *getOpcodeName() const { return "phi"; }
-
-  // getNumIncomingValues - Return the number of incoming edges the PHI node has
-  inline unsigned getNumIncomingValues() const { return Operands.size()/2; }
-
-  // getIncomingValue - Return incoming value #x
-  inline const Value *getIncomingValue(unsigned i) const {
-    return Operands[i*2];
-  }
-  inline Value *getIncomingValue(unsigned i) {
-    return Operands[i*2];
-  }
-  inline void setIncomingValue(unsigned i, Value *V) {
-    Operands[i*2] = V;
-  }
-
-  // getIncomingBlock - Return incoming basic block #x
-  inline const BasicBlock *getIncomingBlock(unsigned i) const { 
-    return cast<const BasicBlock>(Operands[i*2+1]);
-  }
-  inline BasicBlock *getIncomingBlock(unsigned i) { 
-    return cast<BasicBlock>(Operands[i*2+1]);
-  }
-  inline void setIncomingBlock(unsigned i, BasicBlock *BB) {
-    Operands[i*2+1] = BB;
-  }
-
-  // addIncoming - Add an incoming value to the end of the PHI list
-  void addIncoming(Value *D, BasicBlock *BB);
-
-  // removeIncomingValue - Remove an incoming value.  This is useful if a
-  // predecessor basic block is deleted.  The value removed is returned.
-  Value *removeIncomingValue(const BasicBlock *BB);
-
-  // getBasicBlockIndex - Return the first index of the specified basic 
-  // block in the value list for this PHI.  Returns -1 if no instance.
-  //
-  int getBasicBlockIndex(const BasicBlock *BB) const {
-    for (unsigned i = 0; i < Operands.size()/2; ++i) 
-      if (getIncomingBlock(i) == BB) return i;
-    return -1;
-  }
-
-  // Methods for support type inquiry through isa, cast, and dyn_cast:
-  static inline bool classof(const PHINode *) { return true; }
-  static inline bool classof(const Instruction *I) {
-    return I->getOpcode() == Instruction::PHINode; 
-  }
-  static inline bool classof(const Value *V) {
-    return isa<Instruction>(V) && classof(cast<Instruction>(V));
-  }
-};
-
-
-//===----------------------------------------------------------------------===//
 //                                 CastInst Class
 //===----------------------------------------------------------------------===//
 
diff --git a/include/llvm/iPHINode.h b/include/llvm/iPHINode.h
new file mode 100644
index 0000000..66afac6
--- /dev/null
+++ b/include/llvm/iPHINode.h
@@ -0,0 +1,80 @@
+//===-- llvm/iPHINode.h - PHI instruction definition -------------*- C++ -*--=//
+//
+// This file defines the PHINode class.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_IPHINODE_H
+#define LLVM_IPHINODE_H
+
+#include "llvm/Instruction.h"
+class BasicBlock;
+
+//===----------------------------------------------------------------------===//
+//                               PHINode Class
+//===----------------------------------------------------------------------===//
+
+// PHINode - The PHINode class is used to represent the magical mystical PHI
+// node, that can not exist in nature, but can be synthesized in a computer
+// scientist's overactive imagination.
+//
+class PHINode : public Instruction {
+  PHINode(const PHINode &PN);
+public:
+  PHINode(const Type *Ty, const string &Name = "");
+
+  virtual Instruction *clone() const { return new PHINode(*this); }
+  virtual const char *getOpcodeName() const { return "phi"; }
+
+  // getNumIncomingValues - Return the number of incoming edges the PHI node has
+  inline unsigned getNumIncomingValues() const { return Operands.size()/2; }
+
+  // getIncomingValue - Return incoming value #x
+  inline const Value *getIncomingValue(unsigned i) const {
+    return Operands[i*2];
+  }
+  inline Value *getIncomingValue(unsigned i) {
+    return Operands[i*2];
+  }
+  inline void setIncomingValue(unsigned i, Value *V) {
+    Operands[i*2] = V;
+  }
+
+  // getIncomingBlock - Return incoming basic block #x
+  inline const BasicBlock *getIncomingBlock(unsigned i) const { 
+    return (const BasicBlock*)Operands[i*2+1].get();
+  }
+  inline BasicBlock *getIncomingBlock(unsigned i) { 
+    return (BasicBlock*)Operands[i*2+1].get();
+  }
+  inline void setIncomingBlock(unsigned i, BasicBlock *BB) {
+    Operands[i*2+1] = (Value*)BB;
+  }
+
+  // addIncoming - Add an incoming value to the end of the PHI list
+  void addIncoming(Value *D, BasicBlock *BB);
+
+  // removeIncomingValue - Remove an incoming value.  This is useful if a
+  // predecessor basic block is deleted.  The value removed is returned.
+  Value *removeIncomingValue(const BasicBlock *BB);
+
+  // getBasicBlockIndex - Return the first index of the specified basic 
+  // block in the value list for this PHI.  Returns -1 if no instance.
+  //
+  int getBasicBlockIndex(const BasicBlock *BB) const {
+    for (unsigned i = 0; i < Operands.size()/2; ++i) 
+      if (getIncomingBlock(i) == BB) return i;
+    return -1;
+  }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const PHINode *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() == Instruction::PHINode; 
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
+#endif
diff --git a/lib/Analysis/InductionVariable.cpp b/lib/Analysis/InductionVariable.cpp
index b64daa2..73f4e7f 100644
--- a/lib/Analysis/InductionVariable.cpp
+++ b/lib/Analysis/InductionVariable.cpp
@@ -19,7 +19,8 @@
 #include "llvm/Analysis/InductionVariable.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/Expressions.h"
-#include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
+#include "llvm/InstrTypes.h"
 #include "llvm/Type.h"
 #include "llvm/ConstPoolVals.h"
 
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index 0f5c11e..b5816f2 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -4,12 +4,6 @@
 //
 //===------------------------------------------------------------------------=//
 
-//
-// TODO: Parse comments and add them to an internal node... so that they may
-// be saved in the bytecode format as well as everything else.  Very important
-// for a general IR format.
-//
-
 %{
 #include "ParserInternals.h"
 #include "llvm/Assembly/Parser.h"
@@ -21,6 +15,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iMemory.h"
+#include "llvm/iPHINode.h"
 #include "Support/STLExtras.h"
 #include "Support/DepthFirstIterator.h"
 #include <list>
diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp
index 405745d..21462b1 100644
--- a/lib/Bytecode/Reader/ConstantReader.cpp
+++ b/lib/Bytecode/Reader/ConstantReader.cpp
@@ -8,12 +8,11 @@
 //
 //===------------------------------------------------------------------------===
 
+#include "ReaderInternals.h"
 #include "llvm/Module.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/ConstPoolVals.h"
-#include "llvm/DerivedTypes.h"
 #include "llvm/GlobalVariable.h"
-#include "ReaderInternals.h"
 #include <algorithm>
 
 
diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp
index c59d147..a80f656 100644
--- a/lib/Bytecode/Reader/InstructionReader.cpp
+++ b/lib/Bytecode/Reader/InstructionReader.cpp
@@ -11,11 +11,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/iOther.h"
+#include "ReaderInternals.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iMemory.h"
-#include "llvm/DerivedTypes.h"
-#include "ReaderInternals.h"
+#include "llvm/iPHINode.h"
+#include "llvm/iOther.h"
 
 bool BytecodeParser::ParseRawInst(const uchar *&Buf, const uchar *EndBuf, 
 				  RawInst &Result) {
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index 7f02b93..2766b34 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -10,15 +10,15 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "ReaderInternals.h"
 #include "llvm/Bytecode/Reader.h"
 #include "llvm/Bytecode/Format.h"
 #include "llvm/GlobalVariable.h"
 #include "llvm/Module.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/DerivedTypes.h"
 #include "llvm/ConstPoolVals.h"
+#include "llvm/iPHINode.h"
 #include "llvm/iOther.h"
-#include "ReaderInternals.h"
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h
index fb34169..b3977f6 100644
--- a/lib/Bytecode/Reader/ReaderInternals.h
+++ b/lib/Bytecode/Reader/ReaderInternals.h
@@ -11,6 +11,7 @@
 #include "llvm/SymTabValue.h"
 #include "llvm/Method.h"
 #include "llvm/Instruction.h"
+#include "llvm/DerivedTypes.h"
 #include <map>
 #include <utility>
 #include <list>
diff --git a/lib/CodeGen/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp
index c6d5367..e0f0219 100644
--- a/lib/CodeGen/InstrSelection/InstrForest.cpp
+++ b/lib/CodeGen/InstrSelection/InstrForest.cpp
@@ -26,7 +26,7 @@
 #include "llvm/Method.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iMemory.h"
-#include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "llvm/ConstPoolVals.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/CodeGen/MachineInstr.h"
diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp
index ce26a1d..d0a301c 100644
--- a/lib/CodeGen/InstrSelection/InstrSelection.cpp
+++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp
@@ -20,7 +20,7 @@
 #include "llvm/Instruction.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Method.h"
-#include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "llvm/Target/MachineRegInfo.h"
 #include "Support/CommandLine.h"
 #include <string.h>
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index 2f0ee41..a1547c1 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -6,6 +6,7 @@
 
 #include "Interpreter.h"
 #include "ExecutionAnnotations.h"
+#include "llvm/iPHINode.h"
 #include "llvm/iOther.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iMemory.h"
diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
index c6d5367..e0f0219 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
+++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
@@ -26,7 +26,7 @@
 #include "llvm/Method.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iMemory.h"
-#include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "llvm/ConstPoolVals.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/CodeGen/MachineInstr.h"
diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
index ce26a1d..d0a301c 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
+++ b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
@@ -20,7 +20,7 @@
 #include "llvm/Instruction.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Method.h"
-#include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "llvm/Target/MachineRegInfo.h"
 #include "Support/CommandLine.h"
 #include <string.h>
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index a1d92f1..7efe623 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -9,6 +9,7 @@
 #include "TransformInternals.h"
 #include "llvm/Method.h"
 #include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "llvm/iMemory.h"
 #include "llvm/ConstPoolVals.h"
 #include "llvm/Optimizations/ConstantHandling.h"
diff --git a/lib/Transforms/HoistPHIConstants.cpp b/lib/Transforms/HoistPHIConstants.cpp
index d08deba..fe7cabf 100644
--- a/lib/Transforms/HoistPHIConstants.cpp
+++ b/lib/Transforms/HoistPHIConstants.cpp
@@ -6,10 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-
-
-
 #include "llvm/Transforms/HoistPHIConstants.h"
+#include "llvm/iPHINode.h"
 #include "llvm/iOther.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Method.h"
diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp
index e02c022..f29ae29 100644
--- a/lib/Transforms/IPO/DeadTypeElimination.cpp
+++ b/lib/Transforms/IPO/DeadTypeElimination.cpp
@@ -18,9 +18,10 @@
 #include "TransformInternals.h"
 #include "llvm/SymbolTable.h"
 #include "llvm/DerivedTypes.h"
-#include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "llvm/iMemory.h"
 #include "llvm/iTerminators.h"
+#include "llvm/iOther.h"
 #include <algorithm>
 
 static const Type *PtrArrSByte = 0; // '[sbyte]*' type
diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp
index bc320ee..e54e0d9 100644
--- a/lib/Transforms/IPO/InlineSimple.cpp
+++ b/lib/Transforms/IPO/InlineSimple.cpp
@@ -23,6 +23,7 @@
 #include "llvm/Module.h"
 #include "llvm/Method.h"
 #include "llvm/iTerminators.h"
+#include "llvm/iPHINode.h"
 #include "llvm/iOther.h"
 #include <algorithm>
 #include <map>
diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp
index fd1f46d..a433e26 100644
--- a/lib/Transforms/IPO/MutateStructTypes.cpp
+++ b/lib/Transforms/IPO/MutateStructTypes.cpp
@@ -16,9 +16,10 @@
 #include "llvm/Method.h"
 #include "llvm/GlobalVariable.h"
 #include "llvm/SymbolTable.h"
-#include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "llvm/iMemory.h"
 #include "llvm/iTerminators.h"
+#include "llvm/iOther.h"
 #include <algorithm>
 
 // To enable debugging, uncomment this...
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp
index a5d1d12..a38dbc5 100644
--- a/lib/Transforms/Scalar/ADCE.cpp
+++ b/lib/Transforms/Scalar/ADCE.cpp
@@ -12,7 +12,7 @@
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/Analysis/Writer.h"
 #include "llvm/iTerminators.h"
-#include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "Support/STLExtras.h"
 #include "Support/DepthFirstIterator.h"
 #include <set>
diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp
index 15be763..bf28868 100644
--- a/lib/Transforms/Scalar/ConstantProp.cpp
+++ b/lib/Transforms/Scalar/ConstantProp.cpp
@@ -27,6 +27,7 @@
 #include "llvm/Method.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/iTerminators.h"
+#include "llvm/iPHINode.h"
 #include "llvm/iOther.h"
 #include "llvm/ConstPoolVals.h"
 
diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp
index caacf32..e1bda22 100644
--- a/lib/Transforms/Scalar/DCE.cpp
+++ b/lib/Transforms/Scalar/DCE.cpp
@@ -29,7 +29,7 @@
 #include "llvm/Method.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/iTerminators.h"
-#include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "llvm/Assembly/Writer.h"
 #include "Support/STLExtras.h"
 #include <algorithm>
diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp
index 9f0513f..7dfae48 100644
--- a/lib/Transforms/Scalar/InductionVars.cpp
+++ b/lib/Transforms/Scalar/InductionVars.cpp
@@ -24,7 +24,7 @@
 #include "llvm/Analysis/IntervalPartition.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/SymbolTable.h"
-#include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "Support/STLExtras.h"
 #include <algorithm>
 
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index 256fadf..3c699c1 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -21,9 +21,10 @@
 #include "llvm/BasicBlock.h"
 #include "llvm/ConstPoolVals.h"
 #include "llvm/InstrTypes.h"
-#include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "llvm/iMemory.h"
 #include "llvm/iTerminators.h"
+#include "llvm/iOther.h"
 #include "llvm/Assembly/Writer.h"
 #include "Support/STLExtras.h"
 #include <algorithm>
diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
index ab600bd..efc7676 100644
--- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
+++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
@@ -9,7 +9,7 @@
 #include "llvm/BasicBlock.h"
 #include "llvm/Method.h"
 #include "llvm/iTerminators.h"
-#include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "llvm/Type.h"
 
 // UnifyAllExitNodes - Unify all exit nodes of the CFG by creating a new
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index 2be1723..9523c94 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -17,9 +17,10 @@
 #include "llvm/GlobalVariable.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/ConstPoolVals.h"
-#include "llvm/iOther.h"
 #include "llvm/iMemory.h"
 #include "llvm/iTerminators.h"
+#include "llvm/iPHINode.h"
+#include "llvm/iOther.h"
 #include "llvm/SymbolTable.h"
 #include "Support/StringExtras.h"
 #include "Support/STLExtras.h"
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp
index 462b98f..40962ef 100644
--- a/lib/VMCore/BasicBlock.cpp
+++ b/lib/VMCore/BasicBlock.cpp
@@ -10,7 +10,7 @@
 #include "llvm/Method.h"
 #include "llvm/SymbolTable.h"
 #include "llvm/Type.h"
-#include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "llvm/CodeGen/MachineInstr.h"
 
 // Instantiate Templates - This ugliness is the price we have to pay
diff --git a/lib/VMCore/InstrTypes.cpp b/lib/VMCore/InstrTypes.cpp
index 9e49805..69a703c 100644
--- a/lib/VMCore/InstrTypes.cpp
+++ b/lib/VMCore/InstrTypes.cpp
@@ -5,6 +5,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/iOther.h"
+#include "llvm/iPHINode.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Method.h"
 #include "llvm/SymbolTable.h"