r332105 - [Hexagon] Implement checking arguments of builtin calls

2018-05-11 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Fri May 11 09:41:51 2018
New Revision: 332105

URL: http://llvm.org/viewvc/llvm-project?rev=332105&view=rev
Log:
[Hexagon] Implement checking arguments of builtin calls

Added:
cfe/trunk/test/CodeGen/hexagon-check-builtins.c
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=332105&r1=332104&r2=332105&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri May 11 09:41:51 2018
@@ -10380,6 +10380,7 @@ private:
   bool CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
 
   bool CheckAArch64BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
+  bool CheckHexagonBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckMipsBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall);

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=332105&r1=332104&r2=332105&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri May 11 09:41:51 2018
@@ -1295,6 +1295,10 @@ Sema::CheckBuiltinFunctionCall(FunctionD
 if (CheckAArch64BuiltinFunctionCall(BuiltinID, TheCall))
   return ExprError();
 break;
+  case llvm::Triple::hexagon:
+if (CheckHexagonBuiltinFunctionCall(BuiltinID, TheCall))
+  return ExprError();
+break;
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:
@@ -1671,6 +1675,225 @@ bool Sema::CheckAArch64BuiltinFunctionCa
   return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
 }
 
+bool Sema::CheckHexagonBuiltinFunctionCall(unsigned BuiltinID,
+   CallExpr *TheCall) {
+  struct ArgInfo {
+ArgInfo(unsigned O, bool S, unsigned W, unsigned A)
+  : OpNum(O), IsSigned(S), BitWidth(W), Align(A) {}
+unsigned OpNum = 0;
+bool IsSigned = false;
+unsigned BitWidth = 0;
+unsigned Align = 0;
+  };
+
+  static const std::map> 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,  0 }} },
+{ 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_A2_combineii,  {{ 1, true,  8,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A2_tfrih,  {{ 1, false, 16, 0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A2_tfril,  {{ 1, false, 16, 0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A2_tfrpi,  {{ 0, true,  8,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A4_bitspliti,  {{ 1, false, 5,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi,{{ 1, false, 8,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A4_cmpbgti,{{ 1, true,  8,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A4_cround_ri,  {{ 1, false, 5,  0 }} },
+{ Hexagon::BI__builtin_HEXAGON_A4_round_ri,   {{

r332383 - [Hexagon] Add driver options for subtarget features

2018-05-15 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Tue May 15 11:15:59 2018
New Revision: 332383

URL: http://llvm.org/viewvc/llvm-project?rev=332383&view=rev
Log:
[Hexagon] Add driver options for subtarget features

Added:
cfe/trunk/test/Driver/hexagon-memops.c
cfe/trunk/test/Driver/hexagon-nvj.c
cfe/trunk/test/Driver/hexagon-nvs.c
Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=332383&r1=332382&r2=332383&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue May 15 11:15:59 2018
@@ -2562,23 +2562,35 @@ def mv62 : Flag<["-"], "mv62">, Group, AliasArgs<["hexagonv62"]>;
 def mv65 : Flag<["-"], "mv65">, Group,
   Alias, AliasArgs<["hexagonv65"]>;
-def mhexagon_hvx : Flag<[ "-" ], "mhvx">, Group,
+def mhexagon_hvx : Flag<["-"], "mhvx">, Group,
   HelpText<"Enable Hexagon Vector eXtensions">;
-def mhexagon_hvx_EQ : Joined<[ "-" ], "mhvx=">,
+def mhexagon_hvx_EQ : Joined<["-"], "mhvx=">,
   Group,
   HelpText<"Enable Hexagon Vector eXtensions">;
-def mno_hexagon_hvx : Flag<[ "-" ], "mno-hvx">,
+def mno_hexagon_hvx : Flag<["-"], "mno-hvx">,
   Group,
   HelpText<"Disable Hexagon Vector eXtensions">;
-def mhexagon_hvx_length_EQ : Joined<[ "-" ], "mhvx-length=">,
+def mhexagon_hvx_length_EQ : Joined<["-"], "mhvx-length=">,
   Group, HelpText<"Set Hexagon Vector Length">,
   Values<"64B,128B">;
 def ffixed_r19: Flag<["-"], "ffixed-r19">,
-  HelpText<"Reserve the r19 register (Hexagon only)">;
+  HelpText<"Reserve register r19 (Hexagon only)">;
+def mmemops : Flag<["-"], "mmemops">, Group,
+  Flags<[CC1Option]>, HelpText<"Enable generation of memop instructions">;
+def mno_memops : Flag<["-"], "mno-memops">, Group,
+  Flags<[CC1Option]>, HelpText<"Disable generation of memop instructions">;
 def mpackets : Flag<["-"], "mpackets">, Group,
   Flags<[CC1Option]>, HelpText<"Enable generation of instruction packets">;
 def mno_packets : Flag<["-"], "mno-packets">, Group,
   Flags<[CC1Option]>, HelpText<"Disable generation of instruction packets">;
+def mnvj : Flag<["-"], "mnvj">, Group,
+  Flags<[CC1Option]>, HelpText<"Enable generation of new-value jumps">;
+def mno_nvj : Flag<["-"], "mno-nvj">, Group,
+  Flags<[CC1Option]>, HelpText<"Disable generation of new-value jumps">;
+def mnvs : Flag<["-"], "mnvs">, Group,
+  Flags<[CC1Option]>, HelpText<"Enable generation of new-value stores">;
+def mno_nvs : Flag<["-"], "mno-nvs">, Group,
+  Flags<[CC1Option]>, HelpText<"Disable generation of new-value stores">;
 
 
 // X86 feature flags

Added: cfe/trunk/test/Driver/hexagon-memops.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-memops.c?rev=332383&view=auto
==
--- cfe/trunk/test/Driver/hexagon-memops.c (added)
+++ cfe/trunk/test/Driver/hexagon-memops.c Tue May 15 11:15:59 2018
@@ -0,0 +1,10 @@
+// RUN: %clang -target hexagon -### -mmemops %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-MEMOPS
+
+// RUN: %clang -target hexagon -### -mno-memops %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-MEMOPS
+
+// CHECK-MEMOPS: "-target-feature" "+memops"
+
+// CHECK-NO-MEMOPS: "-target-feature" "-memops"
+

Added: cfe/trunk/test/Driver/hexagon-nvj.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-nvj.c?rev=332383&view=auto
==
--- cfe/trunk/test/Driver/hexagon-nvj.c (added)
+++ cfe/trunk/test/Driver/hexagon-nvj.c Tue May 15 11:15:59 2018
@@ -0,0 +1,10 @@
+// RUN: %clang -target hexagon -### -mnvj %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NVJ
+
+// RUN: %clang -target hexagon -### -mno-nvj %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-NVJ
+
+// CHECK-NVJ: "-target-feature" "+nvj"
+
+// CHECK-NO-NVJ: "-target-feature" "-nvj"
+

Added: cfe/trunk/test/Driver/hexagon-nvs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-nvs.c?rev=332383&view=auto
==
--- cfe/trunk/test/Driver/hexagon-nvs.c (added)
+++ cfe/trunk/test/Driver/hexagon-nvs.c Tue May 15 11:15:59 2018
@@ -0,0 +1,10 @@
+// RUN: %clang -target hexagon -### -mnvs %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NVS
+
+// RUN: %clang -target hexagon -### -mno-nvs %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-NVS
+
+// CHECK-NVS: "-target-feature" "+nvs"
+
+// CHECK-NO-NVS: "-target-feature" "-nvs"
+


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


r340622 - [Hexagon] Remove unneeded strings from builtin definitions, NFC

2018-08-24 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Fri Aug 24 10:13:42 2018
New Revision: 340622

URL: http://llvm.org/viewvc/llvm-project?rev=340622&view=rev
Log:
[Hexagon] Remove unneeded strings from builtin definitions, NFC

Modified:
cfe/trunk/include/clang/Basic/BuiltinsHexagon.def

Modified: cfe/trunk/include/clang/Basic/BuiltinsHexagon.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsHexagon.def?rev=340622&r1=340621&r2=340622&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsHexagon.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsHexagon.def Fri Aug 24 10:13:42 2018
@@ -912,827 +912,827 @@ BUILTIN(__builtin_HEXAGON_Y2_dczeroa,"vv
 BUILTIN(__builtin_HEXAGON_Y4_l2fetch,"vv*Ui","")
 BUILTIN(__builtin_HEXAGON_Y5_l2fetch,"vv*LLUi","")
 
-BUILTIN(__builtin_HEXAGON_S6_rol_i_r,"iii","v:60:")
-BUILTIN(__builtin_HEXAGON_S6_rol_i_p,"LLiLLii","v:60:")
-BUILTIN(__builtin_HEXAGON_S6_rol_i_r_acc,"","v:60:")
-BUILTIN(__builtin_HEXAGON_S6_rol_i_p_acc,"LLiLLiLLii","v:60:")
-BUILTIN(__builtin_HEXAGON_S6_rol_i_r_nac,"","v:60:")
-BUILTIN(__builtin_HEXAGON_S6_rol_i_p_nac,"LLiLLiLLii","v:60:")
-BUILTIN(__builtin_HEXAGON_S6_rol_i_r_xacc,"","v:60:")
-BUILTIN(__builtin_HEXAGON_S6_rol_i_p_xacc,"LLiLLiLLii","v:60:")
-BUILTIN(__builtin_HEXAGON_S6_rol_i_r_and,"","v:60:")
-BUILTIN(__builtin_HEXAGON_S6_rol_i_r_or,"","v:60:")
-BUILTIN(__builtin_HEXAGON_S6_rol_i_p_and,"LLiLLiLLii","v:60:")
-BUILTIN(__builtin_HEXAGON_S6_rol_i_p_or,"LLiLLiLLii","v:60:")
-BUILTIN(__builtin_HEXAGON_S2_cabacencbin,"LLiLLiLLii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_valignb,"V16iV16iV16ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_valignb_128B,"V32iV32iV32ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vlalignb,"V16iV16iV16ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vlalignb_128B,"V32iV32iV32ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_valignbi,"V16iV16iV16ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_valignbi_128B,"V32iV32iV32ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vlalignbi,"V16iV16iV16ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vlalignbi_128B,"V32iV32iV32ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vror,"V16iV16ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vror_128B,"V32iV32ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vunpackub,"V32iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vunpackub_128B,"V64iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vunpackb,"V32iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vunpackb_128B,"V64iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vunpackuh,"V32iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vunpackuh_128B,"V64iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vunpackh,"V32iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vunpackh_128B,"V64iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vunpackob,"V32iV32iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vunpackob_128B,"V64iV64iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vunpackoh,"V32iV32iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vunpackoh_128B,"V64iV64iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackeb,"V16iV16iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackeb_128B,"V32iV32iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackeh,"V16iV16iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackeh_128B,"V32iV32iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackob,"V16iV16iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackob_128B,"V32iV32iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackoh,"V16iV16iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackoh_128B,"V32iV32iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackhub_sat,"V16iV16iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackhub_sat_128B,"V32iV32iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackhb_sat,"V16iV16iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackhb_sat_128B,"V32iV32iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackwuh_sat,"V16iV16iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackwuh_sat_128B,"V32iV32iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackwh_sat,"V16iV16iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vpackwh_sat_128B,"V32iV32iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vzb,"V32iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vzb_128B,"V64iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vsb,"V32iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vsb_128B,"V64iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vzh,"V32iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vzh_128B,"V64iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vsh,"V32iV16i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vsh_128B,"V64iV32i","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vdmpybus,"V16iV16ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vdmpybus_128B,"V32iV32ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vdmpybus_acc,"V16iV16iV16ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vdmpybus_acc_128B,"V32iV32iV32ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv,"V32iV32ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vdmpybus_dv_128B,"V64iV64ii","v:60:")
-BUILTIN(__builtin_HEXAGON_V6_vdmpyb

r303851 - [CodeGen] Pessimize aliasing for member unions (and may-alias) objects

2017-05-25 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Thu May 25 07:55:47 2017
New Revision: 303851

URL: http://llvm.org/viewvc/llvm-project?rev=303851&view=rev
Log:
[CodeGen] Pessimize aliasing for member unions (and may-alias) objects

Use the TBAA info of the omnipotent char for these objects.

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

Added:
cfe/trunk/test/CodeGen/union-tbaa1.c
cfe/trunk/test/CodeGenCXX/union-tbaa2.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=303851&r1=303850&r2=303851&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu May 25 07:55:47 2017
@@ -1432,11 +1432,12 @@ llvm::Value *CodeGenFunction::EmitLoadOf
 Load->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
   }
   if (TBAAInfo) {
-llvm::MDNode *TBAAPath = CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo,
-  TBAAOffset);
-if (TBAAPath)
-  CGM.DecorateInstructionWithTBAA(Load, TBAAPath,
-  false /*ConvertTypeToTag*/);
+bool MayAlias = BaseInfo.getMayAlias();
+llvm::MDNode *TBAA = MayAlias
+? CGM.getTBAAInfo(getContext().CharTy)
+: CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo, TBAAOffset);
+if (TBAA)
+  CGM.DecorateInstructionWithTBAA(Load, TBAA, MayAlias);
   }
 
   if (EmitScalarRangeCheck(Load, Ty, Loc)) {
@@ -1522,11 +1523,12 @@ void CodeGenFunction::EmitStoreOfScalar(
 Store->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node);
   }
   if (TBAAInfo) {
-llvm::MDNode *TBAAPath = CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo,
-  TBAAOffset);
-if (TBAAPath)
-  CGM.DecorateInstructionWithTBAA(Store, TBAAPath,
-  false /*ConvertTypeToTag*/);
+bool MayAlias = BaseInfo.getMayAlias();
+llvm::MDNode *TBAA = MayAlias
+? CGM.getTBAAInfo(getContext().CharTy)
+: CGM.getTBAAStructTagInfo(TBAABaseType, TBAAInfo, TBAAOffset);
+if (TBAA)
+  CGM.DecorateInstructionWithTBAA(Store, TBAA, MayAlias);
   }
 }
 
@@ -3535,6 +3537,11 @@ LValue CodeGenFunction::EmitLValueForFie
 getFieldAlignmentSource(BaseInfo.getAlignmentSource());
   LValueBaseInfo FieldBaseInfo(fieldAlignSource, BaseInfo.getMayAlias());
 
+  const RecordDecl *rec = field->getParent();
+  if (rec->isUnion() || rec->hasAttr())
+FieldBaseInfo.setMayAlias(true);
+  bool mayAlias = FieldBaseInfo.getMayAlias();
+
   if (field->isBitField()) {
 const CGRecordLayout &RL =
   CGM.getTypes().getCGRecordLayout(field->getParent());
@@ -3556,11 +3563,7 @@ LValue CodeGenFunction::EmitLValueForFie
 return LValue::MakeBitfield(Addr, Info, fieldType, FieldBaseInfo);
   }
 
-  const RecordDecl *rec = field->getParent();
   QualType type = field->getType();
-
-  bool mayAlias = rec->hasAttr();
-
   Address addr = base.getAddress();
   unsigned cvr = base.getVRQualifiers();
   bool TBAAPath = CGM.getCodeGenOpts().StructPathTBAA;

Added: cfe/trunk/test/CodeGen/union-tbaa1.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/union-tbaa1.c?rev=303851&view=auto
==
--- cfe/trunk/test/CodeGen/union-tbaa1.c (added)
+++ cfe/trunk/test/CodeGen/union-tbaa1.c Thu May 25 07:55:47 2017
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -triple hexagon-unknown-elf -O2 -emit-llvm -o - | 
FileCheck %s
+
+typedef union __attribute__((aligned(4))) {
+  unsigned short uh[2];
+  unsigned uw;
+} vect32;
+
+void bar(vect32 p[][2]);
+
+// CHECK-LABEL: define void @fred
+void fred(unsigned Num, int Vec[2], int *Index, int Arr[4][2]) {
+  vect32 Tmp[4][2];
+// Generate tbaa for the load of Index:
+// CHECK: load i32, i32* %Index{{.*}}tbaa
+// But no tbaa for the two stores:
+// CHECK: %uw[[UW1:[0-9]*]] = getelementptr
+// CHECK: store{{.*}}%uw[[UW1]]
+// CHECK: tbaa ![[OCPATH:[0-9]+]]
+// There will be a load after the store, and it will use tbaa. Make sure
+// the check-not above doesn't find it:
+// CHECK: load
+  Tmp[*Index][0].uw = Arr[*Index][0] * Num;
+// CHECK: %uw[[UW2:[0-9]*]] = getelementptr
+// CHECK: store{{.*}}%uw[[UW2]]
+// CHECK: tbaa ![[OCPATH]]
+  Tmp[*Index][1].uw = Arr[*Index][1] * Num;
+// Same here, don't generate tbaa for the loads:
+// CHECK: %uh[[UH1:[0-9]*]] = bitcast %union.vect32
+// CHECK: %arrayidx[[AX1:[0-9]*]] = getelementptr{{.*}}%uh[[UH1]]
+// CHECK: load i16, i16* %arrayidx[[AX1]]
+// CHECK: tbaa ![[OCPATH]]
+// CHECK: store
+  Vec[0] = Tmp[*Index][0].uh[1];
+// CHECK: %uh[[UH2:[0-9]*]] = bitcast %union.vect32
+// CHECK: %arrayidx[[AX2:[0-9]*]] = getelementptr{{.*}}%uh[[UH2]]
+// CHECK: load i16, i16* %arrayidx[[AX2]]
+// CHECK: tbaa ![[OCPATH]]
+// CHECK: store
+ 

r326366 - [Hexagon] Add -ffixed-r19 driver option and translate it to +reserved-r19

2018-02-28 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Wed Feb 28 12:31:55 2018
New Revision: 326366

URL: http://llvm.org/viewvc/llvm-project?rev=326366&view=rev
Log:
[Hexagon] Add -ffixed-r19 driver option and translate it to +reserved-r19

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
cfe/trunk/test/Driver/hexagon-toolchain-elf.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=326366&r1=326365&r2=326366&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Feb 28 12:31:55 2018
@@ -2496,6 +2496,8 @@ def mno_hexagon_hvx_double
 : Flag<[ "-" ], "mno-hvx-double">,
   Group,
   HelpText<"Disable Hexagon Double Vector eXtensions">;
+def ffixed_r19: Flag<["-"], "ffixed-r19">,
+  HelpText<"Reserve the r19 register (Hexagon only)">;
 
 
 // X86 feature flags

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp?rev=326366&r1=326365&r2=326366&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp Wed Feb 28 12:31:55 2018
@@ -521,11 +521,15 @@ unsigned HexagonToolChain::getOptimizati
 void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs,
  ArgStringList &CC1Args,
  Action::OffloadKind) const {
-  if (DriverArgs.hasArg(options::OPT_ffp_contract))
-return;
-  unsigned OptLevel = getOptimizationLevel(DriverArgs);
-  if (OptLevel >= 3)
-CC1Args.push_back("-ffp-contract=fast");
+  if (!DriverArgs.hasArg(options::OPT_ffp_contract)) {
+unsigned OptLevel = getOptimizationLevel(DriverArgs);
+if (OptLevel >= 3)
+  CC1Args.push_back("-ffp-contract=fast");
+  }
+  if (DriverArgs.hasArg(options::OPT_ffixed_r19)) {
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+reserved-r19");
+  }
 }
 
 void HexagonToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,

Modified: cfe/trunk/test/Driver/hexagon-toolchain-elf.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-toolchain-elf.c?rev=326366&r1=326365&r2=326366&view=diff
==
--- cfe/trunk/test/Driver/hexagon-toolchain-elf.c (original)
+++ cfe/trunk/test/Driver/hexagon-toolchain-elf.c Wed Feb 28 12:31:55 2018
@@ -504,12 +504,22 @@
 // CHECK060-NEXT: hexagon-link
 
 // 
-
+// ffixed-r19
+// 
-
+// RUN: %clang -### -target hexagon-unknown-elf -ffixed-r19 %s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK070 %s
+// CHECK070: "-target-feature" "+reserved-r19"
+// RUN: %clang -### -target hexagon-unknown-elf %s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK071 %s
+// CHECK071-NOT: "+reserved-r19"
+
+// 
-
 // Misc Defaults
 // 
-
 // RUN: %clang -### -target hexagon-unknown-elf \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv60 \
 // RUN:   %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK070 %s
-// CHECK070:  "-cc1"
-// CHECK070:  "-Wreturn-type"
+// RUN:   | FileCheck -check-prefix=CHECK080 %s
+// CHECK080:  "-cc1"
+// CHECK080:  "-Wreturn-type"


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


r327393 - [Hexagon] Clang side of r327302 in LLVM

2018-03-13 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Tue Mar 13 06:30:43 2018
New Revision: 327393

URL: http://llvm.org/viewvc/llvm-project?rev=327393&view=rev
Log:
[Hexagon] Clang side of r327302 in LLVM

Add option -m[no-]packets to control generation of instruction packets
(enabled by default).

Added:
cfe/trunk/test/Driver/hexagon-packets.c
Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=327393&r1=327392&r2=327393&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Mar 13 06:30:43 2018
@@ -2472,41 +2472,45 @@ def _write_dependencies : Flag<["--"], "
 def _write_user_dependencies : Flag<["--"], "write-user-dependencies">, 
Alias;
 def _ : Joined<["--"], "">, Flags<[Unsupported]>;
 
-def mieee_rnd_near : Flag<["-"], "mieee-rnd-near">, 
Group;
+// Hexagon feature flags.
+def mieee_rnd_near : Flag<["-"], "mieee-rnd-near">,
+  Group;
 def mv4 : Flag<["-"], "mv4">, Group,
-  Alias, AliasArgs<["hexagonv4"]>;
+  Alias, AliasArgs<["hexagonv4"]>;
 def mv5 : Flag<["-"], "mv5">, Group, Alias,
-  AliasArgs<["hexagonv5"]>;
+  AliasArgs<["hexagonv5"]>;
 def mv55 : Flag<["-"], "mv55">, Group,
-   Alias, AliasArgs<["hexagonv55"]>;
+  Alias, AliasArgs<["hexagonv55"]>;
 def mv60 : Flag<["-"], "mv60">, Group,
-   Alias, AliasArgs<["hexagonv60"]>;
+  Alias, AliasArgs<["hexagonv60"]>;
 def mv62 : Flag<["-"], "mv62">, Group,
-   Alias, AliasArgs<["hexagonv62"]>;
+  Alias, AliasArgs<["hexagonv62"]>;
 def mv65 : Flag<["-"], "mv65">, Group,
-   Alias, AliasArgs<["hexagonv65"]>;
-def mhexagon_hvx : Flag<[ "-" ], "mhvx">,
-   Group,
-   HelpText<"Enable Hexagon Vector eXtensions">;
+  Alias, AliasArgs<["hexagonv65"]>;
+def mhexagon_hvx : Flag<[ "-" ], "mhvx">, Group,
+  HelpText<"Enable Hexagon Vector eXtensions">;
 def mhexagon_hvx_EQ : Joined<[ "-" ], "mhvx=">,
- Group,
- HelpText<"Enable Hexagon Vector eXtensions">;
+  Group,
+  HelpText<"Enable Hexagon Vector eXtensions">;
 def mno_hexagon_hvx : Flag<[ "-" ], "mno-hvx">,
-  Group,
-  HelpText<"Disable Hexagon Vector eXtensions">;
+  Group,
+  HelpText<"Disable Hexagon Vector eXtensions">;
 def mhexagon_hvx_length_EQ : Joined<[ "-" ], "mhvx-length=">,
-Group,
-HelpText<"Set Hexagon Vector Length">, 
Values<"64B,128B">;
-// hvx-double deprecrated flag.
-def mhexagon_hvx_double : Flag<[ "-" ], "mhvx-double">,
-  Group,
-  HelpText<"Enable Hexagon Double Vector eXtensions">;
-def mno_hexagon_hvx_double
-: Flag<[ "-" ], "mno-hvx-double">,
-  Group,
-  HelpText<"Disable Hexagon Double Vector eXtensions">;
+  Group, HelpText<"Set Hexagon Vector Length">,
+  Values<"64B,128B">;
 def ffixed_r19: Flag<["-"], "ffixed-r19">,
   HelpText<"Reserve the r19 register (Hexagon only)">;
+def mpackets : Flag<["-"], "mpackets">, Group,
+  Flags<[CC1Option]>, HelpText<"Enable generation of instruction packets">;
+def mno_packets : Flag<["-"], "mno-packets">, Group,
+  Flags<[CC1Option]>, HelpText<"Disable generation of instruction packets">;
+// hvx-double deprecrated flag.
+def mhexagon_hvx_double : Flag<[ "-" ], "mhvx-double">,
+  Group,
+  HelpText<"Enable Hexagon Double Vector eXtensions">;
+def mno_hexagon_hvx_double : Flag<[ "-" ], "mno-hvx-double">,
+  Group,
+  HelpText<"Disable Hexagon Double Vector eXtensions">;
 
 
 // X86 feature flags

Added: cfe/trunk/test/Driver/hexagon-packets.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-packets.c?rev=327393&view=auto
==
--- cfe/trunk/test/Driver/hexagon-packets.c (added)
+++ cfe/trunk/test/Driver/hexagon-packets.c Tue Mar 13 06:30:43 2018
@@ -0,0 +1,10 @@
+// RUN: %clang -target hexagon -### -mpackets %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-PACKETS
+
+// RUN: %clang -target hexagon -### -mno-packets %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-PACKETS
+
+// CHECK-PACKETS: "-target-feature" "+packets"
+
+// CHECK-NO-PACKETS: "-target-feature" "-packets"
+


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


r344786 - [Hexagon] Remove support for V4

2018-10-19 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Fri Oct 19 08:36:45 2018
New Revision: 344786

URL: http://llvm.org/viewvc/llvm-project?rev=344786&view=rev
Log:
[Hexagon] Remove support for V4

Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/Hexagon.cpp
cfe/trunk/test/Driver/hexagon-toolchain-elf.c
cfe/trunk/test/Misc/target-invalid-cpu-note.c

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=344786&r1=344785&r2=344786&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Fri Oct 19 08:36:45 2018
@@ -2146,7 +2146,7 @@ Link stack frames through backchain on S
 
 .. option:: -mconsole
 
-.. option:: -mcpu=, -mv4 (equivalent to -mcpu=hexagonv4), -mv5 
(equivalent to -mcpu=hexagonv5), -mv55 (equivalent to -mcpu=hexagonv55), -mv60 
(equivalent to -mcpu=hexagonv60), -mv62 (equivalent to -mcpu=hexagonv62), -mv65 
(equivalent to -mcpu=hexagonv65)
+.. option:: -mcpu=, -mv5 (equivalent to -mcpu=hexagonv5), -mv55 
(equivalent to -mcpu=hexagonv55), -mv60 (equivalent to -mcpu=hexagonv60), -mv62 
(equivalent to -mcpu=hexagonv62), -mv65 (equivalent to -mcpu=hexagonv65)
 
 .. option:: -mcrc, -mno-crc
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=344786&r1=344785&r2=344786&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Oct 19 08:36:45 2018
@@ -2661,8 +2661,6 @@ def _ : Joined<["--"], "">, Flags<[Unsup
 // Hexagon feature flags.
 def mieee_rnd_near : Flag<["-"], "mieee-rnd-near">,
   Group;
-def mv4 : Flag<["-"], "mv4">, Group,
-  Alias, AliasArgs<["hexagonv4"]>;
 def mv5 : Flag<["-"], "mv5">, Group, Alias,
   AliasArgs<["hexagonv5"]>;
 def mv55 : Flag<["-"], "mv55">, Group,

Modified: cfe/trunk/lib/Basic/Targets/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Hexagon.cpp?rev=344786&r1=344785&r2=344786&view=diff
==
--- cfe/trunk/lib/Basic/Targets/Hexagon.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/Hexagon.cpp Fri Oct 19 08:36:45 2018
@@ -25,14 +25,7 @@ void HexagonTargetInfo::getTargetDefines
   Builder.defineMacro("__qdsp6__", "1");
   Builder.defineMacro("__hexagon__", "1");
 
-  if (CPU == "hexagonv4") {
-Builder.defineMacro("__HEXAGON_V4__");
-Builder.defineMacro("__HEXAGON_ARCH__", "4");
-if (Opts.HexagonQdsp6Compat) {
-  Builder.defineMacro("__QDSP6_V4__");
-  Builder.defineMacro("__QDSP6_ARCH__", "4");
-}
-  } else if (CPU == "hexagonv5") {
+  if (CPU == "hexagonv5") {
 Builder.defineMacro("__HEXAGON_V5__");
 Builder.defineMacro("__HEXAGON_ARCH__", "5");
 if (Opts.HexagonQdsp6Compat) {
@@ -150,9 +143,9 @@ struct CPUSuffix {
 };
 
 static constexpr CPUSuffix Suffixes[] = {
-{{"hexagonv4"}, {"4"}},   {{"hexagonv5"}, {"5"}},
-{{"hexagonv55"}, {"55"}}, {{"hexagonv60"}, {"60"}},
-{{"hexagonv62"}, {"62"}}, {{"hexagonv65"}, {"65"}},
+{{"hexagonv5"},  {"5"}},  {{"hexagonv55"}, {"55"}},
+{{"hexagonv60"}, {"60"}}, {{"hexagonv62"}, {"62"}},
+{{"hexagonv65"}, {"65"}},
 };
 
 const char *HexagonTargetInfo::getHexagonCPUSuffix(StringRef Name) {

Modified: cfe/trunk/test/Driver/hexagon-toolchain-elf.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-toolchain-elf.c?rev=344786&r1=344785&r2=344786&view=diff
==
--- cfe/trunk/test/Driver/hexagon-toolchain-elf.c (original)
+++ cfe/trunk/test/Driver/hexagon-toolchain-elf.c Fri Oct 19 08:36:45 2018
@@ -59,14 +59,6 @@
 // 
-
 // RUN: %clang -### -target hexagon-unknown-elf \
 // RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
-// RUN:   -mcpu=hexagonv4 \
-// RUN:   %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK020 %s
-// CHECK020: "-cc1" {{.*}} "-target-cpu" "hexagonv4"
-// CHECK020: 
{{hexagon-link|ld}}{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v4/crt0
-
-// RUN: %clang -### -target hexagon-unknown-elf \
-// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
 // RUN:   -mcpu=hexagonv5 \
 // RUN:   %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK021 %s

Modified: cfe/trunk/test/Misc/target-invalid-cpu-note.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/target-invalid-cpu-note.c?rev=344786&r1=344785&r2=344786&view=diff
==
--- cfe/trunk/test/Misc/target-invalid-cpu-n

r345170 - [Hexagon] Flip hexagon-autohvx to be true by default

2018-10-24 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Wed Oct 24 10:55:18 2018
New Revision: 345170

URL: http://llvm.org/viewvc/llvm-project?rev=345170&view=rev
Log:
[Hexagon] Flip hexagon-autohvx to be true by default

This will allow other generators of LLVM IR to use the auto-vectorizer
without having to change that flag.

Note: on its own, this patch will disable auto-vectorization on Hexagon
in all cases, regardless of the -fvectorize flag. There is a companion
LLVM patch that together with this one forms an NFC for clang users.

Modified:
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
cfe/trunk/test/Driver/hexagon-vectorize.c

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp?rev=345170&r1=345169&r2=345170&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp Wed Oct 24 10:55:18 2018
@@ -516,9 +516,9 @@ void HexagonToolChain::addClangTargetOpt
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+reserved-r19");
   }
-  if (isAutoHVXEnabled(DriverArgs)) {
+  if (!isAutoHVXEnabled(DriverArgs)) {
 CC1Args.push_back("-mllvm");
-CC1Args.push_back("-hexagon-autohvx");
+CC1Args.push_back("-hexagon-autohvx=0");
   }
 }
 

Modified: cfe/trunk/test/Driver/hexagon-vectorize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-vectorize.c?rev=345170&r1=345169&r2=345170&view=diff
==
--- cfe/trunk/test/Driver/hexagon-vectorize.c (original)
+++ cfe/trunk/test/Driver/hexagon-vectorize.c Wed Oct 24 10:55:18 2018
@@ -3,7 +3,7 @@
 // RUN: %clang -target hexagon -fvectorize -fno-vectorize -### %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-NOVECTOR
 // RUN: %clang -target hexagon -fvectorize -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-NEEDHVX
 
-// CHECK-DEFAULT-NOT: hexagon-autohvx
-// CHECK-VECTOR: "-mllvm" "-hexagon-autohvx"
-// CHECK-NOVECTOR-NOT: hexagon-autohvx
+// CHECK-DEFAULT: -hexagon-autohvx={{false|0}}
+// CHECK-VECTOR-NOT: -hexagon-autohvx={{false|0}}
+// CHECK-NOVECTOR: -hexagon-autohvx={{false|0}}
 // CHECK-NEEDHVX: warning: auto-vectorization requires HVX, use -mhvx to 
enable it


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


r348214 - [Hexagon] Fix intrinsic test

2018-12-03 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Mon Dec  3 15:52:33 2018
New Revision: 348214

URL: http://llvm.org/viewvc/llvm-project?rev=348214&view=rev
Log:
[Hexagon] Fix intrinsic test

Modified:
cfe/trunk/test/CodeGen/builtins-hexagon.c

Modified: cfe/trunk/test/CodeGen/builtins-hexagon.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-hexagon.c?rev=348214&r1=348213&r2=348214&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-hexagon.c (original)
+++ cfe/trunk/test/CodeGen/builtins-hexagon.c Mon Dec  3 15:52:33 2018
@@ -426,8 +426,6 @@ void test() {
   __builtin_HEXAGON_A5_vaddhubs(0, 0);
   // CHECK: @llvm.hexagon.A6.vcmpbeq.notany
   __builtin_HEXAGON_A6_vcmpbeq_notany(0, 0);
-  // CHECK: @llvm.hexagon.A6.vcmpbeq.notany.128B
-  __builtin_HEXAGON_A6_vcmpbeq_notany_128B(0, 0);
   // CHECK: @llvm.hexagon.C2.all8
   __builtin_HEXAGON_C2_all8(0);
   // CHECK: @llvm.hexagon.C2.and
@@ -1400,8 +1398,6 @@ void test() {
   __builtin_HEXAGON_S2_brev(0);
   // CHECK: @llvm.hexagon.S2.brevp
   __builtin_HEXAGON_S2_brevp(0);
-  // CHECK: @llvm.hexagon.S2.cabacencbin
-  __builtin_HEXAGON_S2_cabacencbin(0, 0, 0);
   // CHECK: @llvm.hexagon.S2.cl0
   __builtin_HEXAGON_S2_cl0(0);
   // CHECK: @llvm.hexagon.S2.cl0p


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


r348415 - [Hexagon] Add support for Hexagon V66

2018-12-05 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Wed Dec  5 13:38:35 2018
New Revision: 348415

URL: http://llvm.org/viewvc/llvm-project?rev=348415&view=rev
Log:
[Hexagon] Add support for Hexagon V66

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/Hexagon.cpp
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
cfe/trunk/test/Driver/hexagon-hvx.c
cfe/trunk/test/Driver/hexagon-toolchain-elf.c
cfe/trunk/test/Preprocessor/hexagon-predefines.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=348415&r1=348414&r2=348415&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Dec  5 13:38:35 2018
@@ -2708,6 +2708,8 @@ def mv62 : Flag<["-"], "mv62">, Group, AliasArgs<["hexagonv62"]>;
 def mv65 : Flag<["-"], "mv65">, Group,
   Alias, AliasArgs<["hexagonv65"]>;
+def mv66 : Flag<["-"], "mv66">, Group,
+  Alias, AliasArgs<["hexagonv66"]>;
 def mhexagon_hvx : Flag<["-"], "mhvx">, Group,
   HelpText<"Enable Hexagon Vector eXtensions">;
 def mhexagon_hvx_EQ : Joined<["-"], "mhvx=">,

Modified: cfe/trunk/lib/Basic/Targets/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Hexagon.cpp?rev=348415&r1=348414&r2=348415&view=diff
==
--- cfe/trunk/lib/Basic/Targets/Hexagon.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/Hexagon.cpp Wed Dec  5 13:38:35 2018
@@ -48,6 +48,9 @@ void HexagonTargetInfo::getTargetDefines
   } else if (CPU == "hexagonv65") {
 Builder.defineMacro("__HEXAGON_V65__");
 Builder.defineMacro("__HEXAGON_ARCH__", "65");
+  } else if (CPU == "hexagonv66") {
+Builder.defineMacro("__HEXAGON_V66__");
+Builder.defineMacro("__HEXAGON_ARCH__", "66");
   }
 
   if (hasFeature("hvx-length64b")) {
@@ -145,7 +148,7 @@ struct CPUSuffix {
 static constexpr CPUSuffix Suffixes[] = {
 {{"hexagonv5"},  {"5"}},  {{"hexagonv55"}, {"55"}},
 {{"hexagonv60"}, {"60"}}, {{"hexagonv62"}, {"62"}},
-{{"hexagonv65"}, {"65"}},
+{{"hexagonv65"}, {"65"}}, {{"hexagonv66"}, {"66"}},
 };
 
 const char *HexagonTargetInfo::getHexagonCPUSuffix(StringRef Name) {

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp?rev=348415&r1=348414&r2=348415&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp Wed Dec  5 13:38:35 2018
@@ -32,6 +32,7 @@ static StringRef getDefaultHvxLength(Str
   .Case("v60", "64b")
   .Case("v62", "64b")
   .Case("v65", "64b")
+  .Case("v66", "128b")
   .Default("128b");
 }
 

Modified: cfe/trunk/test/Driver/hexagon-hvx.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-hvx.c?rev=348415&r1=348414&r2=348415&view=diff
==
--- cfe/trunk/test/Driver/hexagon-hvx.c (original)
+++ cfe/trunk/test/Driver/hexagon-hvx.c Wed Dec  5 13:38:35 2018
@@ -2,6 +2,10 @@
 // Tests for the hvx features and warnings.
 // 
-
 
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECKHVX166 %s
+// CHECKHVX166: "-target-feature" "+hvxv66"
+
 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv65 -mhvx \
 // RUN:  2>&1 | FileCheck -check-prefix=CHECKHVX165 %s
 // CHECKHVX165: "-target-feature" "+hvxv65"
@@ -69,6 +73,9 @@
 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx \
 // RUN:  -mhvx-length=64B 2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-64B %s
 // CHECK-HVXLENGTH-64B: "-target-feature" "+hvx{{.*}}" "-target-feature" 
"+hvx-length64b"
+// The default mode on v66 and future archs is 128B.
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-128B %s
 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx 
-mhvx-length=128B\
 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-128B %s
 // CHECK-HVXLENGTH-128B: "-target-feature" "+hvx{{.*}}" "-target-feature" 
"+hvx-length128b"

Modified: cfe/trunk/test/Driver/hexagon-toolchain-elf.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-toolchain-elf.c?rev=348415&r1=348414&r2=348415&view=diff
==
--- cfe/trunk/test/Driver/hexagon-toolchain-elf.c (original)
+++ cfe/trunk/test/Driver/hexagon-toolchain-elf.c Wed Dec  5 13:38:35 2018
@@ -99,20 +99,28 @@
 
 // RUN: %clang -### -target hexagon-unknown-elf \
 // RUN:   -ccc-install-dir %S/Inputs/hexago

Re: Patch bug 27628

2017-09-08 Thread Krzysztof Parzyszek via cfe-commits

This should to to cfe-commits.  Redirecting.

-Krzysztof

On 9/8/2017 10:25 AM, Antoni Boucher via llvm-commits wrote:

Hello.
I've fixed the bug 27628:
https://bugs.llvm.org/show_bug.cgi?id=27628

I attached the patch.

Thanks.


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



--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation

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


Re: Patch bug 27628

2017-09-08 Thread Krzysztof Parzyszek via cfe-commits

Aaand the patch itself...

-K

On 9/8/2017 10:32 AM, Krzysztof Parzyszek via cfe-commits wrote:

This should to to cfe-commits.  Redirecting.

-Krzysztof

On 9/8/2017 10:25 AM, Antoni Boucher via llvm-commits wrote:

Hello.
I've fixed the bug 27628:
https://bugs.llvm.org/show_bug.cgi?id=27628

I attached the patch.

Thanks.


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





--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp   (révision 312787)
+++ clang-tidy/tool/ClangTidyMain.cpp   (copie de travail)
@@ -449,6 +449,10 @@
 return WErrorCount;
   }
 
+  if (FoundErrors) {
+  return 1;
+  }
+
   return 0;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r364648 - [Hexagon] driver uses out-of-date option name and binary name

2019-06-28 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Fri Jun 28 08:08:03 2019
New Revision: 364648

URL: http://llvm.org/viewvc/llvm-project?rev=364648&view=rev
Log:
[Hexagon] driver uses out-of-date option name and binary name

Patch by A. Skrobov (t.yomitch).

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp?rev=364648&r1=364647&r2=364648&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp Fri Jun 28 08:08:03 2019
@@ -130,11 +130,11 @@ void hexagon::Assembler::ConstructJob(Co
   const Driver &D = HTC.getDriver();
   ArgStringList CmdArgs;
 
-  CmdArgs.push_back("-march=hexagon");
+  CmdArgs.push_back("--arch=hexagon");
 
   RenderExtraToolArgs(JA, CmdArgs);
 
-  const char *AsName = "hexagon-llvm-mc";
+  const char *AsName = "llvm-mc";
   CmdArgs.push_back("-filetype=obj");
   CmdArgs.push_back(Args.MakeArgString(
   "-mcpu=hexagon" +


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


r329923 - [Hexagon] Enable auto-vectorization only when -fvectorize was given

2018-04-12 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Thu Apr 12 09:25:35 2018
New Revision: 329923

URL: http://llvm.org/viewvc/llvm-project?rev=329923&view=rev
Log:
[Hexagon] Enable auto-vectorization only when -fvectorize was given

Added:
cfe/trunk/test/Driver/hexagon-vectorize.c
Modified:
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp?rev=329923&r1=329922&r2=329923&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp Thu Apr 12 09:25:35 2018
@@ -520,6 +520,13 @@ void HexagonToolChain::addClangTargetOpt
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+reserved-r19");
   }
+  if (Arg *A = DriverArgs.getLastArg(options::OPT_fvectorize,
+ options::OPT_fno_vectorize)) {
+if (A->getOption().matches(options::OPT_fvectorize)) {
+  CC1Args.push_back("-mllvm");
+  CC1Args.push_back("-hexagon-autohvx");
+}
+  }
 }
 
 void HexagonToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,

Added: cfe/trunk/test/Driver/hexagon-vectorize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-vectorize.c?rev=329923&view=auto
==
--- cfe/trunk/test/Driver/hexagon-vectorize.c (added)
+++ cfe/trunk/test/Driver/hexagon-vectorize.c Thu Apr 12 09:25:35 2018
@@ -0,0 +1,7 @@
+// RUN: %clang -target hexagon -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DEFAULT
+// RUN: %clang -target hexagon -fvectorize -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-VECTOR
+// RUN: %clang -target hexagon -fvectorize -fno-vectorize -### %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-NOVECTOR
+
+// CHECK-DEFAULT-NOT: hexagon-autohvx
+// CHECK-VECTOR: "-mllvm" "-hexagon-autohvx"
+// CHECK-NOVECTOR-NOT: hexagon-autohvx


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


r330150 - [Hexagon] Emit a warning when -fvectorize is given without -mhvx

2018-04-16 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Mon Apr 16 12:11:17 2018
New Revision: 330150

URL: http://llvm.org/viewvc/llvm-project?rev=330150&view=rev
Log:
[Hexagon] Emit a warning when -fvectorize is given without -mhvx

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
cfe/trunk/lib/Driver/ToolChains/Hexagon.h
cfe/trunk/test/Driver/hexagon-vectorize.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=330150&r1=330149&r2=330150&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Apr 16 12:11:17 
2018
@@ -288,6 +288,9 @@ def err_analyzer_config_multiple_values
 
 def err_drv_invalid_hvx_length : Error<
   "-mhvx-length is not supported without a -mhvx/-mhvx= flag">;
+def warn_drv_vectorize_needs_hvx : Warning<
+  "auto-vectorization requires HVX, use -mhvx to enable it">,
+  InGroup;
 
 def err_drv_modules_validate_once_requires_timestamp : Error<
   "option '-fmodules-validate-once-per-build-session' requires "

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp?rev=330150&r1=330149&r2=330150&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp Mon Apr 16 12:11:17 2018
@@ -108,8 +108,11 @@ void hexagon::getHexagonTargetFeatures(c
 
   Features.push_back(UseLongCalls ? "+long-calls" : "-long-calls");
 
-  bool HasHVX(false);
+  bool HasHVX = false;
   handleHVXTargetFeatures(D, Args, Features, HasHVX);
+
+  if (HexagonToolChain::isAutoHVXEnabled(Args) && !HasHVX)
+D.Diag(diag::warn_drv_vectorize_needs_hvx);
 }
 
 // Hexagon tools start.
@@ -520,12 +523,9 @@ void HexagonToolChain::addClangTargetOpt
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+reserved-r19");
   }
-  if (Arg *A = DriverArgs.getLastArg(options::OPT_fvectorize,
- options::OPT_fno_vectorize)) {
-if (A->getOption().matches(options::OPT_fvectorize)) {
-  CC1Args.push_back("-mllvm");
-  CC1Args.push_back("-hexagon-autohvx");
-}
+  if (isAutoHVXEnabled(DriverArgs)) {
+CC1Args.push_back("-mllvm");
+CC1Args.push_back("-hexagon-autohvx");
   }
 }
 
@@ -564,6 +564,13 @@ HexagonToolChain::GetCXXStdlibType(const
   return ToolChain::CST_Libstdcxx;
 }
 
+bool HexagonToolChain::isAutoHVXEnabled(const llvm::opt::ArgList &Args) {
+  if (Arg *A = Args.getLastArg(options::OPT_fvectorize,
+   options::OPT_fno_vectorize))
+return A->getOption().matches(options::OPT_fvectorize);
+  return false;
+}
+
 //
 // Returns the default CPU for Hexagon. This is the default compilation target
 // if no Hexagon processor is selected at the command-line.

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.h?rev=330150&r1=330149&r2=330150&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.h Mon Apr 16 12:11:17 2018
@@ -94,6 +94,7 @@ public:
   void getHexagonLibraryPaths(const llvm::opt::ArgList &Args,
   ToolChain::path_list &LibPaths) const;
 
+  static bool isAutoHVXEnabled(const llvm::opt::ArgList &Args);
   static const StringRef GetDefaultCPU();
   static const StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args);
 

Modified: cfe/trunk/test/Driver/hexagon-vectorize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-vectorize.c?rev=330150&r1=330149&r2=330150&view=diff
==
--- cfe/trunk/test/Driver/hexagon-vectorize.c (original)
+++ cfe/trunk/test/Driver/hexagon-vectorize.c Mon Apr 16 12:11:17 2018
@@ -1,7 +1,9 @@
 // RUN: %clang -target hexagon -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DEFAULT
 // RUN: %clang -target hexagon -fvectorize -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-VECTOR
 // RUN: %clang -target hexagon -fvectorize -fno-vectorize -### %s 2>&1 | 
FileCheck %s --check-prefix=CHECK-NOVECTOR
+// RUN: %clang -target hexagon -fvectorize -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-NEEDHVX
 
 // CHECK-DEFAULT-NOT: hexagon-autohvx
 // CHECK-VECTOR: "-mllvm" "-hexagon-autohvx"
 // CHECK-NOVECTOR-NOT: hexagon-autohvx
+// CHECK-NEEDHVX: warning: auto-vectorization requires HVX, use -mhvx to 
enable it


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

r336933 - [Hexagon] Diagnose intrinsics not supported by selected CPU/HVX

2018-07-12 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Thu Jul 12 11:54:04 2018
New Revision: 336933

URL: http://llvm.org/viewvc/llvm-project?rev=336933&view=rev
Log:
[Hexagon] Diagnose intrinsics not supported by selected CPU/HVX

Added:
cfe/trunk/test/Sema/builtins-hexagon-v55.c
cfe/trunk/test/Sema/builtins-hexagon-v60.c
cfe/trunk/test/Sema/builtins-hexagon-v62.c
cfe/trunk/test/Sema/builtins-hexagon-v65.c
cfe/trunk/test/Sema/builtins-hvx-none.c
cfe/trunk/test/Sema/builtins-hvx-v60.c
cfe/trunk/test/Sema/builtins-hvx-v62.c
cfe/trunk/test/Sema/builtins-hvx-v65.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Basic/Targets/Hexagon.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=336933&r1=336932&r2=336933&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 12 11:54:04 
2018
@@ -8181,9 +8181,15 @@ def err_x86_builtin_invalid_rounding : E
   "invalid rounding argument">;
 def err_x86_builtin_invalid_scale : Error<
   "scale argument must be 1, 2, 4, or 8">;
+def err_hexagon_builtin_unsupported_cpu : Error<
+  "builtin is not supported on this CPU">;
+def err_hexagon_builtin_requires_hvx : Error<
+  "builtin requires HVX">;
+def err_hexagon_builtin_unsupported_hvx : Error<
+  "builtin is not supported on this version of HVX">;
+
 def err_builtin_target_unsupported : Error<
   "builtin is not supported on this target">;
-
 def err_builtin_longjmp_unsupported : Error<
   "__builtin_longjmp is not supported for the current target">;
 def err_builtin_setjmp_unsupported : Error<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=336933&r1=336932&r2=336933&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 12 11:54:04 2018
@@ -10418,6 +10418,8 @@ private:
 
   bool CheckAArch64BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckHexagonBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
+  bool CheckHexagonBuiltinCpu(unsigned BuiltinID, CallExpr *TheCall);
+  bool CheckHexagonBuiltinArgument(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckMipsBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
   bool CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall);

Modified: cfe/trunk/lib/Basic/Targets/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Hexagon.cpp?rev=336933&r1=336932&r2=336933&view=diff
==
--- cfe/trunk/lib/Basic/Targets/Hexagon.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/Hexagon.cpp Thu Jul 12 11:54:04 2018
@@ -131,6 +131,10 @@ const Builtin::Info HexagonTargetInfo::B
 };
 
 bool HexagonTargetInfo::hasFeature(StringRef Feature) const {
+  std::string VS = "hvxv" + HVXVersion;
+  if (Feature == VS)
+return true;
+
   return llvm::StringSwitch(Feature)
   .Case("hexagon", true)
   .Case("hvx", HasHVX)

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=336933&r1=336932&r2=336933&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Jul 12 11:54:04 2018
@@ -1731,8 +1731,791 @@ bool Sema::CheckAArch64BuiltinFunctionCa
   return SemaBuiltinConstantArgRange(TheCall, i, l, u + l);
 }
 
-bool Sema::CheckHexagonBuiltinFunctionCall(unsigned BuiltinID,
-   CallExpr *TheCall) {
+bool Sema::CheckHexagonBuiltinCpu(unsigned BuiltinID, CallExpr *TheCall) {
+  static const std::map> ValidCPU = {
+{ Hexagon::BI__builtin_HEXAGON_A6_vcmpbeq_notany, {"v65"} },
+{ Hexagon::BI__builtin_HEXAGON_A6_vminub_RdP, {"v62", "v65"} },
+{ Hexagon::BI__builtin_HEXAGON_M6_vabsdiffb, {"v62", "v65"} },
+{ Hexagon::BI__builtin_HEXAGON_M6_vabsdiffub, {"v62", "v65"} },
+{ Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc, {"v60", "v62", "v65"} },
+{ Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and, {"v60", "v62", "v65"} },
+{ Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac, {"v60", "v62", "v65"} },
+{ Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or, {"v60", "v62", "v65"} },
+{ Hexagon::BI__builtin_HEXAGON_S6_rol_i_p, {"v60", "v62", "v65"} },
+{ Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc, {"v60", "v62", "v65"} },
+{ H

r337049 - [Hexagon] Fix hvx-length feature name in testcases

2018-07-13 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Fri Jul 13 14:32:33 2018
New Revision: 337049

URL: http://llvm.org/viewvc/llvm-project?rev=337049&view=rev
Log:
[Hexagon] Fix hvx-length feature name in testcases

Modified:
cfe/trunk/test/CodeGen/builtins-hvx128.c
cfe/trunk/test/CodeGen/builtins-hvx64.c

Modified: cfe/trunk/test/CodeGen/builtins-hvx128.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-hvx128.c?rev=337049&r1=337048&r2=337049&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-hvx128.c (original)
+++ cfe/trunk/test/CodeGen/builtins-hvx128.c Fri Jul 13 14:32:33 2018
@@ -1,5 +1,5 @@
 // REQUIRES: hexagon-registered-target
-// RUN: %clang_cc1 -triple hexagon-unknown-elf -target-cpu hexagonv65 
-target-feature +hvxv65 -target-feature +hvx-length128 -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple hexagon-unknown-elf -target-cpu hexagonv65 
-target-feature +hvxv65 -target-feature +hvx-length128b -emit-llvm %s -o - | 
FileCheck %s
 
 void test() {
   int v128 __attribute__((__vector_size__(128)));

Modified: cfe/trunk/test/CodeGen/builtins-hvx64.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-hvx64.c?rev=337049&r1=337048&r2=337049&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-hvx64.c (original)
+++ cfe/trunk/test/CodeGen/builtins-hvx64.c Fri Jul 13 14:32:33 2018
@@ -1,5 +1,5 @@
 // REQUIRES: hexagon-registered-target
-// RUN: %clang_cc1 -triple hexagon-unknown-elf -target-cpu hexagonv65 
-target-feature +hvxv65 -target-feature +hvx-length64 -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple hexagon-unknown-elf -target-cpu hexagonv65 
-target-feature +hvxv65 -target-feature +hvx-length64b -emit-llvm %s -o - | 
FileCheck %s
 
 void test() {
   int v64 __attribute__((__vector_size__(64)));


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


[clang] 99f5196 - [Hexagon] Handle remaining registers in getRegisterByName()

2019-10-29 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2019-10-29T08:56:01-05:00
New Revision: 99f51960fdb5559d6720281bff9a63041452bf9a

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

LOG: [Hexagon] Handle remaining registers in getRegisterByName()

This fixes https://llvm.org/PR43829.

Added: 
llvm/test/CodeGen/Hexagon/reg-by-name.ll

Modified: 
clang/lib/Basic/Targets/Hexagon.cpp
llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/Hexagon.cpp 
b/clang/lib/Basic/Targets/Hexagon.cpp
index be23fd2536e0..fcb94b93d69d 100644
--- a/clang/lib/Basic/Targets/Hexagon.cpp
+++ b/clang/lib/Basic/Targets/Hexagon.cpp
@@ -100,7 +100,10 @@ const char *const HexagonTargetInfo::GCCRegNames[] = {
 "r9",  "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
 "r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26",
 "r27", "r28", "r29", "r30", "r31", "p0",  "p1",  "p2",  "p3",
-"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp"
+"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp",
+"r1:0", "r3:2", "r5:4", "r7:6", "r9:8", "r11:10", "r13:12", "r15:14",
+"r17:16", "r19:18", "r21:20", "r23:22", "r25:24", "r27:26", "r29:28",
+"r31:30"
 };
 
 ArrayRef HexagonTargetInfo::getGCCRegNames() const {

diff  --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp 
b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
index 8a8986e232a0..09f5fd82cade 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -240,11 +240,73 @@ bool HexagonTargetLowering::mayBeEmittedAsTailCall(const 
CallInst *CI) const {
   return true;
 }
 
-Register HexagonTargetLowering::getRegisterByName(const char* RegName, EVT VT,
-  const MachineFunction &) 
const {
+Register HexagonTargetLowering::getRegisterByName(
+  const char* RegName, EVT VT, const MachineFunction &) const {
   // Just support r19, the linux kernel uses it.
   Register Reg = StringSwitch(RegName)
+ .Case("r0", Hexagon::R0)
+ .Case("r1", Hexagon::R1)
+ .Case("r2", Hexagon::R2)
+ .Case("r3", Hexagon::R3)
+ .Case("r4", Hexagon::R4)
+ .Case("r5", Hexagon::R5)
+ .Case("r6", Hexagon::R6)
+ .Case("r7", Hexagon::R7)
+ .Case("r8", Hexagon::R8)
+ .Case("r9", Hexagon::R9)
+ .Case("r10", Hexagon::R10)
+ .Case("r11", Hexagon::R11)
+ .Case("r12", Hexagon::R12)
+ .Case("r13", Hexagon::R13)
+ .Case("r14", Hexagon::R14)
+ .Case("r15", Hexagon::R15)
+ .Case("r16", Hexagon::R16)
+ .Case("r17", Hexagon::R17)
+ .Case("r18", Hexagon::R18)
  .Case("r19", Hexagon::R19)
+ .Case("r20", Hexagon::R20)
+ .Case("r21", Hexagon::R21)
+ .Case("r22", Hexagon::R22)
+ .Case("r23", Hexagon::R23)
+ .Case("r24", Hexagon::R24)
+ .Case("r25", Hexagon::R25)
+ .Case("r26", Hexagon::R26)
+ .Case("r27", Hexagon::R27)
+ .Case("r28", Hexagon::R28)
+ .Case("r29", Hexagon::R29)
+ .Case("r30", Hexagon::R30)
+ .Case("r31", Hexagon::R31)
+ .Case("r1:0", Hexagon::D0)
+ .Case("r3:2", Hexagon::D1)
+ .Case("r5:4", Hexagon::D2)
+ .Case("r7:6", Hexagon::D3)
+ .Case("r9:8", Hexagon::D4)
+ .Case("r11:10", Hexagon::D5)
+ .Case("r13:12", Hexagon::D6)
+ .Case("r15:14", Hexagon::D7)
+ .Case("r17:16", Hexagon::D8)
+ .Case("r19:18", Hexagon::D9)
+ .Case("r21:20", Hexagon::D10)
+ .Case("r23:22", Hexagon::D11)
+ .Case("r25:24", Hexagon::D12)
+ .Case("r27:26", Hexagon::D13)
+ .Case("r29:28", Hexagon::D14)
+ .Case("r31:30", Hexagon::D15)
+ .Case("sp", Hexagon::R29)
+ .Case("fp", Hexagon::R30)
+ .Case("lr", Hexagon::R31)
+ .Case("p0", Hexagon::P0)
+ .Case("p1", Hexagon::P1)
+ .Case("p2", Hexagon::P2)
+ .Case("p3", Hexagon::P3)
+ .Case("sa0", Hexagon:

[clang] 7406eb4 - [Hexagon] Avoid creating an empty target feature

2020-08-10 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2020-08-10T10:37:24-05:00
New Revision: 7406eb4f6afd8df9bd4dbb918f5e7005ba71d58c

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

LOG: [Hexagon] Avoid creating an empty target feature

If the CPU string is empty, the target feature map may end up having
an empty string inserted to it. The symptom of the problem is a warning
message:
  '+' is not a recognized feature for this target (ignoring feature)
Also, the target-features attribute in the module will have an empty
string in it.

Added: 
clang/test/CodeGen/hexagon-empty-cpu-feature.c

Modified: 
clang/lib/Basic/Targets/Hexagon.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/Hexagon.cpp 
b/clang/lib/Basic/Targets/Hexagon.cpp
index 205601c359d0..a8b4380b6a87 100644
--- a/clang/lib/Basic/Targets/Hexagon.cpp
+++ b/clang/lib/Basic/Targets/Hexagon.cpp
@@ -98,7 +98,8 @@ bool HexagonTargetInfo::initFeatureMap(
   StringRef CPUFeature = CPU;
   CPUFeature.consume_front("hexagon");
   CPUFeature.consume_back("t");
-  Features[CPUFeature] = true;
+  if (!CPUFeature.empty())
+Features[CPUFeature] = true;
 
   Features["long-calls"] = false;
 

diff  --git a/clang/test/CodeGen/hexagon-empty-cpu-feature.c 
b/clang/test/CodeGen/hexagon-empty-cpu-feature.c
new file mode 100644
index ..3a9e5a80118f
--- /dev/null
+++ b/clang/test/CodeGen/hexagon-empty-cpu-feature.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -triple hexagon-unknown-elf -emit-llvm -o - 2>&1 | 
FileCheck %s
+// CHECK-NOT: '+' is not a recognized feature for this target
+
+// Empty



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


[PATCH] D25597: Try to fix buildbot failure in VirtualFileSystem caused by r284129.

2016-10-14 Thread Krzysztof Parzyszek via cfe-commits
kparzysz added a comment.

dbgs showed that the path components were `.. target hexagon include`.
The paths are constructed in lib/Driver/ToolChains.cpp, many are based on 
"getHexagonTargetDir".


https://reviews.llvm.org/D25597



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


[PATCH] D25597: Try to fix buildbot failure in VirtualFileSystem caused by r284129.

2016-10-14 Thread Krzysztof Parzyszek via cfe-commits
kparzysz added a comment.

Right on entry to the asserting function:

  (gdb) where
  #0  0x752b9870 in (anonymous 
namespace)::RedirectingFileSystem::lookupPath(llvm::sys::path::const_iterator, 
llvm::sys::path::const_iterator, (anonymous namespace)::Entry*) () from 
/w/bld/up/bin/../lib/libclang.so.40
  #1  0x752b9b8c in (anonymous 
namespace)::RedirectingFileSystem::lookupPath(llvm::sys::path::const_iterator, 
llvm::sys::path::const_iterator, (anonymous namespace)::Entry*) () from 
/w/bld/up/bin/../lib/libclang.so.40
  #2  0x752b929f in (anonymous 
namespace)::RedirectingFileSystem::lookupPath(llvm::Twine const&) () from 
/w/bld/up/bin/../lib/libclang.so.40
  #3  0x752b836c in (anonymous 
namespace)::RedirectingFileSystem::status(llvm::Twine const&) () from 
/w/bld/up/bin/../lib/libclang.so.40
  #4  0x752b2171 in clang::vfs::OverlayFileSystem::status(llvm::Twine 
const&) () from /w/bld/up/bin/../lib/libclang.so.40
  #5  0x75292691 in clang::FileSystemStatCache::get(llvm::StringRef, 
clang::FileData&, bool, std::__1::unique_ptr >*, clang::FileSystemStatCache*, 
clang::vfs::FileSystem&)
  () from /w/bld/up/bin/../lib/libclang.so.40
  #6  0x7528f523 in clang::FileManager::getStatValue(llvm::StringRef, 
clang::FileData&, bool, std::__1::unique_ptr >*) () from 
/w/bld/up/bin/../lib/libclang.so.40
  #7  0x7528f326 in clang::FileManager::getDirectory(llvm::StringRef, 
bool) () from /w/bld/up/bin/../lib/libclang.so.40
  #8  0x75323e23 in (anonymous 
namespace)::InitHeaderSearch::AddUnmappedPath(llvm::Twine const&, 
clang::frontend::IncludeDirGroup, bool) ()
 from /w/bld/up/bin/../lib/libclang.so.40
  #9  0x75323133 in 
clang::ApplyHeaderSearchOptions(clang::HeaderSearch&, 
clang::HeaderSearchOptions const&, clang::LangOptions const&, llvm::Triple 
const&) () from /w/bld/up/bin/../lib/libclang.so.40
  #10 0x752dc120 in 
clang::CompilerInstance::createPreprocessor(clang::TranslationUnitKind) () from 
/w/bld/up/bin/../lib/libclang.so.40
  #11 0x7531d0a7 in 
clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, 
clang::FrontendInputFile const&) ()
 from /w/bld/up/bin/../lib/libclang.so.40
  #12 0x752ccc90 in 
clang::ASTUnit::LoadFromCompilerInvocationAction(clang::CompilerInvocation*, 
std::__1::shared_ptr, 
llvm::IntrusiveRefCntPtr, clang::FrontendAction*, 
clang::ASTUnit*, bool, llvm::StringRef, bool, bool, unsigned int, bool, bool, 
bool, std::__1::unique_ptr >*)
  () from /w/bld/up/bin/../lib/libclang.so.40
  #13 0x7507e1b6 in clang_indexSourceFileFullArgv::$_0::operator()() 
const () from /w/bld/up/bin/../lib/libclang.so.40
  #14 0x75c22271 in 
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) () from 
/w/bld/up/bin/../lib/libclang.so.40
  #15 0x75c223b4 in RunSafelyOnThread_Dispatch(void*) ()
 from /w/bld/up/bin/../lib/libclang.so.40
  #16 0x75c6d3fa in ExecuteOnThread_Dispatch(void*) ()
 from /w/bld/up/bin/../lib/libclang.so.40
  #17 0x7797d182 in start_thread (arg=0x73234700)
  at pthread_create.c:312
  #18 0x73b3047d in clone ()
  at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
  
  (gdb) cont
  Continuing.
  ..:target:hexagon:include:
  c-index-test: 
/w/src/llvm.org/tools/clang/lib/Basic/VirtualFileSystem.cpp:1485: 
ErrorOr<(anonymous namespace)::Entry *> (anonymous 
namespace)::RedirectingFileSystem::lookupPath(sys::path::const_iterator, 
sys::path::const_iterator, (anonymous namespace)::Entry *): Assertion 
`!isTraversalComponent(*Start) && !isTraversalComponent(From->getName()) && 
"Paths should not contain traversal components"' failed.
  
  Program received signal SIGABRT, Aborted.
  0x73a6ccc9 in __GI_raise (sig=sig@entry=6)
  at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
  56  ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.


https://reviews.llvm.org/D25597



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


[PATCH] D25597: Try to fix buildbot failure in VirtualFileSystem caused by r284129.

2016-10-14 Thread Krzysztof Parzyszek via cfe-commits
kparzysz added a comment.

The `..:target:hexagon:include:` is debug code printing all the path 
components, separated by :.


https://reviews.llvm.org/D25597



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


[PATCH] D25597: Try to fix buildbot failure in VirtualFileSystem caused by r284129.

2016-10-17 Thread Krzysztof Parzyszek via cfe-commits
kparzysz added a comment.

This change

  bool FileManager::getStatValue(StringRef Path, FileData &Data, bool isFile,
 std::unique_ptr *F) {
// FIXME: FileSystemOpts shouldn't be passed in here, all paths should be
// absolute!
  llvm::dbgs() << "FileSystemOpts.WorkingDir: '" << FileSystemOpts.WorkingDir 
<< "'\n";
if (FileSystemOpts.WorkingDir.empty())
  return FileSystemStatCache::get(Path, Data, isFile, F,StatCache.get(), 
*FS);

prints
`FileSystemOpts.WorkingDir: ''`


https://reviews.llvm.org/D25597



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


[PATCH] D25597: Try to fix buildbot failure in VirtualFileSystem caused by r284129.

2016-10-17 Thread Krzysztof Parzyszek via cfe-commits
kparzysz added a comment.

In https://reviews.llvm.org/D25597#571532, @kparzysz wrote:

> `FileSystemOpts.WorkingDir: ''`


There is no space between the single quotes.


https://reviews.llvm.org/D25597



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


[PATCH] D25597: Try to fix buildbot failure in VirtualFileSystem caused by r284129.

2016-10-17 Thread Krzysztof Parzyszek via cfe-commits
kparzysz added a comment.

Printing Path shows
`/../target/hexagon/include`


https://reviews.llvm.org/D25597



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


r284383 - Return correct path from HexagonToolChain::getHexagonTargetDir

2016-10-17 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Mon Oct 17 08:23:41 2016
New Revision: 284383

URL: http://llvm.org/viewvc/llvm-project?rev=284383&view=rev
Log:
Return correct path from HexagonToolChain::getHexagonTargetDir

This problem was exposed by r284129, causing clang-hexagon-elf to fail
clang tests.

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=284383&r1=284382&r2=284383&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Oct 17 08:23:41 2016
@@ -2970,7 +2970,7 @@ std::string HexagonToolChain::getHexagon
   if (getVFS().exists(InstallRelDir = InstalledDir + "/../target"))
 return InstallRelDir;
 
-  return InstallRelDir;
+  return InstalledDir;
 }
 
 Optional HexagonToolChain::getSmallDataThreshold(


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


Re: [clang-tools-extra] r318840 - [FindAllSymbols] Cache regexes, creating them is expensive

2017-11-23 Thread Krzysztof Parzyszek via cfe-commits

Hi,
This broke build on FreeBSD 11:

[100%] Building CXX object 
tools/clang/tools/extra/include-fixer/find-all-symbols/CMakeFiles/findAllSymbols.dir/HeaderMapCollector.cpp.o
cd /w/bld/org/tools/clang/tools/extra/include-fixer/find-all-symbols && 
/w/c/clang+llvm-5.0.0-x86_64-unknown-freebsd11/bin/clang++ 
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/w/bld/org/tools/clang/tools/extra/include-fixer/find-all-symbols 
-I/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols 
-I/w/src/llvm.org/tools/clang/include -I/w/bld/org/tools/clang/include 
-I/w/bld/org/include -I/w/src/llvm.org/include -isystem 
/usr/local/include -stdlib=libc++ -fPIC -fvisibility-inlines-hidden 
-Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -W 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wmissing-field-initializers -pedantic -Wno-long-long 
-Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor 
-Wno-comment -Wstring-conversion -ffunction-sections -fdata-sections 
-fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3-UNDEBUG 
-fno-exceptions -fno-rtti -o 
CMakeFiles/findAllSymbols.dir/HeaderMapCollector.cpp.o -c 
/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp
In file included from 
/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp:10:
In file included from 
/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.h:13:

In file included from /w/src/llvm.org/include/llvm/ADT/StringMap.h:17:
In file included from /w/src/llvm.org/include/llvm/ADT/StringRef.h:13:
In file included from /w/src/llvm.org/include/llvm/ADT/STLExtras.h:20:
In file included from /w/src/llvm.org/include/llvm/ADT/Optional.h:22:
In file included from /w/src/llvm.org/include/llvm/Support/type_traits.h:19:
/usr/include/c++/v1/utility:315:11: error: call to deleted constructor 
of 'llvm::Regex'

: first(__p.first),
  ^ ~
/usr/include/c++/v1/memory:1747:31: note: in instantiation of member 
function 'std::__1::pair::pair' requested here

::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
  ^
/usr/include/c++/v1/memory:1658:18: note: in instantiation of function 
template specialization 'std::__1::allocatorconst char *> >::construct, 
const std::__1::pair &>' requested here

{__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
 ^
/usr/include/c++/v1/memory:1504:14: note: in instantiation of function 
template specialization 
'std::__1::allocator_traitsconst char *> > >::__construct*>, const std::__1::pair &>' requested here

{__construct(__has_construct(),
 ^
/usr/include/c++/v1/memory:1620:17: note: in instantiation of function 
template specialization 
'std::__1::allocator_traitsconst char *> > >::construct, 
const std::__1::pair &>' requested here
construct(__a, _VSTD::__to_raw_pointer(__end2-1), 
_VSTD::move_if_noexcept(*--__end1));

^
/usr/include/c++/v1/vector:892:21: note: in instantiation of function 
template specialization 
'std::__1::allocator_traitsconst char *> > >::__construct_backwardconst char *> *>' requested here
__alloc_traits::__construct_backward(this->__alloc(), 
this->__begin_, this->__end_, __v.__begin_);

^
/usr/include/c++/v1/vector:1537:9: note: in instantiation of member 
function 'std::__1::vector, 
std::__1::allocator > 
>::__swap_out_circular_buffer' requested here

__swap_out_circular_buffer(__v);
^
/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp:19:33: 
note: in instantiation of member function 
'std::__1::vector, 
std::__1::allocator > 
>::reserve' requested here

  this->RegexHeaderMappingTable.reserve(RegexHeaderMappingTable->size());
^
/w/src/llvm.org/include/llvm/Support/Regex.h:49:5: note: 'Regex' has 
been explicitly marked deleted here

Regex(const Regex &) = delete;
^
1 error generated.
*** Error code 1


-Krzysztof


On 11/22/2017 9:38 AM, Benjamin Kramer via cfe-commits wrote:

Author: d0k
Date: Wed Nov 22 07:38:23 2017
New Revision: 318840

URL: http://llvm.org/viewvc/llvm-project?rev=318840&view=rev
Log:
[FindAllSymbols] Cache regexes, creating them is expensive

This is a bit annoying because LLVM regexes are always mutable to store
errors. Assert that there are never errors and fix broken hardcoded
regexes.

Modified:
 
clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.cpp
 clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.h
 
clang-tools-extra/trunk/include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/HeaderMapCollector.cpp
URL: 
http://llvm.org/viewv

Re: [clang-tools-extra] r318840 - [FindAllSymbols] Cache regexes, creating them is expensive

2017-11-23 Thread Krzysztof Parzyszek via cfe-commits
There has been some problem with std::pair on FreeBSD (due to some ABI 
compatibility issue), but I don't know much about what it was.


Commenting the reserve doesn't help, unfortunately. The same problem is 
now flagged in emplace_back.


-Krzysztof


On 11/23/2017 11:47 AM, Benjamin Kramer wrote:

That looks like a bug in the standard library. Does removing the call
to reserve fix it? It's not really necessary, that code isn't
performance sensitive at all.

On Thu, Nov 23, 2017 at 6:36 PM, Krzysztof Parzyszek
 wrote:

Hi,
This broke build on FreeBSD 11:

[100%] Building CXX object
tools/clang/tools/extra/include-fixer/find-all-symbols/CMakeFiles/findAllSymbols.dir/HeaderMapCollector.cpp.o
cd /w/bld/org/tools/clang/tools/extra/include-fixer/find-all-symbols &&
/w/c/clang+llvm-5.0.0-x86_64-unknown-freebsd11/bin/clang++
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-I/w/bld/org/tools/clang/tools/extra/include-fixer/find-all-symbols
-I/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols
-I/w/src/llvm.org/tools/clang/include -I/w/bld/org/tools/clang/include
-I/w/bld/org/include -I/w/src/llvm.org/include -isystem /usr/local/include
-stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Werror=date-time
-Werror=unguarded-availability-new -std=c++11 -Wall -W -Wno-unused-parameter
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic
-Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor
-Wdelete-non-virtual-dtor -Wno-comment -Wstring-conversion
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual
-Wno-nested-anon-types -O3-UNDEBUG -fno-exceptions -fno-rtti -o
CMakeFiles/findAllSymbols.dir/HeaderMapCollector.cpp.o -c
/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp
In file included from
/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp:10:
In file included from
/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.h:13:
In file included from /w/src/llvm.org/include/llvm/ADT/StringMap.h:17:
In file included from /w/src/llvm.org/include/llvm/ADT/StringRef.h:13:
In file included from /w/src/llvm.org/include/llvm/ADT/STLExtras.h:20:
In file included from /w/src/llvm.org/include/llvm/ADT/Optional.h:22:
In file included from /w/src/llvm.org/include/llvm/Support/type_traits.h:19:
/usr/include/c++/v1/utility:315:11: error: call to deleted constructor of
'llvm::Regex'
 : first(__p.first),
   ^ ~
/usr/include/c++/v1/memory:1747:31: note: in instantiation of member
function 'std::__1::pair::pair' requested here
 ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
   ^
/usr/include/c++/v1/memory:1658:18: note: in instantiation of function
template specialization 'std::__1::allocator >::construct, const
std::__1::pair &>' requested here
 {__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
  ^
/usr/include/c++/v1/memory:1504:14: note: in instantiation of function
template specialization
'std::__1::allocator_traits > >::__construct,
const std::__1::pair &>' requested here
 {__construct(__has_construct(),
  ^
/usr/include/c++/v1/memory:1620:17: note: in instantiation of function
template specialization
'std::__1::allocator_traits > >::construct,
const std::__1::pair &>' requested here
 construct(__a, _VSTD::__to_raw_pointer(__end2-1),
_VSTD::move_if_noexcept(*--__end1));
 ^
/usr/include/c++/v1/vector:892:21: note: in instantiation of function
template specialization
'std::__1::allocator_traits > >::__construct_backward *>' requested here
 __alloc_traits::__construct_backward(this->__alloc(), this->__begin_,
this->__end_, __v.__begin_);
 ^
/usr/include/c++/v1/vector:1537:9: note: in instantiation of member function
'std::__1::vector,
std::__1::allocator >

::__swap_out_circular_buffer' requested here

 __swap_out_circular_buffer(__v);
 ^
/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp:19:33:
note: in instantiation of member function
'std::__1::vector,
std::__1::allocator > >::reserve'
requested here
   this->RegexHeaderMappingTable.reserve(RegexHeaderMappingTable->size());
 ^
/w/src/llvm.org/include/llvm/Support/Regex.h:49:5: note: 'Regex' has been
explicitly marked deleted here
 Regex(const Regex &) = delete;
 ^
1 error generated.
*** Error code 1


-Krzysztof



On 11/22/2017 9:38 AM, Benjamin Kramer via cfe-commits wrote:


Author: d0k
Date: Wed Nov 22 07:38:23 2017
New Revision: 318840

URL: http://llvm.org/viewvc/llvm-project?rev=318840&view=rev
Log:
[FindAllSymbols] Cache regexes, creating them is expensive

This is a bit annoying because LLVM regexes are always mutable to store
errors. Assert that there 

Re: [clang-tools-extra] r318840 - [FindAllSymbols] Cache regexes, creating them is expensive

2017-11-23 Thread Krzysztof Parzyszek via cfe-commits

+Dimitry.


On 11/23/2017 12:50 PM, Benjamin Kramer wrote:

I'm afraid I can't really help you here. You can try twiddling the
code a bit by creating the pair explicitly and moving it into the
vector, just to avoid the brokenness in the standard library. Not sure
if that will help though.

On Thu, Nov 23, 2017 at 7:05 PM, Krzysztof Parzyszek
 wrote:

There has been some problem with std::pair on FreeBSD (due to some ABI
compatibility issue), but I don't know much about what it was.

Commenting the reserve doesn't help, unfortunately. The same problem is now
flagged in emplace_back.

-Krzysztof



On 11/23/2017 11:47 AM, Benjamin Kramer wrote:


That looks like a bug in the standard library. Does removing the call
to reserve fix it? It's not really necessary, that code isn't
performance sensitive at all.

On Thu, Nov 23, 2017 at 6:36 PM, Krzysztof Parzyszek
 wrote:


Hi,
This broke build on FreeBSD 11:

[100%] Building CXX object

tools/clang/tools/extra/include-fixer/find-all-symbols/CMakeFiles/findAllSymbols.dir/HeaderMapCollector.cpp.o
cd /w/bld/org/tools/clang/tools/extra/include-fixer/find-all-symbols &&
/w/c/clang+llvm-5.0.0-x86_64-unknown-freebsd11/bin/clang++
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-I/w/bld/org/tools/clang/tools/extra/include-fixer/find-all-symbols
-I/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols
-I/w/src/llvm.org/tools/clang/include -I/w/bld/org/tools/clang/include
-I/w/bld/org/include -I/w/src/llvm.org/include -isystem
/usr/local/include
-stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Werror=date-time
-Werror=unguarded-availability-new -std=c++11 -Wall -W
-Wno-unused-parameter
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic
-Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor
-Wdelete-non-virtual-dtor -Wno-comment -Wstring-conversion
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual
-Wno-nested-anon-types -O3-UNDEBUG -fno-exceptions -fno-rtti -o
CMakeFiles/findAllSymbols.dir/HeaderMapCollector.cpp.o -c

/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp
In file included from

/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp:10:
In file included from

/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.h:13:
In file included from /w/src/llvm.org/include/llvm/ADT/StringMap.h:17:
In file included from /w/src/llvm.org/include/llvm/ADT/StringRef.h:13:
In file included from /w/src/llvm.org/include/llvm/ADT/STLExtras.h:20:
In file included from /w/src/llvm.org/include/llvm/ADT/Optional.h:22:
In file included from
/w/src/llvm.org/include/llvm/Support/type_traits.h:19:
/usr/include/c++/v1/utility:315:11: error: call to deleted constructor of
'llvm::Regex'
  : first(__p.first),
^ ~
/usr/include/c++/v1/memory:1747:31: note: in instantiation of member
function 'std::__1::pair::pair' requested here
  ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
^
/usr/include/c++/v1/memory:1658:18: note: in instantiation of function
template specialization 'std::__1::allocator >::construct,
const
std::__1::pair &>' requested here
  {__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
   ^
/usr/include/c++/v1/memory:1504:14: note: in instantiation of function
template specialization

'std::__1::allocator_traits > >::__construct,
const std::__1::pair &>' requested here
  {__construct(__has_construct(),
   ^
/usr/include/c++/v1/memory:1620:17: note: in instantiation of function
template specialization

'std::__1::allocator_traits > >::construct,
const std::__1::pair &>' requested here
  construct(__a, _VSTD::__to_raw_pointer(__end2-1),
_VSTD::move_if_noexcept(*--__end1));
  ^
/usr/include/c++/v1/vector:892:21: note: in instantiation of function
template specialization

'std::__1::allocator_traits > >::__construct_backward *>' requested here
  __alloc_traits::__construct_backward(this->__alloc(),
this->__begin_,
this->__end_, __v.__begin_);
  ^
/usr/include/c++/v1/vector:1537:9: note: in instantiation of member
function
'std::__1::vector,
std::__1::allocator >


::__swap_out_circular_buffer' requested here


  __swap_out_circular_buffer(__v);
  ^

/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp:19:33:
note: in instantiation of member function
'std::__1::vector,
std::__1::allocator >

::reserve'

requested here

this->RegexHeaderMappingTable.reserve(RegexHeaderMappingTable->size());
  ^
/w/src/llvm.org/include/llvm/Support/Regex.h:49:5: note: 'Regex' has been
explicitly marked deleted here
  Regex(const Regex &) = delete;
  ^
1 error generated.
*** Err

Re: [clang-tools-extra] r318840 - [FindAllSymbols] Cache regexes, creating them is expensive

2017-11-25 Thread Krzysztof Parzyszek via cfe-commits

After upgrading my FreeBSD to the latest -STABLE this no longer fails.

-Krzysztof

PS. And system clang was upgraded to 5.0.0.  Nice!

On 11/25/2017 11:20 AM, Dimitry Andric wrote:

Yeah, in the past libc++ broke its own ABI with 
http://llvm.org/viewvc/llvm-project?view=revision&revision=194536, which is why we 
had to add the _LIBCPP_TRIVIAL_PAIR_COPY_CTOR hack to our own libc++ __config, in 
https://svnweb.freebsd.org/base?view=revision&revision=261801.

(Afterwards, in 
http://llvm.org/viewvc/llvm-project?view=revision&revision=275749, that define 
was renamed to _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR, but its 
functionality stayed the same.)

More recently, Eric Fiselier made the hack unnecessary with 
http://llvm.org/viewvc/llvm-project?view=revision&revision=283944, which I merged 
into FreeBSD 11-STABLE in 
https://svnweb.freebsd.org/base?view=revision&revision=315702.

After this, hacks for std::pair having trivial constructors should no longer be 
nessary, but the fix only made it into FreeBSD 11.1-RELEASE, so users with 
11.0-RELEASE are still SOL.

-Dimitry


On 24 Nov 2017, at 00:01, Krzysztof Parzyszek  wrote:

+Dimitry.


On 11/23/2017 12:50 PM, Benjamin Kramer wrote:

I'm afraid I can't really help you here. You can try twiddling the
code a bit by creating the pair explicitly and moving it into the
vector, just to avoid the brokenness in the standard library. Not sure
if that will help though.
On Thu, Nov 23, 2017 at 7:05 PM, Krzysztof Parzyszek
 wrote:

There has been some problem with std::pair on FreeBSD (due to some ABI
compatibility issue), but I don't know much about what it was.

Commenting the reserve doesn't help, unfortunately. The same problem is now
flagged in emplace_back.

-Krzysztof



On 11/23/2017 11:47 AM, Benjamin Kramer wrote:


That looks like a bug in the standard library. Does removing the call
to reserve fix it? It's not really necessary, that code isn't
performance sensitive at all.

On Thu, Nov 23, 2017 at 6:36 PM, Krzysztof Parzyszek
 wrote:


Hi,
This broke build on FreeBSD 11:

[100%] Building CXX object

tools/clang/tools/extra/include-fixer/find-all-symbols/CMakeFiles/findAllSymbols.dir/HeaderMapCollector.cpp.o
cd /w/bld/org/tools/clang/tools/extra/include-fixer/find-all-symbols &&
/w/c/clang+llvm-5.0.0-x86_64-unknown-freebsd11/bin/clang++
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-I/w/bld/org/tools/clang/tools/extra/include-fixer/find-all-symbols
-I/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols
-I/w/src/llvm.org/tools/clang/include -I/w/bld/org/tools/clang/include
-I/w/bld/org/include -I/w/src/llvm.org/include -isystem
/usr/local/include
-stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Werror=date-time
-Werror=unguarded-availability-new -std=c++11 -Wall -W
-Wno-unused-parameter
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic
-Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor
-Wdelete-non-virtual-dtor -Wno-comment -Wstring-conversion
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual
-Wno-nested-anon-types -O3-UNDEBUG -fno-exceptions -fno-rtti -o
CMakeFiles/findAllSymbols.dir/HeaderMapCollector.cpp.o -c

/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp
In file included from

/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.cpp:10:
In file included from

/w/src/llvm.org/tools/clang/tools/extra/include-fixer/find-all-symbols/HeaderMapCollector.h:13:
In file included from /w/src/llvm.org/include/llvm/ADT/StringMap.h:17:
In file included from /w/src/llvm.org/include/llvm/ADT/StringRef.h:13:
In file included from /w/src/llvm.org/include/llvm/ADT/STLExtras.h:20:
In file included from /w/src/llvm.org/include/llvm/ADT/Optional.h:22:
In file included from
/w/src/llvm.org/include/llvm/Support/type_traits.h:19:
/usr/include/c++/v1/utility:315:11: error: call to deleted constructor of
'llvm::Regex'
  : first(__p.first),
^ ~
/usr/include/c++/v1/memory:1747:31: note: in instantiation of member
function 'std::__1::pair::pair' requested here
  ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
^
/usr/include/c++/v1/memory:1658:18: note: in instantiation of function
template specialization 'std::__1::allocator >::construct,
const
std::__1::pair &>' requested here
  {__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
   ^
/usr/include/c++/v1/memory:1504:14: note: in instantiation of function
template specialization

'std::__1::allocator_traits > >::__construct,
const std::__1::pair &>' requested here
  {__construct(__has_construct(),
   ^
/usr/include/c++/v1/memory:1620:17: note: in instantiation of function
template specialization

'std::__1::allocator_traits > >::construct,
const std::__1::pair &>'

r320410 - [Hexagon] Remove unsupported vlut intrinsics

2017-12-11 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Mon Dec 11 11:29:56 2017
New Revision: 320410

URL: http://llvm.org/viewvc/llvm-project?rev=320410&view=rev
Log:
[Hexagon] Remove unsupported vlut intrinsics

Modified:
cfe/trunk/test/CodeGen/builtins-hexagon.c

Modified: cfe/trunk/test/CodeGen/builtins-hexagon.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-hexagon.c?rev=320410&r1=320409&r2=320410&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-hexagon.c (original)
+++ cfe/trunk/test/CodeGen/builtins-hexagon.c Mon Dec 11 11:29:56 2017
@@ -2346,22 +2346,6 @@ void foo() {
   // CHECK: @llvm.hexagon.V6.vlsrw
   __builtin_HEXAGON_V6_vlsrwv(v16, v16);
   // CHECK: @llvm.hexagon.V6.vlsrwv
-  __builtin_HEXAGON_V6_vlutb_128B(v32, 0, 0);
-  // CHECK: @llvm.hexagon.V6.vlutb.128B
-  __builtin_HEXAGON_V6_vlutb_acc_128B(v32, v32, 0, 0);
-  // CHECK: @llvm.hexagon.V6.vlutb.acc.128B
-  __builtin_HEXAGON_V6_vlutb_acc(v16, v16, 0, 0);
-  // CHECK: @llvm.hexagon.V6.vlutb.acc
-  __builtin_HEXAGON_V6_vlutb_dv_128B(v64, 0, 0);
-  // CHECK: @llvm.hexagon.V6.vlutb.dv.128B
-  __builtin_HEXAGON_V6_vlutb_dv_acc_128B(v64, v64, 0, 0);
-  // CHECK: @llvm.hexagon.V6.vlutb.dv.acc.128B
-  __builtin_HEXAGON_V6_vlutb_dv_acc(v32, v32, 0, 0);
-  // CHECK: @llvm.hexagon.V6.vlutb.dv.acc
-  __builtin_HEXAGON_V6_vlutb_dv(v32, 0, 0);
-  // CHECK: @llvm.hexagon.V6.vlutb.dv
-  __builtin_HEXAGON_V6_vlutb(v16, 0, 0);
-  // CHECK: @llvm.hexagon.V6.vlutb
   __builtin_HEXAGON_V6_vlutvvb_128B(v32, v32, 0);
   // CHECK: @llvm.hexagon.V6.vlutvvb.128B
   __builtin_HEXAGON_V6_vlutvvb_oracc_128B(v32, v32, v32, 0);


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


r320579 - [Hexagon] Add front-end support for Hexagon V65

2017-12-13 Thread Krzysztof Parzyszek via cfe-commits
Author: kparzysz
Date: Wed Dec 13 05:48:07 2017
New Revision: 320579

URL: http://llvm.org/viewvc/llvm-project?rev=320579&view=rev
Log:
[Hexagon] Add front-end support for Hexagon V65

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/Hexagon.cpp
cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
cfe/trunk/test/Driver/hexagon-hvx.c
cfe/trunk/test/Driver/hexagon-toolchain-elf.c
cfe/trunk/test/Preprocessor/hexagon-predefines.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=320579&r1=320578&r2=320579&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Dec 13 05:48:07 2017
@@ -2407,6 +2407,8 @@ def mv60 : Flag<["-"], "mv60">, Group, AliasArgs<["hexagonv60"]>;
 def mv62 : Flag<["-"], "mv62">, Group,
Alias, AliasArgs<["hexagonv62"]>;
+def mv65 : Flag<["-"], "mv65">, Group,
+   Alias, AliasArgs<["hexagonv65"]>;
 def mhexagon_hvx : Flag<[ "-" ], "mhvx">,
Group,
HelpText<"Enable Hexagon Vector eXtensions">;

Modified: cfe/trunk/lib/Basic/Targets/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Hexagon.cpp?rev=320579&r1=320578&r2=320579&view=diff
==
--- cfe/trunk/lib/Basic/Targets/Hexagon.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/Hexagon.cpp Wed Dec 13 05:48:07 2017
@@ -52,6 +52,9 @@ void HexagonTargetInfo::getTargetDefines
   } else if (CPU == "hexagonv62") {
 Builder.defineMacro("__HEXAGON_V62__");
 Builder.defineMacro("__HEXAGON_ARCH__", "62");
+  } else if (CPU == "hexagonv65") {
+Builder.defineMacro("__HEXAGON_V65__");
+Builder.defineMacro("__HEXAGON_ARCH__", "65");
   }
 
   if (hasFeature("hvx-length64b")) {
@@ -145,6 +148,7 @@ const char *HexagonTargetInfo::getHexago
   .Case("hexagonv55", "55")
   .Case("hexagonv60", "60")
   .Case("hexagonv62", "62")
+  .Case("hexagonv65", "65")
   .Default(nullptr);
 }
 

Modified: cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp?rev=320579&r1=320578&r2=320579&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Hexagon.cpp Wed Dec 13 05:48:07 2017
@@ -32,6 +32,7 @@ static StringRef getDefaultHvxLength(Str
   return llvm::StringSwitch(Cpu)
   .Case("v60", "64b")
   .Case("v62", "64b")
+  .Case("v65", "64b")
   .Default("128b");
 }
 

Modified: cfe/trunk/test/Driver/hexagon-hvx.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-hvx.c?rev=320579&r1=320578&r2=320579&view=diff
==
--- cfe/trunk/test/Driver/hexagon-hvx.c (original)
+++ cfe/trunk/test/Driver/hexagon-hvx.c Wed Dec 13 05:48:07 2017
@@ -2,18 +2,31 @@
 // Tests for the hvx features and warnings.
 // 
-
 
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv65 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECKHVX165 %s
+// CHECKHVX165: "-target-feature" "+hvxv65"
+
 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx \
 // RUN:  2>&1 | FileCheck -check-prefix=CHECKHVX162 %s
 // CHECKHVX162: "-target-feature" "+hvxv62"
 
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv65 -mhvx \
+// RUN:  -mhvx-double 2>&1 | FileCheck -check-prefix=CHECKHVX2 %s
+
 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx \
 // RUN:  -mhvx-double 2>&1 | FileCheck -check-prefix=CHECKHVX2 %s
 
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv65 -mhvx \
+// RUN:  -mhvx-length=128B 2>&1 | FileCheck -check-prefix=CHECKHVX2 %s
+
 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx \
 // RUN:  -mhvx-length=128B 2>&1 | FileCheck -check-prefix=CHECKHVX2 %s
 // CHECKHVX2-NOT: "-target-feature" "+hvx-length64b"
 // CHECKHVX2: "-target-feature" "+hvx-length128b"
 
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv65 2>&1 \
+// RUN:  | FileCheck -check-prefix=CHECKHVX3 %s
+
 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 2>&1 \
 // RUN:  | FileCheck -check-prefix=CHECKHVX3 %s
 // CHECKHVX3-NOT: "-target-feature" "+hvx

Modified: cfe/trunk/test/Driver/hexagon-toolchain-elf.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-toolchain-elf.c?rev=320579&r1=320578&r2=320579&view=diff
==
--- cfe/trunk/test/Driver/hexagon-toolchain-elf.c (original)
+++ cfe/trunk/test/Driver/hexagon-toolchain-elf

[llvm] [flang] [clang] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)

2023-12-05 Thread Krzysztof Parzyszek via cfe-commits

kparzysz wrote:

> The address spaces for AMDGPU defined 
> [here](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/AMDGPU.h#L395-L456)
>  contain more types of address spaces in comparison to the enum defined in 
> clang. Is it ok to extend number of address space types for clang?

I'd just move these definitions to their own file, and use that file in 
clang/flang/llvm backend.  So, indirectly, yes.

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


[clang] [flang] [llvm] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)

2023-12-05 Thread Krzysztof Parzyszek via cfe-commits

kparzysz wrote:

> I'd just move these definitions to their own file, and use that file in 
> clang/flang/llvm backend. So, indirectly, yes.

Sorry, didn't notice you have already created a separate file: 👍 I'd just use 
the address space identifiers that you quoted instead.

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


[llvm] [clang] [flang] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)

2023-12-05 Thread Krzysztof Parzyszek via cfe-commits


@@ -0,0 +1,31 @@
+//=== AMDGPUAddrSpace.h -*- 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
+//
+//===--===//
+//
+/// \file
+/// AMDGPU address space definition
+///
+//
+//===--===//
+
+#ifndef LLVM_SUPPORT_AMDGPUADDRSPACE_H
+#define LLVM_SUPPORT_AMDGPUADDRSPACE_H
+
+namespace llvm {
+namespace AMDGPU {
+enum class AddrSpace {

kparzysz wrote:

You can explicitly say `enum class AddrSpace : unsigned { ...` to avoid the 
need for the static_casts to unsigned.

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


[flang] [clang] [llvm] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)

2023-12-08 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz approved this pull request.

LGTM, thanks!

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


[clang] [Tooling/Inclusion] Avoid narrowing-conversions in macro expansion (PR #72664)

2023-11-17 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz created 
https://github.com/llvm/llvm-project/pull/72664

```
clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:144:65: warning: 
narrowing conversion of ‘llvm::StringRef(((const 
char*)"std::experimental::filesystem::")).llvm::StringRef::size()’ from 
‘size_t’ {aka ‘long un signed int’} to ‘unsigned int’ [-Wnarrowing]
  144 | #define SYMBOL(Name, NS, Header) {#NS #Name, StringRef(#NS).size(), 
#Header},
  |  ~~~^~
clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc:51:1: note: in expansion 
of macro ‘SYMBOL’
   51 | SYMBOL(temp_directory_path, std::experimental::filesystem::, 
)
  | ^~
```

>From c720fc96d8b92e5eccdd594c2b3d6bbc71d81455 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Fri, 17 Nov 2023 09:18:02 -0600
Subject: [PATCH] [Tooling/Inclusion] Avoid narrowing-conversions in macro
 expansion
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:144:65: warning:
 narrowing conversion of ‘llvm::StringRef(((const char*)"std::experiment
al::filesystem::")).llvm::StringRef::size()’ from ‘size_t’ {aka ‘long un
signed int’} to ‘unsigned int’ [-Wnarrowing]
  144 | #define SYMBOL(Name, NS, Header) {#NS #Name, StringRef(#NS).size
(), #Header},
  |  ~~~
^~
clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc:51:1: note: in ex
pansion of macro ‘SYMBOL’
   51 | SYMBOL(temp_directory_path, std::experimental::filesystem::, )
  | ^~
---
 clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp 
b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
index 03f61d33e1f26e7..adf1b230ff03181 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -141,7 +141,9 @@ static int initialize(Lang Language) {
 unsigned NSLen;
 const char *HeaderName;
   };
-#define SYMBOL(Name, NS, Header) {#NS #Name, StringRef(#NS).size(), #Header},
+#define SYMBOL(Name, NS, Header)   
\
+  {#NS #Name, static_cast(StringRef(#NS).size()), 
\
+   #Header},
   switch (Language) {
   case Lang::C: {
 static constexpr Symbol CSymbols[] = {

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


[clang] [Tooling/Inclusion] Avoid narrowing conversions in macro expansion (PR #72664)

2023-11-17 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [Tooling/Inclusion] Avoid narrowing conversions in macro expansion (PR #72664)

2023-11-17 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/72664

>From a6c711d61221558bad907a8e1a4944260d38c6ae Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Fri, 17 Nov 2023 09:18:02 -0600
Subject: [PATCH] [Tooling/Inclusion] Avoid narrowing conversions in macro
 expansion
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp:144:65: warning:
 narrowing conversion of ‘llvm::StringRef(((const char*)"std::experiment
al::filesystem::")).llvm::StringRef::size()’ from ‘size_t’ {aka ‘long un
signed int’} to ‘unsigned int’ [-Wnarrowing]
  144 | #define SYMBOL(Name, NS, Header) {#NS #Name, StringRef(#NS).size
(), #Header},
  |  ~~~
^~
clang/lib/Tooling/Inclusions/Stdlib/StdTsSymbolMap.inc:51:1: note: in ex
pansion of macro ‘SYMBOL’
   51 | SYMBOL(temp_directory_path, std::experimental::filesystem::, )
  | ^~
---
 clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp 
b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
index 03f61d33e1f26e7..adf1b230ff03181 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -141,7 +141,9 @@ static int initialize(Lang Language) {
 unsigned NSLen;
 const char *HeaderName;
   };
-#define SYMBOL(Name, NS, Header) {#NS #Name, StringRef(#NS).size(), #Header},
+#define SYMBOL(Name, NS, Header)   
\
+  {#NS #Name, static_cast(StringRef(#NS).size()), 
\
+   #Header},
   switch (Language) {
   case Lang::C: {
 static constexpr Symbol CSymbols[] = {

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


[clang] [Tooling/Inclusion] Avoid narrowing conversions in macro expansion (PR #72664)

2023-11-17 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] ddfed81 - Revert "[OpenMP] atomic compare fail : Parser & AST support"

2023-11-20 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2023-11-20T10:48:06-06:00
New Revision: ddfed815c930979414d403e01caca23875072676

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

LOG: Revert "[OpenMP] atomic compare fail : Parser & AST support"

This reverts commit edd675ac283909397880f85ba68d0d5f99dc1be2.

This breaks clang build where every component is a shared library.

The file clang/lib/Basic/OpenMPKinds.cpp, which is a part of
libclangBasic.so, uses `getOpenMPClauseName` which isn't:

/usr/bin/ld: CMakeFiles/obj.clangBasic.dir/OpenMPKinds.cpp.o: in functio
n `clang ::getOpenMPSimpleClauseTypeName(llvm::omp::Clause, unsigned int
)':
OpenMPKinds.cpp:(.text._ZN5clang29getOpenMPSimpleClauseTypeNameEN4llvm3o
mp6ClauseEj+0x9b): undefined reference to `llvm::omp::getOpenMPClauseNam
e(llvm::omp::Clause)'

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/atomic_ast_print.cpp
clang/test/OpenMP/atomic_messages.cpp
clang/tools/libclang/CIndex.cpp
flang/lib/Semantics/check-omp-structure.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index ccceadeabedc7ff..549f12e87df597a 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -2513,89 +2513,6 @@ class OMPRelaxedClause final : public OMPClause {
   }
 };
 
-/// This represents 'fail' clause in the '#pragma omp atomic'
-/// directive.
-///
-/// \code
-/// #pragma omp atomic compare fail
-/// \endcode
-/// In this example directive '#pragma omp atomic compare' has 'fail' clause.
-class OMPFailClause final : public OMPClause {
-
-  // FailParameter is a memory-order-clause. Storing the ClauseKind is
-  // sufficient for our purpose.
-  OpenMPClauseKind FailParameter = llvm::omp::Clause::OMPC_unknown;
-  SourceLocation FailParameterLoc;
-  SourceLocation LParenLoc;
-
-  friend class OMPClauseReader;
-
-  /// Sets the location of '(' in fail clause.
-  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
-
-  /// Sets the location of memoryOrder clause argument in fail clause.
-  void setFailParameterLoc(SourceLocation Loc) { FailParameterLoc = Loc; }
-
-  /// Sets the mem_order clause for 'atomic compare fail' directive.
-  void setFailParameter(OpenMPClauseKind FailParameter) {
-this->FailParameter = FailParameter;
-assert(checkFailClauseParameter(FailParameter) &&
-   "Invalid fail clause parameter");
-  }
-
-public:
-  /// Build 'fail' clause.
-  ///
-  /// \param StartLoc Starting location of the clause.
-  /// \param EndLoc Ending location of the clause.
-  OMPFailClause(SourceLocation StartLoc, SourceLocation EndLoc)
-  : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc) {}
-
-  OMPFailClause(OpenMPClauseKind FailParameter, SourceLocation 
FailParameterLoc,
-SourceLocation StartLoc, SourceLocation LParenLoc,
-SourceLocation EndLoc)
-  : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc),
-FailParameterLoc(FailParameterLoc), LParenLoc(LParenLoc) {
-
-setFailParameter(FailParameter);
-  }
-
-  /// Build an empty clause.
-  OMPFailClause()
-  : OMPClause(llvm::omp::OMPC_fail, SourceLocation(), SourceLocation()) {}
-
-  child_range children() {
-return child_range(child_iterator(), child_iterator());
-  }
-
-  const_child_range children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
-  }
-
-  child_range used_children() {
-return child_range(child_iterator(), child_iterator());
-  }
-  const_child_range used_children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
-  }
-
-  static bool classof(const OMPClause *T) {
-return T->getClauseKind() == llvm::omp::OMPC_fail;
-  }
-
-  /// Gets the location of '(' (for the parameter) in fail clause.
-  SourceLocation getLParenLoc() const {
-return LParenLoc;
-  }
-
-  /// Gets the location of Fail Parameter (type memory-order-clause) in
-  /// fail clause.
-  SourceLocation getFailParameterLoc() const { return FailParameterLoc; }
-
-  /// Gets the parameter (type memory-order-clause) in Fa

[llvm] [flang] [clang] [libc] [clang-tools-extra] [compiler-rt] [flang][OpenMP] Move handling of OpenMP symbol flags to OpenMP.cpp (PR #75523)

2023-12-15 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/75523

>From 21261fef67dbbea956adf2e09b8abacd92d9caf3 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Thu, 14 Dec 2023 13:45:17 -0600
Subject: [PATCH 1/3] [flang][OpenMP] Move handling of OpenMP symbol flags to
 OpenMP.cpp

The function `instantiateVariable` in Bridge.cpp has the following code:
```
  if (var.getSymbol().test(
  Fortran::semantics::Symbol::Flag::OmpThreadprivate))
Fortran::lower::genThreadprivateOp(*this, var);

  if (var.getSymbol().test(
  Fortran::semantics::Symbol::Flag::OmpDeclareTarget))
Fortran::lower::genDeclareTargetIntGlobal(*this, var);
```

Implement `handleOpenMPSymbolProperties` in OpenMP.cpp, move the above
code there, and have `instantiateVariable` call this function instead.

This would further separate OpenMP-related details into OpenMP.cpp.
---
 flang/include/flang/Lower/OpenMP.h |  2 ++
 flang/lib/Lower/Bridge.cpp |  8 +---
 flang/lib/Lower/OpenMP.cpp | 13 +
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/flang/include/flang/Lower/OpenMP.h 
b/flang/include/flang/Lower/OpenMP.h
index c9162761a08d54..a6ea26ee949fe7 100644
--- a/flang/include/flang/Lower/OpenMP.h
+++ b/flang/include/flang/Lower/OpenMP.h
@@ -56,6 +56,8 @@ void genOpenMPConstruct(AbstractConverter &, 
semantics::SemanticsContext &,
 pft::Evaluation &, const parser::OpenMPConstruct &);
 void genOpenMPDeclarativeConstruct(AbstractConverter &, pft::Evaluation &,
const parser::OpenMPDeclarativeConstruct &);
+void handleOpenMPSymbolProperties(AbstractConverter &converter,
+  const pft::Variable &var);
 int64_t getCollapseValue(const Fortran::parser::OmpClauseList &clauseList);
 void genThreadprivateOp(AbstractConverter &, const pft::Variable &);
 void genDeclareTargetIntGlobal(AbstractConverter &, const pft::Variable &);
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 6ca910d2696742..1ec242fafc5b6d 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -4244,13 +4244,7 @@ class FirConverter : public 
Fortran::lower::AbstractConverter {
   Fortran::lower::AggregateStoreMap &storeMap) {
 Fortran::lower::instantiateVariable(*this, var, localSymbols, storeMap);
 if (var.hasSymbol()) {
-  if (var.getSymbol().test(
-  Fortran::semantics::Symbol::Flag::OmpThreadprivate))
-Fortran::lower::genThreadprivateOp(*this, var);
-
-  if (var.getSymbol().test(
-  Fortran::semantics::Symbol::Flag::OmpDeclareTarget))
-Fortran::lower::genDeclareTargetIntGlobal(*this, var);
+  handleOpenMPSymbolProperties(*this, var);
 }
   }
 
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 12b8ea82884d9d..9a798e641d1267 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -3483,6 +3483,19 @@ void Fortran::lower::genOpenMPDeclarativeConstruct(
   ompDeclConstruct.u);
 }
 
+void Fortran::lower::handleOpenMPSymbolProperties(
+Fortran::lower::AbstractConverter &converter,
+const Fortran::lower::pft::Variable &var) {
+  assert(var.hasSymbol() && "Expecting Symbol");
+  const Fortran::semantics::Symbol &sym = var.getSymbol();
+
+  if (sym.test(Fortran::semantics::Symbol::Flag::OmpThreadprivate))
+Fortran::lower::genThreadprivateOp(converter, var);
+
+  if (sym.test(Fortran::semantics::Symbol::Flag::OmpDeclareTarget))
+Fortran::lower::genDeclareTargetIntGlobal(converter, var);
+}
+
 int64_t Fortran::lower::getCollapseValue(
 const Fortran::parser::OmpClauseList &clauseList) {
   for (const Fortran::parser::OmpClause &clause : clauseList.v) {

>From ef5a70a1bd4d484f6079e0d55a80e943072ce218 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Fri, 15 Dec 2023 08:28:10 -0600
Subject: [PATCH 2/3] Remove braces around single statement

---
 flang/lib/Lower/Bridge.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 1ec242fafc5b6d..49700744db5181 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -4243,9 +4243,8 @@ class FirConverter : public 
Fortran::lower::AbstractConverter {
   void instantiateVar(const Fortran::lower::pft::Variable &var,
   Fortran::lower::AggregateStoreMap &storeMap) {
 Fortran::lower::instantiateVariable(*this, var, localSymbols, storeMap);
-if (var.hasSymbol()) {
+if (var.hasSymbol())
   handleOpenMPSymbolProperties(*this, var);
-}
   }
 
   /// Where applicable, save the exception state and halting and rounding

>From 906fc9df8aa8a6c559d47dba8573a04d39193054 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Fri, 15 Dec 2023 08:34:36 -0600
Subject: [PATCH 3/3] Rename handleOpenMP... to genOpenMP..., add inine
 documentation

--

[clang] [libc] [clang-tools-extra] [compiler-rt] [flang] [llvm] [flang][OpenMP] Move handling of OpenMP symbol flags to OpenMP.cpp (PR #75523)

2023-12-15 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-27 Thread Krzysztof Parzyszek via cfe-commits


@@ -977,14 +977,51 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, 
const ToolChain &TC,
   return true;
 }
 
-void tools::addFortranRuntimeLibs(const ToolChain &TC,
+void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) {
   // These are handled earlier on Windows by telling the frontend driver to add
   // the correct libraries to link against as dependents in the object file.
   if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) {
+// --whole-archive needs to be part of the link line to make sure
+// that the main() function from Fortran_main.a is pulled in by
+// the linker.
+//
+// We are using this --whole-archive/--no-whole-archive bracket w/o
+// any further checks, because -Wl,--whole-archive at the flang
+// driver's link line will not sucessfully complete, unless the user
+// correctly specified -Wl,--whole-archive/-Wl,--no-whole-archive
+// (e.g., -Wl,--whole-archive -ldummy -Wl,--no-whole-archive).

kparzysz wrote:

This may be true now, but we don't know if it will always be true.

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


[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-27 Thread Krzysztof Parzyszek via cfe-commits


@@ -977,14 +977,51 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, 
const ToolChain &TC,
   return true;
 }
 
-void tools::addFortranRuntimeLibs(const ToolChain &TC,
+void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) {
   // These are handled earlier on Windows by telling the frontend driver to add
   // the correct libraries to link against as dependents in the object file.
   if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) {
+// --whole-archive needs to be part of the link line to make sure
+// that the main() function from Fortran_main.a is pulled in by
+// the linker.
+//
+// We are using this --whole-archive/--no-whole-archive bracket w/o
+// any further checks, because -Wl,--whole-archive at the flang
+// driver's link line will not sucessfully complete, unless the user
+// correctly specified -Wl,--whole-archive/-Wl,--no-whole-archive
+// (e.g., -Wl,--whole-archive -ldummy -Wl,--no-whole-archive).

kparzysz wrote:

What I meant is that it's not clear that we can actually skip this check and 
get away with it forever.  Is that guaranteed?

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


[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-27 Thread Krzysztof Parzyszek via cfe-commits


@@ -977,14 +977,51 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, 
const ToolChain &TC,
   return true;
 }
 
-void tools::addFortranRuntimeLibs(const ToolChain &TC,
+void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) {
   // These are handled earlier on Windows by telling the frontend driver to add
   // the correct libraries to link against as dependents in the object file.
   if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) {
+// --whole-archive needs to be part of the link line to make sure
+// that the main() function from Fortran_main.a is pulled in by
+// the linker.
+//
+// We are using this --whole-archive/--no-whole-archive bracket w/o
+// any further checks, because -Wl,--whole-archive at the flang
+// driver's link line will not sucessfully complete, unless the user
+// correctly specified -Wl,--whole-archive/-Wl,--no-whole-archive
+// (e.g., -Wl,--whole-archive -ldummy -Wl,--no-whole-archive).

kparzysz wrote:

Fine with me.

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


[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-27 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz approved this pull request.


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


[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Krzysztof Parzyszek via cfe-commits


@@ -977,14 +977,63 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, 
const ToolChain &TC,
   return true;
 }
 
-void tools::addFortranRuntimeLibs(const ToolChain &TC,
+void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) {
   // These are handled earlier on Windows by telling the frontend driver to add
   // the correct libraries to link against as dependents in the object file.
   if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) {
+// The --whole-archive option needs to be part of the link line to
+// make sure that the main() function from Fortran_main.a is pulled
+// in by the linker.  Determine if --whole-archive is active when
+// flang will try to link Fortran_main.a.  If it is, don't add the
+// --whole-archive flag to the link line.  If it's not, add a proper
+// --whole-archive/--no-whole-archive bracket to the link line.
+bool WholeArchiveActive = false;
+for (auto &&Arg : Args)

kparzysz wrote:

Thanks.  If could be somewhat simplified though.  You could use
```
Arg *A = Args.getLastArg(clang::driver::options::OPT_Wl_COMMA));
```
To get the last instance of `-Wl`, and then iterate over the values in reverse, 
using `StringRef`:
```
for (StringRef V : llvm::reverse(A->getValues()))
```

`StringRef` allows comparisons against string literals, e.g. `string_ref == 
"blah"`,


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


[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Krzysztof Parzyszek via cfe-commits


@@ -977,14 +977,61 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, 
const ToolChain &TC,
   return true;
 }
 
-void tools::addFortranRuntimeLibs(const ToolChain &TC,
+void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) {
   // These are handled earlier on Windows by telling the frontend driver to add
   // the correct libraries to link against as dependents in the object file.
   if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) {
+// The --whole-archive option needs to be part of the link line to
+// make sure that the main() function from Fortran_main.a is pulled
+// in by the linker.  Determine if --whole-archive is active when
+// flang will try to link Fortran_main.a.  If it is, don't add the
+// --whole-archive flag to the link line.  If it's not, add a proper
+// --whole-archive/--no-whole-archive bracket to the link line.
+bool NeedWholeArchive = true;
+auto * Arg = Args.getLastArg(options::OPT_Wl_COMMA);
+for (StringRef ArgValue : llvm::reverse(Arg->getValues())) {
+  if (ArgValue == "--whole-archive") {
+NeedWholeArchive = false;
+break;
+  }

kparzysz wrote:

This needs an `else if (ArgValue == "-no-whole-archive") break`, or otherwise 
we'll end up ignoring it.

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


[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Krzysztof Parzyszek via cfe-commits


@@ -977,14 +977,61 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, 
const ToolChain &TC,
   return true;
 }
 
-void tools::addFortranRuntimeLibs(const ToolChain &TC,
+void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) {
   // These are handled earlier on Windows by telling the frontend driver to add
   // the correct libraries to link against as dependents in the object file.
   if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) {
+// The --whole-archive option needs to be part of the link line to
+// make sure that the main() function from Fortran_main.a is pulled
+// in by the linker.  Determine if --whole-archive is active when
+// flang will try to link Fortran_main.a.  If it is, don't add the
+// --whole-archive flag to the link line.  If it's not, add a proper
+// --whole-archive/--no-whole-archive bracket to the link line.
+bool NeedWholeArchive = true;
+auto * Arg = Args.getLastArg(options::OPT_Wl_COMMA);

kparzysz wrote:

This can be `nullptr` if the -Wl option wasn't present, so we need to check for 
that.

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


[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Krzysztof Parzyszek via cfe-commits


@@ -977,14 +977,61 @@ bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, 
const ToolChain &TC,
   return true;
 }
 
-void tools::addFortranRuntimeLibs(const ToolChain &TC,
+void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) {
   // These are handled earlier on Windows by telling the frontend driver to add
   // the correct libraries to link against as dependents in the object file.
   if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) {
+// The --whole-archive option needs to be part of the link line to
+// make sure that the main() function from Fortran_main.a is pulled
+// in by the linker.  Determine if --whole-archive is active when
+// flang will try to link Fortran_main.a.  If it is, don't add the
+// --whole-archive flag to the link line.  If it's not, add a proper
+// --whole-archive/--no-whole-archive bracket to the link line.
+bool NeedWholeArchive = true;
+auto * Arg = Args.getLastArg(options::OPT_Wl_COMMA);
+for (StringRef ArgValue : llvm::reverse(Arg->getValues())) {
+  if (ArgValue == "--whole-archive") {
+NeedWholeArchive = false;
+break;
+  }

kparzysz wrote:

> Are you sure? The default is to modify the link line and only not do it if 
> --whole-archive was found.

In `-Wl,-whole-archive,-lfoo,-no-whole-archive`, it will find the 
`whole-archive` part even though it's effectively disabled in the same option.

> However, there's an actual bug now, as this goes is treated wrongly:
> 
> `-Wl,--whole-archive -ldummy -Wl,-dummy`

Ahh, yes.  Indeed.


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


[flang] [clang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz approved this pull request.


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


[clang] [flang] [flang][Driver] Let the linker fail on multiple definitions of main() (PR #73124)

2023-11-28 Thread Krzysztof Parzyszek via cfe-commits

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


[flang] [llvm] [clang] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)

2023-11-30 Thread Krzysztof Parzyszek via cfe-commits


@@ -31,6 +31,15 @@ class Triple;
 // back-end to TableGen to create these clean tables.
 namespace AMDGPU {
 
+/// Address space values for AMD GPUs
+enum AddrSpace {
+  Generic = 0,

kparzysz wrote:

We could change this enum to `enum class`.

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


[flang] [llvm] [clang] [NFC][AMDGPU] Move address space enum to LLVM directory (PR #73944)

2023-11-30 Thread Krzysztof Parzyszek via cfe-commits

kparzysz wrote:

> I think the enum looks a bit out of place in a file called "TargetParser.h", 
> but I'm not very familiar with this part of the project, so I'll let the 
> experts say something if there is a more suitable location for it.

That's a good point.  The address spaces for AMDGPU are already defined 
[here](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/AMDGPU.h#L395-L456).
  I think it makes sense to extract them into a separate file (including the 
static functions to query address spaces), and put that file in 
`llvm/include/llvm/Support`.  We already have two AMDGPU-specific files in 
there, so there is a precedent that we can follow.

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


[clang] 2ecda9e - [Hexagon] Alter meaning of versionless -mhvx

2022-02-08 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2022-02-08T09:06:15-08:00
New Revision: 2ecda9ec9cc89b87ce2e56452229c9444beabf21

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

LOG: [Hexagon] Alter meaning of versionless -mhvx

The documentation for the official (downstream) Qualcomm Hexagon Clang
states that -mhvx sets the HVX version to be the same as the CPU version.
The current implementation upstream would use the most recent versioned
-mhvx= flag first (if present), then the CPU version. Change the upstream
behavior to match the documented behavior of the downstream compiler.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/test/Driver/hexagon-hvx.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Hexagon.cpp 
b/clang/lib/Driver/ToolChains/Hexagon.cpp
index ba3040636604f..e772122f5ff5e 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -72,23 +72,25 @@ static void handleHVXTargetFeatures(const Driver &D, const 
ArgList &Args,
   (Cpu.back() == 'T' || Cpu.back() == 't' ? Cpu.drop_back(1) : Cpu).str();
   HasHVX = false;
 
-  // Handle -mhvx, -mhvx=, -mno-hvx. If both present, -mhvx= wins over -mhvx.
-  auto argOrNull = [&Args](auto FlagOn, auto FlagOff) -> Arg* {
-if (Arg *A = Args.getLastArg(FlagOn, FlagOff)) {
-  if (A->getOption().matches(FlagOn))
-return A;
-}
-return nullptr;
-  };
-
-  Arg *HvxBareA =
-  argOrNull(options::OPT_mhexagon_hvx, options::OPT_mno_hexagon_hvx);
-  Arg *HvxVerA =
-  argOrNull(options::OPT_mhexagon_hvx_EQ, options::OPT_mno_hexagon_hvx);
+  // Handle -mhvx, -mhvx=, -mno-hvx. If versioned and versionless flags
+  // are both present, the last one wins.
+  Arg *HvxEnablingArg =
+  Args.getLastArg(options::OPT_mhexagon_hvx, options::OPT_mhexagon_hvx_EQ,
+  options::OPT_mno_hexagon_hvx);
+  if (HvxEnablingArg) {
+if (HvxEnablingArg->getOption().matches(options::OPT_mno_hexagon_hvx))
+  HvxEnablingArg = nullptr;
+  }
 
-  if (Arg *A = HvxVerA ? HvxVerA : HvxBareA) {
-if (A->getOption().matches(options::OPT_mhexagon_hvx_EQ))
-  HvxVer = StringRef(A->getValue()).lower(); // lower produces std:string
+  if (HvxEnablingArg) {
+// If -mhvx[=] was given, it takes precedence.
+if (Arg *A = Args.getLastArg(options::OPT_mhexagon_hvx,
+ options::OPT_mhexagon_hvx_EQ)) {
+  // If the version was given, set HvxVer. Otherwise HvxVer
+  // will remain equal to the CPU version.
+  if (A->getOption().matches(options::OPT_mhexagon_hvx_EQ))
+HvxVer = StringRef(A->getValue()).lower();
+}
 HasHVX = true;
 Features.push_back(makeFeature(Twine("hvx") + HvxVer, true));
   } else if (Arg *A = Args.getLastArg(options::OPT_mno_hexagon_hvx)) {

diff  --git a/clang/test/Driver/hexagon-hvx.c b/clang/test/Driver/hexagon-hvx.c
index 10bb8fe9327f0..385774824cb0a 100644
--- a/clang/test/Driver/hexagon-hvx.c
+++ b/clang/test/Driver/hexagon-hvx.c
@@ -54,6 +54,23 @@
 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-V68 %s
 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v69 \
 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-V69 %s
+// Infer HVX version from CPU version:
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-V60 %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-V62 %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv65 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-V65 %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-V66 %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv67 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-V67 %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv67t -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-V67 %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv68 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-V68 %s
+// RUN: %clang -c %s -### -target hexagon-unknown-elf -mv69 -mhvx \
+// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-V69 %s
 
 // Direct version flag with 
diff erent CPU version:
 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v60 -mv62 \
@@ -73,19 +90,19 @@
 
 // Direct version flag with 
diff erent CPU version and versionless -mhvx:
 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v60 -mv62 -mhvx \
-// RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-V60 %s
-// RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx=v62 -mv65 -mhvx \
 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-V62 

[clang] d9e6b5d - [clang] Recognize scope of thread local variables in CFGBuilder

2022-05-09 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2022-05-09T07:11:56-07:00
New Revision: d9e6b5df74f54a7cf21a419f737d922040c1ed08

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

LOG: [clang] Recognize scope of thread local variables in CFGBuilder

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

Added: 


Modified: 
clang/lib/Analysis/CFG.cpp
clang/test/Analysis/cfg.cpp

Removed: 




diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 53d43bfa07b4..fd8d1b196f11 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -2019,13 +2019,8 @@ LocalScope* CFGBuilder::addLocalScopeForVarDecl(VarDecl 
*VD,
 return Scope;
 
   // Check if variable is local.
-  switch (VD->getStorageClass()) {
-  case SC_None:
-  case SC_Auto:
-  case SC_Register:
-break;
-  default: return Scope;
-  }
+  if (!VD->hasLocalStorage())
+return Scope;
 
   if (BuildOpts.AddImplicitDtors) {
 if (!hasTrivialDestructor(VD) || BuildOpts.AddScopes) {

diff  --git a/clang/test/Analysis/cfg.cpp b/clang/test/Analysis/cfg.cpp
index b61addcb5d86..333ea565287b 100644
--- a/clang/test/Analysis/cfg.cpp
+++ b/clang/test/Analysis/cfg.cpp
@@ -593,6 +593,63 @@ void CommaTemp::f() {
   A(), B();
 }
 
+// CHECK-LABEL: int crash_with_thread_local(char *p, int *q)
+// CHECK:   [B7 (ENTRY)]
+// CHECK-NEXT:Succs (1): B6
+// CHECK:   [B1]
+// CHECK-NEXT:   bail:
+// CHECK-NEXT:1: 0
+// CHECK-NEXT:2: return [B1.1];
+// CHECK-NEXT:Preds (2): B2 B5
+// CHECK-NEXT:Succs (1): B0
+// CHECK:   [B2]
+// CHECK-NEXT:1: 0
+// CHECK-NEXT:2: q
+// CHECK-NEXT:3: [B2.2] (ImplicitCastExpr, LValueToRValue, int *)
+// CHECK-NEXT:4: *[B2.3]
+// CHECK-NEXT:5: [B2.4] = [B2.1]
+// CHECK-NEXT:Preds (2): B3 B4
+// CHECK-NEXT:Succs (1): B1
+// CHECK:   [B3]
+// WARNINGS-NEXT: 1:  (CXXConstructExpr, struct ClassWithDtor)
+// ANALYZER-NEXT: 1:  (CXXConstructExpr, [B3.2], struct ClassWithDtor)
+// CHECK-NEXT:2: thread_local ClassWithDtor a;
+// CHECK-NEXT:Preds (1): B4
+// CHECK-NEXT:Succs (1): B2
+// CHECK:   [B4]
+// CHECK-NEXT:T: static init a
+// CHECK-NEXT:Preds (1): B6
+// CHECK-NEXT:Succs (2): B2 B3
+// CHECK:   [B5]
+// CHECK-NEXT:T: goto bail;
+// CHECK-NEXT:Preds (1): B6
+// CHECK-NEXT:Succs (1): B1
+// CHECK:   [B6]
+// CHECK-NEXT:1: p
+// CHECK-NEXT:2: [B6.1] (ImplicitCastExpr, LValueToRValue, char *)
+// CHECK-NEXT:3: 0
+// CHECK-NEXT:4: [B6.3] (ImplicitCastExpr, NullToPointer, char *)
+// CHECK-NEXT:5: [B6.2] != [B6.4]
+// CHECK-NEXT:T: if [B6.5]
+// CHECK-NEXT:Preds (1): B7
+// CHECK-NEXT:Succs (2): B5 B4
+// CHECK:   [B0 (EXIT)]
+// CHECK-NEXT:Preds (1): B1
+
+struct ClassWithDtor {
+  ~ClassWithDtor() {}
+};
+
+int crash_with_thread_local(char *p, int *q) {
+  if (p != 0) {
+goto bail;
+  }
+  thread_local ClassWithDtor a;
+  *q = 0;
+bail:
+  return 0;
+}
+
 // CHECK-LABEL: template<> int *PR18472()
 // CHECK: [B2 (ENTRY)]
 // CHECK-NEXT:   Succs (1): B1



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


[clang] [clang][OpenMP] Fix directive in ActOnOpenMPTargetParallelForSimdDire… (PR #85217)

2024-03-14 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz created 
https://github.com/llvm/llvm-project/pull/85217

…ctive

The function `ActOnOpenMPTargetParallelForSimdDirective` gets the number of 
capture levels for OMPD_target_parallel_for, whereas the intended directive is 
OMPD_target_parallel_for_simd.

>From 717561a9d9bdc5cf85f695d3745cb91df622e82c Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Thu, 14 Mar 2024 07:39:24 -0500
Subject: [PATCH] [clang][OpenMP] Fix directive in
 ActOnOpenMPTargetParallelForSimdDirective

The function `ActOnOpenMPTargetParallelForSimdDirective` gets the number
of capture levels for OMPD_target_parallel_for, whereas the intended
directive is OMPD_target_parallel_for_simd.
---
 clang/lib/Sema/SemaOpenMP.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 0cc0cbacb37548..e9ad7bbde0f9b5 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -14366,7 +14366,8 @@ StmtResult 
Sema::ActOnOpenMPTargetParallelForSimdDirective(
   // The point of exit cannot be a branch out of the structured block.
   // longjmp() and throw() must not violate the entry/exit criteria.
   CS->getCapturedDecl()->setNothrow();
-  for (int ThisCaptureLevel = getOpenMPCaptureLevels(OMPD_target_parallel_for);
+  for (int ThisCaptureLevel =
+   getOpenMPCaptureLevels(OMPD_target_parallel_for_simd);
ThisCaptureLevel > 1; --ThisCaptureLevel) {
 CS = cast(CS->getCapturedStmt());
 // 1.2.2 OpenMP Language Terminology

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


[clang] [clang][OpenMP] Fix directive in ActOnOpenMPTargetParallelForSimdDire… (PR #85217)

2024-03-14 Thread Krzysztof Parzyszek via cfe-commits

kparzysz wrote:

I suspect this was a mistake, let me know if you intended to use the existing 
directive here.

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


[clang] cb994d4 - Fix build with shared libraries

2024-03-25 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2024-03-25T16:51:11-05:00
New Revision: cb994d41c3afb2bd0b25a4c5b2ac48978bf1b23d

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

LOG: Fix build with shared libraries

/usr/bin/ld: CMakeFiles/ClangReplInterpreterTests.dir/InterpreterExtensi
onsTest.cpp.o: undefined reference to symbol '_ZN4llvm14TargetRegistry12
lookupTargetENS_9StringRefERNSt7__cxx1112basic_stringIcSt11char_traitsIc
ESaIcEEE'
/usr/bin/ld: /work/kparzysz/git/llvm.org/b/x86/lib/libLLVMMC.so.19.0git:
 error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

The missing symbol is `llvm::TargetRegistry::lookupTarget`, which
interestingly enough is in MC.

Add `MC` to the list of LLVM dependencies.

Added: 


Modified: 
clang/unittests/Interpreter/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/Interpreter/CMakeLists.txt 
b/clang/unittests/Interpreter/CMakeLists.txt
index b56e1e21015db9..e5a77e77de75cd 100644
--- a/clang/unittests/Interpreter/CMakeLists.txt
+++ b/clang/unittests/Interpreter/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Core
+  MC
   OrcJIT
   Support
   TargetParser



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


[clang] [clang][OpenMP] Add const-qualified `getIteratorModifier` to OMPMapClause (PR #86666)

2024-03-26 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz created 
https://github.com/llvm/llvm-project/pull/8

NFC

>From 3ffabe11eb01f42ceaeb92895a0eb0f251e6ef9a Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Thu, 21 Mar 2024 06:54:02 -0500
Subject: [PATCH] [clang][OpenMP] Add const-qualified `getIteratorModifier` to
 OMPMapClause

NFC
---
 clang/include/clang/AST/OpenMPClause.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 325a1baa446142..bf814c81665eb7 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -6050,6 +6050,11 @@ class OMPMapClause final : public 
OMPMappableExprListClause,
 return getTrailingObjects()[2 * varlist_size()];
   }
 
+  /// Fetches Expr * of iterator modifier.
+  Expr *getIteratorModifier() const {
+return getTrailingObjects()[2 * varlist_size()];
+  }
+
   /// Fetches mapping kind for the clause.
   OpenMPMapClauseKind getMapType() const LLVM_READONLY { return MapType; }
 

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


[clang] [clang][OpenMP] Add const-qualified `getIteratorModifier` to OMPMapClause (PR #86666)

2024-03-26 Thread Krzysztof Parzyszek via cfe-commits

kparzysz wrote:

This brings a question: most of such accessors return `Expr *` in both const 
and non-const versions.  If that's intended, does it make sense to even have 
non-const variants of these accessors?

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


[clang] [clang][OpenMP] Add const-qualified `getIteratorModifier` to OMPMapClause (PR #86666)

2024-03-26 Thread Krzysztof Parzyszek via cfe-commits

kparzysz wrote:

I don't think so, because nothing is failing without it.  This is just for 
completeness.

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


[clang] [clang][OpenMP] Add const-qualified `getIteratorModifier` to OMPMapClause (PR #86666)

2024-03-26 Thread Krzysztof Parzyszek via cfe-commits

kparzysz wrote:

> Are you going to submit your code?

Yes, but it's still incomplete.  I can wait with this PR if you prefer.

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


[clang] [clang][OpenMP] Add const-qualified `getIteratorModifier` to OMPMapClause (PR #86666)

2024-03-27 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [clang][OpenMP] Add const-qualified `getIteratorModifier` to OMPMapClause (PR #86666)

2024-03-27 Thread Krzysztof Parzyszek via cfe-commits

kparzysz wrote:

Will revisit this when the using code is ready for review/merge.

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-06 Thread Krzysztof Parzyszek via cfe-commits


@@ -342,4 +359,22 @@ def TDL_DirA : Directive<"dira"> {
 // IMPL-NEXT:llvm_unreachable("Invalid Tdl Directive kind");
 // IMPL-NEXT:  }
 // IMPL-EMPTY:
+// IMPL-NEXT:  llvm::ArrayRef 
llvm::tdl::getLeafConstructs(llvm::tdl::Directive Dir) {
+// IMPL-NEXT:static llvm::ArrayRef nothing {};

kparzysz wrote:

Eh, sorry, it's a mistake.  Thanks for the catch.

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-06 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-06 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/83625

>From b62919c2ce24feb3c75a5bbecce3d6b6ee8e5b7e Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Tue, 16 Jan 2024 16:40:47 -0600
Subject: [PATCH 1/9] [Frontend] Add leaf constructs and association to
 OpenMP/ACC directives

Add members "leafs" and "association" to .td describing OpenMP/ACC
directives: "leafs" are the leaf constructs for composite/combined
constructs, and "association" is the source language construct to
which the directive applies (e.g. loop, block, etc.)

The tblgen-generated output then contains two additional functions
- getLeafConstructs(D), and
- getDirectiveAssociation(D)
plus "enum class Association", all in namespaces "llvm::omp" and
"llvm::acc".

Note: getLeafConstructs returns an empty sequence for a construct
that is itself a leaf construct.

Use the new functions to simplify a few OpenMP-related functions
in clang.
---
 clang/lib/Basic/OpenMPKinds.cpp   | 130 +++---
 .../llvm/Frontend/Directive/DirectiveBase.td  |  36 +++
 llvm/include/llvm/Frontend/OpenACC/ACC.td |  27 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.td  | 172 +++--
 llvm/include/llvm/TableGen/DirectiveEmitter.h |  10 +
 llvm/utils/TableGen/DirectiveEmitter.cpp  | 236 +-
 6 files changed, 489 insertions(+), 122 deletions(-)

diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 6c31b0824eb8a4..dd1a096d178111 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -574,31 +574,7 @@ const char 
*clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
 }
 
 bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
- DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
- DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop || DKind == OMPD_distribute ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_distribute_simd ||
- DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
- DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile ||
- DKind == OMPD_unroll || DKind == OMPD_loop ||
- DKind == OMPD_teams_loop || DKind == OMPD_target_teams_loop ||
- DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
+  return getDirectiveAssociation(DKind) == Association::Loop;
 }
 
 bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
@@ -619,44 +595,22 @@ bool 
clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd;
+  return DKind == OMPD_taskloop ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
 }
 
 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
- DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
- DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_target_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
- DKind == OMPD_pa

[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-06 Thread Krzysztof Parzyszek via cfe-commits


@@ -342,4 +359,22 @@ def TDL_DirA : Directive<"dira"> {
 // IMPL-NEXT:llvm_unreachable("Invalid Tdl Directive kind");
 // IMPL-NEXT:  }
 // IMPL-EMPTY:
+// IMPL-NEXT:  llvm::ArrayRef 
llvm::tdl::getLeafConstructs(llvm::tdl::Directive Dir) {
+// IMPL-NEXT:static llvm::ArrayRef nothing {};

kparzysz wrote:

Returning an empty ArrayRef by value now.  I can't use regular array (as in the 
case of non-empty sets), because I can't create a zero-length array.  The empty 
ArrayRef does not refer to any storage, so returning it by value should be ok.

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-06 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-06 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-06 Thread Krzysztof Parzyszek via cfe-commits


@@ -435,6 +450,217 @@ static void GenerateIsAllowedClause(const 
DirectiveLanguage &DirLang,
   OS << "}\n"; // End of function isAllowedClauseForDirective
 }
 
+// Generate the getLeafConstructs function implementation.
+static void GenerateGetLeafConstructs(const DirectiveLanguage &DirLang,
+  raw_ostream &OS) {
+  auto getQualifiedName = [&](StringRef Formatted) -> std::string {
+return (llvm::Twine("llvm::") + DirLang.getCppNamespace() +
+"::Directive::" + DirLang.getDirectivePrefix() + Formatted)
+.str();
+  };
+
+  // For each list of leaves, generate a static local object, then
+  // return a reference to that object for a given directive, e.g.
+  //
+  //   static ListTy leafConstructs_A_B = { A, B };
+  //   static ListTy leafConstructs_C_D_E = { C, D, E };
+  //   switch (Dir) {
+  // case A_B:
+  //   return leafConstructs_A_B;
+  // case C_D_E:
+  //   return leafConstructs_C_D_E;
+  //   }
+
+  // Map from a record that defines a directive to the name of the
+  // local object with the list of its leaves.
+  DenseMap ListNames;
+
+  std::string DirectiveTypeName =
+  std::string("llvm::") + DirLang.getCppNamespace().str() + "::Directive";
+
+  OS << '\n';
+
+  // ArrayRef<...> llvmGetLeafConstructs(llvmDirective Dir)
+  OS << "llvm::ArrayRef<" << DirectiveTypeName
+ << "> llvm::" << DirLang.getCppNamespace() << "::getLeafConstructs("
+ << DirectiveTypeName << " Dir) ";
+  OS << "{\n";
+
+  // Generate the locals.
+  for (Record *R : DirLang.getDirectives()) {
+Directive Dir{R};
+
+std::vector LeafConstructs = Dir.getLeafConstructs();
+if (LeafConstructs.empty())
+  continue;
+
+std::string ListName = "leafConstructs_" + Dir.getFormattedName();
+OS << "  static const " << DirectiveTypeName << ' ' << ListName
+   << "[] = {\n";
+for (Record *L : LeafConstructs) {
+  Directive LeafDir{L};
+  OS << "" << getQualifiedName(LeafDir.getFormattedName()) << ",\n";
+}
+OS << "  };\n";

kparzysz wrote:

Yes,
```
static const llvm::omp::Directive[] = {...};
```

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-06 Thread Krzysztof Parzyszek via cfe-commits

kparzysz wrote:

Hey @erichkeane, do you have anything to add?  I have replaced `leafs` in the 
.td file with `leafConstructs`, and with `leaves` elsewhere.

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-06 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [llvm] Draft/wip/preview of using leaf constructs in clang (PR #84817)

2024-03-11 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz created 
https://github.com/llvm/llvm-project/pull/84817

This doesn't do anything with clauses yet.  It's just hooking things up to 
handle leaf constructs, and it's not even trying to cover all cases.

>From 45859d3b1fb914d26831086fb7f7e6decdec9010 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Mon, 11 Mar 2024 12:55:38 -0500
Subject: [PATCH 1/2] [Frontend][OpenMP] Add isCompositeConstruct and
 isCombinedConstruct

Implement helper functions to identify composite and combined constructs.
---
 llvm/include/llvm/Frontend/OpenMP/OMP.h |  5 +
 llvm/lib/Frontend/OpenMP/OMP.cpp| 21 +
 2 files changed, 26 insertions(+)

diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.h 
b/llvm/include/llvm/Frontend/OpenMP/OMP.h
index a85cd9d344c6d7..59737417b4b014 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMP.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMP.h
@@ -15,4 +15,9 @@
 
 #include "llvm/Frontend/OpenMP/OMP.h.inc"
 
+namespace llvm::omp {
+bool isCompositeConstruct(Directive D);
+bool isCombinedConstruct(Directive D);
+} // namespace llvm::omp
+
 #endif // LLVM_FRONTEND_OPENMP_OMP_H
diff --git a/llvm/lib/Frontend/OpenMP/OMP.cpp b/llvm/lib/Frontend/OpenMP/OMP.cpp
index 4f2f95392648b3..19327277d22ad8 100644
--- a/llvm/lib/Frontend/OpenMP/OMP.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMP.cpp
@@ -8,6 +8,7 @@
 
 #include "llvm/Frontend/OpenMP/OMP.h"
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -17,3 +18,23 @@ using namespace omp;
 
 #define GEN_DIRECTIVES_IMPL
 #include "llvm/Frontend/OpenMP/OMP.inc"
+
+namespace llvm::omp {
+bool isCompositeConstruct(Directive D) {
+  // OpenMP Spec 5.2: [17.3, 8-9]
+  // If directive-name-A and directive-name-B both correspond to loop-
+  // associated constructs then directive-name is a composite construct
+  size_t numLoopConstructs =
+  llvm::count_if(getLeafConstructs(D), [](Directive L) {
+return getDirectiveAssociation(L) == Association::Loop;
+  });
+  return numLoopConstructs > 1;
+}
+
+bool isCombinedConstruct(Directive D) {
+  // OpenMP Spec 5.2: [17.3, 9-10]
+  // Otherwise directive-name is a combined construct.
+  return !getLeafConstructs(D).empty() && !isCompositeConstruct(D);
+}
+
+} // namespace llvm::omp

>From 0f4bf060d080b156708ff6e9d3fa7987e7652b9c Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Thu, 7 Mar 2024 07:10:20 -0600
Subject: [PATCH 2/2] Draft/wip/preview of using leaf constructs

---
 clang/include/clang/Sema/Sema.h |  3 ++
 clang/lib/Basic/OpenMPKinds.cpp | 35 -
 clang/lib/Parse/ParseOpenMP.cpp | 28 ++---
 clang/lib/Sema/SemaOpenMP.cpp   | 54 -
 4 files changed, 79 insertions(+), 41 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 267c79cc057cba..e5e62d5ea5e8ac 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13718,6 +13718,9 @@ class Sema final {
   ///
   /// \returns Statement for finished OpenMP region.
   StmtResult ActOnOpenMPRegionEnd(StmtResult S, ArrayRef Clauses);
+  StmtResult ActOnOpenMPRegionEnd(
+  StmtResult S, ArrayRef Clauses,
+  std::function callback);
   StmtResult ActOnOpenMPExecutableDirective(
   OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName,
   OpenMPDirectiveKind CancelRegion, ArrayRef Clauses,
diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index b3e9affbb3e58a..289da880400c80 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -706,6 +706,11 @@ void clang::getOpenMPCaptureRegions(
 SmallVectorImpl &CaptureRegions,
 OpenMPDirectiveKind DKind) {
   assert(unsigned(DKind) < llvm::omp::Directive_enumSize);
+  if (isCombinedConstruct(DKind)) {
+for (OpenMPDirectiveKind Leaf : getLeafConstructs(DKind))
+  getOpenMPCaptureRegions(CaptureRegions, Leaf);
+return;
+  }
   switch (DKind) {
   case OMPD_metadirective:
 CaptureRegions.push_back(OMPD_metadirective);
@@ -713,15 +718,15 @@ void clang::getOpenMPCaptureRegions(
   case OMPD_parallel:
   case OMPD_parallel_for:
   case OMPD_parallel_for_simd:
-  case OMPD_parallel_master:
-  case OMPD_parallel_masked:
-  case OMPD_parallel_sections:
+  // case OMPD_parallel_master:
+  // case OMPD_parallel_masked:
+  // case OMPD_parallel_sections:
   case OMPD_distribute_parallel_for:
   case OMPD_distribute_parallel_for_simd:
-  case OMPD_parallel_loop:
+  // case OMPD_parallel_loop:
 CaptureRegions.push_back(OMPD_parallel);
 break;
-  case OMPD_target_teams:
+  // case OMPD_target_teams:
   case OMPD_target_teams_distribute:
   case OMPD_target_teams_distribute_simd:
 CaptureRegions.push_back(OMPD_task);
@@ -729,8 +734,8 @@ void clang::getOpenMPCaptureRegions(
 CaptureRegions.push_back(OMPD_teams);
 break;
   case OM

[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-01 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz created 
https://github.com/llvm/llvm-project/pull/83625

Add members "leafs" and "association" to .td describing OpenMP/ACC directives: 
"leafs" are the leaf constructs for composite/combined constructs, and 
"association" is the source language construct to which the directive applies 
(e.g. loop, block, etc.)

The tblgen-generated output then contains two additional functions
- getLeafConstructs(D), and
- getDirectiveAssociation(D) plus "enum class Association", all in namespaces 
"llvm::omp" and "llvm::acc".

Note: getLeafConstructs returns an empty sequence for a construct that is 
itself a leaf construct.

Use the new functions to simplify a few OpenMP-related functions in clang.

>From 544b309d77a7094d35794e574a1a1d12438021cd Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Tue, 16 Jan 2024 16:40:47 -0600
Subject: [PATCH] [Frontend] Add leaf constructs and association to OpenMP/ACC
 directives

Add members "leafs" and "association" to .td describing OpenMP/ACC
directives: "leafs" are the leaf constructs for composite/combined
constructs, and "association" is the source language construct to
which the directive applies (e.g. loop, block, etc.)

The tblgen-generated output then contains two additional functions
- getLeafConstructs(D), and
- getDirectiveAssociation(D)
plus "enum class Association", all in namespaces "llvm::omp" and
"llvm::acc".

Note: getLeafConstructs returns an empty sequence for a construct
that is itself a leaf construct.

Use the new functions to simplify a few OpenMP-related functions
in clang.
---
 clang/lib/Basic/OpenMPKinds.cpp   | 130 +++---
 .../llvm/Frontend/Directive/DirectiveBase.td  |  36 +++
 llvm/include/llvm/Frontend/OpenACC/ACC.td |  27 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.td  | 172 +++--
 llvm/include/llvm/TableGen/DirectiveEmitter.h |  12 +
 llvm/utils/TableGen/DirectiveEmitter.cpp  | 236 +-
 6 files changed, 491 insertions(+), 122 deletions(-)

diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 6c31b0824eb8a4..dd1a096d178111 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -574,31 +574,7 @@ const char 
*clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
 }
 
 bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
- DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
- DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop || DKind == OMPD_distribute ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_distribute_simd ||
- DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
- DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile ||
- DKind == OMPD_unroll || DKind == OMPD_loop ||
- DKind == OMPD_teams_loop || DKind == OMPD_target_teams_loop ||
- DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
+  return getDirectiveAssociation(DKind) == Association::Loop;
 }
 
 bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
@@ -619,44 +595,22 @@ bool 
clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd;
+  return DKind == OMPD_taskloop ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
 }
 
 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
- DKind == OMPD_parallel_for_si

[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-01 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/83625

>From b62919c2ce24feb3c75a5bbecce3d6b6ee8e5b7e Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Tue, 16 Jan 2024 16:40:47 -0600
Subject: [PATCH] [Frontend] Add leaf constructs and association to OpenMP/ACC
 directives

Add members "leafs" and "association" to .td describing OpenMP/ACC
directives: "leafs" are the leaf constructs for composite/combined
constructs, and "association" is the source language construct to
which the directive applies (e.g. loop, block, etc.)

The tblgen-generated output then contains two additional functions
- getLeafConstructs(D), and
- getDirectiveAssociation(D)
plus "enum class Association", all in namespaces "llvm::omp" and
"llvm::acc".

Note: getLeafConstructs returns an empty sequence for a construct
that is itself a leaf construct.

Use the new functions to simplify a few OpenMP-related functions
in clang.
---
 clang/lib/Basic/OpenMPKinds.cpp   | 130 +++---
 .../llvm/Frontend/Directive/DirectiveBase.td  |  36 +++
 llvm/include/llvm/Frontend/OpenACC/ACC.td |  27 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.td  | 172 +++--
 llvm/include/llvm/TableGen/DirectiveEmitter.h |  10 +
 llvm/utils/TableGen/DirectiveEmitter.cpp  | 236 +-
 6 files changed, 489 insertions(+), 122 deletions(-)

diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 6c31b0824eb8a4..dd1a096d178111 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -574,31 +574,7 @@ const char 
*clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
 }
 
 bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
- DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
- DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop || DKind == OMPD_distribute ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_distribute_simd ||
- DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
- DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile ||
- DKind == OMPD_unroll || DKind == OMPD_loop ||
- DKind == OMPD_teams_loop || DKind == OMPD_target_teams_loop ||
- DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
+  return getDirectiveAssociation(DKind) == Association::Loop;
 }
 
 bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
@@ -619,44 +595,22 @@ bool 
clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd;
+  return DKind == OMPD_taskloop ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
 }
 
 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
- DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
- DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_target_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
- DKind == OMPD_parall

[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-01 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/83625

>From b62919c2ce24feb3c75a5bbecce3d6b6ee8e5b7e Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Tue, 16 Jan 2024 16:40:47 -0600
Subject: [PATCH 1/2] [Frontend] Add leaf constructs and association to
 OpenMP/ACC directives

Add members "leafs" and "association" to .td describing OpenMP/ACC
directives: "leafs" are the leaf constructs for composite/combined
constructs, and "association" is the source language construct to
which the directive applies (e.g. loop, block, etc.)

The tblgen-generated output then contains two additional functions
- getLeafConstructs(D), and
- getDirectiveAssociation(D)
plus "enum class Association", all in namespaces "llvm::omp" and
"llvm::acc".

Note: getLeafConstructs returns an empty sequence for a construct
that is itself a leaf construct.

Use the new functions to simplify a few OpenMP-related functions
in clang.
---
 clang/lib/Basic/OpenMPKinds.cpp   | 130 +++---
 .../llvm/Frontend/Directive/DirectiveBase.td  |  36 +++
 llvm/include/llvm/Frontend/OpenACC/ACC.td |  27 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.td  | 172 +++--
 llvm/include/llvm/TableGen/DirectiveEmitter.h |  10 +
 llvm/utils/TableGen/DirectiveEmitter.cpp  | 236 +-
 6 files changed, 489 insertions(+), 122 deletions(-)

diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 6c31b0824eb8a4..dd1a096d178111 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -574,31 +574,7 @@ const char 
*clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
 }
 
 bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
- DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
- DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop || DKind == OMPD_distribute ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_distribute_simd ||
- DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
- DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile ||
- DKind == OMPD_unroll || DKind == OMPD_loop ||
- DKind == OMPD_teams_loop || DKind == OMPD_target_teams_loop ||
- DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
+  return getDirectiveAssociation(DKind) == Association::Loop;
 }
 
 bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
@@ -619,44 +595,22 @@ bool 
clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd;
+  return DKind == OMPD_taskloop ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
 }
 
 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
- DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
- DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_target_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
- DKind == OMPD_pa

[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-01 Thread Krzysztof Parzyszek via cfe-commits


@@ -665,60 +619,44 @@ bool 
clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_loop;
+  if (DKind == OMPD_teams)
+return true;
+  auto leafs = getLeafConstructs(DKind);

kparzysz wrote:

Done

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-01 Thread Krzysztof Parzyszek via cfe-commits


@@ -665,60 +619,44 @@ bool 
clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_loop;
+  if (DKind == OMPD_teams)
+return true;
+  auto leafs = getLeafConstructs(DKind);
+  return !leafs.empty() && leafs.front() == OMPD_teams;
 }
 
 bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {
-  return isOpenMPNestingTeamsDirective(DKind) || DKind == OMPD_target_teams ||
- DKind == OMPD_target_teams_distribute ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd ||
- DKind == OMPD_target_teams_loop;
+  return DKind == OMPD_teams ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_teams);
 }
 
 bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_simd || DKind == OMPD_for_simd ||
- DKind == OMPD_parallel_for_simd || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_distribute_simd || DKind == OMPD_target_simd ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd ||
- DKind == OMPD_target_parallel_for_simd;
+  // Avoid OMPD_declare_simd
+  if (DKind == OMPD_end_do_simd ||
+  getDirectiveAssociation(DKind) != Association::Loop)
+return false;
+
+  return DKind == OMPD_simd ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_simd);
 }
 
 bool clang::isOpenMPNestingDistributeDirective(OpenMPDirectiveKind Kind) {
-  return Kind == OMPD_distribute || Kind == OMPD_distribute_parallel_for ||
- Kind == OMPD_distribute_parallel_for_simd ||
- Kind == OMPD_distribute_simd;
-  // TODO add next directives.
+  if (Kind == OMPD_distribute)
+return true;
+  auto leafs = getLeafConstructs(Kind);

kparzysz wrote:

Done

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-01 Thread Krzysztof Parzyszek via cfe-commits


@@ -665,60 +619,44 @@ bool 
clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_loop;
+  if (DKind == OMPD_teams)
+return true;
+  auto leafs = getLeafConstructs(DKind);
+  return !leafs.empty() && leafs.front() == OMPD_teams;
 }
 
 bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {
-  return isOpenMPNestingTeamsDirective(DKind) || DKind == OMPD_target_teams ||
- DKind == OMPD_target_teams_distribute ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd ||
- DKind == OMPD_target_teams_loop;
+  return DKind == OMPD_teams ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_teams);
 }
 
 bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_simd || DKind == OMPD_for_simd ||
- DKind == OMPD_parallel_for_simd || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_distribute_simd || DKind == OMPD_target_simd ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd ||
- DKind == OMPD_target_parallel_for_simd;
+  // Avoid OMPD_declare_simd
+  if (DKind == OMPD_end_do_simd ||
+  getDirectiveAssociation(DKind) != Association::Loop)
+return false;
+
+  return DKind == OMPD_simd ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_simd);
 }
 
 bool clang::isOpenMPNestingDistributeDirective(OpenMPDirectiveKind Kind) {
-  return Kind == OMPD_distribute || Kind == OMPD_distribute_parallel_for ||
- Kind == OMPD_distribute_parallel_for_simd ||
- Kind == OMPD_distribute_simd;
-  // TODO add next directives.
+  if (Kind == OMPD_distribute)
+return true;
+  auto leafs = getLeafConstructs(Kind);
+  return !leafs.empty() && leafs.front() == OMPD_distribute;
 }
 
 bool clang::isOpenMPDistributeDirective(OpenMPDirectiveKind Kind) {
-  return isOpenMPNestingDistributeDirective(Kind) ||
- Kind == OMPD_teams_distribute || Kind == OMPD_teams_distribute_simd ||
- Kind == OMPD_teams_distribute_parallel_for_simd ||
- Kind == OMPD_teams_distribute_parallel_for ||
- Kind == OMPD_target_teams_distribute ||
- Kind == OMPD_target_teams_distribute_parallel_for ||
- Kind == OMPD_target_teams_distribute_parallel_for_simd ||
- Kind == OMPD_target_teams_distribute_simd;
+  return Kind == OMPD_distribute ||
+ llvm::is_contained(getLeafConstructs(Kind), OMPD_distribute);
 }
 
 bool clang::isOpenMPGenericLoopDirective(OpenMPDirectiveKind Kind) {
-  return Kind == OMPD_loop || Kind == OMPD_teams_loop ||
- Kind == OMPD_target_teams_loop || Kind == OMPD_parallel_loop ||
- Kind == OMPD_target_parallel_loop;
+  if (Kind == OMPD_loop)
+return true;
+  auto leafs = getLeafConstructs(Kind);

kparzysz wrote:

Done

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-01 Thread Krzysztof Parzyszek via cfe-commits

kparzysz wrote:

I removed the check for `end do simd` with a comment that it can't appear in 
clang.  I think you deleted that remark, let me know if I should bring the 
check back.

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-01 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/83625

>From b62919c2ce24feb3c75a5bbecce3d6b6ee8e5b7e Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Tue, 16 Jan 2024 16:40:47 -0600
Subject: [PATCH 1/3] [Frontend] Add leaf constructs and association to
 OpenMP/ACC directives

Add members "leafs" and "association" to .td describing OpenMP/ACC
directives: "leafs" are the leaf constructs for composite/combined
constructs, and "association" is the source language construct to
which the directive applies (e.g. loop, block, etc.)

The tblgen-generated output then contains two additional functions
- getLeafConstructs(D), and
- getDirectiveAssociation(D)
plus "enum class Association", all in namespaces "llvm::omp" and
"llvm::acc".

Note: getLeafConstructs returns an empty sequence for a construct
that is itself a leaf construct.

Use the new functions to simplify a few OpenMP-related functions
in clang.
---
 clang/lib/Basic/OpenMPKinds.cpp   | 130 +++---
 .../llvm/Frontend/Directive/DirectiveBase.td  |  36 +++
 llvm/include/llvm/Frontend/OpenACC/ACC.td |  27 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.td  | 172 +++--
 llvm/include/llvm/TableGen/DirectiveEmitter.h |  10 +
 llvm/utils/TableGen/DirectiveEmitter.cpp  | 236 +-
 6 files changed, 489 insertions(+), 122 deletions(-)

diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 6c31b0824eb8a4..dd1a096d178111 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -574,31 +574,7 @@ const char 
*clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
 }
 
 bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
- DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
- DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop || DKind == OMPD_distribute ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_distribute_simd ||
- DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
- DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile ||
- DKind == OMPD_unroll || DKind == OMPD_loop ||
- DKind == OMPD_teams_loop || DKind == OMPD_target_teams_loop ||
- DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
+  return getDirectiveAssociation(DKind) == Association::Loop;
 }
 
 bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
@@ -619,44 +595,22 @@ bool 
clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd;
+  return DKind == OMPD_taskloop ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
 }
 
 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
- DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
- DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_target_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
- DKind == OMPD_pa

[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-01 Thread Krzysztof Parzyszek via cfe-commits


@@ -665,60 +619,44 @@ bool 
clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_loop;
+  if (DKind == OMPD_teams)
+return true;
+  auto leafs = getLeafConstructs(DKind);

kparzysz wrote:

Leafs is an accepted form.  I used to live in Toronto, btw.  :)

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-01 Thread Krzysztof Parzyszek via cfe-commits


@@ -665,60 +619,44 @@ bool 
clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_loop;
+  if (DKind == OMPD_teams)
+return true;
+  auto leafs = getLeafConstructs(DKind);
+  return !leafs.empty() && leafs.front() == OMPD_teams;
 }
 
 bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {
-  return isOpenMPNestingTeamsDirective(DKind) || DKind == OMPD_target_teams ||
- DKind == OMPD_target_teams_distribute ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd ||
- DKind == OMPD_target_teams_loop;
+  return DKind == OMPD_teams ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_teams);
 }
 
 bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_simd || DKind == OMPD_for_simd ||
- DKind == OMPD_parallel_for_simd || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_distribute_simd || DKind == OMPD_target_simd ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd ||
- DKind == OMPD_target_parallel_for_simd;
+  // Avoid OMPD_declare_simd
+  if (DKind == OMPD_end_do_simd ||

kparzysz wrote:

Removed.

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-02 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/83625

>From b62919c2ce24feb3c75a5bbecce3d6b6ee8e5b7e Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Tue, 16 Jan 2024 16:40:47 -0600
Subject: [PATCH 1/3] [Frontend] Add leaf constructs and association to
 OpenMP/ACC directives

Add members "leafs" and "association" to .td describing OpenMP/ACC
directives: "leafs" are the leaf constructs for composite/combined
constructs, and "association" is the source language construct to
which the directive applies (e.g. loop, block, etc.)

The tblgen-generated output then contains two additional functions
- getLeafConstructs(D), and
- getDirectiveAssociation(D)
plus "enum class Association", all in namespaces "llvm::omp" and
"llvm::acc".

Note: getLeafConstructs returns an empty sequence for a construct
that is itself a leaf construct.

Use the new functions to simplify a few OpenMP-related functions
in clang.
---
 clang/lib/Basic/OpenMPKinds.cpp   | 130 +++---
 .../llvm/Frontend/Directive/DirectiveBase.td  |  36 +++
 llvm/include/llvm/Frontend/OpenACC/ACC.td |  27 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.td  | 172 +++--
 llvm/include/llvm/TableGen/DirectiveEmitter.h |  10 +
 llvm/utils/TableGen/DirectiveEmitter.cpp  | 236 +-
 6 files changed, 489 insertions(+), 122 deletions(-)

diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 6c31b0824eb8a4..dd1a096d178111 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -574,31 +574,7 @@ const char 
*clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
 }
 
 bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
- DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
- DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop || DKind == OMPD_distribute ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_distribute_simd ||
- DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
- DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile ||
- DKind == OMPD_unroll || DKind == OMPD_loop ||
- DKind == OMPD_teams_loop || DKind == OMPD_target_teams_loop ||
- DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
+  return getDirectiveAssociation(DKind) == Association::Loop;
 }
 
 bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
@@ -619,44 +595,22 @@ bool 
clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd;
+  return DKind == OMPD_taskloop ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
 }
 
 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
- DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
- DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_target_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
- DKind == OMPD_pa

[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-02 Thread Krzysztof Parzyszek via cfe-commits

kparzysz wrote:

The failing test on Windows is unrelated.  I've seen it fail in other builds 
before.

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/83625

>From b62919c2ce24feb3c75a5bbecce3d6b6ee8e5b7e Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Tue, 16 Jan 2024 16:40:47 -0600
Subject: [PATCH 1/3] [Frontend] Add leaf constructs and association to
 OpenMP/ACC directives

Add members "leafs" and "association" to .td describing OpenMP/ACC
directives: "leafs" are the leaf constructs for composite/combined
constructs, and "association" is the source language construct to
which the directive applies (e.g. loop, block, etc.)

The tblgen-generated output then contains two additional functions
- getLeafConstructs(D), and
- getDirectiveAssociation(D)
plus "enum class Association", all in namespaces "llvm::omp" and
"llvm::acc".

Note: getLeafConstructs returns an empty sequence for a construct
that is itself a leaf construct.

Use the new functions to simplify a few OpenMP-related functions
in clang.
---
 clang/lib/Basic/OpenMPKinds.cpp   | 130 +++---
 .../llvm/Frontend/Directive/DirectiveBase.td  |  36 +++
 llvm/include/llvm/Frontend/OpenACC/ACC.td |  27 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.td  | 172 +++--
 llvm/include/llvm/TableGen/DirectiveEmitter.h |  10 +
 llvm/utils/TableGen/DirectiveEmitter.cpp  | 236 +-
 6 files changed, 489 insertions(+), 122 deletions(-)

diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 6c31b0824eb8a4..dd1a096d178111 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -574,31 +574,7 @@ const char 
*clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
 }
 
 bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
- DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
- DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop || DKind == OMPD_distribute ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_distribute_simd ||
- DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
- DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile ||
- DKind == OMPD_unroll || DKind == OMPD_loop ||
- DKind == OMPD_teams_loop || DKind == OMPD_target_teams_loop ||
- DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
+  return getDirectiveAssociation(DKind) == Association::Loop;
 }
 
 bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
@@ -619,44 +595,22 @@ bool 
clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd;
+  return DKind == OMPD_taskloop ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
 }
 
 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
- DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
- DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_target_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
- DKind == OMPD_pa

[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Krzysztof Parzyszek via cfe-commits


@@ -619,44 +595,22 @@ bool 
clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd;
+  return DKind == OMPD_taskloop ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
 }
 
 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
- DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
- DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_target_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop ||
- DKind == OMPD_teams_loop;
+  if (DKind == OMPD_parallel_workshare)
+return false;

kparzysz wrote:

I removed the check.  Formally, it does fall under the "parallel" family of 
directives, so I think we shouldn't exclude it on the basis that it will never 
show up.

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/83625

>From b62919c2ce24feb3c75a5bbecce3d6b6ee8e5b7e Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Tue, 16 Jan 2024 16:40:47 -0600
Subject: [PATCH 1/4] [Frontend] Add leaf constructs and association to
 OpenMP/ACC directives

Add members "leafs" and "association" to .td describing OpenMP/ACC
directives: "leafs" are the leaf constructs for composite/combined
constructs, and "association" is the source language construct to
which the directive applies (e.g. loop, block, etc.)

The tblgen-generated output then contains two additional functions
- getLeafConstructs(D), and
- getDirectiveAssociation(D)
plus "enum class Association", all in namespaces "llvm::omp" and
"llvm::acc".

Note: getLeafConstructs returns an empty sequence for a construct
that is itself a leaf construct.

Use the new functions to simplify a few OpenMP-related functions
in clang.
---
 clang/lib/Basic/OpenMPKinds.cpp   | 130 +++---
 .../llvm/Frontend/Directive/DirectiveBase.td  |  36 +++
 llvm/include/llvm/Frontend/OpenACC/ACC.td |  27 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.td  | 172 +++--
 llvm/include/llvm/TableGen/DirectiveEmitter.h |  10 +
 llvm/utils/TableGen/DirectiveEmitter.cpp  | 236 +-
 6 files changed, 489 insertions(+), 122 deletions(-)

diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 6c31b0824eb8a4..dd1a096d178111 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -574,31 +574,7 @@ const char 
*clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
 }
 
 bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
- DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
- DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop || DKind == OMPD_distribute ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_distribute_simd ||
- DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
- DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile ||
- DKind == OMPD_unroll || DKind == OMPD_loop ||
- DKind == OMPD_teams_loop || DKind == OMPD_target_teams_loop ||
- DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
+  return getDirectiveAssociation(DKind) == Association::Loop;
 }
 
 bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
@@ -619,44 +595,22 @@ bool 
clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd;
+  return DKind == OMPD_taskloop ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
 }
 
 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
- DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
- DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_target_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
- DKind == OMPD_pa

[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Krzysztof Parzyszek via cfe-commits


@@ -231,6 +244,8 @@ static void EmitDirectivesDecl(RecordKeeper &Records, 
raw_ostream &OS) {
   OS << "bool isAllowedClauseForDirective(Directive D, "
  << "Clause C, unsigned Version);\n";
   OS << "\n";
+  OS << "const llvm::SmallVector &getLeafConstructs(Directive 
D);\n";

kparzysz wrote:

I don't think this is a good idea.  Returning a reference is pretty much free, 
Returning an ArrayRef will always create a temporary object.  You can always 
use ArrayRef in the caller, if that's what's desired there.

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Krzysztof Parzyszek via cfe-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/83625

>From b62919c2ce24feb3c75a5bbecce3d6b6ee8e5b7e Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Tue, 16 Jan 2024 16:40:47 -0600
Subject: [PATCH 1/5] [Frontend] Add leaf constructs and association to
 OpenMP/ACC directives

Add members "leafs" and "association" to .td describing OpenMP/ACC
directives: "leafs" are the leaf constructs for composite/combined
constructs, and "association" is the source language construct to
which the directive applies (e.g. loop, block, etc.)

The tblgen-generated output then contains two additional functions
- getLeafConstructs(D), and
- getDirectiveAssociation(D)
plus "enum class Association", all in namespaces "llvm::omp" and
"llvm::acc".

Note: getLeafConstructs returns an empty sequence for a construct
that is itself a leaf construct.

Use the new functions to simplify a few OpenMP-related functions
in clang.
---
 clang/lib/Basic/OpenMPKinds.cpp   | 130 +++---
 .../llvm/Frontend/Directive/DirectiveBase.td  |  36 +++
 llvm/include/llvm/Frontend/OpenACC/ACC.td |  27 +-
 llvm/include/llvm/Frontend/OpenMP/OMP.td  | 172 +++--
 llvm/include/llvm/TableGen/DirectiveEmitter.h |  10 +
 llvm/utils/TableGen/DirectiveEmitter.cpp  | 236 +-
 6 files changed, 489 insertions(+), 122 deletions(-)

diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 6c31b0824eb8a4..dd1a096d178111 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -574,31 +574,7 @@ const char 
*clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
 }
 
 bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_simd || DKind == OMPD_for || DKind == OMPD_for_simd ||
- DKind == OMPD_parallel_for || DKind == OMPD_parallel_for_simd ||
- DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop || DKind == OMPD_distribute ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_distribute_simd ||
- DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
- DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile ||
- DKind == OMPD_unroll || DKind == OMPD_loop ||
- DKind == OMPD_teams_loop || DKind == OMPD_target_teams_loop ||
- DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
+  return getDirectiveAssociation(DKind) == Association::Loop;
 }
 
 bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
@@ -619,44 +595,22 @@ bool 
clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
- DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
- DKind == OMPD_parallel_masked_taskloop ||
- DKind == OMPD_parallel_masked_taskloop_simd ||
- DKind == OMPD_parallel_master_taskloop_simd;
+  return DKind == OMPD_taskloop ||
+ llvm::is_contained(getLeafConstructs(DKind), OMPD_taskloop);
 }
 
 bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_parallel || DKind == OMPD_parallel_for ||
- DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections ||
- DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for ||
- DKind == OMPD_distribute_parallel_for ||
- DKind == OMPD_distribute_parallel_for_simd ||
- DKind == OMPD_target_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
- DKind == OMPD_pa

[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Krzysztof Parzyszek via cfe-commits


@@ -665,60 +617,45 @@ bool 
clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
 }
 
 bool clang::isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind) {
-  return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
- DKind == OMPD_teams_distribute_simd ||
- DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for ||
- DKind == OMPD_teams_loop;
+  if (DKind == OMPD_teams)
+return true;
+  auto Leafs = getLeafConstructs(DKind);

kparzysz wrote:

Done

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Krzysztof Parzyszek via cfe-commits

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Krzysztof Parzyszek via cfe-commits


@@ -231,6 +244,8 @@ static void EmitDirectivesDecl(RecordKeeper &Records, 
raw_ostream &OS) {
   OS << "bool isAllowedClauseForDirective(Directive D, "
  << "Clause C, unsigned Version);\n";
   OS << "\n";
+  OS << "const llvm::SmallVector &getLeafConstructs(Directive 
D);\n";

kparzysz wrote:

The ArrayRef will be the temporary object.

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


[clang] [llvm] [Frontend] Add leaf constructs and association to OpenMP/ACC directives (PR #83625)

2024-03-03 Thread Krzysztof Parzyszek via cfe-commits


@@ -231,6 +244,8 @@ static void EmitDirectivesDecl(RecordKeeper &Records, 
raw_ostream &OS) {
   OS << "bool isAllowedClauseForDirective(Directive D, "
  << "Clause C, unsigned Version);\n";
   OS << "\n";
+  OS << "const llvm::SmallVector &getLeafConstructs(Directive 
D);\n";

kparzysz wrote:

I'm expecting you to be more professional in your replies.  I'm simply trying 
to understand your motivation here.

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


  1   2   3   4   5   >