Skip to content

Commit

Permalink
[MC][LoongArch] Change default cpu in MCSubtargetInfo. (llvm#114922)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ylzsx authored and Groverkss committed Nov 15, 2024
1 parent 588ab87 commit 26e7262
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static MCInstrInfo *createLoongArchMCInstrInfo() {
static MCSubtargetInfo *
createLoongArchMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
if (CPU.empty() || CPU == "generic")
CPU = TT.isArch64Bit() ? "la464" : "generic-la32";
CPU = TT.isArch64Bit() ? "generic-la64" : "generic-la32";
return createLoongArchMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
}

Expand Down
6 changes: 6 additions & 0 deletions llvm/test/CodeGen/LoongArch/e_flags.ll
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
; RUN: llc --mtriple=loongarch32 --filetype=obj %s -o %t-la32s
; RUN: llvm-readelf -h %t-la32s | FileCheck %s --check-prefixes=ILP32,ABI-S --match-full-lines

; RUN: llc --mtriple=loongarch32 -mattr=+d --filetype=obj %s -o %t-la32
; RUN: llvm-readelf -h %t-la32 | FileCheck %s --check-prefixes=ILP32,ABI-D --match-full-lines

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

; RUN: llc --mtriple=loongarch64 --filetype=obj %s -o %t-la64d
; RUN: llvm-readelf -h %t-la64d | FileCheck %s --check-prefixes=LP64,ABI-D --match-full-lines

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

Expand Down

0 comments on commit 26e7262

Please sign in to comment.