Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2020-03

Error building xtensa rtl

15 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Christo Crause

When building the xtensa rtl with

make rtl FPC=~/fpc/3.3.1/compiler/ppcrossxtensa CROSSOPT=-Cacall0 CPU_TARGET=xtensa OS_TARGET=embedded SUBARCH=esp8266 BINUTILSPREFIX=xtensa-lx106-elf-

the following errors are returned by as:
/home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s: Assembler messages:
/home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s:203: Error: unknown opcode or format name 'sext'
/home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s:204: Error: unknown opcode or format name 'sext'

When building with CROSSOPT=-Cawindowed as complains about other errors: /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s: Assembler messages:
/home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s:11: Error: unknown opcode or format name 'retw'

Any tips on how to build the xtensa rtl?

Reply by email

Florian Klämpfl
to Christo Crause
Christo Crause wrote 21 lines
When building the xtensa rtl with make rtl FPC=~/fpc/3.3.1/compiler/ppcrossxtensa CROSSOPT=-Cacall0 CPU_TARGET=xtensa OS_TARGET=embedded SUBARCH=esp8266 BINUTILSPREFIX=xtensa-lx106-elf- the following errors are returned by as: /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s: Assembler messages: /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s:203: Error: unknown opcode or format name 'sext' /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s:204: Error: unknown opcode or format name 'sext' When building with CROSSOPT=-Cawindowed as complains about other errors: /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s: Assembler messages: /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s:11: Error: unknown opcode or format name 'retw' Any tips on how to build the xtensa rtl?

I didn't care about the call0 abi yet. Is it used by the esp8266?

Reply by email

Christo Crause
to Florian Klämpfl
PM Florian Klämpfl wrote 25 lines
Am 28.03.20 um 21:33 schrieb Christo Crause via fpc-devel: > When building the xtensa rtl with > > make rtl FPC=~/fpc/3.3.1/compiler/ppcrossxtensa CROSSOPT=-Cacall0 > CPU_TARGET=xtensa OS_TARGET=embedded SUBARCH=esp8266 > BINUTILSPREFIX=xtensa-lx106-elf- > > the following errors are returned by as: > /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s: Assembler > messages: > /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s:203: Error: > unknown opcode or format name 'sext' > /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s:204: Error: > unknown opcode or format name 'sext' > > When building with CROSSOPT=-Cawindowed as complains about other errors: > /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s: Assembler > messages: > /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s:11: Error: > unknown opcode or format name 'retw' > > Any tips on how to build the xtensa rtl? I didn't care about the call0 abi yet. Is it used by the esp8266?

Inspecting some C examples I've compiled with PlatformIO for ESP8266 shows use of callx0 for the non-rtos SDK. My goal was just to test the cross compiler, but the RTL failed with error 2020031404 (in tcpuparamanager.init_values) which seems to suggest an ABI must be specified. Neither of the options I tried satisfied the assembler however.

Reply by email

Christo Crause
to Christo Crause
AM Christo Crause wrote 35 lines
On Sat, Mar 28, 2020 at 11:04 PM Florian Klämpfl wrote: > Am 28.03.20 um 21:33 schrieb Christo Crause via fpc-devel: > > When building the xtensa rtl with > > > > make rtl FPC=~/fpc/3.3.1/compiler/ppcrossxtensa CROSSOPT=-Cacall0 > > CPU_TARGET=xtensa OS_TARGET=embedded SUBARCH=esp8266 > > BINUTILSPREFIX=xtensa-lx106-elf- > > > > the following errors are returned by as: > > /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s: Assembler > > messages: > > /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s:203: Error: > > unknown opcode or format name 'sext' > > /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s:204: Error: > > unknown opcode or format name 'sext' > > > > When building with CROSSOPT=-Cawindowed as complains about other errors: > > /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s: Assembler > > messages: > > /home/christo/fpc/3.3.1/rtl/units/xtensa-embedded/system.s:11: Error: > > unknown opcode or format name 'retw' > > > > Any tips on how to build the xtensa rtl? > > I didn't care about the call0 abi yet. Is it used by the esp8266? > Inspecting some C examples I've compiled with PlatformIO for ESP8266 shows use of callx0 for the non-rtos SDK. My goal was just to test the cross compiler, but the RTL failed with error 2020031404 (in tcpuparamanager.init_values) which seems to suggest an ABI must be specified. Neither of the options I tried satisfied the assembler however.

