Skip to content

Commit

Permalink
MIPS/Clang: Set HasUnalignedAccess false if +strict-align (llvm#87257)
Browse files Browse the repository at this point in the history
TargetInfo has HasUnalignedAccess support now. For MIPSr6, we should set
it according strict-align.

For pre-R6, we always set strict-align and HasUnalignedAccess to false.
  • Loading branch information
wzssyqa authored Apr 4, 2024
1 parent ea88bb1 commit 1bce411
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clang/lib/Basic/Targets/Mips.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
FPMode = isFP64Default() ? FP64 : FPXX;
NoOddSpreg = false;
bool OddSpregGiven = false;
bool StrictAlign = false;

for (const auto &Feature : Features) {
if (Feature == "+single-float")
Expand All @@ -330,6 +331,10 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
IsMicromips = true;
else if (Feature == "+mips32r6" || Feature == "+mips64r6")
HasUnalignedAccess = true;
// We cannot be sure that the order of strict-align vs mips32r6.
// Thus we need an extra variable here.
else if (Feature == "+strict-align")
StrictAlign = true;
else if (Feature == "+dsp")
DspRev = std::max(DspRev, DSP1);
else if (Feature == "+dspr2")
Expand Down Expand Up @@ -368,6 +373,9 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
if (FPMode == FPXX && !OddSpregGiven)
NoOddSpreg = true;

if (StrictAlign)
HasUnalignedAccess = false;

setDataLayout();

return true;
Expand Down

0 comments on commit 1bce411

Please sign in to comment.