From 456a806692823808f1668994ace79ef4a72043ef Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 30 Sep 2006 22:20:34 +0000 Subject: [PATCH] Override use_back in instruction/basicblock to provide more type information. llvm-svn: 30678 --- llvm/include/llvm/BasicBlock.h | 5 +++++ llvm/include/llvm/Instruction.h | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/BasicBlock.h b/llvm/include/llvm/BasicBlock.h index 551ca4d6c2ea..f15d2b46a914 100644 --- a/llvm/include/llvm/BasicBlock.h +++ b/llvm/include/llvm/BasicBlock.h @@ -85,6 +85,11 @@ public: BasicBlock *getPrev() { return Prev; } const BasicBlock *getPrev() const { return Prev; } + /// use_back - Specialize the methods defined in Value, as we know that an + /// BasicBlock can only be used by Instructions (specifically PHI and terms). + Instruction *use_back() { return cast(*use_begin());} + const Instruction *use_back() const { return cast(*use_begin());} + /// getTerminator() - If this is a well formed basic block, then this returns /// a pointer to the terminator instruction. If it is not, then you get a /// null pointer back. diff --git a/llvm/include/llvm/Instruction.h b/llvm/include/llvm/Instruction.h index cd024d09ea92..591e0d2b889f 100644 --- a/llvm/include/llvm/Instruction.h +++ b/llvm/include/llvm/Instruction.h @@ -71,7 +71,11 @@ public: /// extra information (e.g. load is volatile) agree. bool isIdenticalTo(Instruction *I) const; - + /// use_back - Specialize the methods defined in Value, as we know that an + /// instruction can only be used by other instructions. + Instruction *use_back() { return cast(*use_begin());} + const Instruction *use_back() const { return cast(*use_begin());} + // Accessor methods... // inline const BasicBlock *getParent() const { return Parent; }