Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang][LoongArch] Handle -march/-m{single,double,soft}-float/-mfpu o…
…ptions This patch adds options -march, -msingle-float, -mdouble-float, -msoft-float and -mfpu for LoongArch. Clang options `msingle_float` and `mdouble_float` are moved from `m_mips_Features_Group` to `m_Group` because now more than targets use them. Reference: https://github.com/loongson/LoongArch-Documentation/blob/main/docs/LoongArch-toolchain-conventions-EN.adoc TODO: add -mtune. Differential Revision: https://reviews.llvm.org/D136146
- Loading branch information
1 parent
098e201
commit 135a927
Showing
18 changed files
with
403 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// RUN: not %clang --target=loongarch64 -march=loongarch -fsyntax-only %s 2>&1 \ | ||
// RUN: | FileCheck --check-prefix=LOONGARCH %s | ||
// LOONGARCH: error: invalid arch name '-march=loongarch' | ||
|
||
// RUN: not %clang --target=loongarch64 -march=LA464 -fsyntax-only %s 2>&1 \ | ||
// RUN: | FileCheck --check-prefix=LA464-UPPER %s | ||
// LA464-UPPER: error: invalid arch name '-march=LA464' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: %clang --target=loongarch64 -march=loongarch64 -fsyntax-only %s -### 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=CC1-LOONGARCH64 | ||
// RUN: %clang --target=loongarch64 -march=la464 -fsyntax-only %s -### 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=CC1-LA464 | ||
// RUN: %clang --target=loongarch64 -march=loongarch64 -S -emit-llvm %s -o - \ | ||
// RUN: | FileCheck %s --check-prefix=IR-LOONGARCH64 | ||
// RUN: %clang --target=loongarch64 -march=la464 -S -emit-llvm %s -o - \ | ||
// RUN: | FileCheck %s --check-prefix=IR-LA464 | ||
|
||
// CC1-LOONGARCH64-NOT: "-target-feature" | ||
// CC1-LOONGARCH64: "-target-feature" "+64bit" | ||
// CC1-LOONGARCH64-SAME: {{^}} "-target-feature" "+f" | ||
// CC1-LOONGARCH64-SAME: {{^}} "-target-feature" "+d" | ||
// CC1-LOONGARCH64-NOT: "-target-feature" | ||
// CC1-LOONGARCH64: "-target-abi" "lp64d" | ||
|
||
// CC1-LA464-NOT: "-target-feature" | ||
// CC1-LA464: "-target-feature" "+64bit" | ||
// CC1-LA464-SAME: {{^}} "-target-feature" "+f" | ||
// CC1-LA464-SAME: {{^}} "-target-feature" "+d" | ||
// CC1-LA464-SAME: {{^}} "-target-feature" "+lsx" | ||
// CC1-LA464-SAME: {{^}} "-target-feature" "+lasx" | ||
// CC1-LA464-NOT: "-target-feature" | ||
// CC1-LA464: "-target-abi" "lp64d" | ||
|
||
// IR-LOONGARCH64: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+d,+f" | ||
// IR-LA464: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+d,+f,+lasx,+lsx" | ||
|
||
/// Dummy function | ||
int foo(void) { | ||
return 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// RUN: %clang --target=loongarch64 -mdouble-float -fsyntax-only %s -### 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=CC1 | ||
// RUN: %clang --target=loongarch64 -mdouble-float -S -emit-llvm %s -o - \ | ||
// RUN: | FileCheck %s --check-prefix=IR | ||
|
||
// CC1-NOT: "-target-feature" | ||
// CC1: "-target-feature" "+64bit" | ||
// CC1-SAME: {{^}} "-target-feature" "+f" | ||
// CC1-SAME: {{^}} "-target-feature" "+d" | ||
// CC1-NOT: "-target-feature" | ||
// CC1: "-target-abi" "lp64d" | ||
|
||
// IR: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+d,+f" | ||
|
||
/// Dummy function | ||
int foo(void) { | ||
return 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// RUN: %clang --target=loongarch64 -mfpu=xxx -fsyntax-only %s -### 2>&1 \ | ||
// RUN: | FileCheck %s | ||
|
||
// CHECK: invalid argument 'xxx' to -mfpu=; must be one of: 64, 32, 0, none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// RUN: %clang --target=loongarch64 -mfpu=64 -fsyntax-only %s -### 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=CC1-FPU64 | ||
// RUN: %clang --target=loongarch64 -mfpu=32 -fsyntax-only %s -### 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=CC1-FPU32 | ||
// RUN: %clang --target=loongarch64 -mfpu=0 -fsyntax-only %s -### 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=CC1-FPU0 | ||
// RUN: %clang --target=loongarch64 -mfpu=none -fsyntax-only %s -### 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=CC1-FPU0 | ||
|
||
// RUN: %clang --target=loongarch64 -mfpu=64 -S -emit-llvm %s -o - \ | ||
// RUN: | FileCheck %s --check-prefix=IR-FPU64 | ||
// RUN: %clang --target=loongarch64 -mfpu=32 -S -emit-llvm %s -o - \ | ||
// RUN: | FileCheck %s --check-prefix=IR-FPU32 | ||
// RUN: %clang --target=loongarch64 -mfpu=0 -S -emit-llvm %s -o - \ | ||
// RUN: | FileCheck %s --check-prefix=IR-FPU0 | ||
// RUN: %clang --target=loongarch64 -mfpu=none -S -emit-llvm %s -o - \ | ||
// RUN: | FileCheck %s --check-prefix=IR-FPU0 | ||
|
||
// CC1-FPU64-NOT: "-target-feature" | ||
// CC1-FPU64: "-target-feature" "+64bit" | ||
// CC1-FPU64-SAME: "-target-feature" "+f" | ||
// CC1-FPU64-SAME: "-target-feature" "+d" | ||
// CC1-FPU64-NOT: "-target-feature" | ||
// CC1-FPU64: "-target-abi" "lp64d" | ||
|
||
// CC1-FPU32-NOT: "-target-feature" | ||
// CC1-FPU32: "-target-feature" "+64bit" | ||
// CC1-FPU32-SAME: "-target-feature" "+f" | ||
// CC1-FPU32-SAME: "-target-feature" "-d" | ||
// CC1-FPU32-NOT: "-target-feature" | ||
// CC1-FPU32: "-target-abi" "lp64f" | ||
|
||
// CC1-FPU0-NOT: "-target-feature" | ||
// CC1-FPU0: "-target-feature" "+64bit" | ||
// CC1-FPU0-SAME: "-target-feature" "-f" | ||
// CC1-FPU0-SAME: "-target-feature" "-d" | ||
// CC1-FPU0-NOT: "-target-feature" | ||
// CC1-FPU0: "-target-abi" "lp64s" | ||
|
||
// IR-FPU64: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+d,+f" | ||
// IR-FPU32: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+f,-d" | ||
// IR-FPU0: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,-d,-f" | ||
|
||
/// Dummy function | ||
int foo(void) { | ||
return 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// RUN: %clang --target=loongarch64 -msingle-float -fsyntax-only %s -### 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=CC1 | ||
// RUN: %clang --target=loongarch64 -msingle-float -S -emit-llvm %s -o - \ | ||
// RUN: | FileCheck %s --check-prefix=IR | ||
|
||
// CC1-NOT: "-target-feature" | ||
// CC1: "-target-feature" "+64bit" | ||
// CC1-SAME: {{^}} "-target-feature" "+f" | ||
// CC1-SAME: {{^}} "-target-feature" "-d" | ||
// CC1-NOT: "-target-feature" | ||
// CC1: "-target-abi" "lp64f" | ||
|
||
// IR: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+f,-d" | ||
|
||
/// Dummy function | ||
int foo(void) { | ||
return 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// RUN: %clang --target=loongarch64 -msoft-float -fsyntax-only %s -### 2>&1 \ | ||
// RUN: | FileCheck %s --check-prefix=CC1 | ||
// RUN: %clang --target=loongarch64 -msoft-float -S -emit-llvm %s -o - \ | ||
// RUN: | FileCheck %s --check-prefix=IR | ||
|
||
// CC1-NOT: "-target-feature" | ||
// CC1: "-target-feature" "+64bit" | ||
// CC1-SAME: {{^}} "-target-feature" "-f" | ||
// CC1-SAME: {{^}} "-target-feature" "-d" | ||
// CC1-NOT: "-target-feature" | ||
// CC1: "-target-abi" "lp64s" | ||
|
||
// IR: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,-d,-f" | ||
|
||
/// Dummy function | ||
int foo(void) { | ||
return 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef LOONGARCH_FEATURE | ||
#define LOONGARCH_FEATURE(NAME, KIND) | ||
#endif | ||
|
||
LOONGARCH_FEATURE("invalid", FK_INVALID) | ||
LOONGARCH_FEATURE("none", FK_NONE) | ||
LOONGARCH_FEATURE("+64bit", FK_64BIT) | ||
LOONGARCH_FEATURE("+f", FK_FP32) | ||
LOONGARCH_FEATURE("+d", FK_FP64) | ||
LOONGARCH_FEATURE("+lsx", FK_LSX) | ||
LOONGARCH_FEATURE("+lasx", FK_LASX) | ||
LOONGARCH_FEATURE("+lbt", FK_LBT) | ||
LOONGARCH_FEATURE("+lvz", FK_LVZ) | ||
|
||
#undef LOONGARCH_FEATURE | ||
|
||
#ifndef LOONGARCH_ARCH | ||
#define LOONGARCH_ARCH(NAME, KIND, FEATURES) | ||
#endif | ||
|
||
LOONGARCH_ARCH("invalid", AK_INVALID, FK_INVALID) | ||
LOONGARCH_ARCH("loongarch64", AK_LOONGARCH64, FK_64BIT | FK_FP32 | FK_FP64) | ||
LOONGARCH_ARCH("la464", AK_LA464, FK_64BIT | FK_FP32 | FK_FP64 | FK_LSX | FK_LASX) | ||
|
||
#undef LOONGARCH_ARCH |
Oops, something went wrong.