[llvm] c7fa25f - [RISCV] Set the RVC bit in the ELF EFlags for C or Zca. (#80913)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 18:55:38 PST 2024
Author: Craig Topper
Date: 2024-02-06T18:55:35-08:00
New Revision: c7fa25f0b2398f7037af6e10b18456b69178f7c5
URL: https://github.com/llvm/llvm-project/commit/c7fa25f0b2398f7037af6e10b18456b69178f7c5
DIFF: https://github.com/llvm/llvm-project/commit/c7fa25f0b2398f7037af6e10b18456b69178f7c5.diff
LOG: [RISCV] Set the RVC bit in the ELF EFlags for C or Zca. (#80913)
Added:
Modified:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
llvm/test/MC/RISCV/elf-flags.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
index 961b8f0afe2254..b375e8bb4b8fac 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
@@ -87,14 +87,14 @@ void RISCVTargetELFStreamer::finishAttributeSection() {
void RISCVTargetELFStreamer::finish() {
RISCVTargetStreamer::finish();
MCAssembler &MCA = getStreamer().getAssembler();
- const FeatureBitset &Features = STI.getFeatureBits();
RISCVABI::ABI ABI = getTargetABI();
unsigned EFlags = MCA.getELFHeaderEFlags();
- if (Features[RISCV::FeatureStdExtC])
+ if (STI.hasFeature(RISCV::FeatureStdExtC) ||
+ STI.hasFeature(RISCV::FeatureStdExtZca))
EFlags |= ELF::EF_RISCV_RVC;
- if (Features[RISCV::FeatureStdExtZtso])
+ if (STI.hasFeature(RISCV::FeatureStdExtZtso))
EFlags |= ELF::EF_RISCV_TSO;
switch (ABI) {
diff --git a/llvm/test/MC/RISCV/elf-flags.s b/llvm/test/MC/RISCV/elf-flags.s
index 546e129fb71945..ee59e068e22898 100644
--- a/llvm/test/MC/RISCV/elf-flags.s
+++ b/llvm/test/MC/RISCV/elf-flags.s
@@ -2,6 +2,8 @@
# RUN: llvm-mc -triple=riscv64 -filetype=obj < %s | llvm-readobj --file-headers - | FileCheck -check-prefixes=CHECK-RVI %s
# RUN: llvm-mc -triple=riscv32 -mattr=+c -filetype=obj < %s | llvm-readobj --file-headers - | FileCheck -check-prefixes=CHECK-RVIC %s
# RUN: llvm-mc -triple=riscv64 -mattr=+c -filetype=obj < %s | llvm-readobj --file-headers - | FileCheck -check-prefixes=CHECK-RVIC %s
+# RUN: llvm-mc -triple=riscv32 -mattr=+zca -filetype=obj < %s | llvm-readobj --file-headers - | FileCheck -check-prefixes=CHECK-RVIC %s
+# RUN: llvm-mc -triple=riscv64 -mattr=+zca -filetype=obj < %s | llvm-readobj --file-headers - | FileCheck -check-prefixes=CHECK-RVIC %s
# RUN: llvm-mc -triple=riscv32 -mattr=+e -filetype=obj < %s \
# RUN: | llvm-readobj --file-headers - \
# RUN: | FileCheck -check-prefix=CHECK-RVE %s
More information about the llvm-commits
mailing list