[lld] [llvm] [RISCV] Support RISCV Atomics ABI attributes (PR #84597)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 8 19:15:06 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 96813de52d09d983d14a30ef5e2b4b8658f8e952 714784926146c6b7873c3c702be9b87024861130 -- lld/ELF/Arch/RISCV.cpp llvm/include/llvm/Support/RISCVAttributeParser.h llvm/include/llvm/Support/RISCVAttributes.h llvm/lib/Support/RISCVAttributeParser.cpp llvm/lib/Support/RISCVAttributes.cpp llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp
index e44583fb80..70f28ea8ec 100644
--- a/lld/ELF/Arch/RISCV.cpp
+++ b/lld/ELF/Arch/RISCV.cpp
@@ -1086,11 +1086,10 @@ static void mergeArch(RISCVISAInfo::OrderedExtensionMap &mergedExts,
 
 static void mergeAtomic(DenseMap<unsigned, unsigned> &intAttr,
                         const InputSectionBase *oldSection,
-                        const InputSectionBase *newSection,
-                        unsigned int oldTag,
+                        const InputSectionBase *newSection, unsigned int oldTag,
                         unsigned int newTag) {
   using RISCVAttrs::RISCVAtomicAbiTag::AtomicABI;
-  llvm::errs() << "oldTag=" << oldTag << ", newTag=" << newTag <<"\n";
+  llvm::errs() << "oldTag=" << oldTag << ", newTag=" << newTag << "\n";
   // Same tags stay the same, and UNKNOWN is compatible with anything
   if (oldTag == newTag || newTag == AtomicABI::UNKNOWN)
     return;
@@ -1139,10 +1138,9 @@ static void mergeAtomic(DenseMap<unsigned, unsigned> &intAttr,
 }
 
 static void mergeX3RegUse(DenseMap<unsigned, unsigned> &intAttr,
-                        const InputSectionBase *oldSection,
-                        const InputSectionBase *newSection,
-                        unsigned int oldTag,
-                        unsigned int newTag) {
+                          const InputSectionBase *oldSection,
+                          const InputSectionBase *newSection,
+                          unsigned int oldTag, unsigned int newTag) {
   // X3/GP register usage ar incompatible and cannot be merged, with the
   // exception of the UNKNOWN or 0 value
   using RISCVAttrs::RISCVX3RegUse::X3RegUsage;
@@ -1159,7 +1157,7 @@ static void mergeX3RegUse(DenseMap<unsigned, unsigned> &intAttr,
   }
   // TODO: do we need to check the tags are < 2047?
 }
- 
+
 static RISCVAttributesSection *
 mergeAttributesSection(const SmallVector<InputSectionBase *, 0> &sections) {
   RISCVISAInfo::OrderedExtensionMap exts;
@@ -1219,8 +1217,10 @@ mergeAttributesSection(const SmallVector<InputSectionBase *, 0> &sections) {
           if (r.second) {
             firstAtomicAbi = sec;
           } else {
-            mergeAtomic(merged.intAttr, firstAtomicAbi, sec, r.first->getSecond(),  *i);
-            llvm::errs() << "Merged Attr = " <<merged.intAttr[tag.attr] << "\n";
+            mergeAtomic(merged.intAttr, firstAtomicAbi, sec,
+                        r.first->getSecond(), *i);
+            llvm::errs() << "Merged Attr = " << merged.intAttr[tag.attr]
+                         << "\n";
           }
         }
         continue;
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
index 3f4d692184..9a2621516b 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -78,8 +78,8 @@ void RISCVTargetStreamer::emitTargetAttributes(const MCSubtargetInfo &STI,
 
   if (STI.hasFeature(RISCV::FeatureStdExtA)) {
     unsigned AtomicABITag = STI.hasFeature(RISCV::FeatureTrailingSeqCstFence)
-                             ? RISCVAttrs::RISCVAtomicAbiTag::AtomicABI::A6S
-                             : RISCVAttrs::RISCVAtomicAbiTag::AtomicABI::A6C;
+                                ? RISCVAttrs::RISCVAtomicAbiTag::AtomicABI::A6S
+                                : RISCVAttrs::RISCVAtomicAbiTag::AtomicABI::A6C;
     emitAttribute(RISCVAttrs::ATOMIC_ABI, AtomicABITag);
   }
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/84597


More information about the llvm-commits mailing list