This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 4/8] Implement target_emit_ops




On 02/08/2016 12:30 PM, Yao Qi wrote:
Antoine Tremblay <antoine.tremblay@ericsson.com> writes:

   I'm wondering is there a reason we don't use gcc to generate the
native bytecode like done on x86 ?

x86 has a macro like so :

#define EMIT_ASM(NAME, INSNS)						
   do									
     {									
       extern unsigned char start_ ## NAME, end_ ## NAME;		
       add_insns (&start_ ## NAME, &end_ ## NAME - &start_ ## NAME);	
       __asm__ ("jmp end_" #NAME "\n"					
	       "\t" "start_" #NAME ":"					
	       "\t" INSNS "\n"						
	       "\t" "end_" #NAME ":");					
     } while (0)


The reason is about the code readability.  We find the way we are using
in aarch64 is more readable than the way for x86.


OK.

   p += emit_stp (p, x0, x1, sp, preindex_memory_operand (-2 * 16));
   p += emit_str (p, lr, sp, offset_memory_operand (3 * 8));
   p += emit_str (p, fp, sp, offset_memory_operand (2 * 8));
   p += emit_add (p, fp, sp, immediate_operand (2 * 8));

vs.

   EMIT_ASM (amd64_prologue,
             "pushq %rbp\n\t"
             "movq %rsp,%rbp\n\t"
             "sub $0x20,%rsp\n\t"
             "movq %rdi,-8(%rbp)\n\t"
             "movq %rsi,-16(%rbp)");

Could the same be done for armv7 or there's a reason that prevents it ?


No reason prevents it, but the code should be readable.


OK thanks, It is readable that way but I think I'll go with EMIT_ASM... given that this should save me quite a bit of time considering thumb/arm versions and that there's not much emit_ functions done at the moment.

It should still be readable.

Regards,
Antoine


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]