Skip to content

Commit 7b0c418

Browse files
committed
[RISCV] Move compressible registers to the beginning of the FP allocation order.
We don't have very many compressible FP instructions, just load and store. These instruction require the FP register to be f8-f15. This patch changes the FP allocation order to prioritize f10-f15 first. These are also the FP argument registers. So I allocated them in reverse order starting at f15 to avoid taking the first argument registers. This appears to match gcc allocation order. Reviewed By: asb Differential Revision: https://reviews.llvm.org/D146488
1 parent b0f02ce commit 7b0c418

File tree

118 files changed

+7731
-7726
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+7731
-7726
lines changed

llvm/lib/Target/RISCV/RISCVRegisterInfo.td

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,39 +223,44 @@ let RegAltNameIndices = [ABIRegAltName] in {
223223

224224
// The order of registers represents the preferred allocation sequence,
225225
// meaning caller-save regs are listed before callee-save.
226+
// We start by allocating argument registers in reverse order since they are
227+
// compressible.
226228
def FPR16 : RegisterClass<"RISCV", [f16], 16, (add
227-
(sequence "F%u_H", 0, 7),
228-
(sequence "F%u_H", 10, 17),
229-
(sequence "F%u_H", 28, 31),
230-
(sequence "F%u_H", 8, 9),
231-
(sequence "F%u_H", 18, 27)
229+
(sequence "F%u_H", 15, 10), // fa5-fa0
230+
(sequence "F%u_H", 0, 7), // ft0-f7
231+
(sequence "F%u_H", 16, 17), // fa6-fa7
232+
(sequence "F%u_H", 28, 31), // ft8-ft11
233+
(sequence "F%u_H", 8, 9), // fs0-fs1
234+
(sequence "F%u_H", 18, 27) // fs2-fs11
232235
)>;
233236

234237
def FPR32 : RegisterClass<"RISCV", [f32], 32, (add
238+
(sequence "F%u_F", 15, 10),
235239
(sequence "F%u_F", 0, 7),
236-
(sequence "F%u_F", 10, 17),
240+
(sequence "F%u_F", 16, 17),
237241
(sequence "F%u_F", 28, 31),
238242
(sequence "F%u_F", 8, 9),
239243
(sequence "F%u_F", 18, 27)
240244
)>;
241245

242246
def FPR32C : RegisterClass<"RISCV", [f32], 32, (add
243-
(sequence "F%u_F", 10, 15),
247+
(sequence "F%u_F", 15, 10),
244248
(sequence "F%u_F", 8, 9)
245249
)>;
246250

247251
// The order of registers represents the preferred allocation sequence,
248252
// meaning caller-save regs are listed before callee-save.
249253
def FPR64 : RegisterClass<"RISCV", [f64], 64, (add
254+
(sequence "F%u_D", 15, 10),
250255
(sequence "F%u_D", 0, 7),
251-
(sequence "F%u_D", 10, 17),
256+
(sequence "F%u_D", 16, 17),
252257
(sequence "F%u_D", 28, 31),
253258
(sequence "F%u_D", 8, 9),
254259
(sequence "F%u_D", 18, 27)
255260
)>;
256261

257262
def FPR64C : RegisterClass<"RISCV", [f64], 64, (add
258-
(sequence "F%u_D", 10, 15),
263+
(sequence "F%u_D", 15, 10),
259264
(sequence "F%u_D", 8, 9)
260265
)>;
261266

0 commit comments

Comments
 (0)