[PATCH] D145873: Move definitions of ArgKind from Intrinsics.h to Intrinsics.td

NAKAMURA Takumi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 30 17:15:49 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8922a1c15ba2: Move definitions of ArgKind from Intrinsics.h to Intrinsics.td (authored by chapuni).

Changed prior to commit:
  https://reviews.llvm.org/D145873?vs=505326&id=509858#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145873

Files:
  llvm/include/llvm/IR/Intrinsics.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/utils/TableGen/IntrinsicEmitter.cpp


Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===================================================================
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -53,6 +53,7 @@
   void run(raw_ostream &OS, bool Enums);
 
   void EmitEnumInfo(const CodeGenIntrinsicTable &Ints, raw_ostream &OS);
+  void EmitArgKind(raw_ostream &OS);
   void EmitTargetInfo(const CodeGenIntrinsicTable &Ints, raw_ostream &OS);
   void EmitIntrinsicToNameTable(const CodeGenIntrinsicTable &Ints,
                                 raw_ostream &OS);
@@ -77,6 +78,9 @@
   if (Enums) {
     // Emit the enum information.
     EmitEnumInfo(Ints, OS);
+
+    // Emit ArgKind for Intrinsics.h.
+    EmitArgKind(OS);
   } else {
     // Emit the target metadata.
     EmitTargetInfo(Ints, OS);
@@ -162,6 +166,20 @@
   }
 }
 
+void IntrinsicEmitter::EmitArgKind(raw_ostream &OS) {
+  if (!IntrinsicPrefix.empty())
+    return;
+  OS << "// llvm::Intrinsic::IITDescriptor::ArgKind\n";
+  OS << "#ifdef GET_INTRINSIC_ARGKIND\n";
+  if (auto RecArgKind = Records.getDef("ArgKind")) {
+    for (auto &RV : RecArgKind->getValues())
+      OS << "    AK_" << RV.getName() << " = " << *RV.getValue() << ",\n";
+  } else {
+    OS << "#error \"ArgKind is not defined\"\n";
+  }
+  OS << "#endif\n\n";
+}
+
 void IntrinsicEmitter::EmitTargetInfo(const CodeGenIntrinsicTable &Ints,
                                     raw_ostream &OS) {
   OS << "// Target mapping\n";
Index: llvm/include/llvm/IR/Intrinsics.td
===================================================================
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -167,6 +167,21 @@
 // defined by the hasSideEffects property of the TableGen Instruction class.
 def IntrHasSideEffects : IntrinsicProperty;
 
+//===----------------------------------------------------------------------===//
+// IIT constants and utils
+//===----------------------------------------------------------------------===//
+
+// llvm::Intrinsic::IITDescriptor::ArgKind::AK_%
+def ArgKind {
+  int Any        = 0;
+  int AnyInteger = 1;
+  int AnyFloat   = 2;
+  int AnyVector  = 3;
+  int AnyPointer = 4;
+
+  int MatchType  = 7;
+}
+
 //===----------------------------------------------------------------------===//
 // Types used by intrinsics.
 //===----------------------------------------------------------------------===//
Index: llvm/include/llvm/IR/Intrinsics.h
===================================================================
--- llvm/include/llvm/IR/Intrinsics.h
+++ llvm/include/llvm/IR/Intrinsics.h
@@ -149,13 +149,11 @@
       ElementCount Vector_Width;
     };
 
+    // AK_% : Defined in Intrinsics.td
     enum ArgKind {
-      AK_Any,
-      AK_AnyInteger,
-      AK_AnyFloat,
-      AK_AnyVector,
-      AK_AnyPointer,
-      AK_MatchType = 7
+#define GET_INTRINSIC_ARGKIND
+#include "llvm/IR/IntrinsicEnums.inc"
+#undef GET_INTRINSIC_ARGKIND
     };
 
     unsigned getArgumentNumber() const {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145873.509858.patch
Type: text/x-patch
Size: 2997 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230331/eeedbc4d/attachment.bin>


More information about the llvm-commits mailing list