aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2024-02-25 16:22:57 +0000
committerGitHub <noreply@github.com>2024-02-25 16:22:57 +0000
commitd6ded91121fa02837ef6c8c7f06d98ccf4a0fe16 (patch)
treee5150909522a68e02b53fb526017422ab0809c21 /llvm/lib/CodeGen/MachineInstr.cpp
parent2c5a68858b046c8a2ca3ba07ecd82771a5a9b884 (diff)
downloadllvm-d6ded91121fa02837ef6c8c7f06d98ccf4a0fe16.zip
llvm-d6ded91121fa02837ef6c8c7f06d98ccf4a0fe16.tar.gz
llvm-d6ded91121fa02837ef6c8c7f06d98ccf4a0fe16.tar.bz2
[Codegen] Change getSpillSize/getReloadSize to LocationSize. NFC (#82636)
This is a small part of #70452, attempting to take a small simpler part of it in isolation to simplify what remains. It changes the getSpillSize, getFoldedSpillSize, getRestoreSize and getFoldedRestoreSize methods to return optional<LocationSize> instead of unsigned. The code is intended to be the same, keeping the optional<> to specify when there was no size found, with some minor adjustments to make sure that unknown (~UINT64_C(0)) sizes are handled sensibly. Hopefully as more unsigned's are converted to LocationSize's the use of ~UINT64_C(0) can be cleaned up too.
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineInstr.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index efbcc83..6654e1d6 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -2354,29 +2354,35 @@ void MachineInstr::changeDebugValuesDefReg(Register Reg) {
using MMOList = SmallVector<const MachineMemOperand *, 2>;
-static unsigned getSpillSlotSize(const MMOList &Accesses,
- const MachineFrameInfo &MFI) {
- unsigned Size = 0;
+static LocationSize getSpillSlotSize(const MMOList &Accesses,
+ const MachineFrameInfo &MFI) {
+ uint64_t Size = 0;
for (const auto *A : Accesses)
if (MFI.isSpillSlotObjectIndex(
cast<FixedStackPseudoSourceValue>(A->getPseudoValue())
- ->getFrameIndex()))
- Size += A->getSize();
+ ->getFrameIndex())) {
+ uint64_t S = A->getSize();
+ if (S == ~UINT64_C(0))
+ return LocationSize::beforeOrAfterPointer();
+ Size += S;
+ }
return Size;
}
-std::optional<unsigned>
+std::optional<LocationSize>
MachineInstr::getSpillSize(const TargetInstrInfo *TII) const {
int FI;
if (TII->isStoreToStackSlotPostFE(*this, FI)) {
const MachineFrameInfo &MFI = getMF()->getFrameInfo();
- if (MFI.isSpillSlotObjectIndex(FI))
- return (*memoperands_begin())->getSize();
+ if (MFI.isSpillSlotObjectIndex(FI)) {
+ uint64_t Size = (*memoperands_begin())->getSize();
+ return Size == ~UINT64_C(0) ? LocationSize::beforeOrAfterPointer() : Size;
+ }
}
return std::nullopt;
}
-std::optional<unsigned>
+std::optional<LocationSize>
MachineInstr::getFoldedSpillSize(const TargetInstrInfo *TII) const {
MMOList Accesses;
if (TII->hasStoreToStackSlot(*this, Accesses))
@@ -2384,18 +2390,20 @@ MachineInstr::getFoldedSpillSize(const TargetInstrInfo *TII) const {
return std::nullopt;
}
-std::optional<unsigned>
+std::optional<LocationSize>
MachineInstr::getRestoreSize(const TargetInstrInfo *TII) const {
int FI;
if (TII->isLoadFromStackSlotPostFE(*this, FI)) {
const MachineFrameInfo &MFI = getMF()->getFrameInfo();
- if (MFI.isSpillSlotObjectIndex(FI))
- return (*memoperands_begin())->getSize();
+ if (MFI.isSpillSlotObjectIndex(FI)) {
+ uint64_t Size = (*memoperands_begin())->getSize();
+ return Size == ~UINT64_C(0) ? LocationSize::beforeOrAfterPointer() : Size;
+ }
}
return std::nullopt;
}
-std::optional<unsigned>
+std::optional<LocationSize>
MachineInstr::getFoldedRestoreSize(const TargetInstrInfo *TII) const {
MMOList Accesses;
if (TII->hasLoadFromStackSlot(*this, Accesses))