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