[clang] 1bce411 - MIPS/Clang: Set HasUnalignedAccess false if +strict-align (#87257)

via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 4 06:51:29 PDT 2024


Author: YunQiang Su
Date: 2024-04-04T21:51:25+08:00
New Revision: 1bce411073a1deafef998d0fe9e3ae74c4cef1e5

URL: https://github.com/llvm/llvm-project/commit/1bce411073a1deafef998d0fe9e3ae74c4cef1e5
DIFF: https://github.com/llvm/llvm-project/commit/1bce411073a1deafef998d0fe9e3ae74c4cef1e5.diff

LOG: MIPS/Clang: Set HasUnalignedAccess false if +strict-align (#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.

Added: 
    

Modified: 
    clang/lib/Basic/Targets/Mips.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index c9dcf434c93b0b..0d6e4b4d080890 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,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")
@@ -368,6 +373,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