TargetItinerary.td 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //===- TargetItinerary.td - Target Itinerary Description --*- 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
  10. // which should be implemented by each target that uses instruction
  11. // itineraries for scheduling. Itineraries are detailed reservation
  12. // tables for each instruction class. They are most appropriate for
  13. // in-order machine with complicated scheduling or bundling constraints.
  14. //
  15. //===----------------------------------------------------------------------===//
  16. //===----------------------------------------------------------------------===//
  17. // Processor functional unit - These values represent the function units
  18. // available across all chip sets for the target. Eg., IntUnit, FPUnit, ...
  19. // These may be independent values for each chip set or may be shared across
  20. // all chip sets of the target. Each functional unit is treated as a resource
  21. // during scheduling and has an affect instruction order based on availability
  22. // during a time interval.
  23. //
  24. class FuncUnit;
  25. //===----------------------------------------------------------------------===//
  26. // Pipeline bypass / forwarding - These values specifies the symbolic names of
  27. // pipeline bypasses which can be used to forward results of instructions
  28. // that are forwarded to uses.
  29. class Bypass;
  30. def NoBypass : Bypass;
  31. class ReservationKind<bits<1> val> {
  32. int Value = val;
  33. }
  34. def Required : ReservationKind<0>;
  35. def Reserved : ReservationKind<1>;
  36. //===----------------------------------------------------------------------===//
  37. // Instruction stage - These values represent a non-pipelined step in
  38. // the execution of an instruction. Cycles represents the number of
  39. // discrete time slots needed to complete the stage. Units represent
  40. // the choice of functional units that can be used to complete the
  41. // stage. Eg. IntUnit1, IntUnit2. TimeInc indicates how many cycles
  42. // should elapse from the start of this stage to the start of the next
  43. // stage in the itinerary. For example:
  44. //
  45. // A stage is specified in one of two ways:
  46. //
  47. // InstrStage<1, [FU_x, FU_y]> - TimeInc defaults to Cycles
  48. // InstrStage<1, [FU_x, FU_y], 0> - TimeInc explicit
  49. //
  50. class InstrStage<int cycles, list<FuncUnit> units,
  51. int timeinc = -1,
  52. ReservationKind kind = Required> {
  53. int Cycles = cycles; // length of stage in machine cycles
  54. list<FuncUnit> Units = units; // choice of functional units
  55. int TimeInc = timeinc; // cycles till start of next stage
  56. int Kind = kind.Value; // kind of FU reservation
  57. }
  58. //===----------------------------------------------------------------------===//
  59. // Instruction itinerary - An itinerary represents a sequential series of steps
  60. // required to complete an instruction. Itineraries are represented as lists of
  61. // instruction stages.
  62. //
  63. //===----------------------------------------------------------------------===//
  64. // Instruction itinerary classes - These values represent 'named' instruction
  65. // itinerary. Using named itineraries simplifies managing groups of
  66. // instructions across chip sets. An instruction uses the same itinerary class
  67. // across all chip sets. Thus a new chip set can be added without modifying
  68. // instruction information.
  69. //
  70. class InstrItinClass;
  71. def NoItinerary : InstrItinClass;
  72. //===----------------------------------------------------------------------===//
  73. // Instruction itinerary data - These values provide a runtime map of an
  74. // instruction itinerary class (name) to its itinerary data.
  75. //
  76. // NumMicroOps represents the number of micro-operations that each instruction
  77. // in the class are decoded to. If the number is zero, then it means the
  78. // instruction can decode into variable number of micro-ops and it must be
  79. // determined dynamically. This directly relates to the itineraries
  80. // global IssueWidth property, which constrains the number of microops
  81. // that can issue per cycle.
  82. //
  83. // OperandCycles are optional "cycle counts". They specify the cycle after
  84. // instruction issue the values which correspond to specific operand indices
  85. // are defined or read. Bypasses are optional "pipeline forwarding paths", if
  86. // a def by an instruction is available on a specific bypass and the use can
  87. // read from the same bypass, then the operand use latency is reduced by one.
  88. //
  89. // InstrItinData<IIC_iLoad_i , [InstrStage<1, [A9_Pipe1]>,
  90. // InstrStage<1, [A9_AGU]>],
  91. // [3, 1], [A9_LdBypass]>,
  92. // InstrItinData<IIC_iMVNr , [InstrStage<1, [A9_Pipe0, A9_Pipe1]>],
  93. // [1, 1], [NoBypass, A9_LdBypass]>,
  94. //
  95. // In this example, the instruction of IIC_iLoadi reads its input on cycle 1
  96. // (after issue) and the result of the load is available on cycle 3. The result
  97. // is available via forwarding path A9_LdBypass. If it's used by the first
  98. // source operand of instructions of IIC_iMVNr class, then the operand latency
  99. // is reduced by 1.
  100. class InstrItinData<InstrItinClass Class, list<InstrStage> stages,
  101. list<int> operandcycles = [],
  102. list<Bypass> bypasses = [], int uops = 1> {
  103. InstrItinClass TheClass = Class;
  104. int NumMicroOps = uops;
  105. list<InstrStage> Stages = stages;
  106. list<int> OperandCycles = operandcycles;
  107. list<Bypass> Bypasses = bypasses;
  108. }
  109. //===----------------------------------------------------------------------===//
  110. // Processor itineraries - These values represent the set of all itinerary
  111. // classes for a given chip set.
  112. //
  113. // Set property values to -1 to use the default.
  114. // See InstrItineraryProps for comments and defaults.
  115. class ProcessorItineraries<list<FuncUnit> fu, list<Bypass> bp,
  116. list<InstrItinData> iid> {
  117. list<FuncUnit> FU = fu;
  118. list<Bypass> BP = bp;
  119. list<InstrItinData> IID = iid;
  120. // The packetizer automaton to use for this itinerary. By default all
  121. // itineraries for a target are bundled up into the same automaton. This only
  122. // works correctly when there are no conflicts in functional unit IDs between
  123. // itineraries. For example, given two itineraries A<[SLOT_A]>, B<[SLOT_B]>,
  124. // SLOT_A and SLOT_B will be assigned the same functional unit index, and
  125. // the generated packetizer will confuse instructions referencing these slots.
  126. //
  127. // To avoid this, setting PacketizerNamespace to non-"" will cause this
  128. // itinerary to be generated in a different automaton. The subtarget will need
  129. // to declare a method "create##Namespace##DFAPacketizer()".
  130. string PacketizerNamespace = "";
  131. }
  132. // NoItineraries - A marker that can be used by processors without schedule
  133. // info. Subtargets using NoItineraries can bypass the scheduler's
  134. // expensive HazardRecognizer because no reservation table is needed.
  135. def NoItineraries : ProcessorItineraries<[], [], []>;
  136. //===----------------------------------------------------------------------===//
  137. // Combo Function Unit data - This is a map of combo function unit names to
  138. // the list of functional units that are included in the combination.
  139. //
  140. class ComboFuncData<FuncUnit ComboFunc, list<FuncUnit> funclist> {
  141. FuncUnit TheComboFunc = ComboFunc;
  142. list<FuncUnit> FuncList = funclist;
  143. }
  144. //===----------------------------------------------------------------------===//
  145. // Combo Function Units - This is a list of all combo function unit data.
  146. class ComboFuncUnits<list<ComboFuncData> cfd> {
  147. list<ComboFuncData> CFD = cfd;
  148. }