[PATCH] D139723: [OpenMP][AMDGPU] Enable use of abs labs and llabs math functions in C code

2022-12-25 Thread Michał Górny via Phabricator via cfe-commits
mgorny reopened this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

In D139723#4004536 , @doru1004 wrote:

> Commit: 07ff3c5ccce68aed6c1a270b3f89ea14de7aa250 
> 

The added test fails on 32-bit platforms:

   TEST 'Clang :: Headers/amdgcn_openmp_device_math_c.c' 
FAILED 
  Script:
  --
  : 'RUN: at line 2';   
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/16/include
 -nostdsysteminc -internal-isystem 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/Headers/Inputs/include
 -x c -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -D__OFFLOAD_ARCH_gfx90a__ 
-emit-llvm-bc 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/Headers/amdgcn_openmp_device_math_c.c
 -o 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/test/Headers/Output/amdgcn_openmp_device_math_c.c.tmp-host.bc
  : 'RUN: at line 3';   
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/16/include
 -nostdsysteminc -include __clang_hip_runtime_wrapper.h -internal-isystem 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/Headers/../../lib/Headers/openmp_wrappers
 -include __clang_openmp_device_functions.h -internal-isystem 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/Headers/../../lib/Headers/openmp_wrappers
 -internal-isystem 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/Headers/Inputs/include
 -x c -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown 
-fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/Headers/amdgcn_openmp_device_math_c.c
 -fopenmp-is-device -fopenmp-host-ir-file-path 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/test/Headers/Output/amdgcn_openmp_device_math_c.c.tmp-host.bc
 -o - | /usr/lib/llvm/16/bin/FileCheck 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/Headers/amdgcn_openmp_device_math_c.c
 --check-prefixes=CHECK
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  + : 'RUN: at line 2'
  + 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/16/include
 -nostdsysteminc -internal-isystem 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/Headers/Inputs/include
 -x c -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -D__OFFLOAD_ARCH_gfx90a__ 
-emit-llvm-bc 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/Headers/amdgcn_openmp_device_math_c.c
 -o 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/test/Headers/Output/amdgcn_openmp_device_math_c.c.tmp-host.bc
  error: OpenMP target architecture 'amdgcn-amd-amdhsa' pointer size is 
incompatible with host 'i686-pc-linux-gnu'
  
  --
  
  

Please fix or revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139723

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


[PATCH] D139723: [OpenMP][AMDGPU] Enable use of abs labs and llabs math functions in C code

2022-12-25 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Also, please link commits to diffs using `Differential Revision:` trailer in 
the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139723

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


[PATCH] D140155: [Clang][OpenMP] Allow host call to nohost function with host variant

2022-12-25 Thread Michał Górny via Phabricator via cfe-commits
mgorny reopened this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

In D140155#4004505 , @doru1004 wrote:

> Commit 658ed9547cdd6657895339a6c390c31aa77a5698 
> 

The added test fails on 32-bit platforms:

  FAIL: Clang :: OpenMP/declare_target_nohost_variant_messages.cpp (10230 of 
16135)
   TEST 'Clang :: 
OpenMP/declare_target_nohost_variant_messages.cpp' FAILED 
  Script:
  --
  : 'RUN: at line 3';   
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/16/include
 -nostdsysteminc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa 
-fopenmp-version=52 -DVERBOSE_MODE=1 -verify=omp52 -fnoopenmp-use-tls 
-ferror-limit 100 -fopenmp-targets=amdgcn-amd-amdhsa -o - 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/OpenMP/declare_target_nohost_variant_messages.cpp
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  + : 'RUN: at line 3'
  + 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/clang
 -cc1 -internal-isystem 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/16/include
 -nostdsysteminc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa 
-fopenmp-version=52 -DVERBOSE_MODE=1 -verify=omp52 -fnoopenmp-use-tls 
-ferror-limit 100 -fopenmp-targets=amdgcn-amd-amdhsa -o - 
/var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/OpenMP/declare_target_nohost_variant_messages.cpp
  error: 'error' diagnostics seen but not expected: 
(frontend): OpenMP target architecture 'amdgcn-amd-amdhsa' pointer size is 
incompatible with host 'i686-pc-linux-gnu'
  
  --
  
  

Please fix, or ideally revert, fix and then commit properly linking to the diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140155

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


[PATCH] D139935: [NFC] [Doc] Fix example for AnnotateTypeDocs

2022-12-25 Thread Xiang Li via Phabricator via cfe-commits
python3kgae added a comment.

Merry Christmas and ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139935

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


[PATCH] D140661: [NFC][Clang] Reduce for-loop with SmallVectorUtility

2022-12-25 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: frasercrmck, luismarques, apazos, sameer.abuasal, 
s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

As topic, this commit reduces the for-loops with utilities of SmallVector.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140661

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Support/RISCVVIntrinsicUtils.cpp

Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -939,8 +939,7 @@
 // (void, op0 address, op1 address, ..., maskedoff0, maskedoff1, ...)
 PrototypeDescriptor MaskoffType = NewPrototype[1];
 MaskoffType.TM &= ~static_cast(TypeModifier::Pointer);
-for (unsigned I = 0; I < NF; ++I)
-  NewPrototype.insert(NewPrototype.begin() + NF + 1, MaskoffType);
+NewPrototype.insert(NewPrototype.begin() + NF + 1, NF, MaskoffType);
   }
 }
 // Erase passthru operand for TAM
@@ -983,8 +982,7 @@
   // (void, op0 address, op1 address, maskedoff0, maskedoff1, ...)
   PrototypeDescriptor MaskoffType = Prototype[1];
   MaskoffType.TM &= ~static_cast(TypeModifier::Pointer);
-  for (unsigned I = 0; I < NF; ++I)
-NewPrototype.insert(NewPrototype.begin() + NF + 1, MaskoffType);
+  NewPrototype.insert(NewPrototype.begin() + NF + 1, NF, MaskoffType);
 }
  }
 
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -848,8 +848,7 @@
 // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, vl)
 // intrinsic: (maskedoff0, ..., ptr, mask, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF + 1]);
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 2]);
@@ -867,8 +866,7 @@
 // TU builtin: (val0 address, ..., passthru0, ..., ptr, vl)
 // intrinsic: (passthru0, passthru1, ..., ptr, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 1]);
 } else {
@@ -927,8 +925,7 @@
 // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, new_vl, vl)
 // intrinsic: (maskedoff0, ..., ptr, mask, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF + 1]);
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 3]);
@@ -948,8 +945,7 @@
 // TU builtin: (val0 address, ..., passthru0, ..., ptr, new_vl, vl)
 // intrinsic: (passthru0, passthru1, ..., ptr, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 2]);
   NewVL = Ops[NF + 1];
@@ -1010,8 +1006,7 @@
 // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, stride, vl)
 // intrinsic: (maskedoff0, ..., ptr, stride, mask, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF + 1]);
   Operands.push_back(Ops[NF + 2]);
   Operands.push_back(Ops[NF]);
@@ -1031,8 +1026,7 @@
 // TU builtin: (val0 address, ..., passthru0, ..., ptr, stride, vl)
 // intrinsic: (passthru0, passthru1, ..., ptr, stride, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF]);
   O

[PATCH] D140155: [Clang][OpenMP] Allow host call to nohost function with host variant

2022-12-25 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D140155#4016274 , @mgorny wrote:

> In D140155#4004505 , @doru1004 
> wrote:
>
>> Commit 658ed9547cdd6657895339a6c390c31aa77a5698 
>> 
>
> The added test fails on 32-bit platforms:
>
>   FAIL: Clang :: OpenMP/declare_target_nohost_variant_messages.cpp (10230 of 
> 16135)
>    TEST 'Clang :: 
> OpenMP/declare_target_nohost_variant_messages.cpp' FAILED 
>   Script:
>   --
>   : 'RUN: at line 3';   
> /var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/clang
>  -cc1 -internal-isystem 
> /var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/16/include
>  -nostdsysteminc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa 
> -fopenmp-version=52 -DVERBOSE_MODE=1 -verify=omp52 -fnoopenmp-use-tls 
> -ferror-limit 100 -fopenmp-targets=amdgcn-amd-amdhsa -o - 
> /var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/OpenMP/declare_target_nohost_variant_messages.cpp
>   --
>   Exit Code: 1
>   
>   Command Output (stderr):
>   --
>   + : 'RUN: at line 3'
>   + 
> /var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/clang
>  -cc1 -internal-isystem 
> /var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/16/include
>  -nostdsysteminc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa 
> -fopenmp-version=52 -DVERBOSE_MODE=1 -verify=omp52 -fnoopenmp-use-tls 
> -ferror-limit 100 -fopenmp-targets=amdgcn-amd-amdhsa -o - 
> /var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/OpenMP/declare_target_nohost_variant_messages.cpp
>   error: 'error' diagnostics seen but not expected: 
> (frontend): OpenMP target architecture 'amdgcn-amd-amdhsa' pointer size 
> is incompatible with host 'i686-pc-linux-gnu'
>   
>   --
>   
>   
>
> Please fix, or ideally revert, fix and then commit properly linking to the 
> diff.

Should be a simple fix, someone needs to provide `--triple=` in the test line. 
A lot of the old tests used 64-bit PowerPC but it's not really important.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140155

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


[clang] f74e3d2 - [OpenMP] Fix test on 32-bit platforms

2022-12-25 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-12-25T09:47:04-06:00
New Revision: f74e3d2f81d2aae47d6032fc1d23114460d48a37

URL: 
https://github.com/llvm/llvm-project/commit/f74e3d2f81d2aae47d6032fc1d23114460d48a37
DIFF: 
https://github.com/llvm/llvm-project/commit/f74e3d2f81d2aae47d6032fc1d23114460d48a37.diff

LOG: [OpenMP] Fix test on 32-bit platforms

