Skip to content

[RISCV] Remove StackAlign attribute enum. NFC #79946

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

Merged
merged 2 commits into from
Jan 30, 2024
Merged

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Jan 30, 2024

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

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

llvmbot commented Jan 30, 2024

@llvm/pr-subscribers-llvm-support

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

Author: Craig Topper (topperc)

Changes

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 --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) {

Copy link

github-actions bot commented Jan 30, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@wangpc-pp wangpc-pp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Contributor

@asb asb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@topperc topperc merged commit 80ee608 into llvm:main Jan 30, 2024
@topperc topperc deleted the pr/stack-align branch January 30, 2024 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants