Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By Sprite_tm
#187 Dived into it a bit further. Here's my conclusion for what I can see:
The 'entry'/retw.n'-instuctions are indeed windowed instructions that seem to be unsupported on our chip: in xtensa-config.h:
Code: Select all#define XCHAL_HAVE_WINDOWED 0


I see all kinds of assembly sources neatly confirming to whatever this define says, either outputting optimized code if it's 1 or reverting to slower stuff if the define is 0. Unfortunately, the file that tells the compiler what to emit while outputting C code doesn't have such neatness:
gcc/config/xtensa/xtensa.c:
Code: Select all  if (total_size < (1 << (12+3)))
    insn = emit_insn (gen_entry (size_rtx));
  else
    {
      /* Use a8 as a temporary since a0-a7 may be live.  */
      rtx tmp_reg = gen_rtx_REG (Pmode, A8_REG);
      emit_insn (gen_entry (GEN_INT (MIN_FRAME_SIZE)));
      emit_move_insn (tmp_reg, GEN_INT (total_size - MIN_FRAME_SIZE));
      emit_insn (gen_subsi3 (tmp_reg, stack_pointer_rtx, tmp_reg));
      insn = emit_insn (gen_movsi (stack_pointer_rtx, tmp_reg));
    }

See that emit_insn (gen_entry (size_rtx))? That basically tells the compiler to directly output an "entry (something)"-instruction. No nice ifdefs for this bit of code with alternatives for non-windowed code (the 'if' you see is just for if the window size exceeds a certain limit).

As far as I can see it, apart from the scripting snafus plaguing crosstool-ng, the fact that buildroot doesn't want to build because of crtwhatever mis-assemblies etc, this is the main problem that's keeping us from compiling anything. I can see in some includes that do #ifdef the XCHAL_HAVE_WINDOWED function that
Code: Select allentry   sp, 64

can be replaced by
Code: Select alladdi    sp, sp, -32
s32i    a0, sp, 0

but I have no idea how to integrate that in the code, if I need to do something to keep a0 from clobbering, if the rest of the code will be happy with this and if this is indeed the final problem. EDIT: It's not. Nopping out code generation for these 2 instructions gives me an undefined instruction called 'call8'... I fear the entire windowed function set will have to be replaced if we want this to work.

So, unless someone with detailed gcc/xtensa knowledge can fill me in and/or hack this compiler to work, I fear all we can do is wait for Tensilica.
Last edited by Sprite_tm on Thu Sep 04, 2014 3:10 pm, edited 1 time in total.
User avatar
By jcmvbkbc
#189
Sprite_tm wrote:As far as I can see it, apart from the scripting snafus plaguing crosstool-ng, the fact that buildroot doesn't want to build because of crtwhatever mis-assemblies etc, this is the main problem that's keeping us from compiling anything. I can see in some includes that do #ifdef the XCHAL_HAVE_WINDOWED function that
Code: Select allentry   sp, 64

can be replaced by
Code: Select alladdi    sp, sp, -32
s32i    a0, sp, 0


These snippets are in the hand-written code. But I can't see anything related to XCHAL_HAVE_WINDOWED in the actual code generation part. My assumption is that gcc cannot generate code for the call0 ABI, but I'm not the compiler guy. So I've also posted that question to the Cadence compiler mailing list.
User avatar
By Sprite_tm
#190 Yep, same idea here. Can you point me to that mailing list? (Privately, if needed: jeroen at-sign spritesmods period com) I wouldn't mind following that discussion live.
User avatar
By jcmvbkbc
#191
Sprite_tm wrote:Can you point me to that mailing list?

It's an internal Cadence (former Tensilica) list, I don't think it's accessible from the outside, sorry.
I'll get back if I get any response there.