ARMMCTargetDesc.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //===-- ARMMCTargetDesc.h - ARM Target Descriptions -------------*- 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 provides ARM specific target descriptions.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMMCTARGETDESC_H
  13. #define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMMCTARGETDESC_H
  14. #include "llvm/Support/DataTypes.h"
  15. #include "llvm/MC/MCInstrDesc.h"
  16. #include <memory>
  17. #include <string>
  18. namespace llvm {
  19. class formatted_raw_ostream;
  20. class MCAsmBackend;
  21. class MCCodeEmitter;
  22. class MCContext;
  23. class MCInstrInfo;
  24. class MCInstPrinter;
  25. class MCObjectTargetWriter;
  26. class MCObjectWriter;
  27. class MCRegisterInfo;
  28. class MCSubtargetInfo;
  29. class MCStreamer;
  30. class MCTargetOptions;
  31. class MCRelocationInfo;
  32. class MCTargetStreamer;
  33. class StringRef;
  34. class Target;
  35. class Triple;
  36. namespace ARM_MC {
  37. std::string ParseARMTriple(const Triple &TT, StringRef CPU);
  38. void initLLVMToCVRegMapping(MCRegisterInfo *MRI);
  39. bool isPredicated(const MCInst &MI, const MCInstrInfo *MCII);
  40. bool isCPSRDefined(const MCInst &MI, const MCInstrInfo *MCII);
  41. template<class Inst>
  42. bool isLDMBaseRegInList(const Inst &MI) {
  43. auto BaseReg = MI.getOperand(0).getReg();
  44. for (unsigned I = 1, E = MI.getNumOperands(); I < E; ++I) {
  45. const auto &Op = MI.getOperand(I);
  46. if (Op.isReg() && Op.getReg() == BaseReg)
  47. return true;
  48. }
  49. return false;
  50. }
  51. uint64_t evaluateBranchTarget(const MCInstrDesc &InstDesc, uint64_t Addr,
  52. int64_t Imm);
  53. /// Create a ARM MCSubtargetInfo instance. This is exposed so Asm parser, etc.
  54. /// do not need to go through TargetRegistry.
  55. MCSubtargetInfo *createARMMCSubtargetInfo(const Triple &TT, StringRef CPU,
  56. StringRef FS);
  57. }
  58. MCTargetStreamer *createARMNullTargetStreamer(MCStreamer &S);
  59. MCTargetStreamer *createARMTargetAsmStreamer(MCStreamer &S,
  60. formatted_raw_ostream &OS,
  61. MCInstPrinter *InstPrint,
  62. bool isVerboseAsm);
  63. MCTargetStreamer *createARMObjectTargetStreamer(MCStreamer &S,
  64. const MCSubtargetInfo &STI);
  65. MCCodeEmitter *createARMLEMCCodeEmitter(const MCInstrInfo &MCII,
  66. const MCRegisterInfo &MRI,
  67. MCContext &Ctx);
  68. MCCodeEmitter *createARMBEMCCodeEmitter(const MCInstrInfo &MCII,
  69. const MCRegisterInfo &MRI,
  70. MCContext &Ctx);
  71. MCAsmBackend *createARMLEAsmBackend(const Target &T, const MCSubtargetInfo &STI,
  72. const MCRegisterInfo &MRI,
  73. const MCTargetOptions &Options);
  74. MCAsmBackend *createARMBEAsmBackend(const Target &T, const MCSubtargetInfo &STI,
  75. const MCRegisterInfo &MRI,
  76. const MCTargetOptions &Options);
  77. // Construct a PE/COFF machine code streamer which will generate a PE/COFF
  78. // object file.
  79. MCStreamer *createARMWinCOFFStreamer(MCContext &Context,
  80. std::unique_ptr<MCAsmBackend> &&MAB,
  81. std::unique_ptr<MCObjectWriter> &&OW,
  82. std::unique_ptr<MCCodeEmitter> &&Emitter,
  83. bool RelaxAll,
  84. bool IncrementalLinkerCompatible);
  85. /// Construct an ELF Mach-O object writer.
  86. std::unique_ptr<MCObjectTargetWriter> createARMELFObjectWriter(uint8_t OSABI);
  87. /// Construct an ARM Mach-O object writer.
  88. std::unique_ptr<MCObjectTargetWriter>
  89. createARMMachObjectWriter(bool Is64Bit, uint32_t CPUType,
  90. uint32_t CPUSubtype);
  91. /// Construct an ARM PE/COFF object writer.
  92. std::unique_ptr<MCObjectTargetWriter>
  93. createARMWinCOFFObjectWriter();
  94. /// Construct ARM Mach-O relocation info.
  95. MCRelocationInfo *createARMMachORelocationInfo(MCContext &Ctx);
  96. namespace ARM {
  97. enum OperandType {
  98. OPERAND_VPRED_R = MCOI::OPERAND_FIRST_TARGET,
  99. OPERAND_VPRED_N,
  100. };
  101. inline bool isVpred(OperandType op) {
  102. return op == OPERAND_VPRED_R || op == OPERAND_VPRED_N;
  103. }
  104. inline bool isVpred(uint8_t op) {
  105. return isVpred(static_cast<OperandType>(op));
  106. }
  107. bool isCDECoproc(size_t Coproc, const MCSubtargetInfo &STI);
  108. } // end namespace ARM
  109. } // End llvm namespace
  110. // Defines symbolic names for ARM registers. This defines a mapping from
  111. // register name to register number.
  112. //
  113. #define GET_REGINFO_ENUM
  114. #include "ARMGenRegisterInfo.inc"
  115. // Defines symbolic names for the ARM instructions.
  116. //
  117. #define GET_INSTRINFO_ENUM
  118. #include "ARMGenInstrInfo.inc"
  119. #define GET_SUBTARGETINFO_ENUM
  120. #include "ARMGenSubtargetInfo.inc"
  121. #endif