Skip to content

Conversation

@aykevl
Copy link
Member

@aykevl aykevl commented May 12, 2020

Eventually we might want to start using the FPU, but the easy option right now is to simply disable it everywhere. Previously, it depended on whether Clang was built as part of TinyGo or it was an external binary (but Go code compiled with TinyGo never used the FPU). By setting the floating point mode explicitly, such inconsistencies are avoided.

This commit creates a new cortex-m4 target which can be the central place for setting FPU-related settings across all Cortex-M4 chips.

Tested on the pca10040 and the ItsyBitsy-m4.

@aykevl
Copy link
Member Author

aykevl commented May 12, 2020

What we need before we can enable the FPU (and actually make use of it):

  • Proper save/restore of FPU registers during task switching. This will have an overhead (64 byte of stack per goroutine and about 17 cycles).
  • The right features enabled so that TinyGo will also emit floating point instructions instead of libcalls.

@sago35
Copy link
Member

sago35 commented May 22, 2020

PyPortal (atsamd51j20a) worked correctly with the binary in the CI results section of Azure Pipelines.

Later, I'll try feather-m4 (atsamd51j19a) and wioterminal (atsamd51p19a).

@sago35
Copy link
Member

sago35 commented May 22, 2020

The feather-m4 (atsamd51j19a) also works.

It works without changing the atsamd51j19a.json, is that as intended?
I'm thinking that it works because I changed the options in LLVM, is that correct?

@sago35
Copy link
Member

sago35 commented May 22, 2020

@aykevl
If possible, I'd like to you to merge into dev.

@sago35
Copy link
Member

sago35 commented May 23, 2020

wioterminal (atsamd51p19a) also works.

@sago35
Copy link
Member

sago35 commented May 23, 2020

Please update this file too. @aykevl

targets/atsamd51j19a.json

{
	"inherits": ["cortex-m4"],
	"build-tags": ["atsamd51j19", "atsamd51", "sam"],
	"cflags": [
		"-Qunused-arguments"
	],
	"linkerscript": "targets/atsamd51.ld",
	"extra-files": [
		"src/device/sam/atsamd51j19a.s"
	]
}

@deadprogram
Copy link
Member

@aykevl do you want to make the change proposed by @sago35 before I merge this PR?

@deadprogram deadprogram changed the title arm: make FPU configuraton consistent arm: make FPU configuration consistent May 23, 2020
Eventually we might want to start using the FPU, but the easy option
right now is to simply disable it everywhere. Previously, it depended on
whether Clang was built as part of TinyGo or it was an external binary.
By setting the floating point mode explicitly, such inconsistencies are
avoided.

This commit creates a new cortex-m4 target which can be the central
place for setting FPU-related settings across all Cortex-M4 chips.
@aykevl
Copy link
Member Author

aykevl commented May 23, 2020

I've updated the atsamd51j19a, the nrf52840, and the stm32f4 with the same changes. Somehow I missed those (this time I grepped for v7em). It should be ready now, although I haven't tested all of those (I only tested floats on the nrf52840).

@deadprogram
Copy link
Member

Looks good and all tests passing. Now merging, thanks @aykevl and @sago35

@deadprogram deadprogram merged commit 9f4459c into dev May 26, 2020
@deadprogram deadprogram deleted the arm-fix-fpu branch May 26, 2020 14:39
@sago35 sago35 mentioned this pull request May 29, 2020
5 tasks
@niaow niaow added this to the v0.14 milestone Jun 27, 2020
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.

5 participants