Skip to content

Commit 97dd952

Browse files
committed
use separate case handler for f and improve/simplify tests
1 parent 14ea44a commit 97dd952

File tree

4 files changed

+50
-34
lines changed

4 files changed

+50
-34
lines changed

clang/lib/Basic/Targets/Mips.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,14 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
237237
case 'r': // CPU registers.
238238
case 'd': // Equivalent to "r" unless generating MIPS16 code.
239239
case 'y': // Equivalent to "r", backward compatibility only.
240-
case 'f': // floating-point registers.
241-
if (*Name == 'f' && FloatABI == SoftFloat)
242-
return false;
243-
LLVM_FALLTHROUGH;
244240
case 'c': // $25 for indirect jumps
245241
case 'l': // lo register
246242
case 'x': // hilo register pair
247243
Info.setAllowsRegister();
248244
return true;
245+
case 'f': // floating-point registers.
246+
Info.setAllowsRegister();
247+
return FloatABI != SoftFloat;
249248
case 'I': // Signed 16-bit constant
250249
case 'J': // Integer 0
251250
case 'K': // Unsigned 16-bit constant
Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
// RUN: %clang_cc1 %s -triple mips -target-feature +soft-float \
2-
// RUN: -DSOFT_FLOAT_CONSTRAINT_R \
3-
// RUN: -DFLOAT=float -emit-llvm -o - \
4-
// RUN: | FileCheck %s --check-prefix SOFT_FLOAT_CONSTRAINT_R_SINGLE
1+
// RUN: %clang_cc1 -emit-llvm -triple mips -target-feature +soft-float %s -o - | FileCheck %s --check-prefix=SOFT_FLOAT
52

6-
// RUN: %clang_cc1 %s -triple mips -target-feature +soft-float \
7-
// RUN: -DSOFT_FLOAT_CONSTRAINT_R \
8-
// RUN: -DFLOAT=double -emit-llvm -o - \
9-
// RUN: | FileCheck %s --check-prefix SOFT_FLOAT_CONSTRAINT_R_DOUBLE
3+
// SOFT_FLOAT: call void asm sideeffect "", "r,~{$1}"(float %1)
4+
void read_float(float *p) {
5+
__asm__("" ::"r"(*p));
6+
}
107

11-
#ifdef SOFT_FLOAT_CONSTRAINT_R
12-
// SOFT_FLOAT_CONSTRAINT_R_SINGLE: call void asm sideeffect "", "r,~{$1}"(float %2) #1, !srcloc !2
13-
// SOFT_FLOAT_CONSTRAINT_R_DOUBLE: call void asm sideeffect "", "r,~{$1}"(double %2) #1, !srcloc !2
14-
void read_float(FLOAT* p) {
15-
FLOAT result = *p;
16-
__asm__("" ::"r"(result));
8+
// SOFT_FLOAT: call void asm sideeffect "", "r,~{$1}"(double %1)
9+
void read_double(double *p) {
10+
__asm__("" :: "r"(*p));
1711
}
18-
#endif // SOFT_FLOAT_CONSTRAINT_R

clang/test/Sema/inline-asm-validate-mips.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// RUN: %clang_cc1 -triple mips -target-feature +soft-float -DSOFT_FLOAT_NO_CONSTRAINT_F -fsyntax-only -verify %s
1+
// RUN: %clang_cc1 -triple mips64 -fsyntax-only -verify %s
2+
// RUN: %clang_cc1 -triple mips64 -target-feature +soft-float -fsyntax-only -verify=softfloat %s
23

3-
#ifdef SOFT_FLOAT_NO_CONSTRAINT_F
4-
void read_float(float p) {
5-
float result = p;
6-
__asm__("" ::"f"(result)); // expected-error{{invalid input constraint 'f' in asm}}
4+
// expected-no-diagnostics
5+
6+
void test_f(float p) {
7+
float result = p;
8+
__asm__("" :: "f"(result)); // softfloat-error{{invalid input constraint 'f' in asm}}
79
}
8-
#endif // SOFT_FLOAT_NO_CONSTRAINT_F

llvm/test/CodeGen/Mips/inlineasm-constraints-softfloat.ll

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,46 @@
1-
; RUN: llc -march=mips < %s | FileCheck %s --check-prefix=MIPS32
2-
; RUN: llc -march=mips64 < %s | FileCheck %s --check-prefix=MIPS64
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2+
; RUN: llc -march=mips < %s | FileCheck %s --check-prefix=MIPS32
3+
; RUN: llc -march=mips64 < %s | FileCheck %s --check-prefix=MIPS64
34

45
define dso_local void @read_double(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
5-
%2 = load double, ptr %0, align 8
66
; MIPS32-LABEL: read_double:
7-
; MIPS32: lw $2, 4($4)
8-
; MIPS32-NEXT: lw $3, 0($4)
7+
; MIPS32: # %bb.0:
8+
; MIPS32-NEXT: lw $2, 4($4)
9+
; MIPS32-NEXT: lw $3, 0($4)
10+
; MIPS32-NEXT: #APP
11+
; MIPS32-NEXT: #NO_APP
12+
; MIPS32-NEXT: jr $ra
13+
; MIPS32-NEXT: nop
14+
;
915
; MIPS64-LABEL: read_double:
10-
; MIPS64: ld $2, 0($4)
16+
; MIPS64: # %bb.0:
17+
; MIPS64-NEXT: ld $2, 0($4)
18+
; MIPS64-NEXT: #APP
19+
; MIPS64-NEXT: #NO_APP
20+
; MIPS64-NEXT: jr $ra
21+
; MIPS64-NEXT: nop
22+
%2 = load double, ptr %0, align 8
1123
tail call void asm sideeffect "", "r,~{$1}"(double %2)
1224
ret void
1325
}
1426

1527
define dso_local void @read_float(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
16-
%2 = load float, ptr %0, align 8
1728
; MIPS32-LABEL: read_float:
18-
; MIPS32: lw $2, 0($4)
29+
; MIPS32: # %bb.0:
30+
; MIPS32-NEXT: lw $2, 0($4)
31+
; MIPS32-NEXT: #APP
32+
; MIPS32-NEXT: #NO_APP
33+
; MIPS32-NEXT: jr $ra
34+
; MIPS32-NEXT: nop
35+
;
1936
; MIPS64-LABEL: read_float:
20-
; MIPS64: lw $2, 0($4)
37+
; MIPS64: # %bb.0:
38+
; MIPS64-NEXT: lw $2, 0($4)
39+
; MIPS64-NEXT: #APP
40+
; MIPS64-NEXT: #NO_APP
41+
; MIPS64-NEXT: jr $ra
42+
; MIPS64-NEXT: nop
43+
%2 = load float, ptr %0, align 8
2144
tail call void asm sideeffect "", "r,~{$1}"(float %2)
2245
ret void
2346
}

0 commit comments

Comments
 (0)