[clang] [clang] Introduce target-specific `Sema` components (PR #93179)

2024-05-23 Thread Matt Arsenault via cfe-commits

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


[clang] [clang] Introduce target-specific `Sema` components (PR #93179)

2024-05-23 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm commented:

Should update the GitHub autolabeler paths for the targets 

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


[clang] [clang] Introduce target-specific `Sema` components (PR #93179)

2024-05-23 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

The only thing clang-format complain about is switches for builtins for ARM, 
Hexagon, MIPS, and SystemZ. I don't feel like it makes improvements there, but 
open for input from contributors in those areas.

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


[clang] [clang] Introduce target-specific `Sema` components (PR #93179)

2024-05-23 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 781b13538e55a42b2d02bb4d21779f15ff8a640c 
6e68c960bde622eb244f726d97982219b08a68bf -- 
clang/include/clang/Sema/SemaAMDGPU.h clang/include/clang/Sema/SemaARM.h 
clang/include/clang/Sema/SemaBPF.h clang/include/clang/Sema/SemaHexagon.h 
clang/include/clang/Sema/SemaLoongArch.h clang/include/clang/Sema/SemaMIPS.h 
clang/include/clang/Sema/SemaNVPTX.h clang/include/clang/Sema/SemaPPC.h 
clang/include/clang/Sema/SemaSystemZ.h clang/include/clang/Sema/SemaWasm.h 
clang/lib/Sema/SemaAMDGPU.cpp clang/lib/Sema/SemaARM.cpp 
clang/lib/Sema/SemaBPF.cpp clang/lib/Sema/SemaHexagon.cpp 
clang/lib/Sema/SemaLoongArch.cpp clang/lib/Sema/SemaMIPS.cpp 
clang/lib/Sema/SemaNVPTX.cpp clang/lib/Sema/SemaPPC.cpp 
clang/lib/Sema/SemaSystemZ.cpp clang/lib/Sema/SemaWasm.cpp 
clang/include/clang/Sema/Sema.h clang/lib/Parse/ParseOpenMP.cpp 
clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaChecking.cpp 
clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclAttr.cpp 
clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
clang/utils/TableGen/MveEmitter.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/SemaARM.cpp b/clang/lib/Sema/SemaARM.cpp
index c1280190ff..f6e4a28d44 100644
--- a/clang/lib/Sema/SemaARM.cpp
+++ b/clang/lib/Sema/SemaARM.cpp
@@ -1082,11 +1082,18 @@ bool SemaARM::CheckAArch64BuiltinFunctionCall(const 
TargetInfo ,
   // range check them here.
   unsigned i = 0, l = 0, u = 0;
   switch (BuiltinID) {
-  default: return false;
+  default:
+return false;
   case AArch64::BI__builtin_arm_dmb:
   case AArch64::BI__builtin_arm_dsb:
-  case AArch64::BI__builtin_arm_isb: l = 0; u = 15; break;
-  case AArch64::BI__builtin_arm_tcancel: l = 0; u = 65535; break;
+  case AArch64::BI__builtin_arm_isb:
+l = 0;
+u = 15;
+break;
+  case AArch64::BI__builtin_arm_tcancel:
+l = 0;
+u = 65535;
+break;
   }
 
   return SemaRef.BuiltinConstantArgRange(TheCall, i, l, u + l);
diff --git a/clang/lib/Sema/SemaHexagon.cpp b/clang/lib/Sema/SemaHexagon.cpp
index 5c921c0bc9..25331fc3b3 100644
--- a/clang/lib/Sema/SemaHexagon.cpp
+++ b/clang/lib/Sema/SemaHexagon.cpp
@@ -35,214 +35,200 @@ bool SemaHexagon::CheckHexagonBuiltinArgument(unsigned 
BuiltinID,
   };
 
   static BuiltinInfo Infos[] = {
-{ Hexagon::BI__builtin_circ_ldd,  {{ 3, true,  4,  3 }} },
-{ Hexagon::BI__builtin_circ_ldw,  {{ 3, true,  4,  2 }} },
-{ Hexagon::BI__builtin_circ_ldh,  {{ 3, true,  4,  1 }} },
-{ Hexagon::BI__builtin_circ_lduh, {{ 3, true,  4,  1 }} },
-{ Hexagon::BI__builtin_circ_ldb,  {{ 3, true,  4,  0 }} },
-{ Hexagon::BI__builtin_circ_ldub, {{ 3, true,  4,  0 }} },
-{ Hexagon::BI__builtin_circ_std,  {{ 3, true,  4,  3 }} },
-{ Hexagon::BI__builtin_circ_stw,  {{ 3, true,  4,  2 }} },
-{ Hexagon::BI__builtin_circ_sth,  {{ 3, true,  4,  1 }} },
-{ Hexagon::BI__builtin_circ_sthhi,{{ 3, true,  4,  1 }} },
-{ Hexagon::BI__builtin_circ_stb,  {{ 3, true,  4,  0 }} },
+  {Hexagon::BI__builtin_circ_ldd, {{3, true, 4, 3}}},
+  {Hexagon::BI__builtin_circ_ldw, {{3, true, 4, 2}}},
+  {Hexagon::BI__builtin_circ_ldh, {{3, true, 4, 1}}},
+  {Hexagon::BI__builtin_circ_lduh, {{3, true, 4, 1}}},
+  {Hexagon::BI__builtin_circ_ldb, {{3, true, 4, 0}}},
+  {Hexagon::BI__builtin_circ_ldub, {{3, true, 4, 0}}},
+  {Hexagon::BI__builtin_circ_std, {{3, true, 4, 3}}},
+  {Hexagon::BI__builtin_circ_stw, {{3, true, 4, 2}}},
+  {Hexagon::BI__builtin_circ_sth, {{3, true, 4, 1}}},
+  {Hexagon::BI__builtin_circ_sthhi, {{3, true, 4, 1}}},
+  {Hexagon::BI__builtin_circ_stb, {{3, true, 4, 0}}},
 
-{ Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci,{{ 1, true,  4,  0 }} },
-{ Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci, {{ 1, true,  4,  0 }} },
-{ Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci,{{ 1, true,  4,  1 }} },
-{ Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci, {{ 1, true,  4,  1 }} },
-{ Hexagon::BI__builtin_HEXAGON_L2_loadri_pci, {{ 1, true,  4,  2 }} },
-{ Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci, {{ 1, true,  4,  3 }} },
-{ Hexagon::BI__builtin_HEXAGON_S2_storerb_pci,{{ 1, true,  4,  0 }} },
-{ Hexagon::BI__builtin_HEXAGON_S2_storerh_pci,{{ 1, true,  4,  1 }} },
-{ Hexagon::BI__builtin_HEXAGON_S2_storerf_pci,{{ 1, true,  4,  1 }} },
-{ Hexagon::BI__builtin_HEXAGON_S2_storeri_pci,{{ 1, true,  4,  2 }} },
-{ Hexagon::BI__builtin_HEXAGON_S2_storerd_pci,{{ 1, true,  4,  3 }} },
+  {Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci, {{1, true, 4, 0}}},
+  

[clang] [clang] Introduce target-specific `Sema` components (PR #93179)

2024-05-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-systemz

Author: Vlad Serebrennikov (Endilll)


Changes

This patch introduces `SemaAMDGPU`, `SemaARM`, `SemaBPF`, `SemaHexagon`, 
`SemaLoongArch`, `SemaMIPS`, `SemaNVPTX`, `SemaPPC`, `SemaSystemZ`, `SemaWasm`. 
This continues previous efforts to split Sema up. Additional context can be 
found in #84184 and #92682.

I decided to bundle target-specific components together because of their low 
impact on `Sema`. That said, their impact on `SemaChecking.cpp` is far from 
low, and I consider it a success.

Somewhat accidentally, I also moved Wasm- and AMDGPU-specific function from 
`SemaDeclAttr.cpp`, because they were exposed in `Sema`. That went well, and I 
consider it a success, too. I'd like to move the rest of static target-specific 
functions out of `SemaDeclAttr.cpp` like we're doing with built-ins in 
`SemaChecking.cpp` .

---

Patch is 349.72 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/93179.diff


30 Files Affected:

- (modified) clang/include/clang/Sema/Sema.h (+123-95) 
- (added) clang/include/clang/Sema/SemaAMDGPU.h (+68) 
- (added) clang/include/clang/Sema/SemaARM.h (+63) 
- (added) clang/include/clang/Sema/SemaBPF.h (+28) 
- (added) clang/include/clang/Sema/SemaHexagon.h (+29) 
- (added) clang/include/clang/Sema/SemaLoongArch.h (+30) 
- (added) clang/include/clang/Sema/SemaMIPS.h (+33) 
- (added) clang/include/clang/Sema/SemaNVPTX.h (+30) 
- (added) clang/include/clang/Sema/SemaPPC.h (+58) 
- (added) clang/include/clang/Sema/SemaSystemZ.h (+28) 
- (added) clang/include/clang/Sema/SemaWasm.h (+52) 
- (modified) clang/lib/Parse/ParseOpenMP.cpp (+3-2) 
- (modified) clang/lib/Sema/CMakeLists.txt (+10) 
- (modified) clang/lib/Sema/Sema.cpp (+20) 
- (added) clang/lib/Sema/SemaAMDGPU.cpp (+289) 
- (added) clang/lib/Sema/SemaARM.cpp (+1095) 
- (added) clang/lib/Sema/SemaBPF.cpp (+174) 
- (modified) clang/lib/Sema/SemaChecking.cpp (+31-2979) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+8-6) 
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+50-382) 
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+2-1) 
- (added) clang/lib/Sema/SemaHexagon.cpp (+290) 
- (added) clang/lib/Sema/SemaLoongArch.cpp (+515) 
- (added) clang/lib/Sema/SemaMIPS.cpp (+240) 
- (added) clang/lib/Sema/SemaNVPTX.cpp (+35) 
- (added) clang/lib/Sema/SemaPPC.cpp (+439) 
- (added) clang/lib/Sema/SemaSystemZ.cpp (+94) 
- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+4-3) 
- (added) clang/lib/Sema/SemaWasm.cpp (+340) 
- (modified) clang/utils/TableGen/MveEmitter.cpp (+5-4) 


``diff
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 057ff61ccc644..e19509c811805 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -67,6 +67,7 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/TinyPtrVector.h"
 #include 
 #include 
@@ -168,15 +169,25 @@ class Preprocessor;
 class PseudoDestructorTypeStorage;
 class PseudoObjectExpr;
 class QualType;
+class SemaAMDGPU;
+class SemaARM;
+class SemaBPF;
 class SemaCodeCompletion;
 class SemaCUDA;
 class SemaHLSL;
+class SemaHexagon;
+class SemaLoongArch;
+class SemaMIPS;
+class SemaNVPTX;
 class SemaObjC;
 class SemaOpenACC;
 class SemaOpenMP;
+class SemaPPC;
 class SemaPseudoObject;
 class SemaRISCV;
 class SemaSYCL;
+class SemaSystemZ;
+class SemaWasm;
 class SemaX86;
 class StandardConversionSequence;
 class Stmt;
@@ -993,6 +1004,21 @@ class Sema final : public SemaBase {
   /// CurContext - This is the current declaration context of parsing.
   DeclContext *CurContext;
 
+  SemaAMDGPU () {
+assert(AMDGPUPtr);
+return *AMDGPUPtr;
+  }
+
+  SemaARM () {
+assert(ARMPtr);
+return *ARMPtr;
+  }
+
+  SemaBPF () {
+assert(BPFPtr);
+return *BPFPtr;
+  }
+
   SemaCodeCompletion () {
 assert(CodeCompletionPtr);
 return *CodeCompletionPtr;
@@ -1008,6 +1034,26 @@ class Sema final : public SemaBase {
 return *HLSLPtr;
   }
 
+  SemaHexagon () {
+assert(HexagonPtr);
+return *HexagonPtr;
+  }
+
+  SemaLoongArch () {
+assert(LoongArchPtr);
+return *LoongArchPtr;
+  }
+
+  SemaMIPS () {
+assert(MIPSPtr);
+return *MIPSPtr;
+  }
+
+  SemaNVPTX () {
+assert(NVPTXPtr);
+return *NVPTXPtr;
+  }
+
   SemaObjC () {
 assert(ObjCPtr);
 return *ObjCPtr;
@@ -1023,6 +1069,11 @@ class Sema final : public SemaBase {
 return *OpenMPPtr;
   }
 
+  SemaPPC () {
+assert(PPCPtr);
+return *PPCPtr;
+  }
+
   SemaPseudoObject () {
 assert(PseudoObjectPtr);
 return *PseudoObjectPtr;
@@ -1038,6 +1089,16 @@ class Sema final : public SemaBase {
 return *SYCLPtr;
   }
 
+  SemaSystemZ () {
+assert(SystemZPtr);
+return *SystemZPtr;
+  }
+
+  SemaWasm () {
+assert(WasmPtr);
+return *WasmPtr;
+  }
+
   SemaX86 () {
 assert(X86Ptr);
 return *X86Ptr;

[clang] [clang] Introduce target-specific `Sema` components (PR #93179)

2024-05-23 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-amdgpu

Author: Vlad Serebrennikov (Endilll)


Changes

This patch introduces `SemaAMDGPU`, `SemaARM`, `SemaBPF`, `SemaHexagon`, 
`SemaLoongArch`, `SemaMIPS`, `SemaNVPTX`, `SemaPPC`, `SemaSystemZ`, `SemaWasm`. 
This continues previous efforts to split Sema up. Additional context can be 
found in #84184 and #92682.

I decided to bundle target-specific components together because of their low 
impact on `Sema`. That said, their impact on `SemaChecking.cpp` is far from 
low, and I consider it a success.

Somewhat accidentally, I also moved Wasm- and AMDGPU-specific function from 
`SemaDeclAttr.cpp`, because they were exposed in `Sema`. That went well, and I 
consider it a success, too. I'd like to move the rest of static target-specific 
functions out of `SemaDeclAttr.cpp` like we're doing with built-ins in 
`SemaChecking.cpp` .

---

Patch is 349.72 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/93179.diff


30 Files Affected:

- (modified) clang/include/clang/Sema/Sema.h (+123-95) 
- (added) clang/include/clang/Sema/SemaAMDGPU.h (+68) 
- (added) clang/include/clang/Sema/SemaARM.h (+63) 
- (added) clang/include/clang/Sema/SemaBPF.h (+28) 
- (added) clang/include/clang/Sema/SemaHexagon.h (+29) 
- (added) clang/include/clang/Sema/SemaLoongArch.h (+30) 
- (added) clang/include/clang/Sema/SemaMIPS.h (+33) 
- (added) clang/include/clang/Sema/SemaNVPTX.h (+30) 
- (added) clang/include/clang/Sema/SemaPPC.h (+58) 
- (added) clang/include/clang/Sema/SemaSystemZ.h (+28) 
- (added) clang/include/clang/Sema/SemaWasm.h (+52) 
- (modified) clang/lib/Parse/ParseOpenMP.cpp (+3-2) 
- (modified) clang/lib/Sema/CMakeLists.txt (+10) 
- (modified) clang/lib/Sema/Sema.cpp (+20) 
- (added) clang/lib/Sema/SemaAMDGPU.cpp (+289) 
- (added) clang/lib/Sema/SemaARM.cpp (+1095) 
- (added) clang/lib/Sema/SemaBPF.cpp (+174) 
- (modified) clang/lib/Sema/SemaChecking.cpp (+31-2979) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+8-6) 
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+50-382) 
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+2-1) 
- (added) clang/lib/Sema/SemaHexagon.cpp (+290) 
- (added) clang/lib/Sema/SemaLoongArch.cpp (+515) 
- (added) clang/lib/Sema/SemaMIPS.cpp (+240) 
- (added) clang/lib/Sema/SemaNVPTX.cpp (+35) 
- (added) clang/lib/Sema/SemaPPC.cpp (+439) 
- (added) clang/lib/Sema/SemaSystemZ.cpp (+94) 
- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+4-3) 
- (added) clang/lib/Sema/SemaWasm.cpp (+340) 
- (modified) clang/utils/TableGen/MveEmitter.cpp (+5-4) 


``diff
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 057ff61ccc644..e19509c811805 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -67,6 +67,7 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/TinyPtrVector.h"
 #include 
 #include 
@@ -168,15 +169,25 @@ class Preprocessor;
 class PseudoDestructorTypeStorage;
 class PseudoObjectExpr;
 class QualType;
+class SemaAMDGPU;
+class SemaARM;
+class SemaBPF;
 class SemaCodeCompletion;
 class SemaCUDA;
 class SemaHLSL;
+class SemaHexagon;
+class SemaLoongArch;
+class SemaMIPS;
+class SemaNVPTX;
 class SemaObjC;
 class SemaOpenACC;
 class SemaOpenMP;
+class SemaPPC;
 class SemaPseudoObject;
 class SemaRISCV;
 class SemaSYCL;
+class SemaSystemZ;
+class SemaWasm;
 class SemaX86;
 class StandardConversionSequence;
 class Stmt;
@@ -993,6 +1004,21 @@ class Sema final : public SemaBase {
   /// CurContext - This is the current declaration context of parsing.
   DeclContext *CurContext;
 
+  SemaAMDGPU () {
+assert(AMDGPUPtr);
+return *AMDGPUPtr;
+  }
+
+  SemaARM () {
+assert(ARMPtr);
+return *ARMPtr;
+  }
+
+  SemaBPF () {
+assert(BPFPtr);
+return *BPFPtr;
+  }
+
   SemaCodeCompletion () {
 assert(CodeCompletionPtr);
 return *CodeCompletionPtr;
@@ -1008,6 +1034,26 @@ class Sema final : public SemaBase {
 return *HLSLPtr;
   }
 
+  SemaHexagon () {
+assert(HexagonPtr);
+return *HexagonPtr;
+  }
+
+  SemaLoongArch () {
+assert(LoongArchPtr);
+return *LoongArchPtr;
+  }
+
+  SemaMIPS () {
+assert(MIPSPtr);
+return *MIPSPtr;
+  }
+
+  SemaNVPTX () {
+assert(NVPTXPtr);
+return *NVPTXPtr;
+  }
+
   SemaObjC () {
 assert(ObjCPtr);
 return *ObjCPtr;
@@ -1023,6 +1069,11 @@ class Sema final : public SemaBase {
 return *OpenMPPtr;
   }
 
+  SemaPPC () {
+assert(PPCPtr);
+return *PPCPtr;
+  }
+
   SemaPseudoObject () {
 assert(PseudoObjectPtr);
 return *PseudoObjectPtr;
@@ -1038,6 +1089,16 @@ class Sema final : public SemaBase {
 return *SYCLPtr;
   }
 
+  SemaSystemZ () {
+assert(SystemZPtr);
+return *SystemZPtr;
+  }
+
+  SemaWasm () {
+assert(WasmPtr);
+return *WasmPtr;
+  }
+
   SemaX86 () {
 assert(X86Ptr);
 return *X86Ptr;
@@