forked from OSchip/llvm-project
[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
This commit is contained in:
parent
76c5ce5184
commit
53489ada12
|
@ -80,6 +80,8 @@ public:
|
|||
|
||||
SubtargetFeatures getARMFeatures() const;
|
||||
|
||||
SubtargetFeatures getRISCVFeatures() const;
|
||||
|
||||
void setARMSubArch(Triple &TheTriple) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+c < %s \
|
||||
# RUN: | llvm-objdump -mattr=+c -d - | FileCheck -check-prefix=CHECK-INST %s
|
||||
# RUN: | llvm-objdump -d - | FileCheck -check-prefix=CHECK-INST %s
|
||||
|
||||
# alpha and main are 8 byte alignment
|
||||
# but the alpha function's size is 6
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# RUN: llvm-mc %s -triple riscv32 -mattr=+c -show-encoding \
|
||||
# RUN: | FileCheck -check-prefix=CHECK-FIXUP %s
|
||||
# RUN: llvm-mc -triple riscv32 -filetype=obj -mattr=+c < %s \
|
||||
# RUN: | llvm-objdump -mattr=+c -d - | FileCheck -check-prefix=CHECK-INSTR %s
|
||||
# RUN: | llvm-objdump -d - | FileCheck -check-prefix=CHECK-INSTR %s
|
||||
|
||||
.LBB0_2:
|
||||
# CHECK-FIXUP: fixup A - offset: 0, value: .LBB0_2, kind: fixup_riscv_rvc_jump
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# RUN: llvm-mc -triple=riscv32 -mattr=+c -riscv-no-aliases -show-encoding < %s \
|
||||
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-INST %s
|
||||
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+c -riscv-no-aliases < %s \
|
||||
# RUN: | llvm-objdump -mattr=+c -d - | FileCheck -check-prefix=CHECK-INST %s
|
||||
# RUN: | llvm-objdump -d - | FileCheck -check-prefix=CHECK-INST %s
|
||||
# RUN: not llvm-mc -triple riscv32 \
|
||||
# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
|
||||
# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
# RUN: llvm-mc -triple=riscv64 -mattr=+c -riscv-no-aliases -show-encoding < %s \
|
||||
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-INST %s
|
||||
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+c < %s \
|
||||
# RUN: | llvm-objdump -mattr=+c -riscv-no-aliases -d - \
|
||||
# RUN: | llvm-objdump -riscv-no-aliases -d - \
|
||||
# RUN: | FileCheck -check-prefix=CHECK-INST %s
|
||||
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+c < %s \
|
||||
# RUN: | llvm-objdump -mattr=+c -riscv-no-aliases -d - \
|
||||
# RUN: | llvm-objdump -riscv-no-aliases -d - \
|
||||
# RUN: | FileCheck -check-prefix=CHECK-INST %s
|
||||
|
||||
# TODO: more exhaustive testing of immediate encoding.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# RUN: llvm-mc %s -triple=riscv32 -mattr=+c,+d -riscv-no-aliases -show-encoding \
|
||||
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-INST %s
|
||||
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+c,+d < %s \
|
||||
# RUN: | llvm-objdump -mattr=+c,+d -riscv-no-aliases -d - \
|
||||
# RUN: | llvm-objdump -mattr=+d -riscv-no-aliases -d - \
|
||||
# RUN: | FileCheck -check-prefix=CHECK-INST %s
|
||||
# RUN: not llvm-mc -triple riscv32 -mattr=+c\
|
||||
# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# RUN: llvm-mc %s -triple=riscv32 -mattr=+c,+f -riscv-no-aliases -show-encoding \
|
||||
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-INST %s
|
||||
# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+c,+f < %s \
|
||||
# RUN: | llvm-objdump -mattr=+c,+f -riscv-no-aliases -d - \
|
||||
# RUN: | llvm-objdump -mattr=+f -riscv-no-aliases -d - \
|
||||
# RUN: | FileCheck -check-prefix=CHECK-INST %s
|
||||
# RUN: not llvm-mc -triple riscv32 -mattr=+c \
|
||||
# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# RUN: llvm-mc -triple=riscv64 -mattr=+c -riscv-no-aliases -show-encoding < %s \
|
||||
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-INST %s
|
||||
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+c < %s \
|
||||
# RUN: | llvm-objdump -mattr=+c -riscv-no-aliases -d - \
|
||||
# RUN: | llvm-objdump -riscv-no-aliases -d - \
|
||||
# RUN: | FileCheck -check-prefix=CHECK-INST %s
|
||||
# RUN: not llvm-mc -triple riscv64 \
|
||||
# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# RUN: llvm-mc %s -triple=riscv64 -mattr=+c,+d -riscv-no-aliases -show-encoding \
|
||||
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-INST %s
|
||||
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+c,+d < %s \
|
||||
# RUN: | llvm-objdump -mattr=+c,+d -riscv-no-aliases -d - \
|
||||
# RUN: | llvm-objdump -mattr=+d -riscv-no-aliases -d - \
|
||||
# RUN: | FileCheck -check-prefix=CHECK-INST %s
|
||||
# RUN: not llvm-mc -triple riscv64 -mattr=+c\
|
||||
# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
|
||||
|
|
Loading…
Reference in New Issue