-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[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
Conversation
The alignment is directly encoded in the attribute. There doesn't seem to be a good reason to give the possible alignments a name.
@llvm/pr-subscribers-llvm-support @llvm/pr-subscribers-backend-risc-v Author: Craig Topper (topperc) ChangesThe 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:
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) {
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The alignment is directly encoded in the attribute. There doesn't seem to be a good reason to give the possible alignments a name.