Summary:
This test didn't specify the triple so it defaulted to the user's, if
this was 32-bit then it failed due to a diagnostic message.

Added: 


Modified: 
clang/test/OpenMP/declare_target_nohost_variant_messages.cpp

Removed: 




diff  --git a/clang/test/OpenMP/declare_target_nohost_variant_messages.cpp 
b/clang/test/OpenMP/declare_target_nohost_variant_messages.cpp
index 190c1387cb099..62206d3020e96 100644
--- a/clang/test/OpenMP/declare_target_nohost_variant_messages.cpp
+++ b/clang/test/OpenMP/declare_target_nohost_variant_messages.cpp
@@ -1,6 +1,6 @@
 // REQUIRES: amdgpu-registered-target
 
-// RUN: %clang_cc1 -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa 
-fopenmp-version=52 -DVERBOSE_MODE=1 -verify=omp52 -fnoopenmp-use-tls 
-ferror-limit 100 -fopenmp-targets=amdgcn-amd-amdhsa -o - %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa 
-fopenmp-version=52 -triple powerpc64le-unknown-unknown -DVERBOSE_MODE=1 
-verify=omp52 -fnoopenmp-use-tls -ferror-limit 100 
-fopenmp-targets=amdgcn-amd-amdhsa -o - %s
 
 void fun();
 void host_function();



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


[PATCH] D140155: [Clang][OpenMP] Allow host call to nohost function with host variant

2022-12-25 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D140155#4016274 , @mgorny wrote:

> In D140155#4004505 , @doru1004 
> wrote:
>
>> Commit 658ed9547cdd6657895339a6c390c31aa77a5698 
>> 
>
> The added test fails on 32-bit platforms:
>
>   FAIL: Clang :: OpenMP/declare_target_nohost_variant_messages.cpp (10230 of 
> 16135)
>    TEST 'Clang :: 
> OpenMP/declare_target_nohost_variant_messages.cpp' FAILED 
>   Script:
>   --
>   : 'RUN: at line 3';   
> /var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/clang
>  -cc1 -internal-isystem 
> /var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/16/include
>  -nostdsysteminc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa 
> -fopenmp-version=52 -DVERBOSE_MODE=1 -verify=omp52 -fnoopenmp-use-tls 
> -ferror-limit 100 -fopenmp-targets=amdgcn-amd-amdhsa -o - 
> /var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/OpenMP/declare_target_nohost_variant_messages.cpp
>   --
>   Exit Code: 1
>   
>   Command Output (stderr):
>   --
>   + : 'RUN: at line 3'
>   + 
> /var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/clang
>  -cc1 -internal-isystem 
> /var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/x/y/clang-abi_x86_32.x86/bin/../../../../lib/clang/16/include
>  -nostdsysteminc -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa 
> -fopenmp-version=52 -DVERBOSE_MODE=1 -verify=omp52 -fnoopenmp-use-tls 
> -ferror-limit 100 -fopenmp-targets=amdgcn-amd-amdhsa -o - 
> /var/tmp/portage/sys-devel/clang-16.0.0_pre20221225/work/clang/test/OpenMP/declare_target_nohost_variant_messages.cpp
>   error: 'error' diagnostics seen but not expected: 
> (frontend): OpenMP target architecture 'amdgcn-amd-amdhsa' pointer size 
> is incompatible with host 'i686-pc-linux-gnu'
>   
>   --
>   
>   
>
> Please fix, or ideally revert, fix and then commit properly linking to the 
> diff.

Should be fixed in rGf74e3d2f81d2 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140155

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


[PATCH] D140662: [NFC][Clang][RISCV] Reduce boilerplate when determining prototype for segment loads

2022-12-25 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
eopXD added reviewers: craig.topper, kito-cheng, khchen.
Herald added subscribers: sunshaoce, VincentWu, StephenFan, vkmr, frasercrmck, 
evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, 
zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead.
Herald added a project: clang.

Depends on D140661 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140662

Files:
  clang/include/clang/Basic/riscv_vector.td

Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -843,39 +843,30 @@
   ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
   IntrinsicTypes = {ResultType, Ops.back()->getType()};
   SmallVector Operands;
-  if (IsMasked) {
-// TAMA builtin: (val0 address, ..., mask, ptr, vl)
-// builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, vl)
-// intrinsic: (maskedoff0, ..., ptr, mask, vl)
-if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  Operands.append(NF, llvm::PoisonValue::get(ResultType));
-  Operands.push_back(Ops[NF + 1]);
-  Operands.push_back(Ops[NF]);
-  Operands.push_back(Ops[NF + 2]);
-} else {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(Ops[NF + I + 1]);
-  Operands.push_back(Ops[2 * NF + 1]);
-  Operands.push_back(Ops[NF]);
-  Operands.push_back(Ops[2 * NF + 2]);
-}
+
+  // Intrinsic is in the form of below,
+  // Masked: (Vector0, ..., Vector{NF - 1}, Ptr, Mask, VL, Policy)
+  // Unmasked: (Vector0, ..., Vector{NF - 1}, Ptr, VL)
+  // where the Vectors is poison when the policy behavior allows us to not care
+  // about any masked-off elements.
+  Value *PassThruOperand = IsMasked ?
+(DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) ?
+  llvm::PoisonValue::get(ResultType) : Ops[NF + 1] :
+(DefaultPolicy == TAIL_AGNOSTIC) ?
+  llvm::PoisonValue::get(ResultType) : Ops[NF];
+  unsigned PtrOperandIdx = IsMasked ?
+(DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) ? NF + 1 : 2 * NF + 1 :
+(DefaultPolicy == TAIL_AGNOSTIC) ? NF : 2 * NF;
+  Value *PtrOperand = Ops[PtrOperandIdx];
+  Value *VLOperand = Ops[PtrOperandIdx + 1];
+  Operands.append(NF, PassThruOperand);
+  Operands.push_back(PtrOperand);
+  if (IsMasked)
+Operands.push_back(Ops[NF]);
+  Operands.push_back(VLOperand);
+  if (IsMasked)
 Operands.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy));
-assert(Operands.size() == NF + 4);
-  } else {
-// TA builtin: (val0 address, val1 address, ..., ptr, vl)
-// TU builtin: (val0 address, ..., passthru0, ..., ptr, vl)
-// intrinsic: (passthru0, passthru1, ..., ptr, vl)
-if (DefaultPolicy == TAIL_AGNOSTIC) {
-  Operands.append(NF, llvm::PoisonValue::get(ResultType));
-  Operands.push_back(Ops[NF]);
-  Operands.push_back(Ops[NF + 1]);
-} else {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(Ops[NF + I]);
-  Operands.push_back(Ops[2 * NF]);
-  Operands.push_back(Ops[2 * NF + 1]);
-}
-  }
+
   llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
   llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
   clang::CharUnits Align =
@@ -918,45 +909,31 @@
   ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
   IntrinsicTypes = {ResultType, Ops.back()->getType()};
   SmallVector Operands;
-  Value *NewVL;
 
-  if (IsMasked) {
-// TAMA builtin: (val0 address, ..., mask, ptr, new_vl, vl)
-// builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, new_vl, vl)
-// intrinsic: (maskedoff0, ..., ptr, mask, vl)
-if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  Operands.append(NF, llvm::PoisonValue::get(ResultType));
-  Operands.push_back(Ops[NF + 1]);
-  Operands.push_back(Ops[NF]);
-  Operands.push_back(Ops[NF + 3]);
-  NewVL = Ops[NF + 2];
-} else {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(Ops[NF + I + 1]);
-  Operands.push_back(Ops[2 * NF + 1]);
-  Operands.push_back(Ops[NF]);
-  Operands.push_back(Ops[2 * NF + 3]);
-  NewVL = Ops[2 * NF + 2];
-}
+  // Intrinsic is in the form of below,
+  // Masked: (Vector0, ..., Vector{NF - 1}, Ptr, Mask, NewVL, VL, Policy)

[PATCH] D140543: [clang-format] Add an option to format integer literal separators

2022-12-25 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

It was also failing on the official bots:
https://lab.llvm.org/buildbot/#/builders/109/builds/54291


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140543

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


[PATCH] D140290: [clang-tidy] Add misc-static-declaration-in-header check

2022-12-25 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 485235.
carlosgalvezp added a comment.

Warn only about cases where there really is a problem.
There are other cases which are just a readability issue,
where a separate check for "redundant static" would fit 
better. Remove also the automatic fix-it since it leads
to potentially broken code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140290

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/StaticDeclarationInHeaderCheck.cpp
  clang-tools-extra/clang-tidy/misc/StaticDeclarationInHeaderCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc/static-declaration-in-header.rst
  
