[llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l FileParser.y Record.h
Chris Lattner
lattner at cs.uiuc.edu
Mon Apr 18 18:11:20 PDT 2005
Changes in directory llvm/utils/TableGen:
FileLexer.l updated: 1.23 -> 1.24
FileParser.y updated: 1.31 -> 1.32
Record.h updated: 1.44 -> 1.45
---
Log message:
Add initial lexer and parser support for shifting values. Every use of this
will lead to it being rejected though.
---
Diffs of the changes: (+29 -0)
FileLexer.l | 5 +++++
FileParser.y | 19 +++++++++++++++++++
Record.h | 5 +++++
3 files changed, 29 insertions(+)
Index: llvm/utils/TableGen/FileLexer.l
diff -u llvm/utils/TableGen/FileLexer.l:1.23 llvm/utils/TableGen/FileLexer.l:1.24
--- llvm/utils/TableGen/FileLexer.l:1.23 Wed Oct 13 10:25:46 2004
+++ llvm/utils/TableGen/FileLexer.l Mon Apr 18 20:11:03 2005
@@ -195,6 +195,11 @@
let { return LET; }
in { return IN; }
+!sra { return SRATOK; }
+!srl { return SRLTOK; }
+!shl { return SHLTOK; }
+
+
{Identifier} { Filelval.StrVal = new std::string(yytext, yytext+yyleng);
return ID; }
${Identifier} { Filelval.StrVal = new std::string(yytext+1, yytext+yyleng);
Index: llvm/utils/TableGen/FileParser.y
diff -u llvm/utils/TableGen/FileParser.y:1.31 llvm/utils/TableGen/FileParser.y:1.32
--- llvm/utils/TableGen/FileParser.y:1.31 Wed Sep 1 17:55:40 2004
+++ llvm/utils/TableGen/FileParser.y Mon Apr 18 20:11:03 2005
@@ -189,6 +189,7 @@
};
%token INT BIT STRING BITS LIST CODE DAG CLASS DEF FIELD LET IN
+%token SHLTOK SRATOK SRLTOK
%token <IntVal> INTVAL
%token <StrVal> ID VARNAME STRVAL CODEFRAGMENT
@@ -308,6 +309,24 @@
exit(1);
}
delete $3;
+ } | SHLTOK '(' Value ',' Value ')' {
+ $$ = $3->getBinaryOp(Init::SHL, $5);
+ if ($$ == 0) {
+ err() << "Cannot shift values '" << *$3 << "' and '" << *$5 << "'!\n";
+ exit(1);
+ }
+ } | SRATOK '(' Value ',' Value ')' {
+ $$ = $3->getBinaryOp(Init::SRA, $5);
+ if ($$ == 0) {
+ err() << "Cannot shift values '" << *$3 << "' and '" << *$5 << "'!\n";
+ exit(1);
+ }
+ } | SRLTOK '(' Value ',' Value ')' {
+ $$ = $3->getBinaryOp(Init::SRL, $5);
+ if ($$ == 0) {
+ err() << "Cannot shift values '" << *$3 << "' and '" << *$5 << "'!\n";
+ exit(1);
+ }
};
OptVarName : /* empty */ {
Index: llvm/utils/TableGen/Record.h
diff -u llvm/utils/TableGen/Record.h:1.44 llvm/utils/TableGen/Record.h:1.45
--- llvm/utils/TableGen/Record.h:1.44 Mon Dec 6 17:42:37 2004
+++ llvm/utils/TableGen/Record.h Mon Apr 18 20:11:03 2005
@@ -463,6 +463,11 @@
virtual Init *getFieldInit(Record &R, const std::string &FieldName) const {
return 0;
}
+
+ enum BinaryOp { SHL, SRA, SRL };
+ virtual Init *getBinaryOp(BinaryOp Op, Init *RHS) {
+ return 0;
+ }
/// resolveReferences - This method is used by classes that refer to other
/// variables which may not be defined at the time they expression is formed.
More information about the llvm-commits
mailing list