[llvm-commits] [parallel] CVS: llvm/utils/TableGen/FileLexer.l FileParser.y InstrSelectorEmitter.cpp Record.cpp TableGen.cpp
Misha Brukman
brukman at cs.uiuc.edu
Mon Mar 1 20:29:49 PST 2004
Changes in directory llvm/utils/TableGen:
FileLexer.l updated: 1.17 -> 1.17.4.1
FileParser.y updated: 1.26 -> 1.26.4.1
InstrSelectorEmitter.cpp updated: 1.37 -> 1.37.4.1
Record.cpp updated: 1.30 -> 1.30.4.1
TableGen.cpp updated: 1.23 -> 1.23.4.1
---
Log message:
Merge from trunk
---
Diffs of the changes: (+61 -66)
Index: llvm/utils/TableGen/FileLexer.l
diff -u llvm/utils/TableGen/FileLexer.l:1.17 llvm/utils/TableGen/FileLexer.l:1.17.4.1
--- llvm/utils/TableGen/FileLexer.l:1.17 Tue Nov 11 16:41:34 2003
+++ llvm/utils/TableGen/FileLexer.l Mon Mar 1 17:59:25 2004
@@ -38,7 +38,8 @@
// Global variable recording the location of the include directory
std::string IncludeDirectory;
-// ParseInt - This has to handle the special case of binary numbers 0b0101
+/// ParseInt - This has to handle the special case of binary numbers 0b0101
+///
static int ParseInt(const char *Str) {
if (Str[0] == '0' && Str[1] == 'b')
return strtol(Str+2, 0, 2);
@@ -60,7 +61,6 @@
static std::vector<IncludeRec> IncludeStack;
-
std::ostream &err() {
if (IncludeStack.empty())
return std::cerr << "At end of input: ";
@@ -72,19 +72,8 @@
<< Filelineno << ": ";
}
-
-
-//
-// Function: ParseFile()
-//
-// Description:
-// This function begins the parsing of the specified tablegen file.
-//
-// Inputs:
-// Filename - A string containing the name of the file to parse.
-// IncludeDir - A string containing the directory from which include
-// files can be found.
-//
+/// ParseFile - this function begins the parsing of the specified tablegen file.
+///
void ParseFile(const std::string &Filename, const std::string & IncludeDir) {
FILE *F = stdin;
if (Filename != "-") {
@@ -99,10 +88,8 @@
IncludeStack.push_back(IncludeRec("<stdin>", stdin));
}
- //
// Record the location of the include directory so that the lexer can find
// it later.
- //
IncludeDirectory = IncludeDir;
Filein = F;
@@ -111,8 +98,9 @@
Filein = stdin;
}
-// HandleInclude - This function is called when an include directive is
-// encountered in the input stream...
+/// HandleInclude - This function is called when an include directive is
+/// encountered in the input stream...
+///
static void HandleInclude(const char *Buffer) {
unsigned Length = yyleng;
assert(Buffer[Length-1] == '"');
@@ -133,20 +121,18 @@
// Open the new input file...
yyin = fopen(Filename.c_str(), "r");
if (yyin == 0) {
- //
// If we couldn't find the file in the current directory, look for it in
// the include directories.
//
- // NOTE:
- // Right now, there is only one directory. We need to eventually add
- // support for more.
- //
- Filename = IncludeDirectory + "/" + Filename;
- yyin = fopen(Filename.c_str(), "r");
+ // NOTE: Right now, there is only one directory. We need to eventually add
+ // support for more.
+ std::string NextFilename = IncludeDirectory + "/" + Filename;
+ yyin = fopen(NextFilename.c_str(), "r");
if (yyin == 0) {
err() << "Could not find include file '" << Filename << "'!\n";
- abort();
+ exit(1);
}
+ Filename = NextFilename;
}
// Add the file to our include stack...
@@ -157,10 +143,9 @@
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
}
-
-// yywrap - This is called when the lexer runs out of input in one of the files.
-// Switch back to an includer if an includee has run out of input.
-//
+/// yywrap - This is called when the lexer runs out of input in one of the
+/// files. Switch back to an includer if an includee has run out of input.
+///
extern "C"
int yywrap() {
if (IncludeStack.back().File != stdin)
@@ -229,7 +214,7 @@
<comment>"/*" { ++CommentDepth; }
<comment>"/"+[^*]* /* eat up /'s not followed by *'s */
<comment>"*"+"/" { if (!--CommentDepth) { BEGIN(INITIAL); } }
-<comment><<EOF>> { err() << "Unterminated comment!\n"; abort(); }
+<comment><<EOF>> { err() << "Unterminated comment!\n"; exit(1); }
. { return Filetext[0]; }
Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.26 llvm/utils/TableGen/FileParser.y:1.26.4.1
--- llvm/utils/TableGen/FileParser.y:1.26 Tue Nov 11 16:41:34 2003
+++ llvm/utils/TableGen/FileParser.y Mon Mar 1 17:59:25 2004
@@ -51,7 +51,7 @@
err() << "New definition of '" << RV.getName() << "' of type '"
<< *RV.getType() << "' is incompatible with previous "
<< "definition of type '" << *ERV->getType() << "'!\n";
- abort();
+ exit(1);
}
} else {
CurRec->addValue(RV);
@@ -61,20 +61,27 @@
static void addSuperClass(Record *SC) {
if (CurRec->isSubClassOf(SC)) {
err() << "Already subclass of '" << SC->getName() << "'!\n";
- abort();
+ exit(1);
}
CurRec->addSuperClass(SC);
}
static void setValue(const std::string &ValName,
std::vector<unsigned> *BitList, Init *V) {
- if (!V) return ;
+ if (!V) return;
RecordVal *RV = CurRec->getValue(ValName);
if (RV == 0) {
err() << "Value '" << ValName << "' unknown!\n";
- abort();
+ exit(1);
}
+
+ // Do not allow assignments like 'X = X'. This will just cause infinite loops
+ // in the resolution machinery.
+ if (!BitList)
+ if (VarInit *VI = dynamic_cast<VarInit*>(V))
+ if (VI->getName() == ValName)
+ return;
// If we are assigning to a subset of the bits in the value... then we must be
// assigning to a field of BitsRecTy, which must have a BitsInit
@@ -84,7 +91,7 @@
BitsInit *CurVal = dynamic_cast<BitsInit*>(RV->getValue());
if (CurVal == 0) {
err() << "Value '" << ValName << "' is not a bits type!\n";
- abort();
+ exit(1);
}
// Convert the incoming value to a bits type of the appropriate size...
@@ -92,7 +99,7 @@
if (BI == 0) {
V->convertInitializerTo(new BitsRecTy(BitList->size()));
err() << "Initializer '" << *V << "' not compatible with bit range!\n";
- abort();
+ exit(1);
}
// We should have a BitsInit type now...
@@ -107,7 +114,7 @@
if (NewVal->getBit(Bit)) {
err() << "Cannot set bit #" << Bit << " of value '" << ValName
<< "' more than once!\n";
- abort();
+ exit(1);
}
NewVal->setBit(Bit, BInit->getBit(i));
}
@@ -122,7 +129,7 @@
if (RV->setValue(V)) {
err() << "Value '" << ValName << "' of type '" << *RV->getType()
<< "' is incompatible with initializer '" << *V << "'!\n";
- abort();
+ exit(1);
}
}
@@ -137,7 +144,7 @@
// Ensure that an appropriate number of template arguments are specified...
if (TArgs.size() < TemplateArgs.size()) {
err() << "ERROR: More template args specified than expected!\n";
- abort();
+ exit(1);
} else { // This class expects template arguments...
// Loop over all of the template arguments, setting them to the specified
// value or leaving them as the default as necessary.
@@ -149,15 +156,14 @@
err() << "ERROR: Value not specified for template argument #"
<< i << " (" << TArgs[i] << ") of subclass '" << SC->getName()
<< "'!\n";
- abort();
+ exit(1);
}
}
}
-
// Since everything went well, we can now set the "superclass" list for the
// current record.
- const std::vector<Record*> &SCs = SC->getSuperClasses();
+ const std::vector<Record*> &SCs = SC->getSuperClasses();
for (unsigned i = 0, e = SCs.size(); i != e; ++i)
addSuperClass(SCs[i]);
addSuperClass(SC);
@@ -206,7 +212,7 @@
$$ = Records.getClass(*$1);
if ($$ == 0) {
err() << "Couldn't find class '" << *$1 << "'!\n";
- abort();
+ exit(1);
}
delete $1;
};
@@ -252,7 +258,7 @@
if (Bit == 0) {
err() << "Element #" << i << " (" << *(*$2)[i]
<< ") is not convertable to a bit!\n";
- abort();
+ exit(1);
}
Init->setBit($2->size()-i-1, Bit);
}
@@ -265,7 +271,7 @@
$$ = new DefInit(D);
} else {
err() << "Variable not defined: '" << *$1 << "'!\n";
- abort();
+ exit(1);
}
delete $1;
@@ -273,7 +279,7 @@
$$ = $1->convertInitializerBitRange(*$3);
if ($$ == 0) {
err() << "Invalid bit range for value '" << *$1 << "'!\n";
- abort();
+ exit(1);
}
delete $3;
} | '[' ValueList ']' {
@@ -282,7 +288,7 @@
} | Value '.' ID {
if (!$1->getFieldType(*$3)) {
err() << "Cannot access field '" << *$3 << "' of value '" << *$1 << "!\n";
- abort();
+ exit(1);
}
$$ = new FieldInit($1, *$3);
delete $3;
@@ -290,7 +296,7 @@
Record *D = Records.getDef(*$2);
if (D == 0) {
err() << "Invalid def '" << *$2 << "'!\n";
- abort();
+ exit(1);
}
$$ = new DagInit(D, *$3);
delete $2; delete $3;
@@ -326,7 +332,7 @@
} | INTVAL '-' INTVAL {
if ($1 < $3 || $1 < 0 || $3 < 0) {
err() << "Invalid bit range: " << $1 << "-" << $3 << "!\n";
- abort();
+ exit(1);
}
$$ = new std::vector<unsigned>();
for (int i = $1; i >= $3; --i)
@@ -335,7 +341,7 @@
$2 = -$2;
if ($1 < $2 || $1 < 0 || $2 < 0) {
err() << "Invalid bit range: " << $1 << "-" << $2 << "!\n";
- abort();
+ exit(1);
}
$$ = new std::vector<unsigned>();
for (int i = $1; i >= $2; --i)
@@ -345,7 +351,7 @@
} | RBitList ',' INTVAL '-' INTVAL {
if ($3 < $5 || $3 < 0 || $5 < 0) {
err() << "Invalid bit range: " << $3 << "-" << $5 << "!\n";
- abort();
+ exit(1);
}
$$ = $1;
for (int i = $3; i >= $5; --i)
@@ -354,7 +360,7 @@
$4 = -$4;
if ($3 < $4 || $3 < 0 || $4 < 0) {
err() << "Invalid bit range: " << $3 << "-" << $4 << "!\n";
- abort();
+ exit(1);
}
$$ = $1;
for (int i = $3; i >= $4; --i)
@@ -461,7 +467,8 @@
for (unsigned i = 0, e = $4->size(); i != e; ++i) {
Record *SuperClass = (*$4)[i].first;
for (unsigned i = 0, e = SuperClass->getTemplateArgs().size(); i != e; ++i)
- CurRec->removeValue(SuperClass->getTemplateArgs()[i]);
+ if (!CurRec->isTemplateArg(SuperClass->getTemplateArgs()[i]))
+ CurRec->removeValue(SuperClass->getTemplateArgs()[i]);
}
delete $4; // Delete the class list...
@@ -472,7 +479,7 @@
ClassInst : CLASS ObjectBody {
if (Records.getClass($2->getName())) {
err() << "Class '" << $2->getName() << "' already defined!\n";
- abort();
+ exit(1);
}
Records.addClass($$ = $2);
};
@@ -481,12 +488,12 @@
if (!$2->getTemplateArgs().empty()) {
err() << "Def '" << $2->getName()
<< "' is not permitted to have template arguments!\n";
- abort();
+ exit(1);
}
// If ObjectBody has template arguments, it's an error.
if (Records.getDef($2->getName())) {
err() << "Def '" << $2->getName() << "' already defined!\n";
- abort();
+ exit(1);
}
Records.addDef($$ = $2);
};
@@ -520,5 +527,5 @@
int yyerror(const char *ErrorMsg) {
err() << "Error parsing: " << ErrorMsg << "\n";
- abort();
+ exit(1);
}
Index: llvm/utils/TableGen/InstrSelectorEmitter.cpp
diff -u llvm/utils/TableGen/InstrSelectorEmitter.cpp:1.37 llvm/utils/TableGen/InstrSelectorEmitter.cpp:1.37.4.1
--- llvm/utils/TableGen/InstrSelectorEmitter.cpp:1.37 Wed Dec 10 18:58:34 2003
+++ llvm/utils/TableGen/InstrSelectorEmitter.cpp Mon Mar 1 17:59:25 2004
@@ -1023,7 +1023,7 @@
<< " class " << Target.getName() << "ISel {\n"
<< " SelectionDAG &DAG;\n"
<< " public:\n"
- << " X86ISel(SelectionDAG &D) : DAG(D) {}\n"
+ << " " << Target.getName () << "ISel(SelectionDAG &D) : DAG(D) {}\n"
<< " void generateCode();\n"
<< " private:\n"
<< " unsigned makeAnotherReg(const TargetRegisterClass *RC) {\n"
@@ -1060,7 +1060,7 @@
OS << " };\n}\n\n";
// Emit the generateCode entry-point...
- OS << "void X86ISel::generateCode() {\n"
+ OS << "void " << Target.getName () << "ISel::generateCode() {\n"
<< " SelectionDAGNode *Root = DAG.getRoot();\n"
<< " assert(Root->getValueType() == MVT::isVoid && "
"\"Root of DAG produces value??\");\n\n"
Index: llvm/utils/TableGen/Record.cpp
diff -u llvm/utils/TableGen/Record.cpp:1.30 llvm/utils/TableGen/Record.cpp:1.30.4.1
--- llvm/utils/TableGen/Record.cpp:1.30 Tue Nov 11 16:41:34 2003
+++ llvm/utils/TableGen/Record.cpp Mon Mar 1 17:59:25 2004
@@ -361,11 +361,14 @@
Init *VarInit::getFieldInit(Record &R, const std::string &FieldName) const {
if (RecordRecTy *RTy = dynamic_cast<RecordRecTy*>(getType()))
- if (const RecordVal *RV = R.getValue(VarName))
- if (Init *I = RV->getValue()->getFieldInit(R, FieldName))
+ if (const RecordVal *RV = R.getValue(VarName)) {
+ Init *TheInit = RV->getValue();
+ assert(TheInit != this && "Infinite loop detected!");
+ if (Init *I = TheInit->getFieldInit(R, FieldName))
return I;
else
return 0;
+ }
return 0;
}
Index: llvm/utils/TableGen/TableGen.cpp
diff -u llvm/utils/TableGen/TableGen.cpp:1.23 llvm/utils/TableGen/TableGen.cpp:1.23.4.1
--- llvm/utils/TableGen/TableGen.cpp:1.23 Tue Nov 11 16:41:34 2003
+++ llvm/utils/TableGen/TableGen.cpp Mon Mar 1 17:59:25 2004
@@ -97,7 +97,7 @@
}
std::cerr << "Cannot find requested bit!\n";
- abort();
+ exit(1);
return 0;
}
@@ -273,7 +273,7 @@
if (RangeBegin == InstsB && RangeEnd == InstsE) {
std::cerr << "Error: Could not distinguish among the following insts!:\n";
PrintRange(InstsB, InstsE);
- abort();
+ exit(1);
}
#if 0
@@ -467,7 +467,7 @@
{
std::vector<Record*> Recs = Records.getAllDerivedDefinitions(Class);
for (unsigned i = 0, e = Recs.size(); i != e; ++i)
- *Out << Recs[i] << ", ";
+ *Out << Recs[i]->getName() << ", ";
*Out << "\n";
break;
}
More information about the llvm-commits
mailing list