Skip to content

Commit

Permalink
[RISCV] Add preferred function and loop alignment RISCVSubtarget. NFC
Browse files Browse the repository at this point in the history
These seem like properties we will want to adjust based on -mtune.
Move them to subtarget like is done on ARM and AArch64. Don't add
any overrides yet.

Note there's a slight change here. We are now passing Align(1) for
preferred function alignment where we previously passed the minimum
alignment. As far as I could tell, it will be maxed with min when
it used so this should be ok.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D144048
  • Loading branch information
topperc committed Feb 17, 2023
1 parent b22aa3d commit 22b564c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Expand Up @@ -1014,7 +1014,9 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
// Function alignments.
const Align FunctionAlignment(Subtarget.hasStdExtCOrZca() ? 2 : 4);
setMinFunctionAlignment(FunctionAlignment);
setPrefFunctionAlignment(FunctionAlignment);
// Set preferred alignments.
setPrefFunctionAlignment(Subtarget.getPrefFunctionAlignment());
setPrefLoopAlignment(Subtarget.getPrefLoopAlignment());

setMinimumJumpTableEntries(5);

Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/Target/RISCV/RISCVSubtarget.h
Expand Up @@ -56,6 +56,9 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
uint8_t MaxInterleaveFactor = 2;
RISCVABI::ABI TargetABI = RISCVABI::ABI_Unknown;
std::bitset<RISCV::NUM_TARGET_REGS> UserReservedRegister;
Align PrefFunctionAlignment;
Align PrefLoopAlignment;

RISCVFrameLowering FrameLowering;
RISCVInstrInfo InstrInfo;
RISCVRegisterInfo RegInfo;
Expand Down Expand Up @@ -95,6 +98,9 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
}
bool enableMachineScheduler() const override { return true; }

Align getPrefFunctionAlignment() const { return PrefFunctionAlignment; }
Align getPrefLoopAlignment() const { return PrefLoopAlignment; }

/// Returns RISCV processor family.
/// Avoid this function! CPU specifics should be kept local to this class
/// and preferably modeled with SubtargetFeatures or properties in
Expand Down

0 comments on commit 22b564c

Please sign in to comment.