[llvm] [RISCV] Remove StackAlign attribute enum. NFC (PR #79946)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 21:45:56 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-risc-v

Author: Craig Topper (topperc)

<details>
<summary>Changes</summary>

The alignment is directly encoded in the attribute. There doesn't seem to be a good reason to give the possible alignments a name.

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


3 Files Affected:

- (modified) llvm/include/llvm/Support/RISCVAttributes.h (-2) 
- (modified) llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp (+5-3) 
- (modified) llvm/unittests/Support/RISCVAttributeParserTest.cpp (+2-2) 


``````````diff
diff --git a/llvm/include/llvm/Support/RISCVAttributes.h b/llvm/include/llvm/Support/RISCVAttributes.h
index 8643debb78ebc..18f5a84d21f25 100644
--- a/llvm/include/llvm/Support/RISCVAttributes.h
+++ b/llvm/include/llvm/Support/RISCVAttributes.h
@@ -34,8 +34,6 @@ enum AttrType : unsigned {
   PRIV_SPEC_REVISION = 12,
 };
 
-enum StackAlign { ALIGN_4 = 4, ALIGN_8 = 8, ALIGN_16 = 16 };
-
 enum { NOT_ALLOWED = 0, ALLOWED = 1 };
 
 } // namespace RISCVAttrs
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
index ac4861bf113eb..071a3a5aa5d6e 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -51,12 +51,14 @@ void RISCVTargetStreamer::setTargetABI(RISCVABI::ABI ABI) {
 void RISCVTargetStreamer::emitTargetAttributes(const MCSubtargetInfo &STI,
                                                bool EmitStackAlign) {
   if (EmitStackAlign) {
+    unsigned StackAlign;
     if (TargetABI == RISCVABI::ABI_ILP32E)
-      emitAttribute(RISCVAttrs::STACK_ALIGN, RISCVAttrs::ALIGN_4);
+      StackAlign = 4;
     else if (TargetABI == RISCVABI::ABI_LP64E)
-      emitAttribute(RISCVAttrs::STACK_ALIGN, RISCVAttrs::ALIGN_8);
+      StackAlign = 8;
     else
-      emitAttribute(RISCVAttrs::STACK_ALIGN, RISCVAttrs::ALIGN_16);
+      StackAlign = 16;
+    emitAttribute(RISCVAttrs::STACK_ALIGN, StackAlign);
   }
 
   auto ParseResult = RISCVFeatures::parseFeatureBits(
diff --git a/llvm/unittests/Support/RISCVAttributeParserTest.cpp b/llvm/unittests/Support/RISCVAttributeParserTest.cpp
index a9ede29c659cf..ca9e816ce8e0f 100644
--- a/llvm/unittests/Support/RISCVAttributeParserTest.cpp
+++ b/llvm/unittests/Support/RISCVAttributeParserTest.cpp
@@ -56,9 +56,9 @@ static bool testTagString(unsigned Tag, const char *name) {
 TEST(StackAlign, testAttribute) {
   EXPECT_TRUE(testTagString(4, "Tag_stack_align"));
   EXPECT_TRUE(
-      testAttribute(4, 4, RISCVAttrs::STACK_ALIGN, RISCVAttrs::ALIGN_4));
+      testAttribute(4, 4, RISCVAttrs::STACK_ALIGN, 4));
   EXPECT_TRUE(
-      testAttribute(4, 16, RISCVAttrs::STACK_ALIGN, RISCVAttrs::ALIGN_16));
+      testAttribute(4, 16, RISCVAttrs::STACK_ALIGN, 16));
 }
 
 TEST(UnalignedAccess, testAttribute) {

``````````

</details>


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


More information about the llvm-commits mailing list