diff options
| author | Andrew M. B. Boktor <[email protected]> | 2012-04-18 16:32:54 -0800 |
|---|---|---|
| committer | Andrew Boktor <[email protected]> | 2014-08-14 13:19:05 -0700 |
| commit | 5a65fb7a5f0cb1a8d7831bae33749e8bd15a947d (patch) | |
| tree | 9fb3040a0d43c426471aab94c92c41f2ea113780 /cuobjdump_to_ptxplus/elf.l | |
| parent | 49aaf1cd2cab61dea239264643f25e71251d1ce1 (diff) | |
Merging
//depot/gpgpu_sim_research/fermi-test/cuobjdump_to_ptxplus/...
to //depot/gpgpu_sim_research/fermi/distribution/cuobjdump_to_ptxplus/...
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 12022]
Diffstat (limited to 'cuobjdump_to_ptxplus/elf.l')
| -rw-r--r-- | cuobjdump_to_ptxplus/elf.l | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/cuobjdump_to_ptxplus/elf.l b/cuobjdump_to_ptxplus/elf.l new file mode 100644 index 0000000..3457a7a --- /dev/null +++ b/cuobjdump_to_ptxplus/elf.l @@ -0,0 +1,114 @@ + /*Lex file for elf files output by cuobjdump*/ +%{ +#include <stdio.h> +#include <string.h> +#include "elf_parser.hpp" + +#define yylval elf_lval + +void elf_error(const char*); +%} + +%option stack +%option noyywrap +%option yylineno + +%x cmem +%x symtab + +whitespace [ \t] +newline [\n] +notnewline [^\n] +newlines {newline}+ +ident [[:alnum:]_\.] +hexdigit [[:digit:]abcdef] +%% + +<cmem,INITIAL>\.nv\.constant1\.{notnewline}*{newline} { + BEGIN(cmem); + yylval.string_value = strdup(yytext); + return C1BEGIN; +} + +<cmem,INITIAL>\.nv\.local{notnewline}*{newline} { + BEGIN(INITIAL); + yylval.string_value = strdup(yytext); + return LOCALMEM; +} + +<cmem,INITIAL>\.nv\.constant0{notnewline}*{newline} { + BEGIN(cmem); + return C0BEGIN; +} + + +\.section" "\.symtab\tSYMTAB{newline} { + BEGIN(symtab); + return STBEGIN; +} + +\.section{notnewline}*{newline} { + //These are the lines before the symtab +} + +<cmem,INITIAL>\.{notnewline}*{newline} { + BEGIN(INITIAL); +} + +{notnewline}*{newline} { + //printf("Discarding line %s", yytext); +} + +<cmem>" "{newline}? { + //printf("#SPACE#"); + return SPACE2; +} + +<cmem>0x[0-9a-fA-F]{8} { + //printf("CMEM VAL: %s \n", yytext); + yylval.string_value = strdup(yytext); + return CMEMVAL; +} + +<symtab>{whitespace}*[[:alpha:]]+{whitespace}+[[:alpha:]]+{whitespace}+[[:alpha:]]+{whitespace}+[[:alpha:]]+{whitespace}+[[:alpha:]]+{whitespace}+[[:alpha:]]+{whitespace}+[[:alpha:]]+{whitespace}+{newline} { + return STHEADER; +} + +<symtab>{whitespace}+ {} + +<symtab>{newline} {} + +<symtab>{hexdigit}+ { + yylval.string_value = strdup(yytext); + return NUMBER; +} + +<symtab>{ident}+ { + yylval.string_value = strdup(yytext); + return IDENTIFIER; +} + +<symtab>{newline}{whitespace}*{newline}{whitespace}* { + BEGIN(INITIAL); +} + /*Reached end of file*/ +<<EOF>> return 0; + + /*No other rule matched. Throw an error*/ +. elf_error("Invalid token"); + +%% +void elf_error(const char* message) +{ + printf(" "); + printf(message); + printf(" near \""); + printf(yytext); + printf("\""); + printf(" on line "); + char line[5]; + sprintf(line, "%i", yylineno); + printf(line); + printf("\n"); + abort(); +} |
