summaryrefslogtreecommitdiff
path: root/lib/AsmParser/LLParser.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-28 03:39:23 +0000
committerChris Lattner <sabre@nondot.org>2009-10-28 03:39:23 +0000
commit09d9ef4122414a1a2ec95f52d660d6500f2819d0 (patch)
treef6c1df9220f5a87d7d0b774d61d41a9fba48af40 /lib/AsmParser/LLParser.h
parent73050e1c383100d879597f5d4ef8260bb1d6f07c (diff)
downloadllvm-09d9ef4122414a1a2ec95f52d660d6500f2819d0.tar.gz
llvm-09d9ef4122414a1a2ec95f52d660d6500f2819d0.tar.bz2
llvm-09d9ef4122414a1a2ec95f52d660d6500f2819d0.tar.xz
full asmparser support for blockaddress. We can now do:
$ llvm-as foo.ll -d -disable-output which reads and prints the .ll file. BC encoding is the next project. Testcase will go in once that works. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85368 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/LLParser.h')
-rw-r--r--lib/AsmParser/LLParser.h55
1 files changed, 51 insertions, 4 deletions
diff --git a/lib/AsmParser/LLParser.h b/lib/AsmParser/LLParser.h
index ca2e2b695f..d60bceacb6 100644
--- a/lib/AsmParser/LLParser.h
+++ b/lib/AsmParser/LLParser.h
@@ -31,8 +31,41 @@ namespace llvm {
class MetadataBase;
class MDString;
class MDNode;
- struct ValID;
+ /// ValID - Represents a reference of a definition of some sort with no type.
+ /// There are several cases where we have to parse the value but where the
+ /// type can depend on later context. This may either be a numeric reference
+ /// or a symbolic (%var) reference. This is just a discriminated union.
+ struct ValID {
+ enum {
+ t_LocalID, t_GlobalID, // ID in UIntVal.
+ t_LocalName, t_GlobalName, // Name in StrVal.
+ t_APSInt, t_APFloat, // Value in APSIntVal/APFloatVal.
+ t_Null, t_Undef, t_Zero, // No value.
+ t_EmptyArray, // No value: []
+ t_Constant, // Value in ConstantVal.
+ t_InlineAsm, // Value in StrVal/StrVal2/UIntVal.
+ t_Metadata // Value in MetadataVal.
+ } Kind;
+
+ LLLexer::LocTy Loc;
+ unsigned UIntVal;
+ std::string StrVal, StrVal2;
+ APSInt APSIntVal;
+ APFloat APFloatVal;
+ Constant *ConstantVal;
+ MetadataBase *MetadataVal;
+ ValID() : APFloatVal(0.0) {}
+
+ bool operator<(const ValID &RHS) const {
+ if (Kind == t_LocalID || Kind == t_GlobalID)
+ return UIntVal < RHS.UIntVal;
+ assert((Kind == t_LocalName || Kind == t_GlobalName) &&
+ "Ordering not defined for this ValID kind yet");
+ return StrVal < RHS.StrVal;
+ }
+ };
+
class LLParser {
public:
typedef LLLexer::LocTy LocTy;
@@ -75,7 +108,13 @@ namespace llvm {
std::map<std::string, std::pair<GlobalValue*, LocTy> > ForwardRefVals;
std::map<unsigned, std::pair<GlobalValue*, LocTy> > ForwardRefValIDs;
std::vector<GlobalValue*> NumberedVals;
- Function* MallocF;
+
+ // References to blockaddress. The key is the function ValID, the value is
+ // a list of references to blocks in that function.
+ std::map<ValID, std::vector<std::pair<ValID, GlobalValue*> > >
+ ForwardRefBlockAddresses;
+
+ Function *MallocF;
public:
LLParser(MemoryBuffer *F, SourceMgr &SM, SMDiagnostic &Err, Module *m) :
Context(m->getContext()), Lex(F, SM, Err, m->getContext()),
@@ -184,13 +223,17 @@ namespace llvm {
std::map<std::string, std::pair<Value*, LocTy> > ForwardRefVals;
std::map<unsigned, std::pair<Value*, LocTy> > ForwardRefValIDs;
std::vector<Value*> NumberedVals;
+
+ /// FunctionNumber - If this is an unnamed function, this is the slot
+ /// number of it, otherwise it is -1.
+ int FunctionNumber;
public:
- PerFunctionState(LLParser &p, Function &f);
+ PerFunctionState(LLParser &p, Function &f, int FunctionNumber);
~PerFunctionState();
Function &getFunction() const { return F; }
- bool VerifyFunctionComplete();
+ bool FinishFunction();
/// GetVal - Get a value with the specified name or ID, creating a
/// forward reference record if needed. This can return null if the value
@@ -294,6 +337,10 @@ namespace llvm {
bool ParseGetElementPtr(Instruction *&I, PerFunctionState &PFS);
bool ParseExtractValue(Instruction *&I, PerFunctionState &PFS);
bool ParseInsertValue(Instruction *&I, PerFunctionState &PFS);
+
+ bool ResolveForwardRefBlockAddresses(Function *TheFn,
+ std::vector<std::pair<ValID, GlobalValue*> > &Refs,
+ PerFunctionState *PFS);
};
} // End llvm namespace