Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIPS/Clang: Set HasUnalignedAccess false if +strict-align #87257

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

wzssyqa
Copy link
Contributor

@wzssyqa wzssyqa commented Apr 1, 2024

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.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Apr 1, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 1, 2024

@llvm/pr-subscribers-clang

Author: YunQiang Su (wzssyqa)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/87257.diff

1 Files Affected:

  • (modified) clang/lib/Basic/Targets/Mips.h (+6)
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;

@wzssyqa wzssyqa requested review from urnathan and brad0 April 1, 2024 17:18
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.
@wzssyqa wzssyqa merged commit 1bce411 into llvm:main Apr 4, 2024
4 checks passed
@wzssyqa wzssyqa deleted the HasUnalignedAccess branch April 4, 2024 13:51
@urnathan
Copy link
Contributor

urnathan commented Apr 4, 2024

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants