Skip to content

Commit 48578ef

Browse files
ylzsxheiher
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. (cherry picked from commit 75c2888)
1 parent 51dee6b commit 48578ef

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

lld/test/ELF/emulation-loongarch.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
# LA32-NEXT: StringTableSectionIndex:
3838
# LA32-NEXT: }
3939

40-
# RUN: llvm-mc -filetype=obj -triple=loongarch64 %s -o %t.o
40+
# RUN: llvm-mc -filetype=obj -triple=loongarch64 -mattr=+d %s -o %t.o
4141
# RUN: ld.lld %t.o -o %t
4242
# RUN: llvm-readobj --file-headers %t | FileCheck --check-prefix=LA64 %s
4343
# RUN: ld.lld -m elf64loongarch %t.o -o %t

lld/test/ELF/loongarch-interlink.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
# RUN: yaml2obj %t/blob.yaml -o %t/blob.o
55
# RUN: yaml2obj %t/v0-lp64d.yaml -o %t/v0-lp64d.o
6-
# RUN: llvm-mc --filetype=obj --triple=loongarch64-unknown-gnu %t/start.s -o %t/v1-lp64d.o
6+
# RUN: llvm-mc --filetype=obj --triple=loongarch64-unknown-gnu --mattr=+d %t/start.s -o %t/v1-lp64d.o
77
# RUN: llvm-mc --filetype=obj --triple=loongarch64-unknown-gnusf %t/start.s -o %t/v1-lp64s.o
8-
# RUN: llvm-mc --filetype=obj --triple=loongarch64-unknown-gnu %t/bar.s -o %t/v1-b-lp64d.o
8+
# RUN: llvm-mc --filetype=obj --triple=loongarch64-unknown-gnu --mattr=+d %t/bar.s -o %t/v1-b-lp64d.o
99

1010
## Check that binary input results in e_flags=0 output.
1111
# RUN: ld.lld -m elf64loongarch -b binary %t/blob.bin -o %t/blob.out

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 0 deletions
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 -mattr=+d --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)