mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +01:00
[Hexagon] Convert getTypeAlignment to return Align
Plus some minor related changes of the same nature.
This commit is contained in:
parent
5eab663b62
commit
a981cd8df0
@ -1913,19 +1913,20 @@ const char* HexagonTargetLowering::getTargetNodeName(unsigned Opcode) const {
|
||||
}
|
||||
|
||||
void
|
||||
HexagonTargetLowering::validateConstPtrAlignment(SDValue Ptr, const SDLoc &dl,
|
||||
unsigned NeedAlign) const {
|
||||
HexagonTargetLowering::validateConstPtrAlignment(SDValue Ptr, Align NeedAlign,
|
||||
const SDLoc &dl) const {
|
||||
auto *CA = dyn_cast<ConstantSDNode>(Ptr);
|
||||
if (!CA)
|
||||
return;
|
||||
unsigned Addr = CA->getZExtValue();
|
||||
unsigned HaveAlign = Addr != 0 ? 1u << countTrailingZeros(Addr) : NeedAlign;
|
||||
Align HaveAlign =
|
||||
Addr != 0 ? Align(1u << countTrailingZeros(Addr)) : NeedAlign;
|
||||
if (HaveAlign < NeedAlign) {
|
||||
std::string ErrMsg;
|
||||
raw_string_ostream O(ErrMsg);
|
||||
O << "Misaligned constant address: " << format_hex(Addr, 10)
|
||||
<< " has alignment " << HaveAlign
|
||||
<< ", but the memory access requires " << NeedAlign;
|
||||
<< " has alignment " << HaveAlign.value()
|
||||
<< ", but the memory access requires " << NeedAlign.value();
|
||||
if (DebugLoc DL = dl.getDebugLoc())
|
||||
DL.print(O << ", at ");
|
||||
report_fatal_error(O.str());
|
||||
@ -2900,8 +2901,8 @@ HexagonTargetLowering::LowerLoad(SDValue Op, SelectionDAG &DAG) const {
|
||||
LN = cast<LoadSDNode>(NL.getNode());
|
||||
}
|
||||
|
||||
unsigned ClaimAlign = LN->getAlignment();
|
||||
validateConstPtrAlignment(LN->getBasePtr(), dl, ClaimAlign);
|
||||
Align ClaimAlign = LN->getAlign();
|
||||
validateConstPtrAlignment(LN->getBasePtr(), ClaimAlign, dl);
|
||||
// Call LowerUnalignedLoad for all loads, it recognizes loads that
|
||||
// don't need extra aligning.
|
||||
SDValue LU = LowerUnalignedLoad(SDValue(LN, 0), DAG);
|
||||
@ -2932,12 +2933,11 @@ HexagonTargetLowering::LowerStore(SDValue Op, SelectionDAG &DAG) const {
|
||||
SN = cast<StoreSDNode>(NS.getNode());
|
||||
}
|
||||
|
||||
unsigned ClaimAlign = SN->getAlignment();
|
||||
SDValue Ptr = SN->getBasePtr();
|
||||
validateConstPtrAlignment(Ptr, dl, ClaimAlign);
|
||||
Align ClaimAlign = SN->getAlign();
|
||||
validateConstPtrAlignment(SN->getBasePtr(), ClaimAlign, dl);
|
||||
|
||||
MVT StoreTy = SN->getMemoryVT().getSimpleVT();
|
||||
unsigned NeedAlign = Subtarget.getTypeAlignment(StoreTy);
|
||||
Align NeedAlign = Subtarget.getTypeAlignment(StoreTy);
|
||||
if (ClaimAlign < NeedAlign)
|
||||
return expandUnalignedStore(SN, DAG);
|
||||
return SDValue(SN, 0);
|
||||
@ -2948,8 +2948,8 @@ HexagonTargetLowering::LowerUnalignedLoad(SDValue Op, SelectionDAG &DAG)
|
||||
const {
|
||||
LoadSDNode *LN = cast<LoadSDNode>(Op.getNode());
|
||||
MVT LoadTy = ty(Op);
|
||||
unsigned NeedAlign = Subtarget.getTypeAlignment(LoadTy);
|
||||
unsigned HaveAlign = LN->getAlignment();
|
||||
unsigned NeedAlign = Subtarget.getTypeAlignment(LoadTy).value();
|
||||
unsigned HaveAlign = LN->getAlign().value();
|
||||
if (HaveAlign >= NeedAlign)
|
||||
return Op;
|
||||
|
||||
|
@ -341,8 +341,8 @@ private:
|
||||
void initializeHVXLowering();
|
||||
unsigned getPreferredHvxVectorAction(MVT VecTy) const;
|
||||
|
||||
void validateConstPtrAlignment(SDValue Ptr, const SDLoc &dl,
|
||||
unsigned NeedAlign) const;
|
||||
void validateConstPtrAlignment(SDValue Ptr, Align NeedAlign,
|
||||
const SDLoc &dl) const;
|
||||
|
||||
std::pair<SDValue,int> getBaseAndOffset(SDValue Addr) const;
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "llvm/CodeGen/ScheduleDAGMutation.h"
|
||||
#include "llvm/CodeGen/TargetSubtargetInfo.h"
|
||||
#include "llvm/MC/MCInstrItineraries.h"
|
||||
#include "llvm/Support/Alignment.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -288,10 +289,10 @@ public:
|
||||
bool isHVXVectorType(MVT VecTy, bool IncludeBool = false) const;
|
||||
bool isTypeForHVX(Type *VecTy, bool IncludeBool = false) const;
|
||||
|
||||
unsigned getTypeAlignment(MVT Ty) const {
|
||||
Align getTypeAlignment(MVT Ty) const {
|
||||
if (isHVXVectorType(Ty, true))
|
||||
return getVectorLength();
|
||||
return Ty.getSizeInBits() / 8;
|
||||
return Align(getVectorLength());
|
||||
return Align(std::max<unsigned>(1, Ty.getSizeInBits() / 8));
|
||||
}
|
||||
|
||||
unsigned getL1CacheLineSize() const;
|
||||
|
Loading…
Reference in New Issue
Block a user