Skip to content

Commit 26e7262

Browse files
ylzsxGroverkss
authored andcommitted
[MC][LoongArch] Change default cpu in MCSubtargetInfo. (llvm#114922)
The default value of this CPU affects the `FeatureBits` obtained by `LoongArchTargetELFStreamer` when creating an ELF file, and it will further affect the `Flags` field in the generated file. So, the default CPU value should be consistent with the `initializeSubtargetDependencies` in `LoongArchSubtarget.cpp`. Otherwise, the `Flags` field may be unexpected.
1 parent 588ab87 commit 26e7262

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCTargetDesc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static MCInstrInfo *createLoongArchMCInstrInfo() {
5555
static MCSubtargetInfo *
5656
createLoongArchMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
5757
if (CPU.empty() || CPU == "generic")
58-
CPU = TT.isArch64Bit() ? "la464" : "generic-la32";
58+
CPU = TT.isArch64Bit() ? "generic-la64" : "generic-la32";
5959
return createLoongArchMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
6060
}
6161

llvm/test/CodeGen/LoongArch/e_flags.ll

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
; RUN: llc --mtriple=loongarch32 --filetype=obj %s -o %t-la32s
2+
; RUN: llvm-readelf -h %t-la32s | FileCheck %s --check-prefixes=ILP32,ABI-S --match-full-lines
3+
14
; RUN: llc --mtriple=loongarch32 -mattr=+d --filetype=obj %s -o %t-la32
25
; RUN: llvm-readelf -h %t-la32 | FileCheck %s --check-prefixes=ILP32,ABI-D --match-full-lines
36

@@ -10,6 +13,9 @@
1013
; RUN: llc --mtriple=loongarch32 -mattr=+d --filetype=obj %s --target-abi=ilp32d -o %t-ilp32d
1114
; RUN: llvm-readelf -h %t-ilp32d | FileCheck %s --check-prefixes=ILP32,ABI-D --match-full-lines
1215

16+
; RUN: llc --mtriple=loongarch64 --filetype=obj %s -o %t-la64d
17+
; RUN: llvm-readelf -h %t-la64d | FileCheck %s --check-prefixes=LP64,ABI-D --match-full-lines
18+
1319
; RUN: llc --mtriple=loongarch64 -mattr=+d --filetype=obj %s -o %t-la64
1420
; RUN: llvm-readelf -h %t-la64 | FileCheck %s --check-prefixes=LP64,ABI-D --match-full-lines
1521

0 commit comments

Comments
 (0)