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 <damien.lespiau@intel.com>
This commit is contained in:
Damien Lespiau
2013-01-21 21:41:36 +00:00
parent a45a47183a
commit 79c62f1134
4 changed files with 134 additions and 98 deletions
+12 -11
View File
@@ -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