From 5a65fb7a5f0cb1a8d7831bae33749e8bd15a947d Mon Sep 17 00:00:00 2001 From: "Andrew M. B. Boktor" Date: Wed, 18 Apr 2012 16:32:54 -0800 Subject: 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] --- cuobjdump_to_ptxplus/elf.l | 114 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 cuobjdump_to_ptxplus/elf.l (limited to 'cuobjdump_to_ptxplus/elf.l') 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 +#include +#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] +%% + +\.nv\.constant1\.{notnewline}*{newline} { + BEGIN(cmem); + yylval.string_value = strdup(yytext); + return C1BEGIN; +} + +\.nv\.local{notnewline}*{newline} { + BEGIN(INITIAL); + yylval.string_value = strdup(yytext); + return LOCALMEM; +} + +\.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 +} + +\.{notnewline}*{newline} { + BEGIN(INITIAL); +} + +{notnewline}*{newline} { + //printf("Discarding line %s", yytext); +} + +" "{newline}? { + //printf("#SPACE#"); + return SPACE2; +} + +0x[0-9a-fA-F]{8} { + //printf("CMEM VAL: %s \n", yytext); + yylval.string_value = strdup(yytext); + return CMEMVAL; +} + +{whitespace}*[[:alpha:]]+{whitespace}+[[:alpha:]]+{whitespace}+[[:alpha:]]+{whitespace}+[[:alpha:]]+{whitespace}+[[:alpha:]]+{whitespace}+[[:alpha:]]+{whitespace}+[[:alpha:]]+{whitespace}+{newline} { + return STHEADER; +} + +{whitespace}+ {} + +{newline} {} + +{hexdigit}+ { + yylval.string_value = strdup(yytext); + return NUMBER; +} + +{ident}+ { + yylval.string_value = strdup(yytext); + return IDENTIFIER; +} + +{newline}{whitespace}*{newline}{whitespace}* { + BEGIN(INITIAL); +} + /*Reached end of file*/ +<> 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(); +} -- cgit v1.3