From 79c62f1134b2200fc49c43178d846ecba8e37a7b Mon Sep 17 00:00:00 2001 From: Damien Lespiau Date: Mon, 21 Jan 2013 21:41:36 +0000 Subject: assembler: Don't change the size of opcodes! Until now, the assembler had relocation-related fields added to struct brw_instruction. This changes the size of the structure and break code assuming the opcode structure is really 16 bytes, for instance the emission code in brw_eu_emit.c. With this commit, we build on the infrastructure that slowly emerged in the few previous commits to add a relocatable instruction with the needed fields. Signed-off-by: Damien Lespiau --- assembler/main.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'assembler/main.c') diff --git a/assembler/main.c b/assembler/main.c index eb752308..85f07905 100644 --- a/assembler/main.c +++ b/assembler/main.c @@ -421,24 +421,25 @@ int main(int argc, char **argv) } for (entry = compiled_program.first; entry; entry = entry->next) { - struct brw_instruction *inst = & entry->instruction.gen; + struct relocatable_instruction *reloc = &entry->instruction.reloc; + struct brw_instruction *inst = &reloc->gen; - if (is_label(entry)) + if (!is_relocatable(entry)) continue; - if (inst->first_reloc_target) - inst->first_reloc_offset = label_to_addr(inst->first_reloc_target, entry->inst_offset) - entry->inst_offset; + if (reloc->first_reloc_target) + reloc->first_reloc_offset = label_to_addr(reloc->first_reloc_target, entry->inst_offset) - entry->inst_offset; - if (inst->second_reloc_target) - inst->second_reloc_offset = label_to_addr(inst->second_reloc_target, entry->inst_offset) - entry->inst_offset; + if (reloc->second_reloc_target) + reloc->second_reloc_offset = label_to_addr(reloc->second_reloc_target, entry->inst_offset) - entry->inst_offset; - if (inst->second_reloc_offset) { + if (reloc->second_reloc_offset) { // this is a branch instruction with two offset arguments - inst->bits3.break_cont.jip = jump_distance(inst->first_reloc_offset); - inst->bits3.break_cont.uip = jump_distance(inst->second_reloc_offset); - } else if (inst->first_reloc_offset) { + inst->bits3.break_cont.jip = jump_distance(reloc->first_reloc_offset); + inst->bits3.break_cont.uip = jump_distance(reloc->second_reloc_offset); + } else if (reloc->first_reloc_offset) { // this is a branch instruction with one offset argument - int offset = inst->first_reloc_offset; + int offset = reloc->first_reloc_offset; /* bspec: Unlike other flow control instructions, the offset used by JMPI is relative to the incremented instruction pointer rather than the IP value for the instruction itself. */ int is_jmpi = inst->header.opcode == BRW_OPCODE_JMPI; // target relative to the post-incremented IP, so delta == 1 if JMPI -- cgit v1.2.3