[PATCH] D122490: [RISCV] Generate EF_RISCV_RVC when .option rvc
luxufan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 25 09:42:50 PDT 2022
StephenFan created this revision.
StephenFan added reviewers: luismarques, asb, jrtc27, kito-cheng.
Herald added subscribers: s, VincentWu, luke957, vkmr, frasercrmck, evandro, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
StephenFan requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.
Because of `.option rvc` will enable RISC-V C extension, the eflag value
EF_RISCV_RVC should be specified in ELF Header Eflags.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D122490
Files:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
llvm/test/MC/RISCV/option-rvc-eflag.s
Index: llvm/test/MC/RISCV/option-rvc-eflag.s
===================================================================
--- /dev/null
+++ llvm/test/MC/RISCV/option-rvc-eflag.s
@@ -0,0 +1,9 @@
+# RUN: llvm-mc -triple riscv32 -filetype=obj %s -o - \
+# RUN: | llvm-readobj -h - | FileCheck -check-prefix=CHECK %s
+# RUN: llvm-mc -triple riscv64 -filetype=obj %s -o - \
+# RUN: | llvm-readobj -h - | FileCheck -check-prefix=CHECK %s
+
+# CHECK: Flags [ (0x1)
+# CHECK-NEXT: EF_RISCV_RVC (0x1)
+# CHECK-NEXT: ]
+.option rvc
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
===================================================================
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
@@ -47,7 +47,12 @@
void RISCVTargetELFStreamer::emitDirectiveOptionPop() {}
void RISCVTargetELFStreamer::emitDirectiveOptionPIC() {}
void RISCVTargetELFStreamer::emitDirectiveOptionNoPIC() {}
-void RISCVTargetELFStreamer::emitDirectiveOptionRVC() {}
+void RISCVTargetELFStreamer::emitDirectiveOptionRVC() {
+ MCAssembler &MCA = getStreamer().getAssembler();
+ unsigned Eflags = MCA.getELFHeaderEFlags();
+ Eflags |= ELF::EF_RISCV_RVC;
+ MCA.setELFHeaderEFlags(Eflags);
+}
void RISCVTargetELFStreamer::emitDirectiveOptionNoRVC() {}
void RISCVTargetELFStreamer::emitDirectiveOptionRelax() {}
void RISCVTargetELFStreamer::emitDirectiveOptionNoRelax() {}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122490.418257.patch
Type: text/x-patch
Size: 1439 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220325/5a8ea551/attachment.bin>
More information about the llvm-commits
mailing list