#define LLVM_ASMPARSER_LLPARSER_H
#include "LLLexer.h"
+#include "llvm/Module.h"
#include "llvm/Type.h"
#include <map>
class Instruction;
class Constant;
class GlobalValue;
+ class MetadataBase;
class MDString;
class MDNode;
struct ValID;
public:
typedef LLLexer::LocTy LocTy;
private:
-
+ LLVMContext& Context;
LLLexer Lex;
Module *M;
std::map<unsigned, std::pair<PATypeHolder, LocTy> > ForwardRefTypeIDs;
std::vector<PATypeHolder> NumberedTypes;
/// MetadataCache - This map keeps track of parsed metadata constants.
- std::map<unsigned, Constant *> MetadataCache;
+ std::map<unsigned, MetadataBase *> MetadataCache;
+ std::map<unsigned, std::pair<MetadataBase *, LocTy> > ForwardRefMDNodes;
+ SmallVector<std::pair<unsigned, MDNode *>, 2> MDsOnInst;
struct UpRefRecord {
/// Loc - This is the location of the upref.
LocTy Loc;
std::map<unsigned, std::pair<GlobalValue*, LocTy> > ForwardRefValIDs;
std::vector<GlobalValue*> NumberedVals;
public:
- LLParser(MemoryBuffer *F, ParseError &Err, Module *m) : Lex(F, Err), M(m) {}
+ LLParser(MemoryBuffer *F, SourceMgr &SM, SMDiagnostic &Err, Module *m) :
+ Context(m->getContext()), Lex(F, SM, Err, m->getContext()), M(m) {}
bool Run();
+ LLVMContext& getContext() { return Context; }
+
private:
bool Error(LocTy L, const std::string &Msg) const {
bool HasLinkage; return ParseOptionalLinkage(Linkage, HasLinkage);
}
bool ParseOptionalVisibility(unsigned &Visibility);
- bool ParseOptionalCallingConv(unsigned &CC);
+ bool ParseOptionalCallingConv(CallingConv::ID &CC);
bool ParseOptionalAlignment(unsigned &Alignment);
- bool ParseOptionalCommaAlignment(unsigned &Alignment);
+ bool ParseOptionalCustomMetadata();
+ bool ParseOptionalInfo(unsigned &Alignment);
bool ParseIndexList(SmallVectorImpl<unsigned> &Indices);
// Top-Level Entities
bool ParseDefine();
bool ParseGlobalType(bool &IsConstant);
+ bool ParseUnnamedGlobal();
bool ParseNamedGlobal();
bool ParseGlobal(const std::string &Name, LocTy Loc, unsigned Linkage,
bool HasLinkage, unsigned Visibility);
bool ParseAlias(const std::string &Name, LocTy Loc, unsigned Visibility);
bool ParseStandaloneMetadata();
+ bool ParseNamedMetadata();
+ bool ParseMDString(MetadataBase *&S);
+ bool ParseMDNode(MetadataBase *&N);
// Type Parsing.
bool ParseType(PATypeHolder &Result, bool AllowVoid = false);