[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-07-05 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

> @wzssyqa Is it OK with you if I go ahead and merge this PR? I plan to follow 
> up with further improvements but this is necessary to fix the build of LLVM 
> runtime libraries in the bootstrapping build.

It is OK for me, while I have no permission to approve such a patch.

https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-07-05 Thread YunQiang Su via cfe-commits


@@ -183,6 +183,24 @@ message(STATUS "LLVM default target triple: 
${LLVM_DEFAULT_TARGET_TRIPLE}")
 
 set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
 
+if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+  set(option_prefix "")
+  if (CMAKE_C_SIMULATE_ID MATCHES "MSVC")
+set(option_prefix "/clang:")
+  endif()
+  set(print_target_triple ${CMAKE_C_COMPILER} 
${option_prefix}--target=${LLVM_DEFAULT_TARGET_TRIPLE} 
${option_prefix}-print-target-triple)
+  execute_process(COMMAND ${print_target_triple}
+RESULT_VARIABLE result
+OUTPUT_VARIABLE output
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+  if(result EQUAL 0)
+set(LLVM_DEFAULT_TARGET_TRIPLE ${output})
+  else()
+string(REPLACE ";" " " print_target_triple "${print_target_triple}")

wzssyqa wrote:

Since most of the CIs monitor the commit only. I have no idea how to trigger 
them before commit.

https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-07-05 Thread YunQiang Su via cfe-commits


@@ -368,14 +368,22 @@ macro(construct_compiler_rt_default_triple)
   "Default triple for which compiler-rt runtimes will be built.")
   endif()
 
-  if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
+  if(CMAKE_C_COMPILER_ID MATCHES "Clang")
 set(option_prefix "")
 if (CMAKE_C_SIMULATE_ID MATCHES "MSVC")
   set(option_prefix "/clang:")
 endif()
-execute_process(COMMAND ${CMAKE_C_COMPILER} 
${option_prefix}--target=${COMPILER_RT_DEFAULT_TARGET_TRIPLE} 
${option_prefix}-print-target-triple
-OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE
-OUTPUT_STRIP_TRAILING_WHITESPACE)
+set(print_target_triple ${CMAKE_C_COMPILER} 
${option_prefix}--target=${COMPILER_RT_DEFAULT_TARGET_TRIPLE} 
${option_prefix}-print-target-triple)
+execute_process(COMMAND ${print_target_triple}
+  RESULT_VARIABLE result
+  OUTPUT_VARIABLE output
+  OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(result EQUAL 0)
+  set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${output})
+else()
+  string(REPLACE ";" " " print_target_triple "${print_target_triple}")
+  message(WARNING "Failed to execute `${print_target_triple}` to normalize 
target triple.")

wzssyqa wrote:

Maybe you are right.  I tested with some quite bad --target values, it will 
output the original values.
So, I think that it will be safe.  Anyway, a warning is OK for me as I think 
that it won't be used at all. 

https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)

2024-06-26 Thread YunQiang Su via cfe-commits


@@ -3636,6 +3648,22 @@ def Fmin : FPMathTemplate, LibBuiltin<"math.h"> {
   let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
 }
 
+def FmaximumNum : FPMathTemplate, LibBuiltin<"math.h"> {

wzssyqa wrote:

Yes. They are in C23: https://libc.llvm.org/c23.html

https://github.com/llvm/llvm-project/pull/96281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)

2024-06-25 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/96281

>From 1f357abed9d9e304b12ddd05a525557a8b0082c6 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Fri, 21 Jun 2024 14:28:42 +0800
Subject: [PATCH 1/2] Clang: Support minimumnum and maximumnum intrinsics

We just introduce llvm.minimumnum and llvm.maximumnum intrinsics
support to llvm. Let's support them in Clang.

See: #93033
---
 clang/include/clang/Basic/Builtins.td | 28 +++
 clang/lib/CodeGen/CGBuiltin.cpp   | 24 
 .../Tooling/Inclusions/Stdlib/CSymbolMap.inc  |  6 
 .../Inclusions/Stdlib/StdSymbolMap.inc| 18 
 clang/test/CodeGen/builtins.c | 18 
 clang/test/CodeGen/math-libcalls.c| 25 +
 6 files changed, 119 insertions(+)

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index f5b15cf90d1f8..f0b0521464f97 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -215,6 +215,18 @@ def FminF16F128 : Builtin, F16F128MathTemplate {
   let Prototype = "T(T, T)";
 }
 
+def FmaximumNumF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_fmaximum_num"];
+  let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
+  let Prototype = "T(T, T)";
+}
+
+def FminimumNumF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_fminimum_num"];
+  let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
+  let Prototype = "T(T, T)";
+}
+
 def Atan2F128 : Builtin {
   let Spellings = ["__builtin_atan2f128"];
   let Attributes = [FunctionWithBuiltinPrefix, NoThrow, 
ConstIgnoringErrnoAndExceptions];
@@ -3678,6 +3690,22 @@ def Fmin : FPMathTemplate, LibBuiltin<"math.h"> {
   let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
 }
 
+def FmaximumNum : FPMathTemplate, LibBuiltin<"math.h"> {
+  let Spellings = ["fmaximum_num"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "T(T, T)";
+  let AddBuiltinPrefixedAlias = 1;
+  let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
+}
+
+def FminimumNum : FPMathTemplate, LibBuiltin<"math.h"> {
+  let Spellings = ["fminimum_num"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "T(T, T)";
+  let AddBuiltinPrefixedAlias = 1;
+  let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
+}
+
 def Hypot : FPMathTemplate, LibBuiltin<"math.h"> {
   let Spellings = ["hypot"];
   let Attributes = [NoThrow, ConstIgnoringErrnoAndExceptions];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 4edd8283aa03c..32f5d36067edf 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2767,6 +2767,30 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
Intrinsic::minnum,

Intrinsic::experimental_constrained_minnum));
 
+case Builtin::BIfmaximum_num:
+case Builtin::BIfmaximum_numf:
+case Builtin::BIfmaximum_numl:
+case Builtin::BI__builtin_fmaximum_num:
+case Builtin::BI__builtin_fmaximum_numf:
+case Builtin::BI__builtin_fmaximum_numf16:
+case Builtin::BI__builtin_fmaximum_numl:
+case Builtin::BI__builtin_fmaximum_numf128:
+  return RValue::get(emitBinaryMaybeConstrainedFPBuiltin(
+  *this, E, Intrinsic::maximumnum,
+  Intrinsic::experimental_constrained_maximumnum));
+
+case Builtin::BIfminimum_num:
+case Builtin::BIfminimum_numf:
+case Builtin::BIfminimum_numl:
+case Builtin::BI__builtin_fminimum_num:
+case Builtin::BI__builtin_fminimum_numf:
+case Builtin::BI__builtin_fminimum_numf16:
+case Builtin::BI__builtin_fminimum_numl:
+case Builtin::BI__builtin_fminimum_numf128:
+  return RValue::get(emitBinaryMaybeConstrainedFPBuiltin(
+  *this, E, Intrinsic::minimumnum,
+  Intrinsic::experimental_constrained_minimumnum));
+
 // fmod() is a special-case. It maps to the frem instruction rather than an
 // LLVM intrinsic.
 case Builtin::BIfmod:
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
index 463ce921f0672..af2dcb632fbb6 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
@@ -475,6 +475,12 @@ SYMBOL(fmaxl, None, )
 SYMBOL(fmin, None, )
 SYMBOL(fminf, None, )
 SYMBOL(fminl, None, )
+SYMBOL(fmaximum_num, None, )
+SYMBOL(fmaximum_numf, None, )
+SYMBOL(fmaximum_numfl, None, )
+SYMBOL(fminimum_num, None, )
+SYMBOL(fminimum_numf, None, )
+SYMBOL(fminimum_numl, None, )
 SYMBOL(fmod, None, )
 SYMBOL(fmodf, None, )
 SYMBOL(fmodl, None, )
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
index b46bd2e4d7a4b..442316ce8d4ff 100644
--- 

[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-06-25 Thread YunQiang Su via cfe-commits


@@ -368,14 +368,22 @@ macro(construct_compiler_rt_default_triple)
   "Default triple for which compiler-rt runtimes will be built.")
   endif()
 
-  if ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
+  if(CMAKE_C_COMPILER_ID MATCHES "Clang")
 set(option_prefix "")
 if (CMAKE_C_SIMULATE_ID MATCHES "MSVC")
   set(option_prefix "/clang:")
 endif()
-execute_process(COMMAND ${CMAKE_C_COMPILER} 
${option_prefix}--target=${COMPILER_RT_DEFAULT_TARGET_TRIPLE} 
${option_prefix}-print-target-triple
-OUTPUT_VARIABLE COMPILER_RT_DEFAULT_TARGET_TRIPLE
-OUTPUT_STRIP_TRAILING_WHITESPACE)
+set(print_target_triple ${CMAKE_C_COMPILER} 
${option_prefix}--target=${COMPILER_RT_DEFAULT_TARGET_TRIPLE} 
${option_prefix}-print-target-triple)
+execute_process(COMMAND ${print_target_triple}
+  RESULT_VARIABLE result
+  OUTPUT_VARIABLE output
+  OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(result EQUAL 0)
+  set(COMPILER_RT_DEFAULT_TARGET_TRIPLE ${output})
+else()
+  string(REPLACE ";" " " print_target_triple "${print_target_triple}")
+  message(WARNING "Failed to execute `${print_target_triple}` to normalize 
target triple.")

wzssyqa wrote:

I think that it should be a fetal error instead of just a warning?

https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-06-25 Thread YunQiang Su via cfe-commits


@@ -183,6 +183,24 @@ message(STATUS "LLVM default target triple: 
${LLVM_DEFAULT_TARGET_TRIPLE}")
 
 set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
 
+if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+  set(option_prefix "")
+  if (CMAKE_C_SIMULATE_ID MATCHES "MSVC")
+set(option_prefix "/clang:")
+  endif()
+  set(print_target_triple ${CMAKE_C_COMPILER} 
${option_prefix}--target=${LLVM_DEFAULT_TARGET_TRIPLE} 
${option_prefix}-print-target-triple)
+  execute_process(COMMAND ${print_target_triple}
+RESULT_VARIABLE result
+OUTPUT_VARIABLE output
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+  if(result EQUAL 0)
+set(LLVM_DEFAULT_TARGET_TRIPLE ${output})
+  else()
+string(REPLACE ";" " " print_target_triple "${print_target_triple}")

wzssyqa wrote:

Ditto.  I guess that we need to test on more target. As some target doesn't use 
the new filesystem struct.

https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)

2024-06-21 Thread YunQiang Su via cfe-commits


@@ -3636,6 +3648,22 @@ def Fmin : FPMathTemplate, LibBuiltin<"math.h"> {
   let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
 }
 
+def FmaximumNum : FPMathTemplate, LibBuiltin<"math.h"> {

wzssyqa wrote:

Oh, newer libc does have this function: 
https://www.gnu.org/software/libc/manual/html_node/Misc-FP-Arithmetic.html

https://github.com/llvm/llvm-project/pull/96281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-06-21 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

@nikic Thanks. I submit an RFC now
https://discourse.llvm.org/t/rfc-fix-llvm-min-f-and-llvm-max-f-intrinsics/79735

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-06-21 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

@nikic thanks. Please also revert 
https://github.com/llvm/llvm-project/commit/225d8fc8eb24fb797154c1ef6dcbe5ba033142da

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Clang: Support minimumnum and maximumnum intrinsics (PR #96281)

2024-06-21 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa created 
https://github.com/llvm/llvm-project/pull/96281

We just introduce llvm.minimumnum and llvm.maximumnum intrinsics support to 
llvm. Let's support them in Clang.

See: #93033

>From 5605426ee61ec58cad701103a43922b67792ccaf Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Fri, 21 Jun 2024 14:28:42 +0800
Subject: [PATCH] Clang: Support minimumnum and maximumnum intrinsics

We just introduce llvm.minimumnum and llvm.maximumnum intrinsics
support to llvm. Let's support them in Clang.

See: #93033
---
 clang/include/clang/Basic/Builtins.td | 28 +++
 clang/lib/CodeGen/CGBuiltin.cpp   | 24 
 .../Tooling/Inclusions/Stdlib/CSymbolMap.inc  |  6 
 .../Inclusions/Stdlib/StdSymbolMap.inc| 18 
 clang/test/CodeGen/builtins.c | 18 
 clang/test/CodeGen/math-libcalls.c| 25 +
 6 files changed, 119 insertions(+)

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 9342b6bc75fc8..d8093a7772b65 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -215,6 +215,18 @@ def FminF16F128 : Builtin, F16F128MathTemplate {
   let Prototype = "T(T, T)";
 }
 
+def FmaximumNumF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_fmaximum_num"];
+  let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
+  let Prototype = "T(T, T)";
+}
+
+def FminimumNumF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_fminimum_num"];
+  let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
+  let Prototype = "T(T, T)";
+}
+
 def Atan2F128 : Builtin {
   let Spellings = ["__builtin_atan2f128"];
   let Attributes = [FunctionWithBuiltinPrefix, NoThrow, 
ConstIgnoringErrnoAndExceptions];
@@ -3636,6 +3648,22 @@ def Fmin : FPMathTemplate, LibBuiltin<"math.h"> {
   let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
 }
 
+def FmaximumNum : FPMathTemplate, LibBuiltin<"math.h"> {
+  let Spellings = ["fmaximum_num"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "T(T, T)";
+  let AddBuiltinPrefixedAlias = 1;
+  let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
+}
+
+def FminimumNum : FPMathTemplate, LibBuiltin<"math.h"> {
+  let Spellings = ["fminimum_num"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "T(T, T)";
+  let AddBuiltinPrefixedAlias = 1;
+  let OnlyBuiltinPrefixedAliasIsConstexpr = 1;
+}
+
 def Hypot : FPMathTemplate, LibBuiltin<"math.h"> {
   let Spellings = ["hypot"];
   let Attributes = [NoThrow, ConstIgnoringErrnoAndExceptions];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 2516ed4508242..a9f2245305ec2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2794,6 +2794,30 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
Intrinsic::minnum,

Intrinsic::experimental_constrained_minnum));
 
+case Builtin::BIfmaximum_num:
+case Builtin::BIfmaximum_numf:
+case Builtin::BIfmaximum_numl:
+case Builtin::BI__builtin_fmaximum_num:
+case Builtin::BI__builtin_fmaximum_numf:
+case Builtin::BI__builtin_fmaximum_numf16:
+case Builtin::BI__builtin_fmaximum_numl:
+case Builtin::BI__builtin_fmaximum_numf128:
+  return RValue::get(emitBinaryMaybeConstrainedFPBuiltin(
+  *this, E, Intrinsic::maximumnum,
+  Intrinsic::experimental_constrained_maximumnum));
+
+case Builtin::BIfminimum_num:
+case Builtin::BIfminimum_numf:
+case Builtin::BIfminimum_numl:
+case Builtin::BI__builtin_fminimum_num:
+case Builtin::BI__builtin_fminimum_numf:
+case Builtin::BI__builtin_fminimum_numf16:
+case Builtin::BI__builtin_fminimum_numl:
+case Builtin::BI__builtin_fminimum_numf128:
+  return RValue::get(emitBinaryMaybeConstrainedFPBuiltin(
+  *this, E, Intrinsic::minimumnum,
+  Intrinsic::experimental_constrained_minimumnum));
+
 // fmod() is a special-case. It maps to the frem instruction rather than an
 // LLVM intrinsic.
 case Builtin::BIfmod:
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
index 463ce921f0672..af2dcb632fbb6 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc
@@ -475,6 +475,12 @@ SYMBOL(fmaxl, None, )
 SYMBOL(fmin, None, )
 SYMBOL(fminf, None, )
 SYMBOL(fminl, None, )
+SYMBOL(fmaximum_num, None, )
+SYMBOL(fmaximum_numf, None, )
+SYMBOL(fmaximum_numfl, None, )
+SYMBOL(fminimum_num, None, )
+SYMBOL(fminimum_numf, None, )
+SYMBOL(fminimum_numl, None, )
 SYMBOL(fmod, None, )
 SYMBOL(fmodf, None, )
 SYMBOL(fmodl, None, )
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc 

[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-06-20 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa closed 
https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-06-11 Thread YunQiang Su via cfe-commits


@@ -15868,6 +15868,51 @@ The returned value is completely identical to the 
input except for the sign bit;
 in particular, if the input is a NaN, then the quiet/signaling bit and payload
 are perfectly preserved.
 
+.. _i_fminmax_family:
+
+'``llvm.min.*``' Intrinsics Comparation
+^^^
+
+.. list-table::
+   :header-rows: 1
+   :widths: 16 28 28 28
+
+   * - Operation
+ - minnum/maxnum
+ - minimum/maximum
+ - minimumnum/maximumnum
+
+   * - ``NUM vs qNaN``
+ - NUM, no exception
+ - qNaN, no exception
+ - qNaN, no exception
+
+   * - ``NUM vs sNaN``
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+ - NUM, invalid exception
+
+   * - ``qNaN vs sNaN``
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+
+   * - ``sNaN vs sNaN``
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+
+   * - ``+0.0 vs -0.0``
+ - either one
+ - +0.0(max)/-0.0(min)
+ - +0.0(max)/-0.0(min)
+
+   * - ``NUM vs NUM``
+ - larger(max)/smaller(min)
+ - larger(max)/smaller(min)
+ - larger(max)/smaller(min)

wzssyqa wrote:

For constrained ones, I guess that we should add more details in another PR(s).

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-06-11 Thread YunQiang Su via cfe-commits


@@ -15868,6 +15868,51 @@ The returned value is completely identical to the 
input except for the sign bit;
 in particular, if the input is a NaN, then the quiet/signaling bit and payload
 are perfectly preserved.
 
+.. _i_fminmax_family:
+
+'``llvm.min.*``' Intrinsics Comparation
+^^^
+
+.. list-table::
+   :header-rows: 1
+   :widths: 16 28 28 28
+
+   * - Operation
+ - minnum/maxnum
+ - minimum/maximum
+ - minimumnum/maximumnum
+
+   * - ``NUM vs qNaN``
+ - NUM, no exception
+ - qNaN, no exception
+ - qNaN, no exception
+
+   * - ``NUM vs sNaN``
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+ - NUM, invalid exception
+
+   * - ``qNaN vs sNaN``
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+
+   * - ``sNaN vs sNaN``
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+
+   * - ``+0.0 vs -0.0``
+ - either one
+ - +0.0(max)/-0.0(min)
+ - +0.0(max)/-0.0(min)
+
+   * - ``NUM vs NUM``
+ - larger(max)/smaller(min)
+ - larger(max)/smaller(min)
+ - larger(max)/smaller(min)

wzssyqa wrote:

Sorry, I guess that I am not full understanding "LLVM's NaN-handling policy".
As my understanding, for fmax*, we should fellow the libc's semantics. 

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-06-11 Thread YunQiang Su via cfe-commits


@@ -15883,6 +15883,95 @@ The returned value is completely identical to the 
input except for the sign bit;
 in particular, if the input is a NaN, then the quiet/signaling bit and payload
 are perfectly preserved.
 
+.. _i_fminmax_family:
+
+'``llvm.min.*``' Intrinsics Comparation
+^^^
+
+Standard:
+"
+
+IEEE754 and ISO C define some min/max operations, and they have some 
differences
+on working with qNaN/sNaN and +0.0/-0.0. Here is the list:
+
+.. list-table::
+   :header-rows: 2
+
+   * - ``ISO C``
+ - fmin/fmax
+ - none
+ - fmininum/fmaximum
+ - fminimum_num/fmaximum_num
+
+   * - ``IEEE754``
+ - none
+ - nimNUM/maxNUM (2008)
+ - minimum/maximum (2019)
+ - minimumNumber/maximumNumber (2019)
+
+   * - ``+0.0 vs -0.0``
+ - either one
+ - +0.0 > -0.0
+ - +0.0 > -0.0
+ - +0.0 > -0.0
+
+   * - ``NUM/qNaN vs sNaN``
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+ - NUM/qNaN, invalid exception
+
+   * - ``NUM/qNaN vs qNaN``
+ - NUM/qNaN, no excpetion

wzssyqa wrote:

For more details about sNaN on constrained intrinsics, we may need to update 
them in future PRs.
Since this PR is only about add `minimumnum and maximumnum`.

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-06-11 Thread YunQiang Su via cfe-commits


@@ -15883,6 +15883,95 @@ The returned value is completely identical to the 
input except for the sign bit;
 in particular, if the input is a NaN, then the quiet/signaling bit and payload
 are perfectly preserved.
 
+.. _i_fminmax_family:
+
+'``llvm.min.*``' Intrinsics Comparation
+^^^
+
+Standard:
+"
+
+IEEE754 and ISO C define some min/max operations, and they have some 
differences
+on working with qNaN/sNaN and +0.0/-0.0. Here is the list:
+
+.. list-table::
+   :header-rows: 2
+
+   * - ``ISO C``
+ - fmin/fmax
+ - none
+ - fmininum/fmaximum
+ - fminimum_num/fmaximum_num
+
+   * - ``IEEE754``
+ - none
+ - nimNUM/maxNUM (2008)
+ - minimum/maximum (2019)
+ - minimumNumber/maximumNumber (2019)
+
+   * - ``+0.0 vs -0.0``
+ - either one
+ - +0.0 > -0.0
+ - +0.0 > -0.0
+ - +0.0 > -0.0
+
+   * - ``NUM/qNaN vs sNaN``
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+ - qNaN, invalid exception
+ - NUM/qNaN, invalid exception
+
+   * - ``NUM/qNaN vs qNaN``
+ - NUM/qNaN, no excpetion

wzssyqa wrote:

And I split it to `NUM vs qNaN` and `qNaN vs qNaN`.


https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-06-11 Thread YunQiang Su via cfe-commits


@@ -15883,6 +15883,95 @@ The returned value is completely identical to the 
input except for the sign bit;
 in particular, if the input is a NaN, then the quiet/signaling bit and payload
 are perfectly preserved.
 
+.. _i_fminmax_family:
+
+'``llvm.min.*``' Intrinsics Comparation
+^^^
+
+Standard:
+"
+
+IEEE754 and ISO C define some min/max operations, and they have some 
differences
+on working with qNaN/sNaN and +0.0/-0.0. Here is the list:
+
+.. list-table::
+   :header-rows: 2
+
+   * - ``ISO C``
+ - fmin/fmax
+ - none
+ - fmininum/fmaximum
+ - fminimum_num/fmaximum_num
+
+   * - ``IEEE754``
+ - none
+ - nimNUM/maxNUM (2008)
+ - minimum/maximum (2019)
+ - minimumNumber/maximumNumber (2019)
+
+   * - ``+0.0 vs -0.0``
+ - either one
+ - +0.0 > -0.0

wzssyqa wrote:

Thanks. You are right.  I was confused by the hardware implementations of some 
hardware.
ARM/MIPSr6/PowerPC implement +0.0>-0.0.

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-06-10 Thread YunQiang Su via cfe-commits


@@ -16055,6 +16145,90 @@ of the two arguments. -0.0 is considered to be less 
than +0.0 for this
 intrinsic. Note that these are the semantics specified in the draft of
 IEEE 754-2019.
 
+.. _i_minimumnum:
+
+'``llvm.minimumnum.*``' Intrinsic
+^
+
+Syntax:
+"""
+
+This is an overloaded intrinsic. You can use ``llvm.minimumnum`` on any
+floating-point or vector of floating-point type. Not all targets support
+all types however.
+
+::
+
+  declare float @llvm.minimumnum.f32(float %Val0, float %Val1)
+  declare double@llvm.minimumnum.f64(double %Val0, double %Val1)
+  declare x86_fp80  @llvm.minimumnum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
+  declare fp128 @llvm.minimumnum.f128(fp128 %Val0, fp128 %Val1)
+  declare ppc_fp128 @llvm.minimumnum.ppcf128(ppc_fp128 %Val0, ppc_fp128 
%Val1)
+
+Overview:
+"
+
+The '``llvm.minimumnum.*``' intrinsics return the minimum of the two
+arguments, not propagating NaNs and treating -0.0 as less than +0.0.
+
+
+Arguments:
+""
+
+The arguments and return value are floating-point numbers of the same
+type.
+
+Semantics:
+""
+If both operands are NaNs (including sNaN), returns qNaN. If one operand
+is NaN (including sNaN) and another operand is a number, return the number.
+Otherwise returns the lesser of the two arguments. -0.0 is considered to
+be less than +0.0 for this intrinsic.
+
+Note that these are the semantics of minimumNumber specified in IEEE 754-2019.

wzssyqa wrote:

No. minimumNumber returns NaN only when both are NaN.

```
minimumNumber(x, y) is x if x < y, y if y < x, and the number if one operand is 
a number and the
other is a NaN. For this operation, −0 compares less than +0. If x = y and 
signs are the same it is
either x or y. If both operands are NaNs, a quiet NaN is returned, according to 
6.2. If either
operand is a signaling NaN, an invalid operation exception is signaled, but 
unless both operands
are NaNs, the signaling NaN is otherwise ignored and not converted to a quiet 
NaN as stated in
6.2 for other operations.
```

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-06-01 Thread YunQiang Su via cfe-commits


@@ -32,27 +32,29 @@ class StoreInst;
 
 /// These are the kinds of recurrences that we support.
 enum class RecurKind {
-  None, ///< Not a recurrence.
-  Add,  ///< Sum of integers.
-  Mul,  ///< Product of integers.
-  Or,   ///< Bitwise or logical OR of integers.
-  And,  ///< Bitwise or logical AND of integers.
-  Xor,  ///< Bitwise or logical XOR of integers.
-  SMin, ///< Signed integer min implemented in terms of select(cmp()).
-  SMax, ///< Signed integer max implemented in terms of select(cmp()).
-  UMin, ///< Unsigned integer min implemented in terms of select(cmp()).
-  UMax, ///< Unsigned integer max implemented in terms of select(cmp()).
-  FAdd, ///< Sum of floats.
-  FMul, ///< Product of floats.
-  FMin, ///< FP min implemented in terms of select(cmp()).
-  FMax, ///< FP max implemented in terms of select(cmp()).
-  FMinimum, ///< FP min with llvm.minimum semantics
-  FMaximum, ///< FP max with llvm.maximum semantics
-  FMulAdd,  ///< Sum of float products with llvm.fmuladd(a * b + sum).
-  IAnyOf,   ///< Any_of reduction with select(icmp(),x,y) where one of (x,y) is
-///< loop invariant, and both x and y are integer type.
-  FAnyOf///< Any_of reduction with select(fcmp(),x,y) where one of (x,y) is
-///< loop invariant, and both x and y are integer type.
+  None,///< Not a recurrence.
+  Add, ///< Sum of integers.
+  Mul, ///< Product of integers.
+  Or,  ///< Bitwise or logical OR of integers.
+  And, ///< Bitwise or logical AND of integers.
+  Xor, ///< Bitwise or logical XOR of integers.
+  SMin,///< Signed integer min implemented in terms of select(cmp()).
+  SMax,///< Signed integer max implemented in terms of select(cmp()).
+  UMin,///< Unsigned integer min implemented in terms of select(cmp()).
+  UMax,///< Unsigned integer max implemented in terms of select(cmp()).
+  FAdd,///< Sum of floats.
+  FMul,///< Product of floats.
+  FMin,///< FP min implemented in terms of select(cmp()).
+  FMax,///< FP max implemented in terms of select(cmp()).
+  FMinimum,///< FP min with llvm.minimum semantics
+  FMaximum,///< FP max with llvm.maximum semantics
+  FMinimumnum, ///< FP min with llvm.minimumnum semantics
+  FMaximumnum, ///< FP max with llvm.maximumnum semantics

wzssyqa wrote:

Removed from this PR, and add them into TODOs.

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-31 Thread YunQiang Su via cfe-commits


@@ -9130,6 +9142,15 @@ void SelectionDAGBuilder::visitCall(const CallInst ) {
 if (visitBinaryFloatCall(I, ISD::FMAXNUM))
   return;
 break;
+  case LibFunc_fminimum_num:
+  case LibFunc_fminimum_numf:
+if (visitBinaryFloatCall(I, ISD::FMINIMUMNUM))
+  return;
+break;
+  case LibFunc_fmaximum_num:

wzssyqa wrote:

If need, I think that we need to a new patch, since neither other  libcalls 
have them.

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-31 Thread YunQiang Su via cfe-commits


@@ -9130,6 +9142,15 @@ void SelectionDAGBuilder::visitCall(const CallInst ) {
 if (visitBinaryFloatCall(I, ISD::FMAXNUM))
   return;
 break;
+  case LibFunc_fminimum_num:
+  case LibFunc_fminimum_numf:
+if (visitBinaryFloatCall(I, ISD::FMINIMUMNUM))
+  return;
+break;
+  case LibFunc_fmaximum_num:

wzssyqa wrote:

LibFunc_fminimum_numl
LibFunc_fmaximum_numf
LibFunc_fmaximum_numl

Add. Should we add something like `fmaximum_numfN` and `fmaximum_numfNx `?

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-31 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa edited 
https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-31 Thread YunQiang Su via cfe-commits


@@ -631,6 +631,46 @@ TEST(APFloatTest, Maximum) {
   EXPECT_TRUE(std::isnan(maximum(nan, f1).convertToDouble()));
 }
 
+TEST(APFloatTest, MinimumNumber) {
+  APFloat f1(1.0);
+  APFloat f2(2.0);
+  APFloat zp(0.0);
+  APFloat zn(-0.0);
+  APFloat nan = APFloat::getNaN(APFloat::IEEEdouble());
+  APFloat snan = APFloat::getSNaN(APFloat::IEEEdouble());
+
+  EXPECT_EQ(1.0, minimumnum(f1, f2).convertToDouble());
+  EXPECT_EQ(1.0, minimumnum(f2, f1).convertToDouble());
+  EXPECT_EQ(-0.0, minimumnum(zp, zn).convertToDouble());
+  EXPECT_EQ(-0.0, minimumnum(zn, zp).convertToDouble());

wzssyqa wrote:

Let's add some new isNegtive tests.

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-31 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

> > 3. PowerPC: has some interaction with the behavior of `minnum/maxnum`: need 
> > define `fcanonicalize`.
> 
> AMDGPU has the same handling. This is to break the signaling nan handling 
> from IEEE to the broken old glibc libm behavior. If we fix the definition to 
> match IEEE, this is no longer necessary and the operation is directly legal

Added to TODO list.

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-31 Thread YunQiang Su via cfe-commits


@@ -16049,6 +16094,84 @@ of the two arguments. -0.0 is considered to be less 
than +0.0 for this
 intrinsic. Note that these are the semantics specified in the draft of
 IEEE 754-2019.
 
+.. _i_minimumnum:
+
+'``llvm.minimumnum.*``' Intrinsic
+^
+
+Syntax:
+"""
+
+This is an overloaded intrinsic. You can use ``llvm.minimumnum`` on any
+floating-point or vector of floating-point type. Not all targets support
+all types however.
+
+::
+
+  declare float @llvm.minimumnum.f32(float %Val0, float %Val1)
+  declare double@llvm.minimumnum.f64(double %Val0, double %Val1)
+  declare x86_fp80  @llvm.minimumnum.f80(x86_fp80 %Val0, x86_fp80 %Val1)
+  declare fp128 @llvm.minimumnum.f128(fp128 %Val0, fp128 %Val1)
+  declare ppc_fp128 @llvm.minimumnum.ppcf128(ppc_fp128 %Val0, ppc_fp128 
%Val1)
+
+Overview:
+"
+
+The '``llvm.minimumnum.*``' intrinsics return the minimum of the two
+arguments, not propagating NaNs and treating -0.0 as less than +0.0.
+
+
+Arguments:
+""
+
+The arguments and return value are floating-point numbers of the same
+type.
+
+Semantics:
+""
+If both operands are NaNs, returns qNaN. Otherwise returns the lesser
+of the two arguments. -0.0 is considered to be less than +0.0 for this
+intrinsic. Note that these are the semantics specified in IEEE 754-2019.

wzssyqa wrote:

> Needs to spell out the signaling nan behavior. If we're fixing minnum's snan 
> behavior to match IEEE, this is identical except with the stronger guarantee 
> for signed zero ordering. The documentation should also explicitly state this 
> is the only difference, to help reduce confusion. Alternatively, we could add 
> an immediate bool parameter to minnum/maxnum for whether the ordering of 0 is 
> guaranteed
> 

OK. I will add more details here.

> I hate the naming mess we've ended up with here, but I guess C23 has damned 
> us. If you're going to match the C23 names, this should be `llvm.minimum.num` 
> with an extra _

In fact, in my initial version of patch, I use _, then I get 
`llvm.minimum.num`. I considered it as a problem, since it cost some time to 
know in fact I should use `llvm.minimum.num` instead of `llvm.minimum_num` :(

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-30 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

TODO: implement for architectures that don't have `fmin/fmax` instructions:

This is the example of MIPS pre-R6:

```
mins:
.setnoreorder
.setnomacro
mtc1$0,$f1
add.s   $f0,$f12,$f1
add.s   $f13,$f13,$f1

c.un.s  $fcc0,$f0,$f0
movt.s  $f0,$f13,$fcc0
c.un.s  $fcc0,$f13,$f13
movt.s  $f13,$f0,$fcc0
c.ult.s $fcc0,$f13,$f0
movt.s  $f0,$f13,$fcc0
jr  $31
```

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-30 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

@peterwaller-arm I noticed that in 
`llvm/test/CodeGen/AArch64/combine_andor_with_cmps.ll`, `FMAXNUM_IEEE` is 
claimed that it is not supported. While I noticed that `fmaxnm` follows the 
rules of `maxNUM` of IEEE754-2008.
Is there any other limitation of `fmaxnm`?

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)

2024-05-30 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

Since we need to reuse some logic of `minnum/maxnum` to implement 
`minimumnum/maximumnum`,
let's add them before switch the behavior of `minnum/maxnum`.


Known not working ports, will be fixed in future PRs:

1. X86: the current `minnum/maxnum` cannot process +0 vs -0 as 
`minimumnum/maximumnum` expected.
2. ARM(32): has some interaction with the behavior of `minnum/maxnum`.
3. PowerPC: has some interaction with the behavior of `minnum/maxnum`: need 
define `fcanonicalize`.

https://github.com/llvm/llvm-project/pull/93841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] IR: Add module level attribution language-standard (PR #93159)

2024-05-23 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa closed 
https://github.com/llvm/llvm-project/pull/93159
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] IR: Add module level attribution language-standard (PR #93159)

2024-05-23 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

Let's close it.

https://github.com/llvm/llvm-project/pull/93159
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] IR: Add module level attribution language-standard (PR #93159)

2024-05-23 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa converted_to_draft 
https://github.com/llvm/llvm-project/pull/93159
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] IR: Add module level attribution language-standard (PR #93159)

2024-05-23 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa created 
https://github.com/llvm/llvm-project/pull/93159

The backend may have interest on the language-standard level of source file. 
Let's pass it to IR.

In a ll file, it looks like
   language-standard = "gnu17"

>From 3e413bae6ba18276e4d47075d48d656e4f732b5e Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Thu, 23 May 2024 17:33:34 +0800
Subject: [PATCH] IR: Add module level attribution language-standard

The backend may have interest on the language-standard level
of source file. Let's pass it to IR.

In a ll file, it looks like
   language-standard = "gnu17"
---
 clang/lib/CodeGen/ModuleBuilder.cpp   |  3 +++
 llvm/include/llvm/Bitcode/LLVMBitCodes.h  |  3 +++
 llvm/include/llvm/IR/Module.h |  7 +++
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 22 +-
 llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 23 +++
 llvm/lib/IR/AsmWriter.cpp |  6 ++
 llvm/lib/IR/Module.cpp|  4 ++--
 7 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp 
b/clang/lib/CodeGen/ModuleBuilder.cpp
index df85295cfb2e2..cf07b09b93fd7 100644
--- a/clang/lib/CodeGen/ModuleBuilder.cpp
+++ b/clang/lib/CodeGen/ModuleBuilder.cpp
@@ -153,6 +153,9 @@ namespace {
 
   M->setTargetTriple(Ctx->getTargetInfo().getTriple().getTriple());
   M->setDataLayout(Ctx->getTargetInfo().getDataLayoutString());
+  M->setLanguageStandard(
+  LangStandard::getLangStandardForKind(Ctx->getLangOpts().LangStd)
+  .getName());
   const auto  = Ctx->getTargetInfo().getSDKVersion();
   if (!SDKVersion.empty())
 M->setSDKVersion(SDKVersion);
diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h 
b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
index 909eb833c601a..cba77c322fdb4 100644
--- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
@@ -120,6 +120,9 @@ enum ModuleCodes {
 
   // IFUNC: [ifunc value type, addrspace, resolver val#, linkage, visibility]
   MODULE_CODE_IFUNC = 18,
+
+  // LANGUAGE_STANDARD: [strchr x N]
+  MODULE_CODE_LANGUAGE_STANDARD = 19,
 };
 
 /// PARAMATTR blocks have code for defining a parameter attribute set.
diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index 6135e15fd030f..300dc5c5630dc 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -196,6 +196,7 @@ class LLVM_EXTERNAL_VISIBILITY Module {
   ///< recorded in bitcode.
   std::string TargetTriple;   ///< Platform target triple Module compiled 
on
   ///< Format: (arch)(sub)-(vendor)-(sys0-(abi)
+  std::string LanguageStandard;   ///< Language standard: c89/c99/c11/c23 etc.
   NamedMDSymTabType NamedMDSymTab;  ///< NamedMDNode names.
   DataLayout DL;  ///< DataLayout associated with the module
   StringMap
@@ -277,6 +278,9 @@ class LLVM_EXTERNAL_VISIBILITY Module {
   /// contain the source file name.
   const std::string () const { return SourceFileName; }
 
+  /// Get the module's language standard.
+  const std::string () const { return LanguageStandard; }
+
   /// Get a short "name" for the module.
   ///
   /// This is useful for debugging or logging. It is essentially a convenience
@@ -339,6 +343,9 @@ class LLVM_EXTERNAL_VISIBILITY Module {
   /// Set the target triple.
   void setTargetTriple(StringRef T) { TargetTriple = std::string(T); }
 
+  /// Set the language standard.
+  void setLanguageStandard(StringRef S) { LanguageStandard = std::string(S); }
+
   /// Set the module-scope inline assembly blocks.
   /// A trailing newline is added if the input doesn't have one.
   void setModuleInlineAsm(StringRef Asm) {
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp 
b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index c9295344f8080..8078291477886 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -946,6 +946,9 @@ class ModuleSummaryIndexBitcodeReader : public 
BitcodeReaderBase {
   /// Original source file name recorded in a bitcode record.
   std::string SourceFileName;
 
+  /// Original language standard recorded in a bitcode record.
+  std::string LanguageStandard;
+
   /// The string identifier given to this module by the client, normally the
   /// path to the bitcode file.
   StringRef ModulePath;
@@ -4613,13 +4616,22 @@ Error BitcodeReader::parseModule(uint64_t ResumeBit,
   VSTOffset = Record[0] - 1;
   break;
 /// MODULE_CODE_SOURCE_FILENAME: [namechar x N]
-case bitc::MODULE_CODE_SOURCE_FILENAME:
+case bitc::MODULE_CODE_SOURCE_FILENAME: {
   SmallString<128> ValueName;
   if (convertToString(Record, 0, ValueName))
 return error("Invalid record");
   TheModule->setSourceFileName(ValueName);
   break;
 }
+/// MODULE_CODE_LANGUAGE_STANDARD: [strchar x N]
+case 

[clang] MIPS/Clang: Add more false option pairs into validateTarget (PR #91968)

2024-05-22 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa closed 
https://github.com/llvm/llvm-project/pull/91968
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] MIPS/Clang: Add more false option pairs into validateTarget (PR #91968)

2024-05-21 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/91968

>From cccd9606fd574726c2cde2e473d1e05a62147caf Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Mon, 13 May 2024 21:46:40 +0800
Subject: [PATCH] MIPS/Clang: Add more false option pairs into validateTarget

The option pairs include:
-mfpxx -mips1
-msoft-float -mmsa
-mmsa -mabi=32 with 32bit pre-R2 CPUs
-mfpxx -mmsa
-mfp32 -mmsa
---
 clang/lib/Basic/Targets/Mips.cpp | 28 
 1 file changed, 28 insertions(+)

diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp
index 3a65f53c52485..174bc9d2ab996 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -273,6 +273,34 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine 
) const {
 Diags.Report(diag::err_mips_fp64_req) << "-mfp64";
 return false;
   }
+  // FPXX requires mips2+
+  if (FPMode == FPXX && CPU == "mips1") {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfpxx" << CPU;
+return false;
+  }
+  // -mmsa with -msoft-float makes nonsense
+  if (FloatABI == SoftFloat && HasMSA) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-msoft-float"
+   << "-mmsa";
+return false;
+  }
+  // Option -mmsa permitted on Mips32 iff revision 2 or higher is present
+  if (HasMSA && (CPU == "mips1" || CPU == "mips2" || getISARev() < 2) &&
+  ABI == "o32") {
+Diags.Report(diag::err_mips_fp64_req) << "-mmsa";
+return false;
+  }
+  // MSA requires FP64
+  if (FPMode == FPXX && HasMSA) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfpxx"
+   << "-mmsa";
+return false;
+  }
+  if (FPMode == FP32 && HasMSA) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfp32"
+   << "-mmsa";
+return false;
+  }
 
   return true;
 }

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


[clang] MIPS/Clang: Add more false option pairs into validateTarget (PR #91968)

2024-05-21 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/91968

>From cccd9606fd574726c2cde2e473d1e05a62147caf Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Mon, 13 May 2024 21:46:40 +0800
Subject: [PATCH] MIPS/Clang: Add more false option pairs into validateTarget

The option pairs include:
-mfpxx -mips1
-msoft-float -mmsa
-mmsa -mabi=32 with 32bit pre-R2 CPUs
-mfpxx -mmsa
-mfp32 -mmsa
---
 clang/lib/Basic/Targets/Mips.cpp | 28 
 1 file changed, 28 insertions(+)

diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp
index 3a65f53c52485..174bc9d2ab996 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -273,6 +273,34 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine 
) const {
 Diags.Report(diag::err_mips_fp64_req) << "-mfp64";
 return false;
   }
+  // FPXX requires mips2+
+  if (FPMode == FPXX && CPU == "mips1") {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfpxx" << CPU;
+return false;
+  }
+  // -mmsa with -msoft-float makes nonsense
+  if (FloatABI == SoftFloat && HasMSA) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-msoft-float"
+   << "-mmsa";
+return false;
+  }
+  // Option -mmsa permitted on Mips32 iff revision 2 or higher is present
+  if (HasMSA && (CPU == "mips1" || CPU == "mips2" || getISARev() < 2) &&
+  ABI == "o32") {
+Diags.Report(diag::err_mips_fp64_req) << "-mmsa";
+return false;
+  }
+  // MSA requires FP64
+  if (FPMode == FPXX && HasMSA) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfpxx"
+   << "-mmsa";
+return false;
+  }
+  if (FPMode == FP32 && HasMSA) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfp32"
+   << "-mmsa";
+return false;
+  }
 
   return true;
 }

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


[clang] MIPS/Clang: handleTargetFeatures, add +fp64 if +msa and no other +-fp (PR #92728)

2024-05-21 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa closed 
https://github.com/llvm/llvm-project/pull/92728
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] MIPS/Clang: Add more false option pairs into validateTarget (PR #91968)

2024-05-20 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

Depens on: https://github.com/llvm/llvm-project/pull/92728

https://github.com/llvm/llvm-project/pull/91968
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] MIPS/Clang: handleTargetFeatures, add +fp64 if +msa and no other +-fp (PR #92728)

2024-05-20 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa created 
https://github.com/llvm/llvm-project/pull/92728

Commit: d59bc6b5c75384aa0b1e78cc85e17e8acaccebaf
Clang/MIPS: Add +fp64 if MSA and no explicit -mfp option (#91949)
added +fp64 for `clang`, while not for `clang -cc1`. So

   clang -cc1 -triple=mips -target-feature +msa -S

will emit an asm source file without ".module fp=64".

>From accab3329aa20c80ac4bf360b97c6949cfd82989 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Mon, 20 May 2024 17:21:01 +0800
Subject: [PATCH] MIPS/Clang: handleTargetFeatures, add +fp64 if +msa and no
 other +-fp

Commit: d59bc6b5c75384aa0b1e78cc85e17e8acaccebaf
Clang/MIPS: Add +fp64 if MSA and no explicit -mfp option (#91949)
added +fp64 for `clang`, while not for `clang -cc1`. So

   clang -cc1 -triple=mips -target-feature +msa -S

will emit an asm source file without ".module fp=64".
---
 clang/lib/Basic/Targets/Mips.h | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index f76c6ece8bf48..b6f110249fa78 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -324,6 +324,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 FPMode = getDefaultFPMode();
 bool OddSpregGiven = false;
 bool StrictAlign = false;
+bool FpGiven = false;
 
 for (const auto  : Features) {
   if (Feature == "+single-float")
@@ -348,13 +349,16 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 HasMSA = true;
   else if (Feature == "+nomadd4")
 DisableMadd4 = true;
-  else if (Feature == "+fp64")
+  else if (Feature == "+fp64") {
 FPMode = FP64;
-  else if (Feature == "-fp64")
+FpGiven = true;
+  } else if (Feature == "-fp64") {
 FPMode = FP32;
-  else if (Feature == "+fpxx")
+FpGiven = true;
+  } else if (Feature == "+fpxx") {
 FPMode = FPXX;
-  else if (Feature == "+nan2008")
+FpGiven = true;
+  } else if (Feature == "+nan2008")
 IsNan2008 = true;
   else if (Feature == "-nan2008")
 IsNan2008 = false;
@@ -381,6 +385,11 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 if (StrictAlign)
   HasUnalignedAccess = false;
 
+if (HasMSA && !FpGiven) {
+  FPMode = FP64;
+  Features.push_back("+fp64");
+}
+
 setDataLayout();
 
 return true;

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


[clang] MIPS/Clang: Use FP32 by default if CPU is mips1 (PR #92122)

2024-05-20 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa closed 
https://github.com/llvm/llvm-project/pull/92122
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] MIPS/Clang: Add more false option pairs into validateTarget (PR #91968)

2024-05-20 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/91968

>From cccd9606fd574726c2cde2e473d1e05a62147caf Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Mon, 13 May 2024 21:46:40 +0800
Subject: [PATCH] MIPS/Clang: Add more false option pairs into validateTarget

The option pairs include:
-mfpxx -mips1
-msoft-float -mmsa
-mmsa -mabi=32 with 32bit pre-R2 CPUs
-mfpxx -mmsa
-mfp32 -mmsa
---
 clang/lib/Basic/Targets/Mips.cpp | 28 
 1 file changed, 28 insertions(+)

diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp
index 3a65f53c52485..174bc9d2ab996 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -273,6 +273,34 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine 
) const {
 Diags.Report(diag::err_mips_fp64_req) << "-mfp64";
 return false;
   }
+  // FPXX requires mips2+
+  if (FPMode == FPXX && CPU == "mips1") {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfpxx" << CPU;
+return false;
+  }
+  // -mmsa with -msoft-float makes nonsense
+  if (FloatABI == SoftFloat && HasMSA) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-msoft-float"
+   << "-mmsa";
+return false;
+  }
+  // Option -mmsa permitted on Mips32 iff revision 2 or higher is present
+  if (HasMSA && (CPU == "mips1" || CPU == "mips2" || getISARev() < 2) &&
+  ABI == "o32") {
+Diags.Report(diag::err_mips_fp64_req) << "-mmsa";
+return false;
+  }
+  // MSA requires FP64
+  if (FPMode == FPXX && HasMSA) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfpxx"
+   << "-mmsa";
+return false;
+  }
+  if (FPMode == FP32 && HasMSA) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfp32"
+   << "-mmsa";
+return false;
+  }
 
   return true;
 }

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


[clang] Clang/MIPS: Add +fp64 if MSA and no explicit -mfp option (PR #91949)

2024-05-20 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa closed 
https://github.com/llvm/llvm-project/pull/91949
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] MIPS/Clang: Add more false option pairs into validateTarget (PR #91968)

2024-05-14 Thread YunQiang Su via cfe-commits


@@ -273,6 +273,34 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine 
) const {
 Diags.Report(diag::err_mips_fp64_req) << "-mfp64";
 return false;
   }
+  // FPXX requires mips2+
+  if (FPMode == FPXX && CPU == "mips1") {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfpxx" << CPU;

wzssyqa wrote:

Here, it depends on: https://github.com/llvm/llvm-project/pull/92122
Otherwise  `clang -cc1 -triple mips -target-cpu mips1` will always fail.

https://github.com/llvm/llvm-project/pull/91968
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] MIPS/Clang: Add more false option pairs into validateTarget (PR #91968)

2024-05-14 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

Depends on: https://github.com/llvm/llvm-project/pull/92122


https://github.com/llvm/llvm-project/pull/91968
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] MIPS/Clang: Use FP32 by default if CPU is mips1 (PR #92122)

2024-05-14 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa created 
https://github.com/llvm/llvm-project/pull/92122

FP32 is the only supported FPMode of mips1.
FPXX requires MIPS2+ and FP64 requires MIPS32r2+.

>From 9cb774c2c1239c752b717888f19691f3c6b7f907 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Tue, 14 May 2024 22:00:16 +0800
Subject: [PATCH] MIPS/Clang: Use FP32 by default if CPU is mips1

FP32 is the only supported FPMode of mips1.
FPXX requires MIPS2+ and FP64 requires MIPS32r2+.
---
 clang/lib/Basic/Targets/Mips.h | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index 730deb674aa57..f76c6ece8bf48 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -85,8 +85,13 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 return CPU == "mips32r6" || CPU == "mips64r6";
   }
 
-  bool isFP64Default() const {
-return CPU == "mips32r6" || ABI == "n32" || ABI == "n64" || ABI == "64";
+  enum FPModeEnum getDefaultFPMode() const {
+if (CPU == "mips32r6" || ABI == "n32" || ABI == "n64" || ABI == "64")
+  return FP64;
+else if (CPU == "mips1")
+  return FP32;
+else
+  return FPXX;
   }
 
   bool isNan2008() const override { return IsNan2008; }
@@ -315,8 +320,8 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public 
TargetInfo {
 IsSingleFloat = false;
 FloatABI = HardFloat;
 DspRev = NoDSP;
-FPMode = isFP64Default() ? FP64 : FPXX;
 NoOddSpreg = false;
+FPMode = getDefaultFPMode();
 bool OddSpregGiven = false;
 bool StrictAlign = false;
 

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


[clang] Clang/MIPS: Add +fp64 if MSA and no explicit -mfp option (PR #91949)

2024-05-14 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/91949

>From effc1a239718ebc20ac835e59223c78d3fd9a01c Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Mon, 13 May 2024 19:28:25 +0800
Subject: [PATCH 1/2] Clang/MIPS: Add +fp64 if MSA and no explicit -mfp option

MSA requires -mfp64. If FP64 is supported by CPU (mips32r2+),
and no -mfp32/-mfpxx is explicitly given, let's add +fp64.
Otherwise some cmd like
   clang --target=mips -mips32r5 -mmsa
will issue LLVM backend ICE.
---
 clang/lib/Driver/ToolChains/Arch/Mips.cpp | 10 ++
 clang/test/Driver/mips-features.c |  6 ++
 2 files changed, 16 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp 
b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
index 74a8874a3ea2b..79a00711e6f53 100644
--- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -369,6 +369,9 @@ void mips::getMIPSTargetFeatures(const Driver , const 
llvm::Triple ,
   } else if (mips::isFP64ADefault(Triple, CPUName)) {
 Features.push_back("+fp64");
 Features.push_back("+nooddspreg");
+  } else if (Arg *A = Args.getLastArg(options::OPT_mmsa)) {
+if (A->getOption().matches(options::OPT_mmsa))
+  Features.push_back("+fp64");
   }
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
@@ -499,6 +502,13 @@ bool mips::shouldUseFPXX(const ArgList , const 
llvm::Triple ,
options::OPT_mdouble_float))
 if (A->getOption().matches(options::OPT_msingle_float))
   UseFPXX = false;
+  // FP64 should be used for MSA.
+  if (Arg *A = Args.getLastArg(options::OPT_mmsa))
+if (A->getOption().matches(options::OPT_mmsa))
+  UseFPXX = llvm::StringSwitch(CPUName)
+.Cases("mips32r2", "mips32r3", "mips32r5", false)
+.Cases("mips64r2", "mips64r3", "mips64r5", false)
+.Default(UseFPXX);
 
   return UseFPXX;
 }
diff --git a/clang/test/Driver/mips-features.c 
b/clang/test/Driver/mips-features.c
index 5e92dccaa02ab..8b8db4c4a341b 100644
--- a/clang/test/Driver/mips-features.c
+++ b/clang/test/Driver/mips-features.c
@@ -163,6 +163,12 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NOMMSA %s
 // CHECK-NOMMSA: "-target-feature" "-msa"
 //
+// -mmsa
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN: -mmsa 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MMSA-MFP64 %s
+// CHECK-MMSA-MFP64: "-target-feature" "+msa" "-target-feature" "+fp64"
+//
 // -mmt
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN: -mno-mt -mmt 2>&1 \

>From cd7eabcd2ead397253eddf878ebf832220a221a4 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Tue, 14 May 2024 21:09:57 +0800
Subject: [PATCH 2/2] Remove -mfp64 from ../clang/test/Driver/mips-as.c

-mmsa implies -mfp64 by Gas
---
 clang/test/Driver/mips-as.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Driver/mips-as.c b/clang/test/Driver/mips-as.c
index 14fbb18c93500..a3399f1078fcd 100644
--- a/clang/test/Driver/mips-as.c
+++ b/clang/test/Driver/mips-as.c
@@ -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" "-mfpxx" "-mmsa"
+// MIPS-MSA: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB" "-mmsa"
 //
 // RUN: %clang -target mips-linux-gnu -mmsa -mno-msa -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \

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


[clang] MIPS/Clang: Add more false option pairs into validateTarget (PR #91968)

2024-05-13 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa created 
https://github.com/llvm/llvm-project/pull/91968

The option pairs include:
-mfpxx -mips1
-msoft-float -mmsa
-mmsa -mabi=32 with 32bit pre-R2 CPUs
-mfpxx -mmsa
-mfp32 -mmsa

>From cccd9606fd574726c2cde2e473d1e05a62147caf Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Mon, 13 May 2024 21:46:40 +0800
Subject: [PATCH] MIPS/Clang: Add more false option pairs into validateTarget

The option pairs include:
-mfpxx -mips1
-msoft-float -mmsa
-mmsa -mabi=32 with 32bit pre-R2 CPUs
-mfpxx -mmsa
-mfp32 -mmsa
---
 clang/lib/Basic/Targets/Mips.cpp | 28 
 1 file changed, 28 insertions(+)

diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp
index 3a65f53c52485..174bc9d2ab996 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -273,6 +273,34 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine 
) const {
 Diags.Report(diag::err_mips_fp64_req) << "-mfp64";
 return false;
   }
+  // FPXX requires mips2+
+  if (FPMode == FPXX && CPU == "mips1") {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfpxx" << CPU;
+return false;
+  }
+  // -mmsa with -msoft-float makes nonsense
+  if (FloatABI == SoftFloat && HasMSA) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-msoft-float"
+   << "-mmsa";
+return false;
+  }
+  // Option -mmsa permitted on Mips32 iff revision 2 or higher is present
+  if (HasMSA && (CPU == "mips1" || CPU == "mips2" || getISARev() < 2) &&
+  ABI == "o32") {
+Diags.Report(diag::err_mips_fp64_req) << "-mmsa";
+return false;
+  }
+  // MSA requires FP64
+  if (FPMode == FPXX && HasMSA) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfpxx"
+   << "-mmsa";
+return false;
+  }
+  if (FPMode == FP32 && HasMSA) {
+Diags.Report(diag::err_opt_not_valid_with_opt) << "-mfp32"
+   << "-mmsa";
+return false;
+  }
 
   return true;
 }

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


[clang] Clang/MIPS: Add +fp64 if MSA and no explicit -mfp option (PR #91949)

2024-05-13 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa created 
https://github.com/llvm/llvm-project/pull/91949

MSA requires -mfp64. If FP64 is supported by CPU (mips32r2+), and no 
-mfp32/-mfpxx is explicitly given, let's add +fp64. Otherwise some cmd like
   clang --target=mips -mips32r5 -mmsa
will issue LLVM backend ICE.

>From effc1a239718ebc20ac835e59223c78d3fd9a01c Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Mon, 13 May 2024 19:28:25 +0800
Subject: [PATCH] Clang/MIPS: Add +fp64 if MSA and no explicit -mfp option

MSA requires -mfp64. If FP64 is supported by CPU (mips32r2+),
and no -mfp32/-mfpxx is explicitly given, let's add +fp64.
Otherwise some cmd like
   clang --target=mips -mips32r5 -mmsa
will issue LLVM backend ICE.
---
 clang/lib/Driver/ToolChains/Arch/Mips.cpp | 10 ++
 clang/test/Driver/mips-features.c |  6 ++
 2 files changed, 16 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp 
b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
index 74a8874a3ea2b..79a00711e6f53 100644
--- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -369,6 +369,9 @@ void mips::getMIPSTargetFeatures(const Driver , const 
llvm::Triple ,
   } else if (mips::isFP64ADefault(Triple, CPUName)) {
 Features.push_back("+fp64");
 Features.push_back("+nooddspreg");
+  } else if (Arg *A = Args.getLastArg(options::OPT_mmsa)) {
+if (A->getOption().matches(options::OPT_mmsa))
+  Features.push_back("+fp64");
   }
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
@@ -499,6 +502,13 @@ bool mips::shouldUseFPXX(const ArgList , const 
llvm::Triple ,
options::OPT_mdouble_float))
 if (A->getOption().matches(options::OPT_msingle_float))
   UseFPXX = false;
+  // FP64 should be used for MSA.
+  if (Arg *A = Args.getLastArg(options::OPT_mmsa))
+if (A->getOption().matches(options::OPT_mmsa))
+  UseFPXX = llvm::StringSwitch(CPUName)
+.Cases("mips32r2", "mips32r3", "mips32r5", false)
+.Cases("mips64r2", "mips64r3", "mips64r5", false)
+.Default(UseFPXX);
 
   return UseFPXX;
 }
diff --git a/clang/test/Driver/mips-features.c 
b/clang/test/Driver/mips-features.c
index 5e92dccaa02ab..8b8db4c4a341b 100644
--- a/clang/test/Driver/mips-features.c
+++ b/clang/test/Driver/mips-features.c
@@ -163,6 +163,12 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NOMMSA %s
 // CHECK-NOMMSA: "-target-feature" "-msa"
 //
+// -mmsa
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN: -mmsa 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MMSA-MFP64 %s
+// CHECK-MMSA-MFP64: "-target-feature" "+msa" "-target-feature" "+fp64"
+//
 // -mmt
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN: -mno-mt -mmt 2>&1 \

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


[clang] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa closed 
https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Docs] Add release note for {target}-none-{environment} triple normalization changes (PR #90734)

2024-05-01 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

LGTM.

https://github.com/llvm/llvm-project/pull/90734
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

LGTM.

https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/89638

>From d8c9a636b3fbcdcfef6f934780e6cb042a84b23b Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Sat, 27 Apr 2024 10:55:38 +0800
Subject: [PATCH 1/2] Triple::normalize: Use none as OS for XX-none-ABI

When parsing a 3-component triple, after we determine Arch and Env,
if the middle component is "none", treat it as OS instead of Vendor.

Fixes: #89582.
---
 clang/docs/Multilib.rst  | 4 ++--
 llvm/lib/TargetParser/Triple.cpp | 6 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index ab737e43b97d23..063fe9a336f2fe 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -188,9 +188,9 @@ For a more comprehensive example see
   - Dir: thumb/v6-m
 # List of one or more normalized command line options, as generated by 
Clang
 # from the command line options or from Mappings below.
-# Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi}
+# Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi}
 # then this multilib variant will be considered a match.
-Flags: [--target=thumbv6m-none-unknown-eabi]
+Flags: [--target=thumbv6m-unknown-none-eabi]
 
   # Similarly, a multilib variant targeting Arm v7-M with an FPU (floating
   # point unit).
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 2c5aee3dfb2f3e..f3f244c814e7ee 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1151,6 +1151,12 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // If "none" is in the middle component in a three-component triple, treat it
+  // as the OS (Components[2]) instead of the vendor (Components[1]).
+  if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
+  Components[1] == "none" && Components[2].empty())
+std::swap(Components[1], Components[2]);
+
   // Replace empty components with "unknown" value.
   for (StringRef  : Components)
 if (C.empty())

>From 8128b3c6a911b60b7be2dfd93e42b2c726eaa4b1 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Wed, 1 May 2024 08:44:09 +0800
Subject: [PATCH 2/2] fix test failures

---
 clang/test/Driver/arm-ias-Wa.s|  2 +-
 clang/test/Driver/arm-triple.c| 10 +--
 .../Driver/baremetal-multilib-layered.yaml|  2 +-
 clang/test/Driver/baremetal-multilib.yaml | 64 +--
 clang/test/Driver/baremetal-sysroot.cpp   |  2 +-
 clang/test/Driver/baremetal.cpp   |  2 +-
 .../test/Driver/print-multi-selection-flags.c | 14 ++--
 .../IncrementalCompilerBuilderTest.cpp|  2 +-
 llvm/unittests/TargetParser/TripleTest.cpp|  2 +-
 9 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/clang/test/Driver/arm-ias-Wa.s b/clang/test/Driver/arm-ias-Wa.s
index b82ce8dfb31ab3..5e9518ed2dc423 100644
--- a/clang/test/Driver/arm-ias-Wa.s
+++ b/clang/test/Driver/arm-ias-Wa.s
@@ -71,7 +71,7 @@
 
 // RUN: %clang -target armv7r-none-eabi -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-R-PROFILE %s
-// CHECK-R-PROFILE: "-triple" "armv7r-none-unknown-eabi"
+// CHECK-R-PROFILE: "-triple" "armv7r-unknown-none-eabi"
 
 // RUN: %clang -target armv7m-none-eabi -c %s -### 2>&1 \
 // RUN: %clang -target thumbv7m-none-eabi -c %s -### 2>&1 \
diff --git a/clang/test/Driver/arm-triple.c b/clang/test/Driver/arm-triple.c
index fa9f7b189c8278..1fb2b5afe22a51 100644
--- a/clang/test/Driver/arm-triple.c
+++ b/clang/test/Driver/arm-triple.c
@@ -7,7 +7,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t -mfloat-abi=softfp \
 // RUN:   | FileCheck %s --check-prefix=CHECK-DEFAULT
-// CHECK-DEFAULT: armv4t-none-unknown-eabi
+// CHECK-DEFAULT: armv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=armeb-none-eabi \
@@ -15,7 +15,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mbig-endian \
 // RUN:   | FileCheck %s --check-prefix=CHECK-EB
-// CHECK-EB: armebv4t-none-unknown-eabi
+// CHECK-EB: armebv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t \
@@ -23,7 +23,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mfloat-abi=hard \
 // RUN:   | FileCheck %s --check-prefix=CHECK-HF
-// CHECK-HF: armv4t-none-unknown-eabihf
+// CHECK-HF: armv4t-unknown-none-eabihf
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=armeb-none-eabihf -march=armv4t \
@@ -37,7 +37,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mbig-endian -mfloat-abi=hard \
 // RUN:   | FileCheck %s --check-prefix=CHECK-EB-HF
-// CHECK-EB-HF: armebv4t-none-unknown-eabihf
+// CHECK-EB-HF: armebv4t-unknown-none-eabihf
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi 

[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/89638

>From 2315aa6db326a5b6508e3e9730007fb44c179421 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Sat, 27 Apr 2024 10:55:38 +0800
Subject: [PATCH 1/2] Triple::normalize: Use none as OS for XX-none-ABI

When parsing a 3-component triple, after we determine Arch and Env,
if the middle component is "none", treat it as OS instead of Vendor.

Fixes: #89582.
---
 clang/docs/Multilib.rst  | 4 ++--
 libcxx/utils/ci/run-buildbot | 2 +-
 llvm/lib/TargetParser/Triple.cpp | 6 ++
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index ab737e43b97d23..063fe9a336f2fe 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -188,9 +188,9 @@ For a more comprehensive example see
   - Dir: thumb/v6-m
 # List of one or more normalized command line options, as generated by 
Clang
 # from the command line options or from Mappings below.
-# Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi}
+# Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi}
 # then this multilib variant will be considered a match.
-Flags: [--target=thumbv6m-none-unknown-eabi]
+Flags: [--target=thumbv6m-unknown-none-eabi]
 
   # Similarly, a multilib variant targeting Arm v7-M with an FPU (floating
   # point unit).
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 60307a7d4f350a..23a2a1bbbc63fa 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -217,7 +217,7 @@ function test-armv7m-picolibc() {
 "${@}"
 
 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
-mv "${BUILD_DIR}/install/lib/armv7m-none-unknown-eabi"/* 
"${BUILD_DIR}/install/lib"
+mv "${BUILD_DIR}/install/lib/armv7m-none-eabi"/* "${BUILD_DIR}/install/lib"
 
 check-runtimes
 }
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 2c5aee3dfb2f3e..f3f244c814e7ee 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1151,6 +1151,12 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // If "none" is in the middle component in a three-component triple, treat it
+  // as the OS (Components[2]) instead of the vendor (Components[1]).
+  if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
+  Components[1] == "none" && Components[2].empty())
+std::swap(Components[1], Components[2]);
+
   // Replace empty components with "unknown" value.
   for (StringRef  : Components)
 if (C.empty())

>From d21b4ff131630c016334f574ef307d43ef588840 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Wed, 1 May 2024 08:44:09 +0800
Subject: [PATCH 2/2] fix test failures

---
 clang/test/Driver/arm-ias-Wa.s|  2 +-
 clang/test/Driver/arm-triple.c| 10 +--
 .../Driver/baremetal-multilib-layered.yaml|  2 +-
 clang/test/Driver/baremetal-multilib.yaml | 64 +--
 clang/test/Driver/baremetal-sysroot.cpp   |  2 +-
 clang/test/Driver/baremetal.cpp   |  2 +-
 .../test/Driver/print-multi-selection-flags.c | 14 ++--
 .../IncrementalCompilerBuilderTest.cpp|  2 +-
 llvm/unittests/TargetParser/TripleTest.cpp|  2 +-
 9 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/clang/test/Driver/arm-ias-Wa.s b/clang/test/Driver/arm-ias-Wa.s
index b82ce8dfb31ab3..5e9518ed2dc423 100644
--- a/clang/test/Driver/arm-ias-Wa.s
+++ b/clang/test/Driver/arm-ias-Wa.s
@@ -71,7 +71,7 @@
 
 // RUN: %clang -target armv7r-none-eabi -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-R-PROFILE %s
-// CHECK-R-PROFILE: "-triple" "armv7r-none-unknown-eabi"
+// CHECK-R-PROFILE: "-triple" "armv7r-unknown-none-eabi"
 
 // RUN: %clang -target armv7m-none-eabi -c %s -### 2>&1 \
 // RUN: %clang -target thumbv7m-none-eabi -c %s -### 2>&1 \
diff --git a/clang/test/Driver/arm-triple.c b/clang/test/Driver/arm-triple.c
index fa9f7b189c8278..1fb2b5afe22a51 100644
--- a/clang/test/Driver/arm-triple.c
+++ b/clang/test/Driver/arm-triple.c
@@ -7,7 +7,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t -mfloat-abi=softfp \
 // RUN:   | FileCheck %s --check-prefix=CHECK-DEFAULT
-// CHECK-DEFAULT: armv4t-none-unknown-eabi
+// CHECK-DEFAULT: armv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=armeb-none-eabi \
@@ -15,7 +15,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mbig-endian \
 // RUN:   | FileCheck %s --check-prefix=CHECK-EB
-// CHECK-EB: armebv4t-none-unknown-eabi
+// CHECK-EB: armebv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t \
@@ -23,7 +23,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mfloat-abi=hard \
 // RUN:   | FileCheck %s 

[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/89638

>From 3cec71e178264b69e43c4842302b61465271d735 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Sat, 27 Apr 2024 10:55:38 +0800
Subject: [PATCH 1/2] Triple::normalize: Use none as OS for XX-none-ABI

When parsing a 3-component triple, after we determine Arch and Env,
if the middle component is "none", treat it as OS instead of Vendor.

Fixes: #89582.
---
 clang/docs/Multilib.rst  | 4 ++--
 libcxx/utils/ci/run-buildbot | 2 +-
 llvm/lib/TargetParser/Triple.cpp | 6 ++
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index ab737e43b97d23..063fe9a336f2fe 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -188,9 +188,9 @@ For a more comprehensive example see
   - Dir: thumb/v6-m
 # List of one or more normalized command line options, as generated by 
Clang
 # from the command line options or from Mappings below.
-# Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi}
+# Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi}
 # then this multilib variant will be considered a match.
-Flags: [--target=thumbv6m-none-unknown-eabi]
+Flags: [--target=thumbv6m-unknown-none-eabi]
 
   # Similarly, a multilib variant targeting Arm v7-M with an FPU (floating
   # point unit).
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 60307a7d4f350a..3523a29e4f4613 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -217,7 +217,7 @@ function test-armv7m-picolibc() {
 "${@}"
 
 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
-mv "${BUILD_DIR}/install/lib/armv7m-none-unknown-eabi"/* 
"${BUILD_DIR}/install/lib"
+mv "${BUILD_DIR}/install/lib/armv7m-unknown-none-eabi"/* 
"${BUILD_DIR}/install/lib"
 
 check-runtimes
 }
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 2c5aee3dfb2f3e..f3f244c814e7ee 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1151,6 +1151,12 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // If "none" is in the middle component in a three-component triple, treat it
+  // as the OS (Components[2]) instead of the vendor (Components[1]).
+  if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
+  Components[1] == "none" && Components[2].empty())
+std::swap(Components[1], Components[2]);
+
   // Replace empty components with "unknown" value.
   for (StringRef  : Components)
 if (C.empty())

>From f5aca8b7cdb97b7ad1f8665401ee21caef8f61b4 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Wed, 1 May 2024 08:44:09 +0800
Subject: [PATCH 2/2] fix test failures

---
 clang/test/Driver/arm-ias-Wa.s|  2 +-
 clang/test/Driver/arm-triple.c| 10 +--
 .../Driver/baremetal-multilib-layered.yaml|  2 +-
 clang/test/Driver/baremetal-multilib.yaml | 64 +--
 clang/test/Driver/baremetal-sysroot.cpp   |  2 +-
 clang/test/Driver/baremetal.cpp   |  2 +-
 .../test/Driver/print-multi-selection-flags.c | 14 ++--
 .../IncrementalCompilerBuilderTest.cpp|  2 +-
 llvm/unittests/TargetParser/TripleTest.cpp|  2 +-
 9 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/clang/test/Driver/arm-ias-Wa.s b/clang/test/Driver/arm-ias-Wa.s
index b82ce8dfb31ab3..5e9518ed2dc423 100644
--- a/clang/test/Driver/arm-ias-Wa.s
+++ b/clang/test/Driver/arm-ias-Wa.s
@@ -71,7 +71,7 @@
 
 // RUN: %clang -target armv7r-none-eabi -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-R-PROFILE %s
-// CHECK-R-PROFILE: "-triple" "armv7r-none-unknown-eabi"
+// CHECK-R-PROFILE: "-triple" "armv7r-unknown-none-eabi"
 
 // RUN: %clang -target armv7m-none-eabi -c %s -### 2>&1 \
 // RUN: %clang -target thumbv7m-none-eabi -c %s -### 2>&1 \
diff --git a/clang/test/Driver/arm-triple.c b/clang/test/Driver/arm-triple.c
index fa9f7b189c8278..1fb2b5afe22a51 100644
--- a/clang/test/Driver/arm-triple.c
+++ b/clang/test/Driver/arm-triple.c
@@ -7,7 +7,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t -mfloat-abi=softfp \
 // RUN:   | FileCheck %s --check-prefix=CHECK-DEFAULT
-// CHECK-DEFAULT: armv4t-none-unknown-eabi
+// CHECK-DEFAULT: armv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=armeb-none-eabi \
@@ -15,7 +15,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mbig-endian \
 // RUN:   | FileCheck %s --check-prefix=CHECK-EB
-// CHECK-EB: armebv4t-none-unknown-eabi
+// CHECK-EB: armebv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t \
@@ -23,7 +23,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mfloat-abi=hard \
 // RUN:   | FileCheck %s 

[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa edited 
https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/89638

>From 3cec71e178264b69e43c4842302b61465271d735 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Sat, 27 Apr 2024 10:55:38 +0800
Subject: [PATCH 1/2] Triple::normalize: Use none as OS for XX-none-ABI

When parsing a 3-component triple, after we determine Arch and Env,
if the middle component is "none", treat it as OS instead of Vendor.

Fixes: #89582.
---
 clang/docs/Multilib.rst  | 4 ++--
 libcxx/utils/ci/run-buildbot | 2 +-
 llvm/lib/TargetParser/Triple.cpp | 6 ++
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index ab737e43b97d23..063fe9a336f2fe 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -188,9 +188,9 @@ For a more comprehensive example see
   - Dir: thumb/v6-m
 # List of one or more normalized command line options, as generated by 
Clang
 # from the command line options or from Mappings below.
-# Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi}
+# Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi}
 # then this multilib variant will be considered a match.
-Flags: [--target=thumbv6m-none-unknown-eabi]
+Flags: [--target=thumbv6m-unknown-none-eabi]
 
   # Similarly, a multilib variant targeting Arm v7-M with an FPU (floating
   # point unit).
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 60307a7d4f350a..3523a29e4f4613 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -217,7 +217,7 @@ function test-armv7m-picolibc() {
 "${@}"
 
 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
-mv "${BUILD_DIR}/install/lib/armv7m-none-unknown-eabi"/* 
"${BUILD_DIR}/install/lib"
+mv "${BUILD_DIR}/install/lib/armv7m-unknown-none-eabi"/* 
"${BUILD_DIR}/install/lib"
 
 check-runtimes
 }
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 2c5aee3dfb2f3e..f3f244c814e7ee 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1151,6 +1151,12 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // If "none" is in the middle component in a three-component triple, treat it
+  // as the OS (Components[2]) instead of the vendor (Components[1]).
+  if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
+  Components[1] == "none" && Components[2].empty())
+std::swap(Components[1], Components[2]);
+
   // Replace empty components with "unknown" value.
   for (StringRef  : Components)
 if (C.empty())

>From f5aca8b7cdb97b7ad1f8665401ee21caef8f61b4 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Wed, 1 May 2024 08:44:09 +0800
Subject: [PATCH 2/2] fix test failures

---
 clang/test/Driver/arm-ias-Wa.s|  2 +-
 clang/test/Driver/arm-triple.c| 10 +--
 .../Driver/baremetal-multilib-layered.yaml|  2 +-
 clang/test/Driver/baremetal-multilib.yaml | 64 +--
 clang/test/Driver/baremetal-sysroot.cpp   |  2 +-
 clang/test/Driver/baremetal.cpp   |  2 +-
 .../test/Driver/print-multi-selection-flags.c | 14 ++--
 .../IncrementalCompilerBuilderTest.cpp|  2 +-
 llvm/unittests/TargetParser/TripleTest.cpp|  2 +-
 9 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/clang/test/Driver/arm-ias-Wa.s b/clang/test/Driver/arm-ias-Wa.s
index b82ce8dfb31ab3..5e9518ed2dc423 100644
--- a/clang/test/Driver/arm-ias-Wa.s
+++ b/clang/test/Driver/arm-ias-Wa.s
@@ -71,7 +71,7 @@
 
 // RUN: %clang -target armv7r-none-eabi -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-R-PROFILE %s
-// CHECK-R-PROFILE: "-triple" "armv7r-none-unknown-eabi"
+// CHECK-R-PROFILE: "-triple" "armv7r-unknown-none-eabi"
 
 // RUN: %clang -target armv7m-none-eabi -c %s -### 2>&1 \
 // RUN: %clang -target thumbv7m-none-eabi -c %s -### 2>&1 \
diff --git a/clang/test/Driver/arm-triple.c b/clang/test/Driver/arm-triple.c
index fa9f7b189c8278..1fb2b5afe22a51 100644
--- a/clang/test/Driver/arm-triple.c
+++ b/clang/test/Driver/arm-triple.c
@@ -7,7 +7,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t -mfloat-abi=softfp \
 // RUN:   | FileCheck %s --check-prefix=CHECK-DEFAULT
-// CHECK-DEFAULT: armv4t-none-unknown-eabi
+// CHECK-DEFAULT: armv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=armeb-none-eabi \
@@ -15,7 +15,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mbig-endian \
 // RUN:   | FileCheck %s --check-prefix=CHECK-EB
-// CHECK-EB: armebv4t-none-unknown-eabi
+// CHECK-EB: armebv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t \
@@ -23,7 +23,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mfloat-abi=hard \
 // RUN:   | FileCheck %s 

[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/89638

>From 942b1a8ad3e994aaa7eae63ee923d9946cba0087 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Sat, 27 Apr 2024 10:55:38 +0800
Subject: [PATCH 1/2] Triple::normalize: Use none as OS for XX-none-ABI

When parsing a 3-component triple, after we determine Arch and Env,
if the middle component is "none", treat it as OS instead of Vendor.

Fixes: #89582.
---
 clang/docs/Multilib.rst  | 4 ++--
 libcxx/utils/ci/run-buildbot | 2 +-
 llvm/lib/TargetParser/Triple.cpp | 7 +++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index ab737e43b97d23..063fe9a336f2fe 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -188,9 +188,9 @@ For a more comprehensive example see
   - Dir: thumb/v6-m
 # List of one or more normalized command line options, as generated by 
Clang
 # from the command line options or from Mappings below.
-# Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi}
+# Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi}
 # then this multilib variant will be considered a match.
-Flags: [--target=thumbv6m-none-unknown-eabi]
+Flags: [--target=thumbv6m-unknown-none-eabi]
 
   # Similarly, a multilib variant targeting Arm v7-M with an FPU (floating
   # point unit).
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 60307a7d4f350a..3523a29e4f4613 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -217,7 +217,7 @@ function test-armv7m-picolibc() {
 "${@}"
 
 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
-mv "${BUILD_DIR}/install/lib/armv7m-none-unknown-eabi"/* 
"${BUILD_DIR}/install/lib"
+mv "${BUILD_DIR}/install/lib/armv7m-unknown-none-eabi"/* 
"${BUILD_DIR}/install/lib"
 
 check-runtimes
 }
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 2c5aee3dfb2f3e..c37ca7787b01ae 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1151,6 +1151,13 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // If "none" is in the middle component in a three-component triple, treat it
+  // as the OS (Components[2]) instead of the vendor (Components[1]).
+  // This is for some baremetal cases, such as "arm-none-elf".
+  if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
+  Components[1] == "none" && Components[2].empty())
+std::swap(Components[1], Components[2]);
+
   // Replace empty components with "unknown" value.
   for (StringRef  : Components)
 if (C.empty())

>From e238896bee28a7557c56fbfe6724bcb6324ebebc Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Wed, 1 May 2024 08:44:09 +0800
Subject: [PATCH 2/2] fix test failures

---
 clang/test/Driver/arm-ias-Wa.s|  2 +-
 clang/test/Driver/arm-triple.c| 10 +--
 .../Driver/baremetal-multilib-layered.yaml|  2 +-
 clang/test/Driver/baremetal-multilib.yaml | 64 +--
 clang/test/Driver/baremetal-sysroot.cpp   |  2 +-
 clang/test/Driver/baremetal.cpp   |  2 +-
 .../test/Driver/print-multi-selection-flags.c | 14 ++--
 .../IncrementalCompilerBuilderTest.cpp|  2 +-
 llvm/unittests/TargetParser/TripleTest.cpp|  2 +-
 9 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/clang/test/Driver/arm-ias-Wa.s b/clang/test/Driver/arm-ias-Wa.s
index b82ce8dfb31ab3..5e9518ed2dc423 100644
--- a/clang/test/Driver/arm-ias-Wa.s
+++ b/clang/test/Driver/arm-ias-Wa.s
@@ -71,7 +71,7 @@
 
 // RUN: %clang -target armv7r-none-eabi -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-R-PROFILE %s
-// CHECK-R-PROFILE: "-triple" "armv7r-none-unknown-eabi"
+// CHECK-R-PROFILE: "-triple" "armv7r-unknown-none-eabi"
 
 // RUN: %clang -target armv7m-none-eabi -c %s -### 2>&1 \
 // RUN: %clang -target thumbv7m-none-eabi -c %s -### 2>&1 \
diff --git a/clang/test/Driver/arm-triple.c b/clang/test/Driver/arm-triple.c
index fa9f7b189c8278..1fb2b5afe22a51 100644
--- a/clang/test/Driver/arm-triple.c
+++ b/clang/test/Driver/arm-triple.c
@@ -7,7 +7,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t -mfloat-abi=softfp \
 // RUN:   | FileCheck %s --check-prefix=CHECK-DEFAULT
-// CHECK-DEFAULT: armv4t-none-unknown-eabi
+// CHECK-DEFAULT: armv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=armeb-none-eabi \
@@ -15,7 +15,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mbig-endian \
 // RUN:   | FileCheck %s --check-prefix=CHECK-EB
-// CHECK-EB: armebv4t-none-unknown-eabi
+// CHECK-EB: armebv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t \
@@ -23,7 +23,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   

[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/89638

>From cd3107eca3575b066915c6ea9d6d1a38ad68d913 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Sat, 27 Apr 2024 10:55:38 +0800
Subject: [PATCH 1/2] Triple::normalize: Use none as OS for XX-none-ABI

When parsing a 3-component triple, after we determine Arch and Env,
if the middle component is "none", treat it as OS instead of Vendor.

Fixes: #89582.
---
 clang/docs/Multilib.rst  | 4 ++--
 libcxx/utils/ci/run-buildbot | 2 +-
 llvm/lib/TargetParser/Triple.cpp | 7 +++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index ab737e43b97d23..063fe9a336f2fe 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -188,9 +188,9 @@ For a more comprehensive example see
   - Dir: thumb/v6-m
 # List of one or more normalized command line options, as generated by 
Clang
 # from the command line options or from Mappings below.
-# Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi}
+# Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi}
 # then this multilib variant will be considered a match.
-Flags: [--target=thumbv6m-none-unknown-eabi]
+Flags: [--target=thumbv6m-unknown-none-eabi]
 
   # Similarly, a multilib variant targeting Arm v7-M with an FPU (floating
   # point unit).
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 60307a7d4f350a..3523a29e4f4613 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -217,7 +217,7 @@ function test-armv7m-picolibc() {
 "${@}"
 
 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
-mv "${BUILD_DIR}/install/lib/armv7m-none-unknown-eabi"/* 
"${BUILD_DIR}/install/lib"
+mv "${BUILD_DIR}/install/lib/armv7m-unknown-none-eabi"/* 
"${BUILD_DIR}/install/lib"
 
 check-runtimes
 }
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 2c5aee3dfb2f3e..82922d22bf61fb 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1151,6 +1151,13 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // If "none" is in the middle component in a three-component triple, treat 
it as
+  // the OS (Components[2]) instead of the vendor (Components[1]).
+  // This is for some baremetal cases, such as "arm-none-elf".
+  if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
+  Components[1] == "none" && Components[2].empty())
+std::swap(Components[1], Components[2]);
+
   // Replace empty components with "unknown" value.
   for (StringRef  : Components)
 if (C.empty())

>From 4cff8cee5141d57fceaacd9f62c7d05fd23d6485 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Wed, 1 May 2024 08:44:09 +0800
Subject: [PATCH 2/2] fix test failures

---
 clang/test/Driver/arm-ias-Wa.s|  2 +-
 clang/test/Driver/arm-triple.c| 10 +--
 .../Driver/baremetal-multilib-layered.yaml|  2 +-
 clang/test/Driver/baremetal-multilib.yaml | 64 +--
 clang/test/Driver/baremetal-sysroot.cpp   |  2 +-
 clang/test/Driver/baremetal.cpp   |  2 +-
 .../test/Driver/print-multi-selection-flags.c | 14 ++--
 .../IncrementalCompilerBuilderTest.cpp|  2 +-
 llvm/unittests/TargetParser/TripleTest.cpp|  2 +-
 9 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/clang/test/Driver/arm-ias-Wa.s b/clang/test/Driver/arm-ias-Wa.s
index b82ce8dfb31ab3..5e9518ed2dc423 100644
--- a/clang/test/Driver/arm-ias-Wa.s
+++ b/clang/test/Driver/arm-ias-Wa.s
@@ -71,7 +71,7 @@
 
 // RUN: %clang -target armv7r-none-eabi -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-R-PROFILE %s
-// CHECK-R-PROFILE: "-triple" "armv7r-none-unknown-eabi"
+// CHECK-R-PROFILE: "-triple" "armv7r-unknown-none-eabi"
 
 // RUN: %clang -target armv7m-none-eabi -c %s -### 2>&1 \
 // RUN: %clang -target thumbv7m-none-eabi -c %s -### 2>&1 \
diff --git a/clang/test/Driver/arm-triple.c b/clang/test/Driver/arm-triple.c
index fa9f7b189c8278..1fb2b5afe22a51 100644
--- a/clang/test/Driver/arm-triple.c
+++ b/clang/test/Driver/arm-triple.c
@@ -7,7 +7,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t -mfloat-abi=softfp \
 // RUN:   | FileCheck %s --check-prefix=CHECK-DEFAULT
-// CHECK-DEFAULT: armv4t-none-unknown-eabi
+// CHECK-DEFAULT: armv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=armeb-none-eabi \
@@ -15,7 +15,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mbig-endian \
 // RUN:   | FileCheck %s --check-prefix=CHECK-EB
-// CHECK-EB: armebv4t-none-unknown-eabi
+// CHECK-EB: armebv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t \
@@ -23,7 +23,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   

[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-05-01 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/89638

>From a165cd689e6fa23163736ea6d76d8a60440f4b30 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Sat, 27 Apr 2024 10:55:38 +0800
Subject: [PATCH 1/2] Triple::normalize: Use none as OS for XX-none-ABI

When parsing a 3-component triple, after we determine Arch and Env,
if the middle component is "none", treat it as OS instead of Vendor.

Fixes: #89582.
---
 clang/docs/Multilib.rst  | 4 ++--
 libcxx/utils/ci/run-buildbot | 2 +-
 llvm/lib/TargetParser/Triple.cpp | 7 +++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index ab737e43b97d23..063fe9a336f2fe 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -188,9 +188,9 @@ For a more comprehensive example see
   - Dir: thumb/v6-m
 # List of one or more normalized command line options, as generated by 
Clang
 # from the command line options or from Mappings below.
-# Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi}
+# Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi}
 # then this multilib variant will be considered a match.
-Flags: [--target=thumbv6m-none-unknown-eabi]
+Flags: [--target=thumbv6m-unknown-none-eabi]
 
   # Similarly, a multilib variant targeting Arm v7-M with an FPU (floating
   # point unit).
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 60307a7d4f350a..3523a29e4f4613 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -217,7 +217,7 @@ function test-armv7m-picolibc() {
 "${@}"
 
 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
-mv "${BUILD_DIR}/install/lib/armv7m-none-unknown-eabi"/* 
"${BUILD_DIR}/install/lib"
+mv "${BUILD_DIR}/install/lib/armv7m-unknown-none-eabi"/* 
"${BUILD_DIR}/install/lib"
 
 check-runtimes
 }
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 2c5aee3dfb2f3e..b36aebc14c0825 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1151,6 +1151,13 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // If "none" is in the middle component in a three-component triple, treat 
it as
+  // the OS (Components[2]) instead of the vendor (Components[1]).
+  // This is for some baremetal cases, such as "arm-none-elf".
+  if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
+  Components[1].equals("none") && Components[2].empty())
+std::swap(Components[1], Components[2]);
+
   // Replace empty components with "unknown" value.
   for (StringRef  : Components)
 if (C.empty())

>From 7471e4f6032b7913f9d983a3488f0c6f7e33c9b8 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Wed, 1 May 2024 08:44:09 +0800
Subject: [PATCH 2/2] fix test failures

---
 clang/test/Driver/arm-ias-Wa.s|  2 +-
 clang/test/Driver/arm-triple.c| 10 +--
 .../Driver/baremetal-multilib-layered.yaml|  2 +-
 clang/test/Driver/baremetal-multilib.yaml | 64 +--
 clang/test/Driver/baremetal-sysroot.cpp   |  2 +-
 clang/test/Driver/baremetal.cpp   |  2 +-
 .../test/Driver/print-multi-selection-flags.c | 14 ++--
 .../IncrementalCompilerBuilderTest.cpp|  2 +-
 llvm/unittests/TargetParser/TripleTest.cpp|  2 +-
 9 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/clang/test/Driver/arm-ias-Wa.s b/clang/test/Driver/arm-ias-Wa.s
index b82ce8dfb31ab3..5e9518ed2dc423 100644
--- a/clang/test/Driver/arm-ias-Wa.s
+++ b/clang/test/Driver/arm-ias-Wa.s
@@ -71,7 +71,7 @@
 
 // RUN: %clang -target armv7r-none-eabi -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-R-PROFILE %s
-// CHECK-R-PROFILE: "-triple" "armv7r-none-unknown-eabi"
+// CHECK-R-PROFILE: "-triple" "armv7r-unknown-none-eabi"
 
 // RUN: %clang -target armv7m-none-eabi -c %s -### 2>&1 \
 // RUN: %clang -target thumbv7m-none-eabi -c %s -### 2>&1 \
diff --git a/clang/test/Driver/arm-triple.c b/clang/test/Driver/arm-triple.c
index fa9f7b189c8278..1fb2b5afe22a51 100644
--- a/clang/test/Driver/arm-triple.c
+++ b/clang/test/Driver/arm-triple.c
@@ -7,7 +7,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t -mfloat-abi=softfp \
 // RUN:   | FileCheck %s --check-prefix=CHECK-DEFAULT
-// CHECK-DEFAULT: armv4t-none-unknown-eabi
+// CHECK-DEFAULT: armv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=armeb-none-eabi \
@@ -15,7 +15,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mbig-endian \
 // RUN:   | FileCheck %s --check-prefix=CHECK-EB
-// CHECK-EB: armebv4t-none-unknown-eabi
+// CHECK-EB: armebv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t \
@@ -23,7 +23,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   

[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-04-30 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

@peterwaller-arm It seems OK now. Let's wait the result of CI.

https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-04-30 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/89638

>From aafa018b3d7657483738fa91812e3e8bbdd8205a Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Sat, 27 Apr 2024 10:55:38 +0800
Subject: [PATCH 1/2] Triple::normalize: Use none as OS for XX-none-ABI

When we parse 3-components triples, if the Arch and Env have been
parsed successfully, we have to make a choice between Vendor and
OS for the unrecoginzed component. Noramlly it is the middle one.

In the current code, Vendor is choosed, and then OS is fallbacked
to unknown. It is OK for most cases. But if the unrecoginzed
component is `none`, it is expected to be OS instead of Vendor.

Fixes: #89582.
---
 clang/docs/Multilib.rst  | 4 ++--
 libcxx/utils/ci/run-buildbot | 2 +-
 llvm/lib/TargetParser/Triple.cpp | 7 +++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index ab737e43b97d23..063fe9a336f2fe 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -188,9 +188,9 @@ For a more comprehensive example see
   - Dir: thumb/v6-m
 # List of one or more normalized command line options, as generated by 
Clang
 # from the command line options or from Mappings below.
-# Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi}
+# Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi}
 # then this multilib variant will be considered a match.
-Flags: [--target=thumbv6m-none-unknown-eabi]
+Flags: [--target=thumbv6m-unknown-none-eabi]
 
   # Similarly, a multilib variant targeting Arm v7-M with an FPU (floating
   # point unit).
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 60307a7d4f350a..3523a29e4f4613 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -217,7 +217,7 @@ function test-armv7m-picolibc() {
 "${@}"
 
 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
-mv "${BUILD_DIR}/install/lib/armv7m-none-unknown-eabi"/* 
"${BUILD_DIR}/install/lib"
+mv "${BUILD_DIR}/install/lib/armv7m-unknown-none-eabi"/* 
"${BUILD_DIR}/install/lib"
 
 check-runtimes
 }
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 2c5aee3dfb2f3e..9c04574fe1e4bc 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1151,6 +1151,13 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // For 3-component triples, the middle component is used to set Vendor;
+  // while if it is "none", we'd prefer to set OS.
+  // This is for some baremetal cases, such as "arm-none-elf".
+  if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
+  Components[1].equals("none") && Components[2].empty())
+std::swap(Components[1], Components[2]);
+
   // Replace empty components with "unknown" value.
   for (StringRef  : Components)
 if (C.empty())

>From 9ec75a8b5a038e8851b15bb2ce32aa42dd74f61a Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Wed, 1 May 2024 08:44:09 +0800
Subject: [PATCH 2/2] fix test failures

---
 clang/test/Driver/arm-ias-Wa.s|  2 +-
 clang/test/Driver/arm-triple.c| 10 +--
 .../Driver/baremetal-multilib-layered.yaml|  2 +-
 clang/test/Driver/baremetal-multilib.yaml | 64 +--
 clang/test/Driver/baremetal-sysroot.cpp   |  2 +-
 clang/test/Driver/baremetal.cpp   |  2 +-
 .../test/Driver/print-multi-selection-flags.c |  2 +-
 .../IncrementalCompilerBuilderTest.cpp|  2 +-
 llvm/unittests/TargetParser/TripleTest.cpp|  2 +-
 9 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/clang/test/Driver/arm-ias-Wa.s b/clang/test/Driver/arm-ias-Wa.s
index b82ce8dfb31ab3..5e9518ed2dc423 100644
--- a/clang/test/Driver/arm-ias-Wa.s
+++ b/clang/test/Driver/arm-ias-Wa.s
@@ -71,7 +71,7 @@
 
 // RUN: %clang -target armv7r-none-eabi -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-R-PROFILE %s
-// CHECK-R-PROFILE: "-triple" "armv7r-none-unknown-eabi"
+// CHECK-R-PROFILE: "-triple" "armv7r-unknown-none-eabi"
 
 // RUN: %clang -target armv7m-none-eabi -c %s -### 2>&1 \
 // RUN: %clang -target thumbv7m-none-eabi -c %s -### 2>&1 \
diff --git a/clang/test/Driver/arm-triple.c b/clang/test/Driver/arm-triple.c
index fa9f7b189c8278..1fb2b5afe22a51 100644
--- a/clang/test/Driver/arm-triple.c
+++ b/clang/test/Driver/arm-triple.c
@@ -7,7 +7,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t -mfloat-abi=softfp \
 // RUN:   | FileCheck %s --check-prefix=CHECK-DEFAULT
-// CHECK-DEFAULT: armv4t-none-unknown-eabi
+// CHECK-DEFAULT: armv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=armeb-none-eabi \
@@ -15,7 +15,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mbig-endian \
 // RUN:   | FileCheck %s --check-prefix=CHECK-EB
-// CHECK-EB: 

[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-04-30 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

@peterwaller-arm half-done. Do *NOT* merge it now. It has still some problem.
See `clang/test/Driver/baremetal-multilib.yaml`.

There is still some `none-unknown`.

https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-04-30 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/89638

>From aafa018b3d7657483738fa91812e3e8bbdd8205a Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Sat, 27 Apr 2024 10:55:38 +0800
Subject: [PATCH 1/2] Triple::normalize: Use none as OS for XX-none-ABI

When we parse 3-components triples, if the Arch and Env have been
parsed successfully, we have to make a choice between Vendor and
OS for the unrecoginzed component. Noramlly it is the middle one.

In the current code, Vendor is choosed, and then OS is fallbacked
to unknown. It is OK for most cases. But if the unrecoginzed
component is `none`, it is expected to be OS instead of Vendor.

Fixes: #89582.
---
 clang/docs/Multilib.rst  | 4 ++--
 libcxx/utils/ci/run-buildbot | 2 +-
 llvm/lib/TargetParser/Triple.cpp | 7 +++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index ab737e43b97d23..063fe9a336f2fe 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -188,9 +188,9 @@ For a more comprehensive example see
   - Dir: thumb/v6-m
 # List of one or more normalized command line options, as generated by 
Clang
 # from the command line options or from Mappings below.
-# Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi}
+# Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi}
 # then this multilib variant will be considered a match.
-Flags: [--target=thumbv6m-none-unknown-eabi]
+Flags: [--target=thumbv6m-unknown-none-eabi]
 
   # Similarly, a multilib variant targeting Arm v7-M with an FPU (floating
   # point unit).
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 60307a7d4f350a..3523a29e4f4613 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -217,7 +217,7 @@ function test-armv7m-picolibc() {
 "${@}"
 
 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
-mv "${BUILD_DIR}/install/lib/armv7m-none-unknown-eabi"/* 
"${BUILD_DIR}/install/lib"
+mv "${BUILD_DIR}/install/lib/armv7m-unknown-none-eabi"/* 
"${BUILD_DIR}/install/lib"
 
 check-runtimes
 }
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 2c5aee3dfb2f3e..9c04574fe1e4bc 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1151,6 +1151,13 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // For 3-component triples, the middle component is used to set Vendor;
+  // while if it is "none", we'd prefer to set OS.
+  // This is for some baremetal cases, such as "arm-none-elf".
+  if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
+  Components[1].equals("none") && Components[2].empty())
+std::swap(Components[1], Components[2]);
+
   // Replace empty components with "unknown" value.
   for (StringRef  : Components)
 if (C.empty())

>From 56e8fd7fa124cedef134100174f8d7e6f1779a55 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Wed, 1 May 2024 08:44:09 +0800
Subject: [PATCH 2/2] fix test failures

---
 clang/test/Driver/arm-ias-Wa.s |  2 +-
 clang/test/Driver/arm-triple.c | 10 +-
 clang/test/Driver/baremetal-multilib-layered.yaml  |  2 +-
 clang/test/Driver/baremetal-multilib.yaml  |  8 
 clang/test/Driver/baremetal-sysroot.cpp|  2 +-
 clang/test/Driver/baremetal.cpp|  2 +-
 clang/test/Driver/print-multi-selection-flags.c|  2 +-
 .../Interpreter/IncrementalCompilerBuilderTest.cpp |  2 +-
 llvm/unittests/TargetParser/TripleTest.cpp |  2 +-
 9 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/clang/test/Driver/arm-ias-Wa.s b/clang/test/Driver/arm-ias-Wa.s
index b82ce8dfb31ab3..5e9518ed2dc423 100644
--- a/clang/test/Driver/arm-ias-Wa.s
+++ b/clang/test/Driver/arm-ias-Wa.s
@@ -71,7 +71,7 @@
 
 // RUN: %clang -target armv7r-none-eabi -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-R-PROFILE %s
-// CHECK-R-PROFILE: "-triple" "armv7r-none-unknown-eabi"
+// CHECK-R-PROFILE: "-triple" "armv7r-unknown-none-eabi"
 
 // RUN: %clang -target armv7m-none-eabi -c %s -### 2>&1 \
 // RUN: %clang -target thumbv7m-none-eabi -c %s -### 2>&1 \
diff --git a/clang/test/Driver/arm-triple.c b/clang/test/Driver/arm-triple.c
index fa9f7b189c8278..1fb2b5afe22a51 100644
--- a/clang/test/Driver/arm-triple.c
+++ b/clang/test/Driver/arm-triple.c
@@ -7,7 +7,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabihf -march=armv4t -mfloat-abi=softfp \
 // RUN:   | FileCheck %s --check-prefix=CHECK-DEFAULT
-// CHECK-DEFAULT: armv4t-none-unknown-eabi
+// CHECK-DEFAULT: armv4t-unknown-none-eabi
 
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=armeb-none-eabi \
@@ -15,7 +15,7 @@
 // RUN: %clang -print-effective-triple \
 // RUN:   --target=arm-none-eabi -mbig-endian \
 // 

[clang] [lld] [llvm] Test: Fix tests for normalization of triple XXX-none-ABI. NFC (PR #90313)

2024-04-26 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

Blocked by https://github.com/llvm/llvm-project/pull/89638

https://github.com/llvm/llvm-project/pull/90313
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lld] [llvm] Test: Fix tests for normalization of triple XXX-none-ABI. NFC (PR #90313)

2024-04-26 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa converted_to_draft 
https://github.com/llvm/llvm-project/pull/90313
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lld] [llvm] Test: Fix tests for normalization of triple XXX-none-ABI. NFC (PR #90313)

2024-04-26 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa created 
https://github.com/llvm/llvm-project/pull/90313

https://discourse.llvm.org/t/rfc-baremetal-target-triple-normalization/78524

See: PR#89638.

>From 28b918f8a67381cd568c85bae77af517091a32b4 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Sat, 27 Apr 2024 13:14:02 +0800
Subject: [PATCH] Test: Fix tests for normalization of triple XXX-none-ABI. NFC

https://discourse.llvm.org/t/rfc-baremetal-target-triple-normalization/78524
See: PR#89638.
---
 .../test/CodeGen/Inputs/linker-diagnostic1.ll |  2 +-
 clang/test/CodeGen/linker-diagnostic.ll   |  4 +-
 clang/test/Driver/arm-ias-Wa.s|  2 +-
 clang/test/Driver/arm-triple.c| 10 +--
 .../baremetal-multilib-exclusive-group.yaml   | 22 +++
 .../baremetal-multilib-group-error.yaml   |  4 +-
 .../Driver/baremetal-multilib-layered.yaml|  2 +-
 clang/test/Driver/baremetal-multilib.yaml | 64 +--
 clang/test/Driver/baremetal-sysroot.cpp   |  2 +-
 clang/test/Driver/baremetal.cpp   |  2 +-
 .../test/Driver/print-multi-selection-flags.c | 14 ++--
 clang/test/Preprocessor/init-arm.c|  4 +-
 clang/unittests/Driver/MultilibTest.cpp   | 52 +++
 .../IncrementalCompilerBuilderTest.cpp|  2 +-
 lld/test/ELF/lto/arm.ll   |  4 +-
 .../CodeGen/ARM/machine-sink-multidef.mir |  2 +-
 llvm/test/CodeGen/ARM/store-prepostinc.mir|  2 +-
 .../CodeGen/ARM/unschedule-reg-sequence.ll|  2 +-
 .../Thumb/consthoist-few-dependents.ll|  2 +-
 .../CodeGen/Thumb/consthoist-imm8-costs-1.ll  |  2 +-
 llvm/test/CodeGen/Thumb/pr42760.ll|  2 +-
 llvm/test/CodeGen/Thumb/smul_fix.ll   |  2 +-
 llvm/test/CodeGen/Thumb/smul_fix_sat.ll   |  2 +-
 llvm/test/CodeGen/Thumb/umul_fix.ll   |  2 +-
 llvm/test/CodeGen/Thumb/umul_fix_sat.ll   |  2 +-
 .../Thumb2/LowOverheadLoops/spillingmove.mir  |  2 +-
 .../LowOverheadLoops/wls-search-pred.mir  |  2 +-
 llvm/test/CodeGen/Thumb2/high-reg-spill.mir   |  2 +-
 .../CodeGen/Thumb2/mve-pred-constfold.mir |  2 +-
 .../CodeGen/Thumb2/mve-vpt-block-debug.mir|  2 +-
 .../Thumb2/pipeliner-preserve-ties.mir|  2 +-
 llvm/test/CodeGen/Thumb2/store-prepostinc.mir |  2 +-
 .../InferFunctionAttrs/norecurse_debug.ll |  2 +-
 .../ARM/mve-hoist-runtime-checks.ll   |  2 +-
 llvm/unittests/TargetParser/TripleTest.cpp|  2 +-
 35 files changed, 115 insertions(+), 115 deletions(-)

diff --git a/clang/test/CodeGen/Inputs/linker-diagnostic1.ll 
b/clang/test/CodeGen/Inputs/linker-diagnostic1.ll
index 913dbefe5ccec9..96883aa26cffed 100644
--- a/clang/test/CodeGen/Inputs/linker-diagnostic1.ll
+++ b/clang/test/CodeGen/Inputs/linker-diagnostic1.ll
@@ -1,4 +1,4 @@
-target triple = "armv4-none-unknown-eabi"
+target triple = "armv4-unknown-none-eabi"
 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
 
 declare i32 @foo(i32)
diff --git a/clang/test/CodeGen/linker-diagnostic.ll 
b/clang/test/CodeGen/linker-diagnostic.ll
index c8406314f8d6fd..009819b464fe50 100644
--- a/clang/test/CodeGen/linker-diagnostic.ll
+++ b/clang/test/CodeGen/linker-diagnostic.ll
@@ -4,10 +4,10 @@
 ; RUN: opt -module-summary -o %t/bar.o %S/Inputs/linker-diagnostic1.ll
 ; RUN: llvm-lto2 run --thinlto-distributed-indexes -r %t/foo.o,foo,plx -r 
%t/bar.o,bar,plx \
 ; RUN:   -r %t/bar.o,foo, -o %t/foobar.so %t/foo.o %t/bar.o
-; RUN: %clang -c -o %t/lto.bar.o --target=armv4-none-unknown-eabi -O2 \
+; RUN: %clang -c -o %t/lto.bar.o --target=armv4-unknown-none-eabi -O2 \
 ; RUN:   -fthinlto-index=%t/bar.o.thinlto.bc %t/bar.o -Wno-override-module 
2>&1 | FileCheck %s
 
-; CHECK: linking module '{{.*}}/bar.o': Linking two modules of different 
target triples: '{{.*}}/foo.o' is 'thumbv6-unknown-linux-gnueabihf' whereas 
'{{.*}}/bar.o' is 'armv4-none-unknown-eabi'
+; CHECK: linking module '{{.*}}/bar.o': Linking two modules of different 
target triples: '{{.*}}/foo.o' is 'thumbv6-unknown-linux-gnueabihf' whereas 
'{{.*}}/bar.o' is 'armv4-unknown-none-eabi'
 
 target triple = "thumbv6-unknown-linux-gnueabihf"
 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
diff --git a/clang/test/Driver/arm-ias-Wa.s b/clang/test/Driver/arm-ias-Wa.s
index b82ce8dfb31ab3..5e9518ed2dc423 100644
--- a/clang/test/Driver/arm-ias-Wa.s
+++ b/clang/test/Driver/arm-ias-Wa.s
@@ -71,7 +71,7 @@
 
 // RUN: %clang -target armv7r-none-eabi -c %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-R-PROFILE %s
-// CHECK-R-PROFILE: "-triple" "armv7r-none-unknown-eabi"
+// CHECK-R-PROFILE: "-triple" "armv7r-unknown-none-eabi"
 
 // RUN: %clang -target armv7m-none-eabi -c %s -### 2>&1 \
 // RUN: %clang -target thumbv7m-none-eabi -c %s -### 2>&1 \
diff --git a/clang/test/Driver/arm-triple.c b/clang/test/Driver/arm-triple.c
index fa9f7b189c8278..1fb2b5afe22a51 100644
--- a/clang/test/Driver/arm-triple.c
+++ b/clang/test/Driver/arm-triple.c
@@ -7,7 +7,7 @@
 // 

[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-04-26 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa edited 
https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [llvm] Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-04-26 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa edited 
https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [llvm] Triple::normalize: Triple::normalize: Use none as OS for XX-none-ABI (PR #89638)

2024-04-26 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa edited 
https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [llvm] Triple::normalize: Set OS for 3-component triple with none as middle (PR #89638)

2024-04-26 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa edited 
https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [llvm] Triple::normalize: Set OS for 3-component triple with none as middle (PR #89638)

2024-04-26 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa ready_for_review 
https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [llvm] Triple::normalize: Set OS for 3-component triple with none as middle (PR #89638)

2024-04-26 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/89638

>From aafa018b3d7657483738fa91812e3e8bbdd8205a Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Sat, 27 Apr 2024 10:55:38 +0800
Subject: [PATCH] Triple::normalize: Use none as OS for XX-none-ABI

When we parse 3-components triples, if the Arch and Env have been
parsed successfully, we have to make a choice between Vendor and
OS for the unrecoginzed component. Noramlly it is the middle one.

In the current code, Vendor is choosed, and then OS is fallbacked
to unknown. It is OK for most cases. But if the unrecoginzed
component is `none`, it is expected to be OS instead of Vendor.

Fixes: #89582.
---
 clang/docs/Multilib.rst  | 4 ++--
 libcxx/utils/ci/run-buildbot | 2 +-
 llvm/lib/TargetParser/Triple.cpp | 7 +++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index ab737e43b97d23..063fe9a336f2fe 100644
--- a/clang/docs/Multilib.rst
+++ b/clang/docs/Multilib.rst
@@ -188,9 +188,9 @@ For a more comprehensive example see
   - Dir: thumb/v6-m
 # List of one or more normalized command line options, as generated by 
Clang
 # from the command line options or from Mappings below.
-# Here, if the flags are a superset of {target=thumbv6m-none-unknown-eabi}
+# Here, if the flags are a superset of {target=thumbv6m-unknown-none-eabi}
 # then this multilib variant will be considered a match.
-Flags: [--target=thumbv6m-none-unknown-eabi]
+Flags: [--target=thumbv6m-unknown-none-eabi]
 
   # Similarly, a multilib variant targeting Arm v7-M with an FPU (floating
   # point unit).
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 60307a7d4f350a..3523a29e4f4613 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -217,7 +217,7 @@ function test-armv7m-picolibc() {
 "${@}"
 
 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
-mv "${BUILD_DIR}/install/lib/armv7m-none-unknown-eabi"/* 
"${BUILD_DIR}/install/lib"
+mv "${BUILD_DIR}/install/lib/armv7m-unknown-none-eabi"/* 
"${BUILD_DIR}/install/lib"
 
 check-runtimes
 }
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 2c5aee3dfb2f3e..9c04574fe1e4bc 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1151,6 +1151,13 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // For 3-component triples, the middle component is used to set Vendor;
+  // while if it is "none", we'd prefer to set OS.
+  // This is for some baremetal cases, such as "arm-none-elf".
+  if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
+  Components[1].equals("none") && Components[2].empty())
+std::swap(Components[1], Components[2]);
+
   // Replace empty components with "unknown" value.
   for (StringRef  : Components)
 if (C.empty())

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


[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-04-23 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

> 
> Sure. The motivation on our side is a distributed compile service where the 
> library doesn't exist on the remote end. This patch means we'll have to add 
> knowledge about path layouts at link time to the remote setup at compile 
> time. That's certainly doable, but kind of janky.
> 

I guess `using new-style always` can make things simpler. Since you won't need 
to know how to convert the target name to tail arch name. For every arch, it 
uses the same archive file name.

Does your `distributed compile service` is like:
1. Use upload C/C++ code
2. Your service compiles them to ASM code.
3. User downloads the ASM code
4. User assembles and link
If so, it will always have a trouble for any case, as the archive's filename 
differs between users local setup.
I think that problem is a chaos during the transition.
In fact, a filename like `clang_rt.profile-x86_64.lib` also contains info about 
path layout at compile time.
What you really need is an option for user to tell us their local path layout.

https://github.com/llvm/llvm-project/pull/87866
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [lld] [llvm] Triple::normalize: Set OS for 3-component triple with none as middle (PR #89638)

2024-04-23 Thread YunQiang Su via cfe-commits


@@ -1149,6 +1149,13 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // For 3-component triples, the middle component is used to set Vendor;
+  // while if it is "none", we'd prefer to set OS.
+  // This is for some baremetal cases, such as "arm-none-elf".
+  if (Found[0] && !Found[1] && !Found[2] && Found[3] &&
+  Components[1].equals("none") && Components[2].empty())
+std::swap(Components[1], Components[2]);

wzssyqa wrote:

Sure. we can. I think that we may need more update to `Triple::normalize`. Once 
we can decide how to normalize `aarch64-none-elf`, then I will split this PR.

https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [lld] [llvm] Triple::normalize: Set OS for 3-component triple with none as middle (PR #89638)

2024-04-23 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

> I've just posted an RFC to discourse about how to handle triple 
> normalization: 
> https://discourse.llvm.org/t/rfc-baremetal-target-triple-normalization/78524

We don't need to revert https://github.com/llvm/llvm-project/pull/89234
It is easy to fix `Triple::normalize` once you decide how to normalize your 
triples.
I will help to do so.

https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-04-23 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

Will the contents of `empty.asm` correct if `lib//clang_rt.profile.lib` 
doesn't exist?
I mean, will `empty.asm` contains `/DEFAULTLIB:clang_rt.profile-x86_64.lib` 
then?

https://github.com/llvm/llvm-project/pull/87866
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [lld] [llvm] Triple::normalize: Set OS for 3-component triple with none as middle (PR #89638)

2024-04-23 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

@llvm/pr-subscribers-backend-arm @llvm/pr-subscribers-backend-aarch64 

https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [lld] [llvm] Triple::normalize: Set OS for 3-component triple with none as middle (PR #89638)

2024-04-23 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/89638

>From 11ae27aeb512b661a3423a8b92642a9ec08ca6a1 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Tue, 23 Apr 2024 01:36:17 +0800
Subject: [PATCH] Triple::normalize: Set OS for 3-component triple with none as
 middle

If the middle component of a 3-component triple fails to parse as known
Arch/Vendor/OS/Env, it will fallback as Vendor. While for some cases,
we may wish to recognize it as OS, such as `arm64-none-elf`.

In this patch, we will set OS as `none`, if:
1) Arch is found;
2) Env is found;
3) OS is not found and thus is set as empty;
4) Vendor is not found while is set as "none",
we will swap Component[2] and Component[3].

Use this new triple for these tests:
  - clang/docs/Multilib.rst
  - clang/test/CodeGen/Inputs/linker-diagnostic1.ll
  - clang/test/CodeGen/linker-diagnostic.ll
  - clang/test/Driver/arm-ias-Wa.s
  - clang/test/Driver/arm-triple.c
  - clang/test/Driver/baremetal-multilib-exclusive-group.yaml
  - clang/test/Driver/baremetal-multilib-group-error.yaml
  - clang/test/Driver/baremetal-multilib-layered.yaml
  - clang/test/Driver/baremetal-multilib.yaml
  - clang/test/Driver/baremetal-sysroot.cpp
  - clang/test/Driver/baremetal.cpp
  - clang/test/Driver/print-multi-selection-flags.c
  - clang/test/Driver/program-path-priority.c
  - clang/test/Preprocessor/init-arm.c
  - clang/unittests/Driver/MultilibTest.cpp
  - clang/unittests/Interpreter/IncrementalCompilerBuilderTest.cpp
  - libcxx/utils/ci/run-buildbot
  - lld/test/ELF/lto/arm.ll
  - llvm/test/CodeGen/ARM/machine-sink-multidef.mir
  - llvm/test/CodeGen/ARM/store-prepostinc.mir
  - llvm/test/CodeGen/ARM/unschedule-reg-sequence.ll
  - llvm/test/CodeGen/Thumb/consthoist-few-dependents.ll
  - llvm/test/CodeGen/Thumb/consthoist-imm8-costs-1.ll
  - llvm/test/CodeGen/Thumb/pr42760.ll
  - llvm/test/CodeGen/Thumb/smul_fix.ll
  - llvm/test/CodeGen/Thumb/smul_fix_sat.ll
  - llvm/test/CodeGen/Thumb/umul_fix.ll
  - llvm/test/CodeGen/Thumb/umul_fix_sat.ll
  - llvm/test/CodeGen/Thumb2/LowOverheadLoops/spillingmove.mir
  - llvm/test/CodeGen/Thumb2/LowOverheadLoops/wls-search-pred.mir
  - llvm/test/CodeGen/Thumb2/high-reg-spill.mir
  - llvm/test/CodeGen/Thumb2/mve-pred-constfold.mir
  - llvm/test/CodeGen/Thumb2/mve-vpt-block-debug.mir
  - llvm/test/CodeGen/Thumb2/pipeliner-preserve-ties.mir
  - llvm/test/CodeGen/Thumb2/store-prepostinc.mir
  - llvm/test/Transforms/InferFunctionAttrs/norecurse_debug.ll
  - llvm/test/Transforms/LoopVectorize/ARM/mve-hoist-runtime-checks.ll
  - llvm/unittests/TargetParser/TripleTest.cpp

Fixes: #89582.
---
 clang/docs/Multilib.rst   |  4 +-
 .../test/CodeGen/Inputs/linker-diagnostic1.ll |  2 +-
 clang/test/CodeGen/linker-diagnostic.ll   |  4 +-
 clang/test/Driver/arm-ias-Wa.s|  2 +-
 clang/test/Driver/arm-triple.c| 10 +--
 .../baremetal-multilib-exclusive-group.yaml   | 22 +++
 .../baremetal-multilib-group-error.yaml   |  4 +-
 .../Driver/baremetal-multilib-layered.yaml|  2 +-
 clang/test/Driver/baremetal-multilib.yaml | 64 +--
 clang/test/Driver/baremetal-sysroot.cpp   |  2 +-
 clang/test/Driver/baremetal.cpp   |  2 +-
 .../test/Driver/print-multi-selection-flags.c | 14 ++--
 clang/test/Driver/program-path-priority.c |  4 +-
 clang/test/Preprocessor/init-arm.c|  4 +-
 clang/unittests/Driver/MultilibTest.cpp   | 52 +++
 .../IncrementalCompilerBuilderTest.cpp|  2 +-
 libcxx/utils/ci/run-buildbot  |  2 +-
 lld/test/ELF/lto/arm.ll   |  4 +-
 llvm/lib/TargetParser/Triple.cpp  |  7 ++
 .../CodeGen/ARM/machine-sink-multidef.mir |  2 +-
 llvm/test/CodeGen/ARM/store-prepostinc.mir|  2 +-
 .../CodeGen/ARM/unschedule-reg-sequence.ll|  2 +-
 .../Thumb/consthoist-few-dependents.ll|  2 +-
 .../CodeGen/Thumb/consthoist-imm8-costs-1.ll  |  2 +-
 llvm/test/CodeGen/Thumb/pr42760.ll|  2 +-
 llvm/test/CodeGen/Thumb/smul_fix.ll   |  2 +-
 llvm/test/CodeGen/Thumb/smul_fix_sat.ll   |  2 +-
 llvm/test/CodeGen/Thumb/umul_fix.ll   |  2 +-
 llvm/test/CodeGen/Thumb/umul_fix_sat.ll   |  2 +-
 .../Thumb2/LowOverheadLoops/spillingmove.mir  |  2 +-
 .../LowOverheadLoops/wls-search-pred.mir  |  2 +-
 llvm/test/CodeGen/Thumb2/high-reg-spill.mir   |  2 +-
 .../CodeGen/Thumb2/mve-pred-constfold.mir |  2 +-
 .../CodeGen/Thumb2/mve-vpt-block-debug.mir|  2 +-
 .../Thumb2/pipeliner-preserve-ties.mir|  2 +-
 llvm/test/CodeGen/Thumb2/store-prepostinc.mir |  2 +-
 .../InferFunctionAttrs/norecurse_debug.ll |  2 +-
 .../ARM/mve-hoist-runtime-checks.ll   |  2 +-
 llvm/unittests/TargetParser/TripleTest.cpp|  2 +-
 39 files changed, 127 insertions(+), 120 deletions(-)

diff --git a/clang/docs/Multilib.rst b/clang/docs/Multilib.rst
index ab737e43b97d23..063fe9a336f2fe 

[clang] [libcxx] [llvm] Triple::normalize: Set OS for 3-component triple with none as middle (PR #89638)

2024-04-23 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa converted_to_draft 
https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [llvm] Triple::normalize: Set OS for 3-component triple with none as middle (PR #89638)

2024-04-23 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

@peterwaller-arm Ohh, there is so many `-none-unknown-` in current code. I 
guess it may be widely used.
Do we really want to change all of them?

https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [llvm] Triple::normalize: Set OS for 3-component triple with none as middle (PR #89638)

2024-04-23 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa edited 
https://github.com/llvm/llvm-project/pull/89638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [llvm] Triple::normalize: Set OS for 3-component triple with none as middle (PR #89638)

2024-04-23 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa updated 
https://github.com/llvm/llvm-project/pull/89638

>From a40bf92dcdaa64c2ca73d9276972c8cd47750210 Mon Sep 17 00:00:00 2001
From: YunQiang Su 
Date: Tue, 23 Apr 2024 01:36:17 +0800
Subject: [PATCH] Triple::normalize: Set OS for 3-component triple with none as
 middle

If the middle component of a 3-component triple fails to parse as known
Arch/Vendor/OS/Env, it will fallback as Vendor. While for some cases,
we may wish to recognize it as OS, such as `arm64-none-elf`.

In this patch, we will set OS as `none`, if:
1) Arch is found;
2) Env is found;
3) OS is not found and thus is set as empty;
4) Vendor is not found while is set as "none",
we will swap Component[2] and Component[3].

Use this new triple for these tests:
  - libcxx/utils/ci/run-buildbot
  - clang/test/Driver/print-multi-selection-flags.c
  - llvm/unittests/TargetParser/TripleTest.cpp

Fixes: #89582.
---
 clang/test/Driver/print-multi-selection-flags.c | 14 +++---
 libcxx/utils/ci/run-buildbot|  2 +-
 llvm/lib/TargetParser/Triple.cpp|  7 +++
 llvm/unittests/TargetParser/TripleTest.cpp  |  2 +-
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/clang/test/Driver/print-multi-selection-flags.c 
b/clang/test/Driver/print-multi-selection-flags.c
index 06a12db9d97792..9f58d1b557fd74 100644
--- a/clang/test/Driver/print-multi-selection-flags.c
+++ b/clang/test/Driver/print-multi-selection-flags.c
@@ -5,27 +5,27 @@
 // CHECK-FUCHSIA: --target=aarch64-unknown-fuchsia
 
 // RUN: %clang -print-multi-flags-experimental --target=arm-none-eabi 
-mfloat-abi=soft -fno-exceptions -fno-rtti | FileCheck 
--check-prefix=CHECK-ARMV4T %s
-// CHECK-ARMV4T: --target=armv4t-none-unknown-eabi
+// CHECK-ARMV4T: --target=armv4t-unknown-none-eabi
 // CHECK-ARMV4T: -mfloat-abi=soft
 // CHECK-ARMV4T: -mfpu=none
 
 // RUN: %clang -print-multi-flags-experimental --target=armv7em-none-eabi 
-mfloat-abi=softfp | FileCheck --check-prefix=CHECK-SOFTFP %s
-// CHECK-SOFTFP: --target=thumbv7em-none-unknown-eabi
+// CHECK-SOFTFP: --target=thumbv7em-unknown-none-eabi
 // CHECK-SOFTFP: -mfloat-abi=softfp
 // CHECK-SOFTFP: -mfpu=fpv4-sp-d16
 
 // RUN: %clang -print-multi-flags-experimental --target=arm-none-eabihf 
-march=armv7em -mfpu=fpv5-d16 | FileCheck --check-prefix=CHECK-HARD %s
-// CHECK-HARD: --target=thumbv7em-none-unknown-eabihf
+// CHECK-HARD: --target=thumbv7em-unknown-none-eabihf
 // CHECK-HARD: -mfloat-abi=hard
 // CHECK-HARD: -mfpu=fpv5-d16
 
 // RUN: %clang -print-multi-flags-experimental --target=arm-none-eabi 
-mfloat-abi=soft -march=armv8-m.main+nofp | FileCheck 
--check-prefix=CHECK-V8MMAIN-NOFP %s
-// CHECK-V8MMAIN-NOFP: --target=thumbv8m.main-none-unknown-eabi
+// CHECK-V8MMAIN-NOFP: --target=thumbv8m.main-unknown-none-eabi
 // CHECK-V8MMAIN-NOFP: -mfloat-abi=soft
 // CHECK-V8MMAIN-NOFP: -mfpu=none
 
 // RUN: %clang -print-multi-flags-experimental --target=arm-none-eabi 
-mfloat-abi=hard -march=armv8.1m.main+mve.fp | FileCheck 
--check-prefix=CHECK-MVE %s
-// CHECK-MVE: --target=thumbv8.1m.main-none-unknown-eabihf
+// CHECK-MVE: --target=thumbv8.1m.main-unknown-none-eabihf
 // CHECK-MVE: -march=thumbv8.1m.main{{.*}}+mve{{.*}}+mve.fp{{.*}}
 // CHECK-MVE: -mfloat-abi=hard
 // CHECK-MVE: -mfpu=fp-armv8-fullfp16-sp-d16
@@ -51,10 +51,10 @@
 // CHECK-M85_NO_FP_DP: -mfpu=fp-armv8-fullfp16-sp-d16
 
 // RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf 
-march=armv8-a+lse | FileCheck --check-prefix=CHECK-LSE %s
-// CHECK-LSE: --target=aarch64-none-unknown-elf
+// CHECK-LSE: --target=aarch64-unknown-none-elf
 // CHECK-LSE: -march=armv8-a{{.*}}+lse{{.*}}
 
 // RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf 
-march=armv8.5-a+sve+sve2 | FileCheck --check-prefix=CHECK-SVE2 %s
 // RUN: %clang -print-multi-flags-experimental --target=aarch64-none-elf 
-march=armv9-a| FileCheck --check-prefix=CHECK-SVE2 %s
-// CHECK-SVE2: --target=aarch64-none-unknown-elf
+// CHECK-SVE2: --target=aarch64-unknown-none-elf
 // CHECK-SVE2: -march=armv{{.*}}-a{{.*}}+simd{{.*}}+sve{{.*}}+sve2{{.*}}
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index 60307a7d4f350a..3523a29e4f4613 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -217,7 +217,7 @@ function test-armv7m-picolibc() {
 "${@}"
 
 ${NINJA} -vC "${BUILD_DIR}/compiler-rt" install
-mv "${BUILD_DIR}/install/lib/armv7m-none-unknown-eabi"/* 
"${BUILD_DIR}/install/lib"
+mv "${BUILD_DIR}/install/lib/armv7m-unknown-none-eabi"/* 
"${BUILD_DIR}/install/lib"
 
 check-runtimes
 }
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 77fdf31d4865c0..07f3df4145dad4 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -1149,6 +1149,13 @@ std::string Triple::normalize(StringRef Str) {
 }
   }
 
+  // For 3-component triples, 

[clang] [Driver] Improve error when a compiler-rt library is not found (PR #81037)

2024-04-22 Thread YunQiang Su via cfe-commits


@@ -656,19 +656,29 @@ std::string ToolChain::getCompilerRT(const ArgList , 
StringRef Component,
   // Check for runtime files in the new layout without the architecture first.
   std::string CRTBasename =
   buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false);
+  SmallString<128> Path;
   for (const auto  : getLibraryPaths()) {
 SmallString<128> P(LibPath);
 llvm::sys::path::append(P, CRTBasename);
 if (getVFS().exists(P))
   return std::string(P);
+if (Path.empty())
+  Path = P;
   }
+  if (getTriple().isOSAIX())
+Path.clear();
 
-  // Fall back to the old expected compiler-rt name if the new one does not
-  // exist.
+  // Check the filename for the old layout if the new one does not exist.
   CRTBasename =
   buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/true);
-  SmallString<128> Path(getCompilerRTPath());
-  llvm::sys::path::append(Path, CRTBasename);
+  SmallString<128> OldPath(getCompilerRTPath());
+  llvm::sys::path::append(OldPath, CRTBasename);
+  if (Path.empty() || getVFS().exists(OldPath))
+return std::string(OldPath);
+
+  // If none is found, use a file name from the new layout, which may get
+  // printed in an error message, aiding users in knowing what Clang is
+  // looking for.

wzssyqa wrote:

It is only about warning msg.
Clang will try to find libraries for both new and old style paths.

If you'd like to put the libraries in old style path/filename, you can use 
`-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF`.

Of course, even with the above configure option, if clang cannot find a 
library, it will warn with new style path.

https://github.com/llvm/llvm-project/pull/81037
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-04-19 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa edited 
https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-04-19 Thread YunQiang Su via cfe-commits


@@ -28,6 +28,19 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   if (NOT LLVM_RUNTIMES_BUILD)
 load_llvm_config()
   endif()
+  if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+set(print_target_triple ${CMAKE_CXX_COMPILER} 
--target=${LLVM_RUNTIME_TRIPLE} -print-target-triple)

wzssyqa wrote:

I am wondering that whether `CMAKE_CXX_COMPILER` is defined for 
`compiler-rt/lib/builtins`.
All source of this library is pure C/ASM.

In fact when I worked on my PR, I did meet this problem.
My configure cmd is
```
cmake ../llvm -G Ninja -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=off 
-DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu -DLLVM_USE_LINKER=lld 
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind" 
-DLLVM_ENABLE_PROJECTS="mlir;clang;clang-tools-extra;lld" 
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ 
-DCMAKE_BUILD_TYPE=RelWithDebInfo
```

https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-04-19 Thread YunQiang Su via cfe-commits


@@ -28,6 +28,19 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   if (NOT LLVM_RUNTIMES_BUILD)
 load_llvm_config()
   endif()
+  if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)

wzssyqa wrote:

With my patch, `libclang_rt.builtin` has been installed to per_target runtime 
dir.
I don't think that this one is needed.

And `if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` is not needed here: it is just set 
the triple.
If `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=off`, the libraries will still install 
to non-per-target dir.

And `if(NOT APPLE)` is not needed either.
```
$ ./bin/clang --target=air64-apple-ios16.0 -print-target-triple  
air64-apple-ios16.0
$ ./bin/clang --target=arm64-apple-darwin23.4.0 -print-target-triple  
arm64-apple-darwin23.4.0
```

https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-04-19 Thread YunQiang Su via cfe-commits


@@ -181,6 +181,20 @@ message(STATUS "LLVM default target triple: 
${LLVM_DEFAULT_TARGET_TRIPLE}")
 
 set(LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
 
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+  set(print_target_triple ${CMAKE_CXX_COMPILER} 
--target=${LLVM_RUNTIME_TRIPLE} -print-target-triple)
+  execute_process(COMMAND ${print_target_triple}
+RESULT_VARIABLE result
+OUTPUT_VARIABLE output
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+  if(result EQUAL 0)
+set(LLVM_RUNTIME_TRIPLE ${output})

wzssyqa wrote:

`LLVM_RUNTIME_TRIPLE` seem to be not used? I cannot find this symbol by `grep`.

https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-04-19 Thread YunQiang Su via cfe-commits


@@ -142,7 +142,7 @@ if(WIN32 OR LLVM_WINSYSROOT)
   set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS ${WINDOWS_LINK_FLAGS} CACHE 
STRING "")
 endif()
 
-foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;riscv64-unknown-linux-gnu;x86_64-unknown-linux-gnu)
+foreach(target 
aarch64-linux-gnu;armv7-linux-gnueabihf;i386-linux-gnu;riscv64-linux-gnu;x86_64-linux-gnu)

wzssyqa wrote:

It seems offtopic of commit msg?
Since the normalize format of `aarch64-linux-gnu` is just 
aarch64-unknown-linux-gnu, why do we need to modify them?

https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-04-19 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-04-19 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa edited 
https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [CMake] Use Clang to infer the target triple (PR #89425)

2024-04-19 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

Does it really needed?

https://github.com/llvm/llvm-project/pull/89425
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-04-16 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

See: https://github.com/llvm/llvm-project/pull/87866
Can you have a try to add an extra option
```
-resource-dir=%S/Inputs/resource_dir
```

https://github.com/llvm/llvm-project/pull/87866
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #88661)

2024-04-15 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa closed 
https://github.com/llvm/llvm-project/pull/88661
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #88661)

2024-04-15 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

9f43a41db37253685c5ed428c215528eb92bbd43
1693009679313282afbed38778dd3fad62641e1b

Landed as the above commits.

https://github.com/llvm/llvm-project/pull/88661
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #88661)

2024-04-14 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa edited 
https://github.com/llvm/llvm-project/pull/88661
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-04-14 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

New PR with my resource-dir patch: 
https://github.com/llvm/llvm-project/pull/88661

https://github.com/llvm/llvm-project/pull/87866
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #88661)

2024-04-14 Thread YunQiang Su via cfe-commits

https://github.com/wzssyqa created 
https://github.com/llvm/llvm-project/pull/88661

Follow-up to #81037.

ToolChain::LibraryPaths holds the new compiler-rt library directory (e.g. 
`/tmp/Debug/lib/clang/19/lib/x86_64-unknown-linux-gnu`). However, it might be 
empty when the directory does not exist (due to the `if (getVFS().exists(P))` 
change in https://reviews.llvm.org/D158475).

If neither the old/new compiler-rt library directories exists, we would suggest 
the undesired old compiler-rt file name:

```
% /tmp/Debug/bin/clang++ a.cc -fsanitize=memory -o a
ld.lld: error: cannot open 
/tmp/Debug/lib/clang/19/lib/linux/libclang_rt.msan-x86_64.a: No such file or 
directory
clang++: error: linker command failed with exit code 1 (use -v to see 
invocation)
```

With this change, we will correctly suggest the new compiler-rt file name.

Fix #87150

Pull Request: https://github.com/llvm/llvm-project/pull/87866

>From b8b5c72fefe3e9cbd9782727df75c8bb6eaeec2f Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Mon, 8 Apr 2024 16:51:34 -0700
Subject: [PATCH] Ensure ToolChain::LibraryPaths is not empty for non-Darwin

Follow-up to #81037.

ToolChain::LibraryPaths holds the new compiler-rt library directory
(e.g. `/tmp/Debug/lib/clang/19/lib/x86_64-unknown-linux-gnu`). However,
it might be empty when the directory does not exist (due to the `if
(getVFS().exists(P))` change in https://reviews.llvm.org/D158475).

If neither the old/new compiler-rt library directories exists, we would
suggest the undesired old compiler-rt file name:

```
% /tmp/Debug/bin/clang++ a.cc -fsanitize=memory -o a
ld.lld: error: cannot open 
/tmp/Debug/lib/clang/19/lib/linux/libclang_rt.msan-x86_64.a: No such file or 
directory
clang++: error: linker command failed with exit code 1 (use -v to see 
invocation)
```

With this change, we will correctly suggest the new compiler-rt file name.

Fix #87150

Pull Request: https://github.com/llvm/llvm-project/pull/87866
---
 clang/lib/Driver/ToolChain.cpp|  8 -
 clang/test/Driver/arm-compiler-rt.c   | 14 
 clang/test/Driver/cl-link.c   | 16 -
 clang/test/Driver/compiler-rt-unwind.c|  6 ++--
 clang/test/Driver/coverage-ld.c   |  8 ++---
 clang/test/Driver/instrprof-ld.c  | 16 -
 clang/test/Driver/linux-ld.c  |  8 +++--
 clang/test/Driver/mingw-sanitizers.c  | 16 -
 clang/test/Driver/msp430-toolchain.c  |  4 +--
 .../Driver/print-libgcc-file-name-clangrt.c   | 12 +++
 clang/test/Driver/print-runtime-dir.c |  6 
 clang/test/Driver/riscv32-toolchain-extra.c   |  6 ++--
 clang/test/Driver/riscv32-toolchain.c |  6 ++--
 clang/test/Driver/riscv64-toolchain-extra.c   |  6 ++--
 clang/test/Driver/riscv64-toolchain.c |  6 ++--
 clang/test/Driver/sanitizer-ld.c  | 36 +++
 clang/test/Driver/wasm-toolchain.c| 18 +-
 clang/test/Driver/wasm-toolchain.cpp  | 16 -
 clang/test/Driver/windows-cross.c | 18 +-
 clang/test/Driver/zos-ld.c| 12 +++
 .../test/Driver/msvc-dependent-lib-flags.f90  |  8 ++---
 21 files changed, 127 insertions(+), 119 deletions(-)

diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 03450fc0f57b93..237092ed07e5dc 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -796,7 +796,13 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
 std::optional ToolChain::getRuntimePath() const {
   SmallString<128> P(D.ResourceDir);
   llvm::sys::path::append(P, "lib");
-  return getTargetSubDirPath(P);
+  if (auto Ret = getTargetSubDirPath(P))
+return Ret;
+  // Darwin does not use per-target runtime directory.
+  if (Triple.isOSDarwin())
+return {};
+  llvm::sys::path::append(P, Triple.str());
+  return std::string(P);
 }
 
 std::optional ToolChain::getStdlibPath() const {
diff --git a/clang/test/Driver/arm-compiler-rt.c 
b/clang/test/Driver/arm-compiler-rt.c
index 5e9e528400d08e..cb6c29f48a7814 100644
--- a/clang/test/Driver/arm-compiler-rt.c
+++ b/clang/test/Driver/arm-compiler-rt.c
@@ -10,47 +10,47 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABI
-// ARM-GNUEABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
+// ARM-GNUEABI: "{{.*[/\\]}}libclang_rt.builtins.a"
 
 // RUN: %clang -target arm-linux-gnueabi \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -mfloat-abi=hard -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABI-ABI
-// ARM-GNUEABI-ABI: "{{.*[/\\]}}libclang_rt.builtins-armhf.a"
+// ARM-GNUEABI-ABI: "{{.*[/\\]}}libclang_rt.builtins.a"
 
 // RUN: %clang -target arm-linux-gnueabihf \
 // RUN: 

[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-04-11 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

[xx.patch](https://github.com/llvm/llvm-project/files/14948921/xx.patch)

@aeubanks can you help to test this patch?

https://github.com/llvm/llvm-project/pull/87866
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Look for compiler-rt from subdir given by --target (PR #88334)

2024-04-11 Thread YunQiang Su via cfe-commits

wzssyqa wrote:


> It's better to do some normalization in CMake.

I will try to work in CMake, then.

https://github.com/llvm/llvm-project/pull/88334
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-04-11 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

> > @aeubanks The problem is that in your configure, the libclang_rt is placed 
> > in `/lib/clang/19/lib/linux/libclang_rt.builtins-arm-android.a`, 
> > instead of 
> > `/lib/clang/19/lib/arm-unknown-linux-android/libclang_rt.builtins.a`.
> 
> The point is that both locations were supposed to be accepted, as they were 
> before - this PR was not supposed to be a policy change that affects that.

Yes. After the patch, both locations are accepted. This patch doesn't break it.
The current problem is that in some test cases, `-resource-dir` option are 
missing.

For details:
1. with `--sysroot` option, clang will try to find libclang_rt there. In the 
failure case, it fails to find.
2. then, clang try to look for libclang_rt from 
`lib/clang/19/lib/arm-unknown-android/libclang_rt.builtin.a`, and failed.
3. clang try to look for libclang_rt from 
`lib/clang/19/lib/linux/libclang_rt.builtin-arm-android.a`, and success.
 Thus the file name of libclang_rt is different with the one in test cases.
4. If 3) failed, clang will fallback to  
`lib/clang/19/lib/arm-unknown-android/libclang_rt.builtin.a`, then test case 
success.

So, we can add `-resource-dir` to skip 3 for test case.

   

https://github.com/llvm/llvm-project/pull/87866
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Look for compiler-rt from subdir given by --target (PR #88334)

2024-04-11 Thread YunQiang Su via cfe-commits

wzssyqa wrote:

Configure cmd
```
cmake ../llvm -G Ninja -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu 
-DLLVM_USE_LINKER=lld -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind" 
-DLLVM_ENABLE_PROJECTS="mlir;clang;clang-tools-extra;lld" 
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ 
-DCMAKE_BUILD_TYPE=RelWithDebInfo
```

Note, in `-DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu`,  there is no 
`unknown` aka vendor section.


With this configure, `libclang_rt.builtin.a` is present in 
```
./lib/clang/19/lib/aarch64-linux-gnu/
```

While clang expects it in
   ```
./lib/clang/19/lib/aarch64-unknown-linux-gnu/    Note "unknown"
```

The reason is that in `computeTargetTriple`, the line
```
llvm::Triple Target(llvm::Triple::normalize(TargetTriple));
```
convert the triple to normalize.

https://github.com/llvm/llvm-project/pull/88334
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >