[clang] MIPS/Clang: Set HasUnalignedAccess false if +strict-align (PR #87257)
YunQiang Su via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 1 09:34:28 PDT 2024
https://github.com/wzssyqa created https://github.com/llvm/llvm-project/pull/87257
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.
>From ecee40e72582c98e74e89d3aff97a832ece3fd70 Mon Sep 17 00:00:00 2001
From: YunQiang Su <syq at gcc.gnu.org>
Date: Tue, 2 Apr 2024 00:20:55 +0800
Subject: [PATCH] MIPS/Clang: Set HasUnalignedAccess false if +strict-align
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.
---
clang/lib/Basic/Targets/Mips.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index c9dcf434c93b0b..f5ce1bc735a700 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -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")
@@ -330,6 +331,8 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
IsMicromips = true;
else if (Feature == "+mips32r6" || Feature == "+mips64r6")
HasUnalignedAccess = true;
+ else if (Feature == "+strict-align")
+ StrictAlign = true;
else if (Feature == "+dsp")
DspRev = std::max(DspRev, DSP1);
else if (Feature == "+dspr2")
@@ -368,6 +371,9 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
if (FPMode == FPXX && !OddSpregGiven)
NoOddSpreg = true;
+ if (StrictAlign)
+ HasUnalignedAccess = false;
+
setDataLayout();
return true;
More information about the cfe-commits
mailing list