[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gas/30746] New: [RISCV] upper immediate range should be signed
From: |
andrew.jones at linux dot dev |
Subject: |
[Bug gas/30746] New: [RISCV] upper immediate range should be signed |
Date: |
Fri, 11 Aug 2023 08:22:23 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=30746
Bug ID: 30746
Summary: [RISCV] upper immediate range should be signed
Product: binutils
Version: unspecified
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gas
Assignee: unassigned at sourceware dot org
Reporter: andrew.jones at linux dot dev
Target Milestone: ---
Instructions which have upper immediates (U-immediate) operands (LUI and AUIPC)
should accept negative values, as upper immediates are signed. A U-immediate is
20 bits which will be shifted left 12 bits and the lower 12 bits will always be
zero. After shifting, bit 31 is the sign bit. This implies that when the
immediate is provided as an operand with the lower 12 bits removed, that it
should have the range -524288..524287. However, gas requires the operand to
have the range 0..1048575, even though, after shifting, 524288..1048575 will
represent -2147483648..-4096. This works, but it's inconvenient to developers.
Test 1:
-------
$ echo "lui a0, -1" | riscv64-linux-gnu-as
{standard input}: Assembler messages:
{standard input}:1: Error: lui expression not in range 0..1048575
Expected result:
----------------
Assembling generates 0xfffff537, which can currently be generated with 'lui a0,
0xfffff'
Test 2:
-------
$ echo "auipc a0, -1" | riscv64-linux-gnu-as
{standard input}: Assembler messages:
{standard input}:1: Error: lui expression not in range 0..1048575
Expected result:
----------------
Assembling generates 0xfffff517, which can currently be generated with 'auipc
a0, 0xfffff'
Proposed solution:
------------------
Support the range -524288..1048575, where 524288..1048575 aliases -524288..-1
Additional notes:
-----------------
Another issue, as can be seen in the output above for the auipc test, is that
gas always outputs 'lui' in the error message, even when the instruction was
not lui.
--
You are receiving this mail because:
You are on the CC list for the bug.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug gas/30746] New: [RISCV] upper immediate range should be signed,
andrew.jones at linux dot dev <=