From f9f31ce6a906bad7e62829ccfe7701802c97a0b0 Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Thu, 5 Sep 2019 15:44:33 +0000 Subject: [PATCH] [Alignment][NFC] Change internal representation of TargetLowering.h 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: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67226 llvm-svn: 371082 --- llvm/include/llvm/CodeGen/TargetLowering.h | 24 ++++++++++++------------ llvm/lib/CodeGen/TargetLoweringBase.cpp | 4 ---- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h index 4b2af4f..6ff51ee 100644 --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -1578,22 +1578,22 @@ public: /// Return the minimum stack alignment of an argument. unsigned getMinStackArgumentAlignment() const { - return MinStackArgumentAlignment; + return MinStackArgumentAlignment.value(); } /// Return the minimum function alignment. unsigned getMinFunctionLogAlignment() const { - return MinFunctionLogAlignment; + return Log2(MinFunctionAlignment); } /// Return the preferred function alignment. unsigned getPrefFunctionLogAlignment() const { - return PrefFunctionLogAlignment; + return Log2(PrefFunctionAlignment); } /// Return the preferred loop alignment. virtual unsigned getPrefLoopLogAlignment(MachineLoop *ML = nullptr) const { - return PrefLoopLogAlignment; + return Log2(PrefLoopAlignment); } /// Should loops be aligned even when the function is marked OptSize (but not @@ -2106,14 +2106,14 @@ protected: /// Set the target's minimum function alignment (in log2(bytes)) void setMinFunctionLogAlignment(unsigned LogAlign) { - MinFunctionLogAlignment = LogAlign; + MinFunctionAlignment = llvm::Align(1ULL << LogAlign); } /// Set the target's preferred function alignment. This should be set if /// there is a performance benefit to higher-than-minimum alignment (in /// log2(bytes)) void setPrefFunctionLogAlignment(unsigned LogAlign) { - PrefFunctionLogAlignment = LogAlign; + PrefFunctionAlignment = llvm::Align(1ULL << LogAlign); } /// Set the target's preferred loop alignment. Default alignment is zero, it @@ -2121,12 +2121,12 @@ protected: /// specified in log2(bytes). The target may also override /// getPrefLoopAlignment to provide per-loop values. void setPrefLoopLogAlignment(unsigned LogAlign) { - PrefLoopLogAlignment = LogAlign; + PrefLoopAlignment = llvm::Align(1ULL << LogAlign); } /// Set the minimum stack alignment of an argument. void setMinStackArgumentAlignment(unsigned Align) { - MinStackArgumentAlignment = Align; + MinStackArgumentAlignment = llvm::Align(Align); } /// Set the maximum atomic operation size supported by the @@ -2688,18 +2688,18 @@ private: Sched::Preference SchedPreferenceInfo; /// The minimum alignment that any argument on the stack needs to have. - unsigned MinStackArgumentAlignment; + llvm::Align MinStackArgumentAlignment; /// The minimum function alignment (used when optimizing for size, and to /// prevent explicitly provided alignment from leading to incorrect code). - unsigned MinFunctionLogAlignment; + llvm::Align MinFunctionAlignment; /// The preferred function alignment (used when alignment unspecified and /// optimizing for speed). - unsigned PrefFunctionLogAlignment; + llvm::Align PrefFunctionAlignment; /// The preferred loop alignment (in log2 bot in bytes). - unsigned PrefLoopLogAlignment; + llvm::Align PrefLoopAlignment; /// Size in bits of the maximum atomics size the backend supports. /// Accesses larger than this will be expanded by AtomicExpandPass. diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index 970b206..320f931 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -583,11 +583,7 @@ TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm) : TM(tm) { BooleanFloatContents = UndefinedBooleanContent; BooleanVectorContents = UndefinedBooleanContent; SchedPreferenceInfo = Sched::ILP; - MinFunctionLogAlignment = 0; - PrefFunctionLogAlignment = 0; - PrefLoopLogAlignment = 0; GatherAllAliasesMaxDepth = 18; - MinStackArgumentAlignment = 1; // TODO: the default will be switched to 0 in the next commit, along // with the Target-specific changes necessary. MaxAtomicSizeInBitsSupported = 1024; -- 2.7.4