[llvm] df9bceb - [TTI][Inline] Define inlining behavior in SubtargetFeature (#205348)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 25 00:34:42 PDT 2026


Author: Nikita Popov
Date: 2026-06-25T09:34:38+02:00
New Revision: df9bcebdb20f846b6335dafedb3452fcb95fee48

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

LOG: [TTI][Inline] Define inlining behavior in SubtargetFeature (#205348)

This allows specifying the InliningBehavior as part of SubtargetFeature.
The behavior is one of InlineDefault, InlineInverse, and InlineIgnore.

* InlineDefault: A callee with this feature enabled cannot be inlined
into a caller without it enabled.
* InlineInverse: A callee without this feature enabled cannot be inlined
into a caller with it enabled.
 * InlineIgnore: Arbitrary differences are allowed.

The default areInlineCompatible() implementation respects these now.

The intention behind this change is that it reduces the risk of
forgetting to update feature lists in TTI when adding a new feature,
e.g. when adding a new tuning flag that should be InlineIgnore.

Move X86 and AMDGPU ignored features, and the one inverse feature on
AArch64 to TableGen.

There is various followup work to do here, e.g. currently tuning flags
on AArch64 are not ignored (and on AMDGPU only some are ignored).

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/BasicTTIImpl.h
    llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
    llvm/include/llvm/Target/Target.td
    llvm/lib/Target/AArch64/AArch64Features.td
    llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
    llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
    llvm/lib/Target/AMDGPU/AMDGPU.td
    llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
    llvm/lib/Target/X86/X86.td
    llvm/lib/Target/X86/X86TargetTransformInfo.cpp
    llvm/lib/Target/X86/X86TargetTransformInfo.h
    llvm/test/TableGen/aarch64-apple-tuning-features.td
    llvm/unittests/CodeGen/MFCommon.inc
    llvm/utils/TableGen/SubtargetEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index d64cda740a77f..8c4df6664cf1d 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -397,10 +397,16 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
                            const Function *Callee) const override {
     const TargetMachine &TM = getTLI()->getTargetMachine();
 
-    const FeatureBitset &CallerBits =
-        TM.getSubtargetImpl(*Caller)->getFeatureBits();
-    const FeatureBitset &CalleeBits =
-        TM.getSubtargetImpl(*Callee)->getFeatureBits();
+    const TargetSubtargetInfo *CallerSTI = TM.getSubtargetImpl(*Caller);
+    const TargetSubtargetInfo *CalleeSTI = TM.getSubtargetImpl(*Callee);
+    FeatureBitset InlineIgnoreFeatures = CallerSTI->getInlineIgnoreFeatures();
+    FeatureBitset InlineInverseFeatures = CallerSTI->getInlineInverseFeatures();
+    FeatureBitset CallerBits =
+        (CallerSTI->getFeatureBits() ^ InlineInverseFeatures) &
+        ~InlineIgnoreFeatures;
+    FeatureBitset CalleeBits =
+        (CalleeSTI->getFeatureBits() ^ InlineInverseFeatures) &
+        ~InlineIgnoreFeatures;
 
     // Inline a callee if its target-features are a subset of the callers
     // target-features.

diff  --git a/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h b/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
index 6f95f0fea6441..fe71a17146184 100644
--- a/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetSubtargetInfo.h
@@ -364,6 +364,12 @@ class LLVM_ABI TargetSubtargetInfo : public MCSubtargetInfo {
   }
 
   virtual bool isRegisterReservedByUser(Register R) const { return false; }
+
+  /// Target features to ignore for inline compatibility check.
+  virtual const FeatureBitset &getInlineIgnoreFeatures() const = 0;
+  /// Target features where the callee may have an additional feature,
+  /// instead of the caller.
+  virtual const FeatureBitset &getInlineInverseFeatures() const = 0;
 };
 } // end namespace llvm
 

diff  --git a/llvm/include/llvm/Target/Target.td b/llvm/include/llvm/Target/Target.td
index a02a4209f86fe..455b9f40f8b72 100644
--- a/llvm/include/llvm/Target/Target.td
+++ b/llvm/include/llvm/Target/Target.td
@@ -522,11 +522,25 @@ class DwarfRegAlias<Register reg> {
       Register DwarfAlias = reg;
 }
 
+// Determine whether inlining is allowed if caller and callee 
diff er in whether
+// a feature is enabled.
+class InlineBehavior;
+
+// Arbitrary 
diff erences are allowed.
+def InlineIgnore : InlineBehavior;
+// A callee with this feature enabled cannot be inlined into a caller without
+// it enabled.
+def InlineDefault : InlineBehavior;
+// A callee without this feature enabled cannot be inlined into a caller with
+// it enabled.
+def InlineInverse : InlineBehavior;
+
 //===----------------------------------------------------------------------===//
 // SubtargetFeature - A characteristic of the chip set.
 //
 class SubtargetFeature<string n, string f, string v, string d,
-                       list<SubtargetFeature> i = []> {
+                       list<SubtargetFeature> i = [],
+                       InlineBehavior ib = InlineDefault> {
   // Name - Feature name. Used by command line (-mattr=) to determine the
   // appropriate target chip.
   //
@@ -555,6 +569,8 @@ class SubtargetFeature<string n, string f, string v, string d,
   // features isn't set, then this one shouldn't be set either.
   //
   list<SubtargetFeature> Implies = !sort(f, i, f.Name);
+
+  InlineBehavior InlineBehavior = ib;
 }
 
 /// Specifies a Subtarget feature that this instruction is deprecated on.

diff  --git a/llvm/lib/Target/AArch64/AArch64Features.td b/llvm/lib/Target/AArch64/AArch64Features.td
index e63f4886a1256..c351a92f2f673 100644
--- a/llvm/lib/Target/AArch64/AArch64Features.td
+++ b/llvm/lib/Target/AArch64/AArch64Features.td
@@ -703,10 +703,13 @@ def FeatureStrictAlign : SubtargetFeature<"strict-align",
                                           "Disallow all unaligned memory "
                                           "access">;
 
+// +execute-only callee can be inlined into caller without +execute-only,
+// but not vice versa.
 def FeatureExecuteOnly : SubtargetFeature<"execute-only",
                                           "GenExecuteOnly", "true",
                                           "Enable the generation of "
-                                          "execute only code.">;
+                                          "execute only code.",
+                                          [], InlineInverse>;
 
 foreach i = {1-7,9-15,18,20-28} in
     def FeatureReserveX#i : SubtargetFeature<"reserve-x"#i, "ReserveXRegister["#i#"]", "true",

diff  --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
index f8d2006cbd7de..57ae3c75c07fa 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -276,10 +276,6 @@ bool AArch64TTIImpl::isMultiversionedFunction(const Function &F) const {
   return F.hasFnAttribute("fmv-features");
 }
 
-const FeatureBitset AArch64TTIImpl::InlineInverseFeatures = {
-    AArch64::FeatureExecuteOnly,
-};
-
 bool AArch64TTIImpl::areInlineCompatible(const Function *Caller,
                                          const Function *Callee) const {
   SMECallAttrs CallAttrs(*Caller, *Callee);
@@ -308,19 +304,7 @@ bool AArch64TTIImpl::areInlineCompatible(const Function *Caller,
       return false;
   }
 
-  const TargetMachine &TM = getTLI()->getTargetMachine();
-  const FeatureBitset &CallerBits =
-      TM.getSubtargetImpl(*Caller)->getFeatureBits();
-  const FeatureBitset &CalleeBits =
-      TM.getSubtargetImpl(*Callee)->getFeatureBits();
-  // Adjust the feature bitsets by inverting some of the bits. This is needed
-  // for target features that represent restrictions rather than capabilities,
-  // for example a "+execute-only" callee can be inlined into a caller without
-  // "+execute-only", but not vice versa.
-  FeatureBitset EffectiveCallerBits = CallerBits ^ InlineInverseFeatures;
-  FeatureBitset EffectiveCalleeBits = CalleeBits ^ InlineInverseFeatures;
-
-  return (EffectiveCallerBits & EffectiveCalleeBits) == EffectiveCalleeBits;
+  return BaseT::areInlineCompatible(Caller, Callee);
 }
 
 bool AArch64TTIImpl::areTypesABICompatible(const Function *Caller,

diff  --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
index 7f07b39bd9ee5..5df5f22793cc8 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
@@ -49,8 +49,6 @@ class AArch64TTIImpl final : public BasicTTIImplBase<AArch64TTIImpl> {
   const AArch64Subtarget *ST;
   const AArch64TargetLowering *TLI;
 
-  static const FeatureBitset InlineInverseFeatures;
-
   const AArch64Subtarget *getST() const { return ST; }
   const AArch64TargetLowering *getTLI() const { return TLI; }
 

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPU.td b/llvm/lib/Target/AMDGPU/AMDGPU.td
index 705e76ebeb7e5..e73f87c17e515 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.td
@@ -53,12 +53,14 @@ multiclass AMDGPUSubtargetFeature<string FeatureString,
                                   string Description,
                                   bit GenPredicate = 1,
                                   bit GenAssemblerPredicate = 1,
-                                  list<SubtargetFeature> Deps = []> {
+                                  list<SubtargetFeature> Deps = [],
+                                  InlineBehavior IB = InlineDefault> {
   def Feature#NAME : SubtargetFeature<FeatureString,
     "Has"#NAME,
     "true",
     Description,
-    Deps
+    Deps,
+    IB
   >;
 
   if GenPredicate then
@@ -72,7 +74,7 @@ multiclass AMDGPUSubtargetFeature<string FeatureString,
 
 defm FastFMAF32 : AMDGPUSubtargetFeature<"fast-fmaf",
   "Assuming f32 fma is at least as fast as mul + add",
-  /*GenPredicate=*/0
+  /*GenPredicate=*/0, /*GenAssemblerPredicate=*/1, [], InlineIgnore
 >;
 
 defm FastDenormalF32 : AMDGPUSubtargetFeature<"fast-denormal-f32",
@@ -87,7 +89,7 @@ defm MIMG_R128 : AMDGPUSubtargetFeature<"mimg-r128",
 
 defm HalfRate64Ops : AMDGPUSubtargetFeature<"half-rate-64-ops",
   "Most fp64 instructions are half rate instead of quarter",
-  /*GenPredicate=*/0
+  /*GenPredicate=*/0, /*GenAssemblerPredicate=*/1, [], InlineIgnore
 >;
 
 defm FullRate64Ops : AMDGPUSubtargetFeature<"full-rate-64-ops",
@@ -144,11 +146,12 @@ defm UnalignedBufferAccess : AMDGPUSubtargetFeature<"unaligned-buffer-access",
 
 defm TrapHandler: AMDGPUSubtargetFeature<"trap-handler",
   "Trap handler support",
-  /*GenPredicate=*/0
+  /*GenPredicate=*/0, /*GenAssemblerPredicate=*/1, [], InlineIgnore
 >;
 
 defm UnalignedScratchAccess : AMDGPUSubtargetFeature<"unaligned-scratch-access",
-  "Support unaligned scratch loads and stores"
+  "Support unaligned scratch loads and stores",
+  /*GenPredicate=*/1, /*GenAssemblerPredicate=*/1, [], InlineIgnore
 >;
 
 defm UnalignedDSAccess : AMDGPUSubtargetFeature<"unaligned-ds-access",
@@ -204,14 +207,16 @@ defm Minimum3Maximum3PKF16 : AMDGPUSubtargetFeature<"minimum3-maximum3-pkf16",
 def FeatureSupportsXNACK : SubtargetFeature<"xnack-support",
   "SupportsXNACK",
   "true",
-  "Hardware supports XNACK"
+  "Hardware supports XNACK",
+  [], InlineIgnore
 >;
 
 defm XNACKOnOffModes : AMDGPUSubtargetFeature<"xnack-on-off-modes",
   "Target supports XNACK on/off modes",
   /*GenPredicate=*/1,
   /*GenAssemblerPredicate=*/0,
-  [FeatureSupportsXNACK]
+  [FeatureSupportsXNACK],
+  InlineIgnore
 >;
 
 // XNACK is disabled if SH_MEM_CONFIG.ADDRESS_MODE = GPUVM on chips that support
@@ -225,7 +230,8 @@ def FeatureXNACK : SubtargetFeature<"xnack",
   "EnableXNACK",
   "true",
   "Enable XNACK support",
-  [FeatureSupportsXNACK]
+  [FeatureSupportsXNACK],
+  InlineIgnore
 >;
 
 def FeatureTgSplit : SubtargetFeature<"tgsplit",
@@ -245,7 +251,8 @@ def FeaturePreciseMemory
                        "true", "Enable precise memory mode">;
 
 defm SGPRInitBug : AMDGPUSubtargetFeature<"sgpr-init-bug",
-  "VI SGPR initialization bug requiring a fixed SGPR allocation size"
+  "VI SGPR initialization bug requiring a fixed SGPR allocation size",
+  /*GenPredicate=*/1, /*GenAssemblerPredicate=*/1, [], InlineIgnore
 >;
 
 defm UserSGPRInit16Bug : AMDGPUSubtargetFeature<"user-sgpr-init16-bug",
@@ -1033,10 +1040,13 @@ defm DefaultComponentBroadcast : AMDGPUSubtargetFeature<"default-component-broad
   "BUFFER/IMAGE store instructions set unspecified components to x component (GFX12)"
 >;
 
+// The default assumption needs to be ecc is enabled, but no directly
+// exposed operations depend on it, so it can be safely inlined.
 def FeatureSupportsSRAMECC : SubtargetFeature<"sramecc-support",
   "SupportsSRAMECC",
   "true",
-  "Hardware supports SRAMECC"
+  "Hardware supports SRAMECC",
+  [], InlineIgnore
 >;
 
 def FeatureSRAMECC : SubtargetFeature<"sramecc",
@@ -1243,7 +1253,8 @@ def FeatureDumpCodeLower : SubtargetFeature <"dumpcode",
 def FeatureEnableLoadStoreOpt : SubtargetFeature <"load-store-opt",
   "EnableLoadStoreOpt",
   "true",
-  "Enable SI load/store optimizer pass"
+  "Enable SI load/store optimizer pass",
+  [], InlineIgnore
 >;
 
 // Performance debugging feature. Allow using DS instruction immediate
@@ -1255,13 +1266,15 @@ def FeatureEnableUnsafeDSOffsetFolding : SubtargetFeature <
   "unsafe-ds-offset-folding",
   "EnableUnsafeDSOffsetFolding",
   "true",
-  "Force using DS instruction immediate offsets on SI"
+  "Force using DS instruction immediate offsets on SI",
+  [], InlineIgnore
 >;
 
 def FeatureEnableSIScheduler : SubtargetFeature<"si-scheduler",
   "EnableSIScheduler",
   "true",
-  "Enable SI Machine Scheduler"
+  "Enable SI Machine Scheduler",
+  [], InlineIgnore
 >;
 
 def FeatureEnableDS128 : SubtargetFeature<"enable-ds128",
@@ -1289,12 +1302,13 @@ def FeatureEnablePRTStrictNull : SubtargetFeature<"enable-prt-strict-null",
 def FeatureUseFlatForGlobal : SubtargetFeature<"flat-for-global",
   "UseFlatForGlobal",
   "true",
-  "Force to generate flat instruction for global"
+  "Force to generate flat instruction for global",
+  [], InlineIgnore
 >;
 
 defm AutoWaitcntBeforeBarrier : AMDGPUSubtargetFeature <"auto-waitcnt-before-barrier",
   "Hardware automatically inserts waitcnt before barrier",
-  /*GenPredicate=*/0
+  /*GenPredicate=*/0, /*GenAssemblerPredicate=*/1, [], InlineIgnore
 >;
 
 defm BackOffBarrier : AMDGPUSubtargetFeature <"back-off-barrier",
@@ -1316,7 +1330,8 @@ defm KernargPreload : AMDGPUSubtargetFeature <"kernarg-preload",
 // SH_MEM_CONFIG.alignment_mode
 defm UnalignedAccessMode : AMDGPUSubtargetFeature<"unaligned-access-mode",
   "Enable unaligned global, local and region loads and stores if the hardware"
-  " supports it"
+  " supports it",
+  /*GenPredicate=*/1, /*GenAssemblerPredicate=*/1, [], InlineIgnore
 >;
 
 defm PackedTID : AMDGPUSubtargetFeature<"packed-tid",

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
index fe66a1a5d7242..40227c496a589 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
@@ -283,26 +283,6 @@ uint64_t AMDGPUTTIImpl::getMaxMemIntrinsicInlineSizeThreshold() const {
   return 1024;
 }
 
-const FeatureBitset GCNTTIImpl::InlineFeatureIgnoreList = {
-    // Codegen control options which don't matter.
-    AMDGPU::FeatureEnableLoadStoreOpt, AMDGPU::FeatureEnableSIScheduler,
-    AMDGPU::FeatureEnableUnsafeDSOffsetFolding, AMDGPU::FeatureUseFlatForGlobal,
-    AMDGPU::FeatureUnalignedScratchAccess, AMDGPU::FeatureUnalignedAccessMode,
-
-    AMDGPU::FeatureAutoWaitcntBeforeBarrier,
-
-    // Property of the kernel/environment which can't actually 
diff er.
-    AMDGPU::FeatureSGPRInitBug, AMDGPU::FeatureXNACK,
-    AMDGPU::FeatureXNACKOnOffModes, AMDGPU::FeatureSupportsXNACK,
-    AMDGPU::FeatureTrapHandler,
-
-    // The default assumption needs to be ecc is enabled, but no directly
-    // exposed operations depend on it, so it can be safely inlined.
-    AMDGPU::FeatureSRAMECC,
-
-    // Perf-tuning features
-    AMDGPU::FeatureFastFMAF32, AMDGPU::FeatureHalfRate64Ops};
-
 GCNTTIImpl::GCNTTIImpl(const AMDGPUTargetMachine *TM, const Function &F)
     : BaseT(TM, F.getDataLayout()),
       ST(static_cast<const GCNSubtarget *>(TM->getSubtargetImpl(F))),
@@ -1569,12 +1549,7 @@ bool GCNTTIImpl::areInlineCompatible(const Function *Caller,
   const GCNSubtarget *CalleeST
     = static_cast<const GCNSubtarget *>(TM.getSubtargetImpl(*Callee));
 
-  const FeatureBitset &CallerBits = CallerST->getFeatureBits();
-  const FeatureBitset &CalleeBits = CalleeST->getFeatureBits();
-
-  FeatureBitset RealCallerBits = CallerBits & ~InlineFeatureIgnoreList;
-  FeatureBitset RealCalleeBits = CalleeBits & ~InlineFeatureIgnoreList;
-  if ((RealCallerBits & RealCalleeBits) != RealCalleeBits)
+  if (!BaseT::areInlineCompatible(Caller, Callee))
     return false;
 
   // FIXME: dx10_clamp can just take the caller setting, but there seems to be

diff  --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index 7551966cb8e15..9e833344e7341 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -44,8 +44,10 @@ def FeatureReserveEDI : SubtargetFeature<"reserve-edi", "ReservedRReg[X86::EDI]"
 def FeatureX87     : SubtargetFeature<"x87","HasX87", "true",
                                       "Enable X87 float instructions">;
 
+// Does not have intrinsics or ABI effects.
 def FeatureNOPL    : SubtargetFeature<"nopl", "HasNOPL", "true",
-                                      "Enable NOPL instruction (generally pentium pro+)">;
+                                      "Enable NOPL instruction (generally pentium pro+)",
+                                      [], InlineIgnore>;
 
 def FeatureCMOV    : SubtargetFeature<"cmov","HasCMOV", "true",
                                       "Enable conditional move instructions">;
@@ -104,10 +106,12 @@ def FeatureMMX     : SubtargetFeature<"mmx","HasMMX", "true",
 // without disabling 64-bit mode. Nothing should imply this feature bit. It
 // is used to enforce that only 64-bit capable CPUs are used in 64-bit mode.
 def FeatureX86_64   : SubtargetFeature<"64bit", "HasX86_64", "true",
-                                      "Support 64-bit instructions">;
+                                      "Support 64-bit instructions", [],
+                                      InlineIgnore>;
+// TODO: This should not be InlineIgnore, as it affects the atomics ABI.
 def FeatureCX16     : SubtargetFeature<"cx16", "HasCX16", "true",
                                        "64-bit with cmpxchg16b (this is true for most x86-64 chips, but not the first AMD chips)",
-                                       [FeatureCX8]>;
+                                       [FeatureCX8], InlineIgnore>;
 def FeatureSSE4A   : SubtargetFeature<"sse4a", "HasSSE4A", "true",
                                       "Support SSE 4a instructions",
                                       [FeatureSSE3]>;
@@ -204,9 +208,10 @@ def FeatureFMA4    : SubtargetFeature<"fma4", "HasFMA4", "true",
 def FeatureXOP     : SubtargetFeature<"xop", "HasXOP", "true",
                                       "Enable XOP instructions",
                                       [FeatureFMA4]>;
-def FeatureSSEUnalignedMem : SubtargetFeature<"sse-unaligned-mem",
-                                          "HasSSEUnalignedMem", "true",
-                      "Allow unaligned memory operands with SSE instructions (this may require setting a configuration bit in the processor)">;
+def FeatureSSEUnalignedMem : SubtargetFeature<
+    "sse-unaligned-mem", "HasSSEUnalignedMem", "true",
+    "Allow unaligned memory operands with SSE instructions (this may require setting a configuration bit in the processor)",
+    [], InlineIgnore>;
 def FeatureAES     : SubtargetFeature<"aes", "HasAES", "true",
                                       "Enable AES instructions",
                                       [FeatureSSE2]>;
@@ -253,8 +258,10 @@ def FeaturePRFCHW  : SubtargetFeature<"prfchw", "HasPRFCHW", "true",
                                       "Support PRFCHW instructions">;
 def FeatureRDSEED  : SubtargetFeature<"rdseed", "HasRDSEED", "true",
                                       "Support RDSEED instruction">;
+// Does not have intrinsics or ABI effects.
 def FeatureLAHFSAHF64 : SubtargetFeature<"sahf", "HasLAHFSAHF64", "true",
-                           "Support LAHF and SAHF instructions in 64-bit mode">;
+                           "Support LAHF and SAHF instructions in 64-bit mode",
+                           [], InlineIgnore>;
 def FeatureMWAITX  : SubtargetFeature<"mwaitx", "HasMWAITX", "true",
                                       "Enable MONITORX/MWAITX timer functionality">;
 def FeatureCLZERO  : SubtargetFeature<"clzero", "HasCLZERO", "true",
@@ -488,55 +495,67 @@ def FeatureHardenSlsIJmp
 //===----------------------------------------------------------------------===//
 def TuningPreferMovmskOverVTest : SubtargetFeature<"prefer-movmsk-over-vtest",
                                        "PreferMovmskOverVTest", "true",
-                                       "Prefer movmsk over vtest instruction">;
+                                       "Prefer movmsk over vtest instruction",
+                                       [], InlineIgnore>;
 
 def TuningSlowSHLD : SubtargetFeature<"slow-shld", "IsSHLDSlow", "true",
-                                       "SHLD instruction is slow">;
+                                       "SHLD instruction is slow",
+                                       [], InlineIgnore>;
 
 def TuningSlowPMULLD : SubtargetFeature<"slow-pmulld", "IsPMULLDSlow", "true",
-                                        "PMULLD instruction is slow (compared to PMULLW/PMULHW and PMULUDQ)">;
+                                        "PMULLD instruction is slow (compared to PMULLW/PMULHW and PMULUDQ)",
+                                        [], InlineIgnore>;
 
 def TuningSlowPMULLQ : SubtargetFeature<"slow-pmullq", "IsPMULLQSlow", "true",
-                                        "PMULLQ instruction is slow">;
+                                        "PMULLQ instruction is slow",
+                                        [], InlineIgnore>;
 
 def TuningSlowPMADDWD : SubtargetFeature<"slow-pmaddwd", "IsPMADDWDSlow",
                                           "true",
-                                          "PMADDWD is slower than PMULLD">;
+                                          "PMADDWD is slower than PMULLD",
+                                          [], InlineIgnore>;
 
 // FIXME: This should not apply to CPUs that do not have SSE.
 def TuningSlowUAMem16 : SubtargetFeature<"slow-unaligned-mem-16",
                                 "IsUnalignedMem16Slow", "true",
-                                "Slow unaligned 16-byte memory access">;
+                                "Slow unaligned 16-byte memory access",
+                                [], InlineIgnore>;
 
 def TuningSlowUAMem32 : SubtargetFeature<"slow-unaligned-mem-32",
                                 "IsUnalignedMem32Slow", "true",
-                                "Slow unaligned 32-byte memory access">;
+                                "Slow unaligned 32-byte memory access",
+                                [], InlineIgnore>;
 
 def TuningLEAForSP : SubtargetFeature<"lea-sp", "UseLeaForSP", "true",
-                                     "Use LEA for adjusting the stack pointer (this is an optimization for Intel Atom processors)">;
+                                     "Use LEA for adjusting the stack pointer (this is an optimization for Intel Atom processors)",
+                                     [], InlineIgnore>;
 
 // True if 8-bit divisions are significantly faster than
 // 32-bit divisions and should be used when possible.
 def TuningSlowDivide32 : SubtargetFeature<"idivl-to-divb",
                                      "HasSlowDivide32", "true",
-                                     "Use 8-bit divide for positive values less than 256">;
+                                     "Use 8-bit divide for positive values less than 256",
+                                     [], InlineIgnore>;
 
 // True if 32-bit divides are significantly faster than
 // 64-bit divisions and should be used when possible.
 def TuningSlowDivide64 : SubtargetFeature<"idivq-to-divl",
                                      "HasSlowDivide64", "true",
-                                     "Use 32-bit divide for positive values less than 2^32">;
+                                     "Use 32-bit divide for positive values less than 2^32",
+                                     [], InlineIgnore>;
 
 def TuningPadShortFunctions : SubtargetFeature<"pad-short-functions",
                                      "PadShortFunctions", "true",
-                                     "Pad short functions (to prevent a stall when returning too early)">;
+                                     "Pad short functions (to prevent a stall when returning too early)",
+                                     [], InlineIgnore>;
 
 // On some processors, instructions that implicitly take two memory operands are
 // slow. In practice, this means that CALL, PUSH, and POP with memory operands
 // should be avoided in favor of a MOV + register CALL/PUSH/POP.
 def TuningSlowTwoMemOps : SubtargetFeature<"slow-two-mem-ops",
                                      "SlowTwoMemOps", "true",
-                                     "Two memory operand instructions are slow">;
+                                     "Two memory operand instructions are slow",
+                                     [], InlineIgnore>;
 
 // On some processors, indirect calls from memory (CALL [mem]) are slow
 // compared to loading the address first and using a register indirect call.
@@ -544,109 +563,131 @@ def TuningSlowTwoMemOps : SubtargetFeature<"slow-two-mem-ops",
 // affect PUSH from memory folding.
 def TuningSlowIndirectCall : SubtargetFeature<"slow-indirect-call",
                                      "SlowIndirectCall", "true",
-                                     "Indirect calls from memory are slow">;
+                                     "Indirect calls from memory are slow",
+                                     [], InlineIgnore>;
 
 // True if the LEA instruction inputs have to be ready at address generation
 // (AG) time.
 def TuningLEAUsesAG : SubtargetFeature<"lea-uses-ag", "LeaUsesAG", "true",
-                                   "LEA instruction needs inputs at AG stage">;
+                                   "LEA instruction needs inputs at AG stage",
+                                   [], InlineIgnore>;
 
 def TuningSlowLEA : SubtargetFeature<"slow-lea", "SlowLEA", "true",
-                                   "LEA instruction with certain arguments is slow">;
+                                   "LEA instruction with certain arguments is slow",
+                                   [], InlineIgnore>;
 
 // True if the LEA instruction has all three source operands: base, index,
 // and offset or if the LEA instruction uses base and index registers where
 // the base is EBP, RBP,or R13
 def TuningSlow3OpsLEA : SubtargetFeature<"slow-3ops-lea", "Slow3OpsLEA", "true",
-                                   "LEA instruction with 3 ops or certain registers is slow">;
+                                   "LEA instruction with 3 ops or certain registers is slow",
+                                   [], InlineIgnore>;
 
 // True if INC and DEC instructions are slow when writing to flags
 def TuningSlowIncDec : SubtargetFeature<"slow-incdec", "SlowIncDec", "true",
-                                   "INC and DEC instructions are slower than ADD and SUB">;
+                                   "INC and DEC instructions are slower than ADD and SUB",
+                                   [], InlineIgnore>;
 
 def TuningPOPCNTFalseDeps : SubtargetFeature<"false-deps-popcnt",
                                      "HasPOPCNTFalseDeps", "true",
-                                     "POPCNT has a false dependency on dest register">;
+                                     "POPCNT has a false dependency on dest register",
+                                     [], InlineIgnore>;
 
 def TuningLZCNTFalseDeps : SubtargetFeature<"false-deps-lzcnt-tzcnt",
                                      "HasLZCNTFalseDeps", "true",
-                                     "LZCNT/TZCNT have a false dependency on dest register">;
+                                     "LZCNT/TZCNT have a false dependency on dest register",
+                                     [], InlineIgnore>;
 
 def TuningMULCFalseDeps : SubtargetFeature<"false-deps-mulc",
                                "HasMULCFalseDeps", "true",
-                               "VF[C]MULCPH/SH has a false dependency on dest register">;
+                               "VF[C]MULCPH/SH has a false dependency on dest register",
+                               [], InlineIgnore>;
 
 def TuningPERMFalseDeps : SubtargetFeature<"false-deps-perm",
                                "HasPERMFalseDeps", "true",
-                               "VPERMD/Q/PS/PD has a false dependency on dest register">;
+                               "VPERMD/Q/PS/PD has a false dependency on dest register",
+                               [], InlineIgnore>;
 
 def TuningRANGEFalseDeps : SubtargetFeature<"false-deps-range",
                                "HasRANGEFalseDeps", "true",
-                               "VRANGEPD/PS/SD/SS has a false dependency on dest register">;
+                               "VRANGEPD/PS/SD/SS has a false dependency on dest register",
+                               [], InlineIgnore>;
 
 def TuningGETMANTFalseDeps : SubtargetFeature<"false-deps-getmant",
                                "HasGETMANTFalseDeps", "true",
                                "VGETMANTSS/SD/SH and VGETMANDPS/PD(memory version) has a"
-                               " false dependency on dest register">;
+                               " false dependency on dest register",
+                               [], InlineIgnore>;
 
 def TuningMULLQFalseDeps : SubtargetFeature<"false-deps-mullq",
                                "HasMULLQFalseDeps", "true",
-                               "VPMULLQ has a false dependency on dest register">;
+                               "VPMULLQ has a false dependency on dest register",
+                               [], InlineIgnore>;
 
 def TuningSBBDepBreaking : SubtargetFeature<"sbb-dep-breaking",
                                      "HasSBBDepBreaking", "true",
-                                     "SBB with same register has no source dependency">;
+                                     "SBB with same register has no source dependency",
+                                     [], InlineIgnore>;
 
 // On recent X86 (port bound) processors, its preferable to combine to a single shuffle
 // using a variable mask over multiple fixed shuffles.
 def TuningFastVariableCrossLaneShuffle
     : SubtargetFeature<"fast-variable-crosslane-shuffle",
                        "HasFastVariableCrossLaneShuffle",
-                       "true", "Cross-lane shuffles with variable masks are fast">;
+                       "true", "Cross-lane shuffles with variable masks are fast",
+                       [], InlineIgnore>;
 def TuningFastVariablePerLaneShuffle
     : SubtargetFeature<"fast-variable-perlane-shuffle",
                        "HasFastVariablePerLaneShuffle",
-                       "true", "Per-lane shuffles with variable masks are fast">;
+                       "true", "Per-lane shuffles with variable masks are fast",
+                       [], InlineIgnore>;
 
 // Goldmont / Tremont (atom in general) has no bypass delay
 def TuningNoDomainDelay : SubtargetFeature<"no-bypass-delay",
                                    "NoDomainDelay","true",
-                                   "Has no bypass delay when using the 'wrong' domain">;
+                                   "Has no bypass delay when using the 'wrong' domain",
+                                   [], InlineIgnore>;
 
 // Many processors (Nehalem+ on Intel) have no bypass delay when
 // using the wrong mov type.
 def TuningNoDomainDelayMov : SubtargetFeature<"no-bypass-delay-mov",
                                    "NoDomainDelayMov","true",
-                                   "Has no bypass delay when using the 'wrong' mov type">;
+                                   "Has no bypass delay when using the 'wrong' mov type",
+                                   [], InlineIgnore>;
 
 // Newer processors (Skylake+ on Intel) have no bypass delay when
 // using the wrong blend type.
 def TuningNoDomainDelayBlend : SubtargetFeature<"no-bypass-delay-blend",
                                    "NoDomainDelayBlend","true",
-                                   "Has no bypass delay when using the 'wrong' blend type">;
+                                   "Has no bypass delay when using the 'wrong' blend type",
+                                   [], InlineIgnore>;
 
 // Newer processors (Haswell+ on Intel) have no bypass delay when
 // using the wrong shuffle type.
 def TuningNoDomainDelayShuffle : SubtargetFeature<"no-bypass-delay-shuffle",
                                    "NoDomainDelayShuffle","true",
-                                   "Has no bypass delay when using the 'wrong' shuffle type">;
+                                   "Has no bypass delay when using the 'wrong' shuffle type",
+                                   [], InlineIgnore>;
 
 // Prefer lowering shuffles on AVX512 targets (e.g. Skylake Server) to
 // imm shifts/rotate if they can use more ports than regular shuffles.
 def TuningPreferShiftShuffle : SubtargetFeature<"faster-shift-than-shuffle",
                                    "PreferLowerShuffleAsShift", "true",
-                                   "Shifts are faster (or as fast) as shuffle">;
+                                   "Shifts are faster (or as fast) as shuffle",
+                                   [], InlineIgnore>;
 
 def TuningFastImmVectorShift : SubtargetFeature<"tuning-fast-imm-vector-shift",
                                    "FastImmVectorShift", "true",
-                                   "Vector shifts are fast (2/cycle) as opposed to slow (1/cycle)">;
+                                   "Vector shifts are fast (2/cycle) as opposed to slow (1/cycle)",
+                                   [], InlineIgnore>;
 
 // On some X86 processors, a vzeroupper instruction should be inserted after
 // using ymm/zmm registers before executing code that may use SSE instructions.
 def TuningInsertVZEROUPPER
     : SubtargetFeature<"vzeroupper",
                        "InsertVZEROUPPER",
-                       "true", "Should insert vzeroupper instructions">;
+                       "true", "Should insert vzeroupper instructions",
+                       [], InlineIgnore>;
 
 // TuningFastScalarFSQRT should be enabled if scalar FSQRT has shorter latency
 // than the corresponding NR code. TuningFastVectorFSQRT should be enabled if
@@ -660,37 +701,43 @@ def TuningInsertVZEROUPPER
 // RSQRTSS followed by a Newton-Raphson iteration.
 def TuningFastScalarFSQRT
     : SubtargetFeature<"fast-scalar-fsqrt", "HasFastScalarFSQRT",
-                       "true", "Scalar SQRT is fast (disable Newton-Raphson)">;
+                       "true", "Scalar SQRT is fast (disable Newton-Raphson)",
+                       [], InlineIgnore>;
 // True if hardware SQRTPS/VSQRTPS instructions are at least as fast
 // (throughput) as RSQRTPS/VRSQRTPS followed by a Newton-Raphson iteration.
 def TuningFastVectorFSQRT
     : SubtargetFeature<"fast-vector-fsqrt", "HasFastVectorFSQRT",
-                       "true", "Vector SQRT is fast (disable Newton-Raphson)">;
+                       "true", "Vector SQRT is fast (disable Newton-Raphson)",
+                       [], InlineIgnore>;
 
 // If lzcnt has equivalent latency/throughput to most simple integer ops, it can
 // be used to replace test/set sequences.
 def TuningFastLZCNT
     : SubtargetFeature<
           "fast-lzcnt", "HasFastLZCNT", "true",
-          "LZCNT instructions are as fast as most simple integer ops">;
+          "LZCNT instructions are as fast as most simple integer ops",
+          [], InlineIgnore>;
 
 // If the target can efficiently decode NOPs upto 7-bytes in length.
 def TuningFast7ByteNOP
     : SubtargetFeature<
           "fast-7bytenop", "HasFast7ByteNOP", "true",
-          "Target can quickly decode up to 7 byte NOPs">;
+          "Target can quickly decode up to 7 byte NOPs",
+          [], InlineIgnore>;
 
 // If the target can efficiently decode NOPs upto 11-bytes in length.
 def TuningFast11ByteNOP
     : SubtargetFeature<
           "fast-11bytenop", "HasFast11ByteNOP", "true",
-          "Target can quickly decode up to 11 byte NOPs">;
+          "Target can quickly decode up to 11 byte NOPs",
+          [], InlineIgnore>;
 
 // If the target can efficiently decode NOPs upto 15-bytes in length.
 def TuningFast15ByteNOP
     : SubtargetFeature<
           "fast-15bytenop", "HasFast15ByteNOP", "true",
-          "Target can quickly decode up to 15 byte NOPs">;
+          "Target can quickly decode up to 15 byte NOPs",
+          [], InlineIgnore>;
 
 // Sandy Bridge and newer processors can use SHLD with the same source on both
 // inputs to implement rotate to avoid the partial flag update of the normal
@@ -698,20 +745,23 @@ def TuningFast15ByteNOP
 def TuningFastSHLDRotate
     : SubtargetFeature<
           "fast-shld-rotate", "HasFastSHLDRotate", "true",
-          "SHLD can be used as a faster rotate">;
+          "SHLD can be used as a faster rotate",
+          [], InlineIgnore>;
 
 // Bulldozer and newer processors can merge CMP/TEST (but not other
 // instructions) with conditional branches.
 def TuningBranchFusion
     : SubtargetFeature<"branchfusion", "HasBranchFusion", "true",
-                 "CMP/TEST can be fused with conditional branches">;
+                 "CMP/TEST can be fused with conditional branches",
+                 [], InlineIgnore>;
 
 // Sandy Bridge and newer processors have many instructions that can be
 // fused with conditional branches and pass through the CPU as a single
 // operation.
 def TuningMacroFusion
     : SubtargetFeature<"macrofusion", "HasMacroFusion", "true",
-                 "Various instructions can be fused with conditional branches">;
+                 "Various instructions can be fused with conditional branches",
+                 [], InlineIgnore>;
 
 // Gather is available since Haswell (AVX2 set). So technically, we can
 // generate Gathers on all AVX2 processors. But the overhead on HSW is high.
@@ -719,40 +769,49 @@ def TuningMacroFusion
 // similar to Skylake Server (AVX-512).
 def TuningFastGather
     : SubtargetFeature<"fast-gather", "HasFastGather", "true",
-                       "Indicates if gather is reasonably fast (this is true for Skylake client and all AVX-512 CPUs)">;
+                       "Indicates if gather is reasonably fast (this is true for Skylake client and all AVX-512 CPUs)",
+                       [], InlineIgnore>;
 
 // Generate vpdpwssd instead of vpmaddwd+vpaddd sequence.
 def TuningFastDPWSSD
     : SubtargetFeature<
           "fast-dpwssd", "HasFastDPWSSD", "true",
-          "Prefer vpdpwssd instruction over vpmaddwd+vpaddd instruction sequence">;
+          "Prefer vpdpwssd instruction over vpmaddwd+vpaddd instruction sequence",
+          [], InlineIgnore>;
 
 def TuningPreferNoGather
     : SubtargetFeature<"prefer-no-gather", "PreferGather", "false",
-                       "Prefer no gather instructions">;
+                       "Prefer no gather instructions",
+                       [], InlineIgnore>;
 def TuningPreferNoScatter
     : SubtargetFeature<"prefer-no-scatter", "PreferScatter", "false",
-                       "Prefer no scatter instructions">;
+                       "Prefer no scatter instructions",
+                       [], InlineIgnore>;
 
 def TuningPrefer128Bit
     : SubtargetFeature<"prefer-128-bit", "Prefer128Bit", "true",
-                       "Prefer 128-bit AVX instructions">;
+                       "Prefer 128-bit AVX instructions",
+                       [], InlineIgnore>;
 
 def TuningPrefer256Bit
     : SubtargetFeature<"prefer-256-bit", "Prefer256Bit", "true",
-                       "Prefer 256-bit AVX instructions">;
+                       "Prefer 256-bit AVX instructions",
+                       [], InlineIgnore>;
 
 def TuningAllowLight256Bit
     : SubtargetFeature<"allow-light-256-bit", "AllowLight256Bit", "true",
-                       "Enable generation of 256-bit load/stores even if we prefer 128-bit">;
+                       "Enable generation of 256-bit load/stores even if we prefer 128-bit",
+                       [], InlineIgnore>;
 
 def TuningPreferMaskRegisters
     : SubtargetFeature<"prefer-mask-registers", "PreferMaskRegisters", "true",
-                       "Prefer AVX512 mask registers over PTEST/MOVMSK">;
+                       "Prefer AVX512 mask registers over PTEST/MOVMSK",
+                       [], InlineIgnore>;
 
 def TuningFastBEXTR : SubtargetFeature<"fast-bextr", "HasFastBEXTR", "true",
           "Indicates that the BEXTR instruction is implemented as a single uop "
-          "with good throughput">;
+          "with good throughput",
+          [], InlineIgnore>;
 
 // Combine vector math operations with shuffles into horizontal math
 // instructions if a CPU implements horizontal operations (introduced with
@@ -761,46 +820,53 @@ def TuningFastHorizontalOps
     : SubtargetFeature<
         "fast-hops", "HasFastHorizontalOps", "true",
         "Prefer horizontal vector math instructions (haddp, phsub, etc.) over "
-        "normal vector instructions with shuffles">;
+        "normal vector instructions with shuffles",
+        [], InlineIgnore>;
 
 def TuningFastScalarShiftMasks
     : SubtargetFeature<
         "fast-scalar-shift-masks", "HasFastScalarShiftMasks", "true",
-        "Prefer a left/right scalar logical shift pair over a shift+and pair">;
+        "Prefer a left/right scalar logical shift pair over a shift+and pair",
+        [], InlineIgnore>;
 
 def TuningFastVectorShiftMasks
     : SubtargetFeature<
         "fast-vector-shift-masks", "HasFastVectorShiftMasks", "true",
-        "Prefer a left/right vector logical shift pair over a shift+and pair">;
+        "Prefer a left/right vector logical shift pair over a shift+and pair",
+        [], InlineIgnore>;
 
 def TuningFastMOVBE
     : SubtargetFeature<"fast-movbe", "HasFastMOVBE", "true",
-    "Prefer a movbe over a single-use load + bswap / single-use bswap + store">;
+    "Prefer a movbe over a single-use load + bswap / single-use bswap + store",
+    [], InlineIgnore>;
 
 def TuningFastImm16
     : SubtargetFeature<"fast-imm16", "HasFastImm16", "true",
-    "Prefer a i16 instruction with i16 immediate over extension to i32">;
+    "Prefer a i16 instruction with i16 immediate over extension to i32",
+    [], InlineIgnore>;
 
 def TuningUseSLMArithCosts
     : SubtargetFeature<"use-slm-arith-costs", "UseSLMArithCosts", "true",
-        "Use Silvermont specific arithmetic costs">;
+        "Use Silvermont specific arithmetic costs", [], InlineIgnore>;
 
 def TuningUseGLMDivSqrtCosts
     : SubtargetFeature<"use-glm-div-sqrt-costs", "UseGLMDivSqrtCosts", "true",
-        "Use Goldmont specific floating point div/sqrt costs">;
+        "Use Goldmont specific floating point div/sqrt costs",
+        [], InlineIgnore>;
 
 def TuningNDDMem
     : SubtargetFeature<"prefer-ndd-mem", "HasNDDM",
-          "true", "Prefer NDD memory addressing">;
+          "true", "Prefer NDD memory addressing", [], InlineIgnore>;
 
 // Starting with Redwood Cove architecture, the branch has branch taken hint
 // (i.e., instruction prefix 3EH).
 def TuningBranchHint: SubtargetFeature<"branch-hint", "HasBranchHint", "true",
-                                        "Target has branch hint feature">;
+                                        "Target has branch hint feature",
+                                        [], InlineIgnore>;
 
 def TuningPreferLegacySetCC
     : SubtargetFeature<"prefer-legacy-setcc", "PreferLegacySetCC", "true",
-                       "Prefer to emit legacy SetCC.">;
+                       "Prefer to emit legacy SetCC.", [], InlineIgnore>;
 
 //===----------------------------------------------------------------------===//
 // X86 CPU Families
@@ -808,7 +874,7 @@ def TuningPreferLegacySetCC
 //===----------------------------------------------------------------------===//
 
 // Bonnell
-def ProcIntelAtom : SubtargetFeature<"", "IsAtom", "true", "Is Intel Atom processor">;
+def ProcIntelAtom : SubtargetFeature<"", "IsAtom", "true", "Is Intel Atom processor", [], InlineIgnore>;
 
 //===----------------------------------------------------------------------===//
 // Register File Description

diff  --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index fba2f08912fed..0dee9be6667c4 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -6727,8 +6727,10 @@ bool X86TTIImpl::areInlineCompatible(const Function *Caller,
 
   // Check whether callee features are a subset of caller features
   // (apart from the ignore list).
-  FeatureBitset RealCallerBits = CallerBits & ~InlineFeatureIgnoreList;
-  FeatureBitset RealCalleeBits = CalleeBits & ~InlineFeatureIgnoreList;
+  const FeatureBitset &InlineIgnoreFeatures =
+      CallerSubtarget.getInlineIgnoreFeatures();
+  FeatureBitset RealCallerBits = CallerBits & ~InlineIgnoreFeatures;
+  FeatureBitset RealCalleeBits = CalleeBits & ~InlineIgnoreFeatures;
   if ((RealCallerBits & RealCalleeBits) != RealCalleeBits)
     return false;
 

diff  --git a/llvm/lib/Target/X86/X86TargetTransformInfo.h b/llvm/lib/Target/X86/X86TargetTransformInfo.h
index 4120421622b21..556e997b01bd3 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.h
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.h
@@ -36,82 +36,6 @@ class X86TTIImpl final : public BasicTTIImplBase<X86TTIImpl> {
   const X86Subtarget *getST() const { return ST; }
   const X86TargetLowering *getTLI() const { return TLI; }
 
-  const FeatureBitset InlineFeatureIgnoreList = {
-      // clang-format off
-      // This indicates the CPU is 64 bit capable not that we are in 64-bit
-      // mode.
-      X86::FeatureX86_64,
-
-      // These features don't have any intrinsics or ABI effect.
-      X86::FeatureNOPL,
-      X86::FeatureCX16,
-      X86::FeatureLAHFSAHF64,
-
-      // Some older targets can be setup to fold unaligned loads.
-      X86::FeatureSSEUnalignedMem,
-
-      // Codegen control options.
-      X86::TuningFast11ByteNOP,
-      X86::TuningFast15ByteNOP,
-      X86::TuningFastBEXTR,
-      X86::TuningFastHorizontalOps,
-      X86::TuningFastLZCNT,
-      X86::TuningFastScalarFSQRT,
-      X86::TuningFastSHLDRotate,
-      X86::TuningFastScalarShiftMasks,
-      X86::TuningFastVectorShiftMasks,
-      X86::TuningFastVariableCrossLaneShuffle,
-      X86::TuningFastVariablePerLaneShuffle,
-      X86::TuningFastVectorFSQRT,
-      X86::TuningLEAForSP,
-      X86::TuningLEAUsesAG,
-      X86::TuningLZCNTFalseDeps,
-      X86::TuningBranchFusion,
-      X86::TuningMacroFusion,
-      X86::TuningPadShortFunctions,
-      X86::TuningPOPCNTFalseDeps,
-      X86::TuningMULCFalseDeps,
-      X86::TuningPERMFalseDeps,
-      X86::TuningRANGEFalseDeps,
-      X86::TuningGETMANTFalseDeps,
-      X86::TuningMULLQFalseDeps,
-      X86::TuningSlow3OpsLEA,
-      X86::TuningSlowDivide32,
-      X86::TuningSlowDivide64,
-      X86::TuningSlowIncDec,
-      X86::TuningSlowIndirectCall,
-      X86::TuningSlowLEA,
-      X86::TuningSlowPMADDWD,
-      X86::TuningSlowPMULLD,
-      X86::TuningSlowSHLD,
-      X86::TuningSlowTwoMemOps,
-      X86::TuningSlowUAMem16,
-      X86::TuningPreferMaskRegisters,
-      X86::TuningInsertVZEROUPPER,
-      X86::TuningUseSLMArithCosts,
-      X86::TuningUseGLMDivSqrtCosts,
-      X86::TuningNoDomainDelay,
-      X86::TuningNoDomainDelayMov,
-      X86::TuningNoDomainDelayShuffle,
-      X86::TuningNoDomainDelayBlend,
-      X86::TuningPreferShiftShuffle,
-      X86::TuningFastImmVectorShift,
-      X86::TuningFastDPWSSD,
-
-      // Perf-tuning flags.
-      X86::TuningFastGather,
-      X86::TuningSlowUAMem32,
-      X86::TuningAllowLight256Bit,
-
-      // Based on whether user set the -mprefer-vector-width command line.
-      X86::TuningPrefer128Bit,
-      X86::TuningPrefer256Bit,
-
-      // CPU name enums. These just follow CPU string.
-      X86::ProcIntelAtom
-      // clang-format on
-  };
-
 public:
   explicit X86TTIImpl(const X86TargetMachine *TM, const Function &F)
       : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),

diff  --git a/llvm/test/TableGen/aarch64-apple-tuning-features.td b/llvm/test/TableGen/aarch64-apple-tuning-features.td
index 94501fd6043fe..fb0bd1e1c204f 100644
--- a/llvm/test/TableGen/aarch64-apple-tuning-features.td
+++ b/llvm/test/TableGen/aarch64-apple-tuning-features.td
@@ -25,6 +25,7 @@
 // CHECK-NEXT:    FeatureZCZeroingFPR128,
 // CHECK-NEXT:    FeatureZCZeroingGPR32,
 // CHECK-NEXT:    FeatureZCZeroingGPR64];
+// CHECK-NEXT:    InlineBehavior InlineBehavior = InlineDefault;
 // CHECK-NEXT: }
 // CHECK-LABEL: def TuneAppleA11 {      // SubtargetFeature
 // CHECK-NEXT:    string Name = "apple-a11";
@@ -45,6 +46,7 @@
 // CHECK-NEXT:    FeatureZCZeroingFPR128,
 // CHECK-NEXT:    FeatureZCZeroingGPR32,
 // CHECK-NEXT:    FeatureZCZeroingGPR64];
+// CHECK-NEXT:    InlineBehavior InlineBehavior = InlineDefault;
 // CHECK-NEXT: }
 // CHECK-LABEL: def TuneAppleA12 {      // SubtargetFeature
 // CHECK-NEXT:    string Name = "apple-a12";
@@ -65,6 +67,7 @@
 // CHECK-NEXT:    FeatureZCZeroingFPR128,
 // CHECK-NEXT:    FeatureZCZeroingGPR32,
 // CHECK-NEXT:    FeatureZCZeroingGPR64];
+// CHECK-NEXT:    InlineBehavior InlineBehavior = InlineDefault;
 // CHECK-NEXT: }
 // CHECK-LABEL: def TuneAppleA13 {      // SubtargetFeature
 // CHECK-NEXT:    string Name = "apple-a13";
@@ -85,6 +88,7 @@
 // CHECK-NEXT:    FeatureZCZeroingFPR128,
 // CHECK-NEXT:    FeatureZCZeroingGPR32,
 // CHECK-NEXT:    FeatureZCZeroingGPR64];
+// CHECK-NEXT:    InlineBehavior InlineBehavior = InlineDefault;
 // CHECK-NEXT: }
 // CHECK-LABEL: def TuneAppleA14 {      // SubtargetFeature
 // CHECK-NEXT:    string Name = "apple-a14";
@@ -113,6 +117,7 @@
 // CHECK-NEXT:    FeatureZCZeroingFPR128,
 // CHECK-NEXT:    FeatureZCZeroingGPR32,
 // CHECK-NEXT:    FeatureZCZeroingGPR64];
+// CHECK-NEXT:    InlineBehavior InlineBehavior = InlineDefault;
 // CHECK-NEXT: }
 // CHECK-LABEL: def TuneAppleA15 {      // SubtargetFeature
 // CHECK-NEXT:    string Name = "apple-a15";
@@ -141,6 +146,7 @@
 // CHECK-NEXT:    FeatureZCZeroingFPR128,
 // CHECK-NEXT:    FeatureZCZeroingGPR32,
 // CHECK-NEXT:    FeatureZCZeroingGPR64];
+// CHECK-NEXT:    InlineBehavior InlineBehavior = InlineDefault;
 // CHECK-NEXT: }
 // CHECK-LABEL: def TuneAppleA16 {      // SubtargetFeature
 // CHECK-NEXT:    string Name = "apple-a16";
@@ -170,6 +176,7 @@
 // CHECK-NEXT:    FeatureZCZeroingFPR128,
 // CHECK-NEXT:    FeatureZCZeroingGPR32,
 // CHECK-NEXT:    FeatureZCZeroingGPR64];
+// CHECK-NEXT:    InlineBehavior InlineBehavior = InlineDefault;
 // CHECK-NEXT: }
 // CHECK-LABEL: def TuneAppleA17 {      // SubtargetFeature
 // CHECK-NEXT:    string Name = "apple-a17";
@@ -199,6 +206,7 @@
 // CHECK-NEXT:    FeatureZCZeroingFPR128,
 // CHECK-NEXT:    FeatureZCZeroingGPR32,
 // CHECK-NEXT:    FeatureZCZeroingGPR64];
+// CHECK-NEXT:    InlineBehavior InlineBehavior = InlineDefault;
 // CHECK-NEXT: }
 // CHECK-LABEL: def TuneAppleA7 {       // SubtargetFeature
 // CHECK-NEXT:    string Name = "apple-a7";
@@ -220,6 +228,7 @@
 // CHECK-NEXT:    FeatureZCZeroingFPR128,
 // CHECK-NEXT:    FeatureZCZeroingGPR32,
 // CHECK-NEXT:    FeatureZCZeroingGPR64];
+// CHECK-NEXT:    InlineBehavior InlineBehavior = InlineDefault;
 // CHECK-NEXT: }
 // CHECK-LABEL: def TuneAppleM4 {       // SubtargetFeature
 // CHECK-NEXT:    string Name = "apple-m4";
@@ -248,6 +257,7 @@
 // CHECK-NEXT:    FeatureZCZeroingFPR128,
 // CHECK-NEXT:    FeatureZCZeroingGPR32,
 // CHECK-NEXT:    FeatureZCZeroingGPR64];
+// CHECK-NEXT:    InlineBehavior InlineBehavior = InlineDefault;
 // CHECK-NEXT: }
 // CHECK-LABEL: def TuneAppleM5 {       // SubtargetFeature
 // CHECK-NEXT:    string Name = "apple-m5";
@@ -276,4 +286,5 @@
 // CHECK-NEXT:    FeatureZCZeroingFPR128,
 // CHECK-NEXT:    FeatureZCZeroingGPR32,
 // CHECK-NEXT:    FeatureZCZeroingGPR64];
+// CHECK-NEXT:    InlineBehavior InlineBehavior = InlineDefault;
 // CHECK-NEXT: }

diff  --git a/llvm/unittests/CodeGen/MFCommon.inc b/llvm/unittests/CodeGen/MFCommon.inc
index 6c47461629070..a3a8b3652ad47 100644
--- a/llvm/unittests/CodeGen/MFCommon.inc
+++ b/llvm/unittests/CodeGen/MFCommon.inc
@@ -101,6 +101,16 @@ public:
 
   const TargetRegisterInfo *getRegisterInfo() const override { return &TRI; }
 
+  const FeatureBitset &getInlineIgnoreFeatures() const override {
+    static constexpr FeatureBitset Features;
+    return Features;
+  }
+
+  const FeatureBitset &getInlineInverseFeatures() const override {
+    static constexpr FeatureBitset Features;
+    return Features;
+  }
+
 private:
   BogusFrameLowering FL;
   BogusRegisterInfo TRI;

diff  --git a/llvm/utils/TableGen/SubtargetEmitter.cpp b/llvm/utils/TableGen/SubtargetEmitter.cpp
index c3a9d69d6ec3e..a915ce0daec2d 100644
--- a/llvm/utils/TableGen/SubtargetEmitter.cpp
+++ b/llvm/utils/TableGen/SubtargetEmitter.cpp
@@ -136,6 +136,8 @@ class SubtargetEmitter : TargetFeaturesEmitter {
   void emitGetMacroFusions(const std::string &ClassName, raw_ostream &OS);
   void emitHwModeCheck(const std::string &ClassName, raw_ostream &OS,
                        bool IsMC);
+  void emitInlineFeatures(const std::string &ClassName, raw_ostream &OS,
+                          StringRef Behavior);
   void parseFeaturesFunction(raw_ostream &OS);
 
 public:
@@ -1990,6 +1992,25 @@ void SubtargetEmitter::parseFeaturesFunction(raw_ostream &OS) {
   OS << "}\n";
 }
 
+void SubtargetEmitter::emitInlineFeatures(const std::string &ClassName,
+                                          raw_ostream &OS, StringRef Behavior) {
+  std::vector<const Record *> FeatureList =
+      Records.getAllDerivedDefinitions("SubtargetFeature");
+  llvm::sort(FeatureList, LessRecordFieldFieldName());
+
+  OS << "const FeatureBitset &" << ClassName << "::get" << Behavior
+     << "Features() const {\n"
+     << "  static constexpr FeatureBitset Features = {\n";
+
+  for (const Record *Feature : FeatureList)
+    if (Behavior == Feature->getValueAsDef("InlineBehavior")->getName())
+      OS << Target << "::" << Feature->getName() << ",\n";
+
+  OS << "  };\n"
+     << "  return Features;\n"
+     << "}\n\n";
+}
+
 void SubtargetEmitter::emitGenMCSubtargetInfo(raw_ostream &OS) {
   {
     NamespaceEmitter NS(OS, (Target + Twine("_MC")).str());
@@ -2177,6 +2198,9 @@ void SubtargetEmitter::emitHeader(raw_ostream &OS) {
     OS << "  std::vector<MacroFusionPredTy> getMacroFusions() const "
           "final;\n";
 
+  OS << "  const FeatureBitset &getInlineIgnoreFeatures() const override;\n";
+  OS << "  const FeatureBitset &getInlineInverseFeatures() const override;\n";
+
   STIPredicateExpander PE(Target);
   PE.setByRef(false);
   for (const STIPredicateFunction &Fn : SchedModels.getSTIPredicates())
@@ -2244,6 +2268,8 @@ void SubtargetEmitter::emitCtor(raw_ostream &OS, unsigned NumNames,
   emitSchedModelHelpers(ClassName, OS);
   emitHwModeCheck(ClassName, OS, /*IsMC=*/false);
   emitGetMacroFusions(ClassName, OS);
+  emitInlineFeatures(ClassName, OS, "InlineIgnore");
+  emitInlineFeatures(ClassName, OS, "InlineInverse");
 }
 
 //


        


More information about the llvm-commits mailing list