PPCMacroFusion.def 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //=== ---- PPCMacroFusion.def - PowerPC MacroFuson Candidates -v-*- C++ -*-===//
  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 contains descriptions of the macro-fusion pair for PowerPC.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. // NOTE: NO INCLUDE GUARD DESIRED!
  13. #ifndef FUSION_FEATURE
  14. // Each FUSION_FEATURE is assigned with one TYPE, and can be enabled/disabled
  15. // by HAS_FEATURE. The instructions pair is fusable only when the opcode
  16. // of the first instruction is in OPSET1, and the second instruction opcode is
  17. // in OPSET2. And if DEP_OP_IDX >=0, we will check the result of first OP is
  18. // the operand of the second op with DEP_OP_IDX as its operand index. We assume
  19. // that the result of the first op is its operand zero.
  20. #define FUSION_FEATURE(TYPE, HAS_FEATURE, DEP_OP_IDX, OPSET1, OPSET2)
  21. #endif
  22. #ifndef FUSION_OP_SET
  23. #define FUSION_OP_SET(...) __VA_ARGS__
  24. #endif
  25. // Power8 User Manual Section 10.1.12, Instruction Fusion
  26. // {addi} followed by one of these {lxvd2x, lxvw4x, lxvdsx, lvebx, lvehx,
  27. // lvewx, lvx, lxsdx}
  28. FUSION_FEATURE(AddiLoad, hasAddiLoadFusion, 2, \
  29. FUSION_OP_SET(ADDI, ADDI8, ADDItocL), \
  30. FUSION_OP_SET(LXVD2X, LXVW4X, LXVDSX, LVEBX, LVEHX, LVEWX, \
  31. LVX, LXSDX))
  32. // {addis) followed by one of these {ld, lbz, lhz, lwz}
  33. FUSION_FEATURE(AddisLoad, hasAddisLoadFusion, 2, \
  34. FUSION_OP_SET(ADDIS, ADDIS8, ADDIStocHA8), \
  35. FUSION_OP_SET(LD, LBZ, LBZ8, LHZ, LHZ8, LWZ, LWZ8))
  36. // Power10 User Manual Section 19.1.5.4, Fusion
  37. // {add, mulld} - add
  38. FUSION_FEATURE(ArithAdd, hasArithAddFusion, -1,
  39. FUSION_OP_SET(ADD4, ADD8, MULLD), FUSION_OP_SET(ADD4, ADD8))
  40. // {add, subf} - {and, nand, nor, or}
  41. FUSION_FEATURE(ArithLogical, hasAddLogicalFusion, -1,
  42. FUSION_OP_SET(ADD4, ADD8, SUBF, SUBF8),
  43. FUSION_OP_SET(AND, AND8, OR, OR8, NAND, NAND8, NOR, NOR8))
  44. // {and, andc, eqv, nand, nor, or, orc, xor} - {add, subf}
  45. FUSION_FEATURE(LogicalArith, hasLogicalAddFusion, -1,
  46. FUSION_OP_SET(AND, ANDC, EQV, NAND, NOR, OR, ORC, XOR, AND8,
  47. ANDC8, EQV8, NAND8, NOR8, OR8, ORC8, XOR8),
  48. FUSION_OP_SET(ADD4, ADD8, SUBF, SUBF8))
  49. // Either of {and, andc, eqv, nand, nor, or, orc, xor}
  50. FUSION_FEATURE(Logical, hasLogicalFusion, -1,
  51. FUSION_OP_SET(AND, ANDC, EQV, NAND, NOR, OR, ORC, XOR, AND8,
  52. ANDC8, EQV8, NAND8, NOR8, OR8, ORC8, XOR8),
  53. FUSION_OP_SET(AND, ANDC, EQV, NAND, NOR, OR, ORC, XOR, AND8,
  54. ANDC8, EQV8, NAND8, NOR8, OR8, ORC8, XOR8))
  55. // vaddudm - vaddudm
  56. FUSION_FEATURE(VecAdd, hasArithAddFusion, -1, FUSION_OP_SET(VADDUDM),
  57. FUSION_OP_SET(VADDUDM))
  58. // Either of {vand, vandc, veqv, vnand, vnor, vor, vorc, vxor}
  59. FUSION_FEATURE(VecLogical, hasLogicalFusion, -1,
  60. FUSION_OP_SET(VAND, VANDC, VEQV, VNAND, VNOR, VOR, VORC, VXOR),
  61. FUSION_OP_SET(VAND, VANDC, VEQV, VNAND, VNOR, VOR, VORC, VXOR))
  62. // sldi rx, ra, {3, 6} - {add, subf}
  63. // sldi rx, ra n is alias of rldicr rx, ra, n, 63-n
  64. FUSION_FEATURE(SldiAdd, hasArithAddFusion, -1, FUSION_OP_SET(RLDICR, RLDICR_32),
  65. FUSION_OP_SET(ADD4, ADD8, SUBF, SUBF8))
  66. // rldicl rx, ra, 1, 0 - xor
  67. FUSION_FEATURE(RotateLeftXor, hasSha3Fusion, 1,
  68. FUSION_OP_SET(RLDICL, RLDICL_32, RLDICL_32_64),
  69. FUSION_OP_SET(XOR, XOR8))
  70. // rldicr rx, ra, 1, 63 - xor
  71. FUSION_FEATURE(RotateRightXor, hasSha3Fusion, 1,
  72. FUSION_OP_SET(RLDICR, RLDICR_32), FUSION_OP_SET(XOR, XOR8))
  73. // There're two special cases in 'load-compare' series, so we have to split
  74. // them into several pattern groups to fit into current framework. This can
  75. // be clearer once we switched to a more expressive approach.
  76. // { lbz,lbzx,lhz,lhzx,lwz,lwzx } - cmpi 0,1,rx,{ 0,1,-1 }
  77. // { lbz,lbzx,lhz,lhzx,lwz,lwzx } - cmpli 0,L,rx,{ 0,1 }
  78. FUSION_FEATURE(LoadCmp1, hasCompareFusion, 1,
  79. FUSION_OP_SET(LBZ, LBZ8, LBZX, LBZX8, LBZXTLS, LBZXTLS_,
  80. LBZXTLS_32, LHZ, LHZ8, LHZX, LHZX8, LHZXTLS,
  81. LHZXTLS_, LHZXTLS_32, LWZ, LWZ8, LWZX, LWZX8,
  82. LWZXTLS, LWZXTLS_, LWZXTLS_32),
  83. FUSION_OP_SET(CMPDI, CMPLDI, CMPLWI))
  84. // { ld,ldx } - cmpi 0,1,rx,{ 0,1,-1 }
  85. // { ld,ldx } - cmpli 0,1,rx,{ 0,1 }
  86. FUSION_FEATURE(LoadCmp2, hasCompareFusion, 1,
  87. FUSION_OP_SET(LD, LDX, LDXTLS, LDXTLS_),
  88. FUSION_OP_SET(CMPDI, CMPLDI))
  89. // { lha,lhax,lwa,lwax } - cmpi 0,L,rx,{ 0,1,-1 }
  90. FUSION_FEATURE(LoadCmp3, hasCompareFusion, 1,
  91. FUSION_OP_SET(LHA, LHA8, LHAX, LHAX8, LWA, LWA_32, LWAX,
  92. LWAX_32),
  93. FUSION_OP_SET(CMPLDI, CMPLWI))
  94. // ori - oris
  95. FUSION_FEATURE(OriOris, hasWideImmFusion, 1, FUSION_OP_SET(ORI, ORI8),
  96. FUSION_OP_SET(ORIS, ORIS8))
  97. // lis - ori
  98. FUSION_FEATURE(LisOri, hasWideImmFusion, 1, FUSION_OP_SET(LIS, LIS8),
  99. FUSION_OP_SET(ORI, ORI8))
  100. // oris - ori
  101. FUSION_FEATURE(OrisOri, hasWideImmFusion, 1, FUSION_OP_SET(ORIS, ORIS8),
  102. FUSION_OP_SET(ORI, ORI8))
  103. // xori - xoris
  104. FUSION_FEATURE(XoriXoris, hasWideImmFusion, 1, FUSION_OP_SET(XORI, XORI8),
  105. FUSION_OP_SET(XORIS, XORIS8))
  106. // xoris - xori
  107. FUSION_FEATURE(XorisXori, hasWideImmFusion, 1, FUSION_OP_SET(XORIS, XORIS8),
  108. FUSION_OP_SET(XORI, XORI8))
  109. // addis rx,ra,si - addi rt,rx,SI, SI >= 0
  110. FUSION_FEATURE(AddisAddi, hasWideImmFusion, 1,
  111. FUSION_OP_SET(ADDIS, ADDIS8, ADDIStocHA8),
  112. FUSION_OP_SET(ADDI, ADDI8, ADDItocL))
  113. // addi rx,ra,si - addis rt,rx,SI, ra > 0, SI >= 2
  114. FUSION_FEATURE(AddiAddis, hasWideImmFusion, 1,
  115. FUSION_OP_SET(ADDI, ADDI8, ADDItocL),
  116. FUSION_OP_SET(ADDIS, ADDIS8, ADDIStocHA8))
  117. // mtctr - { bcctr,bcctrl }
  118. FUSION_FEATURE(ZeroMoveCTR, hasZeroMoveFusion, -1,
  119. FUSION_OP_SET(MTCTR, MTCTRloop, MTSPR8, MTSPR),
  120. FUSION_OP_SET(BCCTR, BCCTRn, BCCTR8, BCCTR8n, BCCTRL, BCCTRLn,
  121. BCCTRL8, BCCTRL8n, gBCCTR, gBCCTRL))
  122. // mtlr - { bclr,bclrl }
  123. FUSION_FEATURE(ZeroMoveLR, hasZeroMoveFusion, -1,
  124. FUSION_OP_SET(MTLR8, MTLR, MTSPR8, MTSPR),
  125. FUSION_OP_SET(BCLR, BCLRn, gBCLR, BCLRL, BCLRLn, gBCLRL))
  126. #include "PPCBack2BackFusion.def"
  127. #undef FUSION_FEATURE
  128. #undef FUSION_OP_SET