Skip to content

Commit 6890b9b

Browse files
committed
Add missing changes for "[Clang][LoongArch] Handle -march/-m{single,double,soft}-float/-mfpu options"
Some changes in D136146 were lost by an accidentally sumbit. So recover them.
1 parent dc26c03 commit 6890b9b

10 files changed

+83
-96
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,5 +693,5 @@ def err_drv_riscv_unsupported_with_linker_relaxation : Error<
693693
"%0 is unsupported with RISC-V linker relaxation (-mrelax)">;
694694

695695
def err_drv_loongarch_invalid_mfpu_EQ : Error<
696-
"invalid argument '%0' to -mfpu=; must be one of: 64, 32, 0, none">;
696+
"invalid argument '%0' to -mfpu=; must be one of: 64, 32, none, 0 (alias for none)">;
697697
}

clang/test/Driver/loongarch-default-features.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// LA32-NOT: "target-features"=
55
// LA64: "target-features"="+64bit,+d,+f"
66

7-
/// Dummy function
87
int foo(void) {
9-
return 3;
8+
return 3;
109
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: not %clang --target=loongarch64 -march=loongarch -fsyntax-only %s 2>&1 \
2-
// RUN: | FileCheck --check-prefix=LOONGARCH %s
1+
// RUN: not %clang --target=loongarch64 -march=loongarch -fsyntax-only %s 2>&1 | \
2+
// RUN: FileCheck --check-prefix=LOONGARCH %s
33
// LOONGARCH: error: invalid arch name '-march=loongarch'
44

5-
// RUN: not %clang --target=loongarch64 -march=LA464 -fsyntax-only %s 2>&1 \
6-
// RUN: | FileCheck --check-prefix=LA464-UPPER %s
5+
// RUN: not %clang --target=loongarch64 -march=LA464 -fsyntax-only %s 2>&1 | \
6+
// RUN: FileCheck --check-prefix=LA464-UPPER %s
77
// LA464-UPPER: error: invalid arch name '-march=LA464'

clang/test/Driver/loongarch-march.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
1-
// RUN: %clang --target=loongarch64 -march=loongarch64 -fsyntax-only %s -### 2>&1 \
2-
// RUN: | FileCheck %s --check-prefix=CC1-LOONGARCH64
3-
// RUN: %clang --target=loongarch64 -march=la464 -fsyntax-only %s -### 2>&1 \
4-
// RUN: | FileCheck %s --check-prefix=CC1-LA464
5-
// RUN: %clang --target=loongarch64 -march=loongarch64 -S -emit-llvm %s -o - \
6-
// RUN: | FileCheck %s --check-prefix=IR-LOONGARCH64
7-
// RUN: %clang --target=loongarch64 -march=la464 -S -emit-llvm %s -o - \
8-
// RUN: | FileCheck %s --check-prefix=IR-LA464
1+
// RUN: %clang --target=loongarch64 -march=loongarch64 -fsyntax-only %s -### 2>&1 | \
2+
// RUN: FileCheck %s --check-prefix=CC1-LOONGARCH64
3+
// RUN: %clang --target=loongarch64 -march=la464 -fsyntax-only %s -### 2>&1 | \
4+
// RUN: FileCheck %s --check-prefix=CC1-LA464
5+
// RUN: %clang --target=loongarch64 -march=loongarch64 -S -emit-llvm %s -o - | \
6+
// RUN: FileCheck %s --check-prefix=IR-LOONGARCH64
7+
// RUN: %clang --target=loongarch64 -march=la464 -S -emit-llvm %s -o - | \
8+
// RUN: FileCheck %s --check-prefix=IR-LA464
99

1010
// CC1-LOONGARCH64-NOT: "-target-feature"
11-
// CC1-LOONGARCH64: "-target-feature" "+64bit"
12-
// CC1-LOONGARCH64-SAME: {{^}} "-target-feature" "+f"
13-
// CC1-LOONGARCH64-SAME: {{^}} "-target-feature" "+d"
11+
// CC1-LOONGARCH64: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "+d"
1412
// CC1-LOONGARCH64-NOT: "-target-feature"
1513
// CC1-LOONGARCH64: "-target-abi" "lp64d"
1614

1715
// CC1-LA464-NOT: "-target-feature"
18-
// CC1-LA464: "-target-feature" "+64bit"
19-
// CC1-LA464-SAME: {{^}} "-target-feature" "+f"
20-
// CC1-LA464-SAME: {{^}} "-target-feature" "+d"
21-
// CC1-LA464-SAME: {{^}} "-target-feature" "+lsx"
22-
// CC1-LA464-SAME: {{^}} "-target-feature" "+lasx"
16+
// CC1-LA464: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "+d" "-target-feature" "+lsx" "-target-feature" "+lasx"
2317
// CC1-LA464-NOT: "-target-feature"
2418
// CC1-LA464: "-target-abi" "lp64d"
2519

26-
// IR-LOONGARCH64: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+d,+f"
27-
// IR-LA464: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+d,+f,+lasx,+lsx"
20+
// IR-LOONGARCH64: attributes #[[#]] ={{.*}}"target-features"="+64bit,+d,+f"
21+
// IR-LA464: attributes #[[#]] ={{.*}}"target-features"="+64bit,+d,+f,+lasx,+lsx"
2822

29-
/// Dummy function
3023
int foo(void) {
31-
return 3;
24+
return 3;
3225
}
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
// RUN: %clang --target=loongarch64 -mdouble-float -fsyntax-only %s -### 2>&1 \
2-
// RUN: | FileCheck %s --check-prefix=CC1
3-
// RUN: %clang --target=loongarch64 -mdouble-float -S -emit-llvm %s -o - \
4-
// RUN: | FileCheck %s --check-prefix=IR
1+
// RUN: %clang --target=loongarch64 -mdouble-float -fsyntax-only %s -### 2>&1 | \
2+
// RUN: FileCheck %s --check-prefix=CC1
3+
// RUN: %clang --target=loongarch64 -mdouble-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
4+
// RUN: FileCheck %s --check-prefixes=CC1,WARN
5+
// RUN: %clang --target=loongarch64 -mdouble-float -S -emit-llvm %s -o - | \
6+
// RUN: FileCheck %s --check-prefix=IR
7+
8+
// WARN: warning: argument unused during compilation: '-mfpu=0'
9+
// WARN: warning: argument unused during compilation: '-mabi=lp64s'
510

611
// CC1-NOT: "-target-feature"
7-
// CC1: "-target-feature" "+64bit"
8-
// CC1-SAME: {{^}} "-target-feature" "+f"
9-
// CC1-SAME: {{^}} "-target-feature" "+d"
12+
// CC1: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "+d"
1013
// CC1-NOT: "-target-feature"
1114
// CC1: "-target-abi" "lp64d"
1215

13-
// IR: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+d,+f"
16+
// IR: attributes #[[#]] ={{.*}}"target-features"="+64bit,+d,+f"
1417

15-
/// Dummy function
1618
int foo(void) {
17-
return 3;
19+
return 3;
1820
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// RUN: %clang --target=loongarch64 -mfpu=xxx -fsyntax-only %s -### 2>&1 \
2-
// RUN: | FileCheck %s
1+
// RUN: %clang --target=loongarch64 -mfpu=xxx %s -### 2>&1 | FileCheck %s
32

4-
// CHECK: invalid argument 'xxx' to -mfpu=; must be one of: 64, 32, 0, none
3+
// CHECK: invalid argument 'xxx' to -mfpu=; must be one of: 64, 32, none, 0 (alias for none)

clang/test/Driver/loongarch-mfpu.c

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,40 @@
1-
// RUN: %clang --target=loongarch64 -mfpu=64 -fsyntax-only %s -### 2>&1 \
2-
// RUN: | FileCheck %s --check-prefix=CC1-FPU64
3-
// RUN: %clang --target=loongarch64 -mfpu=32 -fsyntax-only %s -### 2>&1 \
4-
// RUN: | FileCheck %s --check-prefix=CC1-FPU32
5-
// RUN: %clang --target=loongarch64 -mfpu=0 -fsyntax-only %s -### 2>&1 \
6-
// RUN: | FileCheck %s --check-prefix=CC1-FPU0
7-
// RUN: %clang --target=loongarch64 -mfpu=none -fsyntax-only %s -### 2>&1 \
8-
// RUN: | FileCheck %s --check-prefix=CC1-FPU0
1+
// RUN: %clang --target=loongarch64 -mfpu=64 -fsyntax-only %s -### 2>&1 | \
2+
// RUN: FileCheck %s --check-prefix=CC1-FPU64
3+
// RUN: %clang --target=loongarch64 -mfpu=32 -fsyntax-only %s -### 2>&1 | \
4+
// RUN: FileCheck %s --check-prefix=CC1-FPU32
5+
// RUN: %clang --target=loongarch64 -mfpu=0 -fsyntax-only %s -### 2>&1 | \
6+
// RUN: FileCheck %s --check-prefix=CC1-FPU0
7+
// RUN: %clang --target=loongarch64 -mfpu=none -fsyntax-only %s -### 2>&1 | \
8+
// RUN: FileCheck %s --check-prefix=CC1-FPU0
99

10-
// RUN: %clang --target=loongarch64 -mfpu=64 -S -emit-llvm %s -o - \
11-
// RUN: | FileCheck %s --check-prefix=IR-FPU64
12-
// RUN: %clang --target=loongarch64 -mfpu=32 -S -emit-llvm %s -o - \
13-
// RUN: | FileCheck %s --check-prefix=IR-FPU32
14-
// RUN: %clang --target=loongarch64 -mfpu=0 -S -emit-llvm %s -o - \
15-
// RUN: | FileCheck %s --check-prefix=IR-FPU0
16-
// RUN: %clang --target=loongarch64 -mfpu=none -S -emit-llvm %s -o - \
17-
// RUN: | FileCheck %s --check-prefix=IR-FPU0
10+
// RUN: %clang --target=loongarch64 -mfpu=64 -S -emit-llvm %s -o - | \
11+
// RUN: FileCheck %s --check-prefix=IR-FPU64
12+
// RUN: %clang --target=loongarch64 -mfpu=32 -S -emit-llvm %s -o - | \
13+
// RUN: FileCheck %s --check-prefix=IR-FPU32
14+
// RUN: %clang --target=loongarch64 -mfpu=0 -S -emit-llvm %s -o - | \
15+
// RUN: FileCheck %s --check-prefix=IR-FPU0
16+
// RUN: %clang --target=loongarch64 -mfpu=none -S -emit-llvm %s -o - | \
17+
// RUN: FileCheck %s --check-prefix=IR-FPU0
1818

1919
// CC1-FPU64-NOT: "-target-feature"
20-
// CC1-FPU64: "-target-feature" "+64bit"
21-
// CC1-FPU64-SAME: "-target-feature" "+f"
22-
// CC1-FPU64-SAME: "-target-feature" "+d"
20+
// CC1-FPU64: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "+d"
2321
// CC1-FPU64-NOT: "-target-feature"
2422
// CC1-FPU64: "-target-abi" "lp64d"
2523

2624
// CC1-FPU32-NOT: "-target-feature"
27-
// CC1-FPU32: "-target-feature" "+64bit"
28-
// CC1-FPU32-SAME: "-target-feature" "+f"
29-
// CC1-FPU32-SAME: "-target-feature" "-d"
25+
// CC1-FPU32: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "-d"
3026
// CC1-FPU32-NOT: "-target-feature"
3127
// CC1-FPU32: "-target-abi" "lp64f"
3228

3329
// CC1-FPU0-NOT: "-target-feature"
34-
// CC1-FPU0: "-target-feature" "+64bit"
35-
// CC1-FPU0-SAME: "-target-feature" "-f"
36-
// CC1-FPU0-SAME: "-target-feature" "-d"
30+
// CC1-FPU0: "-target-feature" "+64bit" "-target-feature" "-f" "-target-feature" "-d"
3731
// CC1-FPU0-NOT: "-target-feature"
3832
// CC1-FPU0: "-target-abi" "lp64s"
3933

40-
// IR-FPU64: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+d,+f"
41-
// IR-FPU32: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+f,-d"
42-
// IR-FPU0: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,-d,-f"
34+
// IR-FPU64: attributes #[[#]] ={{.*}}"target-features"="+64bit,+d,+f"
35+
// IR-FPU32: attributes #[[#]] ={{.*}}"target-features"="+64bit,+f,-d"
36+
// IR-FPU0: attributes #[[#]] ={{.*}}"target-features"="+64bit,-d,-f"
4337

44-
/// Dummy function
4538
int foo(void) {
46-
return 3;
39+
return 3;
4740
}
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
// RUN: %clang --target=loongarch64 -msingle-float -fsyntax-only %s -### 2>&1 \
2-
// RUN: | FileCheck %s --check-prefix=CC1
3-
// RUN: %clang --target=loongarch64 -msingle-float -S -emit-llvm %s -o - \
4-
// RUN: | FileCheck %s --check-prefix=IR
1+
// RUN: %clang --target=loongarch64 -msingle-float -fsyntax-only %s -### 2>&1 | \
2+
// RUN: FileCheck %s --check-prefix=CC1
3+
// RUN: %clang --target=loongarch64 -msingle-float -mfpu=0 -mabi=lp64s -fsyntax-only %s -### 2>&1 | \
4+
// RUN: FileCheck %s --check-prefixes=CC1,WARN
5+
// RUN: %clang --target=loongarch64 -msingle-float -S -emit-llvm %s -o - | \
6+
// RUN: FileCheck %s --check-prefix=IR
7+
8+
// WARN: warning: argument unused during compilation: '-mfpu=0'
9+
// WARN: warning: argument unused during compilation: '-mabi=lp64s'
510

611
// CC1-NOT: "-target-feature"
7-
// CC1: "-target-feature" "+64bit"
8-
// CC1-SAME: {{^}} "-target-feature" "+f"
9-
// CC1-SAME: {{^}} "-target-feature" "-d"
12+
// CC1: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "-d"
1013
// CC1-NOT: "-target-feature"
1114
// CC1: "-target-abi" "lp64f"
1215

13-
// IR: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,+f,-d"
16+
// IR: attributes #[[#]] ={{.*}}"target-features"="+64bit,+f,-d"
1417

15-
/// Dummy function
1618
int foo(void) {
17-
return 3;
19+
return 3;
1820
}
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
// RUN: %clang --target=loongarch64 -msoft-float -fsyntax-only %s -### 2>&1 \
2-
// RUN: | FileCheck %s --check-prefix=CC1
3-
// RUN: %clang --target=loongarch64 -msoft-float -S -emit-llvm %s -o - \
4-
// RUN: | FileCheck %s --check-prefix=IR
1+
// RUN: %clang --target=loongarch64 -msoft-float -fsyntax-only %s -### 2>&1 | \
2+
// RUN: FileCheck %s --check-prefix=CC1
3+
// RUN: %clang --target=loongarch64 -msoft-float -mfpu=64 -mabi=lp64d -fsyntax-only %s -### 2>&1 | \
4+
// RUN: FileCheck %s --check-prefixes=CC1,WARN
5+
// RUN: %clang --target=loongarch64 -msoft-float -S -emit-llvm %s -o - | \
6+
// RUN: FileCheck %s --check-prefix=IR
7+
8+
// WARN: warning: argument unused during compilation: '-mfpu=64'
9+
// WARN: warning: argument unused during compilation: '-mabi=lp64d'
510

611
// CC1-NOT: "-target-feature"
7-
// CC1: "-target-feature" "+64bit"
8-
// CC1-SAME: {{^}} "-target-feature" "-f"
9-
// CC1-SAME: {{^}} "-target-feature" "-d"
12+
// CC1: "-target-feature" "+64bit" "-target-feature" "-f" "-target-feature" "-d"
1013
// CC1-NOT: "-target-feature"
1114
// CC1: "-target-abi" "lp64s"
1215

13-
// IR: attributes #{{[0-9]+}} ={{.*}}"target-features"="+64bit,-d,-f"
16+
// IR: attributes #[[#]] ={{.*}}"target-features"="+64bit,-d,-f"
1417

15-
/// Dummy function
1618
int foo(void) {
17-
return 3;
19+
return 3;
1820
}

llvm/lib/Support/LoongArchTargetParser.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ const ArchInfo AllArchs[] = {
2929
};
3030

3131
LoongArch::ArchKind LoongArch::parseArch(StringRef Arch) {
32-
for (const auto A : AllArchs) {
32+
for (const auto A : AllArchs)
3333
if (A.Name == Arch)
3434
return A.Kind;
35-
}
3635

3736
return LoongArch::ArchKind::AK_INVALID;
3837
}
@@ -41,11 +40,9 @@ bool LoongArch::getArchFeatures(StringRef Arch,
4140
std::vector<StringRef> &Features) {
4241
for (const auto A : AllArchs) {
4342
if (A.Name == Arch) {
44-
for (const auto F : AllFeatures) {
45-
if ((A.Features & F.Kind) == F.Kind && F.Kind != FK_INVALID) {
43+
for (const auto F : AllFeatures)
44+
if ((A.Features & F.Kind) == F.Kind && F.Kind != FK_INVALID)
4645
Features.push_back(F.Name);
47-
}
48-
}
4946
return true;
5047
}
5148
}

0 commit comments

Comments
 (0)