clang-tools-extra/test/clang-tidy/checkers/misc/static-declaration-in-header.hpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc/static-declaration-in-header.hpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc/static-declaration-in-header.hpp
@@ -0,0 +1,40 @@
+// RUN: %check_clang_tidy %s misc-static-declaration-in-header %t
+
+static int v1 = 123;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: static declaration in header [misc-static-declaration-in-header]
+
+static void f1(){}
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: static declaration in header
+
+namespace foo {
+  static int v2 = 123;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: static declaration in header
+
+  static int f2(){}
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: static declaration in header
+}
+
+namespace {
+  static int v3 = 123;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: static declaration in header
+
+  static int f3(){}
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: static declaration in header
+}
+
+// OK
+struct Foo {
+  static const int v4 = 123;
+  static void f4(){}
+};
+
+// OK
+void f5() {
+  static int v5 = 123;
+}
+
+// OK, 'static' is only redundant (readability)
+static const int v6 = 123;
+static constexpr int v7 = 123;
+static constexpr int f6(){ return 123; }
+static inline void f7(){}
Index: clang-tools-extra/docs/clang-tidy/checks/misc/static-declaration-in-header.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc/static-declaration-in-header.rst
@@ -0,0 +1,57 @@
+.. title:: clang-tidy - misc-static-declaration-in-header
+
+misc-static-declaration-in-header
+=
+
+Warns about ``static`` variable and function declarations at file or namespace
+scope in header files.
+
+Header files are used to share code among different translation units. ``static``,
+on the other hand, can be used to express that a given declaration has internal
+linkage. Using ``static`` in header files leads to each translation unit creating
+their own internal copy of the function or variable at hand, which is problematic.
+This can cause unexpected results, bloat the resulting executable or even trigger
+one-definition-rule (ODR) violations.
+
+This problem is similar to having anonymous namespaces in header files, already
+covered by :doc:`google-build-namespaces`.
+
+Example of problematic code:
+
+.. code-block:: c++
+
+  // foo.h
+  static int x = 123;
+  static void f(){}
+
+The code should instead be changed to remove ``static`` from function and variable
+declarations in the header, and provide their definitions in a separate translation
+unit.
+
+.. code-block:: c++
+
+  // foo.h
+  int x;
+  void f();
+
+  // foo.cpp
+  int x = 123;
+  void f(){}
+
+Alternatively, functions (and variables in C++17) can be made ``inline``.
+
+.. code-block:: c++
+
+  // foo.h
+  inline int x = 123;  // Since C++17
+  inline void f(){}
+
+Options
+---
+
+.. option:: HeaderFileExtensions
+
+   A semicolon-separated list of filename extensions of header files (the filename
+   extensions should not include `.` prefix). Default is `;h;hh;hpp;hxx`.
+   For extension-less header files, using an empty string or leaving an
+   empty string between `;` if there are other filename extensions.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -254,6 +254,7 @@
`misc-non-private-member-variables-in-classes `_,
`misc-redundant-expression `_, "Yes"
`misc-static-assert `_, "Yes"
+   `misc-static-declaration-in-header `_,
`misc-throw-by-value-catch-by-reference `_,
`misc-unconventional-assign-operator `_,
`misc-uniqueptr-reset-release `_, "Yes"
Index: clang-tools-extra/docs/ReleaseNotes.rst
==

[PATCH] D140290: [clang-tidy] Add misc-static-declaration-in-header check

2022-12-25 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 485236.
carlosgalvezp added a comment.

Remove remaining function declaration in the check class.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140290

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/StaticDeclarationInHeaderCheck.cpp
  clang-tools-extra/clang-tidy/misc/StaticDeclarationInHeaderCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc/static-declaration-in-header.rst
  
clang-tools-extra/test/clang-tidy/checkers/misc/static-declaration-in-header.hpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc/static-declaration-in-header.hpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/misc/static-declaration-in-header.hpp
@@ -0,0 +1,40 @@
+// RUN: %check_clang_tidy %s misc-static-declaration-in-header %t
+
+static int v1 = 123;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: static declaration in header [misc-static-declaration-in-header]
+
+static void f1(){}
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: static declaration in header
+
+namespace foo {
+  static int v2 = 123;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: static declaration in header
+
+  static int f2(){}
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: static declaration in header
+}
+
+namespace {
+  static int v3 = 123;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: static declaration in header
+
+  static int f3(){}
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: static declaration in header
+}
+
+// OK
+struct Foo {
+  static const int v4 = 123;
+  static void f4(){}
+};
+
+// OK
+void f5() {
+  static int v5 = 123;
+}
+
+// OK, 'static' is only redundant (readability)
+static const int v6 = 123;
+static constexpr int v7 = 123;
+static constexpr int f6(){ return 123; }
+static inline void f7(){}
Index: clang-tools-extra/docs/clang-tidy/checks/misc/static-declaration-in-header.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc/static-declaration-in-header.rst
@@ -0,0 +1,57 @@
+.. title:: clang-tidy - misc-static-declaration-in-header
+
+misc-static-declaration-in-header
+=
+
+Warns about ``static`` variable and function declarations at file or namespace
+scope in header files.
+
+Header files are used to share code among different translation units. ``static``,
+on the other hand, can be used to express that a given declaration has internal
+linkage. Using ``static`` in header files leads to each translation unit creating
+their own internal copy of the function or variable at hand, which is problematic.
+This can cause unexpected results, bloat the resulting executable or even trigger
+one-definition-rule (ODR) violations.
+
+This problem is similar to having anonymous namespaces in header files, already
+covered by :doc:`google-build-namespaces`.
+
+Example of problematic code:
+
+.. code-block:: c++
+
+  // foo.h
+  static int x = 123;
+  static void f(){}
+
+The code should instead be changed to remove ``static`` from function and variable
+declarations in the header, and provide their definitions in a separate translation
+unit.
+
+.. code-block:: c++
+
+  // foo.h
+  int x;
+  void f();
+
+  // foo.cpp
+  int x = 123;
+  void f(){}
+
+Alternatively, functions (and variables in C++17) can be made ``inline``.
+
+.. code-block:: c++
+
+  // foo.h
+  inline int x = 123;  // Since C++17
+  inline void f(){}
+
+Options
+---
+
+.. option:: HeaderFileExtensions
+
+   A semicolon-separated list of filename extensions of header files (the filename
+   extensions should not include `.` prefix). Default is `;h;hh;hpp;hxx`.
+   For extension-less header files, using an empty string or leaving an
+   empty string between `;` if there are other filename extensions.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -254,6 +254,7 @@
`misc-non-private-member-variables-in-classes `_,
`misc-redundant-expression `_, "Yes"
`misc-static-assert `_, "Yes"
+   `misc-static-declaration-in-header `_,
`misc-throw-by-value-catch-by-reference `_,
`misc-unconventional-assign-operator `_,
`misc-uniqueptr-reset-release `_, "Yes"
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -118,6 +118,12 @@
 
   Warns when using ``do-while`` loops.
 
