[llvm-commits] [llvm] r73138 - in /llvm/trunk: docs/TableGenFundamentals.html test/TableGen/patsubst.td test/TableGen/regmatch.td utils/TableGen/CodeGenDAGPatterns.cpp utils/TableGen/Record.cpp utils/TableGen/Record.h utils/TableGen/TGLexer.cpp utils/TableGen/TGLexer.h utils/TableGen/TGParser.cpp
David Greene
greened at obbligato.org
Tue Jun 9 11:31:20 PDT 2009
Author: greened
Date: Tue Jun 9 13:31:17 2009
New Revision: 73138
URL: http://llvm.org/viewvc/llvm-project?rev=73138&view=rev
Log:
Revert 73074 and 73099 because Windows doesn't have POSIX
regular expressions. We will add an OpenBSD implementation
and re-apply ASAP.
Modified:
llvm/trunk/docs/TableGenFundamentals.html
llvm/trunk/test/TableGen/patsubst.td
llvm/trunk/test/TableGen/regmatch.td
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/trunk/utils/TableGen/Record.cpp
llvm/trunk/utils/TableGen/Record.h
llvm/trunk/utils/TableGen/TGLexer.cpp
llvm/trunk/utils/TableGen/TGLexer.h
llvm/trunk/utils/TableGen/TGParser.cpp
Modified: llvm/trunk/docs/TableGenFundamentals.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/TableGenFundamentals.html?rev=73138&r1=73137&r2=73138&view=diff
==============================================================================
--- llvm/trunk/docs/TableGenFundamentals.html (original)
+++ llvm/trunk/docs/TableGenFundamentals.html Tue Jun 9 13:31:17 2009
@@ -417,13 +417,6 @@
<dt><tt>!subst(a, b, c)</tt></dt>
<dd>If 'a' and 'b' are of string type or are symbol references, substitute
'b' for 'a' in 'c.' This operation is analogous to $(subst) in GNU make.</dd>
-<dt><tt>!patsubst(a, b, c)</tt></dt>
- <dd>patch regular expression 'a' against string 'c' and substitute string 'b' on
-a match. 'b' may contain placeholders of the form $<digit>, where
-<digit> is a number 1-9.</dd>
-<dt><tt>!regmatch(a, b)</tt></dt>
- <dd>An integer {0,1} indicating whether string 'b' matched regular expression
-'a.'</dd>
<dt><tt>!foreach(a, b, c)</tt></dt>
<dd>For each member 'b' of dag or list 'a' apply operator 'c.' 'b' is a
dummy variable that should be declared as a member variable of an instantiated
Modified: llvm/trunk/test/TableGen/patsubst.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/patsubst.td?rev=73138&r1=73137&r2=73138&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/patsubst.td (original)
+++ llvm/trunk/test/TableGen/patsubst.td Tue Jun 9 13:31:17 2009
@@ -1,15 +0,0 @@
-// RUN: tblgen %s | grep {Match1 = "v4f32"} | count 1
-// RUN: tblgen %s | grep {Match2 = "v2f64"} | count 1
-// RUN: tblgen %s | grep {Match3 = "v4f32 add"} | count 1
-// RUN: tblgen %s | grep {Match4 = "v2f64 add"} | count 1
-
-class Foo<string v> {
- string Value = v;
- string Match1 = !patsubst(".*ps$", "v4f32", v);
- string Match2 = !patsubst(".*pd$", "v2f64", v);
- string Match3 = !patsubst("(.*)ps$", "v4f32 $1", v);
- string Match4 = !patsubst("(.*)pd$", "v2f64 $1", v);
-}
-
-def Bar : Foo<"addps">;
-def Baz : Foo<"addpd">;
Modified: llvm/trunk/test/TableGen/regmatch.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/regmatch.td?rev=73138&r1=73137&r2=73138&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/regmatch.td (original)
+++ llvm/trunk/test/TableGen/regmatch.td Tue Jun 9 13:31:17 2009
@@ -1,11 +0,0 @@
-// RUN: tblgen %s | grep {Match1 = 1} | count 1
-// RUN: tblgen %s | grep {Match2 = 1} | count 1
-
-class Foo<string v> {
- string Value = v;
- int Match1 = !regmatch(".*ps$", v);
- int Match2 = !regmatch(".*pd$", v);
-}
-
-def Bar : Foo<"addps">;
-def Baz : Foo<"addpd">;
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=73138&r1=73137&r2=73138&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Tue Jun 9 13:31:17 2009
@@ -2025,7 +2025,7 @@
}
}
else {
- ListTy = TArg->getType();
+ ListTy - TArg->getType();
}
}
ListInit *LI = new ListInit(Values, new ListRecTy(ListTy));
Modified: llvm/trunk/utils/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=73138&r1=73137&r2=73138&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.cpp (original)
+++ llvm/trunk/utils/TableGen/Record.cpp Tue Jun 9 13:31:17 2009
@@ -16,9 +16,6 @@
#include "llvm/Support/Streams.h"
#include "llvm/ADT/StringExtras.h"
#include <ios>
-#include <sys/types.h>
-#include <regex.h>
-#include <sstream>
using namespace llvm;
@@ -750,36 +747,6 @@
}
break;
}
- case REGMATCH: {
- StringInit *LHSs = dynamic_cast<StringInit*>(LHS);
- StringInit *RHSs = dynamic_cast<StringInit*>(RHS);
- if (LHSs && RHSs) {
- regex_t compiled;
- int err = regcomp (&compiled, LHSs->getValue().c_str(), REG_EXTENDED);
- if (err != 0) {
- size_t length = regerror (err, &compiled, NULL, 0);
- char *buffer = new char[length];
- (void) regerror (err, &compiled, buffer, length);
- std::string errmsg = buffer;
- delete[] buffer;
- regfree(&compiled);
- throw errmsg;
- }
- int result = regexec(&compiled, RHSs->getValue().c_str(), 0, NULL, 0);
- if (result == REG_ESPACE) {
- size_t length = regerror (err, &compiled, NULL, 0);
- char *buffer = new char[length];
- (void) regerror (err, &compiled, buffer, length);
- std::string errmsg = buffer;
- delete[] buffer;
- regfree(&compiled);
- throw errmsg;
- }
- regfree(&compiled);
- return new IntInit(result == 0);
- }
- break;
- }
case SHL:
case SRA:
case SRL: {
@@ -819,7 +786,6 @@
case SRA: Result = "!sra"; break;
case SRL: Result = "!srl"; break;
case STRCONCAT: Result = "!strconcat"; break;
- case REGMATCH: Result = "!regmatch"; break;
case NAMECONCAT:
Result = "!nameconcat<" + getType()->getAsString() + ">"; break;
}
@@ -1035,69 +1001,6 @@
}
break;
}
-
- case PATSUBST: {
- StringInit *LHSs = dynamic_cast<StringInit*>(LHS);
- StringInit *MHSs = dynamic_cast<StringInit*>(MHS);
- StringInit *RHSs = dynamic_cast<StringInit*>(RHS);
-
- if (LHSs && MHSs && RHSs) {
- regex_t compiled;
- int err = regcomp (&compiled, LHSs->getValue().c_str(), REG_EXTENDED);
- if (err != 0) {
- size_t length = regerror (err, &compiled, NULL, 0);
- char *buffer = new char[length];
- (void) regerror (err, &compiled, buffer, length);
- std::string errmsg = buffer;
- delete[] buffer;
- regfree(&compiled);
- throw errmsg;
- }
- regmatch_t matches[10];
- int result = regexec(&compiled, RHSs->getValue().c_str(), 10, matches, 0);
- if (result == REG_ESPACE) {
- size_t length = regerror (err, &compiled, NULL, 0);
- char *buffer = new char[length];
- (void) regerror (err, &compiled, buffer, length);
- std::string errmsg = buffer;
- delete[] buffer;
- regfree(&compiled);
- throw errmsg;
- }
- regfree(&compiled);
- if (result == 0) {
- // Parse the substitution string looking for $1, $2, etc. and
- // substitute strings. If there are no $1, etc. just replace
- // the whole string.
- std::string replacement = MHSs->getValue();
- size_t pos = replacement.find("$");
- while (pos != std::string::npos && pos+1 < replacement.size()) {
- if (std::isdigit(replacement[pos+1])) {
- std::string sidx(&replacement[pos+1], 1);
- std::istringstream str(sidx);
- int idx;
- if (str >> idx) {
- replacement.replace(pos, 2, RHSs->getValue(), matches[idx].rm_so,
- matches[idx].rm_eo - matches[idx].rm_so);
- }
- else {
- throw "unexpected failure in patsubst index calculation";
- }
- }
- else if (replacement[pos+1] == '$') {
- replacement.replace(pos, 2, "$");
- }
- pos = replacement.find("$", pos+1);
- }
- return new StringInit(replacement);
- }
- else {
- // No match, just pass the string through
- return RHSs;
- }
- }
- break;
- }
}
return this;
@@ -1133,7 +1036,6 @@
std::string Result;
switch (Opc) {
case SUBST: Result = "!subst"; break;
- case PATSUBST: Result = "!patsubst"; break;
case FOREACH: Result = "!foreach"; break;
case IF: Result = "!if"; break;
}
Modified: llvm/trunk/utils/TableGen/Record.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.h?rev=73138&r1=73137&r2=73138&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/Record.h (original)
+++ llvm/trunk/utils/TableGen/Record.h Tue Jun 9 13:31:17 2009
@@ -841,7 +841,7 @@
///
class BinOpInit : public OpInit {
public:
- enum BinaryOp { SHL, SRA, SRL, STRCONCAT, CONCAT, NAMECONCAT, REGMATCH };
+ enum BinaryOp { SHL, SRA, SRL, STRCONCAT, CONCAT, NAMECONCAT };
private:
BinaryOp Opc;
Init *LHS, *RHS;
@@ -885,7 +885,7 @@
///
class TernOpInit : public OpInit {
public:
- enum TernaryOp { SUBST, FOREACH, IF, PATSUBST };
+ enum TernaryOp { SUBST, FOREACH, IF };
private:
TernaryOp Opc;
Init *LHS, *MHS, *RHS;
Modified: llvm/trunk/utils/TableGen/TGLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGLexer.cpp?rev=73138&r1=73137&r2=73138&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/TGLexer.cpp (original)
+++ llvm/trunk/utils/TableGen/TGLexer.cpp Tue Jun 9 13:31:17 2009
@@ -447,9 +447,7 @@
if (Len == 3 && !memcmp(Start, "shl", 3)) return tgtok::XSHL;
if (Len == 9 && !memcmp(Start, "strconcat", 9)) return tgtok::XStrConcat;
if (Len == 10 && !memcmp(Start, "nameconcat", 10)) return tgtok::XNameConcat;
- if (Len == 8 && !memcmp(Start, "regmatch", 8)) return tgtok::XRegMatch;
if (Len == 5 && !memcmp(Start, "subst", 5)) return tgtok::XSubst;
- if (Len == 8 && !memcmp(Start, "patsubst", 8)) return tgtok::XPatSubst;
if (Len == 7 && !memcmp(Start, "foreach", 7)) return tgtok::XForEach;
if (Len == 4 && !memcmp(Start, "cast", 4)) return tgtok::XCast;
if (Len == 3 && !memcmp(Start, "car", 3)) return tgtok::XCar;
Modified: llvm/trunk/utils/TableGen/TGLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGLexer.h?rev=73138&r1=73137&r2=73138&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/TGLexer.h (original)
+++ llvm/trunk/utils/TableGen/TGLexer.h Tue Jun 9 13:31:17 2009
@@ -46,7 +46,7 @@
// !keywords.
XConcat, XSRA, XSRL, XSHL, XStrConcat, XNameConcat, XCast, XSubst,
- XForEach, XCar, XCdr, XNull, XIf, XRegMatch, XPatSubst,
+ XForEach, XCar, XCdr, XNull, XIf,
// Integer value.
IntVal,
Modified: llvm/trunk/utils/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.cpp?rev=73138&r1=73137&r2=73138&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/TGParser.cpp (original)
+++ llvm/trunk/utils/TableGen/TGParser.cpp Tue Jun 9 13:31:17 2009
@@ -799,7 +799,6 @@
case tgtok::XSRL:
case tgtok::XSHL:
case tgtok::XStrConcat:
- case tgtok::XRegMatch:
case tgtok::XNameConcat: { // Value ::= !binop '(' Value ',' Value ')'
BinOpInit::BinaryOp Code;
RecTy *Type = 0;
@@ -832,11 +831,6 @@
Code = BinOpInit::STRCONCAT;
Type = new StringRecTy();
break;
- case tgtok::XRegMatch:
- Lex.Lex(); // eat the operation
- Code = BinOpInit::REGMATCH;
- Type = new IntRecTy();
- break;
case tgtok::XNameConcat:
Lex.Lex(); // eat the operation
Code = BinOpInit::NAMECONCAT;
@@ -878,7 +872,6 @@
case tgtok::XIf:
case tgtok::XForEach:
- case tgtok::XPatSubst:
case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')'
TernOpInit::TernaryOp Code;
RecTy *Type = 0;
@@ -897,9 +890,6 @@
case tgtok::XSubst:
Code = TernOpInit::SUBST;
break;
- case tgtok::XPatSubst:
- Code = TernOpInit::PATSUBST;
- break;
}
if (Lex.getCode() != tgtok::l_paren) {
TokError("expected '(' after ternary operator");
@@ -973,10 +963,6 @@
Type = RHSt->getType();
break;
}
- case tgtok::XPatSubst: {
- Type = new StringRecTy;
- break;
- }
}
return (new TernOpInit(Code, LHS, MHS, RHS, Type))->Fold(CurRec, CurMultiClass);
}
@@ -1281,11 +1267,9 @@
case tgtok::XSRL:
case tgtok::XSHL:
case tgtok::XStrConcat:
- case tgtok::XRegMatch:
case tgtok::XNameConcat: // Value ::= !binop '(' Value ',' Value ')'
case tgtok::XIf:
case tgtok::XForEach:
- case tgtok::XPatSubst:
case tgtok::XSubst: { // Value ::= !ternop '(' Value ',' Value ',' Value ')'
return ParseOperation(CurRec);
break;
More information about the llvm-commits
mailing list