xtensa: register FP opcodes for ESP32 and ESP32-S3 - #43
Open
hinaultd wants to merge 1 commit into
Open
Conversation
Both cores advertise a single-precision FPU -- XCHAL_HAVE_FP is 1 in their
core-isa.h, along with FP_DIV, FP_SQRT, FP_RECIP and FP_RSQRT -- but their
XtensaConfig had no .opcode_translators list. As a result no floating point
opcode table was attached, config->opcode_ops[opc] stayed NULL, and every FP
instruction ended up in the 'unimplemented opcode' path of
xtensa_tr_init_dc() (translate.c:886).
Reproducing is straightforward: run any ESP-IDF application that uses floats on
cpuType "esp32s3". The firmware I hit this with contains ~700 FP instructions
(180 lsx, 148 lsi, 100 add.s, 56 float.s) and aborts on the first one:
unimplemented opcode 'lsi' in slot 0 (pc = 4200bdad)
xtensa_fpu_opcodes is the correct table rather than xtensa_fpu2000_opcodes, for
two reasons: the lsip/ssip forms the compiler emits only exist in the former,
and FPU2000 provides neither divide nor square root, which both cores
advertise.
ESP32-S2 is deliberately left alone: XCHAL_HAVE_FP is 0 there, so it correctly
has no FP table.
Verified by building the xtensa target and running an ESP-IDF firmware that
previously failed on the first FP instruction; it now executes them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both cores advertise a single-precision FPU —
XCHAL_HAVE_FPis 1 in theircore-isa.h, along withFP_DIV,FP_SQRT,FP_RECIPandFP_RSQRT— buttheir
XtensaConfighad no.opcode_translatorslist. As a result no floatingpoint opcode table is attached,
config->opcode_ops[opc]stays NULL, and everyFP instruction ends up in the unimplemented opcode path of
xtensa_tr_init_dc()(translate.c:886).Reproducing is straightforward: run any ESP-IDF application that uses floats on
cpuType: "esp32s3". The firmware I hit this with contains around 700 FPinstructions (180
lsx, 148lsi, 100add.s, 56float.s) and aborts on thefirst one:
Why
xtensa_fpu_opcodesand notxtensa_fpu2000_opcodesTwo reasons, both checked against the tables in
translate.c:lsip/ssipforms the compiler emits exist only infpu_ops(37 and 23 occurrences in the firmware above);
FP_DIV,FP_SQRT,FP_RECIPandFP_RSQRT.Scope
ESP32-S2 is deliberately left alone:
XCHAL_HAVE_FPis 0 there, so itcorrectly has no FP table.
Verification
Built the
xtensatarget throughrenode-infrastructure's CMake and ran anESP-IDF firmware that previously aborted on its first FP instruction. It now
executes them, and the boot proceeds into application code.