mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-29 08:16:51 +00:00 
			
		
		
		
	Added methods to make dealing with switches and branch instructions
more tolerable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -71,6 +71,9 @@ public: | |||||||
|  |  | ||||||
|   virtual void dropAllReferences(); |   virtual void dropAllReferences(); | ||||||
|   |   | ||||||
|  |   inline const Value *getCondition() const { return Condition; } | ||||||
|  |   inline       Value *getCondition()       { return Condition; } | ||||||
|  |  | ||||||
|   inline bool isUnconditional() const { |   inline bool isUnconditional() const { | ||||||
|     return Condition == 0 || !FalseDest; |     return Condition == 0 || !FalseDest; | ||||||
|   } |   } | ||||||
| @@ -83,6 +86,9 @@ public: | |||||||
|   virtual const Value *getOperand(unsigned i) const; |   virtual const Value *getOperand(unsigned i) const; | ||||||
|   virtual bool setOperand(unsigned i, Value *Val); |   virtual bool setOperand(unsigned i, Value *Val); | ||||||
|   virtual unsigned getNumOperands() const { return isUnconditional() ? 1 : 3; } |   virtual unsigned getNumOperands() const { return isUnconditional() ? 1 : 3; } | ||||||
|  |   inline BasicBlock *getSuccessor(unsigned idx) { | ||||||
|  |     return (BasicBlock*)((const BranchInst *)this)->getSuccessor(idx); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   // Additionally, they must provide a method to get at the successors of this |   // Additionally, they must provide a method to get at the successors of this | ||||||
|   // terminator instruction.  If 'idx' is out of range, a null pointer shall be |   // terminator instruction.  If 'idx' is out of range, a null pointer shall be | ||||||
| @@ -114,6 +120,18 @@ public: | |||||||
|  |  | ||||||
|   virtual Instruction *clone() const { return new SwitchInst(*this); } |   virtual Instruction *clone() const { return new SwitchInst(*this); } | ||||||
|  |  | ||||||
|  |   // Accessor Methods for Switch stmt | ||||||
|  |   // | ||||||
|  |   inline dest_iterator dest_begin() { return Destinations.begin(); } | ||||||
|  |   inline dest_iterator dest_end  () { return Destinations.end(); } | ||||||
|  |   inline dest_const_iterator dest_begin() const { return Destinations.begin(); } | ||||||
|  |   inline dest_const_iterator dest_end  () const { return Destinations.end(); } | ||||||
|  |  | ||||||
|  |   inline const Value *getCondition() const { return Val; } | ||||||
|  |   inline       Value *getCondition()       { return Val; } | ||||||
|  |   inline const BasicBlock *getDefaultDest() const { return DefaultDest; } | ||||||
|  |   inline       BasicBlock *getDefaultDest()       { return DefaultDest; } | ||||||
|  |  | ||||||
|   void dest_push_back(ConstPoolVal *OnVal, BasicBlock *Dest); |   void dest_push_back(ConstPoolVal *OnVal, BasicBlock *Dest); | ||||||
|  |  | ||||||
|   virtual string getOpcode() const { return "switch"; } |   virtual string getOpcode() const { return "switch"; } | ||||||
| @@ -131,6 +149,9 @@ public: | |||||||
|   // |   // | ||||||
|   virtual const BasicBlock *getSuccessor(unsigned idx) const; |   virtual const BasicBlock *getSuccessor(unsigned idx) const; | ||||||
|   virtual unsigned getNumSuccessors() const { return 1+Destinations.size(); } |   virtual unsigned getNumSuccessors() const { return 1+Destinations.size(); } | ||||||
|  |   inline BasicBlock *getSuccessor(unsigned idx) { | ||||||
|  |     return (BasicBlock*)((const SwitchInst *)this)->getSuccessor(idx); | ||||||
|  |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user