According to the Xtensa ISA 4.3.8 the SEXT instruction is optional (and some others too) and apparently not implemented for ESP8266 according to core-isa.h in ESP8266_RTOS_SDK (
https://github.com/espressif/ESP8266_RTOS_SDK/blob/master/components/esp8266/include/xtensa/config/core-isa.h). This explains why xtensa-lx106-elf-as does not recognise the SEXT instruction.

It seems that a different instruction sequence should be used for sign extension for the lx106 subarch.

Also core-isa.h indicates XCHAL_HAVE_WINDOWED = 0, which I take to mean that the LX106 toolchain doesn't know/implement the windowed ABI, which explains why setting the FPC ABI to windowed caused as to flag retw as unknown.

Reply by email

Florian Klämpfl
to Christo Crause
Christo Crause wrote 10 lines
According to the Xtensa ISA 4.3.8 the SEXT instruction is optional (and some others too) and apparently not implemented for ESP8266 according to core-isa.h in ESP8266_RTOS_SDK (https://github.com/espressif/ESP8266_RTOS_SDK/blob/master/components/esp8266/include/xtensa/config/core-isa.h). This explains why xtensa-lx106-elf-as does not recognise the SEXT instruction. It seems that a different instruction sequence should be used for sign extension for the lx106 subarch.

Ok, I see. Let me first integrate everything done so far in trunk, then we can continue with the details :)

Also core-isa.h indicates XCHAL_HAVE_WINDOWED = 0, which I take to mean that the LX106 toolchain doesn't know/implement the windowed ABI, which explains why setting the FPC ABI to windowed caused as to flag retw as unknown.

Reply by email

Christo Crause
to Florian Klämpfl
PM Florian Klämpfl wrote 7 lines
Am 29.03.20 um 22:46 schrieb Christo Crause via fpc-devel: > It seems that a different instruction sequence should be used for sign > extension for the lx106 subarch. Ok, I see. Let me first integrate everything done so far in trunk, then we can continue with the details :)

I've noticed GCC uses the SLLI + SRAI instructions to perform sign extension on ESP8266.

Since different CPUs can support different subsets of the Xtensa instructions do you think a finalizecode type function can be used as a post code generation step to map unsupported instructions to alternative sequences?

Reply by email

Florian Klämpfl
to Christo Crause
Christo Crause wrote 20 lines
On Sun, Mar 29, 2020 at 11:00 PM Florian Klämpfl < > wrote: Am 29.03.20 um 22:46 schrieb Christo Crause via fpc-devel: > It seems that a different instruction sequence should be used for sign > extension for the lx106 subarch. Ok, I see. Let me first integrate everything done so far in trunk, then we can continue with the details :) I've noticed GCC uses the SLLI + SRAI instructions to perform sign extension on ESP8266. Since different CPUs can support different subsets of the Xtensa instructions do you think a finalizecode type function can be used as a post code generation step to map unsupported instructions to alternative sequences?

In this case just cgcpu can be adapted to generate the right code. This results normally in better code.

Reply by email

Sven Barth
to Christo Crause: On Sun, Mar 29, 2020 at 11:00 PM Florian Klämpfl I've noticed GCC uses the SLLI + SRAI…
Christo Crause wrote 21 lines
On Sun, Mar 29, 2020 at 11:00 PM Florian Klämpfl < > wrote: Am 29.03.20 um 22:46 schrieb Christo Crause via fpc-devel: > It seems that a different instruction sequence should be used for sign > extension for the lx106 subarch. Ok, I see. Let me first integrate everything done so far in trunk, then we can continue with the details :) I've noticed GCC uses the SLLI + SRAI instructions to perform sign extension on ESP8266. Since different CPUs can support different subsets of the Xtensa instructions do you think a finalizecode type function can be used as a post code generation step to map unsupported instructions to alternative sequences?

These are simply different CPU types (-CpXXX or selected by the controller type) which the code generator will handle accordingly. Just like it's done with ARM, AVR and all other platforms.

Regards,
Sven

Reply by email

Christo Crause
to Sven Barth

On Tue, Mar 31, 2020 at 7:39 AM Sven Barth via fpc-devel <

Show quoted text 29 lines
wrote: Am 30.03.2020 um 22:07 schrieb Christo Crause via fpc-devel: On Sun, Mar 29, 2020 at 11:00 PM Florian Klämpfl wrote: > Am 29.03.20 um 22:46 schrieb Christo Crause via fpc-devel: > > It seems that a different instruction sequence should be used for sign > > extension for the lx106 subarch. > > Ok, I see. Let me first integrate everything done so far in trunk, then > we can continue with the details :) > I've noticed GCC uses the SLLI + SRAI instructions to perform sign extension on ESP8266. Since different CPUs can support different subsets of the Xtensa instructions do you think a finalizecode type function can be used as a post code generation step to map unsupported instructions to alternative sequences? These are simply different CPU types (-CpXXX or selected by the controller type) which the code generator will handle accordingly. Just like it's done with ARM, AVR and all other platforms.

Make sense. The make files are not current set up like that for xtensa. I'll make a patch to make xtensa-embedded work like avr etc with regards to subarch. This will then make it easier to check for cpu_capabilities in the compiler.

Reply by email

Christo Crause
to Sven Barth: These are simply different CPU types (-CpXXX or selected by the controller type) which…

On Tue, Mar 31, 2020 at 7:39 AM Sven Barth via fpc-devel <

