X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=utils%2FTableGen%2FTGParser.h;h=9f4b634606475504049ecd34fec3b3e57f1a1c0a;hb=2214dc07649d36e47d11914e1ffc7c56eb40ad73;hp=6ec0415a57a61d3d53fda0ec8d70100ce5de3486;hpb=f460165a4c1bf4bc762f9b3f12b9ed284b89cc99;p=oota-llvm.git diff --git a/utils/TableGen/TGParser.h b/utils/TableGen/TGParser.h index 6ec0415a57a..9f4b6346064 100644 --- a/utils/TableGen/TGParser.h +++ b/utils/TableGen/TGParser.h @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by Chris Lattner and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -15,23 +15,25 @@ #define TGPARSER_H #include "TGLexer.h" +#include "llvm/Support/SourceMgr.h" #include namespace llvm { class Record; class RecordVal; - class RecTy; - class Init; + struct RecTy; + struct Init; struct MultiClass; struct SubClassReference; + struct SubMultiClassReference; struct LetRecord { std::string Name; std::vector Bits; Init *Value; - TGLexer::LocTy Loc; + SMLoc Loc; LetRecord(const std::string &N, const std::vector &B, Init *V, - TGLexer::LocTy L) + SMLoc L) : Name(N), Bits(B), Value(V), Loc(L) { } }; @@ -45,17 +47,13 @@ class TGParser { /// current value. MultiClass *CurMultiClass; public: - typedef TGLexer::LocTy LocTy; + TGParser(SourceMgr &SrcMgr) : Lex(SrcMgr), CurMultiClass(0) {} - TGParser(MemoryBuffer *StartBuf) : Lex(StartBuf), CurMultiClass(0) {} - - void setIncludeDirs(const std::vector &D){Lex.setIncludeDirs(D);} - /// ParseFile - Main entrypoint for parsing a tblgen file. These parser /// routines return true on error, or false on success. bool ParseFile(); - bool Error(LocTy L, const std::string &Msg) const { + bool Error(SMLoc L, const std::string &Msg) const { Lex.PrintError(L, Msg); return true; } @@ -63,10 +61,12 @@ public: return Error(Lex.getLoc(), Msg); } private: // Semantic analysis methods. - bool AddValue(Record *TheRec, LocTy Loc, const RecordVal &RV); - bool SetValue(Record *TheRec, LocTy Loc, const std::string &ValName, + bool AddValue(Record *TheRec, SMLoc Loc, const RecordVal &RV); + bool SetValue(Record *TheRec, SMLoc Loc, const std::string &ValName, const std::vector &BitList, Init *V); - bool AddSubClass(Record *Rec, class SubClassReference &SubClass); + bool AddSubClass(Record *Rec, SubClassReference &SubClass); + bool AddSubMultiClass(MultiClass *CurMC, + SubMultiClassReference &SubMultiClass); private: // Parser methods. bool ParseObjectList(); @@ -87,20 +87,24 @@ private: // Parser methods. std::string ParseDeclaration(Record *CurRec, bool ParsingTemplateArgs); SubClassReference ParseSubClassReference(Record *CurRec, bool isDefm); + SubMultiClassReference ParseSubMultiClassReference(MultiClass *CurMC); Init *ParseIDValue(Record *CurRec); - Init *ParseIDValue(Record *CurRec, const std::string &Name, LocTy NameLoc); - Init *ParseSimpleValue(Record *CurRec); - Init *ParseValue(Record *CurRec); - std::vector ParseValueList(Record *CurRec); + Init *ParseIDValue(Record *CurRec, const std::string &Name, SMLoc NameLoc); + Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = 0); + Init *ParseValue(Record *CurRec, RecTy *ItemType = 0); + std::vector ParseValueList(Record *CurRec, Record *ArgsRec = 0, RecTy *EltTy = 0); std::vector > ParseDagArgList(Record *); bool ParseOptionalRangeList(std::vector &Ranges); bool ParseOptionalBitList(std::vector &Ranges); std::vector ParseRangeList(); bool ParseRangePiece(std::vector &Ranges); RecTy *ParseType(); + Init *ParseOperation(Record *CurRec); + RecTy *ParseOperatorType(); std::string ParseObjectName(); Record *ParseClassID(); + MultiClass *ParseMultiClassID(); Record *ParseDefmID(); };