Does gcc compiler use push/pop for register backup if I dont write anything in clobber list? What happens for input and output list registers?
I will make a short asm inline that saves some general purpose registers to XMM/YMM registers then plays on general purpose registers. In the end, original values are returned from XMM/YMM registers to general purpose ones. Would compiler put push/pops to save them anyway?
How can I tell GCC compiler: "dont push/pop enything for me, I am using XMM/YMM for that purpose . Maybe I will do push/pops myself"
Something like:
__asm__ __volatile__ (
".intel_syntax noprefix \n\t"
"movd xmm0,eax \n\t"//storing in xmm registers instead of pushing
"movd xmm1,ebx \n\t"
"movd xmm2,ecx \n\t"
"movd xmm3,edx \n\t"
"movd xmm4,edi \n\t" // end of backups
//.
//... doing work
//.
"movd edi,xmm4 \n\t"
"movd edx,xmm3 \n\t"
"movd ecx,xmm2 \n\t"
"movd ebx,xmm1 \n\t"
"movd eax,xmm0 \n\t" // end of pops
://outputs
"=g"(x[0]), //%0
"=g"(x[1]) //%1
://inputs
"g"(x[0]), //%2
"g"(x[1]) //%3
://no clobber list
);
or something like this(I know this swapping is extremely slow, just wanted to have push pops working):
__asm__ __volatile__ (
".intel_syntax noprefix \n\t"
"push rax \n\t"
"push rbx \n\t"
"push rcx \n\t"
"push rdx \n\t"
"mov eax,%2 \n\t"
"mov ecx,%3 \n\t"
"mov edx,eax \n\t"
"mov eax,ecx \n\t"
"mov ecx,edx \n\t"
"mov %0,eax \n\t"
"mov %1,ecx \n\t"
"pop rdx \n\t"
"pop rcx \n\t"
"pop rbx \n\t"
"pop rax \n\t"
://outputs
"=g"(x[0]), //%0
"=g"(x[1]) //%1
://inputs
"g"(x[0]), //%2
"g"(x[1]) //%3
://no clobber list
);