On Wed, Apr 1, 2020 at 12:06 AM Sven Barth <pascaldra...@googlemail.com>
wrote:

> Christo Crause <christo.cra...@gmail.com> schrieb am Di., 31. März 2020,
> 19:45:
>
>> On Tue, Mar 31, 2020 at 7:39 AM Sven Barth via fpc-devel <
>> fpc-devel@lists.freepascal.org> 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


> 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.
diff --git a/utils/fpcm/fpcmake.ini b/utils/fpcm/fpcmake.ini
index 42cd924023..1b3b179cfb 100644
--- a/utils/fpcm/fpcmake.ini
+++ b/utils/fpcm/fpcmake.ini
@@ -288,6 +288,13 @@ endif
 override FPCOPT+=-Cp$(SUBARCH)
 endif
 
+ifeq ($(FULL_TARGET),xtensa-embedded)
+ifeq ($(SUBARCH),)
+$(error When compiling for xtensa-embedded, a sub-architecture (e.g. SUBARCH=lx106 or SUBARCH=lx6) must be defined)
+endif
+override FPCOPT+=-Cp$(SUBARCH)
+endif
+
 # Full name of the target, including CPU and OS. For OSs limited
 # to 8.3 we only use the target OS
 ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to