From f05760de76b4ec26474da18c97770ca369972cfd Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 30 Jul 2003 21:47:42 +0000 Subject: [PATCH] Initial support for the 'code' type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7439 91177308-0d34-0410-b5e6-96231b3b80d8 --- support/tools/TableGen/FileLexer.l | 1 + support/tools/TableGen/FileParser.y | 4 +++- support/tools/TableGen/Record.h | 9 +++++++++ utils/TableGen/FileLexer.l | 1 + utils/TableGen/FileParser.y | 4 +++- utils/TableGen/Record.h | 9 +++++++++ 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/support/tools/TableGen/FileLexer.l b/support/tools/TableGen/FileLexer.l index d3264da91a0..34a2818b2f2 100644 --- a/support/tools/TableGen/FileLexer.l +++ b/support/tools/TableGen/FileLexer.l @@ -151,6 +151,7 @@ bit { return BIT; } bits { return BITS; } string { return STRING; } list { return LIST; } +code { return CODE; } class { return CLASS; } def { return DEF; } diff --git a/support/tools/TableGen/FileParser.y b/support/tools/TableGen/FileParser.y index 431fcfcc624..e906a5e4e38 100644 --- a/support/tools/TableGen/FileParser.y +++ b/support/tools/TableGen/FileParser.y @@ -153,7 +153,7 @@ static void addSubClass(Record *SC, const std::vector &TemplateArgs) { std::vector *SubClassList; }; -%token INT BIT STRING BITS LIST CLASS DEF FIELD SET IN +%token INT BIT STRING BITS LIST CODE CLASS DEF FIELD SET IN %token INTVAL %token ID STRVAL @@ -202,6 +202,8 @@ Type : STRING { // string type $$ = new IntRecTy(); } | LIST '<' ClassID '>' { // list type $$ = new ListRecTy($3); + } | CODE { // code type + $$ = new CodeRecTy(); } | ClassID { // Record Type $$ = new RecordRecTy($1); }; diff --git a/support/tools/TableGen/Record.h b/support/tools/TableGen/Record.h index 0ac5648c86d..308047a2b43 100644 --- a/support/tools/TableGen/Record.h +++ b/support/tools/TableGen/Record.h @@ -131,6 +131,15 @@ public: void print(std::ostream &OS) const; }; +/// CodeRecTy - 'code' - Represent an code fragment, function or method. +/// +struct CodeRecTy : public RecTy { + Init *convertValue(UnsetInit *UI) { return (Init*)UI; } + + void print(std::ostream &OS) const { OS << "code"; } +}; + + /// RecordRecTy - '' - Represent an instance of a class, such as: /// (R32 X = EAX). /// diff --git a/utils/TableGen/FileLexer.l b/utils/TableGen/FileLexer.l index d3264da91a0..34a2818b2f2 100644 --- a/utils/TableGen/FileLexer.l +++ b/utils/TableGen/FileLexer.l @@ -151,6 +151,7 @@ bit { return BIT; } bits { return BITS; } string { return STRING; } list { return LIST; } +code { return CODE; } class { return CLASS; } def { return DEF; } diff --git a/utils/TableGen/FileParser.y b/utils/TableGen/FileParser.y index 431fcfcc624..e906a5e4e38 100644 --- a/utils/TableGen/FileParser.y +++ b/utils/TableGen/FileParser.y @@ -153,7 +153,7 @@ static void addSubClass(Record *SC, const std::vector &TemplateArgs) { std::vector *SubClassList; }; -%token INT BIT STRING BITS LIST CLASS DEF FIELD SET IN +%token INT BIT STRING BITS LIST CODE CLASS DEF FIELD SET IN %token INTVAL %token ID STRVAL @@ -202,6 +202,8 @@ Type : STRING { // string type $$ = new IntRecTy(); } | LIST '<' ClassID '>' { // list type $$ = new ListRecTy($3); + } | CODE { // code type + $$ = new CodeRecTy(); } | ClassID { // Record Type $$ = new RecordRecTy($1); }; diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h index 0ac5648c86d..308047a2b43 100644 --- a/utils/TableGen/Record.h +++ b/utils/TableGen/Record.h @@ -131,6 +131,15 @@ public: void print(std::ostream &OS) const; }; +/// CodeRecTy - 'code' - Represent an code fragment, function or method. +/// +struct CodeRecTy : public RecTy { + Init *convertValue(UnsetInit *UI) { return (Init*)UI; } + + void print(std::ostream &OS) const { OS << "code"; } +}; + + /// RecordRecTy - '' - Represent an instance of a class, such as: /// (R32 X = EAX). ///