[llvm] d2d6c9f - [Alignment][NFC] GlobalIsel Utils inferAlignFromPtrInfo
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 31 00:01:56 PDT 2020
Author: Guillaume Chatelet
Date: 2020-03-31T06:58:57Z
New Revision: d2d6c9f59197bd82ec5bc9c003840f244a70a347
URL: https://github.com/llvm/llvm-project/commit/d2d6c9f59197bd82ec5bc9c003840f244a70a347
DIFF: https://github.com/llvm/llvm-project/commit/d2d6c9f59197bd82ec5bc9c003840f244a70a347.diff
LOG: [Alignment][NFC] GlobalIsel Utils inferAlignFromPtrInfo
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Reviewers: courbet
Subscribers: rovka, hiraditya, volkan, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D77079
Added:
Modified:
llvm/include/llvm/CodeGen/GlobalISel/Utils.h
llvm/lib/CodeGen/GlobalISel/Utils.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h
index c30f4db1cc8c..54079fffadbe 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h
@@ -16,6 +16,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/Register.h"
+#include "llvm/Support/Alignment.h"
#include "llvm/Support/LowLevelTypeImpl.h"
#include "llvm/Support/MachineValueType.h"
@@ -181,8 +182,13 @@ inline bool isKnownNeverSNaN(Register Val, const MachineRegisterInfo &MRI) {
return isKnownNeverNaN(Val, MRI, true);
}
-unsigned inferAlignmentFromPtrInfo(MachineFunction &MF,
- const MachinePointerInfo &MPO);
+Align inferAlignFromPtrInfo(MachineFunction &MF, const MachinePointerInfo &MPO);
+
+/// FIXME: Remove once the transition to Align is over.
+inline unsigned inferAlignmentFromPtrInfo(MachineFunction &MF,
+ const MachinePointerInfo &MPO) {
+ return inferAlignFromPtrInfo(MF, MPO).value();
+}
/// Return the least common multiple type of \p Ty0 and \p Ty1, by changing
/// the number of vector elements or scalar bitwidth. The intent is a
diff --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
index 27b346d05dbd..d248a2f1d9eb 100644
--- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
@@ -457,15 +457,16 @@ bool llvm::isKnownNeverNaN(Register Val, const MachineRegisterInfo &MRI,
return false;
}
-unsigned llvm::inferAlignmentFromPtrInfo(MachineFunction &MF,
- const MachinePointerInfo &MPO) {
+Align llvm::inferAlignFromPtrInfo(MachineFunction &MF,
+ const MachinePointerInfo &MPO) {
auto PSV = MPO.V.dyn_cast<const PseudoSourceValue *>();
if (auto FSPV = dyn_cast_or_null<FixedStackPseudoSourceValue>(PSV)) {
MachineFrameInfo &MFI = MF.getFrameInfo();
- return MinAlign(MFI.getObjectAlignment(FSPV->getFrameIndex()), MPO.Offset);
+ return commonAlignment(MFI.getObjectAlign(FSPV->getFrameIndex()),
+ MPO.Offset);
}
- return 1;
+ return Align(1);
}
Optional<APInt> llvm::ConstantFoldExtOp(unsigned Opcode, const unsigned Op1,
More information about the llvm-commits
mailing list