[llvm-commits] [llvm] r66897 - in /llvm/trunk/utils/TableGen: Record.h TGParser.cpp TGSourceMgr.h TableGen.cpp
Chris Lattner
sabre at nondot.org
Fri Mar 13 09:09:24 PDT 2009
Author: lattner
Date: Fri Mar 13 11:09:24 2009
New Revision: 66897
URL: http://llvm.org/viewvc/llvm-project?rev=66897&view=rev
Log:
give each Record a location.
Modified:
llvm/trunk/utils/TableGen/Record.h
llvm/trunk/utils/TableGen/TGParser.cpp
llvm/trunk/utils/TableGen/TGSourceMgr.h
llvm/trunk/utils/TableGen/TableGen.cpp
Modified: llvm/trunk/utils/TableGen/Record.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.h?rev=66897&r1=66896&r2=66897&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.h (original)
+++ llvm/trunk/utils/TableGen/Record.h Fri Mar 13 11:09:24 2009
@@ -15,15 +15,13 @@
#ifndef RECORD_H
#define RECORD_H
+#include "TGSourceMgr.h"
#include "llvm/Support/DataTypes.h"
-#include <string>
-#include <vector>
#include <map>
#include <ostream>
-#include <cassert>
namespace llvm {
-
+
// RecTy subclasses.
class BitRecTy;
class BitsRecTy;
@@ -962,16 +960,20 @@
class Record {
std::string Name;
+ TGLoc Loc;
std::vector<std::string> TemplateArgs;
std::vector<RecordVal> Values;
std::vector<Record*> SuperClasses;
public:
- explicit Record(const std::string &N) : Name(N) {}
+ explicit Record(const std::string &N, TGLoc loc) : Name(N), Loc(loc) {}
~Record() {}
-
+
const std::string &getName() const { return Name; }
void setName(const std::string &Name); // Also updates RecordKeeper.
+
+ TGLoc getLoc() const { return Loc; }
+
const std::vector<std::string> &getTemplateArgs() const {
return TemplateArgs;
}
@@ -1198,6 +1200,9 @@
extern RecordKeeper Records;
+void PrintError(TGLoc ErrorLoc, const std::string &Msg);
+
+
} // End llvm namespace
#endif
Modified: llvm/trunk/utils/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.cpp?rev=66897&r1=66896&r2=66897&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/TGParser.cpp (original)
+++ llvm/trunk/utils/TableGen/TGParser.cpp Fri Mar 13 11:09:24 2009
@@ -27,7 +27,7 @@
Record Rec; // Placeholder for template args and Name.
std::vector<Record*> DefPrototypes;
- MultiClass(const std::string &Name) : Rec(Name) {}
+ MultiClass(const std::string &Name, TGLoc Loc) : Rec(Name, Loc) {}
};
struct SubClassReference {
@@ -570,7 +570,7 @@
// Create the new record, set it as CurRec temporarily.
static unsigned AnonCounter = 0;
- Record *NewRec = new Record("anonymous.val."+utostr(AnonCounter++));
+ Record *NewRec = new Record("anonymous.val."+utostr(AnonCounter++),NameLoc);
SubClassReference SCRef;
SCRef.RefLoc = NameLoc;
SCRef.Rec = Class;
@@ -1039,7 +1039,7 @@
Lex.Lex(); // Eat the 'def' token.
// Parse ObjectName and make a record for it.
- Record *CurRec = new Record(ParseObjectName());
+ Record *CurRec = new Record(ParseObjectName(), DefLoc);
if (!CurMultiClass) {
// Top-level def definition.
@@ -1093,7 +1093,7 @@
return TokError("Class '" + CurRec->getName() + "' already defined");
} else {
// 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);
}
Lex.Lex(); // eat the name.
@@ -1232,7 +1232,7 @@
if (MultiClasses.count(Name))
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.
// If there are template args, parse them.
@@ -1299,7 +1299,7 @@
Record *DefProto = MC->DefPrototypes[i];
// 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;
Ref.RefLoc = DefmPrefixLoc;
Modified: llvm/trunk/utils/TableGen/TGSourceMgr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGSourceMgr.h?rev=66897&r1=66896&r2=66897&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/TGSourceMgr.h (original)
+++ llvm/trunk/utils/TableGen/TGSourceMgr.h Fri Mar 13 11:09:24 2009
@@ -14,9 +14,9 @@
#ifndef TGSOURCEMGR_H
#define TGSOURCEMGR_H
-#include <cassert>
-#include <vector>
#include <string>
+#include <vector>
+#include <cassert>
namespace llvm {
class MemoryBuffer;
Modified: llvm/trunk/utils/TableGen/TableGen.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=66897&r1=66896&r2=66897&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/TableGen.cpp (original)
+++ llvm/trunk/utils/TableGen/TableGen.cpp Fri Mar 13 11:09:24 2009
@@ -108,8 +108,18 @@
cl::value_desc("directory"), cl::Prefix);
}
+
+// FIXME: Eliminate globals from tblgen.
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
/// file.
static bool ParseFile(const std::string &Filename,
@@ -139,7 +149,6 @@
PrettyStackTraceProgram X(argc, argv);
cl::ParseCommandLineOptions(argc, argv);
- TGSourceMgr SrcMgr;
// Parse the input file.
if (ParseFile(InputFilename, IncludeDirs, SrcMgr))
More information about the llvm-commits
mailing list