diff options
| author | Jimmy Kwa <[email protected]> | 2010-10-28 12:07:29 -0800 |
|---|---|---|
| committer | Jimmy Kwa <[email protected]> | 2010-10-28 12:07:29 -0800 |
| commit | 0586c55d7688f492d5264cb9299cf00ff73d3df7 (patch) | |
| tree | ef1ecc58933398e333f16dc56915bdffc64ef422 /decuda_to_ptxplus/header.y | |
| parent | 0efd3c00f5611bfa82b01d87d175122388d621cc (diff) | |
used p4 integrate to copy decuda_to_ptxplus into the distribtion folder. Edited baseline_ptxplus.config so the ptxplus regression runs properly.
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 7942]
Diffstat (limited to 'decuda_to_ptxplus/header.y')
| -rw-r--r-- | decuda_to_ptxplus/header.y | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/decuda_to_ptxplus/header.y b/decuda_to_ptxplus/header.y new file mode 100644 index 0000000..c0554f3 --- /dev/null +++ b/decuda_to_ptxplus/header.y @@ -0,0 +1,88 @@ +%{ +#include <iostream> +#include "decudaInstList.h" + +int yylex(void); +void yyerror(const char*); + +extern decudaInstList *g_headerList; +extern void output(const char * text); +%} + + +%union { + double double_value; + float float_value; + int int_value; + char * string_value; + void * ptr_value; +} + +%token DOTVERSION +%token DOTTARGET +%token DOTENTRY + +%token DOTPARAM + +%token DOTU64 +%token DOTU32 +%token DOTU16 +%token DOTB32 +%token DOTF32 + +%token <string_value> IDENTIFER + + /*change these 4 to int later?*/ +%token <string_value> DECLITERAL + +%token LEFTPAREN +%token RIGHTPAREN + + +%% + + /*translation rules*/ +program : statementList { output("No parsing errors\n"); } + ; + +statementList : statementList statement { output("\n"); } + | statement { output("\n"); } + ; + +statement : compilerDirective literal literal {} + | compilerDirective identifierList {} + | compilerDirective identifierList LEFTPAREN parameterList RIGHTPAREN {} + ; + +compilerDirective : DOTVERSION { output(".version"); decudaInst *instEntry = new decudaInst(); instEntry->setBase(".version"); g_headerList->add(instEntry);} + | DOTTARGET { output(".target"); decudaInst *instEntry = new decudaInst(); instEntry->setBase(".target"); g_headerList->add(instEntry);} + | DOTENTRY { output(".entry"); decudaInst *instEntry = new decudaInst(); instEntry->setBase(".entry"); g_headerList->add(instEntry);} + ; + +identifierList : identifierList IDENTIFER { output(" "); output($2); g_headerList->getListEnd().addOperand($2); } + | IDENTIFER { output(" "); output($1); g_headerList->getListEnd().addOperand($1); } + ; + +parameterList : parameterList parameter + | parameter + ; + +parameter : stateSpace opTypes IDENTIFER { output(" "); output($3); g_headerList->getListEnd().addOperand($3);} + ; + +stateSpace : DOTPARAM { output("\n.param"); decudaInst *instEntry = new decudaInst(); instEntry->setBase(".param"); g_headerList->add(instEntry); } + ; + +opTypes : DOTU64 { output(".u64"); g_headerList->getListEnd().addTypeModifier(".u64");} + | DOTU32 { output(".u32"); g_headerList->getListEnd().addTypeModifier(".u32");} + | DOTU16 { output(".u16"); g_headerList->getListEnd().addTypeModifier(".u16");} + | DOTB32 { output(".b32"); g_headerList->getListEnd().addTypeModifier(".b32");} + | DOTF32 { output(".f32"); g_headerList->getListEnd().addTypeModifier(".f32");} + ; + +literal : DECLITERAL { output(" "); output($1); g_headerList->getListEnd().addOperand($1); } + ; + +%% + +/*support c++ functions go here*/ |
