ARMFeatures.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //===-- ARMFeatures.h - Checks for ARM instruction features -----*- 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 the code shared between ARM CodeGen and ARM MC
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_ARM_ARMFEATURES_H
  13. #define LLVM_LIB_TARGET_ARM_ARMFEATURES_H
  14. #include "MCTargetDesc/ARMMCTargetDesc.h"
  15. namespace llvm {
  16. template<typename InstrType> // could be MachineInstr or MCInst
  17. bool IsCPSRDead(const InstrType *Instr);
  18. template<typename InstrType> // could be MachineInstr or MCInst
  19. inline bool isV8EligibleForIT(const InstrType *Instr) {
  20. switch (Instr->getOpcode()) {
  21. default:
  22. return false;
  23. case ARM::tADC:
  24. case ARM::tADDi3:
  25. case ARM::tADDi8:
  26. case ARM::tADDrr:
  27. case ARM::tAND:
  28. case ARM::tASRri:
  29. case ARM::tASRrr:
  30. case ARM::tBIC:
  31. case ARM::tEOR:
  32. case ARM::tLSLri:
  33. case ARM::tLSLrr:
  34. case ARM::tLSRri:
  35. case ARM::tLSRrr:
  36. case ARM::tMOVi8:
  37. case ARM::tMUL:
  38. case ARM::tMVN:
  39. case ARM::tORR:
  40. case ARM::tROR:
  41. case ARM::tRSB:
  42. case ARM::tSBC:
  43. case ARM::tSUBi3:
  44. case ARM::tSUBi8:
  45. case ARM::tSUBrr:
  46. // Outside of an IT block, these set CPSR.
  47. return IsCPSRDead(Instr);
  48. case ARM::tADDrSPi:
  49. case ARM::tCMNz:
  50. case ARM::tCMPi8:
  51. case ARM::tCMPr:
  52. case ARM::tLDRBi:
  53. case ARM::tLDRBr:
  54. case ARM::tLDRHi:
  55. case ARM::tLDRHr:
  56. case ARM::tLDRSB:
  57. case ARM::tLDRSH:
  58. case ARM::tLDRi:
  59. case ARM::tLDRr:
  60. case ARM::tLDRspi:
  61. case ARM::tSTRBi:
  62. case ARM::tSTRBr:
  63. case ARM::tSTRHi:
  64. case ARM::tSTRHr:
  65. case ARM::tSTRi:
  66. case ARM::tSTRr:
  67. case ARM::tSTRspi:
  68. case ARM::tTST:
  69. return true;
  70. // there are some "conditionally deprecated" opcodes
  71. case ARM::tADDspr:
  72. case ARM::tBLXr:
  73. case ARM::tBLXr_noip:
  74. return Instr->getOperand(2).getReg() != ARM::PC;
  75. // ADD PC, SP and BLX PC were always unpredictable,
  76. // now on top of it they're deprecated
  77. case ARM::tADDrSP:
  78. case ARM::tBX:
  79. return Instr->getOperand(0).getReg() != ARM::PC;
  80. case ARM::tADDhirr:
  81. return Instr->getOperand(0).getReg() != ARM::PC &&
  82. Instr->getOperand(2).getReg() != ARM::PC;
  83. case ARM::tCMPhir:
  84. case ARM::tMOVr:
  85. return Instr->getOperand(0).getReg() != ARM::PC &&
  86. Instr->getOperand(1).getReg() != ARM::PC;
  87. }
  88. }
  89. }
  90. #endif