From 53489ada12e9e27a4863ad96adf7a64edf16eef3 Mon Sep 17 00:00:00 2001 From: Shiva Chen Date: Fri, 2 Feb 2018 06:01:02 +0000 Subject: [RISCV] Add ELFObjectFileBase::getRISCVFeatures let llvm-objdump could get RISCV target feature llvm-objdump could get C feature by ELF::EF_RISCV_RVC e_flag, so then we don't have to add -mattr=+c on the command line. Differential Revision: https://reviews.llvm.org/D42629 llvm-svn: 324058 --- llvm/lib/Object/ELFObjectFile.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'llvm/lib/Object/ELFObjectFile.cpp') diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp index 3c1bdf5..e806c8f 100644 --- a/llvm/lib/Object/ELFObjectFile.cpp +++ b/llvm/lib/Object/ELFObjectFile.cpp @@ -238,12 +238,25 @@ SubtargetFeatures ELFObjectFileBase::getARMFeatures() const { return Features; } +SubtargetFeatures ELFObjectFileBase::getRISCVFeatures() const { + SubtargetFeatures Features; + unsigned PlatformFlags = getPlatformFlags(); + + if (PlatformFlags & ELF::EF_RISCV_RVC) { + Features.AddFeature("c"); + } + + return Features; +} + SubtargetFeatures ELFObjectFileBase::getFeatures() const { switch (getEMachine()) { case ELF::EM_MIPS: return getMIPSFeatures(); case ELF::EM_ARM: return getARMFeatures(); + case ELF::EM_RISCV: + return getRISCVFeatures(); default: return SubtargetFeatures(); } -- cgit v1.1