diff options
author | Homer Hsing <homer.xing@intel.com> | 2012-09-21 10:06:20 +0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2012-09-28 04:06:00 -0400 |
commit | 22e4490848868259cdff141082c1824623360acb (patch) | |
tree | 290e4fd1a1d122e38c7800b26275252746d0d958 | |
parent | 2d327f3e6294d1bca39991d556d52f81cef642e3 (diff) |
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.
-rw-r--r-- | src/gen4asm.h | 1 | ||||
-rw-r--r-- | src/gram.y | 45 |
2 files changed, 11 insertions, 35 deletions
diff --git a/src/gen4asm.h b/src/gen4asm.h index b4e199c..3a8d595 100644 --- a/src/gen4asm.h +++ b/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 { @@ -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 { |