X86PfmCounters.td 13 KB

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