[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-05-16 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

In D146269#4347514 , @MaskRay wrote:

> Is this the new GCC behavior?

Marking o32 objects with 64bit CPU is a long history gas behaviour, maybe 
appeared in 1990s, or even in the era of Irix.
I guess the reason is that to achive something like:

  -mabi=32 -march=octeon

`Octeon` is a 64bit CPU.
Since no matter about the -march value, due to all of them are using o32 abi,
they can interlink.
And thus Linux kernel uses this behaviour.

>> `clang -target mipsel-linux-gnu -mabi=64`
>
> Use `--target=`

Done


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146269/new/

https://reviews.llvm.org/D146269

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-05-16 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

ping...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146269/new/

https://reviews.llvm.org/D146269

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-05-03 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

@MaskRay ping?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146269/new/

https://reviews.llvm.org/D146269

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-04-28 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 517903.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146269/new/

https://reviews.llvm.org/D146269

Files:
  clang/lib/Basic/Targets/Mips.cpp
  clang/test/Driver/mips-abi.c
  clang/test/Driver/mips-cpu64abi32.c
  llvm/lib/Target/Mips/MipsSubtarget.cpp

Index: llvm/lib/Target/Mips/MipsSubtarget.cpp
===
--- llvm/lib/Target/Mips/MipsSubtarget.cpp
+++ llvm/lib/Target/Mips/MipsSubtarget.cpp
@@ -104,8 +104,7 @@
 report_fatal_error("Code generation for MIPS-V is not implemented", false);
 
   // Check if Architecture and ABI are compatible.
-  assert(((!isGP64bit() && isABI_O32()) ||
-  (isGP64bit() && (isABI_N32() || isABI_N64( &&
+  assert(((!isGP64bit() && isABI_O32()) || isGP64bit()) &&
  "Invalid  Arch & ABI pair.");
 
   if (hasMSA() && !isFP64bit())
Index: clang/test/Driver/mips-cpu64abi32.c
===
--- /dev/null
+++ clang/test/Driver/mips-cpu64abi32.c
@@ -0,0 +1,68 @@
+/// Check handling the CPU is 64bit while ABI is O32.
+/// when build for MIPS platforms.
+
+/// abi-n32
+// RUN: %clang -### -c %s --target=mips-linux-gnu -mabi=n32 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-N32 %s
+// CHECK-ABI-N32: "-target-abi" "n32"
+
+/// abi-64
+// RUN: %clang -### -c %s --target=mips-linux-gnu -mabi=64 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-64 %s
+// CHECK-ABI-64: "-target-abi" "n64"
+
+
+/// -march=mips3
+// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips3 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS3 %s
+// CHECK-MIPS-MIPS3: "-target-cpu" "mips3" {{.*}} "-target-abi" "o32"
+
+/// -march=mips4
+// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips4 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS4 %s
+// CHECK-MIPS-MIPS4: "-target-cpu" "mips4" {{.*}} "-target-abi" "o32"
+
+/// FIXME: MIPS V is not implemented yet.
+
+/// -march=mips64
+/// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips64 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64 %s
+// CHECK-MIPS-MIPS64: "-target-cpu" "mips64" {{.*}} "-target-abi" "o32"
+
+/// -march=mips64r2
+/// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips64r2 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64R2 %s
+// CHECK-MIPS-MIPS64R2: "-target-cpu" "mips64r2" {{.*}} "-target-abi" "o32"
+
+/// -march=mips64r6
+// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips64r6 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64R6 %s
+// CHECK-MIPS-MIPS64R6: "-target-cpu" "mips64r6" {{.*}} "-target-abi" "o32"
+
+
+/// mipsisa3
+// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips3 -mabi=32 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA3 %s
+// CHECK-MIPS-MIPSISA3: "-target-cpu" "mips3" {{.*}} "-target-abi" "o32"
+
+/// mipsisa4
+// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips4 -mabi=32 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA4 %s
+// CHECK-MIPS-MIPSISA4: "-target-cpu" "mips4" {{.*}} "-target-abi" "o32"
+
+/// FIXME: MIPS V is not implemented yet.
+
+/// mipsisa64
+// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips64 -mabi=32 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64 %s
+// CHECK-MIPS-MIPSISA64: "-target-cpu" "mips64" {{.*}} "-target-abi" "o32"
+
+/// mipsisa64r2
+// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips64r2 -mabi=32 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R2 %s
+// CHECK-MIPS-MIPSISA64R2: "-target-cpu" "mips64r2" {{.*}} "-target-abi" "o32"
+
+/// mipsisa64r6
+// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips64r6 -mabi=32 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R6 %s
+// CHECK-MIPS-MIPSISA64R6: "-target-cpu" "mips64r6" {{.*}} "-target-abi" "o32"
Index: clang/test/Driver/mips-abi.c
===
--- clang/test/Driver/mips-abi.c
+++ clang/test/Driver/mips-abi.c
@@ -9,13 +9,6 @@
 // MIPS32R2-O32: "-target-cpu" "mips32r2"
 // MIPS32R2-O32: "-target-abi" "o32"
 //
-// FIXME: This is a valid combination of options but we reject it at the moment
-//because the backend can't handle it.
-// RUN: not %clang -target mips-linux-gnu -c %s \
-// RUN:-march=mips64r2 -mabi=32 2>&1 \
-// RUN:   | FileCheck -check-prefix=MIPS64R2-O32 %s
-// MIPS64R2-O32: error: ABI 'o32' is not supported on CPU 'mips64r2'
-//
 // RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
 // RUN: %clang -target mips-img-linux-gnu -mips64r2 -### -c %s 2>&1 \
Index: clang/lib/Basic/Targets/Mips.cpp
===
--- clang/lib/Basic/Targets/Mips.cpp
+++ clang/lib/Basic/Targets/Mips.cpp
@@ -238,12 +238,6 @@
 

[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-04-25 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

@MaskRay can you help to submit this patch?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146269/new/

https://reviews.llvm.org/D146269

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-04-24 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 516277.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146269/new/

https://reviews.llvm.org/D146269

Files:
  clang/lib/Basic/Targets/Mips.cpp
  clang/test/Driver/mips-abi.c
  clang/test/Driver/mips-cpu64abi32.c
  llvm/lib/Target/Mips/MipsSubtarget.cpp

Index: llvm/lib/Target/Mips/MipsSubtarget.cpp
===
--- llvm/lib/Target/Mips/MipsSubtarget.cpp
+++ llvm/lib/Target/Mips/MipsSubtarget.cpp
@@ -104,8 +104,7 @@
 report_fatal_error("Code generation for MIPS-V is not implemented", false);
 
   // Check if Architecture and ABI are compatible.
-  assert(((!isGP64bit() && isABI_O32()) ||
-  (isGP64bit() && (isABI_N32() || isABI_N64( &&
+  assert(((!isGP64bit() && isABI_O32()) || isGP64bit()) &&
  "Invalid  Arch & ABI pair.");
 
   if (hasMSA() && !isFP64bit())
Index: clang/test/Driver/mips-cpu64abi32.c
===
--- /dev/null
+++ clang/test/Driver/mips-cpu64abi32.c
@@ -0,0 +1,81 @@
+// Check handling the CPU is 64bit while ABI is O32.
+// when build for MIPS platforms.
+//
+// abi-n32
+// RUN: %clang -c %s -target mips-linux-gnu -mabi=n32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-N32 %s
+// CHECK-ABI-N32: abi2
+//
+// abi-64
+// RUN: %clang -c %s -target mips-linux-gnu -mabi=64 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-64 %s
+// CHECK-ABI-64: ELF64
+//
+//
+// -march=mips3
+// RUN: %clang -c %s -target mips-linux-gnu -march=mips3 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS3 %s
+// CHECK-MIPS-MIPS3: o32, mips3
+//
+// -march=mips4
+// RUN: %clang -c %s -target mips-linux-gnu -march=mips4 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS4 %s
+// CHECK-MIPS-MIPS4: o32, mips4
+//
+// FIXME: MIPS V is not implemented yet.
+//
+// -march=mips64
+/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64 %s
+// CHECK-MIPS-MIPS64: o32, mips64
+//
+// -march=mips64r2
+/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64r2 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64R2 %s
+// CHECK-MIPS-MIPS64R2: o32, mips64r2
+//
+// -march=mips64r6
+/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64r6 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64R6 %s
+// CHECK-MIPS-MIPS64R6: o32, mips64r6
+//
+//
+// mipsisa3
+// RUN: %clang -c %s -target mips64-linux-gnu -march=mips3 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA3 %s
+// CHECK-MIPS-MIPSISA3: o32, mips3
+//
+// mipsisa4
+// RUN: %clang -c %s -target mips64-linux-gnu -march=mips4 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA4 %s
+// CHECK-MIPS-MIPSISA4: o32, mips4
+//
+// FIXME: MIPS V is not implemented yet.
+//
+// mipsisa64
+/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64 %s
+// CHECK-MIPS-MIPSISA64: o32, mips64
+//
+// mipsisa64r2
+/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64r2 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R2 %s
+// CHECK-MIPS-MIPSISA64R2: o32, mips64r2
+//
+// mipsisa64r6
+/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64r6 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R6 %s
+// CHECK-MIPS-MIPSISA64R6: o32, mips64r6
+//
Index: clang/test/Driver/mips-abi.c
===
--- clang/test/Driver/mips-abi.c
+++ clang/test/Driver/mips-abi.c
@@ -9,13 +9,6 @@
 // MIPS32R2-O32: "-target-cpu" "mips32r2"
 // MIPS32R2-O32: "-target-abi" "o32"
 //
-// FIXME: This is a valid combination of options but we reject it at the moment
-//because the backend can't handle it.
-// RUN: not %clang -target mips-linux-gnu -c %s \
-// RUN:-march=mips64r2 -mabi=32 2>&1 \
-// RUN:   | FileCheck -check-prefix=MIPS64R2-O32 %s
-// MIPS64R2-O32: error: ABI 'o32' is not supported on CPU 'mips64r2'
-//
 // RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
 // RUN: %clang -target mips-img-linux-gnu -mips64r2 -### -c %s 2>&1 \
Index: clang/lib/Basic/Targets/Mips.cpp
===
--- clang/lib/Basic/Targets/Mips.cpp
+++ clang/lib/Basic/Targets/Mips.cpp
@@ -238,12 +238,6 @@
 Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU;
 return false;
   

[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-04-18 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

ping...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146269/new/

https://reviews.llvm.org/D146269

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-04-02 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

ping


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146269/new/

https://reviews.llvm.org/D146269

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-03-20 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 506838.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146269/new/

https://reviews.llvm.org/D146269

Files:
  clang/lib/Basic/Targets/Mips.cpp
  clang/test/Driver/mips-abi.c
  clang/test/Driver/mips-cpu64abi32.c
  llvm/lib/Target/Mips/MipsSubtarget.cpp

Index: llvm/lib/Target/Mips/MipsSubtarget.cpp
===
--- llvm/lib/Target/Mips/MipsSubtarget.cpp
+++ llvm/lib/Target/Mips/MipsSubtarget.cpp
@@ -104,8 +104,7 @@
 report_fatal_error("Code generation for MIPS-V is not implemented", false);
 
   // Check if Architecture and ABI are compatible.
-  assert(((!isGP64bit() && isABI_O32()) ||
-  (isGP64bit() && (isABI_N32() || isABI_N64( &&
+  assert(((!isGP64bit() && isABI_O32()) || (isGP64bit())) &&
  "Invalid  Arch & ABI pair.");
 
   if (hasMSA() && !isFP64bit())
Index: clang/test/Driver/mips-cpu64abi32.c
===
--- /dev/null
+++ clang/test/Driver/mips-cpu64abi32.c
@@ -0,0 +1,81 @@
+// Check handling the CPU is 64bit while ABI is O32.
+// when build for MIPS platforms.
+//
+// abi-n32
+// RUN: %clang -c %s -target mips-linux-gnu -mabi=n32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-N32 %s
+// CHECK-ABI-N32: abi2
+//
+// abi-64
+// RUN: %clang -c %s -target mips-linux-gnu -mabi=64 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-64 %s
+// CHECK-ABI-64: ELF64
+//
+//
+// -march=mips3
+// RUN: %clang -c %s -target mips-linux-gnu -march=mips3 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS3 %s
+// CHECK-MIPS-MIPS3: o32, mips3
+//
+// -march=mips4
+// RUN: %clang -c %s -target mips-linux-gnu -march=mips4 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS4 %s
+// CHECK-MIPS-MIPS4: o32, mips4
+//
+// FIXME: MIPS V is not implemented yet.
+//
+// -march=mips64
+/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64 %s
+// CHECK-MIPS-MIPS64: o32, mips64
+//
+// -march=mips64r2
+/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64r2 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64R2 %s
+// CHECK-MIPS-MIPS64R2: o32, mips64r2
+//
+// -march=mips64r6
+/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64r6 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64R6 %s
+// CHECK-MIPS-MIPS64R6: o32, mips64r6
+//
+//
+// mipsisa3
+// RUN: %clang -c %s -target mips64-linux-gnu -march=mips3 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA3 %s
+// CHECK-MIPS-MIPSISA3: o32, mips3
+//
+// mipsisa4
+// RUN: %clang -c %s -target mips64-linux-gnu -march=mips4 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA4 %s
+// CHECK-MIPS-MIPSISA4: o32, mips4
+//
+// FIXME: MIPS V is not implemented yet.
+//
+// mipsisa64
+/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64 %s
+// CHECK-MIPS-MIPSISA64: o32, mips64
+//
+// mipsisa64r2
+/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64r2 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R2 %s
+// CHECK-MIPS-MIPSISA64R2: o32, mips64r2
+//
+// mipsisa64r6
+/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64r6 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R6 %s
+// CHECK-MIPS-MIPSISA64R6: o32, mips64r6
+//
Index: clang/test/Driver/mips-abi.c
===
--- clang/test/Driver/mips-abi.c
+++ clang/test/Driver/mips-abi.c
@@ -9,13 +9,6 @@
 // MIPS32R2-O32: "-target-cpu" "mips32r2"
 // MIPS32R2-O32: "-target-abi" "o32"
 //
-// FIXME: This is a valid combination of options but we reject it at the moment
-//because the backend can't handle it.
-// RUN: not %clang -target mips-linux-gnu -c %s \
-// RUN:-march=mips64r2 -mabi=32 2>&1 \
-// RUN:   | FileCheck -check-prefix=MIPS64R2-O32 %s
-// MIPS64R2-O32: error: ABI 'o32' is not supported on CPU 'mips64r2'
-//
 // RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
 // RUN: %clang -target mips-img-linux-gnu -mips64r2 -### -c %s 2>&1 \
Index: clang/lib/Basic/Targets/Mips.cpp
===
--- clang/lib/Basic/Targets/Mips.cpp
+++ clang/lib/Basic/Targets/Mips.cpp
@@ -238,12 +238,6 @@
 Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU;
 return false;
  

[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-03-20 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 506814.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146269/new/

https://reviews.llvm.org/D146269

Files:
  clang/lib/Basic/Targets/Mips.cpp
  clang/test/Driver/mips-abi.c
  clang/test/Driver/mips-cpu64abi32.c
  llvm/lib/Target/Mips/MipsSubtarget.cpp

Index: llvm/lib/Target/Mips/MipsSubtarget.cpp
===
--- llvm/lib/Target/Mips/MipsSubtarget.cpp
+++ llvm/lib/Target/Mips/MipsSubtarget.cpp
@@ -104,9 +104,7 @@
 report_fatal_error("Code generation for MIPS-V is not implemented", false);
 
   // Check if Architecture and ABI are compatible.
-  assert(((!isGP64bit() && isABI_O32()) ||
-  (isGP64bit() && (isABI_N32() || isABI_N64( &&
- "Invalid  Arch & ABI pair.");
+  assert((!isGP64bit() && !isABI_O32()) && "Invalid  Arch & ABI pair.");
 
   if (hasMSA() && !isFP64bit())
 report_fatal_error("MSA requires a 64-bit FPU register file (FR=1 mode). "
Index: clang/test/Driver/mips-cpu64abi32.c
===
--- /dev/null
+++ clang/test/Driver/mips-cpu64abi32.c
@@ -0,0 +1,81 @@
+// Check handling the CPU is 64bit while ABI is O32.
+// when build for MIPS platforms.
+//
+// abi-n32
+// RUN: %clang -c %s -target mips-linux-gnu -mabi=n32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-N32 %s
+// CHECK-ABI-N32: abi2
+//
+// abi-64
+// RUN: %clang -c %s -target mips-linux-gnu -mabi=64 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-64 %s
+// CHECK-ABI-64: ELF64
+//
+//
+// -march=mips3
+// RUN: %clang -c %s -target mips-linux-gnu -march=mips3 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS3 %s
+// CHECK-MIPS-MIPS3: o32, mips3
+//
+// -march=mips4
+// RUN: %clang -c %s -target mips-linux-gnu -march=mips4 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS4 %s
+// CHECK-MIPS-MIPS4: o32, mips4
+//
+// FIXME: MIPS V is not implemented yet.
+//
+// -march=mips64
+/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64 %s
+// CHECK-MIPS-MIPS64: o32, mips64
+//
+// -march=mips64r2
+/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64r2 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64R2 %s
+// CHECK-MIPS-MIPS64R2: o32, mips64r2
+//
+// -march=mips64r6
+/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64r6 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64R6 %s
+// CHECK-MIPS-MIPS64R6: o32, mips64r6
+//
+//
+// mipsisa3
+// RUN: %clang -c %s -target mips64-linux-gnu -march=mips3 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA3 %s
+// CHECK-MIPS-MIPSISA3: o32, mips3
+//
+// mipsisa4
+// RUN: %clang -c %s -target mips64-linux-gnu -march=mips4 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA4 %s
+// CHECK-MIPS-MIPSISA4: o32, mips4
+//
+// FIXME: MIPS V is not implemented yet.
+//
+// mipsisa64
+/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64 %s
+// CHECK-MIPS-MIPSISA64: o32, mips64
+//
+// mipsisa64r2
+/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64r2 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R2 %s
+// CHECK-MIPS-MIPSISA64R2: o32, mips64r2
+//
+// mipsisa64r6
+/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64r6 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R6 %s
+// CHECK-MIPS-MIPSISA64R6: o32, mips64r6
+//
Index: clang/test/Driver/mips-abi.c
===
--- clang/test/Driver/mips-abi.c
+++ clang/test/Driver/mips-abi.c
@@ -9,13 +9,6 @@
 // MIPS32R2-O32: "-target-cpu" "mips32r2"
 // MIPS32R2-O32: "-target-abi" "o32"
 //
-// FIXME: This is a valid combination of options but we reject it at the moment
-//because the backend can't handle it.
-// RUN: not %clang -target mips-linux-gnu -c %s \
-// RUN:-march=mips64r2 -mabi=32 2>&1 \
-// RUN:   | FileCheck -check-prefix=MIPS64R2-O32 %s
-// MIPS64R2-O32: error: ABI 'o32' is not supported on CPU 'mips64r2'
-//
 // RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
 // RUN: %clang -target mips-img-linux-gnu -mips64r2 -### -c %s 2>&1 \
Index: clang/lib/Basic/Targets/Mips.cpp
===
--- 

[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-03-20 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

In D146269#4201150 , @jrtc27 wrote:

> Tests?

Added.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146269/new/

https://reviews.llvm.org/D146269

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU and 64 abi with 32bit triple

2023-03-20 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 506482.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146269/new/

https://reviews.llvm.org/D146269

Files:
  clang/lib/Basic/Targets/Mips.cpp
  clang/test/Driver/mips-cpu64abi32.c

Index: clang/test/Driver/mips-cpu64abi32.c
===
--- /dev/null
+++ clang/test/Driver/mips-cpu64abi32.c
@@ -0,0 +1,81 @@
+// Check handling the CPU is 64bit while ABI is O32.
+// when build for MIPS platforms.
+//
+// abi-n32
+// RUN: %clang -c %s -target mips-linux-gnu -mabi=n32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-N32 %s
+// CHECK-ABI-N32: abi2
+//
+// abi-64
+// RUN: %clang -c %s -target mips-linux-gnu -mabi=64 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-ABI-64 %s
+// CHECK-ABI-64: ELF64
+//
+//
+// -march=mips3
+// RUN: %clang -c %s -target mips-linux-gnu -march=mips3 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS3 %s
+// CHECK-MIPS-MIPS3: o32, mips3
+//
+// -march=mips4
+// RUN: %clang -c %s -target mips-linux-gnu -march=mips4 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS4 %s
+// CHECK-MIPS-MIPS4: o32, mips4
+//
+// FIXME: MIPS V is not implemented yet.
+//
+// -march=mips64
+/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64 %s
+// CHECK-MIPS-MIPS64: o32, mips64
+//
+// -march=mips64r2
+/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64r2 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64R2 %s
+// CHECK-MIPS-MIPS64R2: o32, mips64r2
+//
+// -march=mips64r6
+/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64r6 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPS64R6 %s
+// CHECK-MIPS-MIPS64R6: o32, mips64r6
+//
+//
+// mipsisa3
+// RUN: %clang -c %s -target mips64-linux-gnu -march=mips3 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA3 %s
+// CHECK-MIPS-MIPSISA3: o32, mips3
+//
+// mipsisa4
+// RUN: %clang -c %s -target mips64-linux-gnu -march=mips4 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA4 %s
+// CHECK-MIPS-MIPSISA4: o32, mips4
+//
+// FIXME: MIPS V is not implemented yet.
+//
+// mipsisa64
+/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64 %s
+// CHECK-MIPS-MIPSISA64: o32, mips64
+//
+// mipsisa64r2
+/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64r2 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R2 %s
+// CHECK-MIPS-MIPSISA64R2: o32, mips64r2
+//
+// mipsisa64r6
+/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64r6 -mabi=32 -o - \
+// RUN:   | llvm-readelf -h - \
+// RUN:   | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R6 %s
+// CHECK-MIPS-MIPSISA64R6: o32, mips64r6
+//
Index: clang/lib/Basic/Targets/Mips.cpp
===
--- clang/lib/Basic/Targets/Mips.cpp
+++ clang/lib/Basic/Targets/Mips.cpp
@@ -238,12 +238,6 @@
 Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU;
 return false;
   }
-  // FIXME: It's valid to use O32 on a 64-bit CPU but the backend can't handle
-  //this yet. It's better to fail here than on the backend assertion.
-  if (processorSupportsGPR64() && ABI == "o32") {
-Diags.Report(diag::err_target_unsupported_abi) << ABI << CPU;
-return false;
-  }
 
   // 64-bit ABI's require 64-bit CPU's.
   if (!processorSupportsGPR64() && (ABI == "n32" || ABI == "n64")) {
@@ -251,24 +245,6 @@
 return false;
   }
 
-  // FIXME: It's valid to use O32 on a mips64/mips64el triple but the backend
-  //can't handle this yet. It's better to fail here than on the
-  //backend assertion.
-  if (getTriple().isMIPS64() && ABI == "o32") {
-Diags.Report(diag::err_target_unsupported_abi_for_triple)
-<< ABI << getTriple().str();
-return false;
-  }
-
-  // FIXME: It's valid to use N32/N64 on a mips/mipsel triple but the backend
-  //can't handle this yet. It's better to fail here than on the
-  //backend assertion.
-  if (getTriple().isMIPS32() && (ABI == "n32" || ABI == "n64")) {
-Diags.Report(diag::err_target_unsupported_abi_for_triple)
-<< ABI << getTriple().str();
-return false;
-  }
-
   // -fpxx is valid only for the o32 ABI
   if (FPMode == FPXX && (ABI == "n32" || ABI == "n64")) {
 Diags.Report(diag::err_unsupported_abi_for_opt) << "-mfpxx" << "o32";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D146269: MIPS: allow o32 abi with 64bit CPU

2023-03-16 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa created this revision.
wzssyqa added a reviewer: MaskRay.
Herald added subscribers: atanasyan, jrtc27, arichardson, sdardis.
Herald added a project: All.
wzssyqa requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In general, MIPS support ELF format like

  ELF 32-bit LSB relocatable, MIPS, MIPS64 rel2 version 1 (SYSV)

and Linux's VDSO uses it.

Currently clang stop CMDs like

  clang -march=mips64r2 -mabi=32

While it is not needed now, since the the backend support the combination now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146269

Files:
  clang/lib/Basic/Targets/Mips.cpp


Index: clang/lib/Basic/Targets/Mips.cpp
===
--- clang/lib/Basic/Targets/Mips.cpp
+++ clang/lib/Basic/Targets/Mips.cpp
@@ -238,12 +238,6 @@
 Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU;
 return false;
   }
-  // FIXME: It's valid to use O32 on a 64-bit CPU but the backend can't handle
-  //this yet. It's better to fail here than on the backend assertion.
-  if (processorSupportsGPR64() && ABI == "o32") {
-Diags.Report(diag::err_target_unsupported_abi) << ABI << CPU;
-return false;
-  }
 
   // 64-bit ABI's require 64-bit CPU's.
   if (!processorSupportsGPR64() && (ABI == "n32" || ABI == "n64")) {
@@ -251,24 +245,6 @@
 return false;
   }
 
-  // FIXME: It's valid to use O32 on a mips64/mips64el triple but the backend
-  //can't handle this yet. It's better to fail here than on the
-  //backend assertion.
-  if (getTriple().isMIPS64() && ABI == "o32") {
-Diags.Report(diag::err_target_unsupported_abi_for_triple)
-<< ABI << getTriple().str();
-return false;
-  }
-
-  // FIXME: It's valid to use N32/N64 on a mips/mipsel triple but the backend
-  //can't handle this yet. It's better to fail here than on the
-  //backend assertion.
-  if (getTriple().isMIPS32() && (ABI == "n32" || ABI == "n64")) {
-Diags.Report(diag::err_target_unsupported_abi_for_triple)
-<< ABI << getTriple().str();
-return false;
-  }
-
   // -fpxx is valid only for the o32 ABI
   if (FPMode == FPXX && (ABI == "n32" || ABI == "n64")) {
 Diags.Report(diag::err_unsupported_abi_for_opt) << "-mfpxx" << "o32";


Index: clang/lib/Basic/Targets/Mips.cpp
===
--- clang/lib/Basic/Targets/Mips.cpp
+++ clang/lib/Basic/Targets/Mips.cpp
@@ -238,12 +238,6 @@
 Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU;
 return false;
   }
-  // FIXME: It's valid to use O32 on a 64-bit CPU but the backend can't handle
-  //this yet. It's better to fail here than on the backend assertion.
-  if (processorSupportsGPR64() && ABI == "o32") {
-Diags.Report(diag::err_target_unsupported_abi) << ABI << CPU;
-return false;
-  }
 
   // 64-bit ABI's require 64-bit CPU's.
   if (!processorSupportsGPR64() && (ABI == "n32" || ABI == "n64")) {
@@ -251,24 +245,6 @@
 return false;
   }
 
-  // FIXME: It's valid to use O32 on a mips64/mips64el triple but the backend
-  //can't handle this yet. It's better to fail here than on the
-  //backend assertion.
-  if (getTriple().isMIPS64() && ABI == "o32") {
-Diags.Report(diag::err_target_unsupported_abi_for_triple)
-<< ABI << getTriple().str();
-return false;
-  }
-
-  // FIXME: It's valid to use N32/N64 on a mips/mipsel triple but the backend
-  //can't handle this yet. It's better to fail here than on the
-  //backend assertion.
-  if (getTriple().isMIPS32() && (ABI == "n32" || ABI == "n64")) {
-Diags.Report(diag::err_target_unsupported_abi_for_triple)
-<< ABI << getTriple().str();
-return false;
-  }
-
   // -fpxx is valid only for the o32 ABI
   if (FPMode == FPXX && (ABI == "n32" || ABI == "n64")) {
 Diags.Report(diag::err_unsupported_abi_for_opt) << "-mfpxx" << "o32";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140270: MIPS: fix build from IR files, nan2008 and FpAbi

2023-02-06 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

@MaskRay can you help to submit this patch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140270/new/

https://reviews.llvm.org/D140270

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140270: MIPS: fix build from IR files, nan2008 and FpAbi

2023-01-30 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140270/new/

https://reviews.llvm.org/D140270

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80392: [mips][mc][clang] Use pc-relative relocations in .eh_frame

2023-01-05 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

When link with ld.bfd, we get:

  ld/ld-new: .eh_frame_hdr entry overflow
  ld/ld-new: final link failed: bad value

It seems due to the `initial_loc` in the object from LLVM is quite big than the 
gcc/gas one.

  initial_loc: 0x10cd0, vma: 0xe78




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80392/new/

https://reviews.llvm.org/D80392

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140270: MIPS: fix build from IR files, nan2008 and FpAbi

2023-01-02 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 485898.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140270/new/

https://reviews.llvm.org/D140270

Files:
  clang/lib/Driver/ToolChains/Arch/Mips.cpp
  clang/test/Driver/mips-as.c
  clang/test/Driver/mips-integrated-as.s
  llvm/lib/Target/Mips/MipsAsmPrinter.cpp
  llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll

Index: llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
@@ -0,0 +1,18 @@
+;; When we compile object with "-flto", the info of "-mnan=2008"
+;; and "-mfp32/-mfpxx/-mfp64" will be missing in the result IR file.
+;; Thus the asm/obj files will have wrong format.
+;; With D140270 we extract these info from the first function,
+;; and set it for the whole compile unit.
+; RUN: llc %s -o - | FileCheck %s
+
+target triple = "mipsel-unknown-linux-gnu"
+
+define dso_local void @test() #0 {
+  ret void
+}
+
+attributes #0 = { "target-cpu"="mips32r2" "target-features"="+fp64,+mips32r2,+nan2008" }
+
+
+; CHECK: .nan2008
+; CHECK: .module fp=64
Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp
===
--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -777,14 +777,18 @@
   // around it by re-initializing the PIC state here.
   TS.setPic(OutContext.getObjectFileInfo()->isPositionIndependent());
 
+  // Try to get target-features from the first function.
+  StringRef FS = TM.getTargetFeatureString();
+  Module::iterator F = M.begin();
+  if (FS.empty() && M.size() && F->hasFnAttribute("target-features"))
+FS = F->getFnAttribute("target-features").getValueAsString();
+
   // Compute MIPS architecture attributes based on the default subtarget
-  // that we'd have constructed. Module level directives aren't LTO
-  // clean anyhow.
+  // that we'd have constructed.
   // FIXME: For ifunc related functions we could iterate over and look
   // for a feature string that doesn't match the default one.
   const Triple  = TM.getTargetTriple();
   StringRef CPU = MIPS_MC::selectMipsCPU(TT, TM.getTargetCPU());
-  StringRef FS = TM.getTargetFeatureString();
   const MipsTargetMachine  = static_cast(TM);
   const MipsSubtarget STI(TT, CPU, FS, MTM.isLittleEndian(), MTM, std::nullopt);
 
Index: clang/test/Driver/mips-integrated-as.s
===
--- clang/test/Driver/mips-integrated-as.s
+++ clang/test/Driver/mips-integrated-as.s
@@ -160,8 +160,8 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=FPXX-DEFAULT %s
 // FPXX-DEFAULT: -cc1as
-// FPXX-DEFAULT-NOT: "-target-feature" "+fpxx"
-// FPXX-DEFAULT-NOT: "-target-feature" "+nooddspreg"
+// FPXX-DEFAULT: "-target-feature" "+fpxx"
+// FPXX-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfp32 2>&1 | \
 // RUN:   FileCheck -check-prefix=FP32 %s
@@ -182,7 +182,7 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-DEFAULT %s
 // ODDSPREG-DEFAULT: -cc1as
-// ODDSPREG-DEFAULT-NOT: "-target-feature" "{{[+-]}}nooddspreg"
+// ODDSPREG-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -modd-spreg 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-ON %s
Index: clang/test/Driver/mips-as.c
===
--- clang/test/Driver/mips-as.c
+++ clang/test/Driver/mips-as.c
@@ -196,7 +196,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-mips16 -mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-16 %s
-// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mips16"
+// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mips16"
 //
 // RUN: %clang -target mips-linux-gnu -mips16 -mno-mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -207,7 +207,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-micromips -mmicromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MICRO %s
-// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmicromips"
+// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mmicromips"
 //
 // RUN: %clang -target mips-linux-gnu -mmicromips -mno-micromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -218,7 +218,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dsp -mdsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSP %s
-// MIPS-DSP: 

[PATCH] D140270: MIPS: fix build from IR files, nan2008 and FpAbi

2023-01-02 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 485897.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140270/new/

https://reviews.llvm.org/D140270

Files:
  clang/lib/Driver/ToolChains/Arch/Mips.cpp
  clang/test/Driver/mips-as.c
  clang/test/Driver/mips-integrated-as.s
  llvm/lib/Target/Mips/MipsAsmPrinter.cpp
  llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll

Index: llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
@@ -0,0 +1,13 @@
+; RUN: llc %s -o - | FileCheck %s
+
+target triple = "mipsel-unknown-linux-gnu"
+
+define dso_local void @test() #0 {
+  ret void
+}
+
+attributes #0 = { "target-cpu"="mips32r2" "target-features"="+fp64,+mips32r2,+nan2008" }
+
+
+; CHECK: .nan2008
+; CHECK: .module fp=64
Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp
===
--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -777,14 +777,18 @@
   // around it by re-initializing the PIC state here.
   TS.setPic(OutContext.getObjectFileInfo()->isPositionIndependent());
 
+  // Try to get target-features from the first function.
+  StringRef FS = TM.getTargetFeatureString();
+  Module::iterator F = M.begin();
+  if (FS.empty() && M.size() && F->hasFnAttribute("target-features"))
+FS = F->getFnAttribute("target-features").getValueAsString();
+
   // Compute MIPS architecture attributes based on the default subtarget
-  // that we'd have constructed. Module level directives aren't LTO
-  // clean anyhow.
+  // that we'd have constructed.
   // FIXME: For ifunc related functions we could iterate over and look
   // for a feature string that doesn't match the default one.
   const Triple  = TM.getTargetTriple();
   StringRef CPU = MIPS_MC::selectMipsCPU(TT, TM.getTargetCPU());
-  StringRef FS = TM.getTargetFeatureString();
   const MipsTargetMachine  = static_cast(TM);
   const MipsSubtarget STI(TT, CPU, FS, MTM.isLittleEndian(), MTM, std::nullopt);
 
Index: clang/test/Driver/mips-integrated-as.s
===
--- clang/test/Driver/mips-integrated-as.s
+++ clang/test/Driver/mips-integrated-as.s
@@ -160,8 +160,8 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=FPXX-DEFAULT %s
 // FPXX-DEFAULT: -cc1as
-// FPXX-DEFAULT-NOT: "-target-feature" "+fpxx"
-// FPXX-DEFAULT-NOT: "-target-feature" "+nooddspreg"
+// FPXX-DEFAULT: "-target-feature" "+fpxx"
+// FPXX-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfp32 2>&1 | \
 // RUN:   FileCheck -check-prefix=FP32 %s
@@ -182,7 +182,7 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-DEFAULT %s
 // ODDSPREG-DEFAULT: -cc1as
-// ODDSPREG-DEFAULT-NOT: "-target-feature" "{{[+-]}}nooddspreg"
+// ODDSPREG-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -modd-spreg 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-ON %s
Index: clang/test/Driver/mips-as.c
===
--- clang/test/Driver/mips-as.c
+++ clang/test/Driver/mips-as.c
@@ -196,7 +196,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-mips16 -mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-16 %s
-// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mips16"
+// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mips16"
 //
 // RUN: %clang -target mips-linux-gnu -mips16 -mno-mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -207,7 +207,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-micromips -mmicromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MICRO %s
-// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmicromips"
+// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mmicromips"
 //
 // RUN: %clang -target mips-linux-gnu -mmicromips -mno-micromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -218,7 +218,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dsp -mdsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSP %s
-// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdsp"
+// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdsp"
 //
 // RUN: %clang -target mips-linux-gnu -mdsp -mno-dsp -### \
 // RUN:   

[PATCH] D140270: MIPS: fix build from IR files, nan2008 and FpAbi

2022-12-31 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

@nathanchance can you have a try this patch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140270/new/

https://reviews.llvm.org/D140270

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140270: MIPS: fix build from IR files, nan2008 and FpAbi

2022-12-31 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 485793.
wzssyqa retitled this revision from "MIPS: emit .module and .nan directives 
only for first function" to "MIPS: fix build from IR files, nan2008 and FpAbi".
wzssyqa edited the summary of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140270/new/

https://reviews.llvm.org/D140270

Files:
  clang/lib/Driver/ToolChains/Arch/Mips.cpp
  clang/test/Driver/mips-as.c
  clang/test/Driver/mips-integrated-as.s
  llvm/lib/Target/Mips/MipsAsmPrinter.cpp
  llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll

Index: llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
@@ -0,0 +1,13 @@
+; RUN: llc %s -o - | FileCheck %s
+
+target triple = "mipsel-unknown-linux-gnu"
+
+define dso_local void @test() #0 {
+  ret void
+}
+
+attributes #0 = { "target-cpu"="mips32r2" "target-features"="+fp64,+mips32r2,+nan2008" }
+
+
+; CHECK: .nan2008
+; CHECK: .module fp=64
Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp
===
--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -777,14 +777,18 @@
   // around it by re-initializing the PIC state here.
   TS.setPic(OutContext.getObjectFileInfo()->isPositionIndependent());
 
+  // Try to get target-features from the first function.
+  StringRef FS = TM.getTargetFeatureString();
+  Module::iterator F = M.begin();
+  if (FS.empty() && M.size() && F->hasFnAttribute("target-features"))
+FS = F->getFnAttribute("target-features").getValueAsString();
+
   // Compute MIPS architecture attributes based on the default subtarget
-  // that we'd have constructed. Module level directives aren't LTO
-  // clean anyhow.
+  // that we'd have constructed.
   // FIXME: For ifunc related functions we could iterate over and look
   // for a feature string that doesn't match the default one.
   const Triple  = TM.getTargetTriple();
   StringRef CPU = MIPS_MC::selectMipsCPU(TT, TM.getTargetCPU());
-  StringRef FS = TM.getTargetFeatureString();
   const MipsTargetMachine  = static_cast(TM);
   const MipsSubtarget STI(TT, CPU, FS, MTM.isLittleEndian(), MTM, std::nullopt);
 
Index: clang/test/Driver/mips-integrated-as.s
===
--- clang/test/Driver/mips-integrated-as.s
+++ clang/test/Driver/mips-integrated-as.s
@@ -160,8 +160,8 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=FPXX-DEFAULT %s
 // FPXX-DEFAULT: -cc1as
-// FPXX-DEFAULT-NOT: "-target-feature" "+fpxx"
-// FPXX-DEFAULT-NOT: "-target-feature" "+nooddspreg"
+// FPXX-DEFAULT: "-target-feature" "+fpxx"
+// FPXX-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfp32 2>&1 | \
 // RUN:   FileCheck -check-prefix=FP32 %s
@@ -182,7 +182,7 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-DEFAULT %s
 // ODDSPREG-DEFAULT: -cc1as
-// ODDSPREG-DEFAULT-NOT: "-target-feature" "{{[+-]}}nooddspreg"
+// ODDSPREG-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -modd-spreg 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-ON %s
Index: clang/test/Driver/mips-as.c
===
--- clang/test/Driver/mips-as.c
+++ clang/test/Driver/mips-as.c
@@ -196,7 +196,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-mips16 -mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-16 %s
-// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mips16"
+// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mips16"
 //
 // RUN: %clang -target mips-linux-gnu -mips16 -mno-mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -207,7 +207,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-micromips -mmicromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MICRO %s
-// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmicromips"
+// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mmicromips"
 //
 // RUN: %clang -target mips-linux-gnu -mmicromips -mno-micromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -218,7 +218,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dsp -mdsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSP %s
-// MIPS-DSP: as{{(.exe)?}}" 

[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-12-18 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

https://reviews.llvm.org/D140270


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138179/new/

https://reviews.llvm.org/D138179

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-12-18 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

In D138179#4002068 , @nathanchance 
wrote:

> For what it's worth, this breaks building the Linux kernel's `ARCH=mips 
> 32r1_defconfig` with clang and GNU as, with thousands of messages along the 
> line of:
>
>   /tmp/mmc_ops-d329c3.s: Assembler messages:
>   /tmp/mmc_ops-d329c3.s:310: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:473: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:594: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:687: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:781: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:946: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:1023: Error: .module is not permitted after 
> generating code
>   ...
>
> A simplified reproducer:
>
>   void rcu_normal_store() {}
>   void __attribute__ksysfs_init() {}

Thanks for your test. I will work it just now.

>   $ clang --version | head -1
>   ClangBuiltLinux clang version 16.0.0 (https://github.com/llvm/llvm-project 
> 9739bb81aed490bfcbcbbac6970da8fb7232fd34)
>   
>   $ clang --target=mips-linux-gnu -fno-integrated-as -c -o /dev/null ksysfs.i
>   /tmp/ksysfs-9b0c50.s: Assembler messages:
>   /tmp/ksysfs-9b0c50.s:44: Error: .module is not permitted after generating 
> code
>   clang-16: error: assembler command failed with exit code 1 (use -v to see 
> invocation)
>
>
>
>   $ clang --version | head -1
>   ClangBuiltLinux clang version 16.0.0 (https://github.com/llvm/llvm-project 
> 92619956eb27ef08dd24045307593fc3d7f78db0)
>   
>   $ clang --target=mips-linux-gnu -fno-integrated-as -c -o /dev/null ksysfs.i



In D138179#4002068 , @nathanchance 
wrote:

> For what it's worth, this breaks building the Linux kernel's `ARCH=mips 
> 32r1_defconfig` with clang and GNU as, with thousands of messages along the 
> line of:
>
>   /tmp/mmc_ops-d329c3.s: Assembler messages:
>   /tmp/mmc_ops-d329c3.s:310: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:473: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:594: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:687: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:781: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:946: Error: .module is not permitted after generating 
> code
>   /tmp/mmc_ops-d329c3.s:1023: Error: .module is not permitted after 
> generating code
>   ...
>
> A simplified reproducer:
>
>   void rcu_normal_store() {}
>   void __attribute__ksysfs_init() {}
>
>
>
>   $ clang --version | head -1
>   ClangBuiltLinux clang version 16.0.0 (https://github.com/llvm/llvm-project 
> 9739bb81aed490bfcbcbbac6970da8fb7232fd34)
>   
>   $ clang --target=mips-linux-gnu -fno-integrated-as -c -o /dev/null ksysfs.i
>   /tmp/ksysfs-9b0c50.s: Assembler messages:
>   /tmp/ksysfs-9b0c50.s:44: Error: .module is not permitted after generating 
> code
>   clang-16: error: assembler command failed with exit code 1 (use -v to see 
> invocation)
>
>
>
>   $ clang --version | head -1
>   ClangBuiltLinux clang version 16.0.0 (https://github.com/llvm/llvm-project 
> 92619956eb27ef08dd24045307593fc3d7f78db0)
>   
>   $ clang --target=mips-linux-gnu -fno-integrated-as -c -o /dev/null ksysfs.i




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138179/new/

https://reviews.llvm.org/D138179

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-12-14 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

ahhh, ping.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138179/new/

https://reviews.llvm.org/D138179

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-11-19 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 476716.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138179/new/

https://reviews.llvm.org/D138179

Files:
  clang/lib/Driver/ToolChains/Arch/Mips.cpp
  clang/test/Driver/mips-as.c
  clang/test/Driver/mips-integrated-as.s
  llvm/lib/Target/Mips/MipsAsmPrinter.cpp
  llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll

Index: llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
@@ -0,0 +1,13 @@
+; RUN: llc %s -o - | FileCheck %s
+
+target triple = "mipsel-unknown-linux-gnu"
+
+define dso_local void @test() #0 {
+  ret void
+}
+
+attributes #0 = { "target-cpu"="mips32r2" "target-features"="+fp64,+mips32r2,+nan2008" }
+
+
+; CHECK: .nan2008
+; CHECK: .module fp=64
Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp
===
--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -399,6 +399,14 @@
 
 void MipsAsmPrinter::emitFunctionEntryLabel() {
   MipsTargetStreamer  = getTargetStreamer();
+  bool IsO32 = (static_cast(TM)).getABI().IsO32();
+
+  TS.updateABIInfo(*Subtarget);
+  if (Subtarget->isNaN2008())
+TS.emitDirectiveNaN2008();
+  if ((IsO32 && (Subtarget->isABI_FPXX() || Subtarget->isFP64bit())) ||
+  Subtarget->useSoftFloat())
+TS.emitDirectiveModuleFP();
 
   // NaCl sandboxing requires that indirect call instructions are masked.
   // This means that function entry points should be bundle-aligned.
Index: clang/test/Driver/mips-integrated-as.s
===
--- clang/test/Driver/mips-integrated-as.s
+++ clang/test/Driver/mips-integrated-as.s
@@ -160,8 +160,8 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=FPXX-DEFAULT %s
 // FPXX-DEFAULT: -cc1as
-// FPXX-DEFAULT-NOT: "-target-feature" "+fpxx"
-// FPXX-DEFAULT-NOT: "-target-feature" "+nooddspreg"
+// FPXX-DEFAULT: "-target-feature" "+fpxx"
+// FPXX-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfp32 2>&1 | \
 // RUN:   FileCheck -check-prefix=FP32 %s
@@ -182,7 +182,7 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-DEFAULT %s
 // ODDSPREG-DEFAULT: -cc1as
-// ODDSPREG-DEFAULT-NOT: "-target-feature" "{{[+-]}}nooddspreg"
+// ODDSPREG-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -modd-spreg 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-ON %s
Index: clang/test/Driver/mips-as.c
===
--- clang/test/Driver/mips-as.c
+++ clang/test/Driver/mips-as.c
@@ -196,7 +196,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-mips16 -mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-16 %s
-// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mips16"
+// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mips16"
 //
 // RUN: %clang -target mips-linux-gnu -mips16 -mno-mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -207,7 +207,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-micromips -mmicromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MICRO %s
-// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmicromips"
+// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mmicromips"
 //
 // RUN: %clang -target mips-linux-gnu -mmicromips -mno-micromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -218,7 +218,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dsp -mdsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSP %s
-// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdsp"
+// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdsp"
 //
 // RUN: %clang -target mips-linux-gnu -mdsp -mno-dsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -229,7 +229,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dspr2 -mdspr2 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSPR2 %s
-// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdspr2"
+// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdspr2"
 //
 // RUN: %clang -target mips-linux-gnu -mdspr2 -mno-dspr2 -### \
 // RUN:   

[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-11-17 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 476303.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138179/new/

https://reviews.llvm.org/D138179

Files:
  clang/lib/Driver/ToolChains/Arch/Mips.cpp
  clang/test/Driver/mips-as.c
  clang/test/Driver/mips-integrated-as.s
  llvm/lib/Target/Mips/MipsAsmPrinter.cpp
  llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll

Index: llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
@@ -0,0 +1,13 @@
+; RUN: llc %s -o - | FileCheck %s
+
+target triple = "mipsel-unknown-linux-gnu"
+
+define dso_local void @test() #0 {
+  ret void
+}
+
+attributes #0 = { "target-cpu"="mips32r2" "target-features"="+fp64,+mips32r2,+nan2008" }
+
+
+; CHECK: .nan2008
+; CHECK: .module fp=64
Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp
===
--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -400,6 +400,16 @@
 void MipsAsmPrinter::emitFunctionEntryLabel() {
   MipsTargetStreamer  = getTargetStreamer();
 
+  const MipsTargetMachine  = static_cast(TM);
+  const MipsABIInfo  = MTM.getABI();
+
+  TS.updateABIInfo(*Subtarget);
+  if (Subtarget->isNaN2008())
+TS.emitDirectiveNaN2008();
+  if ((ABI.IsO32() && (Subtarget->isABI_FPXX() || Subtarget->isFP64bit())) ||
+  Subtarget->useSoftFloat())
+TS.emitDirectiveModuleFP();
+
   // NaCl sandboxing requires that indirect call instructions are masked.
   // This means that function entry points should be bundle-aligned.
   if (Subtarget->isTargetNaCl())
Index: clang/test/Driver/mips-integrated-as.s
===
--- clang/test/Driver/mips-integrated-as.s
+++ clang/test/Driver/mips-integrated-as.s
@@ -160,8 +160,8 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=FPXX-DEFAULT %s
 // FPXX-DEFAULT: -cc1as
-// FPXX-DEFAULT-NOT: "-target-feature" "+fpxx"
-// FPXX-DEFAULT-NOT: "-target-feature" "+nooddspreg"
+// FPXX-DEFAULT: "-target-feature" "+fpxx"
+// FPXX-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfp32 2>&1 | \
 // RUN:   FileCheck -check-prefix=FP32 %s
@@ -182,7 +182,7 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-DEFAULT %s
 // ODDSPREG-DEFAULT: -cc1as
-// ODDSPREG-DEFAULT-NOT: "-target-feature" "{{[+-]}}nooddspreg"
+// ODDSPREG-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -modd-spreg 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-ON %s
Index: clang/test/Driver/mips-as.c
===
--- clang/test/Driver/mips-as.c
+++ clang/test/Driver/mips-as.c
@@ -196,7 +196,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-mips16 -mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-16 %s
-// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mips16"
+// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mips16"
 //
 // RUN: %clang -target mips-linux-gnu -mips16 -mno-mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -207,7 +207,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-micromips -mmicromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MICRO %s
-// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmicromips"
+// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mmicromips"
 //
 // RUN: %clang -target mips-linux-gnu -mmicromips -mno-micromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -218,7 +218,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dsp -mdsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSP %s
-// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdsp"
+// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdsp"
 //
 // RUN: %clang -target mips-linux-gnu -mdsp -mno-dsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -229,7 +229,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dspr2 -mdspr2 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSPR2 %s
-// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdspr2"
+// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdspr2"
 //
 // RUN: 

[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-11-17 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 476302.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138179/new/

https://reviews.llvm.org/D138179

Files:
  clang/lib/Driver/ToolChains/Arch/Mips.cpp
  clang/test/Driver/mips-as.c
  clang/test/Driver/mips-integrated-as.s
  llvm/lib/Target/Mips/MipsAsmPrinter.cpp
  llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll

Index: llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
@@ -0,0 +1,13 @@
+; RUN: llc %s -o - | FileCheck %s
+
+target triple = "mipsel-unknown-linux-gnu"
+
+define dso_local void @test() #0 {
+  ret void
+}
+
+attributes #0 = { "target-cpu"="mips32r2" "target-features"="+fp64,+mips32r2,+nan2008" }
+
+
+; CHECK: .nan2008
+; CHECK: .module fp=64
Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp
===
--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -400,6 +400,16 @@
 void MipsAsmPrinter::emitFunctionEntryLabel() {
   MipsTargetStreamer  = getTargetStreamer();
 
+  TS.updateABIInfo(*Subtarget);
+  if (Subtarget->isNaN2008())
+TS.emitDirectiveNaN2008();
+  const MipsTargetMachine  = static_cast(TM);
+  const MipsABIInfo  = MTM.getABI();
+
+  if ((ABI.IsO32() && (Subtarget->isABI_FPXX() || Subtarget->isFP64bit())) ||
+  Subtarget->useSoftFloat())
+TS.emitDirectiveModuleFP();
+
   // NaCl sandboxing requires that indirect call instructions are masked.
   // This means that function entry points should be bundle-aligned.
   if (Subtarget->isTargetNaCl())
Index: clang/test/Driver/mips-integrated-as.s
===
--- clang/test/Driver/mips-integrated-as.s
+++ clang/test/Driver/mips-integrated-as.s
@@ -160,8 +160,8 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=FPXX-DEFAULT %s
 // FPXX-DEFAULT: -cc1as
-// FPXX-DEFAULT-NOT: "-target-feature" "+fpxx"
-// FPXX-DEFAULT-NOT: "-target-feature" "+nooddspreg"
+// FPXX-DEFAULT: "-target-feature" "+fpxx"
+// FPXX-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfp32 2>&1 | \
 // RUN:   FileCheck -check-prefix=FP32 %s
@@ -182,7 +182,7 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-DEFAULT %s
 // ODDSPREG-DEFAULT: -cc1as
-// ODDSPREG-DEFAULT-NOT: "-target-feature" "{{[+-]}}nooddspreg"
+// ODDSPREG-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -modd-spreg 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-ON %s
Index: clang/test/Driver/mips-as.c
===
--- clang/test/Driver/mips-as.c
+++ clang/test/Driver/mips-as.c
@@ -196,7 +196,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-mips16 -mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-16 %s
-// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mips16"
+// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mips16"
 //
 // RUN: %clang -target mips-linux-gnu -mips16 -mno-mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -207,7 +207,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-micromips -mmicromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MICRO %s
-// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmicromips"
+// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mmicromips"
 //
 // RUN: %clang -target mips-linux-gnu -mmicromips -mno-micromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -218,7 +218,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dsp -mdsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSP %s
-// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdsp"
+// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdsp"
 //
 // RUN: %clang -target mips-linux-gnu -mdsp -mno-dsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -229,7 +229,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dspr2 -mdspr2 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSPR2 %s
-// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdspr2"
+// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdspr2"
 //
 // RUN: 

[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-11-17 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

In D138179#3934543 , @MaskRay wrote:

> Rubber stamp. I try to find some mips folks who can verify, so maybe wait a 
> day or so.
>
>> When we use llc or lld to compiler IR files, the features +nan2008 and 
>> +fpxx/+fp64 are not used. Thus wrong format files are produced.
>
> Not sure lld is related. It just consumes the bitcode input when using LTO. 
> Did you mean Clang?

Any program call libllvm to convert IR to asm file or object is effected.
the example is like this:

example 1:

  clang -flto -mnan=2008 -O3 -target mipsel-linux-gnu -c test.c   # the nan2008 
attribute does set
  llc test.o  # the nan2008 is not set in the output test.o.s

example 2

  clang -flto -mnan=2008 -O3 -target mipsel-linux-gnu -o a.out test.c
  # the output is not nan2008 object
  #due to clang doesn't pass -mllvm=-mattr=+nan2008 to lld.

For example2:
We can:

1. pass -mllvm=-mattr=+nan2008 to lld, while ld.bfd doesn't support it.
2. make lld/llvm can recognize the `attributes #0 = ` in IR files.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138179/new/

https://reviews.llvm.org/D138179

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-11-17 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 476039.
wzssyqa added a comment.

Add llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138179/new/

https://reviews.llvm.org/D138179

Files:
  clang/lib/Driver/ToolChains/Arch/Mips.cpp
  clang/test/Driver/mips-as.c
  clang/test/Driver/mips-integrated-as.s
  llvm/lib/Target/Mips/MipsAsmPrinter.cpp
  llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll

Index: llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll
@@ -0,0 +1,15 @@
+; RUN: llc -filetype=asm %s -o - | FileCheck %s
+
+target datalayout = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
+target triple = "mipsel-unknown-linux-gnu"
+
+; Function Attrs: noinline nounwind optnone
+define dso_local void @test() #0 {
+  ret void
+}
+
+attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="mips32r2" "target-features"="+fp64,+mips32r2,+nan2008,-noabicalls" }
+
+
+; CHECK: .nan2008
+; CHECK: .module fp=64
Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp
===
--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -400,6 +400,16 @@
 void MipsAsmPrinter::emitFunctionEntryLabel() {
   MipsTargetStreamer  = getTargetStreamer();
 
+  TS.updateABIInfo(*Subtarget);
+  if (Subtarget->isNaN2008())
+TS.emitDirectiveNaN2008();
+  const MipsTargetMachine  = static_cast(TM);
+  const MipsABIInfo  = MTM.getABI();
+
+  if ((ABI.IsO32() && (Subtarget->isABI_FPXX() || Subtarget->isFP64bit())) ||
+  Subtarget->useSoftFloat())
+TS.emitDirectiveModuleFP();
+
   // NaCl sandboxing requires that indirect call instructions are masked.
   // This means that function entry points should be bundle-aligned.
   if (Subtarget->isTargetNaCl())
Index: clang/test/Driver/mips-integrated-as.s
===
--- clang/test/Driver/mips-integrated-as.s
+++ clang/test/Driver/mips-integrated-as.s
@@ -160,8 +160,8 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=FPXX-DEFAULT %s
 // FPXX-DEFAULT: -cc1as
-// FPXX-DEFAULT-NOT: "-target-feature" "+fpxx"
-// FPXX-DEFAULT-NOT: "-target-feature" "+nooddspreg"
+// FPXX-DEFAULT: "-target-feature" "+fpxx"
+// FPXX-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfp32 2>&1 | \
 // RUN:   FileCheck -check-prefix=FP32 %s
@@ -182,7 +182,7 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-DEFAULT %s
 // ODDSPREG-DEFAULT: -cc1as
-// ODDSPREG-DEFAULT-NOT: "-target-feature" "{{[+-]}}nooddspreg"
+// ODDSPREG-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -modd-spreg 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-ON %s
Index: clang/test/Driver/mips-as.c
===
--- clang/test/Driver/mips-as.c
+++ clang/test/Driver/mips-as.c
@@ -196,7 +196,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-mips16 -mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-16 %s
-// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mips16"
+// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mips16"
 //
 // RUN: %clang -target mips-linux-gnu -mips16 -mno-mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -207,7 +207,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-micromips -mmicromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MICRO %s
-// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmicromips"
+// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mmicromips"
 //
 // RUN: %clang -target mips-linux-gnu -mmicromips -mno-micromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -218,7 +218,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dsp -mdsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSP %s
-// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdsp"
+// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdsp"
 //
 // RUN: %clang -target mips-linux-gnu -mdsp -mno-dsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -229,7 +229,7 @@
 // RUN: %clang 

[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-11-17 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 476033.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138179/new/

https://reviews.llvm.org/D138179

Files:
  clang/lib/Driver/ToolChains/Arch/Mips.cpp
  clang/test/Driver/mips-as.c
  clang/test/Driver/mips-integrated-as.s
  llvm/lib/Target/Mips/MipsAsmPrinter.cpp

Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp
===
--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -400,6 +400,16 @@
 void MipsAsmPrinter::emitFunctionEntryLabel() {
   MipsTargetStreamer  = getTargetStreamer();
 
+  TS.updateABIInfo(*Subtarget);
+  if (Subtarget->isNaN2008())
+TS.emitDirectiveNaN2008();
+  const MipsTargetMachine  = static_cast(TM);
+  const MipsABIInfo  = MTM.getABI();
+
+  if ((ABI.IsO32() && (Subtarget->isABI_FPXX() || Subtarget->isFP64bit())) ||
+  Subtarget->useSoftFloat())
+TS.emitDirectiveModuleFP();
+
   // NaCl sandboxing requires that indirect call instructions are masked.
   // This means that function entry points should be bundle-aligned.
   if (Subtarget->isTargetNaCl())
Index: clang/test/Driver/mips-integrated-as.s
===
--- clang/test/Driver/mips-integrated-as.s
+++ clang/test/Driver/mips-integrated-as.s
@@ -160,8 +160,8 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=FPXX-DEFAULT %s
 // FPXX-DEFAULT: -cc1as
-// FPXX-DEFAULT-NOT: "-target-feature" "+fpxx"
-// FPXX-DEFAULT-NOT: "-target-feature" "+nooddspreg"
+// FPXX-DEFAULT: "-target-feature" "+fpxx"
+// FPXX-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfp32 2>&1 | \
 // RUN:   FileCheck -check-prefix=FP32 %s
@@ -182,7 +182,7 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-DEFAULT %s
 // ODDSPREG-DEFAULT: -cc1as
-// ODDSPREG-DEFAULT-NOT: "-target-feature" "{{[+-]}}nooddspreg"
+// ODDSPREG-DEFAULT: "-target-feature" "+nooddspreg"
 
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -modd-spreg 2>&1 | \
 // RUN:   FileCheck -check-prefix=ODDSPREG-ON %s
Index: clang/test/Driver/mips-as.c
===
--- clang/test/Driver/mips-as.c
+++ clang/test/Driver/mips-as.c
@@ -196,7 +196,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-mips16 -mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-16 %s
-// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mips16"
+// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mips16"
 //
 // RUN: %clang -target mips-linux-gnu -mips16 -mno-mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -207,7 +207,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-micromips -mmicromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MICRO %s
-// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmicromips"
+// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mmicromips"
 //
 // RUN: %clang -target mips-linux-gnu -mmicromips -mno-micromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -218,7 +218,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dsp -mdsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSP %s
-// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdsp"
+// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdsp"
 //
 // RUN: %clang -target mips-linux-gnu -mdsp -mno-dsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -229,7 +229,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dspr2 -mdspr2 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSPR2 %s
-// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdspr2"
+// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdspr2"
 //
 // RUN: %clang -target mips-linux-gnu -mdspr2 -mno-dspr2 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -266,7 +266,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-msa -mmsa -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MSA %s
-// MIPS-MSA: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmsa"
+// MIPS-MSA: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" 

[PATCH] D138179: MIPS: fix build from IR files, nan2008 and FpAbi

2022-11-16 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa created this revision.
wzssyqa added reviewers: MaskRay, atanasyan.
Herald added subscribers: StephenFan, jrtc27, hiraditya, arichardson, sdardis.
Herald added a project: All.
wzssyqa requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

When we use llc or lld to compiler IR files, the features +nan2008 and 
+fpxx/+fp64 are not used.
Thus wrong format files are produced.

In IR files, the attributes are only set for function while not the whole 
compile units.
So we output `.nan 2008` and `.module fp=xx/64` before every function.

`isFPXXDefault`: for o32, the FPXX is always should be the default, no matter 
about the vendors.
Of course some distributions with FP64 default enabled should be listed 
explicit.
Let's add them in future if we know about one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138179

Files:
  clang/lib/Driver/ToolChains/Arch/Mips.cpp
  llvm/lib/Target/Mips/MipsAsmPrinter.cpp


Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp
===
--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -400,6 +400,16 @@
 void MipsAsmPrinter::emitFunctionEntryLabel() {
   MipsTargetStreamer  = getTargetStreamer();
 
+  TS.updateABIInfo(*Subtarget);
+  if (Subtarget->isNaN2008())
+TS.emitDirectiveNaN2008();
+  const MipsTargetMachine  = static_cast(TM);
+  const MipsABIInfo  = MTM.getABI();
+
+  if ((ABI.IsO32() && (Subtarget->isABI_FPXX() || Subtarget->isFP64bit())) ||
+  Subtarget->useSoftFloat())
+TS.emitDirectiveModuleFP();
+
   // NaCl sandboxing requires that indirect call instructions are masked.
   // This means that function entry points should be bundle-aligned.
   if (Subtarget->isTargetNaCl())
Index: clang/lib/Driver/ToolChains/Arch/Mips.cpp
===
--- clang/lib/Driver/ToolChains/Arch/Mips.cpp
+++ clang/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -467,11 +467,6 @@
 
 bool mips::isFPXXDefault(const llvm::Triple , StringRef CPUName,
  StringRef ABIName, mips::FloatABI FloatABI) {
-  if (Triple.getVendor() != llvm::Triple::ImaginationTechnologies &&
-  Triple.getVendor() != llvm::Triple::MipsTechnologies &&
-  !Triple.isAndroid())
-return false;
-
   if (ABIName != "32")
 return false;
 


Index: llvm/lib/Target/Mips/MipsAsmPrinter.cpp
===
--- llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -400,6 +400,16 @@
 void MipsAsmPrinter::emitFunctionEntryLabel() {
   MipsTargetStreamer  = getTargetStreamer();
 
+  TS.updateABIInfo(*Subtarget);
+  if (Subtarget->isNaN2008())
+TS.emitDirectiveNaN2008();
+  const MipsTargetMachine  = static_cast(TM);
+  const MipsABIInfo  = MTM.getABI();
+
+  if ((ABI.IsO32() && (Subtarget->isABI_FPXX() || Subtarget->isFP64bit())) ||
+  Subtarget->useSoftFloat())
+TS.emitDirectiveModuleFP();
+
   // NaCl sandboxing requires that indirect call instructions are masked.
   // This means that function entry points should be bundle-aligned.
   if (Subtarget->isTargetNaCl())
Index: clang/lib/Driver/ToolChains/Arch/Mips.cpp
===
--- clang/lib/Driver/ToolChains/Arch/Mips.cpp
+++ clang/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -467,11 +467,6 @@
 
 bool mips::isFPXXDefault(const llvm::Triple , StringRef CPUName,
  StringRef ABIName, mips::FloatABI FloatABI) {
-  if (Triple.getVendor() != llvm::Triple::ImaginationTechnologies &&
-  Triple.getVendor() != llvm::Triple::MipsTechnologies &&
-  !Triple.isAndroid())
-return false;
-
   if (ABIName != "32")
 return false;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80392: [mips][mc][clang] Use pc-relative relocations in .eh_frame

2022-11-09 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

In D80392#3876782 , @wzssyqa wrote:

> I don't think that we need that option: what we need to do is to update the 
> old tools.

the ld.bfd support R_MIPS_PC32 here.
I think that we can just switch the behavior without any condtions.

And I am working to fix GCC/GAS for it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80392/new/

https://reviews.llvm.org/D80392

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80392: [mips][mc][clang] Use pc-relative relocations in .eh_frame

2022-10-22 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.
Herald added a subscriber: StephenFan.
Herald added a project: All.

I don't think that we need that option: what we need to do is to update the old 
tools.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80392/new/

https://reviews.llvm.org/D80392

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112158: mips: fix search path for multilib o32

2021-10-24 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 381826.
Herald added subscribers: ormris, jrtc27.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112158/new/

https://reviews.llvm.org/D112158

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/debian_6_mips64_tree/libo32/.keep
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtbegin.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtend.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtbegin.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtend.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtbegin.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtend.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtbegin.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtend.o
  clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crt1.o
  clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crti.o
  clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crtn.o
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1039,7 +1039,6 @@
 // CHECK-SPARCV9: "-m" "elf64_sparc"
 // CHECK-SPARCV9: "-dynamic-linker" 
"{{(/usr/sparcv9-unknown-linux-gnu)?}}/lib{{(64)?}}/ld-linux.so.2"
 
-
 // Test linker invocation on Android.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-linux-androideabi -rtlib=platform 
--unwindlib=platform \
@@ -1455,6 +1454,22 @@
 // CHECK-DEBIAN-ML-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=mips64el-linux-gnuabi64 -rtlib=platform -mabi=32 \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/debian_6_mips64_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-DEBIAN-ML-MIPS64EL-O32 %s
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "{{.*}}ld{{(.exe)?}}" 
"--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"{{.*}}/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/../../../../libo32{{/|}}crt1.o"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"{{.*}}/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/../../../../libo32{{/|}}crti.o"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"{{.*}}/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32{{/|}}crtbegin.o"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"-L[[SYSROOT]]/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"-L[[SYSROOT]]/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/../../../../libo32"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/libo32"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/usr/libo32"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=mips64-unknown-linux-gnu --rtlib=platform \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/debian_6_mips64_tree \
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -261,6 +261,13 @@
   const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
+  // mips32: Debian multilib, we use /libo32, while in other case, /lib is
+  // used. We need add both libo32 and /lib.
+  if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel) {
+Generic_GCC::AddMultilibPaths(D, SysRoot, "libo32", MultiarchTriple, 
Paths);
+addPathIfExists(D, SysRoot + "/libo32", Paths);
+addPathIfExists(D, SysRoot + "/usr/libo32", Paths);
+  }
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
 
   addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1081,7 +1081,8 @@
.flag("-m32")
.flag("-mabi=n32");
 
-Multilib M32 = Multilib().flag("-m64").flag("+m32").flag("-mabi=n32");
+Multilib M32 =
+
Multilib().gccSuffix("/32").flag("-m64").flag("+m32").flag("-mabi=n32");
 
 DebianMipsMultilibs =
 MultilibSet().Either(M32, M64, MAbiN32).FilterOut(NonExistent);
@@ -2120,11 +2121,11 @@
   static const char *const M68kTriples[] = {
   "m68k-linux-gnu", "m68k-unknown-linux-gnu", "m68k-suse-linux"};

[PATCH] D112158: mips: fix search path for multilib o32

2021-10-21 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

In D112158#3077049 , @atanasyan wrote:

> - Does this problem exist on all versions of Debian or starting from specific 
> version only?

This feature starts from llvm-8. And this problem is since then.

> - This fix needs test cases. Take a look at "Check linker invocation on 
> Debian 6 MIPS 32/64-bit" in the `clang/test/Driver/linux-ld.c` for example.

I will do so.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112158/new/

https://reviews.llvm.org/D112158

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112158: mips: fix search path for multilib o32

2021-10-20 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa created this revision.
wzssyqa added a reviewer: atanasyan.
Herald added subscribers: arichardson, sdardis.
wzssyqa requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In the situation of multilib, the gcc objects are in a /32 directory.
On Debian, the libraries is under /libo32 to avoid confliction.

This patch enables clang find gcc in /32, and C lib in /libo32.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112158

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -261,6 +261,10 @@
   const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
+  // mips32: Debian multilib, we use /libo32, while in other case, /lib is
+  // used. We need add both libo32 and /lib.
+  if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel)
+Generic_GCC::AddMultilibPaths(D, SysRoot, "libo32", MultiarchTriple, 
Paths);
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
 
   addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1086,7 +1086,8 @@
.flag("-m32")
.flag("-mabi=n32");
 
-Multilib M32 = Multilib().flag("-m64").flag("+m32").flag("-mabi=n32");
+Multilib M32 =
+
Multilib().gccSuffix("/32").flag("-m64").flag("+m32").flag("-mabi=n32");
 
 DebianMipsMultilibs =
 MultilibSet().Either(M32, M64, MAbiN32).FilterOut(NonExistent);
@@ -2125,11 +2126,11 @@
   static const char *const M68kTriples[] = {
   "m68k-linux-gnu", "m68k-unknown-linux-gnu", "m68k-suse-linux"};
 
-  static const char *const MIPSLibDirs[] = {"/lib"};
+  static const char *const MIPSLibDirs[] = {"/libo32", "/lib"};
   static const char *const MIPSTriples[] = {
   "mips-linux-gnu", "mips-mti-linux", "mips-mti-linux-gnu",
   "mips-img-linux-gnu", "mipsisa32r6-linux-gnu"};
-  static const char *const MIPSELLibDirs[] = {"/lib"};
+  static const char *const MIPSELLibDirs[] = {"/libo32", "/lib"};
   static const char *const MIPSELTriples[] = {
   "mipsel-linux-gnu", "mips-img-linux-gnu", "mipsisa32r6el-linux-gnu"};
 


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -261,6 +261,10 @@
   const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
+  // mips32: Debian multilib, we use /libo32, while in other case, /lib is
+  // used. We need add both libo32 and /lib.
+  if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel)
+Generic_GCC::AddMultilibPaths(D, SysRoot, "libo32", MultiarchTriple, Paths);
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
 
   addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1086,7 +1086,8 @@
.flag("-m32")
.flag("-mabi=n32");
 
-Multilib M32 = Multilib().flag("-m64").flag("+m32").flag("-mabi=n32");
+Multilib M32 =
+Multilib().gccSuffix("/32").flag("-m64").flag("+m32").flag("-mabi=n32");
 
 DebianMipsMultilibs =
 MultilibSet().Either(M32, M64, MAbiN32).FilterOut(NonExistent);
@@ -2125,11 +2126,11 @@
   static const char *const M68kTriples[] = {
   "m68k-linux-gnu", "m68k-unknown-linux-gnu", "m68k-suse-linux"};
 
-  static const char *const MIPSLibDirs[] = {"/lib"};
+  static const char *const MIPSLibDirs[] = {"/libo32", "/lib"};
   static const char *const MIPSTriples[] = {
   "mips-linux-gnu", "mips-mti-linux", "mips-mti-linux-gnu",
   "mips-img-linux-gnu", "mipsisa32r6-linux-gnu"};
-  static const char *const MIPSELLibDirs[] = {"/lib"};
+  static const char *const MIPSELLibDirs[] = {"/libo32", "/lib"};
   static const char *const MIPSELTriples[] = {
   "mipsel-linux-gnu", "mips-img-linux-gnu", "mipsisa32r6el-linux-gnu"};
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50850: clang: Add triples support for MIPS r6

2018-10-16 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 169810.

https://reviews.llvm.org/D50850

Files:
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -291,13 +291,27 @@
 // MIPS: "-target-cpu" "mips32r2"
 // MIPS: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa32r6-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSR6 %s
+// MIPSR6: clang
+// MIPSR6: "-cc1"
+// MIPSR6: "-target-cpu" "mips32r6"
+// MIPSR6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mipsel-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSEL %s
 // MIPSEL: clang
 // MIPSEL: "-cc1"
 // MIPSEL: "-target-cpu" "mips32r2"
 // MIPSEL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa32r6el-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSR6EL %s
+// MIPSR6EL: clang
+// MIPSR6EL: "-cc1"
+// MIPSR6EL: "-target-cpu" "mips32r6"
+// MIPSR6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mipsel-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSEL-ANDROID %s
 // MIPSEL-ANDROID: clang
@@ -323,45 +337,91 @@
 // MIPS64: "-target-cpu" "mips64r2"
 // MIPS64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6 %s
+// MIPS64R6: clang
+// MIPS64R6: "-cc1"
+// MIPS64R6: "-target-cpu" "mips64r6"
+// MIPS64R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL %s
 // MIPS64EL: clang
 // MIPS64EL: "-cc1"
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6EL %s
+// MIPS64R6EL: clang
+// MIPS64R6EL: "-cc1"
+// MIPS64R6EL: "-target-cpu" "mips64r6"
+// MIPS64R6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
 // MIPS64-GNUABI64: clang
 // MIPS64-GNUABI64: "-cc1"
 // MIPS64-GNUABI64: "-target-cpu" "mips64r2"
 // MIPS64-GNUABI64: "-target-abi" "n64"
 // MIPS64-GNUABI64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6-GNUABI64 %s
+// MIPS64R6-GNUABI64: clang
+// MIPS64R6-GNUABI64: "-cc1"
+// MIPS64R6-GNUABI64: "-target-cpu" "mips64r6"
+// MIPS64R6-GNUABI64: "-target-abi" "n64"
+// MIPS64R6-GNUABI64: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
 // MIPS64EL-GNUABI64: clang
 // MIPS64EL-GNUABI64: "-cc1"
 // MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
 // MIPS64EL-GNUABI64: "-target-abi" "n64"
 // MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6EL-GNUABI64 %s
+// MIPS64R6EL-GNUABI64: clang
+// MIPS64R6EL-GNUABI64: "-cc1"
+// MIPS64R6EL-GNUABI64: "-target-cpu" "mips64r6"
+// MIPS64R6EL-GNUABI64: "-target-abi" "n64"
+// MIPS64R6EL-GNUABI64: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSN32 %s
 // MIPSN32: clang
 // MIPSN32: "-cc1"
 // MIPSN32: "-target-cpu" "mips64r2"
 // MIPSN32: "-target-abi" "n32"
 // MIPSN32: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32R6 %s
+// MIPSN32R6: clang
+// MIPSN32R6: "-cc1"
+// MIPSN32R6: "-target-cpu" "mips64r6"
+// MIPSN32R6: "-target-abi" "n32"
+// MIPSN32R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSN32EL %s
 // MIPSN32EL: clang
 // MIPSN32EL: "-cc1"
 // MIPSN32EL: "-target-cpu" "mips64r2"
 // MIPSN32EL: "-target-abi" "n32"
 // MIPSN32EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32R6EL %s
+// MIPSN32R6EL: clang
+// MIPSN32R6EL: "-cc1"
+// MIPSN32R6EL: "-target-cpu" "mips64r6"
+// MIPSN32R6EL: "-target-abi" "n32"
+// MIPSN32R6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -5,20 +5,36 @@
 // RUN: %clang_cc1 

[PATCH] D50850: clang: Add triples support for MIPS r6

2018-10-16 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

In https://reviews.llvm.org/D50850#1250313, @atanasyan wrote:

> In https://reviews.llvm.org/D50850#1250285, @wzssyqa wrote:
>
> > This is really for Clang. I guess you mean that compiler-rt directory also 
> > need to be patched.
>
>
> If you take a look at the previous version of this patch 
> https://reviews.llvm.org/D50850?id=167419, you see that it changed LLVM 
> files. Probably you attached another diff.


You are right. I uploaded the patch for llvm here by mistake.
And soon, I recognized, and then upload the right one.

> As to `compiler-rt` - the Phabricator replace `R6` symbols by the 
> `https://reviews.llvm.org/source/compiler-rt/` links. So my statement was 
> "Could you attach an actual patch brings `R6` support to the Clang driver?".






Comment at: lib/Driver/ToolChains/Linux.cpp:126
   return "mips64-linux-gnu";
-if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnuabi64"))
-  return "mips64-linux-gnuabi64";
+MipsCpu = (TargetSubArch == llvm::Triple::MipsSubArch_r6) ? "mipsisa64"
+  : "mips64";

wzssyqa wrote:
> atanasyan wrote:
> > Suppose there are both "/lib/mips64-linux-gnu" and 
> > "/lib/mipsisa64-linux-gnuabi64" paths on a disk and provided target triple 
> > is mipsisa64-linux-gnuabi64. Is it good that we return "mips64-linux-gnu" 
> > from this function anyway?
> No, return `mips64-linux-gnu' is not good, I keep it just for to making sure 
> I don't change the behavior of clang with my patch.
> 
> In fact, mips64-linux-gnu in gcc is N32, and Debian never use this triple, we 
> use
> mips*64*-linux-gnuabin32
> So, on Debian, mips64-linux-gnu should never appear.
mips64-linux-gnu is removed and replaced by  MipsCpu + "-linux-" + Mips64Abi


https://reviews.llvm.org/D50850



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-10-03 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

ohhh. make check-all is needed, instead of make check

> test/CodeGen/target-data.c

  is due to duplicate line `MIPS-64EL: target datalayout = 
"e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"'

> test/Driver/mips-cs.cpp

  is due to this test use the hardcode path `/mips-linux-gnu/', so mipsel and 
mips64el also need
  BiarchTripleAliases.append(begin(MIPSTriples), end(MIPSTriples));
  although MIPSTriples should in the last order.




Comment at: lib/Driver/ToolChains/Arch/Mips.cpp:109
 
+  if (ABIName.empty() && (Triple.getEnvironment() == llvm::Triple::GNUABIN32))
+ABIName = "n32";

atanasyan wrote:
> If target triple is mips-mti-linux-gnuabin32 the code above set (incorrectly) 
> the `ABIName` to `n64` and this statement will be `false`.
as I know mips-mti-linux-gnuabin32 is never used, at least for gcc.
Should we allow it?



Comment at: lib/Driver/ToolChains/Arch/Mips.cpp:85
 
   if (ABIName.empty() &&
   (Triple.getVendor() == llvm::Triple::MipsTechnologies ||

atanasyan wrote:
> Is possible to rewrite this piece of code (lines 85-114) as follows?
> ```
>   if (ABIName.empty() && (Triple.getEnvironment() == llvm::Triple::GNUABIN32))
> ABIName = "n32";
> 
>   if (ABIName.empty() &&
>   (Triple.getVendor() == llvm::Triple::MipsTechnologies ||
>Triple.getVendor() == llvm::Triple::ImaginationTechnologies)) {
> ABIName = llvm::StringSwitch(CPUName)
>   .Case("mips1", "o32")
>   .Case("mips2", "o32")
>   .Case("mips3", "n64")
>   .Case("mips4", "n64")
>   .Case("mips5", "n64")
>   .Case("mips32", "o32")
>   .Case("mips32r2", "o32")
>   .Case("mips32r3", "o32")
>   .Case("mips32r5", "o32")
>   .Case("mips32r6", "o32")
>   .Case("mips64", "n64")
>   .Case("mips64r2", "n64")
>   .Case("mips64r3", "n64")
>   .Case("mips64r5", "n64")
>   .Case("mips64r6", "n64")
>   .Case("octeon", "n64")
>   .Case("p5600", "o32")
>   .Default("");
>   }
> ```
OK. I didn't do like this because I am not very full confident about whether 
there are some case that it is set to N32 even -gnuabin32 is used.



Comment at: lib/Driver/ToolChains/Gnu.cpp:2082
 BiarchTripleAliases.append(begin(MIPSELTriples), end(MIPSELTriples));
-BiarchTripleAliases.append(begin(MIPSTriples), end(MIPSTriples));
+BiarchLibDirs.append(begin(MIPSN32ELLibDirs), end(MIPSN32ELLibDirs));
+BiarchTripleAliases.append(begin(MIPSN32ELTriples), end(MIPSN32ELTriples));

atanasyan wrote:
> Why do you remove `BiarchTripleAliases.append(begin(MIPSTriples), 
> end(MIPSTriples));` in that case only? Is it intended?
ohhh, my fault. I should remove from mipsel also.



Comment at: lib/Driver/ToolChains/Linux.cpp:47
   bool IsAndroid = TargetTriple.isAndroid();
+  std::string MipsCpu = "", Mips64Abi = "gnuabi64";
+  if (TargetEnvironment == llvm::Triple::GNUABIN32)

atanasyan wrote:
> - Do you need `MipsCpu` variable?
> - Is it possible to use any lightweight type like `StringRef` for the 
> `Mips64Abi`?
oh, MipsCpu is not used here, while used in D50850.
In that patch. we need different CPU names:

mipsel vs mipsisa32r6el

etc. It is my fault to split the patches.


StringRef  is not OK as, the return value of getMultiarchTriple is std::string.



Comment at: lib/Driver/ToolChains/Linux.cpp:118
   case llvm::Triple::mips64:
 if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnu"))
   return "mips64-linux-gnu";

atanasyan wrote:
> If a user has two toolchains installed into "/lib/mips64-linux-gnu" and 
> "/lib/mips64-linux-gnuabin32", this code always selects mips64-linux-gnu even 
> if N32 ABI is requested. Is it intended?
Yes. It is intended.

I don't want my patch change the behavior of llvm/clang:
the previous of llvm/clang behavior is perfering /lib/mips64-linux-gnu.

And on Debian, /lib/mips64-linux-gnu should never exists, we use
/lib/mips64-linux-gnuabi64
and 
   /lib/mips64-linux-gnuabin32




Comment at: lib/Driver/ToolChains/Linux.cpp:118
   case llvm::Triple::mips64:
 if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnu"))
   return "mips64-linux-gnu";

wzssyqa wrote:
> atanasyan wrote:
> > If a user has two toolchains installed into "/lib/mips64-linux-gnu" and 
> > "/lib/mips64-linux-gnuabin32", this code always selects mips64-linux-gnu 
> > even if N32 ABI is requested. Is it intended?
> Yes. It is intended.
> 
> I don't want my patch change the behavior of llvm/clang:
> the previous of llvm/clang behavior is perfering /lib/mips64-linux-gnu.
> 
> And on Debian, 

[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-10-03 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 168116.

https://reviews.llvm.org/D51464

Files:
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -330,6 +330,38 @@
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
+// MIPS64-GNUABI64: clang
+// MIPS64-GNUABI64: "-cc1"
+// MIPS64-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64-GNUABI64: "-target-abi" "n64"
+// MIPS64-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
+// MIPS64EL-GNUABI64: clang
+// MIPS64EL-GNUABI64: "-cc1"
+// MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64EL-GNUABI64: "-target-abi" "n64"
+// MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32 %s
+// MIPSN32: clang
+// MIPSN32: "-cc1"
+// MIPSN32: "-target-cpu" "mips64r2"
+// MIPSN32: "-target-abi" "n32"
+// MIPSN32: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32EL %s
+// MIPSN32EL: clang
+// MIPSN32EL: "-cc1"
+// MIPSN32EL: "-target-cpu" "mips64r2"
+// MIPSN32EL: "-target-abi" "n32"
+// MIPSN32EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -11,6 +11,14 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple mips64el-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
Index: test/CodeGen/target-data.c
===
--- test/CodeGen/target-data.c
+++ test/CodeGen/target-data.c
@@ -42,18 +42,30 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EL
+
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabin32 -o - -emit-llvm \
+// RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EB
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 \
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
 // MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -o - -emit-llvm %s \
+// RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
+
 // RUN: %clang_cc1 -triple powerpc64-lv2 -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=PS3
 // PS3: target datalayout = "E-m:e-p:32:32-i64:64-n32:64"
Index: test/CodeGen/mips-zero-sized-struct.c
===
--- test/CodeGen/mips-zero-sized-struct.c
+++ test/CodeGen/mips-zero-sized-struct.c
@@ -2,8 +2,12 @@
 // RUN: 

[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-09-29 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 167632.

https://reviews.llvm.org/D51464

Files:
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -330,6 +330,38 @@
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
+// MIPS64-GNUABI64: clang
+// MIPS64-GNUABI64: "-cc1"
+// MIPS64-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64-GNUABI64: "-target-abi" "n64"
+// MIPS64-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
+// MIPS64EL-GNUABI64: clang
+// MIPS64EL-GNUABI64: "-cc1"
+// MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64EL-GNUABI64: "-target-abi" "n64"
+// MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32 %s
+// MIPSN32: clang
+// MIPSN32: "-cc1"
+// MIPSN32: "-target-cpu" "mips64r2"
+// MIPSN32: "-target-abi" "n32"
+// MIPSN32: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32EL %s
+// MIPSN32EL: clang
+// MIPSN32EL: "-cc1"
+// MIPSN32EL: "-target-cpu" "mips64r2"
+// MIPSN32EL: "-target-abi" "n32"
+// MIPSN32EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -11,6 +11,14 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple mips64el-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
Index: test/CodeGen/target-data.c
===
--- test/CodeGen/target-data.c
+++ test/CodeGen/target-data.c
@@ -42,18 +42,34 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EL
+// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabin32 -o - -emit-llvm \
+// RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
+// MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EB
+// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 \
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
 // MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -o - -emit-llvm %s \
+// RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
+// MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple powerpc64-lv2 

[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-09-29 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 167631.

https://reviews.llvm.org/D51464

Files:
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2060,7 +2060,6 @@
   case llvm::Triple::mipsel:
 LibDirs.append(begin(MIPSELLibDirs), end(MIPSELLibDirs));
 TripleAliases.append(begin(MIPSELTriples), end(MIPSELTriples));
-TripleAliases.append(begin(MIPSTriples), end(MIPSTriples));
 BiarchLibDirs.append(begin(MIPS64ELLibDirs), end(MIPS64ELLibDirs));
 BiarchTripleAliases.append(begin(MIPS64ELTriples), end(MIPS64ELTriples));
 BiarchLibDirs.append(begin(MIPSN32ELLibDirs), end(MIPSN32ELLibDirs));
Index: lib/Driver/ToolChains/Arch/Mips.cpp
===
--- lib/Driver/ToolChains/Arch/Mips.cpp
+++ lib/Driver/ToolChains/Arch/Mips.cpp
@@ -82,6 +82,9 @@
 }
   }
 
+  if (ABIName.empty() && (Triple.getEnvironment() == llvm::Triple::GNUABIN32))
+ABIName = "n32";
+
   if (ABIName.empty() &&
   (Triple.getVendor() == llvm::Triple::MipsTechnologies ||
Triple.getVendor() == llvm::Triple::ImaginationTechnologies)) {
@@ -104,15 +107,8 @@
   .Case("octeon", "n64")
   .Case("p5600", "o32")
   .Default("");
-if (Triple.getEnvironment() == llvm::Triple::GNUABIN32)
-  ABIName = llvm::StringSwitch(ABIName)
-.Case("n64", "n32")
-.Default(ABIName);
   }
 
-  if (ABIName.empty() && (Triple.getEnvironment() == llvm::Triple::GNUABIN32))
-ABIName = "n32";
-
   if (ABIName.empty()) {
 // Deduce ABI name from the target triple.
 ABIName = Triple.isMIPS32() ? "o32" : "n64";


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2060,7 +2060,6 @@
   case llvm::Triple::mipsel:
 LibDirs.append(begin(MIPSELLibDirs), end(MIPSELLibDirs));
 TripleAliases.append(begin(MIPSELTriples), end(MIPSELTriples));
-TripleAliases.append(begin(MIPSTriples), end(MIPSTriples));
 BiarchLibDirs.append(begin(MIPS64ELLibDirs), end(MIPS64ELLibDirs));
 BiarchTripleAliases.append(begin(MIPS64ELTriples), end(MIPS64ELTriples));
 BiarchLibDirs.append(begin(MIPSN32ELLibDirs), end(MIPSN32ELLibDirs));
Index: lib/Driver/ToolChains/Arch/Mips.cpp
===
--- lib/Driver/ToolChains/Arch/Mips.cpp
+++ lib/Driver/ToolChains/Arch/Mips.cpp
@@ -82,6 +82,9 @@
 }
   }
 
+  if (ABIName.empty() && (Triple.getEnvironment() == llvm::Triple::GNUABIN32))
+ABIName = "n32";
+
   if (ABIName.empty() &&
   (Triple.getVendor() == llvm::Triple::MipsTechnologies ||
Triple.getVendor() == llvm::Triple::ImaginationTechnologies)) {
@@ -104,15 +107,8 @@
   .Case("octeon", "n64")
   .Case("p5600", "o32")
   .Default("");
-if (Triple.getEnvironment() == llvm::Triple::GNUABIN32)
-  ABIName = llvm::StringSwitch(ABIName)
-.Case("n64", "n32")
-.Default(ABIName);
   }
 
-  if (ABIName.empty() && (Triple.getEnvironment() == llvm::Triple::GNUABIN32))
-ABIName = "n32";
-
   if (ABIName.empty()) {
 // Deduce ABI name from the target triple.
 ABIName = Triple.isMIPS32() ? "o32" : "n64";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50850: clang: Add triples support for MIPS r6

2018-09-29 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 167630.

https://reviews.llvm.org/D50850

Files:
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -291,13 +291,27 @@
 // MIPS: "-target-cpu" "mips32r2"
 // MIPS: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa32r6-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSR6 %s
+// MIPSR6: clang
+// MIPSR6: "-cc1"
+// MIPSR6: "-target-cpu" "mips32r6"
+// MIPSR6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mipsel-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSEL %s
 // MIPSEL: clang
 // MIPSEL: "-cc1"
 // MIPSEL: "-target-cpu" "mips32r2"
 // MIPSEL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa32r6el-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSR6EL %s
+// MIPSR6EL: clang
+// MIPSR6EL: "-cc1"
+// MIPSR6EL: "-target-cpu" "mips32r6"
+// MIPSR6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mipsel-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSEL-ANDROID %s
 // MIPSEL-ANDROID: clang
@@ -323,45 +337,91 @@
 // MIPS64: "-target-cpu" "mips64r2"
 // MIPS64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6 %s
+// MIPS64R6: clang
+// MIPS64R6: "-cc1"
+// MIPS64R6: "-target-cpu" "mips64r6"
+// MIPS64R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL %s
 // MIPS64EL: clang
 // MIPS64EL: "-cc1"
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6EL %s
+// MIPS64R6EL: clang
+// MIPS64R6EL: "-cc1"
+// MIPS64R6EL: "-target-cpu" "mips64r6"
+// MIPS64R6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
 // MIPS64-GNUABI64: clang
 // MIPS64-GNUABI64: "-cc1"
 // MIPS64-GNUABI64: "-target-cpu" "mips64r2"
 // MIPS64-GNUABI64: "-target-abi" "n64"
 // MIPS64-GNUABI64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6-GNUABI64 %s
+// MIPS64R6-GNUABI64: clang
+// MIPS64R6-GNUABI64: "-cc1"
+// MIPS64R6-GNUABI64: "-target-cpu" "mips64r6"
+// MIPS64R6-GNUABI64: "-target-abi" "n64"
+// MIPS64R6-GNUABI64: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
 // MIPS64EL-GNUABI64: clang
 // MIPS64EL-GNUABI64: "-cc1"
 // MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
 // MIPS64EL-GNUABI64: "-target-abi" "n64"
 // MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6EL-GNUABI64 %s
+// MIPS64R6EL-GNUABI64: clang
+// MIPS64R6EL-GNUABI64: "-cc1"
+// MIPS64R6EL-GNUABI64: "-target-cpu" "mips64r6"
+// MIPS64R6EL-GNUABI64: "-target-abi" "n64"
+// MIPS64R6EL-GNUABI64: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSN32 %s
 // MIPSN32: clang
 // MIPSN32: "-cc1"
 // MIPSN32: "-target-cpu" "mips64r2"
 // MIPSN32: "-target-abi" "n32"
 // MIPSN32: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32R6 %s
+// MIPSN32R6: clang
+// MIPSN32R6: "-cc1"
+// MIPSN32R6: "-target-cpu" "mips64r6"
+// MIPSN32R6: "-target-abi" "n32"
+// MIPSN32R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSN32EL %s
 // MIPSN32EL: clang
 // MIPSN32EL: "-cc1"
 // MIPSN32EL: "-target-cpu" "mips64r2"
 // MIPSN32EL: "-target-abi" "n32"
 // MIPSN32EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32R6EL %s
+// MIPSN32R6EL: clang
+// MIPSN32R6EL: "-cc1"
+// MIPSN32R6EL: "-target-cpu" "mips64r6"
+// MIPSN32R6EL: "-target-abi" "n32"
+// MIPSN32R6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -5,20 +5,36 @@
 // RUN: %clang_cc1 

[PATCH] D50850: clang: Add triples support for MIPS r6

2018-09-29 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

This is really for Clang. I guess you mean that compiler-rt directory also need 
to be patched.




Comment at: lib/Driver/ToolChains/Arch/Mips.cpp:115
+  if (ABIName.empty() && (Triple.getEnvironment() == llvm::Triple::GNUABIN32))
+ABIName = "n32";
+

atanasyan wrote:
> It looks like this change is unrelated to introducing new target triples and 
> can be made by a separate commit.
These lines code about N32, is quite close tied with r6 staffs, as they shared 
lots.

Is it ok to update the descriptions?



Comment at: lib/Driver/ToolChains/Gnu.cpp:2093
 BiarchTripleAliases.append(begin(MIPSELTriples), end(MIPSELTriples));
-BiarchTripleAliases.append(begin(MIPSTriples), end(MIPSTriples));
+BiarchLibDirs.append(begin(MIPSN32ELLibDirs), end(MIPSN32ELLibDirs));
+BiarchTripleAliases.append(begin(MIPSN32ELTriples), end(MIPSN32ELTriples));

atanasyan wrote:
> Ditto
As a question: why  MIPSTriples here?
the above mips64 lines don't include any EL Triples.



Comment at: lib/Driver/ToolChains/Gnu.cpp:2437
 if (getTriple().getEnvironment() == llvm::Triple::GNUABI64 ||
-getTriple().isAndroid() ||
-getTriple().isOSFreeBSD() ||
+getTriple().getEnvironment() == llvm::Triple::GNUABIN32 ||
+getTriple().isAndroid() || getTriple().isOSFreeBSD() ||

atanasyan wrote:
> Are you sure that integrated LLVM assembler is ready to support N32 code 
> generation? Anyway this change is for  a separate patch.
I didn't have so many test, while helloworld programs really works.





Comment at: lib/Driver/ToolChains/Linux.cpp:126
   return "mips64-linux-gnu";
-if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnuabi64"))
-  return "mips64-linux-gnuabi64";
+MipsCpu = (TargetSubArch == llvm::Triple::MipsSubArch_r6) ? "mipsisa64"
+  : "mips64";

atanasyan wrote:
> Suppose there are both "/lib/mips64-linux-gnu" and 
> "/lib/mipsisa64-linux-gnuabi64" paths on a disk and provided target triple is 
> mipsisa64-linux-gnuabi64. Is it good that we return "mips64-linux-gnu" from 
> this function anyway?
No, return `mips64-linux-gnu' is not good, I keep it just for to making sure I 
don't change the behavior of clang with my patch.

In fact, mips64-linux-gnu in gcc is N32, and Debian never use this triple, we 
use
mips*64*-linux-gnuabin32
So, on Debian, mips64-linux-gnu should never appear.


https://reviews.llvm.org/D50850



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50850: clang: Add triples support for MIPS r6

2018-09-27 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 167419.
Herald added a subscriber: dexonsmith.

https://reviews.llvm.org/D50850

Files:
  include/llvm/ADT/Triple.h
  lib/Support/Triple.cpp
  lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp
  unittests/ADT/TripleTest.cpp

Index: unittests/ADT/TripleTest.cpp
===
--- unittests/ADT/TripleTest.cpp
+++ unittests/ADT/TripleTest.cpp
@@ -366,59 +366,163 @@
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::Linux, T.getOS());
   EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
   T = Triple("mips64el");
   EXPECT_EQ(Triple::mips64el, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
 
   T = Triple("mips64-unknown-linux-gnuabi64");
   EXPECT_EQ(Triple::mips64, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::Linux, T.getOS());
   EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
   T = Triple("mips64");
   EXPECT_EQ(Triple::mips64, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+
+  T = Triple("mipsisa64r6el-unknown-linux-gnuabi64");
+  EXPECT_EQ(Triple::mips64el, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::Linux, T.getOS());
+  EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+  T = Triple("mips64r6el");
+  EXPECT_EQ(Triple::mips64el, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+  T = Triple("mipsisa64r6el");
+  EXPECT_EQ(Triple::mips64el, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+
+  T = Triple("mipsisa64r6-unknown-linux-gnuabi64");
+  EXPECT_EQ(Triple::mips64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::Linux, T.getOS());
+  EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+  T = Triple("mips64r6");
+  EXPECT_EQ(Triple::mips64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+  T = Triple("mipsisa64r6");
+  EXPECT_EQ(Triple::mips64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::GNUABI64, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
 
   T = Triple("mips64el-unknown-linux-gnuabin32");
   EXPECT_EQ(Triple::mips64el, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::Linux, T.getOS());
   EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
   T = Triple("mipsn32el");
   EXPECT_EQ(Triple::mips64el, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
 
   T = Triple("mips64-unknown-linux-gnuabin32");
   EXPECT_EQ(Triple::mips64, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::Linux, T.getOS());
   EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
   T = Triple("mipsn32");
   EXPECT_EQ(Triple::mips64, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::NoSubArch, T.getSubArch());
+
+  T = Triple("mipsisa64r6el-unknown-linux-gnuabin32");
+  EXPECT_EQ(Triple::mips64el, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::Linux, T.getOS());
+  EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+  T = Triple("mipsn32r6el");
+  EXPECT_EQ(Triple::mips64el, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+
+  T = Triple("mipsisa64r6-unknown-linux-gnuabin32");
+  EXPECT_EQ(Triple::mips64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::Linux, T.getOS());
+  EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
+  T = Triple("mipsn32r6");
+  EXPECT_EQ(Triple::mips64, T.getArch());
+  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
+  EXPECT_EQ(Triple::GNUABIN32, T.getEnvironment());
+  EXPECT_EQ(Triple::MipsSubArch_r6, T.getSubArch());
 

[PATCH] D50850: clang: Add triples support for MIPS r6

2018-09-27 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a subscriber: rsmith.
wzssyqa added a comment.

I updated N32 patch for clang.
Simon Atanasyan via Phabricator 
于2018年9月27日周四 下午8:23写道:

> atanasyan added a comment.
> 
> Could you please update the patch against the current trunk?
> 
> Repository:
> 
>   rC Clang
> 
> https://reviews.llvm.org/D50850


Repository:
  rC Clang

https://reviews.llvm.org/D50850



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-09-27 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 167340.

https://reviews.llvm.org/D51464

Files:
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -330,6 +330,38 @@
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
+// MIPS64-GNUABI64: clang
+// MIPS64-GNUABI64: "-cc1"
+// MIPS64-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64-GNUABI64: "-target-abi" "n64"
+// MIPS64-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
+// MIPS64EL-GNUABI64: clang
+// MIPS64EL-GNUABI64: "-cc1"
+// MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64EL-GNUABI64: "-target-abi" "n64"
+// MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32 %s
+// MIPSN32: clang
+// MIPSN32: "-cc1"
+// MIPSN32: "-target-cpu" "mips64r2"
+// MIPSN32: "-target-abi" "n32"
+// MIPSN32: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32EL %s
+// MIPSN32EL: clang
+// MIPSN32EL: "-cc1"
+// MIPSN32EL: "-target-cpu" "mips64r2"
+// MIPSN32EL: "-target-abi" "n32"
+// MIPSN32EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -11,6 +11,14 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple mips64el-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
Index: test/CodeGen/target-data.c
===
--- test/CodeGen/target-data.c
+++ test/CodeGen/target-data.c
@@ -42,18 +42,34 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EL
+// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabin32 -o - -emit-llvm \
+// RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
+// MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EB
+// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 \
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
 // MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -o - -emit-llvm %s \
+// RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
+// MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple powerpc64-lv2 

[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-09-19 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 166220.
wzssyqa added a comment.

remove mips64(el)-linux-gnu from path search.


Repository:
  rC Clang

https://reviews.llvm.org/D51464

Files:
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -330,6 +330,38 @@
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
+// MIPS64-GNUABI64: clang
+// MIPS64-GNUABI64: "-cc1"
+// MIPS64-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64-GNUABI64: "-target-abi" "n64"
+// MIPS64-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
+// MIPS64EL-GNUABI64: clang
+// MIPS64EL-GNUABI64: "-cc1"
+// MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64EL-GNUABI64: "-target-abi" "n64"
+// MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32 %s
+// MIPSN32: clang
+// MIPSN32: "-cc1"
+// MIPSN32: "-target-cpu" "mips64r2"
+// MIPSN32: "-target-abi" "n32"
+// MIPSN32: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32EL %s
+// MIPSN32EL: clang
+// MIPSN32EL: "-cc1"
+// MIPSN32EL: "-target-cpu" "mips64r2"
+// MIPSN32EL: "-target-abi" "n32"
+// MIPSN32EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -11,6 +11,14 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple mips64el-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
+// RUN: -triple mips64el-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - \
 // RUN: -triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
Index: test/CodeGen/target-data.c
===
--- test/CodeGen/target-data.c
+++ test/CodeGen/target-data.c
@@ -42,18 +42,34 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EL
+// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabin32 -o - -emit-llvm \
+// RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
+// MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EB
+// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 \
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
 // MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -o - -emit-llvm %s \
+// RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
+// MIPS-64EB-N32: target datalayout = 

[PATCH] D50850: clang: Add triples support for MIPS r6

2018-09-19 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 166219.

Repository:
  rC Clang

https://reviews.llvm.org/D50850

Files:
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -291,13 +291,27 @@
 // MIPS: "-target-cpu" "mips32r2"
 // MIPS: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa32r6-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSR6 %s
+// MIPSR6: clang
+// MIPSR6: "-cc1"
+// MIPSR6: "-target-cpu" "mips32r6"
+// MIPSR6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mipsel-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSEL %s
 // MIPSEL: clang
 // MIPSEL: "-cc1"
 // MIPSEL: "-target-cpu" "mips32r2"
 // MIPSEL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa32r6el-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSR6EL %s
+// MIPSR6EL: clang
+// MIPSR6EL: "-cc1"
+// MIPSR6EL: "-target-cpu" "mips32r6"
+// MIPSR6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mipsel-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSEL-ANDROID %s
 // MIPSEL-ANDROID: clang
@@ -323,45 +337,91 @@
 // MIPS64: "-target-cpu" "mips64r2"
 // MIPS64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6 %s
+// MIPS64R6: clang
+// MIPS64R6: "-cc1"
+// MIPS64R6: "-target-cpu" "mips64r6"
+// MIPS64R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL %s
 // MIPS64EL: clang
 // MIPS64EL: "-cc1"
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6EL %s
+// MIPS64R6EL: clang
+// MIPS64R6EL: "-cc1"
+// MIPS64R6EL: "-target-cpu" "mips64r6"
+// MIPS64R6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
 // MIPS64-GNUABI64: clang
 // MIPS64-GNUABI64: "-cc1"
 // MIPS64-GNUABI64: "-target-cpu" "mips64r2"
 // MIPS64-GNUABI64: "-target-abi" "n64"
 // MIPS64-GNUABI64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6-GNUABI64 %s
+// MIPS64R6-GNUABI64: clang
+// MIPS64R6-GNUABI64: "-cc1"
+// MIPS64R6-GNUABI64: "-target-cpu" "mips64r6"
+// MIPS64R6-GNUABI64: "-target-abi" "n64"
+// MIPS64R6-GNUABI64: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
 // MIPS64EL-GNUABI64: clang
 // MIPS64EL-GNUABI64: "-cc1"
 // MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
 // MIPS64EL-GNUABI64: "-target-abi" "n64"
 // MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6EL-GNUABI64 %s
+// MIPS64R6EL-GNUABI64: clang
+// MIPS64R6EL-GNUABI64: "-cc1"
+// MIPS64R6EL-GNUABI64: "-target-cpu" "mips64r6"
+// MIPS64R6EL-GNUABI64: "-target-abi" "n64"
+// MIPS64R6EL-GNUABI64: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSN32 %s
 // MIPSN32: clang
 // MIPSN32: "-cc1"
 // MIPSN32: "-target-cpu" "mips64r2"
 // MIPSN32: "-target-abi" "n32"
 // MIPSN32: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32R6 %s
+// MIPSN32R6: clang
+// MIPSN32R6: "-cc1"
+// MIPSN32R6: "-target-cpu" "mips64r6"
+// MIPSN32R6: "-target-abi" "n32"
+// MIPSN32R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSN32EL %s
 // MIPSN32EL: clang
 // MIPSN32EL: "-cc1"
 // MIPSN32EL: "-target-cpu" "mips64r2"
 // MIPSN32EL: "-target-abi" "n32"
 // MIPSN32EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32R6EL %s
+// MIPSN32R6EL: clang
+// MIPSN32R6EL: "-cc1"
+// MIPSN32R6EL: "-target-cpu" "mips64r6"
+// MIPSN32R6EL: "-target-abi" "n32"
+// MIPSN32R6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -5,20 

[PATCH] D50850: clang: Add triples support for MIPS r6

2018-09-01 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 163624.

https://reviews.llvm.org/D50850

Files:
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -291,13 +291,27 @@
 // MIPS: "-target-cpu" "mips32r2"
 // MIPS: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa32r6-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSR6 %s
+// MIPSR6: clang
+// MIPSR6: "-cc1"
+// MIPSR6: "-target-cpu" "mips32r6"
+// MIPSR6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mipsel-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSEL %s
 // MIPSEL: clang
 // MIPSEL: "-cc1"
 // MIPSEL: "-target-cpu" "mips32r2"
 // MIPSEL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa32r6el-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSR6EL %s
+// MIPSR6EL: clang
+// MIPSR6EL: "-cc1"
+// MIPSR6EL: "-target-cpu" "mips32r6"
+// MIPSR6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mipsel-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSEL-ANDROID %s
 // MIPSEL-ANDROID: clang
@@ -323,45 +337,91 @@
 // MIPS64: "-target-cpu" "mips64r2"
 // MIPS64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6 %s
+// MIPS64R6: clang
+// MIPS64R6: "-cc1"
+// MIPS64R6: "-target-cpu" "mips64r6"
+// MIPS64R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL %s
 // MIPS64EL: clang
 // MIPS64EL: "-cc1"
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6EL %s
+// MIPS64R6EL: clang
+// MIPS64R6EL: "-cc1"
+// MIPS64R6EL: "-target-cpu" "mips64r6"
+// MIPS64R6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
 // MIPS64-GNUABI64: clang
 // MIPS64-GNUABI64: "-cc1"
 // MIPS64-GNUABI64: "-target-cpu" "mips64r2"
 // MIPS64-GNUABI64: "-target-abi" "n64"
 // MIPS64-GNUABI64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6-GNUABI64 %s
+// MIPS64R6-GNUABI64: clang
+// MIPS64R6-GNUABI64: "-cc1"
+// MIPS64R6-GNUABI64: "-target-cpu" "mips64r6"
+// MIPS64R6-GNUABI64: "-target-abi" "n64"
+// MIPS64R6-GNUABI64: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
 // MIPS64EL-GNUABI64: clang
 // MIPS64EL-GNUABI64: "-cc1"
 // MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
 // MIPS64EL-GNUABI64: "-target-abi" "n64"
 // MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6EL-GNUABI64 %s
+// MIPS64R6EL-GNUABI64: clang
+// MIPS64R6EL-GNUABI64: "-cc1"
+// MIPS64R6EL-GNUABI64: "-target-cpu" "mips64r6"
+// MIPS64R6EL-GNUABI64: "-target-abi" "n64"
+// MIPS64R6EL-GNUABI64: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSN32 %s
 // MIPSN32: clang
 // MIPSN32: "-cc1"
 // MIPSN32: "-target-cpu" "mips64r2"
 // MIPSN32: "-target-abi" "n32"
 // MIPSN32: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32R6 %s
+// MIPSN32R6: clang
+// MIPSN32R6: "-cc1"
+// MIPSN32R6: "-target-cpu" "mips64r6"
+// MIPSN32R6: "-target-abi" "n32"
+// MIPSN32R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSN32EL %s
 // MIPSN32EL: clang
 // MIPSN32EL: "-cc1"
 // MIPSN32EL: "-target-cpu" "mips64r2"
 // MIPSN32EL: "-target-abi" "n32"
 // MIPSN32EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32R6EL %s
+// MIPSN32R6EL: clang
+// MIPSN32R6EL: "-cc1"
+// MIPSN32R6EL: "-target-cpu" "mips64r6"
+// MIPSN32R6EL: "-target-abi" "n32"
+// MIPSN32R6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -1,13 +1,21 @@
 // RUN: %clang_cc1 

[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-09-01 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 163622.
wzssyqa added a comment.

Remove unused MipsCpu.


Repository:
  rC Clang

https://reviews.llvm.org/D51464

Files:
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -330,6 +330,38 @@
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
+// MIPS64-GNUABI64: clang
+// MIPS64-GNUABI64: "-cc1"
+// MIPS64-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64-GNUABI64: "-target-abi" "n64"
+// MIPS64-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
+// MIPS64EL-GNUABI64: clang
+// MIPS64EL-GNUABI64: "-cc1"
+// MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64EL-GNUABI64: "-target-abi" "n64"
+// MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32 %s
+// MIPSN32: clang
+// MIPSN32: "-cc1"
+// MIPSN32: "-target-cpu" "mips64r2"
+// MIPSN32: "-target-abi" "n32"
+// MIPSN32: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32EL %s
+// MIPSN32EL: clang
+// MIPSN32EL: "-cc1"
+// MIPSN32EL: "-target-cpu" "mips64r2"
+// MIPSN32EL: "-target-abi" "n32"
+// MIPSN32EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -4,6 +4,10 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mipsel-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnuabin32 | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
Index: test/CodeGen/target-data.c
===
--- test/CodeGen/target-data.c
+++ test/CodeGen/target-data.c
@@ -42,18 +42,34 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EL
+// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabin32 -o - -emit-llvm \
+// RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
+// MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EB
+// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s -target-abi n32 \
 // RUN: | FileCheck %s -check-prefix=MIPS-64EB-N32
 // MIPS-64EB-N32: target datalayout = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple 

[PATCH] D51464: clang: fix MIPS/N32 triple and paths

2018-08-29 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa created this revision.
wzssyqa added a reviewer: atanasyan.
Herald added subscribers: cfe-commits, jrtc27, arichardson, sdardis, srhines.

Guess N32 ABI when no abi option is given based on llvm patch.
It now support mips64(el)-linux-gnuabin32 and mipsn32(el).

The include and library paths are also added based on
Debian/Gcc scheme.


Repository:
  rC Clang

https://reviews.llvm.org/D51464

Files:
  lib/Basic/Targets/Mips.h
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -330,6 +330,38 @@
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
+// MIPS64-GNUABI64: clang
+// MIPS64-GNUABI64: "-cc1"
+// MIPS64-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64-GNUABI64: "-target-abi" "n64"
+// MIPS64-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
+// MIPS64EL-GNUABI64: clang
+// MIPS64EL-GNUABI64: "-cc1"
+// MIPS64EL-GNUABI64: "-target-cpu" "mips64r2"
+// MIPS64EL-GNUABI64: "-target-abi" "n64"
+// MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32 %s
+// MIPSN32: clang
+// MIPSN32: "-cc1"
+// MIPSN32: "-target-cpu" "mips64r2"
+// MIPSN32: "-target-abi" "n32"
+// MIPSN32: "-mfloat-abi" "hard"
+
+// RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32EL %s
+// MIPSN32EL: clang
+// MIPSN32EL: "-cc1"
+// MIPSN32EL: "-target-cpu" "mips64r2"
+// MIPSN32EL: "-target-abi" "n32"
+// MIPSN32EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -4,6 +4,10 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mipsel-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnuabi64 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnuabin32 | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnuabin32 | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
Index: test/CodeGen/target-data.c
===
--- test/CodeGen/target-data.c
+++ test/CodeGen/target-data.c
@@ -42,18 +42,34 @@
 // RUN: FileCheck %s -check-prefix=MIPS-64EL
 // MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EL
+// MIPS-64EL: target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -o - -emit-llvm -target-abi n32 \
 // RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
 // MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64el-linux-gnuabin32 -o - -emit-llvm \
+// RUN: %s | FileCheck %s -check-prefix=MIPS-64EL-N32
+// MIPS-64EL-N32: target datalayout = "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: %clang_cc1 -triple mips64-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-64EB
 // MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
 
+// RUN: %clang_cc1 -triple mips64-linux-gnuabi64 -o - -emit-llvm %s | \
+// RUN: FileCheck %s -check-prefix=MIPS-64EB
+// MIPS-64EB: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128"
+
 // RUN: 

[PATCH] D50850: clang: Add triples support for MIPS r6

2018-08-29 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa updated this revision to Diff 163221.

Repository:
  rC Clang

https://reviews.llvm.org/D50850

Files:
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  test/CodeGen/atomics-inlining.c
  test/CodeGen/mips-zero-sized-struct.c
  test/CodeGen/target-data.c
  test/CodeGen/xray-attributes-supported.cpp
  test/Driver/clang-translation.c

Index: test/Driver/clang-translation.c
===
--- test/Driver/clang-translation.c
+++ test/Driver/clang-translation.c
@@ -291,6 +291,13 @@
 // MIPS: "-target-cpu" "mips32r2"
 // MIPS: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa32r6-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSR6 %s
+// MIPSR6: clang
+// MIPSR6: "-cc1"
+// MIPSR6: "-target-cpu" "mips32r6"
+// MIPSR6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mipsel-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSEL %s
 // MIPSEL: clang
@@ -298,6 +305,13 @@
 // MIPSEL: "-target-cpu" "mips32r2"
 // MIPSEL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa32r6el-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSR6EL %s
+// MIPSR6EL: clang
+// MIPSR6EL: "-cc1"
+// MIPSR6EL: "-target-cpu" "mips32r6"
+// MIPSR6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mipsel-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSEL-ANDROID %s
 // MIPSEL-ANDROID: clang
@@ -323,6 +337,13 @@
 // MIPS64: "-target-cpu" "mips64r2"
 // MIPS64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6 %s
+// MIPS64R6: clang
+// MIPS64R6: "-cc1"
+// MIPS64R6: "-target-cpu" "mips64r6"
+// MIPS64R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnu -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL %s
 // MIPS64EL: clang
@@ -330,6 +351,13 @@
 // MIPS64EL: "-target-cpu" "mips64r2"
 // MIPS64EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnu -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6EL %s
+// MIPS64R6EL: clang
+// MIPS64R6EL: "-cc1"
+// MIPS64R6EL: "-target-cpu" "mips64r6"
+// MIPS64R6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnuabi64 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64-GNUABI64 %s
 // MIPS64-GNUABI64: clang
@@ -338,6 +366,14 @@
 // MIPS64-GNUABI64: "-target-abi" "n64"
 // MIPS64-GNUABI64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6-GNUABI64 %s
+// MIPS64R6-GNUABI64: clang
+// MIPS64R6-GNUABI64: "-cc1"
+// MIPS64R6-GNUABI64: "-target-cpu" "mips64r6"
+// MIPS64R6-GNUABI64: "-target-abi" "n64"
+// MIPS64R6-GNUABI64: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnuabi64 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-GNUABI64 %s
 // MIPS64EL-GNUABI64: clang
@@ -346,6 +382,14 @@
 // MIPS64EL-GNUABI64: "-target-abi" "n64"
 // MIPS64EL-GNUABI64: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnuabi64 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPS64R6EL-GNUABI64 %s
+// MIPS64R6EL-GNUABI64: clang
+// MIPS64R6EL-GNUABI64: "-cc1"
+// MIPS64R6EL-GNUABI64: "-target-cpu" "mips64r6"
+// MIPS64R6EL-GNUABI64: "-target-abi" "n64"
+// MIPS64R6EL-GNUABI64: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64-linux-gnuabin32 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSN32 %s
 // MIPSN32: clang
@@ -354,6 +398,14 @@
 // MIPSN32: "-target-abi" "n32"
 // MIPSN32: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32R6 %s
+// MIPSN32R6: clang
+// MIPSN32R6: "-cc1"
+// MIPSN32R6: "-target-cpu" "mips64r6"
+// MIPSN32R6: "-target-abi" "n32"
+// MIPSN32R6: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-gnuabin32 -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPSN32EL %s
 // MIPSN32EL: clang
@@ -362,6 +414,14 @@
 // MIPSN32EL: "-target-abi" "n32"
 // MIPSN32EL: "-mfloat-abi" "hard"
 
+// RUN: %clang -target mipsisa64r6el-linux-gnuabin32 -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=MIPSN32R6EL %s
+// MIPSN32R6EL: clang
+// MIPSN32R6EL: "-cc1"
+// MIPSN32R6EL: "-target-cpu" "mips64r6"
+// MIPSN32R6EL: "-target-abi" "n32"
+// MIPSN32R6EL: "-mfloat-abi" "hard"
+
 // RUN: %clang -target mips64el-linux-android -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=MIPS64EL-ANDROID %s
 // MIPS64EL-ANDROID: clang
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- test/CodeGen/xray-attributes-supported.cpp
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -1,13 +1,21 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ 

[PATCH] D50850: Add triples support for MIPS r6

2018-08-16 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa created this revision.
wzssyqa added reviewers: rsmith, atanasyan.
Herald added subscribers: cfe-commits, jrtc27, arichardson, sdardis, srhines.

Debian uses different triples for MIPS r6 and paths.

These new triples include:

mipsisa32r6-linux-gnu
mipsisa32r6el-linux-gnu
mipsisa64r6-linux-gnuabi64
mipsisa64r6el-linux-gnuabi64
mipsisa64r6-linux-gnuabin32
mipsisa64r6el-linux-gnuabin32


Repository:
  rC Clang

https://reviews.llvm.org/D50850

Files:
  lib/Driver/ToolChains/Arch/Mips.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp

Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -43,7 +43,11 @@
   StringRef SysRoot) {
   llvm::Triple::EnvironmentType TargetEnvironment =
   TargetTriple.getEnvironment();
+  llvm::Triple::SubArchType TargetSubArch = TargetTriple.getSubArch();
   bool IsAndroid = TargetTriple.isAndroid();
+  std::string MipsCpu = "", Mips64Abi = "gnuabi64";
+  if (TargetEnvironment == llvm::Triple::GNUABIN32)
+Mips64Abi = "gnuabin32";
 
   // For most architectures, just use whatever we have rather than trying to be
   // clever.
@@ -102,28 +106,37 @@
   return "aarch64_be-linux-gnu";
 break;
   case llvm::Triple::mips:
-if (D.getVFS().exists(SysRoot + "/lib/mips-linux-gnu"))
-  return "mips-linux-gnu";
+MipsCpu =
+(TargetSubArch == llvm::Triple::MipsSubArch_r6) ? "mipsisa32"
+	: "mips";
+if (D.getVFS().exists(SysRoot + "/lib/" + MipsCpu + "-linux-gnu"))
+  return MipsCpu + "-linux-gnu";
 break;
   case llvm::Triple::mipsel:
 if (IsAndroid)
   return "mipsel-linux-android";
-if (D.getVFS().exists(SysRoot + "/lib/mipsel-linux-gnu"))
-  return "mipsel-linux-gnu";
+MipsCpu = (TargetSubArch == llvm::Triple::MipsSubArch_r6) ? "mipsisa32el"
+  : "mipsel";
+if (D.getVFS().exists(SysRoot + "/lib/" + MipsCpu + "-linux-gnu"))
+  return MipsCpu + "-linux-gnu";
 break;
   case llvm::Triple::mips64:
 if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnu"))
   return "mips64-linux-gnu";
-if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnuabi64"))
-  return "mips64-linux-gnuabi64";
+MipsCpu = (TargetSubArch == llvm::Triple::MipsSubArch_r6) ? "mipsisa64"
+  : "mips64";
+if (D.getVFS().exists(SysRoot + "/lib/" + MipsCpu + "-linux-" + Mips64Abi))
+  return MipsCpu + "-linux-" + Mips64Abi;
 break;
   case llvm::Triple::mips64el:
 if (IsAndroid)
   return "mips64el-linux-android";
 if (D.getVFS().exists(SysRoot + "/lib/mips64el-linux-gnu"))
   return "mips64el-linux-gnu";
-if (D.getVFS().exists(SysRoot + "/lib/mips64el-linux-gnuabi64"))
-  return "mips64el-linux-gnuabi64";
+MipsCpu = (TargetSubArch == llvm::Triple::MipsSubArch_r6) ? "mipsisa64el"
+  : "mips64el";
+if (D.getVFS().exists(SysRoot + "/lib/" + MipsCpu + "-linux-" + Mips64Abi))
+  return MipsCpu + "-linux-" + Mips64Abi;
 break;
   case llvm::Triple::ppc:
 if (D.getVFS().exists(SysRoot + "/lib/powerpc-linux-gnuspe"))
@@ -699,6 +712,24 @@
   const StringRef MIPS64ELMultiarchIncludeDirs[] = {
   "/usr/include/mips64el-linux-gnu",
   "/usr/include/mips64el-linux-gnuabi64"};
+  const StringRef MIPSN32MultiarchIncludeDirs[] = {
+  "/usr/include/mips64-linux-gnuabin32"};
+  const StringRef MIPSN32ELMultiarchIncludeDirs[] = {
+  "/usr/include/mips64el-linux-gnuabin32"};
+  const StringRef MIPSR6MultiarchIncludeDirs[] = {
+  "/usr/include/mipsisa32-linux-gnu"};
+  const StringRef MIPSR6ELMultiarchIncludeDirs[] = {
+  "/usr/include/mipsisa32r6el-linux-gnu"};
+  const StringRef MIPS64R6MultiarchIncludeDirs[] = {
+  "/usr/include/mipsisa64r6-linux-gnu",
+  "/usr/include/mipsisa64r6-linux-gnuabi64"};
+  const StringRef MIPS64R6ELMultiarchIncludeDirs[] = {
+  "/usr/include/mipsisa64r6el-linux-gnu",
+  "/usr/include/mipsisa64r6el-linux-gnuabi64"};
+  const StringRef MIPSN32R6MultiarchIncludeDirs[] = {
+  "/usr/include/mipsisa64r6-linux-gnuabin32"};
+  const StringRef MIPSN32R6ELMultiarchIncludeDirs[] = {
+  "/usr/include/mipsisa64r6el-linux-gnuabin32"};
   const StringRef PPCMultiarchIncludeDirs[] = {
   "/usr/include/powerpc-linux-gnu"};
   const StringRef PPC64MultiarchIncludeDirs[] = {
@@ -738,16 +769,38 @@
   MultiarchIncludeDirs = ARMEBMultiarchIncludeDirs;
 break;
   case llvm::Triple::mips:
-MultiarchIncludeDirs = MIPSMultiarchIncludeDirs;
+if (getTriple().getSubArch() == llvm::Triple::MipsSubArch_r6)
+  MultiarchIncludeDirs = MIPSR6MultiarchIncludeDirs;
+else
+  MultiarchIncludeDirs =