diff options
author | Karl Schimpf <kschimpf@google.com> | 2013-07-02 14:36:36 -0700 |
---|---|---|
committer | Karl Schimpf <kschimpf@google.com> | 2013-07-02 14:36:36 -0700 |
commit | 4390b1a9ac86937b9f9886119b5fa0ffc77295eb (patch) | |
tree | 0ed3cbe3018c87f90bb55627066f6bdd5cfae9e0 /lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h | |
parent | bdad02d55969b0963ac23e05578d28def5636ebd (diff) |
Simplify globals in PNaCl wire format based on normalized constants.
Generates simple global variable records, followed by list of records defining
byte initialization and relocations.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3504
R=mseaborn@chromium.org
Review URL: https://codereview.chromium.org/18111002
Diffstat (limited to 'lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h')
-rw-r--r-- | lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h index 9320de92ea..454875796a 100644 --- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h +++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.h @@ -82,13 +82,32 @@ public: // already been declared. bool createValueFwdRef(unsigned Idx, Type *Ty); + // Declares the type of the forward-referenced constant Idx. Returns + // 0 if an error occurred. + // TODO(kschimpf) Convert these to be like createValueFwdRef and + // getValueFwdRef. Constant *getConstantFwdRef(unsigned Idx, Type *Ty); // Gets the forward reference value for Idx. Value *getValueFwdRef(unsigned Idx); + // Gets the corresponding constant defining the address of the + // corresponding global variable defined by Idx, if already defined. + // Otherwise, creates a forward reference for Idx, and returns the + // placeholder constant for the address of the corresponding global + // variable defined by Idx. + Constant *getOrCreateGlobalVarRef(unsigned Idx, Module* M); + + // Assigns Idx to the given value (if new), or assigns V to Idx (if Idx + // was forward referenced). void AssignValue(Value *V, unsigned Idx); + // Assigns Idx to the given global variable. If the Idx currently has + // a forward reference (built by createGlobalVarFwdRef(unsigned Idx)), + // replaces uses of the global variable forward reference with the + // value GV. + void AssignGlobalVar(GlobalVariable *GV, unsigned Idx); + /// ResolveConstantForwardRefs - Once all constants are read, this method bulk /// resolves any forward references. void ResolveConstantForwardRefs(); @@ -114,7 +133,6 @@ class NaClBitcodeReader : public GVMaterializer { SmallVector<Instruction *, 64> InstructionList; SmallVector<SmallVector<uint64_t, 64>, 64> UseListRecords; - std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInits; std::vector<std::pair<GlobalAlias*, unsigned> > AliasInits; /// FunctionBBs - While parsing a function body, this is a list of the basic @@ -259,13 +277,13 @@ private: bool ParseModule(bool Resume); bool ParseTypeTable(); bool ParseTypeTableBody(); - + bool ParseGlobalVars(); bool ParseValueSymbolTable(); bool ParseConstants(); bool RememberAndSkipFunctionBody(); bool ParseFunctionBody(Function *F); bool GlobalCleanup(); - bool ResolveGlobalAndAliasInits(); + bool ResolveAliasInits(); bool ParseUseLists(); bool InitStream(); bool InitStreamFromBuffer(); |