X86PfmCounters.td 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. //===-- X86PfmCounters.td - X86 Hardware Counters ----------*- 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 describes the available hardware counters for various subtargets.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. def UnhaltedCoreCyclesPfmCounter : PfmCounter<"unhalted_core_cycles">;
  13. def UopsIssuedPfmCounter : PfmCounter<"uops_issued:any">;
  14. // No default counters on X86.
  15. def DefaultPfmCounters : ProcPfmCounters {}
  16. def : PfmCountersDefaultBinding<DefaultPfmCounters>;
  17. // Intel X86 Counters.
  18. def PentiumPfmCounters : ProcPfmCounters {
  19. let CycleCounter = PfmCounter<"cpu_clk_unhalted">;
  20. let UopsCounter = PfmCounter<"uops_retired">;
  21. }
  22. def : PfmCountersBinding<"pentiumpro", PentiumPfmCounters>;
  23. def : PfmCountersBinding<"pentium2", PentiumPfmCounters>;
  24. def : PfmCountersBinding<"pentium3", PentiumPfmCounters>;
  25. def : PfmCountersBinding<"pentium3m", PentiumPfmCounters>;
  26. def : PfmCountersBinding<"pentium-m", PentiumPfmCounters>;
  27. def CorePfmCounters : ProcPfmCounters {
  28. let CycleCounter = UnhaltedCoreCyclesPfmCounter;
  29. let UopsCounter = PfmCounter<"uops_retired:any">;
  30. }
  31. def : PfmCountersBinding<"yonah", CorePfmCounters>;
  32. def : PfmCountersBinding<"prescott", CorePfmCounters>;
  33. def : PfmCountersBinding<"core2", CorePfmCounters>;
  34. def : PfmCountersBinding<"penryn", CorePfmCounters>;
  35. def : PfmCountersBinding<"nehalem", CorePfmCounters>;
  36. def : PfmCountersBinding<"corei7", CorePfmCounters>;
  37. def : PfmCountersBinding<"westmere", CorePfmCounters>;
  38. def AtomPfmCounters : ProcPfmCounters {
  39. let CycleCounter = UnhaltedCoreCyclesPfmCounter;
  40. let UopsCounter = PfmCounter<"uops_retired:any">;
  41. }
  42. def : PfmCountersBinding<"bonnell", AtomPfmCounters>;
  43. def : PfmCountersBinding<"atom", AtomPfmCounters>;
  44. def SLMPfmCounters : ProcPfmCounters {
  45. let CycleCounter = UnhaltedCoreCyclesPfmCounter;
  46. let UopsCounter = PfmCounter<"uops_retired:any">;
  47. }
  48. def : PfmCountersBinding<"silvermont", SLMPfmCounters>;
  49. def : PfmCountersBinding<"goldmont", SLMPfmCounters>;
  50. def : PfmCountersBinding<"goldmont-plus", SLMPfmCounters>;
  51. def : PfmCountersBinding<"tremont", SLMPfmCounters>;
  52. def KnightPfmCounters : ProcPfmCounters {
  53. let CycleCounter = UnhaltedCoreCyclesPfmCounter;
  54. let UopsCounter = PfmCounter<"uops_retired:all">;
  55. }
  56. def : PfmCountersBinding<"knl", KnightPfmCounters>;
  57. def : PfmCountersBinding<"knm", KnightPfmCounters>;
  58. def SandyBridgePfmCounters : ProcPfmCounters {
  59. let CycleCounter = UnhaltedCoreCyclesPfmCounter;
  60. let UopsCounter = UopsIssuedPfmCounter;
  61. let IssueCounters = [
  62. PfmIssueCounter<"SBPort0", "uops_dispatched_port:port_0">,
  63. PfmIssueCounter<"SBPort1", "uops_dispatched_port:port_1">,
  64. PfmIssueCounter<"SBPort23", "uops_dispatched_port:port_2 + uops_dispatched_port:port_3">,
  65. PfmIssueCounter<"SBPort4", "uops_dispatched_port:port_4">,
  66. PfmIssueCounter<"SBPort5", "uops_dispatched_port:port_5">
  67. ];
  68. }
  69. def : PfmCountersBinding<"sandybridge", SandyBridgePfmCounters>;
  70. def : PfmCountersBinding<"ivybridge", SandyBridgePfmCounters>;
  71. def HaswellPfmCounters : ProcPfmCounters {
  72. let CycleCounter = UnhaltedCoreCyclesPfmCounter;
  73. let UopsCounter = UopsIssuedPfmCounter;
  74. let IssueCounters = [
  75. PfmIssueCounter<"HWPort0", "uops_executed_port:port_0">,
  76. PfmIssueCounter<"HWPort1", "uops_executed_port:port_1">,
  77. PfmIssueCounter<"HWPort2", "uops_executed_port:port_2">,
  78. PfmIssueCounter<"HWPort3", "uops_executed_port:port_3">,
  79. PfmIssueCounter<"HWPort4", "uops_executed_port:port_4">,
  80. PfmIssueCounter<"HWPort5", "uops_executed_port:port_5">,
  81. PfmIssueCounter<"HWPort6", "uops_executed_port:port_6">,
  82. PfmIssueCounter<"HWPort7", "uops_executed_port:port_7">
  83. ];
  84. }
  85. def : PfmCountersBinding<"haswell", HaswellPfmCounters>;
  86. def BroadwellPfmCounters : ProcPfmCounters {
  87. let CycleCounter = UnhaltedCoreCyclesPfmCounter;
  88. let UopsCounter = UopsIssuedPfmCounter;
  89. let IssueCounters = [
  90. PfmIssueCounter<"BWPort0", "uops_executed_port:port_0">,
  91. PfmIssueCounter<"BWPort1", "uops_executed_port:port_1">,
  92. PfmIssueCounter<"BWPort2", "uops_executed_port:port_2">,
  93. PfmIssueCounter<"BWPort3", "uops_executed_port:port_3">,
  94. PfmIssueCounter<"BWPort4", "uops_executed_port:port_4">,
  95. PfmIssueCounter<"BWPort5", "uops_executed_port:port_5">,
  96. PfmIssueCounter<"BWPort6", "uops_executed_port:port_6">,
  97. PfmIssueCounter<"BWPort7", "uops_executed_port:port_7">
  98. ];
  99. }
  100. def : PfmCountersBinding<"broadwell", BroadwellPfmCounters>;
  101. def SkylakeClientPfmCounters : ProcPfmCounters {
  102. let CycleCounter = UnhaltedCoreCyclesPfmCounter;
  103. let UopsCounter = UopsIssuedPfmCounter;
  104. let IssueCounters = [
  105. PfmIssueCounter<"SKLPort0", "uops_dispatched_port:port_0">,
  106. PfmIssueCounter<"SKLPort1", "uops_dispatched_port:port_1">,
  107. PfmIssueCounter<"SKLPort2", "uops_dispatched_port:port_2">,
  108. PfmIssueCounter<"SKLPort3", "uops_dispatched_port:port_3">,
  109. PfmIssueCounter<"SKLPort4", "uops_dispatched_port:port_4">,
  110. PfmIssueCounter<"SKLPort5", "uops_dispatched_port:port_5">,
  111. PfmIssueCounter<"SKLPort6", "uops_dispatched_port:port_6">,
  112. PfmIssueCounter<"SKLPort7", "uops_dispatched_port:port_7">
  113. ];
  114. }
  115. def : PfmCountersBinding<"skylake", SkylakeClientPfmCounters>;
  116. def SkylakeServerPfmCounters : ProcPfmCounters {
  117. let CycleCounter = UnhaltedCoreCyclesPfmCounter;
  118. let UopsCounter = UopsIssuedPfmCounter;
  119. let IssueCounters = [
  120. PfmIssueCounter<"SKXPort0", "uops_dispatched_port:port_0">,
  121. PfmIssueCounter<"SKXPort1", "uops_dispatched_port:port_1">,
  122. PfmIssueCounter<"SKXPort2", "uops_dispatched_port:port_2">,
  123. PfmIssueCounter<"SKXPort3", "uops_dispatched_port:port_3">,
  124. PfmIssueCounter<"SKXPort4", "uops_dispatched_port:port_4">,
  125. PfmIssueCounter<"SKXPort5", "uops_dispatched_port:port_5">,
  126. PfmIssueCounter<"SKXPort6", "uops_dispatched_port:port_6">,
  127. PfmIssueCounter<"SKXPort7", "uops_dispatched_port:port_7">
  128. ];
  129. }
  130. def : PfmCountersBinding<"skylake-avx512", SkylakeServerPfmCounters>;
  131. def : PfmCountersBinding<"cascadelake", SkylakeServerPfmCounters>;
  132. def : PfmCountersBinding<"cannonlake", SkylakeServerPfmCounters>;
  133. def IceLakePfmCounters : ProcPfmCounters {
  134. let CycleCounter = UnhaltedCoreCyclesPfmCounter;
  135. let UopsCounter = UopsIssuedPfmCounter;
  136. let IssueCounters = [
  137. PfmIssueCounter<"ICXPort0", "uops_dispatched_port:port_0">,
  138. PfmIssueCounter<"ICXPort1", "uops_dispatched_port:port_1">,
  139. PfmIssueCounter<"ICXPort23", "uops_dispatched_port:port_2_3">,
  140. PfmIssueCounter<"ICXPort49", "uops_dispatched_port:port_4_9">,
  141. PfmIssueCounter<"ICXPort5", "uops_dispatched_port:port_5">,
  142. PfmIssueCounter<"ICXPort6", "uops_dispatched_port:port_6">,
  143. PfmIssueCounter<"ICXPort78", "uops_dispatched_port:port_7_8">
  144. ];
  145. }
  146. def : PfmCountersBinding<"icelake-client", IceLakePfmCounters>;
  147. def : PfmCountersBinding<"icelake-server", IceLakePfmCounters>;
  148. def : PfmCountersBinding<"rocketlake", IceLakePfmCounters>;
  149. def : PfmCountersBinding<"tigerlake", IceLakePfmCounters>;
  150. // AMD X86 Counters.
  151. // Set basic counters for AMD cpus that we know libpfm4 supports.
  152. def DefaultAMDPfmCounters : ProcPfmCounters {
  153. let CycleCounter = PfmCounter<"cpu_clk_unhalted">;
  154. let UopsCounter = PfmCounter<"retired_uops">;
  155. }
  156. def : PfmCountersBinding<"athlon", DefaultAMDPfmCounters>;
  157. def : PfmCountersBinding<"athlon-tbird", DefaultAMDPfmCounters>;
  158. def : PfmCountersBinding<"athlon-4", DefaultAMDPfmCounters>;
  159. def : PfmCountersBinding<"athlon-xp", DefaultAMDPfmCounters>;
  160. def : PfmCountersBinding<"athlon-mp", DefaultAMDPfmCounters>;
  161. def : PfmCountersBinding<"k8", DefaultAMDPfmCounters>;
  162. def : PfmCountersBinding<"opteron", DefaultAMDPfmCounters>;
  163. def : PfmCountersBinding<"athlon64", DefaultAMDPfmCounters>;
  164. def : PfmCountersBinding<"athlon-fx", DefaultAMDPfmCounters>;
  165. def : PfmCountersBinding<"k8-sse3", DefaultAMDPfmCounters>;
  166. def : PfmCountersBinding<"opteron-sse3", DefaultAMDPfmCounters>;
  167. def : PfmCountersBinding<"athlon64-sse3", DefaultAMDPfmCounters>;
  168. def : PfmCountersBinding<"amdfam10", DefaultAMDPfmCounters>;
  169. def : PfmCountersBinding<"barcelona", DefaultAMDPfmCounters>;
  170. def BdVer2PfmCounters : ProcPfmCounters {
  171. let CycleCounter = PfmCounter<"cpu_clk_unhalted">;
  172. let UopsCounter = PfmCounter<"retired_uops">;
  173. let IssueCounters = [
  174. PfmIssueCounter<"PdFPU0", "dispatched_fpu_ops:ops_pipe0 + dispatched_fpu_ops:ops_dual_pipe0">,
  175. PfmIssueCounter<"PdFPU1", "dispatched_fpu_ops:ops_pipe1 + dispatched_fpu_ops:ops_dual_pipe1">,
  176. PfmIssueCounter<"PdFPU2", "dispatched_fpu_ops:ops_pipe2 + dispatched_fpu_ops:ops_dual_pipe2">,
  177. PfmIssueCounter<"PdFPU3", "dispatched_fpu_ops:ops_pipe3 + dispatched_fpu_ops:ops_dual_pipe3">
  178. ];
  179. }
  180. def : PfmCountersBinding<"bdver1", BdVer2PfmCounters>;
  181. def : PfmCountersBinding<"bdver2", BdVer2PfmCounters>;
  182. def BdVer3PfmCounters : ProcPfmCounters {
  183. let CycleCounter = PfmCounter<"cpu_clk_unhalted">;
  184. let UopsCounter = PfmCounter<"retired_uops">;
  185. let IssueCounters = [
  186. PfmIssueCounter<"SrFPU0", "dispatched_fpu_ops:ops_pipe0 + dispatched_fpu_ops:ops_dual_pipe0">,
  187. PfmIssueCounter<"SrFPU1", "dispatched_fpu_ops:ops_pipe1 + dispatched_fpu_ops:ops_dual_pipe1">,
  188. PfmIssueCounter<"SrFPU2", "dispatched_fpu_ops:ops_pipe2 + dispatched_fpu_ops:ops_dual_pipe2">
  189. ];
  190. }
  191. def : PfmCountersBinding<"bdver3", BdVer3PfmCounters>;
  192. def : PfmCountersBinding<"bdver4", BdVer3PfmCounters>;
  193. def BtVer1PfmCounters : ProcPfmCounters {
  194. let CycleCounter = PfmCounter<"cpu_clk_unhalted">;
  195. let UopsCounter = PfmCounter<"retired_uops">;
  196. let IssueCounters = [
  197. PfmIssueCounter<"BtFPU0", "dispatched_fpu:pipe0">,
  198. PfmIssueCounter<"BtFPU1", "dispatched_fpu:pipe1">
  199. ];
  200. }
  201. def : PfmCountersBinding<"btver1", BtVer1PfmCounters>;
  202. def BtVer2PfmCounters : ProcPfmCounters {
  203. let CycleCounter = PfmCounter<"cpu_clk_unhalted">;
  204. let UopsCounter = PfmCounter<"retired_uops">;
  205. let IssueCounters = [
  206. PfmIssueCounter<"JFPU0", "dispatched_fpu:pipe0">,
  207. PfmIssueCounter<"JFPU1", "dispatched_fpu:pipe1">
  208. ];
  209. }
  210. def : PfmCountersBinding<"btver2", BtVer2PfmCounters>;
  211. def ZnVer1PfmCounters : ProcPfmCounters {
  212. let CycleCounter = PfmCounter<"cycles_not_in_halt">;
  213. let UopsCounter = PfmCounter<"retired_uops">;
  214. let IssueCounters = [
  215. PfmIssueCounter<"ZnFPU0", "fpu_pipe_assignment:total0">,
  216. PfmIssueCounter<"ZnFPU1", "fpu_pipe_assignment:total1">,
  217. PfmIssueCounter<"ZnFPU2", "fpu_pipe_assignment:total2">,
  218. PfmIssueCounter<"ZnFPU3", "fpu_pipe_assignment:total3">,
  219. PfmIssueCounter<"ZnDivider", "div_op_count">
  220. ];
  221. }
  222. def : PfmCountersBinding<"znver1", ZnVer1PfmCounters>;
  223. def ZnVer2PfmCounters : ProcPfmCounters {
  224. let CycleCounter = PfmCounter<"cycles_not_in_halt">;
  225. let UopsCounter = PfmCounter<"retired_uops">;
  226. let IssueCounters = [
  227. PfmIssueCounter<"Zn2AGU", "ls_dispatch:ld_dispatch + ls_dispatch:store_dispatch">,
  228. PfmIssueCounter<"Zn2Divider", "div_op_count">
  229. ];
  230. }
  231. def : PfmCountersBinding<"znver2", ZnVer2PfmCounters>;
  232. def ZnVer3PfmCounters : ProcPfmCounters {
  233. let CycleCounter = PfmCounter<"cycles_not_in_halt">;
  234. let UopsCounter = PfmCounter<"retired_ops">;
  235. let IssueCounters = [
  236. PfmIssueCounter<"Zn3Int", "ops_type_dispatched_from_decoder:int_disp_retire_mode">,
  237. PfmIssueCounter<"Zn3FPU", "ops_type_dispatched_from_decoder:fp_disp_retire_mode">,
  238. PfmIssueCounter<"Zn3Load", "ls_dispatch:ld_dispatch">,
  239. PfmIssueCounter<"Zn3Store", "ls_dispatch:store_dispatch">,
  240. PfmIssueCounter<"Zn3Divider", "div_op_count">
  241. ];
  242. }
  243. def : PfmCountersBinding<"znver3", ZnVer3PfmCounters>;