RISCVInstrInfoXVentana.td 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //===-- RISCVInstrInfoXVentana.td --------------------------*- 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 describes the vendor extensions defined by Ventana Micro Systems.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. //===----------------------------------------------------------------------===//
  13. // XVentanaCondOps
  14. //===----------------------------------------------------------------------===//
  15. let Predicates = [IsRV64, HasVendorXVentanaCondOps], hasSideEffects = 0,
  16. mayLoad = 0, mayStore = 0, isCodeGenOnly = 0, DecoderNamespace = "Ventana" in
  17. class VTMaskedMove<bits<3> funct3, string opcodestr>
  18. : RVInstR<0b0000000, funct3, OPC_CUSTOM_3, (outs GPR:$rd),
  19. (ins GPR:$rs1, GPR:$rs2), opcodestr,
  20. "$rd, $rs1, $rs2"> {
  21. }
  22. def VT_MASKC : VTMaskedMove<0b110, "vt.maskc">,
  23. Sched<[WriteIALU, ReadIALU, ReadIALU]>;
  24. def VT_MASKCN : VTMaskedMove<0b111, "vt.maskcn">,
  25. Sched<[WriteIALU, ReadIALU, ReadIALU]>;
  26. let Predicates = [IsRV64, HasVendorXVentanaCondOps] in {
  27. // Directly use MASKC/MASKCN in case of any of the operands being 0.
  28. def : Pat<(select GPR:$rc, GPR:$rs1, (i64 0)),
  29. (VT_MASKC $rs1, $rc)>;
  30. def : Pat<(select GPR:$rc, (i64 0), GPR:$rs1),
  31. (VT_MASKCN $rs1, $rc)>;
  32. def : Pat<(select (i64 (setne GPR:$rc, (i64 0))), GPR:$rs1, (i64 0)),
  33. (VT_MASKC GPR:$rs1, GPR:$rc)>;
  34. def : Pat<(select (i64 (seteq GPR:$rc, (i64 0))), GPR:$rs1, (i64 0)),
  35. (VT_MASKCN GPR:$rs1, GPR:$rc)>;
  36. def : Pat<(select (i64 (setne GPR:$rc, (i64 0))), (i64 0), GPR:$rs1),
  37. (VT_MASKCN GPR:$rs1, GPR:$rc)>;
  38. def : Pat<(select (i64 (seteq GPR:$rc, (i64 0))), (i64 0), GPR:$rs1),
  39. (VT_MASKC GPR:$rs1, GPR:$rc)>;
  40. def : Pat<(select (i64 (setne GPR:$x, simm12_plus1:$y)), GPR:$rs1, (i64 0)),
  41. (VT_MASKC GPR:$rs1, (ADDI GPR:$x, (NegImm simm12_plus1:$y)))>;
  42. def : Pat<(select (i64 (seteq GPR:$x, simm12_plus1:$y)), GPR:$rs1, (i64 0)),
  43. (VT_MASKCN GPR:$rs1, (ADDI GPR:$x, (NegImm simm12_plus1:$y)))>;
  44. def : Pat<(select (i64 (setne GPR:$x, simm12_plus1:$y)), (i64 0), GPR:$rs1),
  45. (VT_MASKCN GPR:$rs1, (ADDI GPR:$x, (NegImm simm12_plus1:$y)))>;
  46. def : Pat<(select (i64 (seteq GPR:$x, simm12_plus1:$y)), (i64 0), GPR:$rs1),
  47. (VT_MASKC GPR:$rs1, (ADDI GPR:$x, (NegImm simm12_plus1:$y)))>;
  48. def : Pat<(select (i64 (setne GPR:$x, (i64 -2048))), GPR:$rs1, (i64 0)),
  49. (VT_MASKC GPR:$rs1, (XORI GPR:$x, -2048))>;
  50. def : Pat<(select (i64 (seteq GPR:$x, (i64 -2048))), GPR:$rs1, (i64 0)),
  51. (VT_MASKCN GPR:$rs1, (XORI GPR:$x, -2048))>;
  52. def : Pat<(select (i64 (setne GPR:$x, (i64 -2048))), (i64 0), GPR:$rs1),
  53. (VT_MASKCN GPR:$rs1, (XORI GPR:$x, -2048))>;
  54. def : Pat<(select (i64 (seteq GPR:$x, (i64 -2048))), (i64 0), GPR:$rs1),
  55. (VT_MASKC GPR:$rs1, (XORI GPR:$x, -2048))>;
  56. def : Pat<(select (i64 (setne GPR:$x, GPR:$y)), GPR:$rs1, (i64 0)),
  57. (VT_MASKC GPR:$rs1, (XOR GPR:$x, GPR:$y))>;
  58. def : Pat<(select (i64 (seteq GPR:$x, GPR:$y)), GPR:$rs1, (i64 0)),
  59. (VT_MASKCN GPR:$rs1, (XOR GPR:$x, GPR:$y))>;
  60. def : Pat<(select (i64 (setne GPR:$x, GPR:$y)), (i64 0), GPR:$rs1),
  61. (VT_MASKCN GPR:$rs1, (XOR GPR:$x, GPR:$y))>;
  62. def : Pat<(select (i64 (seteq GPR:$x, GPR:$y)), (i64 0), GPR:$rs1),
  63. (VT_MASKC GPR:$rs1, (XOR GPR:$x, GPR:$y))>;
  64. // Conditional AND operation patterns.
  65. def : Pat<(i64 (select GPR:$rc, (and GPR:$rs1, GPR:$rs2), GPR:$rs1)),
  66. (OR (AND $rs1, $rs2), (VT_MASKCN $rs1, $rc))>;
  67. def : Pat<(i64 (select GPR:$rc, GPR:$rs1, (and GPR:$rs1, GPR:$rs2))),
  68. (OR (AND $rs1, $rs2), (VT_MASKC $rs1, $rc))>;
  69. // Basic select pattern that selects between 2 registers.
  70. def : Pat<(i64 (select GPR:$rc, GPR:$rs1, GPR:$rs2)),
  71. (OR (VT_MASKC $rs1, $rc), (VT_MASKCN $rs2, $rc))>;
  72. def : Pat<(i64 (select (i64 (setne GPR:$rc, (i64 0))), GPR:$rs1, GPR:$rs2)),
  73. (OR (VT_MASKC GPR:$rs1, GPR:$rc), (VT_MASKCN GPR:$rs2, GPR:$rc))>;
  74. def : Pat<(i64 (select (i64 (seteq GPR:$rc, (i64 0))), GPR:$rs2, GPR:$rs1)),
  75. (OR (VT_MASKC GPR:$rs1, GPR:$rc), (VT_MASKCN GPR:$rs2, GPR:$rc))>;
  76. def : Pat<(i64 (select (i64 (setne GPR:$x, simm12_plus1:$y)), GPR:$rs1, GPR:$rs2)),
  77. (OR (VT_MASKC GPR:$rs1, (ADDI GPR:$x, (NegImm simm12_plus1:$y))),
  78. (VT_MASKCN GPR:$rs2, (ADDI GPR:$x, (NegImm simm12_plus1:$y))))>;
  79. def : Pat<(i64 (select (i64 (seteq GPR:$x, simm12_plus1:$y)), GPR:$rs2, GPR:$rs1)),
  80. (OR (VT_MASKC GPR:$rs1, (ADDI GPR:$x, (NegImm simm12_plus1:$y))),
  81. (VT_MASKCN GPR:$rs2, (ADDI GPR:$x, (NegImm simm12_plus1:$y))))>;
  82. def : Pat<(i64 (select (i64 (setne GPR:$x, (i64 -2048))), GPR:$rs1, GPR:$rs2)),
  83. (OR (VT_MASKC GPR:$rs1, (XORI GPR:$x, -2048)),
  84. (VT_MASKCN GPR:$rs2, (XORI GPR:$x, -2048)))>;
  85. def : Pat<(i64 (select (i64 (seteq GPR:$x, (i64 -2048))), GPR:$rs2, GPR:$rs1)),
  86. (OR (VT_MASKC GPR:$rs1, (XORI GPR:$x, -2048)),
  87. (VT_MASKCN GPR:$rs2, (XORI GPR:$x, -2048)))>;
  88. def : Pat<(i64 (select (i64 (setne GPR:$x, GPR:$y)), GPR:$rs1, GPR:$rs2)),
  89. (OR (VT_MASKC GPR:$rs1, (XOR GPR:$x, GPR:$y)),
  90. (VT_MASKCN GPR:$rs2, (XOR GPR:$x, GPR:$y)))>;
  91. def : Pat<(i64 (select (i64 (seteq GPR:$x, GPR:$y)), GPR:$rs2, GPR:$rs1)),
  92. (OR (VT_MASKC GPR:$rs1, (XOR GPR:$x, GPR:$y)),
  93. (VT_MASKCN GPR:$rs2, (XOR GPR:$x, GPR:$y)))>;
  94. } // Predicates = [IsRV64, HasVendorXVentanaCondOps]