+- New :doc:`misc-static-declarat

[PATCH] D140543: [clang-format] Add an option to format integer literal separators

2022-12-25 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka reopened this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

Introduces memory bugs:
https://lab.llvm.org/buildbot/#/builders/5/builds/30234
https://lab.llvm.org/buildbot/#/builders/236/builds/1556


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140543

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


[PATCH] D140663: CUDA/HIP: Use kernel name to map to symbol

2022-12-25 Thread Daniele Castagna via Phabricator via cfe-commits
dcastagna created this revision.
Herald added subscribers: mattd, yaxunl.
Herald added a project: All.
dcastagna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently CGCUDANV uses an llvm::Function as a key to map kernels to a
symbol in host code.  HIP adds one level of indirection and uses the
llvm::Function to map to a global variable that will be initialized to
the kernel stub ptr.

Unfortunately there is no garantee that the llvm::Function created
by GetOrCreateLLVMFunction will be the same.  In fact, the first
time we encounter GetOrCrateLLVMFunction for a kernel, the type
might not be completed yet, and the type of llvm::Function will be
a generic {}, since the complete type is not required to get a symbol
to a function.  In this case we end up creating two global variables,
one for the llvm::Function with the incomplete type and one for the
function with the complete type. The first global variable will be
declared by not defined, resulting in a linking error.

This change uses the mangled name of the llvm::Function as key in the
KernelHandles map, in this way the same llvm::Function will be
associated to the same kernel handle even if they types are different.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140663

Files:
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/test/CodeGenCUDA/incomplete-func-ptr-type.cu

Index: clang/test/CodeGenCUDA/incomplete-func-ptr-type.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/incomplete-func-ptr-type.cu
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x hip %s -o - \
+// RUN: | FileCheck %s
+
+#define __global__ __attribute__((global))
+// CHECK: @_Z4kern7TempValIjE = constant ptr @_Z19__device_stub__kern7TempValIjE, align 8
+template 
+struct TempVal {
+  type value;
+};
+
+__global__ void kern(TempVal in_val);
+
+int main(int argc, char ** argv) {
+  auto* fptr = &(kern);
+// CHECK:   store ptr @_Z4kern7TempValIjE, ptr %fptr, align 8
+  return 0;
+}
+
+__global__ void kern(TempVal in_val) {
+}
+
Index: clang/lib/CodeGen/CGCUDANV.cpp
===
--- clang/lib/CodeGen/CGCUDANV.cpp
+++ clang/lib/CodeGen/CGCUDANV.cpp
@@ -49,10 +49,10 @@
 const Decl *D;
   };
   llvm::SmallVector EmittedKernels;
-  // Map a device stub function to a symbol for identifying kernel in host code.
+  // Map a kernel mangled name to a symbol for identifying kernel in host code
   // For CUDA, the symbol for identifying the kernel is the same as the device
   // stub function. For HIP, they are different.
-  llvm::DenseMap KernelHandles;
+  llvm::DenseMap KernelHandles;
   // Map a kernel handle to the kernel stub.
   llvm::DenseMap KernelStubs;
   struct VarInfo {
@@ -310,7 +310,8 @@
 void CGNVCUDARuntime::emitDeviceStub(CodeGenFunction &CGF,
  FunctionArgList &Args) {
   EmittedKernels.push_back({CGF.CurFn, CGF.CurFuncDecl});
-  if (auto *GV = dyn_cast(KernelHandles[CGF.CurFn])) {
+  if (auto *GV =
+  dyn_cast(KernelHandles[CGF.CurFn->getName()])) {
 GV->setLinkage(CGF.CurFn->getLinkage());
 GV->setInitializer(CGF.CurFn);
   }
@@ -400,8 +401,8 @@
ShmemSize.getPointer(), Stream.getPointer()});
 
   // Emit the call to cudaLaunch
-  llvm::Value *Kernel =
-  CGF.Builder.CreatePointerCast(KernelHandles[CGF.CurFn], VoidPtrTy);
+  llvm::Value *Kernel = CGF.Builder.CreatePointerCast(
+  KernelHandles[CGF.CurFn->getName()], VoidPtrTy);
   CallArgList LaunchKernelArgs;
   LaunchKernelArgs.add(RValue::get(Kernel),
cudaLaunchKernelFD->getParamDecl(0)->getType());
@@ -456,8 +457,8 @@
 
   // Emit the call to cudaLaunch
   llvm::FunctionCallee cudaLaunchFn = getLaunchFn();
-  llvm::Value *Arg =
-  CGF.Builder.CreatePointerCast(KernelHandles[CGF.CurFn], CharPtrTy);
+  llvm::Value *Arg = CGF.Builder.CreatePointerCast(
+  KernelHandles[CGF.CurFn->getName()], CharPtrTy);
   CGF.EmitRuntimeCallOrInvoke(cudaLaunchFn, Arg);
   CGF.EmitBranch(EndBlock);
 
@@ -551,7 +552,7 @@
 llvm::Constant *NullPtr = llvm::ConstantPointerNull::get(VoidPtrTy);
 llvm::Value *Args[] = {
 &GpuBinaryHandlePtr,
-Builder.CreateBitCast(KernelHandles[I.Kernel], VoidPtrTy),
+Builder.CreateBitCast(KernelHandles[I.Kernel->getName()], VoidPtrTy),
 KernelName,
 KernelName,
 llvm::ConstantInt::get(IntTy, -1),
@@ -1130,7 +1131,7 @@
   StringRef Section = CGM.getLangOpts().HIP ? "hip_offloading_entries"
 : "cuda_offloading_entries";
   for (KernelInfo &I : EmittedKernels)
-OMPBuilder.emitOffloadingEntry(KernelHandles[I.Kernel],
+OMPBuilder.emitOffloadingEntry(KernelHandles[I.Kernel->getName()],
getDeviceSideName(cast(I.D)), 0,
  

[clang] f0756e0 - Revert "[clang-format] Add an option to format integer literal separators"

2022-12-25 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-12-25T13:04:41-08:00
New Revision: f0756e0860107262890d122cac909934563b1f5c

URL: 
https://github.com/llvm/llvm-project/commit/f0756e0860107262890d122cac909934563b1f5c
DIFF: 
https://github.com/llvm/llvm-project/commit/f0756e0860107262890d122cac909934563b1f5c.diff

LOG: Revert "[clang-format] Add an option to format integer literal separators"
Revert "[clang-format] Disable FixRanges in IntegerLiteralSeparatorTest"

Breaks buildbots, details in https://reviews.llvm.org/D140543

This reverts commit 879bd9146a2c9ea395abd7c1ebd0f76f414a4967.
This reverts commit 46c94e5067b5f396c24bb950505c79bc819bd4b8.

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/CMakeLists.txt
clang/lib/Format/Format.cpp
clang/unittests/Format/CMakeLists.txt

Removed: 
clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
clang/lib/Format/IntegerLiteralSeparatorFixer.h
clang/unittests/Format/IntegerLiteralSeparatorTest.cpp



diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 989c91e9a3efe..cac0afe0bffcc 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3159,37 +3159,6 @@ the configuration (without a prefix: ``Auto``).
 
 
 
-**IntegerLiteralSeparator** (``IntegerLiteralSeparatorStyle``) 
:versionbadge:`clang-format 16`
-  Format integer literal separators (``'`` for C++ and ``_`` for C#, Java,
-  and JavaScript).
-
-  Nested configuration flags:
-
-  Separator format of integer literals of 
diff erent bases.
-  <0: Remove separators.
-   0: Leave the literal as is.
-  >0: Insert separators between digits, starting from the rightmost digit.
-
-  * ``int8_t Binary`` .. code-block:: c++
-
-   -1: 0b10001101
-0: 0b10011'11'0110'1
-3: 0b100'111'101'101
-4: 0b1001'1110'1101
-
-  * ``int8_t Decimal`` .. code-block:: c++
-
-   -1: 18446744073709550592ull
-0: 184467'440737'0'95505'92ull
-3: 18'446'744'073'709'550'592ull
-
-  * ``int8_t Hex`` .. code-block:: c++
-
-   -1: 0xDEADBEEFDEADBEEFuz
-0: 0xDEAD'BEEF'DE'AD'BEE'Fuz
-2: 0xDE'AD'BE'EF'DE'AD'BE'EFuz
-
-
 **JavaImportGroups** (``List of Strings``) :versionbadge:`clang-format 8`
   A vector of prefixes ordered by the desired groups for Java imports.
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c30f8fb0fd954..48ffafafb1bb7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -867,8 +867,6 @@ clang-format
 - Add ``RequiresExpressionIndentation`` option for configuring the alignment 
of requires-expressions.
   The default value of this option is ``OuterScope``, which 
diff ers in behavior from clang-format 15.
   To match the default behavior of clang-format 15, use the ``Keyword`` value.
-- Add ``IntegerLiteralSeparator`` option for fixing integer literal separators
-  in C++, C#, Java, and JavaScript.
 
 clang-extdef-mapping
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 9162028c53ede..8949520f87b01 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2450,37 +2450,6 @@ struct FormatStyle {
   /// \version 11
   TrailingCommaStyle InsertTrailingCommas;
 
-  /// Separator format of integer literals of 
diff erent bases.
-  /// <0: Remove separators.
-  ///  0: Leave the literal as is.
-  /// >0: Insert separators between digits, starting from the rightmost digit.
-  struct IntegerLiteralSeparatorStyle {
-/// \code
-///-1: 0b10001101
-/// 0: 0b10011'11'0110'1
-/// 3: 0b100'111'101'101
-/// 4: 0b1001'1110'1101
-/// \endcode
-int8_t Binary;
-/// \code
-///-1: 18446744073709550592ull
-/// 0: 184467'440737'0'95505'92ull
-/// 3: 18'446'744'073'709'550'592ull
-/// \endcode
-int8_t Decimal;
-/// \code
-///-1: 0xDEADBEEFDEADBEEFuz
-/// 0: 0xDEAD'BEEF'DE'AD'BEE'Fuz
-/// 2: 0xDE'AD'BE'EF'DE'AD'BE'EFuz
-/// \endcode
-int8_t Hex;
-  };
-
-  /// Format integer literal separators (``'`` for C++ and ``_`` for C#, Java,
-  /// and JavaScript).
-  /// \version 16
-  IntegerLiteralSeparatorStyle IntegerLiteralSeparator;
-
   /// A vector of prefixes ordered by the desired groups for Java imports.
   ///
   /// One group's prefix can be a subset of another - the longest prefix is
@@ -4120,10 +4089,6 @@ struct FormatStyle {
IndentWidth == R.IndentWidth &&
IndentWrappedFunctionNames == R.IndentWrappedFunctionNames &&
InsertBraces == R.InsertBraces &&
-   IntegerLiteralSeparator.Binary == R.IntegerLiteralSeparator.Binary 
&&
-   IntegerLiteralSeparator.Decimal ==
-

[PATCH] D140664: [Sema] Don't mark deleted special member functions as non-trivial

2022-12-25 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson created this revision.
Herald added a project: All.
royjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As noted in https://github.com/llvm/llvm-project/issues/59624, we sometimes 
mark implicitly
deleted special member functions as non-trivial. This is unnecessary work and 
leads to some
weird type traits errors.

This fixes the problem by making the implicitly deleted special member 
functions always
trivial.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140664

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/AST/ast-dump-funcs.cpp
  clang/test/SemaCXX/GH59624.cpp

Index: clang/test/SemaCXX/GH59624.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/GH59624.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20
+// expected-no-diagnostics
+
+namespace GH59624 {
+
+struct Foo{
+int x{0};
+};
+struct CFoo{
+const int x{0};
+};
+struct Bar{
+const Foo y;
+};
+
+// Deleted move assignment shouldn't make type non-trivially copyable:
+
+static_assert(__is_trivially_copyable(Bar), "");
+
+}
+
Index: clang/test/AST/ast-dump-funcs.cpp
===
--- clang/test/AST/ast-dump-funcs.cpp
+++ clang/test/AST/ast-dump-funcs.cpp
@@ -54,10 +54,10 @@
   virtual void g() = 0;
   // CHECK: CXXMethodDecl 0x{{[^ ]*}}  col:16 g 'void ()' virtual pure
 
-  // CHECK: CXXConstructorDecl 0x{{[^ ]*}}  col:8 implicit S 'void (const S &)' inline default_delete noexcept-unevaluated
+  // CHECK: CXXConstructorDecl 0x{{[^ ]*}}  col:8 implicit S 'void (const S &)' inline default_delete trivial noexcept-unevaluated
   // CHECK: CXXConstructorDecl 0x{{[^ ]*}}  col:8 implicit constexpr S 'void (S &&)' inline default noexcept-unevaluated
-  // CHECK: CXXMethodDecl 0x{{[^ ]*}}  col:8 implicit operator= 'S &(const S &)' inline default_delete noexcept-unevaluated
-  // CHECK: CXXMethodDecl 0x{{[^ ]*}}  col:8 implicit operator= 'S &(S &&)' inline default_delete noexcept-unevaluated
+  // CHECK: CXXMethodDecl 0x{{[^ ]*}}  col:8 implicit operator= 'S &(const S &)' inline default_delete trivial noexcept-unevaluated
+  // CHECK: CXXMethodDecl 0x{{[^ ]*}}  col:8 implicit operator= 'S &(S &&)' inline default_delete trivial noexcept-unevaluated
   // CHECK: CXXDestructorDecl 0x{{[^ ]*}}  col:8 implicit ~S 'void ()' inline default noexcept-unevaluated
 };
 
@@ -70,9 +70,9 @@
   // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}}  'int' 100
   // CHECK-NEXT: OverrideAttr
 
-  // CHECK: CXXConstructorDecl 0x{{[^ ]*}}  col:8 implicit T 'void (const T &)' inline default_delete noexcept-unevaluated
-  // CHECK: CXXMethodDecl 0x{{[^ ]*}}  col:8 implicit operator= 'T &(const T &)' inline default_delete noexcept-unevaluated
-  // CHECK: CXXMethodDecl 0x{{[^ ]*}}  col:8 implicit operator= 'T &(T &&)' inline default_delete noexcept-unevaluated
+  // CHECK: CXXConstructorDecl 0x{{[^ ]*}}  col:8 implicit T 'void (const T &)' inline default_delete trivial noexcept-unevaluated
+  // CHECK: CXXMethodDecl 0x{{[^ ]*}}  col:8 implicit operator= 'T &(const T &)' inline default_delete trivial noexcept-unevaluated
+  // CHECK: CXXMethodDecl 0x{{[^ ]*}}  col:8 implicit operator= 'T &(T &&)' inline default_delete trivial noexcept-unevaluated
   // CHECK: CXXDestructorDecl 0x{{[^ ]*}}  col:8 implicit ~T 'void ()' inline default noexcept-unevaluated
 };
 
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -14475,11 +14475,6 @@
nullptr);
   CopyAssignment->setParams(FromParam);
 
-  CopyAssignment->setTrivial(
-ClassDecl->needsOverloadResolutionForCopyAssignment()
-  ? SpecialMemberIsTrivial(CopyAssignment, CXXCopyAssignment)
-  : ClassDecl->hasTrivialCopyAssignment());
-
   // Note that we have added this copy-assignment operator.
   ++getASTContext().NumImplicitCopyAssignmentOperatorsDeclared;
 
@@ -14489,6 +14484,11 @@
   if (ShouldDeleteSpecialMember(CopyAssignment, CXXCopyAssignment)) {
 ClassDecl->setImplicitCopyAssignmentIsDeleted();
 SetDeclDeleted(CopyAssignment, ClassLoc);
+  } else {
+CopyAssignment->setTrivial(
+  ClassDecl->needsOverloadResolutionForCopyAssignment()
+? SpecialMemberIsTrivial(CopyAssignment, CXXCopyAssignment)
+: ClassDecl->hasTrivialCopyAssignment());
   }
 
   if (S)
@@ -14813,10 +14813,6 @@
nullptr);
   MoveAssignment->setParams(FromParam);
 
-  MoveAssignment->setTrivial(
-ClassDecl->needsOverloadResolutionForMoveAssignment()
-  ? SpecialMemberIsTrivial(MoveAssignment, CXXMoveAssignment)
-  : ClassDecl->hasTrivialMoveAssignment());
 
   // Note that w

[clang] b1d7010 - [DebugInfo] make DW_LANG_C11 respect -gstrict-dwarf

2022-12-25 Thread Chen Zheng via cfe-commits

Author: Chen Zheng
Date: 2022-12-25T21:01:02-05:00
New Revision: b1d7010caa4394e7f5b41c627702f6acabe0cec5

URL: 
https://github.com/llvm/llvm-project/commit/b1d7010caa4394e7f5b41c627702f6acabe0cec5
DIFF: 
https://github.com/llvm/llvm-project/commit/b1d7010caa4394e7f5b41c627702f6acabe0cec5.diff

LOG: [DebugInfo] make DW_LANG_C11 respect -gstrict-dwarf

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D140544

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGen/debug-info-programming-language.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 576a97b66859c..62ea222fade67 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -578,8 +578,8 @@ void CGDebugInfo::CreateCompileUnit() {
 LangTag = llvm::dwarf::DW_LANG_OpenCL;
   } else if (LO.RenderScript) {
 LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
-  } else if (LO.C11) {
-LangTag = llvm::dwarf::DW_LANG_C11;
+  } else if (LO.C11 && !(CGO.DebugStrictDwarf && CGO.DwarfVersion < 5)) {
+  LangTag = llvm::dwarf::DW_LANG_C11;
   } else if (LO.C99) {
 LangTag = llvm::dwarf::DW_LANG_C99;
   } else {

diff  --git a/clang/test/CodeGen/debug-info-programming-language.c 
b/clang/test/CodeGen/debug-info-programming-language.c
index f81bab610d51e..02e45d89ca15e 100644
--- a/clang/test/CodeGen/debug-info-programming-language.c
+++ b/clang/test/CodeGen/debug-info-programming-language.c
@@ -4,7 +4,14 @@
 // RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
 // RUN:   -x c -std=c17 -O0 -disable-llvm-passes -debug-info-kind=limited \
 // RUN:   | FileCheck --check-prefix=CHECK-C17 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   -gstrict-dwarf | FileCheck --check-prefix=CHECK-STRICT %s
+// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   -gstrict-dwarf | FileCheck --check-prefix=CHECK-C11 %s
 
+// CHECK-STRICT: !DICompileUnit(language: DW_LANG_C99
 // CHECK-C11: !DICompileUnit(language: DW_LANG_C11
 // Update this check once support for DW_LANG_C17 is broadly supported/known in
 // consumers. Maybe we'll skip this and go to the DWARFv6 language+version



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


[PATCH] D140544: [DebugInfo] make DW_LANG_C11 respect -gstrict-dwarf

2022-12-25 Thread ChenZheng via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
shchenz marked an inline comment as done.
Closed by commit rGb1d7010caa43: [DebugInfo] make DW_LANG_C11 respect 
-gstrict-dwarf (authored by shchenz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140544

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-programming-language.c


Index: clang/test/CodeGen/debug-info-programming-language.c
===
--- clang/test/CodeGen/debug-info-programming-language.c
+++ clang/test/CodeGen/debug-info-programming-language.c
@@ -4,7 +4,14 @@
 // RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
 // RUN:   -x c -std=c17 -O0 -disable-llvm-passes -debug-info-kind=limited \
 // RUN:   | FileCheck --check-prefix=CHECK-C17 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   -gstrict-dwarf | FileCheck --check-prefix=CHECK-STRICT %s
+// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   -gstrict-dwarf | FileCheck --check-prefix=CHECK-C11 %s
 
+// CHECK-STRICT: !DICompileUnit(language: DW_LANG_C99
 // CHECK-C11: !DICompileUnit(language: DW_LANG_C11
 // Update this check once support for DW_LANG_C17 is broadly supported/known in
 // consumers. Maybe we'll skip this and go to the DWARFv6 language+version
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -578,8 +578,8 @@
 LangTag = llvm::dwarf::DW_LANG_OpenCL;
   } else if (LO.RenderScript) {
 LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
-  } else if (LO.C11) {
-LangTag = llvm::dwarf::DW_LANG_C11;
+  } else if (LO.C11 && !(CGO.DebugStrictDwarf && CGO.DwarfVersion < 5)) {
+  LangTag = llvm::dwarf::DW_LANG_C11;
   } else if (LO.C99) {
 LangTag = llvm::dwarf::DW_LANG_C99;
   } else {


Index: clang/test/CodeGen/debug-info-programming-language.c
===
--- clang/test/CodeGen/debug-info-programming-language.c
+++ clang/test/CodeGen/debug-info-programming-language.c
@@ -4,7 +4,14 @@
 // RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -x c -std=c17 -O0 -disable-llvm-passes -debug-info-kind=limited \
 // RUN:   | FileCheck --check-prefix=CHECK-C17 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   -gstrict-dwarf | FileCheck --check-prefix=CHECK-STRICT %s
+// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   -gstrict-dwarf | FileCheck --check-prefix=CHECK-C11 %s
 
+// CHECK-STRICT: !DICompileUnit(language: DW_LANG_C99
 // CHECK-C11: !DICompileUnit(language: DW_LANG_C11
 // Update this check once support for DW_LANG_C17 is broadly supported/known in
 // consumers. Maybe we'll skip this and go to the DWARFv6 language+version
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -578,8 +578,8 @@
 LangTag = llvm::dwarf::DW_LANG_OpenCL;
   } else if (LO.RenderScript) {
 LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
-  } else if (LO.C11) {
-LangTag = llvm::dwarf::DW_LANG_C11;
+  } else if (LO.C11 && !(CGO.DebugStrictDwarf && CGO.DwarfVersion < 5)) {
+  LangTag = llvm::dwarf::DW_LANG_C11;
   } else if (LO.C99) {
 LangTag = llvm::dwarf::DW_LANG_C99;
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140055: [ODRHash] Detect mismatches in anonymous `RecordDecl`.

2022-12-25 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

LGTM since it shouldn't be bad to call `getMostRecentDecl()` multiple times.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140055

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


[PATCH] D140073: [ODRHash] Hash `ObjCInterfaceDecl` and diagnose discovered mismatches.

2022-12-25 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

Although I'm not familiar with ObjC, the code looks good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140073

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


[clang] 1179ef4 - [RISCV] Implement assembler support for XTHeadVdot

2022-12-25 Thread Jojo R via cfe-commits

Author: Jojo R
Date: 2022-12-26T18:32:42+08:00
New Revision: 1179ef46a34292179d3e7e8570d7342edd2dc27d

URL: 
https://github.com/llvm/llvm-project/commit/1179ef46a34292179d3e7e8570d7342edd2dc27d
DIFF: 
https://github.com/llvm/llvm-project/commit/1179ef46a34292179d3e7e8570d7342edd2dc27d.diff

LOG: [RISCV] Implement assembler support for XTHeadVdot

This patch implements the T-Head vendor extensions (XTHeadVdot),
which is documented here, it's based on standard vector extension v1.0:
  https://github.com/T-head-Semi/thead-extension-spec

Added: 
llvm/lib/Target/RISCV/RISCVInstrInfoXTHead.td
llvm/test/MC/RISCV/XTHeadVdot-valid.s

Modified: 
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
llvm/lib/Target/RISCV/RISCV.td
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/lib/TargetParser/RISCVISAInfo.cpp
llvm/test/CodeGen/RISCV/attributes.ll

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 8884b0989086d..7791703cbbe46 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -446,6 +446,10 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-XVENTANACONDOPS-EXT %s
 // CHECK-XVENTANACONDOPS-EXT: __riscv_xventanacondops 100{{$}}
 
+// RUN: %clang -target riscv64 -march=rv64ixtheadvdot -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-XTHEADVDOT-EXT %s
+// CHECK-XTHEADVDOT-EXT: __riscv_xtheadvdot 100{{$}}
+
 // RUN: %clang -target riscv32 -march=rv32izcd0p70 
-menable-experimental-extensions \
 // RUN: -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-ZCD-EXT %s
 // RUN: %clang -target riscv64 -march=rv64izcd0p70 
-menable-experimental-extensions \

diff  --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index aa39935153973..c5f947a76eb28 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -160,6 +160,9 @@ The current vendor extensions supported are:
 ``XVentanaCondOps``
   LLVM implements `version 1.0.0 of the VTx-family custom instructions 
