From d2d6c9f59197bd82ec5bc9c003840f244a70a347 Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Mon, 30 Mar 2020 18:55:41 +0000 Subject: [PATCH] [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 --- llvm/include/llvm/CodeGen/GlobalISel/Utils.h | 10 ++++++++-- llvm/lib/CodeGen/GlobalISel/Utils.cpp | 9 +++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h index c30f4db..54079ff 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 27b346d..d248a2f 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(); if (auto FSPV = dyn_cast_or_null(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 llvm::ConstantFoldExtOp(unsigned Opcode, const unsigned Op1, -- 2.7.4