summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-04-19 01:11:03 +0000
committerChris Lattner <sabre@nondot.org>2005-04-19 01:11:03 +0000
commit101fc501d00b38277e2e259eb1ab2a0543cc3f6d (patch)
treea0531f662c877fbab0829a73a094e72b68b7549f
parent2331c061ee02d340581b10678d9fa6042549fd97 (diff)
downloadbcm5719-llvm-101fc501d00b38277e2e259eb1ab2a0543cc3f6d.tar.gz
bcm5719-llvm-101fc501d00b38277e2e259eb1ab2a0543cc3f6d.zip
Add initial lexer and parser support for shifting values. Every use of this
will lead to it being rejected though. llvm-svn: 21335
-rw-r--r--llvm/utils/TableGen/FileLexer.l5
-rw-r--r--llvm/utils/TableGen/FileParser.y19
-rw-r--r--llvm/utils/TableGen/Record.h5
3 files changed, 29 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/FileLexer.l b/llvm/utils/TableGen/FileLexer.l
index 08daf2fc2e6..a4335879961 100644
--- a/llvm/utils/TableGen/FileLexer.l
+++ b/llvm/utils/TableGen/FileLexer.l
@@ -195,6 +195,11 @@ field { return FIELD; }
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);
diff --git a/llvm/utils/TableGen/FileParser.y b/llvm/utils/TableGen/FileParser.y
index 8781049956b..e7d50322ef4 100644
--- a/llvm/utils/TableGen/FileParser.y
+++ b/llvm/utils/TableGen/FileParser.y
@@ -189,6 +189,7 @@ using namespace llvm;
};
%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 @@ Value : INTVAL {
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 */ {
diff --git a/llvm/utils/TableGen/Record.h b/llvm/utils/TableGen/Record.h
index e2b9c0e6ef0..9c5166c0cc8 100644
--- a/llvm/utils/TableGen/Record.h
+++ b/llvm/utils/TableGen/Record.h
@@ -463,6 +463,11 @@ struct Init {
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.
OpenPOWER on IntegriCloud