specification 
`_
 by Ventana Micro Systems.  All instructions are prefixed with `vt.` as 
described in the specification, and the riscv-toolchai-convention document 
linked above.  These instructions are only available for riscv64 at this time.
 
+``XTHeadVdot``
+  LLVM implements `version 1.0.0 of the THeadV-family custom instructions 
specification 
`_
 by T-HEAD of Alibaba.  All instructions are prefixed with `th.` as described 
in the specification, and the riscv-toolchai-convention document linked above.
+
 
 Specification Documents
 ===

diff  --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp 
b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
index 4a00e5045462b..42cdd755b5b42 100644
--- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
+++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
@@ -474,6 +474,15 @@ DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, 
uint64_t &Size,
 return Result;
   }
 }
+if (STI.getFeatureBits()[RISCV::FeatureVendorXTHeadVdot]) {
+  LLVM_DEBUG(dbgs() << "Trying T-Head custom opcode table:\n");
+  Result =
+  decodeInstruction(DecoderTableTHeadV32, MI, Insn, Address, this, 
STI);
+  if (Result != MCDisassembler::Fail) {
+Size = 4;
+return Result;
+  }
+}
 
 LLVM_DEBUG(dbgs() << "Trying RISCV32 table :\n");
 Result = decodeInstruction(DecoderTable32, MI, Insn, Address, this, STI);

diff  --git a/llvm/lib/Target/RISCV/RISCV.td b/llvm/lib/Target/RISCV/RISCV.td
index 2ba00bd7b7b72..c94d426fb72e3 100644
--- a/llvm/lib/Target/RISCV/RISCV.td
+++ b/llvm/lib/Target/RISCV/RISCV.td
@@ -445,6 +445,14 @@ def HasVendorXVentanaCondOps : 
Predicate<"Subtarget->hasVendorXVentanaCondOps()"
 AssemblerPredicate<(all_of 
FeatureVendorXVentanaCondOps),
 "'XVentanaCondOps' (Ventana Conditional Ops)">;
 
+def FeatureVendorXTHeadVdot
+: SubtargetFeature<"xtheadvdot", "HasVendorXTHeadVdot", "true",
+   "'xtheadvdot' (T-Head Vector Extensions for Dot)",
+   [FeatureStdExtV]>;
+def HasVendorXTHeadVdot : Predicate<"Subtarget->hasVendorXTHeadVdot()">,
+AssemblerPredicate<(all_of 
FeatureVendorXTHeadVdot),
+"'xtheadvdot' (T-Head Vector Extensions 
for Dot)">;
+
 
//===--===//
 // L

[clang] 54752f3 - [RISCV] Implement assembler support for XTHeadVdot

2022-12-25 Thread Jojo R via cfe-commits

Author: Jojo R
Date: 2022-12-26T19:05:22+08:00
New Revision: 54752f3ff6d50944f17c260a6dc47a4758a026fc

URL: 
https://github.com/llvm/llvm-project/commit/54752f3ff6d50944f17c260a6dc47a4758a026fc
DIFF: 
https://github.com/llvm/llvm-project/commit/54752f3ff6d50944f17c260a6dc47a4758a026fc.diff

LOG: [RISCV] Implement assembler support for XTHeadVdot

This patch implements the T-Head vendor extensions (XTHeadVdot),
which is documented here, it's based on standard vector extension v1.0:
  https://github.com/T-head-Semi/thead-extension-spec

Added: 
llvm/lib/Target/RISCV/RISCVInstrInfoXTHead.td
llvm/test/MC/RISCV/XTHeadVdot-valid.s

Modified: 
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
llvm/lib/Target/RISCV/RISCV.td
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/lib/TargetParser/RISCVISAInfo.cpp
llvm/test/CodeGen/RISCV/attributes.ll

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 8884b0989086d..7791703cbbe46 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -446,6 +446,10 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-XVENTANACONDOPS-EXT %s
 // CHECK-XVENTANACONDOPS-EXT: __riscv_xventanacondops 100{{$}}
 
+// RUN: %clang -target riscv64 -march=rv64ixtheadvdot -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-XTHEADVDOT-EXT %s
+// CHECK-XTHEADVDOT-EXT: __riscv_xtheadvdot 100{{$}}
+
 // RUN: %clang -target riscv32 -march=rv32izcd0p70 
-menable-experimental-extensions \
 // RUN: -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-ZCD-EXT %s
 // RUN: %clang -target riscv64 -march=rv64izcd0p70 
-menable-experimental-extensions \

diff  --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index aa39935153973..c5f947a76eb28 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -160,6 +160,9 @@ The current vendor extensions supported are:
 ``XVentanaCondOps``
   LLVM implements `version 1.0.0 of the VTx-family custom instructions 
