summaryrefslogtreecommitdiff
path: root/lib/Bitcode/Reader/BitcodeReader.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-05-01 07:01:57 +0000
committerChris Lattner <sabre@nondot.org>2007-05-01 07:01:57 +0000
commita7c49aac984fafa5dfdfcc2762d4d51b26788e38 (patch)
tree5d0916dccc6e28efa45e31039aec4af479cb92aa /lib/Bitcode/Reader/BitcodeReader.h
parent6f7c8ffd9a92bdd625c5bc316187a49c0b1d41d6 (diff)
downloadllvm-a7c49aac984fafa5dfdfcc2762d4d51b26788e38.tar.gz
llvm-a7c49aac984fafa5dfdfcc2762d4d51b26788e38.tar.bz2
llvm-a7c49aac984fafa5dfdfcc2762d4d51b26788e38.tar.xz
handle function-level forward references, read binops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36620 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Reader/BitcodeReader.h')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.h b/lib/Bitcode/Reader/BitcodeReader.h
index 65c495b669..36972734e8 100644
--- a/lib/Bitcode/Reader/BitcodeReader.h
+++ b/lib/Bitcode/Reader/BitcodeReader.h
@@ -51,6 +51,22 @@ public:
virtual void print(std::ostream&) const {}
Constant *getConstantFwdRef(unsigned Idx, const Type *Ty);
+ Value *getValueFwdRef(unsigned Idx, const Type *Ty);
+
+ void AssignValue(Value *V, unsigned Idx) {
+ if (Idx == size()) {
+ push_back(V);
+ } else if (Value *OldV = getOperand(Idx)) {
+ // If there was a forward reference to this value, replace it.
+ setOperand(Idx, V);
+ OldV->replaceAllUsesWith(V);
+ delete OldV;
+ } else {
+ initVal(Idx, V);
+ }
+ }
+
+private:
void initVal(unsigned Idx, Value *V) {
assert(Uses[Idx] == 0 && "Cannot init an already init'd Use!");
Uses[Idx].init(V, this);
@@ -113,6 +129,9 @@ public:
bool ParseBitcode();
private:
const Type *getTypeByID(unsigned ID, bool isTypeTable = false);
+ Value *getFnValueByID(unsigned ID, const Type *Ty) {
+ return ValueList.getValueFwdRef(ID, Ty);
+ }
bool ParseModule(const std::string &ModuleID);
bool ParseTypeTable();