summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-06-22 08:08:12 +0000
committered <ed@FreeBSD.org>2009-06-22 08:08:12 +0000
commita4c19d68f13cf0a83bc0da53bd6d547fcaf635fe (patch)
tree86c1bc482baa6c81fc70b8d715153bfa93377186 /utils
parentdb89e312d968c258aba3c79c1c398f5fb19267a3 (diff)
downloadFreeBSD-src-a4c19d68f13cf0a83bc0da53bd6d547fcaf635fe.zip
FreeBSD-src-a4c19d68f13cf0a83bc0da53bd6d547fcaf635fe.tar.gz
Update LLVM sources to r73879.
Diffstat (limited to 'utils')
-rwxr-xr-xutils/NewNightlyTest.pl58
-rw-r--r--utils/TableGen/AsmWriterEmitter.cpp6
-rw-r--r--utils/TableGen/CMakeLists.txt1
-rw-r--r--utils/TableGen/CodeGenDAGPatterns.cpp6
-rw-r--r--utils/TableGen/Record.h18
-rw-r--r--utils/TableGen/TGLexer.cpp44
-rw-r--r--utils/TableGen/TGLexer.h20
-rw-r--r--utils/TableGen/TGParser.cpp40
-rw-r--r--utils/TableGen/TGParser.h18
-rw-r--r--utils/TableGen/TGSourceMgr.cpp105
-rw-r--r--utils/TableGen/TGSourceMgr.h106
-rw-r--r--utils/TableGen/TableGen.cpp16
12 files changed, 97 insertions, 341 deletions
diff --git a/utils/NewNightlyTest.pl b/utils/NewNightlyTest.pl
index feac974..00d4038 100755
--- a/utils/NewNightlyTest.pl
+++ b/utils/NewNightlyTest.pl
@@ -1,6 +1,7 @@
#!/usr/bin/perl
use POSIX qw(strftime);
use File::Copy;
+use File::Find;
use Socket;
#
@@ -99,6 +100,8 @@ use Socket;
my $HOME = $ENV{'HOME'};
my $SVNURL = $ENV{"SVNURL"};
$SVNURL = 'http://llvm.org/svn/llvm-project' unless $SVNURL;
+my $TestSVNURL = $ENV{"TestSVNURL"};
+$TestSVNURL = 'https://llvm.org/svn/llvm-project' unless $TestSVNURL;
my $CVSRootDir = $ENV{'CVSROOT'};
$CVSRootDir = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
my $BuildDir = $ENV{'BUILDDIR'};
@@ -537,19 +540,20 @@ if (!$NOCHECKOUT) {
if ( $VERBOSE ) { print "CHECKOUT STAGE:\n"; }
if ($USESVN) {
my $SVNCMD = "$NICE svn co --non-interactive $SVNURL";
+ my $SVNCMD2 = "$NICE svn co --non-interactive $TestSVNURL";
if ($VERBOSE) {
print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
- "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
+ "$SVNCMD2/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
}
system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
- "$SVNCMD/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
- if ($WITHCLANG) {
- my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
- if ($VERBOSE) {
- print "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n";
- }
- system "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n";
- }
+ "$SVNCMD2/test-suite/trunk llvm-test ) > $COLog 2>&1\n";
+ if ($WITHCLANG) {
+ my $SVNCMD = "$NICE svn co --non-interactive $SVNURL/cfe/trunk";
+ if ($VERBOSE) {
+ print "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n";
+ }
+ system "( time -p cd llvm/tools ; $SVNCMD clang ) > $COLog 2>&1\n";
+ }
} else {
my $CVSOPT = "";
$CVSOPT = "-z3" # Use compression if going over ssh.
@@ -784,40 +788,20 @@ if (!$BuildError) {
print "Organizing size of .o and .a files\n"
if ( $VERBOSE );
ChangeDir( "$BuildDir/llvm", "Build Directory" );
- $afiles.= `find utils/ -iname '*.a' -ls`;
- $afiles.= `find lib/ -iname '*.a' -ls`;
- $afiles.= `find tools/ -iname '*.a' -ls`;
- if($BUILDTYPE eq "release"){
- $afiles.= `find Release/ -iname '*.a' -ls`;
- } elsif($BUILDTYPE eq "release-asserts") {
- $afiles.= `find Release-Asserts/ -iname '*.a' -ls`;
- } else {
- $afiles.= `find Debug/ -iname '*.a' -ls`;
- }
- $ofiles.= `find utils/ -iname '*.o' -ls`;
- $ofiles.= `find lib/ -iname '*.o' -ls`;
- $ofiles.= `find tools/ -iname '*.o' -ls`;
+ my @dirs = ('utils', 'lib', 'tools');
if($BUILDTYPE eq "release"){
- $ofiles.= `find Release/ -iname '*.o' -ls`;
+ push @dirs, 'Release';
} elsif($BUILDTYPE eq "release-asserts") {
- $ofiles.= `find Release-Asserts/ -iname '*.o' -ls`;
+ push @dirs, 'Release-Asserts';
} else {
- $ofiles.= `find Debug/ -iname '*.o' -ls`;
+ push @dirs, 'Debug';
}
- @AFILES = split "\n", $afiles;
- $a_file_sizes="";
- foreach $x (@AFILES){
- $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
- $a_file_sizes.="$1 $2 $BUILDTYPE\n";
- }
- @OFILES = split "\n", $ofiles;
- $o_file_sizes="";
- foreach $x (@OFILES){
- $x =~ m/.+\s+.+\s+.+\s+.+\s+.+\s+.+\s+(.+)\s+.+\s+.+\s+.+\s+(.+)/;
- $o_file_sizes.="$1 $2 $BUILDTYPE\n";
- }
+ find(sub {
+ $a_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.a$/i;
+ $o_file_sizes .= (-s $_)." $File::Find::name $BUILDTYPE\n" if /\.o$/i;
+ }, @dirs);
} else {
$a_file_sizes="No data due to a bad build.";
$o_file_sizes="No data due to a bad build.";
diff --git a/utils/TableGen/AsmWriterEmitter.cpp b/utils/TableGen/AsmWriterEmitter.cpp
index c615aba..183c691 100644
--- a/utils/TableGen/AsmWriterEmitter.cpp
+++ b/utils/TableGen/AsmWriterEmitter.cpp
@@ -651,6 +651,8 @@ void AsmWriterEmitter::run(std::ostream &O) {
O << " processDebugLoc(MI->getDebugLoc());\n\n";
+ O << "\n#ifndef NO_ASM_WRITER_BOILERPLATE\n";
+
O << " if (MI->getOpcode() == TargetInstrInfo::INLINEASM) {\n"
<< " O << \"\\t\";\n"
<< " printInlineAsm(MI);\n"
@@ -665,7 +667,9 @@ void AsmWriterEmitter::run(std::ostream &O) {
<< " printImplicitDef(MI);\n"
<< " return true;\n"
<< " }\n\n";
-
+
+ O << "\n#endif\n";
+
O << " O << \"\\t\";\n\n";
O << " // Emit the opcode for the instruction.\n"
diff --git a/utils/TableGen/CMakeLists.txt b/utils/TableGen/CMakeLists.txt
index 3f982e0..6ec1d99 100644
--- a/utils/TableGen/CMakeLists.txt
+++ b/utils/TableGen/CMakeLists.txt
@@ -17,7 +17,6 @@ add_executable(tblgen
SubtargetEmitter.cpp
TGLexer.cpp
TGParser.cpp
- TGSourceMgr.cpp
TGValueTypes.cpp
TableGen.cpp
TableGenBackend.cpp
diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp
index e668468..839059d 100644
--- a/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -720,7 +720,7 @@ TreePatternNode *TreePatternNode::InlinePatternFragments(TreePattern &TP) {
}
/// getImplicitType - Check to see if the specified record has an implicit
-/// type which should be applied to it. This infer the type of register
+/// type which should be applied to it. This will infer the type of register
/// references from the register file information, for example.
///
static std::vector<unsigned char> getImplicitType(Record *R, bool NotRegisters,
@@ -833,8 +833,8 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
getEnumName(getTypeNum(0)) + "'!");
}
}
- }
- }
+ }
+ }
}
return MadeChange;
diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h
index ac06cae..5f45ea0 100644
--- a/utils/TableGen/Record.h
+++ b/utils/TableGen/Record.h
@@ -15,7 +15,7 @@
#ifndef RECORD_H
#define RECORD_H
-#include "TGSourceMgr.h"
+#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/DataTypes.h"
#include <map>
#include <ostream>
@@ -1214,19 +1214,19 @@ inline std::ostream &operator<<(std::ostream &OS, const RecordVal &RV) {
class Record {
std::string Name;
- TGLoc Loc;
+ SMLoc Loc;
std::vector<std::string> TemplateArgs;
std::vector<RecordVal> Values;
std::vector<Record*> SuperClasses;
public:
- explicit Record(const std::string &N, TGLoc loc) : Name(N), Loc(loc) {}
+ explicit Record(const std::string &N, SMLoc 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; }
+ SMLoc getLoc() const { return Loc; }
const std::vector<std::string> &getTemplateArgs() const {
return TemplateArgs;
@@ -1381,7 +1381,7 @@ struct MultiClass {
void dump() const;
- MultiClass(const std::string &Name, TGLoc Loc) : Rec(Name, Loc) {}
+ MultiClass(const std::string &Name, SMLoc Loc) : Rec(Name, Loc) {}
};
class RecordKeeper {
@@ -1461,12 +1461,12 @@ struct LessRecordFieldName {
class TGError {
- TGLoc Loc;
+ SMLoc Loc;
std::string Message;
public:
- TGError(TGLoc loc, const std::string &message) : Loc(loc), Message(message) {}
+ TGError(SMLoc loc, const std::string &message) : Loc(loc), Message(message) {}
- TGLoc getLoc() const { return Loc; }
+ SMLoc getLoc() const { return Loc; }
const std::string &getMessage() const { return Message; }
};
@@ -1475,7 +1475,7 @@ std::ostream &operator<<(std::ostream &OS, const RecordKeeper &RK);
extern RecordKeeper Records;
-void PrintError(TGLoc ErrorLoc, const std::string &Msg);
+void PrintError(SMLoc ErrorLoc, const std::string &Msg);
} // End llvm namespace
diff --git a/utils/TableGen/TGLexer.cpp b/utils/TableGen/TGLexer.cpp
index 758d499..6fe8d82 100644
--- a/utils/TableGen/TGLexer.cpp
+++ b/utils/TableGen/TGLexer.cpp
@@ -12,10 +12,9 @@
//===----------------------------------------------------------------------===//
#include "TGLexer.h"
-#include "TGSourceMgr.h"
+#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/Streams.h"
#include "llvm/Support/MemoryBuffer.h"
-#include <ostream>
#include "llvm/Config/config.h"
#include <cctype>
#include <cstdio>
@@ -24,15 +23,15 @@
#include <cerrno>
using namespace llvm;
-TGLexer::TGLexer(TGSourceMgr &SM) : SrcMgr(SM) {
+TGLexer::TGLexer(SourceMgr &SM) : SrcMgr(SM) {
CurBuffer = 0;
CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
CurPtr = CurBuf->getBufferStart();
TokStart = 0;
}
-TGLoc TGLexer::getLoc() const {
- return TGLoc::getFromPointer(TokStart);
+SMLoc TGLexer::getLoc() const {
+ return SMLoc::getFromPointer(TokStart);
}
@@ -45,11 +44,11 @@ tgtok::TokKind TGLexer::ReturnError(const char *Loc, const std::string &Msg) {
void TGLexer::PrintError(const char *Loc, const std::string &Msg) const {
- SrcMgr.PrintError(TGLoc::getFromPointer(Loc), Msg);
+ SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg);
}
-void TGLexer::PrintError(TGLoc Loc, const std::string &Msg) const {
- SrcMgr.PrintError(Loc, Msg);
+void TGLexer::PrintError(SMLoc Loc, const std::string &Msg) const {
+ SrcMgr.PrintMessage(Loc, Msg);
}
@@ -66,8 +65,8 @@ int TGLexer::getNextChar() {
// If this is the end of an included file, pop the parent file off the
// include stack.
- TGLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer);
- if (ParentIncludeLoc != TGLoc()) {
+ SMLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer);
+ if (ParentIncludeLoc != SMLoc()) {
CurBuffer = SrcMgr.FindBufferContainingLoc(ParentIncludeLoc);
CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
CurPtr = ParentIncludeLoc.getPointer();
@@ -278,24 +277,15 @@ bool TGLexer::LexInclude() {
// Get the string.
std::string Filename = CurStrVal;
- // Try to find the file.
- MemoryBuffer *NewBuf = MemoryBuffer::getFile(Filename.c_str());
-
- // If the file didn't exist directly, see if it's in an include path.
- for (unsigned i = 0, e = IncludeDirectories.size(); i != e && !NewBuf; ++i) {
- std::string IncFile = IncludeDirectories[i] + "/" + Filename;
- NewBuf = MemoryBuffer::getFile(IncFile.c_str());
- }
-
- if (NewBuf == 0) {
+
+ CurBuffer = SrcMgr.AddIncludeFile(Filename, SMLoc::getFromPointer(CurPtr));
+ if (CurBuffer == -1) {
PrintError(getLoc(), "Could not find include file '" + Filename + "'");
return true;
}
// Save the line number and lex buffer of the includer.
- CurBuffer = SrcMgr.AddNewSourceBuffer(NewBuf, TGLoc::getFromPointer(CurPtr));
-
- CurBuf = NewBuf;
+ CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
CurPtr = CurBuf->getBufferStart();
return false;
}
@@ -362,19 +352,19 @@ tgtok::TokKind TGLexer::LexNumber() {
// Requires at least one hex digit.
if (CurPtr == NumStart)
- return ReturnError(CurPtr-2, "Invalid hexadecimal number");
+ return ReturnError(TokStart, "Invalid hexadecimal number");
errno = 0;
CurIntVal = strtoll(NumStart, 0, 16);
if (errno == EINVAL)
- return ReturnError(CurPtr-2, "Invalid hexadecimal number");
+ return ReturnError(TokStart, "Invalid hexadecimal number");
if (errno == ERANGE) {
errno = 0;
CurIntVal = (int64_t)strtoull(NumStart, 0, 16);
if (errno == EINVAL)
- return ReturnError(CurPtr-2, "Invalid hexadecimal number");
+ return ReturnError(TokStart, "Invalid hexadecimal number");
if (errno == ERANGE)
- return ReturnError(CurPtr-2, "Hexadecimal number out of range");
+ return ReturnError(TokStart, "Hexadecimal number out of range");
}
return tgtok::IntVal;
} else if (CurPtr[0] == 'b') {
diff --git a/utils/TableGen/TGLexer.h b/utils/TableGen/TGLexer.h
index ac3b984..80405ac 100644
--- a/utils/TableGen/TGLexer.h
+++ b/utils/TableGen/TGLexer.h
@@ -17,13 +17,12 @@
#include "llvm/Support/DataTypes.h"
#include <vector>
#include <string>
-#include <iosfwd>
#include <cassert>
namespace llvm {
class MemoryBuffer;
-class TGSourceMgr;
-class TGLoc;
+class SourceMgr;
+class SMLoc;
namespace tgtok {
enum TokKind {
@@ -58,7 +57,7 @@ namespace tgtok {
/// TGLexer - TableGen Lexer class.
class TGLexer {
- TGSourceMgr &SrcMgr;
+ SourceMgr &SrcMgr;
const char *CurPtr;
const MemoryBuffer *CurBuf;
@@ -73,17 +72,10 @@ class TGLexer {
/// by the SourceMgr object.
int CurBuffer;
- // IncludeDirectories - This is the list of directories we should search for
- // include files in.
- std::vector<std::string> IncludeDirectories;
public:
- TGLexer(TGSourceMgr &SrcMgr);
+ TGLexer(SourceMgr &SrcMgr);
~TGLexer() {}
- void setIncludeDirs(const std::vector<std::string> &Dirs) {
- IncludeDirectories = Dirs;
- }
-
tgtok::TokKind Lex() {
return CurCode = LexToken();
}
@@ -101,10 +93,10 @@ public:
return CurIntVal;
}
- TGLoc getLoc() const;
+ SMLoc getLoc() const;
void PrintError(const char *Loc, const std::string &Msg) const;
- void PrintError(TGLoc Loc, const std::string &Msg) const;
+ void PrintError(SMLoc Loc, const std::string &Msg) const;
private:
/// LexToken - Read the next token and return its code.
diff --git a/utils/TableGen/TGParser.cpp b/utils/TableGen/TGParser.cpp
index cdd2857..28ebdb5 100644
--- a/utils/TableGen/TGParser.cpp
+++ b/utils/TableGen/TGParser.cpp
@@ -26,7 +26,7 @@ using namespace llvm;
namespace llvm {
struct SubClassReference {
- TGLoc RefLoc;
+ SMLoc RefLoc;
Record *Rec;
std::vector<Init*> TemplateArgs;
SubClassReference() : Rec(0) {}
@@ -35,7 +35,7 @@ struct SubClassReference {
};
struct SubMultiClassReference {
- TGLoc RefLoc;
+ SMLoc RefLoc;
MultiClass *MC;
std::vector<Init*> TemplateArgs;
SubMultiClassReference() : MC(0) {}
@@ -60,7 +60,7 @@ void SubMultiClassReference::dump() const {
} // end namespace llvm
-bool TGParser::AddValue(Record *CurRec, TGLoc Loc, const RecordVal &RV) {
+bool TGParser::AddValue(Record *CurRec, SMLoc Loc, const RecordVal &RV) {
if (CurRec == 0)
CurRec = &CurMultiClass->Rec;
@@ -79,7 +79,7 @@ bool TGParser::AddValue(Record *CurRec, TGLoc Loc, const RecordVal &RV) {
/// SetValue -
/// Return true on error, false on success.
-bool TGParser::SetValue(Record *CurRec, TGLoc Loc, const std::string &ValName,
+bool TGParser::SetValue(Record *CurRec, SMLoc Loc, const std::string &ValName,
const std::vector<unsigned> &BitList, Init *V) {
if (!V) return false;
@@ -527,7 +527,7 @@ bool TGParser::ParseOptionalRangeList(std::vector<unsigned> &Ranges) {
if (Lex.getCode() != tgtok::less)
return false;
- TGLoc StartLoc = Lex.getLoc();
+ SMLoc StartLoc = Lex.getLoc();
Lex.Lex(); // eat the '<'
// Parse the range list.
@@ -549,7 +549,7 @@ bool TGParser::ParseOptionalBitList(std::vector<unsigned> &Ranges) {
if (Lex.getCode() != tgtok::l_brace)
return false;
- TGLoc StartLoc = Lex.getLoc();
+ SMLoc StartLoc = Lex.getLoc();
Lex.Lex(); // eat the '{'
// Parse the range list.
@@ -634,7 +634,7 @@ RecTy *TGParser::ParseType() {
Init *TGParser::ParseIDValue(Record *CurRec) {
assert(Lex.getCode() == tgtok::Id && "Expected ID in ParseIDValue");
std::string Name = Lex.getCurStrVal();
- TGLoc Loc = Lex.getLoc();
+ SMLoc Loc = Lex.getLoc();
Lex.Lex();
return ParseIDValue(CurRec, Name, Loc);
}
@@ -642,7 +642,7 @@ Init *TGParser::ParseIDValue(Record *CurRec) {
/// ParseIDValue - This is just like ParseIDValue above, but it assumes the ID
/// has already been read.
Init *TGParser::ParseIDValue(Record *CurRec,
- const std::string &Name, TGLoc NameLoc) {
+ const std::string &Name, SMLoc NameLoc) {
if (CurRec) {
if (const RecordVal *RV = CurRec->getValue(Name))
return new VarInit(Name, RV->getType());
@@ -1041,7 +1041,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
R = new CodeInit(Lex.getCurStrVal()); Lex.Lex(); break;
case tgtok::question: R = new UnsetInit(); Lex.Lex(); break;
case tgtok::Id: {
- TGLoc NameLoc = Lex.getLoc();
+ SMLoc NameLoc = Lex.getLoc();
std::string Name = Lex.getCurStrVal();
if (Lex.Lex() != tgtok::less) // consume the Id.
return ParseIDValue(CurRec, Name, NameLoc); // Value ::= IDValue
@@ -1087,7 +1087,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
return new DefInit(NewRec);
}
case tgtok::l_brace: { // Value ::= '{' ValueList '}'
- TGLoc BraceLoc = Lex.getLoc();
+ SMLoc BraceLoc = Lex.getLoc();
Lex.Lex(); // eat the '{'
std::vector<Init*> Vals;
@@ -1295,7 +1295,7 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) {
switch (Lex.getCode()) {
default: return Result;
case tgtok::l_brace: {
- TGLoc CurlyLoc = Lex.getLoc();
+ SMLoc CurlyLoc = Lex.getLoc();
Lex.Lex(); // eat the '{'
std::vector<unsigned> Ranges = ParseRangeList();
if (Ranges.empty()) return 0;
@@ -1317,7 +1317,7 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) {
break;
}
case tgtok::l_square: {
- TGLoc SquareLoc = Lex.getLoc();
+ SMLoc SquareLoc = Lex.getLoc();
Lex.Lex(); // eat the '['
std::vector<unsigned> Ranges = ParseRangeList();
if (Ranges.empty()) return 0;
@@ -1449,7 +1449,7 @@ std::string TGParser::ParseDeclaration(Record *CurRec,
return "";
}
- TGLoc IdLoc = Lex.getLoc();
+ SMLoc IdLoc = Lex.getLoc();
std::string DeclName = Lex.getCurStrVal();
Lex.Lex();
@@ -1470,7 +1470,7 @@ std::string TGParser::ParseDeclaration(Record *CurRec,
// If a value is present, parse it.
if (Lex.getCode() == tgtok::equal) {
Lex.Lex();
- TGLoc ValLoc = Lex.getLoc();
+ SMLoc ValLoc = Lex.getLoc();
Init *Val = ParseValue(CurRec, Type);
if (Val == 0 ||
SetValue(CurRec, ValLoc, DeclName, std::vector<unsigned>(), Val))
@@ -1536,7 +1536,7 @@ bool TGParser::ParseBodyItem(Record *CurRec) {
if (Lex.Lex() != tgtok::Id)
return TokError("expected field identifier after let");
- TGLoc IdLoc = Lex.getLoc();
+ SMLoc IdLoc = Lex.getLoc();
std::string FieldName = Lex.getCurStrVal();
Lex.Lex(); // eat the field name.
@@ -1640,7 +1640,7 @@ bool TGParser::ParseObjectBody(Record *CurRec) {
/// DefInst ::= DEF ObjectName ObjectBody
///
llvm::Record *TGParser::ParseDef(MultiClass *CurMultiClass) {
- TGLoc DefLoc = Lex.getLoc();
+ SMLoc DefLoc = Lex.getLoc();
assert(Lex.getCode() == tgtok::Def && "Unknown tok");
Lex.Lex(); // Eat the 'def' token.
@@ -1728,7 +1728,7 @@ std::vector<LetRecord> TGParser::ParseLetList() {
return std::vector<LetRecord>();
}
std::string Name = Lex.getCurStrVal();
- TGLoc NameLoc = Lex.getLoc();
+ SMLoc NameLoc = Lex.getLoc();
Lex.Lex(); // Eat the identifier.
// Check for an optional RangeList.
@@ -1780,7 +1780,7 @@ bool TGParser::ParseTopLevelLet() {
if (ParseObject())
return true;
} else { // Object ::= LETCommand '{' ObjectList '}'
- TGLoc BraceLoc = Lex.getLoc();
+ SMLoc BraceLoc = Lex.getLoc();
// Otherwise, this is a group let.
Lex.Lex(); // eat the '{'.
@@ -1905,7 +1905,7 @@ bool TGParser::ParseDefm() {
if (Lex.Lex() != tgtok::Id) // eat the defm.
return TokError("expected identifier after defm");
- TGLoc DefmPrefixLoc = Lex.getLoc();
+ SMLoc DefmPrefixLoc = Lex.getLoc();
std::string DefmPrefix = Lex.getCurStrVal();
if (Lex.Lex() != tgtok::colon)
return TokError("expected ':' after defm identifier");
@@ -1913,7 +1913,7 @@ bool TGParser::ParseDefm() {
// eat the colon.
Lex.Lex();
- TGLoc SubClassLoc = Lex.getLoc();
+ SMLoc SubClassLoc = Lex.getLoc();
SubClassReference Ref = ParseSubClassReference(0, true);
while (1) {
diff --git a/utils/TableGen/TGParser.h b/utils/TableGen/TGParser.h
index 3af467d..9f4b634 100644
--- a/utils/TableGen/TGParser.h
+++ b/utils/TableGen/TGParser.h
@@ -15,7 +15,7 @@
#define TGPARSER_H
#include "TGLexer.h"
-#include "TGSourceMgr.h"
+#include "llvm/Support/SourceMgr.h"
#include <map>
namespace llvm {
@@ -31,9 +31,9 @@ namespace llvm {
std::string Name;
std::vector<unsigned> Bits;
Init *Value;
- TGLoc Loc;
+ SMLoc Loc;
LetRecord(const std::string &N, const std::vector<unsigned> &B, Init *V,
- TGLoc L)
+ SMLoc L)
: Name(N), Bits(B), Value(V), Loc(L) {
}
};
@@ -47,15 +47,13 @@ class TGParser {
/// current value.
MultiClass *CurMultiClass;
public:
- TGParser(TGSourceMgr &SrcMgr) : Lex(SrcMgr), CurMultiClass(0) {}
+ TGParser(SourceMgr &SrcMgr) : Lex(SrcMgr), CurMultiClass(0) {}
- void setIncludeDirs(const std::vector<std::string> &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(TGLoc L, const std::string &Msg) const {
+ bool Error(SMLoc L, const std::string &Msg) const {
Lex.PrintError(L, Msg);
return true;
}
@@ -63,8 +61,8 @@ public:
return Error(Lex.getLoc(), Msg);
}
private: // Semantic analysis methods.
- bool AddValue(Record *TheRec, TGLoc Loc, const RecordVal &RV);
- bool SetValue(Record *TheRec, TGLoc 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<unsigned> &BitList, Init *V);
bool AddSubClass(Record *Rec, SubClassReference &SubClass);
bool AddSubMultiClass(MultiClass *CurMC,
@@ -92,7 +90,7 @@ private: // Parser methods.
SubMultiClassReference ParseSubMultiClassReference(MultiClass *CurMC);
Init *ParseIDValue(Record *CurRec);
- Init *ParseIDValue(Record *CurRec, const std::string &Name, TGLoc NameLoc);
+ 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<Init*> ParseValueList(Record *CurRec, Record *ArgsRec = 0, RecTy *EltTy = 0);
diff --git a/utils/TableGen/TGSourceMgr.cpp b/utils/TableGen/TGSourceMgr.cpp
deleted file mode 100644
index 42bc752..0000000
--- a/utils/TableGen/TGSourceMgr.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-//===- TGSourceMgr.cpp - Manager for Source Buffers & Diagnostics ---------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the TGSourceMgr class.
-//
-//===----------------------------------------------------------------------===//
-
-#include "TGSourceMgr.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/raw_ostream.h"
-using namespace llvm;
-
-TGSourceMgr::~TGSourceMgr() {
- while (!Buffers.empty()) {
- delete Buffers.back().Buffer;
- Buffers.pop_back();
- }
-}
-
-/// FindBufferContainingLoc - Return the ID of the buffer containing the
-/// specified location, returning -1 if not found.
-int TGSourceMgr::FindBufferContainingLoc(TGLoc Loc) const {
- for (unsigned i = 0, e = Buffers.size(); i != e; ++i)
- if (Loc.getPointer() >= Buffers[i].Buffer->getBufferStart() &&
- // Use <= here so that a pointer to the null at the end of the buffer
- // is included as part of the buffer.
- Loc.getPointer() <= Buffers[i].Buffer->getBufferEnd())
- return i;
- return -1;
-}
-
-/// FindLineNumber - Find the line number for the specified location in the
-/// specified file. This is not a fast method.
-unsigned TGSourceMgr::FindLineNumber(TGLoc Loc, int BufferID) const {
- if (BufferID == -1) BufferID = FindBufferContainingLoc(Loc);
- assert(BufferID != -1 && "Invalid Location!");
-
- MemoryBuffer *Buff = getBufferInfo(BufferID).Buffer;
-
- // Count the number of \n's between the start of the file and the specified
- // location.
- unsigned LineNo = 1;
-
- const char *Ptr = Buff->getBufferStart();
-
- for (; TGLoc::getFromPointer(Ptr) != Loc; ++Ptr)
- if (*Ptr == '\n') ++LineNo;
- return LineNo;
-}
-
-void TGSourceMgr::PrintIncludeStack(TGLoc IncludeLoc) const {
- if (IncludeLoc == TGLoc()) return; // Top of stack.
-
- int CurBuf = FindBufferContainingLoc(IncludeLoc);
- assert(CurBuf != -1 && "Invalid or unspecified location!");
-
- PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc);
-
- errs() << "Included from "
- << getBufferInfo(CurBuf).Buffer->getBufferIdentifier()
- << ":" << FindLineNumber(IncludeLoc, CurBuf) << ":\n";
-}
-
-
-void TGSourceMgr::PrintError(TGLoc ErrorLoc, const std::string &Msg) const {
- raw_ostream &OS = errs();
-
- // First thing to do: find the current buffer containing the specified
- // location.
- int CurBuf = FindBufferContainingLoc(ErrorLoc);
- assert(CurBuf != -1 && "Invalid or unspecified location!");
-
- PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc);
-
- MemoryBuffer *CurMB = getBufferInfo(CurBuf).Buffer;
-
-
- OS << "Parsing " << CurMB->getBufferIdentifier() << ":"
- << FindLineNumber(ErrorLoc, CurBuf) << ": ";
-
- OS << Msg << "\n";
-
- // Scan backward to find the start of the line.
- const char *LineStart = ErrorLoc.getPointer();
- while (LineStart != CurMB->getBufferStart() &&
- LineStart[-1] != '\n' && LineStart[-1] != '\r')
- --LineStart;
- // Get the end of the line.
- const char *LineEnd = ErrorLoc.getPointer();
- while (LineEnd != CurMB->getBufferEnd() &&
- LineEnd[0] != '\n' && LineEnd[0] != '\r')
- ++LineEnd;
- // Print out the line.
- OS << std::string(LineStart, LineEnd) << "\n";
- // Print out spaces before the caret.
- for (const char *Pos = LineStart; Pos != ErrorLoc.getPointer(); ++Pos)
- OS << (*Pos == '\t' ? '\t' : ' ');
- OS << "^\n";
-}
diff --git a/utils/TableGen/TGSourceMgr.h b/utils/TableGen/TGSourceMgr.h
deleted file mode 100644
index 69fb74c..0000000
--- a/utils/TableGen/TGSourceMgr.h
+++ /dev/null
@@ -1,106 +0,0 @@
-//===- TGSourceMgr.h - Manager for Source Buffers & Diagnostics -*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file declares the TGSourceMgr class.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef TGSOURCEMGR_H
-#define TGSOURCEMGR_H
-
-#include <string>
-#include <vector>
-#include <cassert>
-
-namespace llvm {
- class MemoryBuffer;
- class TGSourceMgr;
-
-class TGLoc {
- const char *Ptr;
-public:
- TGLoc() : Ptr(0) {}
- TGLoc(const TGLoc &RHS) : Ptr(RHS.Ptr) {}
-
- bool operator==(const TGLoc &RHS) const { return RHS.Ptr == Ptr; }
- bool operator!=(const TGLoc &RHS) const { return RHS.Ptr != Ptr; }
-
- const char *getPointer() const { return Ptr; }
-
- static TGLoc getFromPointer(const char *Ptr) {
- TGLoc L;
- L.Ptr = Ptr;
- return L;
- }
-};
-
-/// TGSourceMgr - This owns the files read by tblgen, handles include stacks,
-/// and handles printing of diagnostics.
-class TGSourceMgr {
- struct SrcBuffer {
- /// Buffer - The memory buffer for the file.
- MemoryBuffer *Buffer;
-
- /// IncludeLoc - This is the location of the parent include, or null if at
- /// the top level.
- TGLoc IncludeLoc;
- };
-
- /// Buffers - This is all of the buffers that we are reading from.
- std::vector<SrcBuffer> Buffers;
-
- TGSourceMgr(const TGSourceMgr&); // DO NOT IMPLEMENT
- void operator=(const TGSourceMgr&); // DO NOT IMPLEMENT
-public:
- TGSourceMgr() {}
- ~TGSourceMgr();
-
- const SrcBuffer &getBufferInfo(unsigned i) const {
- assert(i < Buffers.size() && "Invalid Buffer ID!");
- return Buffers[i];
- }
-
- const MemoryBuffer *getMemoryBuffer(unsigned i) const {
- assert(i < Buffers.size() && "Invalid Buffer ID!");
- return Buffers[i].Buffer;
- }
-
- TGLoc getParentIncludeLoc(unsigned i) const {
- assert(i < Buffers.size() && "Invalid Buffer ID!");
- return Buffers[i].IncludeLoc;
- }
-
- unsigned AddNewSourceBuffer(MemoryBuffer *F, TGLoc IncludeLoc) {
- SrcBuffer NB;
- NB.Buffer = F;
- NB.IncludeLoc = IncludeLoc;
- Buffers.push_back(NB);
- return Buffers.size()-1;
- }
-
- /// FindBufferContainingLoc - Return the ID of the buffer containing the
- /// specified location, returning -1 if not found.
- int FindBufferContainingLoc(TGLoc Loc) const;
-
- /// FindLineNumber - Find the line number for the specified location in the
- /// specified file. This is not a fast method.
- unsigned FindLineNumber(TGLoc Loc, int BufferID = -1) const;
-
-
- /// PrintError - Emit an error message about the specified location with the
- /// specified string.
- void PrintError(TGLoc ErrorLoc, const std::string &Msg) const;
-
-private:
- void PrintIncludeStack(TGLoc IncludeLoc) const;
-};
-
-} // end llvm namespace
-
-#endif
diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp
index dbc4d33..038cde2 100644
--- a/utils/TableGen/TableGen.cpp
+++ b/utils/TableGen/TableGen.cpp
@@ -124,10 +124,10 @@ namespace {
// FIXME: Eliminate globals from tblgen.
RecordKeeper llvm::Records;
-static TGSourceMgr SrcMgr;
+static SourceMgr SrcMgr;
-void llvm::PrintError(TGLoc ErrorLoc, const std::string &Msg) {
- SrcMgr.PrintError(ErrorLoc, Msg);
+void llvm::PrintError(SMLoc ErrorLoc, const std::string &Msg) {
+ SrcMgr.PrintMessage(ErrorLoc, Msg);
}
@@ -136,7 +136,7 @@ void llvm::PrintError(TGLoc ErrorLoc, const std::string &Msg) {
/// file.
static bool ParseFile(const std::string &Filename,
const std::vector<std::string> &IncludeDirs,
- TGSourceMgr &SrcMgr) {
+ SourceMgr &SrcMgr) {
std::string ErrorStr;
MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr);
if (F == 0) {
@@ -145,13 +145,13 @@ static bool ParseFile(const std::string &Filename,
}
// Tell SrcMgr about this buffer, which is what TGParser will pick up.
- SrcMgr.AddNewSourceBuffer(F, TGLoc());
-
- TGParser Parser(SrcMgr);
+ SrcMgr.AddNewSourceBuffer(F, SMLoc());
// Record the location of the include directory so that the lexer can find
// it later.
- Parser.setIncludeDirs(IncludeDirs);
+ SrcMgr.setIncludeDirs(IncludeDirs);
+
+ TGParser Parser(SrcMgr);
return Parser.ParseFile();
}
OpenPOWER on IntegriCloud