[llvm] [RISCV] Remove StackAlign attribute enum. NFC (PR #79946)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 29 21:45:28 PST 2024
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/79946
The alignment is directly encoded in the attribute. There doesn't seem to be a good reason to give the possible alignments a name.
>From 1c09a6a5da722e8b0f448a1769fa6e7b1fd59d7c Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Mon, 29 Jan 2024 21:42:25 -0800
Subject: [PATCH] [RISCV] Remove StackAlign attribute enum. NFC
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/include/llvm/Support/RISCVAttributes.h | 2 --
.../lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp | 8 +++++---
llvm/unittests/Support/RISCVAttributeParserTest.cpp | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
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) {
More information about the llvm-commits
mailing list