Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move floating point from libgcc out of IRAM #7180

Merged
merged 1 commit into from
Apr 3, 2020

Conversation

s-hadinger
Copy link
Contributor

@s-hadinger s-hadinger commented Apr 1, 2020

In Tasmota I realized the following floating point function are in precious IRAM:

                0x0000000040107184                __divsf3
                0x0000000040107240                __eqsf2
                0x0000000040107240                __nesf2
                0x0000000040107268                __gtsf2
                0x0000000040107288                __lesf2
                0x00000000401072d4                __gesf2
                0x00000000401072f4                __ltsf2
                0x0000000040107340                __unordsf2
                0x0000000040107364                __fixsfsi
                0x00000000401073a4                __nedf2
                0x00000000401073a4                __eqdf2
                0x00000000401073d4                __gtdf2
                0x00000000401073f8                __ledf2
                0x000000004010745c                __gedf2
                0x0000000040107480                __ltdf2
                0x00000000401074e4                __unorddf2

This PR adds a #define FP_IN_IROM to move floating point function out of IRAM to IROM.

  • *f2.o,*f3.o : float and double functions
  • *fsi.o: fp to int
  • *fdi.o: fp to long
  • *ifs.o: int to fp
  • *ids.o: long to fp

In Tasmota, the only functions from libgcc remaining in IRAM are: __modsi3 (integer modulus) and __ashrdi3 (bit shifting).

The net result is reducing IRAM usage by 1040 bytes.

Copy link
Collaborator

@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, in the Arduino core it is legal to do FP operations inside ISRs so this can't be done generally.

If you invert the logic (i.e. #ifndef FP_IN_PMEM) so that the core/PIO users don't see code breaking, and your own project can add the #define since it's a limited scope, then it would be more acceptable.

@s-hadinger
Copy link
Contributor Author

I totally agree. Actually this is already the case. By default the FP libs are still in IRAM as before, and you need to explicitly #define FP_IN_IROM to move them out of IRAM. No braking change.

The added lines are in the .irom0.text section.

Copy link
Collaborator

@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, sorry! I didn't catch which section was being edited.

@d-a-v d-a-v merged commit 483bfde into esp8266:master Apr 3, 2020
@Gisi0
Copy link

Gisi0 commented Apr 3, 2020

How can I use it?
Use of #define FP_IN_IROM in the source code seems not working.
I have no changes in the size.

using: framework-arduinoespressif8266 483bfde

@s-hadinger
Copy link
Contributor Author

I just realized the #defines were not automatically used when generating ld scripts. I created a new PR to solve this: #7188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants