[llvm] 8922a1c - Move definitions of ArgKind from Intrinsics.h to Intrinsics.td
NAKAMURA Takumi via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 30 17:15:41 PDT 2023
Author: NAKAMURA Takumi
Date: 2023-03-31T09:15:08+09:00
New Revision: 8922a1c15ba24ca3449fc475998bc037608d428b
URL: https://github.com/llvm/llvm-project/commit/8922a1c15ba24ca3449fc475998bc037608d428b
DIFF: https://github.com/llvm/llvm-project/commit/8922a1c15ba24ca3449fc475998bc037608d428b.diff
LOG: Move definitions of ArgKind from Intrinsics.h to Intrinsics.td
Values of ArgKind are used (as naked constants) also in IntrinsicEmitter.
They can be dissolved to move their logic to Intrinsics.td.
Differential Revision: https://reviews.llvm.org/D145873
Added:
Modified:
llvm/include/llvm/IR/Intrinsics.h
llvm/include/llvm/IR/Intrinsics.td
llvm/utils/TableGen/IntrinsicEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Intrinsics.h b/llvm/include/llvm/IR/Intrinsics.h
index 9bb7c86d26caf..c677983b71867 100644
--- a/llvm/include/llvm/IR/Intrinsics.h
+++ b/llvm/include/llvm/IR/Intrinsics.h
@@ -149,13 +149,11 @@ namespace Intrinsic {
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 {
diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index c24f53ce018f9..5962471647d59 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -167,6 +167,21 @@ def IntrSpeculatable : IntrinsicProperty;
// 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.
//===----------------------------------------------------------------------===//
diff --git a/llvm/utils/TableGen/IntrinsicEmitter.cpp b/llvm/utils/TableGen/IntrinsicEmitter.cpp
index e93182849173d..0e3c9694097c8 100644
--- a/llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ b/llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -53,6 +53,7 @@ class IntrinsicEmitter {
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 @@ void IntrinsicEmitter::run(raw_ostream &OS, bool Enums) {
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::EmitEnumInfo(const CodeGenIntrinsicTable &Ints,
}
}
+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";
More information about the llvm-commits
mailing list