specification 
`_
 by Ventana Micro Systems.  All instructions are prefixed with `vt.` as 
described in the specification, and the riscv-toolchai-convention document 
linked above.  These instructions are only available for riscv64 at this time.
 
+``XTHeadVdot``
+  LLVM implements `version 1.0.0 of the THeadV-family custom instructions 
specification 
`_
 by T-HEAD of Alibaba.  All instructions are prefixed with `th.` as described 
in the specification, and the riscv-toolchai-convention document linked above.
+
 
 Specification Documents
 ===

diff  --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp 
b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
index 4a00e5045462b..42cdd755b5b42 100644
--- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
+++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
@@ -474,6 +474,15 @@ DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, 
uint64_t &Size,
 return Result;
   }
 }
+if (STI.getFeatureBits()[RISCV::FeatureVendorXTHeadVdot]) {
+  LLVM_DEBUG(dbgs() << "Trying T-Head custom opcode table:\n");
+  Result =
+  decodeInstruction(DecoderTableTHeadV32, MI, Insn, Address, this, 
STI);
+  if (Result != MCDisassembler::Fail) {
+Size = 4;
+return Result;
+  }
+}
 
 LLVM_DEBUG(dbgs() << "Trying RISCV32 table :\n");
 Result = decodeInstruction(DecoderTable32, MI, Insn, Address, this, STI);

diff  --git a/llvm/lib/Target/RISCV/RISCV.td b/llvm/lib/Target/RISCV/RISCV.td
index 2ba00bd7b7b72..c94d426fb72e3 100644
--- a/llvm/lib/Target/RISCV/RISCV.td
+++ b/llvm/lib/Target/RISCV/RISCV.td
@@ -445,6 +445,14 @@ def HasVendorXVentanaCondOps : 
Predicate<"Subtarget->hasVendorXVentanaCondOps()"
 AssemblerPredicate<(all_of 
FeatureVendorXVentanaCondOps),
 "'XVentanaCondOps' (Ventana Conditional Ops)">;
 
+def FeatureVendorXTHeadVdot
+: SubtargetFeature<"xtheadvdot", "HasVendorXTHeadVdot", "true",
+   "'xtheadvdot' (T-Head Vector Extensions for Dot)",
+   [FeatureStdExtV]>;
+def HasVendorXTHeadVdot : Predicate<"Subtarget->hasVendorXTHeadVdot()">,
+AssemblerPredicate<(all_of 
FeatureVendorXTHeadVdot),
+"'xtheadvdot' (T-Head Vector Extensions 
for Dot)">;
+
 
//===--===//
 // L

[clang] d5a5ee8 - [Clang] Add `nvptx-arch` tool to query installed NVIDIA GPUs

2022-12-25 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-12-25T21:24:30-06:00
New Revision: d5a5ee856e7ccd442ad22168c56ff77197255cbe

URL: 
https://github.com/llvm/llvm-project/commit/d5a5ee856e7ccd442ad22168c56ff77197255cbe
DIFF: 
https://github.com/llvm/llvm-project/commit/d5a5ee856e7ccd442ad22168c56ff77197255cbe.diff

LOG: [Clang] Add `nvptx-arch` tool to query installed NVIDIA GPUs

We already have a tool called `amdgpu-arch` which returns the GPUs on
the system. This is used to determine the default architecture when
doing offloading. This patch introduces a similar tool `nvptx-arch`.
Right now we use the detected GPU at compile time. This is unhelpful
when building on a login node and moving execution to a compute node for
example. This will allow us to better choose a default architecture when
targeting NVPTX. Also we can probably use this with CMake's `native`
setting for CUDA now.

CUDA since 11.6 provides `__nvcc_device_query` which has a similar
function but it is probably better to define this locally if we want to
depend on it in clang.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D140433

Added: 
clang/tools/nvptx-arch/CMakeLists.txt
clang/tools/nvptx-arch/NVPTXArch.cpp

Modified: 
clang/tools/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt
index 2ce7fd65a555b..f60db6ef0ba34 100644
--- a/clang/tools/CMakeLists.txt
+++ b/clang/tools/CMakeLists.txt
@@ -50,3 +50,4 @@ add_llvm_external_project(clang-tools-extra extra)
 add_clang_subdirectory(libclang)
 
 add_clang_subdirectory(amdgpu-arch)
+add_clang_subdirectory(nvptx-arch)

diff  --git a/clang/tools/nvptx-arch/CMakeLists.txt 
b/clang/tools/nvptx-arch/CMakeLists.txt
new file mode 100644
index 0..94ef206a3bd75
--- /dev/null
+++ b/clang/tools/nvptx-arch/CMakeLists.txt
@@ -0,0 +1,28 @@
+# 
//======//
+# //
+# // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+# // See https://llvm.org/LICENSE.txt for details.
+# // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+# //
+# 
//======//
+
+
+# TODO: This is deprecated. Since CMake 3.17 we can use FindCUDAToolkit 
instead.
+find_package(CUDA QUIET)
+find_library(cuda-library NAMES cuda PATHS /lib64)
+if (NOT cuda-library AND CUDA_FOUND)
+  get_filename_component(CUDA_LIBDIR "${CUDA_cudart_static_LIBRARY}" DIRECTORY)
+  find_library(cuda-library NAMES cuda HINTS "${CUDA_LIBDIR}/stubs")
+endif()
+
+if (NOT CUDA_FOUND OR NOT cuda-library)
+  message(STATUS "Not building nvptx-arch: cuda runtime not found")
+  return()
+endif()
+
+add_clang_tool(nvptx-arch NVPTXArch.cpp)
+
+set_target_properties(nvptx-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
+target_include_directories(nvptx-arch PRIVATE ${CUDA_INCLUDE_DIRS})
+
+clang_target_link_libraries(nvptx-arch PRIVATE ${cuda-library})

diff  --git a/clang/tools/nvptx-arch/NVPTXArch.cpp 
b/clang/tools/nvptx-arch/NVPTXArch.cpp
new file mode 100644
index 0..f70acf9a9f5b3
--- /dev/null
+++ b/clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -0,0 +1,72 @@
+//===- NVPTXArch.cpp - list installed NVPTX devies --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements a tool for detecting name of CUDA gpus installed in the
+// system.
+//
+//===--===//
+
+#if defined(__has_include)
+#if __has_include("cuda.h")
+#include "cuda.h"
+#define CUDA_HEADER_FOUND 1
+#else
+#define CUDA_HEADER_FOUND 0
+#endif
+#else
+#define CUDA_HEADER_FOUND 0
+#endif
+
+#if !CUDA_HEADER_FOUND
+int main() { return 1; }
+#else
+
+#include 
+#include 
+
+static int handleError(CUresult Err) {
+  const char *ErrStr = nullptr;
+  CUresult Result = cuGetErrorString(Err, &ErrStr);
+  if (Result != CUDA_SUCCESS)
+return EXIT_FAILURE;
+  fprintf(stderr, "CUDA error: %s\n", ErrStr);
+  return EXIT_FAILURE;
+}
+
+int main() {
+  if (CUresult Err = cuInit(0)) {
+if (Err == CUDA_ERROR_NO_DEVICE)
+  return EXIT_SUCCESS;
+else
+  return handleError(Err);
+  }
+
+  int Count = 0;
+  if (CUresult Err = cuDeviceGetCount(&Count))
+return handleError(Err);
+  if (Count == 0)
+return EXIT_SUCCESS;
+  for (int DeviceId = 0; DeviceId < Count; ++DeviceId) {
+CUdevice Device;
+if (CUresult Err = cuDeviceGet(&Device, DeviceId))
+  return handleError(Err);
+
+int32_t Major, Minor;
+if (CUresult Err = cuDeviceGetAttribute(
+&Major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPA

[PATCH] D140433: [Clang] Add `nvptx-arch` tool to query installed NVIDIA GPUs

2022-12-25 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd5a5ee856e7c: [Clang] Add `nvptx-arch` tool to query 
installed NVIDIA GPUs (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140433

Files:
  clang/tools/CMakeLists.txt
  clang/tools/nvptx-arch/CMakeLists.txt
  clang/tools/nvptx-arch/NVPTXArch.cpp

Index: clang/tools/nvptx-arch/NVPTXArch.cpp
===
--- /dev/null
+++ clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -0,0 +1,72 @@
+//===- NVPTXArch.cpp - list installed NVPTX devies --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements a tool for detecting name of CUDA gpus installed in the
+// system.
+//
+//===--===//
+
+#if defined(__has_include)
+#if __has_include("cuda.h")
+#include "cuda.h"
+#define CUDA_HEADER_FOUND 1
+#else
+#define CUDA_HEADER_FOUND 0
+#endif
+#else
+#define CUDA_HEADER_FOUND 0
+#endif
+
+#if !CUDA_HEADER_FOUND
+int main() { return 1; }
+#else
+
+#include 
+#include 
+
+static int handleError(CUresult Err) {
+  const char *ErrStr = nullptr;
+  CUresult Result = cuGetErrorString(Err, &ErrStr);
+  if (Result != CUDA_SUCCESS)
+return EXIT_FAILURE;
+  fprintf(stderr, "CUDA error: %s\n", ErrStr);
+  return EXIT_FAILURE;
+}
+
+int main() {
+  if (CUresult Err = cuInit(0)) {
+if (Err == CUDA_ERROR_NO_DEVICE)
+  return EXIT_SUCCESS;
+else
+  return handleError(Err);
+  }
+
+  int Count = 0;
+  if (CUresult Err = cuDeviceGetCount(&Count))
+return handleError(Err);
+  if (Count == 0)
+return EXIT_SUCCESS;
+  for (int DeviceId = 0; DeviceId < Count; ++DeviceId) {
+CUdevice Device;
+if (CUresult Err = cuDeviceGet(&Device, DeviceId))
+  return handleError(Err);
+
+int32_t Major, Minor;
+if (CUresult Err = cuDeviceGetAttribute(
+&Major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, Device))
+  return handleError(Err);
+if (CUresult Err = cuDeviceGetAttribute(
+&Minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, Device))
+  return handleError(Err);
+
+printf("sm_%d%d\n", Major, Minor);
+  }
+  return EXIT_SUCCESS;
+}
+
+#endif
Index: clang/tools/nvptx-arch/CMakeLists.txt
===
--- /dev/null
+++ clang/tools/nvptx-arch/CMakeLists.txt
@@ -0,0 +1,28 @@
+# //======//
+# //
+# // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# // See https://llvm.org/LICENSE.txt for details.
+# // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+# //
+# //======//
+
+
+# TODO: This is deprecated. Since CMake 3.17 we can use FindCUDAToolkit instead.
+find_package(CUDA QUIET)
+find_library(cuda-library NAMES cuda PATHS /lib64)
+if (NOT cuda-library AND CUDA_FOUND)
+  get_filename_component(CUDA_LIBDIR "${CUDA_cudart_static_LIBRARY}" DIRECTORY)
+  find_library(cuda-library NAMES cuda HINTS "${CUDA_LIBDIR}/stubs")
+endif()
+
+if (NOT CUDA_FOUND OR NOT cuda-library)
+  message(STATUS "Not building nvptx-arch: cuda runtime not found")
+  return()
+endif()
+
+add_clang_tool(nvptx-arch NVPTXArch.cpp)
+
+set_target_properties(nvptx-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
+target_include_directories(nvptx-arch PRIVATE ${CUDA_INCLUDE_DIRS})
+
+clang_target_link_libraries(nvptx-arch PRIVATE ${cuda-library})
Index: clang/tools/CMakeLists.txt
===
--- clang/tools/CMakeLists.txt
+++ clang/tools/CMakeLists.txt
@@ -50,3 +50,4 @@
 add_clang_subdirectory(libclang)
 
 add_clang_subdirectory(amdgpu-arch)
+add_clang_subdirectory(nvptx-arch)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140294: clang: Replace implementation of __builtin_isnormal

2022-12-25 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

As mentioned in another review, using `fcmp` to represent `isnormal` in IR as 
well as any other classification function would result in incorrect code in 
strict mode. The source:

  inline __attribute__((always_inline)) _Bool func(float x) {
return __builtin_isnormal(x);
  }
  
  _Bool check(float x) {
  #pragma STDC FENV_ACCESS ON
return func(x);
  }

in this case would produce code that uses FP comparisons to implement 
`isnormal` (in the form of constrained intrinsics), this is incorrect. Using 
correct representation is impossible in this case, as the information about 
original check is already lost.


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

https://reviews.llvm.org/D140294

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


[PATCH] D140661: [NFC][Clang] Reduce for-loop with SmallVector utility

2022-12-25 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Please add [RISCV] to title


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140661

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


[PATCH] D140661: [NFC][Clang][RISCV] Reduce for-loop with SmallVector utility

2022-12-25 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140661

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


[PATCH] D140661: [NFC][Clang][RISCV] Reduce for-loop with SmallVector utility

2022-12-25 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG904a79f99153: [NFC][Clang][RISCV] Reduce for-loop with 
SmallVector utility (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140661

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Support/RISCVVIntrinsicUtils.cpp

Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -939,8 +939,7 @@
 // (void, op0 address, op1 address, ..., maskedoff0, maskedoff1, ...)
 PrototypeDescriptor MaskoffType = NewPrototype[1];
 MaskoffType.TM &= ~static_cast(TypeModifier::Pointer);
-for (unsigned I = 0; I < NF; ++I)
-  NewPrototype.insert(NewPrototype.begin() + NF + 1, MaskoffType);
+NewPrototype.insert(NewPrototype.begin() + NF + 1, NF, MaskoffType);
   }
 }
 // Erase passthru operand for TAM
@@ -983,8 +982,7 @@
   // (void, op0 address, op1 address, maskedoff0, maskedoff1, ...)
   PrototypeDescriptor MaskoffType = Prototype[1];
   MaskoffType.TM &= ~static_cast(TypeModifier::Pointer);
-  for (unsigned I = 0; I < NF; ++I)
-NewPrototype.insert(NewPrototype.begin() + NF + 1, MaskoffType);
+  NewPrototype.insert(NewPrototype.begin() + NF + 1, NF, MaskoffType);
 }
  }
 
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -848,8 +848,7 @@
 // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, vl)
 // intrinsic: (maskedoff0, ..., ptr, mask, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF + 1]);
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 2]);
@@ -867,8 +866,7 @@
 // TU builtin: (val0 address, ..., passthru0, ..., ptr, vl)
 // intrinsic: (passthru0, passthru1, ..., ptr, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 1]);
 } else {
@@ -927,8 +925,7 @@
 // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, new_vl, vl)
 // intrinsic: (maskedoff0, ..., ptr, mask, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF + 1]);
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 3]);
@@ -948,8 +945,7 @@
 // TU builtin: (val0 address, ..., passthru0, ..., ptr, new_vl, vl)
 // intrinsic: (passthru0, passthru1, ..., ptr, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 2]);
   NewVL = Ops[NF + 1];
@@ -1010,8 +1006,7 @@
 // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, stride, vl)
 // intrinsic: (maskedoff0, ..., ptr, stride, mask, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF + 1]);
   Operands.push_back(Ops[NF + 2]);
   Operands.push_back(Ops[NF]);
@@ -1031,8 +1026,7 @@
 // TU builtin: (val0 address, ..., passthru0, ..., ptr, stride, vl)
 // intrinsic: (passthru0, passthru1, ..., ptr, stride, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 1]);
   Operands.push_back(Ops[NF + 2]);
@@ -1086,8 +1080,7 @@
 // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, index, vl)
 // intrinsic: (maskedoff0, ..., ptr, index, mask, vl)
 

[clang] 904a79f - [NFC][Clang][RISCV] Reduce for-loop with SmallVector utility

2022-12-25 Thread via cfe-commits

Author: eopXD
Date: 2022-12-25T22:57:51-08:00
New Revision: 904a79f99153d9d8ed67beeed82a0f910bb000fd

URL: 
https://github.com/llvm/llvm-project/commit/904a79f99153d9d8ed67beeed82a0f910bb000fd
DIFF: 
https://github.com/llvm/llvm-project/commit/904a79f99153d9d8ed67beeed82a0f910bb000fd.diff

LOG: [NFC][Clang][RISCV] Reduce for-loop with SmallVector utility

As topic, this commit reduces the for-loops with utilities of SmallVector.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D140661

Added: 


Modified: 
clang/include/clang/Basic/riscv_vector.td
clang/lib/Support/RISCVVIntrinsicUtils.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index 7dbd331b2c5ec..1ed8e00dd82ba 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -848,8 +848,7 @@ multiclass RVVUnitStridedSegLoad {
 // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, vl)
 // intrinsic: (maskedoff0, ..., ptr, mask, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF + 1]);
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 2]);
@@ -867,8 +866,7 @@ multiclass RVVUnitStridedSegLoad {
 // TU builtin: (val0 address, ..., passthru0, ..., ptr, vl)
 // intrinsic: (passthru0, passthru1, ..., ptr, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 1]);
 } else {
@@ -927,8 +925,7 @@ multiclass RVVUnitStridedSegLoadFF {
 // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, new_vl, vl)
 // intrinsic: (maskedoff0, ..., ptr, mask, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF + 1]);
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 3]);
@@ -948,8 +945,7 @@ multiclass RVVUnitStridedSegLoadFF {
 // TU builtin: (val0 address, ..., passthru0, ..., ptr, new_vl, vl)
 // intrinsic: (passthru0, passthru1, ..., ptr, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 2]);
   NewVL = Ops[NF + 1];
@@ -1010,8 +1006,7 @@ multiclass RVVStridedSegLoad {
 // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, stride, vl)
 // intrinsic: (maskedoff0, ..., ptr, stride, mask, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF + 1]);
   Operands.push_back(Ops[NF + 2]);
   Operands.push_back(Ops[NF]);
@@ -1031,8 +1026,7 @@ multiclass RVVStridedSegLoad {
 // TU builtin: (val0 address, ..., passthru0, ..., ptr, stride, vl)
 // intrinsic: (passthru0, passthru1, ..., ptr, stride, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF]);
   Operands.push_back(Ops[NF + 1]);
   Operands.push_back(Ops[NF + 2]);
@@ -1086,8 +1080,7 @@ multiclass RVVIndexedSegLoad {
 // builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, index, vl)
 // intrinsic: (maskedoff0, ..., ptr, index, mask, vl)
 if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(llvm::PoisonValue::get(ResultType));
+  Operands.append(NF, llvm::PoisonValue::get(ResultType));
   Operands.push_back(Ops[NF + 1]);
   Operands.push_back(Ops[NF + 2]);
   Operands.push_back(Ops[NF]);
@@ -1109,8 +1102,7 @@ multiclass RVVIndexedSegLoad {
 // TU builtin: (val0 address, ..., passthru0, ..., ptr, index, vl)
 // intrinsic: (passth

[PATCH] D140662: [NFC][Clang][RISCV] Reduce boilerplate when determining prototype for segment loads

2022-12-25 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 485270.
eopXD added a comment.

Rebase to latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140662

Files:
  clang/include/clang/Basic/riscv_vector.td

Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -843,39 +843,30 @@
   ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
   IntrinsicTypes = {ResultType, Ops.back()->getType()};
   SmallVector Operands;
-  if (IsMasked) {
-// TAMA builtin: (val0 address, ..., mask, ptr, vl)
-// builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, vl)
-// intrinsic: (maskedoff0, ..., ptr, mask, vl)
-if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  Operands.append(NF, llvm::PoisonValue::get(ResultType));
-  Operands.push_back(Ops[NF + 1]);
-  Operands.push_back(Ops[NF]);
-  Operands.push_back(Ops[NF + 2]);
-} else {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(Ops[NF + I + 1]);
-  Operands.push_back(Ops[2 * NF + 1]);
-  Operands.push_back(Ops[NF]);
-  Operands.push_back(Ops[2 * NF + 2]);
-}
+
+  // Intrinsic is in the form of below,
+  // Masked: (Vector0, ..., Vector{NF - 1}, Ptr, Mask, VL, Policy)
+  // Unmasked: (Vector0, ..., Vector{NF - 1}, Ptr, VL)
+  // where the Vectors is poison when the policy behavior allows us to not care
+  // about any masked-off elements.
+  Value *PassThruOperand = IsMasked ?
+(DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) ?
+  llvm::PoisonValue::get(ResultType) : Ops[NF + 1] :
+(DefaultPolicy == TAIL_AGNOSTIC) ?
+  llvm::PoisonValue::get(ResultType) : Ops[NF];
+  unsigned PtrOperandIdx = IsMasked ?
+(DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) ? NF + 1 : 2 * NF + 1 :
+(DefaultPolicy == TAIL_AGNOSTIC) ? NF : 2 * NF;
+  Value *PtrOperand = Ops[PtrOperandIdx];
+  Value *VLOperand = Ops[PtrOperandIdx + 1];
+  Operands.append(NF, PassThruOperand);
+  Operands.push_back(PtrOperand);
+  if (IsMasked)
+Operands.push_back(Ops[NF]);
+  Operands.push_back(VLOperand);
+  if (IsMasked)
 Operands.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy));
-assert(Operands.size() == NF + 4);
-  } else {
-// TA builtin: (val0 address, val1 address, ..., ptr, vl)
-// TU builtin: (val0 address, ..., passthru0, ..., ptr, vl)
-// intrinsic: (passthru0, passthru1, ..., ptr, vl)
-if (DefaultPolicy == TAIL_AGNOSTIC) {
-  Operands.append(NF, llvm::PoisonValue::get(ResultType));
-  Operands.push_back(Ops[NF]);
-  Operands.push_back(Ops[NF + 1]);
-} else {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(Ops[NF + I]);
-  Operands.push_back(Ops[2 * NF]);
-  Operands.push_back(Ops[2 * NF + 1]);
-}
-  }
+
   llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
   llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
   clang::CharUnits Align =
@@ -918,45 +909,31 @@
   ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
   IntrinsicTypes = {ResultType, Ops.back()->getType()};
   SmallVector Operands;
-  Value *NewVL;
 
-  if (IsMasked) {
-// TAMA builtin: (val0 address, ..., mask, ptr, new_vl, vl)
-// builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, new_vl, vl)
-// intrinsic: (maskedoff0, ..., ptr, mask, vl)
-if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) {
-  Operands.append(NF, llvm::PoisonValue::get(ResultType));
-  Operands.push_back(Ops[NF + 1]);
-  Operands.push_back(Ops[NF]);
-  Operands.push_back(Ops[NF + 3]);
-  NewVL = Ops[NF + 2];
-} else {
-  for (unsigned I = 0; I < NF; ++I)
-Operands.push_back(Ops[NF + I + 1]);
-  Operands.push_back(Ops[2 * NF + 1]);
-  Operands.push_back(Ops[NF]);
-  Operands.push_back(Ops[2 * NF + 3]);
-  NewVL = Ops[2 * NF + 2];
-}
+  // Intrinsic is in the form of below,
+  // Masked: (Vector0, ..., Vector{NF - 1}, Ptr, Mask, NewVL, VL, Policy)
+  // Unmasked: (Vector0, ..., Vector{NF - 1}, Ptr, NewVL, VL)
+  // where the Vectors is poison when the policy behavior allows us to not care
+  // about any masked-off elements.
+  Value *PassThruOperand = IsMasked ?
+(DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC) ?
+  llvm::PoisonValue::get(ResultType) : Ops[NF + 1] :
+(DefaultPolicy == TAIL_AGNOSTIC) ?
+  llvm::PoisonValue::get(ResultType) : Ops[NF];
+