|
68 | 68 |
|
69 | 69 | // Forward declarations.
|
70 | 70 | class Instruction;
|
| 71 | +class SchedMachineModel; |
71 | 72 |
|
72 | 73 | // A generic machine instruction predicate.
|
73 | 74 | class MCInstPredicate;
|
@@ -230,3 +231,100 @@ class CheckFunctionPredicate<string MCInstFn, string MachineInstrFn> : MCInstPre
|
230 | 231 | string MCInstFnName = MCInstFn;
|
231 | 232 | string MachineInstrFnName = MachineInstrFn;
|
232 | 233 | }
|
| 234 | + |
| 235 | +// Used to classify machine instructions based on a machine instruction |
| 236 | +// predicate. |
| 237 | +// |
| 238 | +// Let IC be an InstructionEquivalenceClass definition, and MI a machine |
| 239 | +// instruction. We say that MI belongs to the equivalence class described by IC |
| 240 | +// if and only if the following two conditions are met: |
| 241 | +// a) MI's opcode is in the `opcodes` set, and |
| 242 | +// b) `Predicate` evaluates to true when applied to MI. |
| 243 | +// |
| 244 | +// Instances of this class can be used by processor scheduling models to |
| 245 | +// describe instructions that have a property in common. For example, |
| 246 | +// InstructionEquivalenceClass definitions can be used to identify the set of |
| 247 | +// dependency breaking instructions for a processor model. |
| 248 | +// |
| 249 | +// An (optional) list of operand indices can be used to further describe |
| 250 | +// properties that apply to instruction operands. For example, it can be used to |
| 251 | +// identify register uses of a dependency breaking instructions that are not in |
| 252 | +// a RAW dependency. |
| 253 | +class InstructionEquivalenceClass<list<Instruction> opcodes, |
| 254 | + MCInstPredicate pred, |
| 255 | + list<int> operands = []> { |
| 256 | + list<Instruction> Opcodes = opcodes; |
| 257 | + MCInstPredicate Predicate = pred; |
| 258 | + list<int> OperandIndices = operands; |
| 259 | +} |
| 260 | + |
| 261 | +// Used by processor models to describe dependency breaking instructions. |
| 262 | +// |
| 263 | +// This is mainly an alias for InstructionEquivalenceClass. Input operand |
| 264 | +// `BrokenDeps` identifies the set of "broken dependencies". There is one bit |
| 265 | +// per each implicit and explicit input operand. An empty set of broken |
| 266 | +// dependencies means: "explicit input register operands are independent." |
| 267 | +class DepBreakingClass<list<Instruction> opcodes, MCInstPredicate pred, |
| 268 | + list<int> BrokenDeps = []> |
| 269 | + : InstructionEquivalenceClass<opcodes, pred, BrokenDeps>; |
| 270 | + |
| 271 | +// A function descriptor used to describe the signature of a predicate methods |
| 272 | +// which will be expanded by the STIPredicateExpander into a tablegen'd |
| 273 | +// XXXGenSubtargetInfo class member definition (here, XXX is a target name). |
| 274 | +// |
| 275 | +// It describes the signature of a TargetSubtarget hook, as well as a few extra |
| 276 | +// properties. Examples of extra properties are: |
| 277 | +// - The default return value for the auto-generate function hook. |
| 278 | +// - A list of subtarget hooks (Delegates) that are called from this function. |
| 279 | +// |
| 280 | +class STIPredicateDecl<string name, MCInstPredicate default = FalsePred, |
| 281 | + bit overrides = 1, bit expandForMC = 1, |
| 282 | + bit updatesOpcodeMask = 0, |
| 283 | + list<STIPredicateDecl> delegates = []> { |
| 284 | + string Name = name; |
| 285 | + |
| 286 | + MCInstPredicate DefaultReturnValue = default; |
| 287 | + |
| 288 | + // True if this method is declared as virtual in class TargetSubtargetInfo. |
| 289 | + bit OverridesBaseClassMember = overrides; |
| 290 | + |
| 291 | + // True if we need an equivalent predicate function in the MC layer. |
| 292 | + bit ExpandForMC = expandForMC; |
| 293 | + |
| 294 | + // True if the autogenerated method has a extra in/out APInt param used as a |
| 295 | + // mask of operands. |
| 296 | + bit UpdatesOpcodeMask = updatesOpcodeMask; |
| 297 | + |
| 298 | + // A list of STIPredicates used by this definition to delegate part of the |
| 299 | + // computation. For example, STIPredicateFunction `isDependencyBreaking()` |
| 300 | + // delegates to `isZeroIdiom()` part of its computation. |
| 301 | + list<STIPredicateDecl> Delegates = delegates; |
| 302 | +} |
| 303 | + |
| 304 | +// A predicate function definition member of class `XXXGenSubtargetInfo`. |
| 305 | +// |
| 306 | +// If `Declaration.ExpandForMC` is true, then SubtargetEmitter |
| 307 | +// will also expand another definition of this method that accepts a MCInst. |
| 308 | +class STIPredicate<STIPredicateDecl declaration, |
| 309 | + list<InstructionEquivalenceClass> classes> { |
| 310 | + STIPredicateDecl Declaration = declaration; |
| 311 | + list<InstructionEquivalenceClass> Classes = classes; |
| 312 | + SchedMachineModel SchedModel = ?; |
| 313 | +} |
| 314 | + |
| 315 | +// Convenience classes and definitions used by processor scheduling models to |
| 316 | +// describe dependency breaking instructions. |
| 317 | +let UpdatesOpcodeMask = 1 in { |
| 318 | + |
| 319 | +def IsZeroIdiomDecl : STIPredicateDecl<"isZeroIdiom">; |
| 320 | + |
| 321 | +let Delegates = [IsZeroIdiomDecl] in |
| 322 | +def IsDepBreakingDecl : STIPredicateDecl<"isDependencyBreaking">; |
| 323 | + |
| 324 | +} // UpdatesOpcodeMask |
| 325 | + |
| 326 | +class IsZeroIdiomFunction<list<DepBreakingClass> classes> |
| 327 | + : STIPredicate<IsZeroIdiomDecl, classes>; |
| 328 | + |
| 329 | +class IsDepBreakingFunction<list<DepBreakingClass> classes> |
| 330 | + : STIPredicate<IsDepBreakingDecl, classes>; |
0 commit comments