Skip to content

Commit ccf5417

Browse files
zhaixiaojuanheiher
authored andcommitted
Enable loongarch64 LLVM target
1 parent 10f7ba5 commit ccf5417

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

compiler/rustc_llvm/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const OPTIONAL_COMPONENTS: &[&str] = &[
1010
"aarch64",
1111
"amdgpu",
1212
"avr",
13+
"loongarch",
1314
"m68k",
1415
"mips",
1516
"powerpc",

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) {
146146
#define SUBTARGET_HEXAGON
147147
#endif
148148

149+
#ifdef LLVM_COMPONENT_LOONGARCH
150+
#define SUBTARGET_LOONGARCH SUBTARGET(LoongArch)
151+
#else
152+
#define SUBTARGET_LOONGARCH
153+
#endif
154+
149155
#define GEN_SUBTARGETS \
150156
SUBTARGET_X86 \
151157
SUBTARGET_ARM \
@@ -159,6 +165,7 @@ extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) {
159165
SUBTARGET_SPARC \
160166
SUBTARGET_HEXAGON \
161167
SUBTARGET_RISCV \
168+
SUBTARGET_LOONGARCH \
162169

163170
#define SUBTARGET(x) \
164171
namespace llvm { \

compiler/rustc_llvm/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ pub fn initialize_available_targets() {
102102
LLVMInitializeM68kAsmPrinter,
103103
LLVMInitializeM68kAsmParser
104104
);
105+
init_target!(
106+
llvm_component = "loongarch",
107+
LLVMInitializeLoongArchTargetInfo,
108+
LLVMInitializeLoongArchTarget,
109+
LLVMInitializeLoongArchTargetMC,
110+
LLVMInitializeLoongArchAsmPrinter,
111+
LLVMInitializeLoongArchAsmParser
112+
);
105113
init_target!(
106114
llvm_component = "mips",
107115
LLVMInitializeMipsTargetInfo,

config.example.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ changelog-seen = 2
8888
# the resulting rustc being unable to compile for the disabled architectures.
8989
#
9090
# To add support for new targets, see https://rustc-dev-guide.rust-lang.org/building/new-target.html.
91-
#targets = "AArch64;ARM;BPF;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;Sparc;SystemZ;WebAssembly;X86"
91+
#targets = "AArch64;ARM;BPF;Hexagon;LoongArch;MSP430;Mips;NVPTX;PowerPC;RISCV;Sparc;SystemZ;WebAssembly;X86"
9292

9393
# LLVM experimental targets to build support for. These targets are specified in
9494
# the same format as above, but since these targets are experimental, they are

src/bootstrap/llvm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ impl Step for Llvm {
291291
let llvm_targets = match &builder.config.llvm_targets {
292292
Some(s) => s,
293293
None => {
294-
"AArch64;ARM;BPF;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;\
294+
"AArch64;ARM;BPF;Hexagon;LoongArch;MSP430;Mips;NVPTX;PowerPC;RISCV;\
295295
Sparc;SystemZ;WebAssembly;X86"
296296
}
297297
};

0 commit comments

Comments
 (0)