[llvm] a98662f - [Alignment][NFC] Update MachineMemOperand implementation to use MaybeAlign
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 27 01:16:04 PDT 2020
Author: Guillaume Chatelet
Date: 2020-03-27T08:06:10Z
New Revision: a98662f4c15e91b697e589ac93a39777a62bfb64
URL: https://github.com/llvm/llvm-project/commit/a98662f4c15e91b697e589ac93a39777a62bfb64
DIFF: https://github.com/llvm/llvm-project/commit/a98662f4c15e91b697e589ac93a39777a62bfb64.diff
LOG: [Alignment][NFC] Update MachineMemOperand implementation to use MaybeAlign
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
Reviewed By: courbet
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D76625
Added:
Modified:
llvm/include/llvm/CodeGen/MachineMemOperand.h
llvm/lib/CodeGen/MachineOperand.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/MachineMemOperand.h b/llvm/include/llvm/CodeGen/MachineMemOperand.h
index 7ee700c62a25..76ae8dec668f 100644
--- a/llvm/include/llvm/CodeGen/MachineMemOperand.h
+++ b/llvm/include/llvm/CodeGen/MachineMemOperand.h
@@ -169,7 +169,7 @@ class MachineMemOperand {
MachinePointerInfo PtrInfo;
uint64_t Size;
Flags FlagVals;
- uint16_t BaseAlignLog2; // log_2(base_alignment) + 1
+ Align BaseAlign;
MachineAtomicInfo AtomicInfo;
AAMDNodes AAInfo;
const MDNode *Ranges;
@@ -229,7 +229,7 @@ class MachineMemOperand {
/// Return the minimum known alignment in bytes of the base address, without
/// the offset.
- uint64_t getBaseAlignment() const { return (1ull << BaseAlignLog2) >> 1; }
+ uint64_t getBaseAlignment() const { return BaseAlign.value(); }
/// Return the AA tags for the memory reference.
AAMDNodes getAAInfo() const { return AAInfo; }
diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp
index c7cbd9e51aa5..47d1c68d8c44 100644
--- a/llvm/lib/CodeGen/MachineOperand.cpp
+++ b/llvm/lib/CodeGen/MachineOperand.cpp
@@ -1009,8 +1009,8 @@ MachineMemOperand::MachineMemOperand(MachinePointerInfo ptrinfo, Flags f,
const MDNode *Ranges, SyncScope::ID SSID,
AtomicOrdering Ordering,
AtomicOrdering FailureOrdering)
- : PtrInfo(ptrinfo), Size(s), FlagVals(f), BaseAlignLog2(Log2_32(a) + 1),
- AAInfo(AAInfo), Ranges(Ranges) {
+ : PtrInfo(ptrinfo), Size(s), FlagVals(f), BaseAlign(a), AAInfo(AAInfo),
+ Ranges(Ranges) {
assert((PtrInfo.V.isNull() || PtrInfo.V.is<const PseudoSourceValue *>() ||
isa<PointerType>(PtrInfo.V.get<const Value *>()->getType())) &&
"invalid pointer value");
@@ -1043,7 +1043,7 @@ void MachineMemOperand::refineAlignment(const MachineMemOperand *MMO) {
if (MMO->getBaseAlignment() >= getBaseAlignment()) {
// Update the alignment value.
- BaseAlignLog2 = Log2_32(MMO->getBaseAlignment()) + 1;
+ BaseAlign = Align(MMO->getBaseAlignment());
// Also update the base and offset, because the new alignment may
// not be applicable with the old ones.
PtrInfo = MMO->PtrInfo;
More information about the llvm-commits
mailing list