From b0b540f02a67ca8d7d1e6748586a51e5bd755503 Mon Sep 17 00:00:00 2001 From: Homer Hsing Date: Fri, 21 Sep 2012 10:06:20 +0800 Subject: [PATCH] Reduce replicative code in gram.y by reloc_target field in src_operand Bspec says JIP and UIP should be the source operands. It is better if src_operand has a field "reloc_target" according to bspec. The replicative code in JMPI and branchloop rules can be merged into one. --- assembler/src/gen4asm.h | 1 + assembler/src/gram.y | 45 ++++++++++----------------------------------- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/assembler/src/gen4asm.h b/assembler/src/gen4asm.h index b4e199c..3a8d595 100644 --- a/assembler/src/gen4asm.h +++ b/assembler/src/gen4asm.h @@ -108,6 +108,7 @@ struct src_operand { int swizzle_x, swizzle_y, swizzle_z, swizzle_w; uint32_t imm32; /* only set if reg_file == BRW_IMMEDIATE_VALUE */ + char *reloc_target; /* bspec: branching instructions JIP and UIP are source operands */ } src_operand; typedef struct { diff --git a/assembler/src/gram.y b/assembler/src/gram.y index 2897447..ba8e36f 100644 --- a/assembler/src/gram.y +++ b/assembler/src/gram.y @@ -813,39 +813,7 @@ jumpinstruction: predicate JMPI execsize relativelocation2 set_direct_src_operand(&ip_src, &dst, BRW_REGISTER_TYPE_UD); set_instruction_src0(&$$, &ip_src); set_instruction_src1(&$$, &$4); - } - | predicate JMPI execsize STRING - { - struct direct_reg dst; - struct dst_operand ip_dst; - struct src_operand ip_src; - struct src_operand imm; - - /* The jump instruction requires that the IP register - * be the destination and first source operand, while the - * offset is the second source operand. The next instruction - is the post-incremented IP plus the offset. - */ - dst.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; - dst.reg_nr = BRW_ARF_IP; - dst.subreg_nr = 0; - memset (&imm, '\0', sizeof (imm)); - imm.reg_file = BRW_IMMEDIATE_VALUE; - imm.reg_type = BRW_REGISTER_TYPE_D; - imm.imm32 = 0; - - memset(&$$, 0, sizeof($$)); - $$.header.opcode = $2; - $$.header.execution_size = ffs(1) - 1; - if(advanced_flag) - $$.header.mask_control = BRW_MASK_DISABLE; - set_direct_dst_operand(&ip_dst, &dst, BRW_REGISTER_TYPE_UD); - set_instruction_dest(&$$, &ip_dst); - set_instruction_predicate(&$$, &$1); - set_direct_src_operand(&ip_src, &dst, BRW_REGISTER_TYPE_UD); - set_instruction_src0(&$$, &ip_src); - set_instruction_src1(&$$, &imm); - $$.first_reloc_target = $4; + $$.first_reloc_target = $4.reloc_target; } ; @@ -2136,12 +2104,19 @@ relativelocation: imm32 ; relativelocation2: - exp + STRING { memset (&$$, '\0', sizeof ($$)); $$.reg_file = BRW_IMMEDIATE_VALUE; $$.reg_type = BRW_REGISTER_TYPE_D; - $$.imm32 = $1.u.d; + $$.reloc_target = $1; + } + | exp + { + memset (&$$, '\0', sizeof ($$)); + $$.reg_file = BRW_IMMEDIATE_VALUE; + $$.reg_type = BRW_REGISTER_TYPE_D; + $$.imm32 = $1; } | directgenreg region regtype { -- 2.7.4