TargetSchedule.td 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. //===- TargetSchedule.td - Target Independent Scheduling ---*- tablegen -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file defines the target-independent scheduling interfaces which should
  10. // be implemented by each target which is using TableGen based scheduling.
  11. //
  12. // The SchedMachineModel is defined by subtargets for three categories of data:
  13. // 1. Basic properties for coarse grained instruction cost model.
  14. // 2. Scheduler Read/Write resources for simple per-opcode cost model.
  15. // 3. Instruction itineraries for detailed reservation tables.
  16. //
  17. // (1) Basic properties are defined by the SchedMachineModel
  18. // class. Target hooks allow subtargets to associate opcodes with
  19. // those properties.
  20. //
  21. // (2) A per-operand machine model can be implemented in any
  22. // combination of the following ways:
  23. //
  24. // A. Associate per-operand SchedReadWrite types with Instructions by
  25. // modifying the Instruction definition to inherit from Sched. For
  26. // each subtarget, define WriteRes and ReadAdvance to associate
  27. // processor resources and latency with each SchedReadWrite type.
  28. //
  29. // B. In each instruction definition, name an ItineraryClass. For each
  30. // subtarget, define ItinRW entries to map ItineraryClass to
  31. // per-operand SchedReadWrite types. Unlike method A, these types may
  32. // be subtarget specific and can be directly associated with resources
  33. // by defining SchedWriteRes and SchedReadAdvance.
  34. //
  35. // C. In the subtarget, map SchedReadWrite types to specific
  36. // opcodes. This overrides any SchedReadWrite types or
  37. // ItineraryClasses defined by the Instruction. As in method B, the
  38. // subtarget can directly associate resources with SchedReadWrite
  39. // types by defining SchedWriteRes and SchedReadAdvance.
  40. //
  41. // D. In either the target or subtarget, define SchedWriteVariant or
  42. // SchedReadVariant to map one SchedReadWrite type onto another
  43. // sequence of SchedReadWrite types. This allows dynamic selection of
  44. // an instruction's machine model via custom C++ code. It also allows
  45. // a machine-independent SchedReadWrite type to map to a sequence of
  46. // machine-dependent types.
  47. //
  48. // (3) A per-pipeline-stage machine model can be implemented by providing
  49. // Itineraries in addition to mapping instructions to ItineraryClasses.
  50. //===----------------------------------------------------------------------===//
  51. // Include legacy support for instruction itineraries.
  52. include "llvm/Target/TargetItinerary.td"
  53. class Instruction; // Forward def
  54. class Predicate; // Forward def
  55. // DAG operator that interprets the DAG args as Instruction defs.
  56. def instrs;
  57. // DAG operator that interprets each DAG arg as a regex pattern for
  58. // matching Instruction opcode names.
  59. // The regex must match the beginning of the opcode (as in Python re.match).
  60. // To avoid matching prefixes, append '$' to the pattern.
  61. def instregex;
  62. // Define the SchedMachineModel and provide basic properties for
  63. // coarse grained instruction cost model. Default values for the
  64. // properties are defined in MCSchedModel. A value of "-1" in the
  65. // target description's SchedMachineModel indicates that the property
  66. // is not overriden by the target.
  67. //
  68. // Target hooks allow subtargets to associate LoadLatency and
  69. // HighLatency with groups of opcodes.
  70. //
  71. // See MCSchedule.h for detailed comments.
  72. class SchedMachineModel {
  73. int IssueWidth = -1; // Max micro-ops that may be scheduled per cycle.
  74. int MicroOpBufferSize = -1; // Max micro-ops that can be buffered.
  75. int LoopMicroOpBufferSize = -1; // Max micro-ops that can be buffered for
  76. // optimized loop dispatch/execution.
  77. int LoadLatency = -1; // Cycles for loads to access the cache.
  78. int HighLatency = -1; // Approximation of cycles for "high latency" ops.
  79. int MispredictPenalty = -1; // Extra cycles for a mispredicted branch.
  80. // Per-cycle resources tables.
  81. ProcessorItineraries Itineraries = NoItineraries;
  82. bit PostRAScheduler = false; // Enable Post RegAlloc Scheduler pass.
  83. // Subtargets that define a model for only a subset of instructions
  84. // that have a scheduling class (itinerary class or SchedRW list)
  85. // and may actually be generated for that subtarget must clear this
  86. // bit. Otherwise, the scheduler considers an unmodelled opcode to
  87. // be an error. This should only be set during initial bringup,
  88. // or there will be no way to catch simple errors in the model
  89. // resulting from changes to the instruction definitions.
  90. bit CompleteModel = true;
  91. // Indicates that we should do full overlap checking for multiple InstrRWs
  92. // defining the same instructions within the same SchedMachineModel.
  93. // FIXME: Remove when all in tree targets are clean with the full check
  94. // enabled.
  95. bit FullInstRWOverlapCheck = true;
  96. // A processor may only implement part of published ISA, due to either new ISA
  97. // extensions, (e.g. Pentium 4 doesn't have AVX) or implementation
  98. // (ARM/MIPS/PowerPC/SPARC soft float cores).
  99. //
  100. // For a processor which doesn't support some feature(s), the schedule model
  101. // can use:
  102. //
  103. // let<Predicate> UnsupportedFeatures = [HaveA,..,HaveY];
  104. //
  105. // to skip the checks for scheduling information when building LLVM for
  106. // instructions which have any of the listed predicates in their Predicates
  107. // field.
  108. list<Predicate> UnsupportedFeatures = [];
  109. bit NoModel = false; // Special tag to indicate missing machine model.
  110. }
  111. def NoSchedModel : SchedMachineModel {
  112. let NoModel = true;
  113. let CompleteModel = false;
  114. }
  115. // Define a kind of processor resource that may be common across
  116. // similar subtargets.
  117. class ProcResourceKind;
  118. // Define a number of interchangeable processor resources. NumUnits
  119. // determines the throughput of instructions that require the resource.
  120. //
  121. // An optional Super resource may be given to model these resources as
  122. // a subset of the more general super resources. Using one of these
  123. // resources implies using one of the super resources.
  124. //
  125. // ProcResourceUnits normally model a few buffered resources within an
  126. // out-of-order engine. Buffered resources may be held for multiple
  127. // clock cycles, but the scheduler does not pin them to a particular
  128. // clock cycle relative to instruction dispatch. Setting BufferSize=0
  129. // changes this to an in-order issue/dispatch resource. In this case,
  130. // the scheduler counts down from the cycle that the instruction
  131. // issues in-order, forcing a stall whenever a subsequent instruction
  132. // requires the same resource until the number of ResourceCycles
  133. // specified in WriteRes expire. Setting BufferSize=1 changes this to
  134. // an in-order latency resource. In this case, the scheduler models
  135. // producer/consumer stalls between instructions that use the
  136. // resource.
  137. //
  138. // Examples (all assume an out-of-order engine):
  139. //
  140. // Use BufferSize = -1 for "issue ports" fed by a unified reservation
  141. // station. Here the size of the reservation station is modeled by
  142. // MicroOpBufferSize, which should be the minimum size of either the
  143. // register rename pool, unified reservation station, or reorder
  144. // buffer.
  145. //
  146. // Use BufferSize = 0 for resources that force "dispatch/issue
  147. // groups". (Different processors define dispath/issue
  148. // differently. Here we refer to stage between decoding into micro-ops
  149. // and moving them into a reservation station.) Normally NumMicroOps
  150. // is sufficient to limit dispatch/issue groups. However, some
  151. // processors can form groups of with only certain combinations of
  152. // instruction types. e.g. POWER7.
  153. //
  154. // Use BufferSize = 1 for in-order execution units. This is used for
  155. // an in-order pipeline within an out-of-order core where scheduling
  156. // dependent operations back-to-back is guaranteed to cause a
  157. // bubble. e.g. Cortex-a9 floating-point.
  158. //
  159. // Use BufferSize > 1 for out-of-order executions units with a
  160. // separate reservation station. This simply models the size of the
  161. // reservation station.
  162. //
  163. // To model both dispatch/issue groups and in-order execution units,
  164. // create two types of units, one with BufferSize=0 and one with
  165. // BufferSize=1.
  166. //
  167. // SchedModel ties these units to a processor for any stand-alone defs
  168. // of this class.
  169. class ProcResourceUnits<ProcResourceKind kind, int num> {
  170. ProcResourceKind Kind = kind;
  171. int NumUnits = num;
  172. ProcResourceKind Super = ?;
  173. int BufferSize = -1;
  174. SchedMachineModel SchedModel = ?;
  175. }
  176. // EponymousProcResourceKind helps implement ProcResourceUnits by
  177. // allowing a ProcResourceUnits definition to reference itself. It
  178. // should not be referenced anywhere else.
  179. def EponymousProcResourceKind : ProcResourceKind;
  180. // Subtargets typically define processor resource kind and number of
  181. // units in one place.
  182. class ProcResource<int num> : ProcResourceKind,
  183. ProcResourceUnits<EponymousProcResourceKind, num>;
  184. class ProcResGroup<list<ProcResource> resources> : ProcResourceKind {
  185. list<ProcResource> Resources = resources;
  186. SchedMachineModel SchedModel = ?;
  187. int BufferSize = -1;
  188. }
  189. // A target architecture may define SchedReadWrite types and associate
  190. // them with instruction operands.
  191. class SchedReadWrite;
  192. // List the per-operand types that map to the machine model of an
  193. // instruction. One SchedWrite type must be listed for each explicit
  194. // def operand in order. Additional SchedWrite types may optionally be
  195. // listed for implicit def operands. SchedRead types may optionally
  196. // be listed for use operands in order. The order of defs relative to
  197. // uses is insignificant. This way, the same SchedReadWrite list may
  198. // be used for multiple forms of an operation. For example, a
  199. // two-address instruction could have two tied operands or single
  200. // operand that both reads and writes a reg. In both cases we have a
  201. // single SchedWrite and single SchedRead in any order.
  202. class Sched<list<SchedReadWrite> schedrw> {
  203. list<SchedReadWrite> SchedRW = schedrw;
  204. }
  205. // Define a scheduler resource associated with a def operand.
  206. class SchedWrite : SchedReadWrite;
  207. def NoWrite : SchedWrite;
  208. // Define a scheduler resource associated with a use operand.
  209. class SchedRead : SchedReadWrite;
  210. // Define a SchedWrite that is modeled as a sequence of other
  211. // SchedWrites with additive latency. This allows a single operand to
  212. // be mapped the resources composed from a set of previously defined
  213. // SchedWrites.
  214. //
  215. // If the final write in this sequence is a SchedWriteVariant marked
  216. // Variadic, then the list of prior writes are distributed across all
  217. // operands after resolving the predicate for the final write.
  218. //
  219. // SchedModel silences warnings but is ignored.
  220. class WriteSequence<list<SchedWrite> writes, int rep = 1> : SchedWrite {
  221. list<SchedWrite> Writes = writes;
  222. int Repeat = rep;
  223. SchedMachineModel SchedModel = ?;
  224. }
  225. // Define values common to WriteRes and SchedWriteRes.
  226. //
  227. // SchedModel ties these resources to a processor.
  228. class ProcWriteResources<list<ProcResourceKind> resources> {
  229. list<ProcResourceKind> ProcResources = resources;
  230. list<int> ResourceCycles = [];
  231. int Latency = 1;
  232. int NumMicroOps = 1;
  233. bit BeginGroup = false;
  234. bit EndGroup = false;
  235. // Allow a processor to mark some scheduling classes as unsupported
  236. // for stronger verification.
  237. bit Unsupported = false;
  238. // Allow a processor to mark some scheduling classes as single-issue.
  239. // SingleIssue is an alias for Begin/End Group.
  240. bit SingleIssue = false;
  241. SchedMachineModel SchedModel = ?;
  242. }
  243. // Define the resources and latency of a SchedWrite. This will be used
  244. // directly by targets that have no itinerary classes. In this case,
  245. // SchedWrite is defined by the target, while WriteResources is
  246. // defined by the subtarget, and maps the SchedWrite to processor
  247. // resources.
  248. //
  249. // If a target already has itinerary classes, SchedWriteResources can
  250. // be used instead to define subtarget specific SchedWrites and map
  251. // them to processor resources in one place. Then ItinRW can map
  252. // itinerary classes to the subtarget's SchedWrites.
  253. //
  254. // ProcResources indicates the set of resources consumed by the write.
  255. // Optionally, ResourceCycles indicates the number of cycles the
  256. // resource is consumed. Each ResourceCycles item is paired with the
  257. // ProcResource item at the same position in its list. ResourceCycles
  258. // can be `[]`: in that case, all resources are consumed for a single
  259. // cycle, regardless of latency, which models a fully pipelined processing
  260. // unit. A value of 0 for ResourceCycles means that the resource must
  261. // be available but is not consumed, which is only relevant for
  262. // unbuffered resources.
  263. //
  264. // By default, each SchedWrite takes one micro-op, which is counted
  265. // against the processor's IssueWidth limit. If an instruction can
  266. // write multiple registers with a single micro-op, the subtarget
  267. // should define one of the writes to be zero micro-ops. If a
  268. // subtarget requires multiple micro-ops to write a single result, it
  269. // should either override the write's NumMicroOps to be greater than 1
  270. // or require additional writes. Extra writes can be required either
  271. // by defining a WriteSequence, or simply listing extra writes in the
  272. // instruction's list of writers beyond the number of "def"
  273. // operands. The scheduler assumes that all micro-ops must be
  274. // dispatched in the same cycle. These micro-ops may be required to
  275. // begin or end the current dispatch group.
  276. class WriteRes<SchedWrite write, list<ProcResourceKind> resources>
  277. : ProcWriteResources<resources> {
  278. SchedWrite WriteType = write;
  279. }
  280. // Directly name a set of WriteResources defining a new SchedWrite
  281. // type at the same time. This class is unaware of its SchedModel so
  282. // must be referenced by InstRW or ItinRW.
  283. class SchedWriteRes<list<ProcResourceKind> resources> : SchedWrite,
  284. ProcWriteResources<resources>;
  285. // Define values common to ReadAdvance and SchedReadAdvance.
  286. //
  287. // SchedModel ties these resources to a processor.
  288. class ProcReadAdvance<int cycles, list<SchedWrite> writes = []> {
  289. int Cycles = cycles;
  290. list<SchedWrite> ValidWrites = writes;
  291. // Allow a processor to mark some scheduling classes as unsupported
  292. // for stronger verification.
  293. bit Unsupported = false;
  294. SchedMachineModel SchedModel = ?;
  295. }
  296. // A processor may define a ReadAdvance associated with a SchedRead
  297. // to reduce latency of a prior write by N cycles. A negative advance
  298. // effectively increases latency, which may be used for cross-domain
  299. // stalls.
  300. //
  301. // A ReadAdvance may be associated with a list of SchedWrites
  302. // to implement pipeline bypass. The Writes list may be empty to
  303. // indicate operands that are always read this number of Cycles later
  304. // than a normal register read, allowing the read's parent instruction
  305. // to issue earlier relative to the writer.
  306. class ReadAdvance<SchedRead read, int cycles, list<SchedWrite> writes = []>
  307. : ProcReadAdvance<cycles, writes> {
  308. SchedRead ReadType = read;
  309. }
  310. // Directly associate a new SchedRead type with a delay and optional
  311. // pipeline bypass. For use with InstRW or ItinRW.
  312. class SchedReadAdvance<int cycles, list<SchedWrite> writes = []> : SchedRead,
  313. ProcReadAdvance<cycles, writes>;
  314. // Define SchedRead defaults. Reads seldom need special treatment.
  315. def ReadDefault : SchedRead;
  316. def NoReadAdvance : SchedReadAdvance<0>;
  317. // Define shared code that will be in the same scope as all
  318. // SchedPredicates. Available variables are:
  319. // (const MachineInstr *MI, const TargetSchedModel *SchedModel)
  320. class PredicateProlog<code c> {
  321. code Code = c;
  322. }
  323. // Base class for scheduling predicates.
  324. class SchedPredicateBase;
  325. // A scheduling predicate whose logic is defined by a MCInstPredicate.
  326. // This can directly be used by SchedWriteVariant definitions.
  327. class MCSchedPredicate<MCInstPredicate P> : SchedPredicateBase {
  328. MCInstPredicate Pred = P;
  329. SchedMachineModel SchedModel = ?;
  330. }
  331. // Define a predicate to determine which SchedVariant applies to a
  332. // particular MachineInstr. The code snippet is used as an
  333. // if-statement's expression. Available variables are MI, SchedModel,
  334. // and anything defined in a PredicateProlog.
  335. //
  336. // SchedModel silences warnings but is ignored.
  337. class SchedPredicate<code pred> : SchedPredicateBase {
  338. SchedMachineModel SchedModel = ?;
  339. code Predicate = pred;
  340. }
  341. // Define a predicate to be typically used as the default case in a
  342. // SchedVariant. It the SchedVariant does not use any other predicate based on
  343. // MCSchedPredicate, this is the default scheduling case used by llvm-mca.
  344. def NoSchedPred : MCSchedPredicate<TruePred>;
  345. // Associate a predicate with a list of SchedReadWrites. By default,
  346. // the selected SchedReadWrites are still associated with a single
  347. // operand and assumed to execute sequentially with additive
  348. // latency. However, if the parent SchedWriteVariant or
  349. // SchedReadVariant is marked "Variadic", then each Selected
  350. // SchedReadWrite is mapped in place to the instruction's variadic
  351. // operands. In this case, latency is not additive. If the current Variant
  352. // is already part of a Sequence, then that entire chain leading up to
  353. // the Variant is distributed over the variadic operands.
  354. class SchedVar<SchedPredicateBase pred, list<SchedReadWrite> selected> {
  355. SchedPredicateBase Predicate = pred;
  356. list<SchedReadWrite> Selected = selected;
  357. }
  358. // SchedModel silences warnings but is ignored.
  359. class SchedVariant<list<SchedVar> variants> {
  360. list<SchedVar> Variants = variants;
  361. bit Variadic = false;
  362. SchedMachineModel SchedModel = ?;
  363. }
  364. // A SchedWriteVariant is a single SchedWrite type that maps to a list
  365. // of SchedWrite types under the conditions defined by its predicates.
  366. //
  367. // A Variadic write is expanded to cover multiple "def" operands. The
  368. // SchedVariant's Expansion list is then interpreted as one write
  369. // per-operand instead of the usual sequential writes feeding a single
  370. // operand.
  371. class SchedWriteVariant<list<SchedVar> variants> : SchedWrite,
  372. SchedVariant<variants> {
  373. }
  374. // A SchedReadVariant is a single SchedRead type that maps to a list
  375. // of SchedRead types under the conditions defined by its predicates.
  376. //
  377. // A Variadic write is expanded to cover multiple "readsReg" operands as
  378. // explained above.
  379. class SchedReadVariant<list<SchedVar> variants> : SchedRead,
  380. SchedVariant<variants> {
  381. }
  382. // Map a set of opcodes to a list of SchedReadWrite types. This allows
  383. // the subtarget to easily override specific operations.
  384. //
  385. // SchedModel ties this opcode mapping to a processor.
  386. class InstRW<list<SchedReadWrite> rw, dag instrlist> {
  387. list<SchedReadWrite> OperandReadWrites = rw;
  388. dag Instrs = instrlist;
  389. SchedMachineModel SchedModel = ?;
  390. // Allow a subtarget to mark some instructions as unsupported.
  391. bit Unsupported = false;
  392. }
  393. // Map a set of itinerary classes to SchedReadWrite resources. This is
  394. // used to bootstrap a target (e.g. ARM) when itineraries already
  395. // exist and changing InstrInfo is undesirable.
  396. //
  397. // SchedModel ties this ItineraryClass mapping to a processor.
  398. class ItinRW<list<SchedReadWrite> rw, list<InstrItinClass> iic> {
  399. list<InstrItinClass> MatchedItinClasses = iic;
  400. list<SchedReadWrite> OperandReadWrites = rw;
  401. SchedMachineModel SchedModel = ?;
  402. }
  403. // Alias a target-defined SchedReadWrite to a processor specific
  404. // SchedReadWrite. This allows a subtarget to easily map a
  405. // SchedReadWrite type onto a WriteSequence, SchedWriteVariant, or
  406. // SchedReadVariant.
  407. //
  408. // SchedModel will usually be provided by surrounding let statement
  409. // and ties this SchedAlias mapping to a processor.
  410. class SchedAlias<SchedReadWrite match, SchedReadWrite alias> {
  411. SchedReadWrite MatchRW = match;
  412. SchedReadWrite AliasRW = alias;
  413. SchedMachineModel SchedModel = ?;
  414. }
  415. // Allow the definition of processor register files for register renaming
  416. // purposes.
  417. //
  418. // Each processor register file declares:
  419. // - The set of registers that can be renamed.
  420. // - The number of physical registers which can be used for register renaming
  421. // purpose.
  422. // - The cost of a register rename.
  423. // - The set of registers that allow move elimination.
  424. // - The maximum number of moves that can be eliminated every cycle.
  425. // - Whether move elimination is limited to register moves whose input
  426. // is known to be zero.
  427. //
  428. // The cost of a rename is the number of physical registers allocated by the
  429. // register alias table to map the new definition. By default, register can be
  430. // renamed at the cost of a single physical register. Note that register costs
  431. // are defined at register class granularity (see field `Costs`).
  432. //
  433. // The set of registers that are subject to register renaming is declared using
  434. // a list of register classes (see field `RegClasses`). An empty list of
  435. // register classes means: all the logical registers defined by the target can
  436. // be fully renamed.
  437. //
  438. // A register R can be renamed if its register class appears in the `RegClasses`
  439. // set. When R is written, a new alias is allocated at the cost of one or more
  440. // physical registers; as a result, false dependencies on R are removed.
  441. //
  442. // A sub-register V of register R is implicitly part of the same register file.
  443. // However, V is only renamed if its register class is part of `RegClasses`.
  444. // Otherwise, the processor keeps it (as well as any other different part
  445. // of R) together with R, and a write of V always causes a compulsory read of R.
  446. //
  447. // This is what happens for example on AMD processors (at least from Bulldozer
  448. // onwards), where AL and AH are not treated as independent from AX, and AX is
  449. // not treated as independent from EAX. A write to AL has an implicity false
  450. // dependency on the last write to EAX (or a portion of EAX). As a consequence,
  451. // a write to AL cannot go in parallel with a write to AH.
  452. //
  453. // There is no false dependency if the partial register write belongs to a
  454. // register class that is in `RegClasses`.
  455. // There is also no penalty for writes that "clear the content a super-register"
  456. // (see MC/MCInstrAnalysis.h - method MCInstrAnalysis::clearsSuperRegisters()).
  457. // On x86-64, 32-bit GPR writes implicitly zero the upper half of the underlying
  458. // physical register, effectively removing any false dependencies with the
  459. // previous register definition.
  460. //
  461. // TODO: This implementation assumes that there is no limit in the number of
  462. // renames per cycle, which might not be true for all hardware or register
  463. // classes. Also, there is no limit to how many times the same logical register
  464. // can be renamed during the same cycle.
  465. //
  466. // TODO: we don't currently model merge penalties for the case where a write to
  467. // a part of a register is followed by a read from a larger part of the same
  468. // register. On some Intel chips, different parts of a GPR can be stored in
  469. // different physical registers. However, there is a cost to pay for when the
  470. // partial write is combined with the previous super-register definition. We
  471. // should add support for these cases, and correctly model merge problems with
  472. // partial register accesses.
  473. //
  474. // Field MaxMovesEliminatedPerCycle specifies how many moves can be eliminated
  475. // every cycle. A default value of zero for that field means: there is no limit
  476. // to the number of moves that can be eliminated by this register file.
  477. //
  478. // An instruction MI is a candidate for move elimination if a call to
  479. // method TargetSubtargetInfo::isOptimizableRegisterMove(MI) returns true (see
  480. // llvm/CodeGen/TargetSubtargetInfo.h, and llvm/MC/MCInstrAnalysis.h).
  481. //
  482. // Subtargets can instantiate tablegen class IsOptimizableRegisterMove (see
  483. // llvm/Target/TargetInstrPredicate.td) to customize the set of move elimination
  484. // candidates. By default, no instruction is a valid move elimination candidate.
  485. //
  486. // A register move MI is eliminated only if:
  487. // - MI is a move elimination candidate.
  488. // - The destination register is from a register class that allows move
  489. // elimination (see field `AllowMoveElimination` below).
  490. // - Constraints on the move kind, and the maximum number of moves that can be
  491. // eliminated per cycle are all met.
  492. class RegisterFile<int numPhysRegs, list<RegisterClass> Classes = [],
  493. list<int> Costs = [], list<bit> AllowMoveElim = [],
  494. int MaxMoveElimPerCy = 0, bit AllowZeroMoveElimOnly = false> {
  495. list<RegisterClass> RegClasses = Classes;
  496. list<int> RegCosts = Costs;
  497. list<bit> AllowMoveElimination = AllowMoveElim;
  498. int NumPhysRegs = numPhysRegs;
  499. int MaxMovesEliminatedPerCycle = MaxMoveElimPerCy;
  500. bit AllowZeroMoveEliminationOnly = AllowZeroMoveElimOnly;
  501. SchedMachineModel SchedModel = ?;
  502. }
  503. // Describe the retire control unit.
  504. // A retire control unit specifies the size of the reorder buffer, as well as
  505. // the maximum number of opcodes that can be retired every cycle.
  506. // A value less-than-or-equal-to zero for field 'ReorderBufferSize' means: "the
  507. // size is unknown". The idea is that external tools can fall-back to using
  508. // field MicroOpBufferSize in SchedModel if the reorder buffer size is unknown.
  509. // A zero or negative value for field 'MaxRetirePerCycle' means "no
  510. // restrictions on the number of instructions retired per cycle".
  511. // Models can optionally specify up to one instance of RetireControlUnit per
  512. // scheduling model.
  513. class RetireControlUnit<int bufferSize, int retirePerCycle> {
  514. int ReorderBufferSize = bufferSize;
  515. int MaxRetirePerCycle = retirePerCycle;
  516. SchedMachineModel SchedModel = ?;
  517. }
  518. // Base class for Load/StoreQueue. It is used to identify processor resources
  519. // which describe load/store queues in the LS unit.
  520. class MemoryQueue<ProcResourceKind PR> {
  521. ProcResourceKind QueueDescriptor = PR;
  522. SchedMachineModel SchedModel = ?;
  523. }
  524. class LoadQueue<ProcResourceKind LDQueue> : MemoryQueue<LDQueue>;
  525. class StoreQueue<ProcResourceKind STQueue> : MemoryQueue<STQueue>;