summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cuobjdump_to_ptxplus/ptx_parser.h5
-rw-r--r--src/cuda-sim/ptx.y4
-rw-r--r--src/cuda-sim/ptx_ir.cc40
-rw-r--r--src/cuda-sim/ptx_ir.h9
-rw-r--r--src/cuda-sim/ptx_parser.cc11
-rw-r--r--src/cuda-sim/ptx_parser.h4
6 files changed, 71 insertions, 2 deletions
diff --git a/cuobjdump_to_ptxplus/ptx_parser.h b/cuobjdump_to_ptxplus/ptx_parser.h
index 1c96b46..418a733 100644
--- a/cuobjdump_to_ptxplus/ptx_parser.h
+++ b/cuobjdump_to_ptxplus/ptx_parser.h
@@ -110,6 +110,11 @@ void add_alignment_spec( int ) {PTX_PARSE_DPRINTF(" ");}
void add_pragma( const char *a ) {PTX_PARSE_DPRINTF(" ");}
void add_constptr(const char* identifier1, const char* identifier2, int offset) {PTX_PARSE_DPRINTF(" ");}
+//Jin: handle instructino group for cdp
+void start_inst_group(){PTX_PARSE_DPRINTF(" ");};
+void end_inst_group(){PTX_PARSE_DPRINTF(" ");};
+
+
/*non-dummy stuff below this point*/
extern cuobjdumpInstList *g_headerList;
diff --git a/src/cuda-sim/ptx.y b/src/cuda-sim/ptx.y
index 2f85213..c8208ea 100644
--- a/src/cuda-sim/ptx.y
+++ b/src/cuda-sim/ptx.y
@@ -270,8 +270,8 @@ statement_list: directive_statement { add_directive(); }
| instruction_statement { add_instruction(); }
| statement_list directive_statement { add_directive(); }
| statement_list instruction_statement { add_instruction(); }
- | statement_list statement_block
- | statement_block
+ | statement_list {start_inst_group();} statement_block {end_inst_group();}
+ | {start_inst_group();} statement_block {end_inst_group();}
;
directive_statement: variable_declaration SEMI_COLON
diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc
index 751b3f4..915c623 100644
--- a/src/cuda-sim/ptx_ir.cc
+++ b/src/cuda-sim/ptx_ir.cc
@@ -90,6 +90,11 @@ symbol_table::symbol_table( const char *scope_name, unsigned entry_point, symbol
m_const_next = 0;
m_global_next = 0x100;
m_local_next = 0;
+ m_tex_next = 0;
+
+ //Jin: handle instruction group for cdp
+ m_inst_group_id = 0;
+
m_parent = parent;
if ( m_parent ) {
m_shared_next = m_parent->m_shared_next;
@@ -170,6 +175,41 @@ void symbol_table::add_function( function_info *func, const char *filename, unsi
m_symbols[ func->get_name() ] = s;
}
+//Jin: handle instruction group for cdp
+symbol_table* symbol_table::start_inst_group() {
+ char inst_group_name[1024];
+ snprintf(inst_group_name, 1024, "%s_inst_group_%u", m_scope_name.c_str(), m_inst_group_id);
+
+ //previous added
+ assert(m_inst_group_symtab.find(std::string(inst_group_name)) == m_inst_group_symtab.end());
+ symbol_table *sym_table = new symbol_table(inst_group_name, 3/*inst group*/, this );
+
+ sym_table->m_global_next = m_global_next;
+ sym_table->m_shared_next = m_shared_next;
+ sym_table->m_local_next = m_local_next;
+ sym_table->m_reg_allocator = m_reg_allocator;
+ sym_table->m_tex_next = m_tex_next;
+ sym_table->m_const_next = m_const_next;
+
+ m_inst_group_symtab[std::string(inst_group_name)] = sym_table;
+
+ return sym_table;
+}
+
+symbol_table * symbol_table::end_inst_group() {
+ symbol_table * sym_table = m_parent;
+
+ sym_table->m_global_next = m_global_next;
+ sym_table->m_shared_next = m_shared_next;
+ sym_table->m_local_next = m_local_next;
+ sym_table->m_reg_allocator = m_reg_allocator;
+ sym_table->m_tex_next = m_tex_next;
+ sym_table->m_const_next = m_const_next;
+ sym_table->m_inst_group_id++;
+
+ return sym_table;
+}
+
void register_ptx_function( const char *name, function_info *impl ); // either libcuda or libopencl
bool symbol_table::add_function_decl( const char *name, int entry_point, function_info **func_info, symbol_table **sym_table )
diff --git a/src/cuda-sim/ptx_ir.h b/src/cuda-sim/ptx_ir.h
index 601a13d..7325e5f 100644
--- a/src/cuda-sim/ptx_ir.h
+++ b/src/cuda-sim/ptx_ir.h
@@ -330,6 +330,11 @@ public:
iterator const_iterator_end() { return m_consts.end();}
void dump();
+
+ //Jin: handle instruction group for cdp
+ symbol_table* start_inst_group();
+ symbol_table* end_inst_group();
+
private:
unsigned m_reg_allocator;
unsigned m_shared_next;
@@ -347,6 +352,10 @@ private:
std::list<symbol*> m_consts;
std::map<std::string,function_info*> m_function_info_lookup;
std::map<std::string,symbol_table*> m_function_symtab_lookup;
+
+ //Jin: handle instruction group for cdp
+ unsigned m_inst_group_id;
+ std::map<std::string,symbol_table*> m_inst_group_symtab;
};
class operand_info {
diff --git a/src/cuda-sim/ptx_parser.cc b/src/cuda-sim/ptx_parser.cc
index 824714a..39257da 100644
--- a/src/cuda-sim/ptx_parser.cc
+++ b/src/cuda-sim/ptx_parser.cc
@@ -187,6 +187,17 @@ void add_function_name( const char *name )
g_global_symbol_table->add_function( g_func_info, g_filename, ptx_lineno );
}
+//Jin: handle instruction group for cdp
+void start_inst_group() {
+ PTX_PARSE_DPRINTF("start_instruction_group");
+ g_current_symbol_table = g_current_symbol_table->start_inst_group();
+}
+
+void end_inst_group() {
+ PTX_PARSE_DPRINTF("end_instruction_group");
+ g_current_symbol_table = g_current_symbol_table->end_inst_group();
+}
+
void add_directive()
{
PTX_PARSE_DPRINTF("add_directive");
diff --git a/src/cuda-sim/ptx_parser.h b/src/cuda-sim/ptx_parser.h
index fef7635..32f3903 100644
--- a/src/cuda-sim/ptx_parser.h
+++ b/src/cuda-sim/ptx_parser.h
@@ -94,6 +94,10 @@ void change_operand_neg( );
void set_immediate_operand_type( );
void version_header(double a);
+//Jin: handle instructino group for cdp
+void start_inst_group();
+void end_inst_group();
+
#define NON_ARRAY_IDENTIFIER 1
#define ARRAY_IDENTIFIER_NO_DIM 2
#define ARRAY_IDENTIFIER 3