diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cuda-sim/ptx.l | 14 | ||||
| -rw-r--r-- | src/cuda-sim/ptx.y | 3 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_parser.cc | 4 |
3 files changed, 11 insertions, 10 deletions
diff --git a/src/cuda-sim/ptx.l b/src/cuda-sim/ptx.l index d173451..cc83bd1 100644 --- a/src/cuda-sim/ptx.l +++ b/src/cuda-sim/ptx.l @@ -41,10 +41,8 @@ class ptx_recognizer; #include "ptx.tab.h" #include <string.h> -#define LINEBUF_SIZE (64*1024) -char linebuf[LINEBUF_SIZE]; -unsigned col = 0; -#define TC col+=strlen(yytext); +#define LINEBUF_SIZE (4*1024) +#define TC yylval->col+=strlen(yytext); #define CHECK_UNSIGNED \ if( yytext[strlen(yytext)-1]=='U' ) { \ printf("GPGPU-Sim: ERROR ** U modifier not implemented\n"); \ @@ -416,7 +414,7 @@ breakaddr TC; yylval->int_value = BREAKADDR_OP; return OPCODE; "//"[^\n]* TC; // eat single -\n.* col=0; strncpy(linebuf, yytext + 1, LINEBUF_SIZE); yyless( 1 ); +\n.* yylval->col=0; strncpy(yylval->linebuf, yytext + 1, LINEBUF_SIZE); yyless( 1 ); " " TC; "\t" TC; @@ -464,10 +462,10 @@ int ptx_error( yyscan_t yyscanner, ptx_recognizer* recognizer, const char *s ) fflush(stdout); if( s != NULL ) printf("%s:%u Syntax error:\n\n", g_filename, yylineno ); - printf(" %s\n", linebuf ); + printf(" %s\n", yylval->linebuf ); printf(" "); - for( i=0; i < col-1; i++ ) { - if( linebuf[i] == '\t' ) printf("\t"); + for( i=0; i < yylval->col-1; i++ ) { + if( yylval->linebuf[i] == '\t' ) printf("\t"); else printf(" "); } diff --git a/src/cuda-sim/ptx.y b/src/cuda-sim/ptx.y index 366b0cc..38a627f 100644 --- a/src/cuda-sim/ptx.y +++ b/src/cuda-sim/ptx.y @@ -43,6 +43,9 @@ class ptx_recognizer; int int_value; char * string_value; void * ptr_value; +#define LINEBUF_SIZE (4*1024) + char linebuf[LINEBUF_SIZE]; + unsigned col; } %token <string_value> STRING diff --git a/src/cuda-sim/ptx_parser.cc b/src/cuda-sim/ptx_parser.cc index a1f6e00..2ec8386 100644 --- a/src/cuda-sim/ptx_parser.cc +++ b/src/cuda-sim/ptx_parser.cc @@ -33,6 +33,7 @@ typedef void * yyscan_t; #include <stdarg.h> extern int ptx_get_lineno (yyscan_t yyscanner ); +extern YYSTYPE* ptx_get_lval (yyscan_t yyscanner ); extern int ptx_error( yyscan_t yyscanner, const char *s ); extern int ptx_lex_init(yyscan_t* scanner); extern void ptx_set_in(FILE * _in_str ,yyscan_t yyscanner ); @@ -285,7 +286,6 @@ void ptx_recognizer::parse_assert_impl( int test_value, const char *file, unsign parse_error_impl(file,line, msg); } -extern char linebuf[4096]; void ptx_recognizer::set_return() @@ -325,7 +325,7 @@ void ptx_recognizer::add_instruction() g_space_spec, g_filename, ptx_get_lineno(scanner), - linebuf, + ptx_get_lval(scanner)->linebuf, g_shader_core_config ); g_instructions.push_back(i); g_inst_lookup[g_filename][ptx_get_lineno(scanner)] = i; |
