diff --git a/llvm/include/llvm/IR/Intrinsics.h b/llvm/include/llvm/IR/Intrinsics.h --- a/llvm/include/llvm/IR/Intrinsics.h +++ b/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 { diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td --- a/llvm/include/llvm/IR/Intrinsics.td +++ b/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. //===----------------------------------------------------------------------===// diff --git a/llvm/utils/TableGen/IntrinsicEmitter.cpp b/llvm/utils/TableGen/IntrinsicEmitter.cpp --- a/llvm/utils/TableGen/IntrinsicEmitter.cpp +++ b/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";