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
This commit is contained in:
Chris Lattner 2001-12-03 18:02:31 +00:00
parent 6148c02591
commit 7061dc50b2
27 changed files with 113 additions and 98 deletions

View File

@ -11,74 +11,6 @@
#include "llvm/InstrTypes.h"
#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
//===----------------------------------------------------------------------===//

80
include/llvm/iPHINode.h Normal file
View File

@ -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

View File

@ -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"

View File

@ -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>

View File

@ -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>

View File

@ -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) {

View File

@ -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>

View File

@ -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>

View File

@ -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"

View File

@ -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>

View File

@ -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"

View File

@ -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"

View File

@ -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>

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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>

View File

@ -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...

View File

@ -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>

View File

@ -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"

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -5,6 +5,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/iOther.h"
#include "llvm/iPHINode.h"
#include "llvm/BasicBlock.h"
#include "llvm/Method.h"
#include "llvm/SymbolTable.h"