aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-28 00:01:44 +0000
committerChris Lattner <sabre@nondot.org>2009-10-28 00:01:44 +0000
commit2ee11eccdde14c95c78773be76b02bb5fd09d7ee (patch)
treefb35c2b746714f2074d1e391b04682b3080b625f /include
parentcd4f04d6bcb7aefa24d92582fbadfe17519f4756 (diff)
downloadexternal_llvm-2ee11eccdde14c95c78773be76b02bb5fd09d7ee.tar.gz
external_llvm-2ee11eccdde14c95c78773be76b02bb5fd09d7ee.tar.bz2
external_llvm-2ee11eccdde14c95c78773be76b02bb5fd09d7ee.zip
IR support for the new BlockAddress constant kind. This is
untested and there is no way to use it, next up: doing battle with asmparser. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Constants.h40
-rw-r--r--include/llvm/Value.h1
2 files changed, 41 insertions, 0 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 2855fdcc2b..0b881dc688 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -549,7 +549,47 @@ public:
}
};
+/// BlockAddress - The address of a basic block.
+///
+class BlockAddress : public Constant {
+ void *operator new(size_t, unsigned); // DO NOT IMPLEMENT
+ void *operator new(size_t s) { return User::operator new(s, 2); }
+ BlockAddress(Function *F, BasicBlock *BB);
+public:
+ /// get - Return a BlockAddress for the specified function and basic block.
+ static BlockAddress *get(Function *F, BasicBlock *BB);
+
+ /// get - Return a BlockAddress for the specified basic block. The basic
+ /// block must be embedded into a function.
+ static BlockAddress *get(BasicBlock *BB);
+
+ /// Transparently provide more efficient getOperand methods.
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
+
+ Function *getFunction() const { return (Function*)Op<0>().get(); }
+ BasicBlock *getBasicBlock() const { return (BasicBlock*)Op<1>().get(); }
+
+ /// isNullValue - Return true if this is the value that would be returned by
+ /// getNullValue.
+ virtual bool isNullValue() const { return false; }
+
+ virtual void destroyConstant();
+ virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const BlockAddress *) { return true; }
+ static inline bool classof(const Value *V) {
+ return V->getValueID() == BlockAddressVal;
+ }
+};
+
+template <>
+struct OperandTraits<BlockAddress> : public FixedNumOperandTraits<2> {
+};
+DEFINE_TRANSPARENT_CASTED_OPERAND_ACCESSORS(BlockAddress, Constant)
+
+//===----------------------------------------------------------------------===//
/// ConstantExpr - a constant value that is initialized with an expression using
/// other constant values.
///
diff --git a/include/llvm/Value.h b/include/llvm/Value.h
index c09fdfb8a8..b485524b05 100644
--- a/include/llvm/Value.h
+++ b/include/llvm/Value.h
@@ -210,6 +210,7 @@ public:
GlobalAliasVal, // This is an instance of GlobalAlias
GlobalVariableVal, // This is an instance of GlobalVariable
UndefValueVal, // This is an instance of UndefValue
+ BlockAddressVal, // This is an instance of BlockAddress
ConstantExprVal, // This is an instance of ConstantExpr
ConstantAggregateZeroVal, // This is an instance of ConstantAggregateNull
ConstantIntVal, // This is an instance of ConstantInt