Skip to content

Commit 6a6f184

Browse files
toppercfrederik-h
authored andcommitted
[RISCV] Shrink the size of the VLMul field in RegisterClass target flags. Use uint8_t for TSFlags. NFC (llvm#131227)
There are only 4 possible LMULs corresponding to log2 of 1, 2, 4, and 8. Those fit in 2 bits. Use uint8_t for the flag bits to match the size in TargetRegisterClass.
1 parent c5a8cab commit 6a6f184

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

llvm/lib/Target/RISCV/RISCVRegisterInfo.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,34 @@
2222
namespace llvm {
2323

2424
namespace RISCVRI {
25-
enum {
25+
enum : uint8_t {
2626
// The IsVRegClass value of this RegisterClass.
2727
IsVRegClassShift = 0,
2828
IsVRegClassShiftMask = 0b1 << IsVRegClassShift,
2929
// The VLMul value of this RegisterClass. This value is valid iff IsVRegClass
3030
// is true.
3131
VLMulShift = IsVRegClassShift + 1,
32-
VLMulShiftMask = 0b111 << VLMulShift,
32+
VLMulShiftMask = 0b11 << VLMulShift,
3333

3434
// The NF value of this RegisterClass. This value is valid iff IsVRegClass is
3535
// true.
36-
NFShift = VLMulShift + 3,
36+
NFShift = VLMulShift + 2,
3737
NFShiftMask = 0b111 << NFShift,
3838
};
3939

4040
/// \returns the IsVRegClass for the register class.
41-
static inline bool isVRegClass(uint64_t TSFlags) {
41+
static inline bool isVRegClass(uint8_t TSFlags) {
4242
return (TSFlags & IsVRegClassShiftMask) >> IsVRegClassShift;
4343
}
4444

4545
/// \returns the LMUL for the register class.
46-
static inline RISCVVType::VLMUL getLMul(uint64_t TSFlags) {
46+
static inline RISCVVType::VLMUL getLMul(uint8_t TSFlags) {
4747
return static_cast<RISCVVType::VLMUL>((TSFlags & VLMulShiftMask) >>
4848
VLMulShift);
4949
}
5050

5151
/// \returns the NF for the register class.
52-
static inline unsigned getNF(uint64_t TSFlags) {
52+
static inline unsigned getNF(uint8_t TSFlags) {
5353
return static_cast<unsigned>((TSFlags & NFShiftMask) >> NFShift) + 1;
5454
}
5555
} // namespace RISCVRI

llvm/lib/Target/RISCV/RISCVRegisterInfo.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ class RISCVRegisterClass<list<ValueType> regTypes, int align, dag regList>
229229
let CopyCost = !if(IsVRegClass, !mul(VLMul, NF), 1);
230230

231231
let TSFlags{0} = IsVRegClass;
232-
let TSFlags{3-1} = !logtwo(VLMul);
233-
let TSFlags{6-4} = !sub(NF, 1);
232+
let TSFlags{2-1} = !logtwo(VLMul);
233+
let TSFlags{5-3} = !sub(NF, 1);
234234
}
235235

236236
class GPRRegisterClass<dag regList>

0 commit comments

Comments
 (0)