Skip to content

Commit b8f39a8

Browse files
justsmthsamuel40791765
authored andcommitted
Fix FIPS delocator handling of floating-point immediates on aarch63 (#3029)
Addresses #3028 When GCC 15 compiles the FIPS module at `-O3` on aarch64, it emits `fmov` instructions with floating-point immediates (e.g. `fmov v8.4s, so it parses `#2.0e+0` as the integer `#2` followed by what it thinks is a symbol reference `.0e`. This gets turned into a redirector (`.Lbcm_redirector_.0e`), producing invalid assembly. This change fixes the issue in two ways: - **Grammar fix**: Adds a floating-point immediate alternative to the `RegisterOrConstant` rule in `delocate.peg`, so values like `#2.0e+0` are parsed as a single token. - **Pass-through**: Adds `fmov` to the special-case instruction list in `processAarch64Instruction()`. Since `fmov` only operates on registers and immediates (never memory), it never needs delocating and can safely be written through unchanged. The GCC 15 + FIPS exclusion in `arm-gcc-tests` CI is also removed now that the underlying issue is resolved. The `delocate.peg.go` file is regenerated from the grammar using the `peg` tool. The grammar change is the one line in `delocate.peg`; the rest of that file is mechanical. - Added 6 test cases to `testdata/aarch64-Basic/in.s` covering float immediates with exponent notation, simple decimals, negative values, fractional values, scalar forms, and register-to-register `fmov`. - All 19 existing delocator tests continue to pass. - Re-enabled the `arm-gcc-tests` CI matrix entry for GCC 15 + FIPS on arm64 which will validate the end-to-end build. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license. (cherry picked from commit 7b2a86c)
1 parent e732603 commit b8f39a8

5 files changed

Lines changed: 1788 additions & 1650 deletions

File tree

util/fipstools/delocate/delocate.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,14 @@ func (d *delocation) processAarch64Instruction(statement, instruction *node32) (
553553
d.writeNode(statement)
554554
return statement, nil
555555

556+
case "fmov":
557+
// fmov can take a floating-point immediate (e.g. #2.0e+0) whose
558+
// decimal point and exponent notation can be misinterpreted as a
559+
// symbol reference by the parser. fmov only operates on registers
560+
// and immediates, never memory, so it is safe to pass through.
561+
d.writeNode(statement)
562+
return statement, nil
563+
556564
case "mrs":
557565
// Functions that take special register names also look like a symbol
558566
// reference to the parser.

util/fipstools/delocate/delocate.peg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ IndirectionIndicator <- '*'
8080
RegisterOrConstant <- (('%'[[A-Z]][[A-Z0-9]]*) /
8181
('$' [0-9]+ WS? '*' WS? '(' [0-9]+ WS? '-' WS? [0-9]+ ')' ) /
8282
('$'? ((Offset Offset) / Offset)) /
83+
('#' '-'? [0-9]+ '.' [0-9]+ ([eE] [+\-]? [0-9]+)? ) /
8384
('#' Offset ('*' [0-9]+ ('-' [0-9] [0-9]*)?)? ) /
8485
('#' '~'? '(' [0-9] WS? "<<" WS? [0-9] [0-9]? ')' ) /
8586
(('#' / '$') '~'? '0x'? [[0-9A-F]]+ ) /

0 commit comments

Comments
 (0)