Show quoted text 17 lines
wrote: Am 30.03.2020 um 22:07 schrieb Christo Crause via fpc-devel: I've noticed GCC uses the SLLI + SRAI instructions to perform sign extension on ESP8266. Since different CPUs can support different subsets of the Xtensa instructions do you think a finalizecode type function can be used as a post code generation step to map unsupported instructions to alternative sequences? These are simply different CPU types (-CpXXX or selected by the controller type) which the code generator will handle accordingly. Just like it's done with ARM, AVR and all other platforms.

Attach please find a patch to rtl/embedded/MakeFile* to handle subarch similar to avr and others.
Also attached a patch that checks whether the SEXT instruction is available for the current subarchitecture, else it generates SLLI + SRAI combination.

I post the patches here for review since I'm not sure this is necessarily the style to be followed when checking capabilities.

Reply by email

Sven Barth
to Christo Crause

Christo Crause schrieb am Di., 31. März 2020,
19:45:

Show quoted text 22 lines
On Tue, Mar 31, 2020 at 7:39 AM Sven Barth via fpc-devel < > wrote: > Am 30.03.2020 um 22:07 schrieb Christo Crause via fpc-devel: > > I've noticed GCC uses the SLLI + SRAI instructions to perform sign > extension on ESP8266. > > Since different CPUs can support different subsets of the Xtensa > instructions do you think a finalizecode type function can be used as a > post code generation step to map unsupported instructions to alternative > sequences? > > > These are simply different CPU types (-CpXXX or selected by the > controller type) which the code generator will handle accordingly. Just > like it's done with ARM, AVR and all other platforms. > Attach please find a patch to rtl/embedded/MakeFile* to handle subarch similar to avr and others.

Did you manually edit the Makefile or regenerate it from the Makefile.fpc? If the former then your changes at the top will be overwritten by the next makefile regeneration.

Also attached a patch that checks whether the SEXT instruction is available

for the current subarchitecture, else it generates SLLI + SRAI combination.

If SLLI and SRAI are supported by the other processors supported by FPC then you don't need to check for the processor type, checking against the capability for SEXT is enough. If some processor does not support SLLI or SRAI either then this would need to be a capability as well.

Regards,
Sven

Reply by email

Christo Crause
to Sven Barth
AM Sven Barth wrote 30 lines
Christo Crause schrieb am Di., 31. März 2020, 19:45: > On Tue, Mar 31, 2020 at 7:39 AM Sven Barth via fpc-devel < > > wrote: > >> Am 30.03.2020 um 22:07 schrieb Christo Crause via fpc-devel: >> >> I've noticed GCC uses the SLLI + SRAI instructions to perform sign >> extension on ESP8266. >> >> Since different CPUs can support different subsets of the Xtensa >> instructions do you think a finalizecode type function can be used as a >> post code generation step to map unsupported instructions to alternative >> sequences? >> >> >> These are simply different CPU types (-CpXXX or selected by the >> controller type) which the code generator will handle accordingly. Just >> like it's done with ARM, AVR and all other platforms. >> > > Attach please find a patch to rtl/embedded/MakeFile* to handle subarch > similar to avr and others. > Did you manually edit the Makefile or regenerate it from the Makefile.fpc? If the former then your changes at the top will be overwritten by the next makefile regeneration.

I directly edited the makefile to demonstrate the principle. In addition to a change to makefile.fpc an update to fpcmake.ini is also required, see attached fpcmake.patch

Show quoted text 10 lines
Also attached a patch that checks whether the SEXT instruction is > available for the current subarchitecture, else it generates SLLI + SRAI > combination. > If SLLI and SRAI are supported by the other processors supported by FPC then you don't need to check for the processor type, checking against the capability for SEXT is enough. If some processor does not support SLLI or SRAI either then this would need to be a capability as well.

Good idea, the alternative instructions are part of the core ISA so it should always be supported.

Reply by email

Michael Ring
to Florian Klämpfl

doesn't it make sense to also include subarchs in xtensa-freertos?

diff --git a/utils/fpcm/fpcmake.ini b/utils/fpcm/fpcmake.ini index 16396ca921..9151c09021 100644
--- a/utils/fpcm/fpcmake.ini
+++ b/utils/fpcm/fpcmake.ini
@@ -295,6 +295,13 @@ endif
 override FPCOPT+=-Cp$(SUBARCH)
 endif

+ifeq ($(FULL_TARGET),xtensa-freertos)
+ifeq ($(SUBARCH),)
+$(error When compiling for xtensa-freertos, a sub-architecture (e.g. SUBARCH=lx106 or SUBARCH=lx6) must be defined)
+endif
+override FPCOPT+=-Cp$(SUBARCH)
+endif
+

Florian Klämpfl wrote 10 lines
Am 01.04.20 um 18:58 schrieb Christo Crause via fpc-devel: > I directly edited the makefile to demonstrate the principle. In > addition to a change to makefile.fpc an update to fpcmake.ini is also > required, see attached fpcmake.patch I committed the SUBARCH changes. _______________________________________________ fpc-devel maillist  -  https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email