mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-02 07:32:52 +00:00
give each Record a location.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66897 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1c8ae59dfd
commit
7b9ffe4a6d
@ -15,15 +15,13 @@
|
|||||||
#ifndef RECORD_H
|
#ifndef RECORD_H
|
||||||
#define RECORD_H
|
#define RECORD_H
|
||||||
|
|
||||||
|
#include "TGSourceMgr.h"
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
// RecTy subclasses.
|
// RecTy subclasses.
|
||||||
class BitRecTy;
|
class BitRecTy;
|
||||||
class BitsRecTy;
|
class BitsRecTy;
|
||||||
@ -962,16 +960,20 @@ inline std::ostream &operator<<(std::ostream &OS, const RecordVal &RV) {
|
|||||||
|
|
||||||
class Record {
|
class Record {
|
||||||
std::string Name;
|
std::string Name;
|
||||||
|
TGLoc Loc;
|
||||||
std::vector<std::string> TemplateArgs;
|
std::vector<std::string> TemplateArgs;
|
||||||
std::vector<RecordVal> Values;
|
std::vector<RecordVal> Values;
|
||||||
std::vector<Record*> SuperClasses;
|
std::vector<Record*> SuperClasses;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit Record(const std::string &N) : Name(N) {}
|
explicit Record(const std::string &N, TGLoc loc) : Name(N), Loc(loc) {}
|
||||||
~Record() {}
|
~Record() {}
|
||||||
|
|
||||||
const std::string &getName() const { return Name; }
|
const std::string &getName() const { return Name; }
|
||||||
void setName(const std::string &Name); // Also updates RecordKeeper.
|
void setName(const std::string &Name); // Also updates RecordKeeper.
|
||||||
|
|
||||||
|
TGLoc getLoc() const { return Loc; }
|
||||||
|
|
||||||
const std::vector<std::string> &getTemplateArgs() const {
|
const std::vector<std::string> &getTemplateArgs() const {
|
||||||
return TemplateArgs;
|
return TemplateArgs;
|
||||||
}
|
}
|
||||||
@ -1198,6 +1200,9 @@ std::ostream &operator<<(std::ostream &OS, const RecordKeeper &RK);
|
|||||||
|
|
||||||
extern RecordKeeper Records;
|
extern RecordKeeper Records;
|
||||||
|
|
||||||
|
void PrintError(TGLoc ErrorLoc, const std::string &Msg);
|
||||||
|
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,7 +27,7 @@ struct MultiClass {
|
|||||||
Record Rec; // Placeholder for template args and Name.
|
Record Rec; // Placeholder for template args and Name.
|
||||||
std::vector<Record*> DefPrototypes;
|
std::vector<Record*> DefPrototypes;
|
||||||
|
|
||||||
MultiClass(const std::string &Name) : Rec(Name) {}
|
MultiClass(const std::string &Name, TGLoc Loc) : Rec(Name, Loc) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SubClassReference {
|
struct SubClassReference {
|
||||||
@ -570,7 +570,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec) {
|
|||||||
|
|
||||||
// Create the new record, set it as CurRec temporarily.
|
// Create the new record, set it as CurRec temporarily.
|
||||||
static unsigned AnonCounter = 0;
|
static unsigned AnonCounter = 0;
|
||||||
Record *NewRec = new Record("anonymous.val."+utostr(AnonCounter++));
|
Record *NewRec = new Record("anonymous.val."+utostr(AnonCounter++),NameLoc);
|
||||||
SubClassReference SCRef;
|
SubClassReference SCRef;
|
||||||
SCRef.RefLoc = NameLoc;
|
SCRef.RefLoc = NameLoc;
|
||||||
SCRef.Rec = Class;
|
SCRef.Rec = Class;
|
||||||
@ -1039,7 +1039,7 @@ llvm::Record *TGParser::ParseDef(MultiClass *CurMultiClass) {
|
|||||||
Lex.Lex(); // Eat the 'def' token.
|
Lex.Lex(); // Eat the 'def' token.
|
||||||
|
|
||||||
// Parse ObjectName and make a record for it.
|
// Parse ObjectName and make a record for it.
|
||||||
Record *CurRec = new Record(ParseObjectName());
|
Record *CurRec = new Record(ParseObjectName(), DefLoc);
|
||||||
|
|
||||||
if (!CurMultiClass) {
|
if (!CurMultiClass) {
|
||||||
// Top-level def definition.
|
// Top-level def definition.
|
||||||
@ -1093,7 +1093,7 @@ bool TGParser::ParseClass() {
|
|||||||
return TokError("Class '" + CurRec->getName() + "' already defined");
|
return TokError("Class '" + CurRec->getName() + "' already defined");
|
||||||
} else {
|
} else {
|
||||||
// If this is the first reference to this class, create and add it.
|
// If this is the first reference to this class, create and add it.
|
||||||
CurRec = new Record(Lex.getCurStrVal());
|
CurRec = new Record(Lex.getCurStrVal(), Lex.getLoc());
|
||||||
Records.addClass(CurRec);
|
Records.addClass(CurRec);
|
||||||
}
|
}
|
||||||
Lex.Lex(); // eat the name.
|
Lex.Lex(); // eat the name.
|
||||||
@ -1232,7 +1232,7 @@ bool TGParser::ParseMultiClass() {
|
|||||||
if (MultiClasses.count(Name))
|
if (MultiClasses.count(Name))
|
||||||
return TokError("multiclass '" + Name + "' already defined");
|
return TokError("multiclass '" + Name + "' already defined");
|
||||||
|
|
||||||
CurMultiClass = MultiClasses[Name] = new MultiClass(Name);
|
CurMultiClass = MultiClasses[Name] = new MultiClass(Name, Lex.getLoc());
|
||||||
Lex.Lex(); // Eat the identifier.
|
Lex.Lex(); // Eat the identifier.
|
||||||
|
|
||||||
// If there are template args, parse them.
|
// If there are template args, parse them.
|
||||||
@ -1299,7 +1299,7 @@ bool TGParser::ParseDefm() {
|
|||||||
Record *DefProto = MC->DefPrototypes[i];
|
Record *DefProto = MC->DefPrototypes[i];
|
||||||
|
|
||||||
// Add the suffix to the defm name to get the new name.
|
// Add the suffix to the defm name to get the new name.
|
||||||
Record *CurRec = new Record(DefmPrefix + DefProto->getName());
|
Record *CurRec = new Record(DefmPrefix + DefProto->getName(),DefmPrefixLoc);
|
||||||
|
|
||||||
SubClassReference Ref;
|
SubClassReference Ref;
|
||||||
Ref.RefLoc = DefmPrefixLoc;
|
Ref.RefLoc = DefmPrefixLoc;
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
#ifndef TGSOURCEMGR_H
|
#ifndef TGSOURCEMGR_H
|
||||||
#define TGSOURCEMGR_H
|
#define TGSOURCEMGR_H
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class MemoryBuffer;
|
class MemoryBuffer;
|
||||||
|
@ -108,8 +108,18 @@ namespace {
|
|||||||
cl::value_desc("directory"), cl::Prefix);
|
cl::value_desc("directory"), cl::Prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FIXME: Eliminate globals from tblgen.
|
||||||
RecordKeeper llvm::Records;
|
RecordKeeper llvm::Records;
|
||||||
|
|
||||||
|
static TGSourceMgr SrcMgr;
|
||||||
|
|
||||||
|
void PrintError(TGLoc ErrorLoc, const std::string &Msg) {
|
||||||
|
SrcMgr.PrintError(ErrorLoc, Msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// ParseFile - this function begins the parsing of the specified tablegen
|
/// ParseFile - this function begins the parsing of the specified tablegen
|
||||||
/// file.
|
/// file.
|
||||||
static bool ParseFile(const std::string &Filename,
|
static bool ParseFile(const std::string &Filename,
|
||||||
@ -139,7 +149,6 @@ int main(int argc, char **argv) {
|
|||||||
PrettyStackTraceProgram X(argc, argv);
|
PrettyStackTraceProgram X(argc, argv);
|
||||||
cl::ParseCommandLineOptions(argc, argv);
|
cl::ParseCommandLineOptions(argc, argv);
|
||||||
|
|
||||||
TGSourceMgr SrcMgr;
|
|
||||||
|
|
||||||
// Parse the input file.
|
// Parse the input file.
|
||||||
if (ParseFile(InputFilename, IncludeDirs, SrcMgr))
|
if (ParseFile(InputFilename, IncludeDirs, SrcMgr))
|
||||||
|
Loading…
Reference in New Issue
Block a user