aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/iPHINode.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-12-03 18:02:31 +0000
committerChris Lattner <sabre@nondot.org>2001-12-03 18:02:31 +0000
commit7061dc50b2513731d7b346ab16183cda4a44619f (patch)
tree11e3735e2f62245644424ec160eb40ffefd96e07 /include/llvm/iPHINode.h
parent6148c02591bd83da7b957589c4bbf6f9720d503f (diff)
downloadexternal_llvm-7061dc50b2513731d7b346ab16183cda4a44619f.zip
external_llvm-7061dc50b2513731d7b346ab16183cda4a44619f.tar.gz
external_llvm-7061dc50b2513731d7b346ab16183cda4a44619f.tar.bz2
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
Diffstat (limited to 'include/llvm/iPHINode.h')
-rw-r--r--include/llvm/iPHINode.h80
1 files changed, 80 insertions, 0 deletions
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