Skip to content

Commit eb9bc38

Browse files
committed
[ELF][RISCV] Support RISC-V in getBitcodeMachineKind
Add Triple::riscv64 and Triple::riscv32 to getBitcodeMachineKind for get right e_machine during LTO. Reviewed By: ruiu, MaskRay Differential Revision: https://reviews.llvm.org/D52165 llvm-svn: 364996
1 parent 80177ca commit eb9bc38

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

lld/ELF/InputFiles.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,9 @@ static uint8_t getBitcodeMachineKind(StringRef Path, const Triple &T) {
14021402
case Triple::ppc64:
14031403
case Triple::ppc64le:
14041404
return EM_PPC64;
1405+
case Triple::riscv32:
1406+
case Triple::riscv64:
1407+
return EM_RISCV;
14051408
case Triple::x86:
14061409
return T.isOSIAMCU() ? EM_IAMCU : EM_386;
14071410
case Triple::x86_64:

lld/test/ELF/lto/riscv32.ll

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; REQUIRES: riscv
2+
3+
; RUN: llvm-as %s -o %t.o
4+
; RUN: ld.lld %t.o -o %t
5+
target datalayout = "e-m:e-p:32:32-i64:64-n32-S128"
6+
target triple = "riscv32-unknown-elf"
7+
8+
define void @f() {
9+
ret void
10+
}

lld/test/ELF/lto/riscv64.ll

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; REQUIRES: riscv
2+
3+
; RUN: llvm-as %s -o %t.o
4+
; RUN: ld.lld %t.o -o %t
5+
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
6+
target triple = "riscv64-unknown-elf"
7+
8+
define void @f() {
9+
ret void
10+
}

0 commit comments

Comments
 (0)