[llvm] [RFC][CodeGen] Add generic target feature checks for intrinsics (PR #201470)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 05:05:05 PDT 2026


================
@@ -306,6 +311,33 @@ static constexpr unsigned IntrinsicNameOffsetTable[] = {
   OS << "\n}; // IntrinsicNameOffsetTable\n";
 }
 
+void IntrinsicEmitter::EmitIntrinsicToTargetFeaturesTable(
+    const CodeGenIntrinsicTable &Ints, raw_ostream &OS) {
+  StringToOffsetTable Table;
+  for (const CodeGenIntrinsic &Int : Ints)
+    Table.GetOrAddStringOffset(Int.TargetFeatures);
+
+  IfDefEmitter IfDef(OS, "GET_INTRINSIC_TARGET_FEATURES_TABLE");
+  OS << R"(// Intrinsic ID to required target features table.
+// Note that entry #0 is the invalid intrinsic!
+
+)";
+
+  Table.EmitStringTableDef(OS, "IntrinsicTargetFeaturesTable");
+
+  OS << R"(
+static constexpr unsigned IntrinsicTargetFeaturesOffsetTable[] = {
----------------
shiltian wrote:

Since intrinsic `.td` file is included by all targets, we can't map it to the target-dependent feature bit vector at this point, IIUC.

https://github.com/llvm/llvm-project/pull/201470


More information about the llvm-commits mailing list