Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Target/RISCV/RISCVFrameLowering.h
//===-- RISCVFrameLowering.h - Define frame lowering for RISCV -*- C++ -*--===// | //===-- RISCVFrameLowering.h - Define frame lowering for RISCV -*- C++ -*--===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// | // | ||||
// This class implements RISCV-specific bits of TargetFrameLowering class. | // This class implements RISCV-specific bits of TargetFrameLowering class. | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#ifndef LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H | #ifndef LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H | ||||
#define LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H | #define LLVM_LIB_TARGET_RISCV_RISCVFRAMELOWERING_H | ||||
#include "llvm/ADT/Optional.h" | |||||
#include "llvm/CodeGen/TargetFrameLowering.h" | #include "llvm/CodeGen/TargetFrameLowering.h" | ||||
#include "llvm/Support/TypeSize.h" | #include "llvm/Support/TypeSize.h" | ||||
namespace llvm { | namespace llvm { | ||||
class RISCVSubtarget; | class RISCVSubtarget; | ||||
class RISCVFrameLowering : public TargetFrameLowering { | class RISCVFrameLowering : public TargetFrameLowering { | ||||
public: | public: | ||||
Show All 28 Lines | bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, | ||||
ArrayRef<CalleeSavedInfo> CSI, | ArrayRef<CalleeSavedInfo> CSI, | ||||
const TargetRegisterInfo *TRI) const override; | const TargetRegisterInfo *TRI) const override; | ||||
bool | bool | ||||
restoreCalleeSavedRegisters(MachineBasicBlock &MBB, | restoreCalleeSavedRegisters(MachineBasicBlock &MBB, | ||||
MachineBasicBlock::iterator MI, | MachineBasicBlock::iterator MI, | ||||
MutableArrayRef<CalleeSavedInfo> CSI, | MutableArrayRef<CalleeSavedInfo> CSI, | ||||
const TargetRegisterInfo *TRI) const override; | const TargetRegisterInfo *TRI) const override; | ||||
// Get the first stack adjustment amount for SplitSPAdjust. | /// Returns whether the stack pointer (SP) should be adjusted in two | ||||
// Return 0 if we don't want to to split the SP adjustment in prologue and | /// adjustments in the prologue and epilogue ("split"), or only adjusted once. | ||||
asb: Nit: LLVM seems to mostly use prologue and epilogue spellings | |||||
// epilogue. | /// | ||||
uint64_t getFirstSPAdjustAmount(const MachineFunction &MF) const; | /// Splitting the SP adjustment can result in better code size. | ||||
/// | |||||
/// The result will be `None` if the SP adjustment should not be split, or an | |||||
Nit: optional => Opetional asb: Nit: optional => Opetional | |||||
Oh dear, I managed to typo my suggested correction! optional => Optional asb: Oh dear, I managed to typo my suggested correction!
optional => Optional | |||||
/// Optional containing the first adjustment amount if the adjustment should | |||||
/// be split. | |||||
/// | |||||
/// The first SP adjustment will never be more than the function's StackSize, | |||||
/// so that the second SP adjustment is monotinic. | |||||
Optional<uint64_t> | |||||
getFirstSPAdjustmentAmount(const MachineFunction &MF) const; | |||||
Should use a C++ style comment asb: Should use a C++ style comment | |||||
Actually I want to keep this as a doc comment, given it's in the header. lenary: Actually I want to keep this as a doc comment, given it's in the header. | |||||
So /// then? jrtc27: So `///` then? | |||||
Ah, I didn't realise LLVM had a preference, because there are both styles in the repository. lenary: Ah, I didn't realise LLVM had a preference, because there are both styles in the repository. | |||||
bool canUseAsPrologue(const MachineBasicBlock &MBB) const override; | bool canUseAsPrologue(const MachineBasicBlock &MBB) const override; | ||||
bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override; | bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override; | ||||
protected: | protected: | ||||
const RISCVSubtarget &STI; | const RISCVSubtarget &STI; | ||||
private: | private: | ||||
void determineFrameLayout(MachineFunction &MF) const; | void determineFrameLayout(MachineFunction &MF) const; | ||||
void adjustReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, | void adjustReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, | ||||
const DebugLoc &DL, Register DestReg, Register SrcReg, | const DebugLoc &DL, Register DestReg, Register SrcReg, | ||||
int64_t Val, MachineInstr::MIFlag Flag) const; | int64_t Val, MachineInstr::MIFlag Flag) const; | ||||
}; | }; | ||||
} | } | ||||
#endif | #endif |
Nit: LLVM seems to mostly use prologue and epilogue spellings