Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.9 KiB

  1. //===-- MCInstPrinter.h - Convert an MCInst to target assembly syntax -----===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef LLVM_MC_MCINSTPRINTER_H
  10. #define LLVM_MC_MCINSTPRINTER_H
  11. #include "llvm/Support/DataTypes.h"
  12. #include "llvm/Support/Format.h"
  13. namespace llvm {
  14. class MCInst;
  15. class raw_ostream;
  16. class MCAsmInfo;
  17. class MCInstrInfo;
  18. class MCRegisterInfo;
  19. class StringRef;
  20. /// MCInstPrinter - This is an instance of a target assembly language printer
  21. /// that converts an MCInst to valid target assembly syntax.
  22. class MCInstPrinter {
  23. protected:
  24. /// CommentStream - a stream that comments can be emitted to if desired.
  25. /// Each comment must end with a newline. This will be null if verbose
  26. /// assembly emission is disable.
  27. raw_ostream *CommentStream;
  28. const MCAsmInfo &MAI;
  29. const MCInstrInfo &MII;
  30. const MCRegisterInfo &MRI;
  31. /// The current set of available features.
  32. unsigned AvailableFeatures;
  33. /// True if we are printing marked up assembly.
  34. bool UseMarkup;
  35. /// True if we are printing immediates as hex.
  36. bool PrintImmHex;
  37. /// Utility function for printing annotations.
  38. void printAnnotation(raw_ostream &OS, StringRef Annot);
  39. public:
  40. MCInstPrinter(const MCAsmInfo &mai, const MCInstrInfo &mii,
  41. const MCRegisterInfo &mri)
  42. : CommentStream(0), MAI(mai), MII(mii), MRI(mri), AvailableFeatures(0),
  43. UseMarkup(0), PrintImmHex(0) {}
  44. virtual ~MCInstPrinter();
  45. /// setCommentStream - Specify a stream to emit comments to.
  46. void setCommentStream(raw_ostream &OS) { CommentStream = &OS; }
  47. /// printInst - Print the specified MCInst to the specified raw_ostream.
  48. ///
  49. virtual void printInst(const MCInst *MI, raw_ostream &OS,
  50. StringRef Annot) = 0;
  51. /// getOpcodeName - Return the name of the specified opcode enum (e.g.
  52. /// "MOV32ri") or empty if we can't resolve it.
  53. StringRef getOpcodeName(unsigned Opcode) const;
  54. /// printRegName - Print the assembler register name.
  55. virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
  56. unsigned getAvailableFeatures() const { return AvailableFeatures; }
  57. void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; }
  58. bool getUseMarkup() const { return UseMarkup; }
  59. void setUseMarkup(bool Value) { UseMarkup = Value; }
  60. /// Utility functions to make adding mark ups simpler.
  61. StringRef markup(StringRef s) const;
  62. StringRef markup(StringRef a, StringRef b) const;
  63. bool getPrintImmHex() const { return PrintImmHex; }
  64. void setPrintImmHex(bool Value) { PrintImmHex = Value; }
  65. /// Utility function to print immediates in decimal or hex.
  66. format_object1<int64_t> formatImm(const int64_t Value) const;
  67. };
  68. } // namespace llvm
  69. #endif