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.

86 lines
3.0 KiB

  1. //===-- llvm/MC/MCParsedAsmOperand.h - Asm Parser Operand -------*- C++ -*-===//
  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_MCPARSER_MCPARSEDASMOPERAND_H
  10. #define LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H
  11. namespace llvm {
  12. class SMLoc;
  13. class raw_ostream;
  14. /// MCParsedAsmOperand - This abstract class represents a source-level assembly
  15. /// instruction operand. It should be subclassed by target-specific code. This
  16. /// base class is used by target-independent clients and is the interface
  17. /// between parsing an asm instruction and recognizing it.
  18. class MCParsedAsmOperand {
  19. /// MCOperandNum - The corresponding MCInst operand number. Only valid when
  20. /// parsing MS-style inline assembly.
  21. unsigned MCOperandNum;
  22. /// Constraint - The constraint on this operand. Only valid when parsing
  23. /// MS-style inline assembly.
  24. std::string Constraint;
  25. public:
  26. MCParsedAsmOperand() {}
  27. virtual ~MCParsedAsmOperand() {}
  28. void setConstraint(StringRef C) { Constraint = C.str(); }
  29. StringRef getConstraint() { return Constraint; }
  30. void setMCOperandNum (unsigned OpNum) { MCOperandNum = OpNum; }
  31. unsigned getMCOperandNum() { return MCOperandNum; }
  32. virtual StringRef getSymName() { return StringRef(); }
  33. /// isToken - Is this a token operand?
  34. virtual bool isToken() const = 0;
  35. /// isImm - Is this an immediate operand?
  36. virtual bool isImm() const = 0;
  37. /// isReg - Is this a register operand?
  38. virtual bool isReg() const = 0;
  39. virtual unsigned getReg() const = 0;
  40. /// isMem - Is this a memory operand?
  41. virtual bool isMem() const = 0;
  42. /// getStartLoc - Get the location of the first token of this operand.
  43. virtual SMLoc getStartLoc() const = 0;
  44. /// getEndLoc - Get the location of the last token of this operand.
  45. virtual SMLoc getEndLoc() const = 0;
  46. /// needAddressOf - Do we need to emit code to get the address of the
  47. /// variable/label? Only valid when parsing MS-style inline assembly.
  48. virtual bool needAddressOf() const { return false; }
  49. /// isOffsetOf - Do we need to emit code to get the offset of the variable,
  50. /// rather then the value of the variable? Only valid when parsing MS-style
  51. /// inline assembly.
  52. virtual bool isOffsetOf() const { return false; }
  53. /// getOffsetOfLoc - Get the location of the offset operator.
  54. virtual SMLoc getOffsetOfLoc() const { return SMLoc(); }
  55. /// print - Print a debug representation of the operand to the given stream.
  56. virtual void print(raw_ostream &OS) const = 0;
  57. /// dump - Print to the debug stream.
  58. virtual void dump() const;
  59. };
  60. //===----------------------------------------------------------------------===//
  61. // Debugging Support
  62. inline raw_ostream& operator<<(raw_ostream &OS, const MCParsedAsmOperand &MO) {
  63. MO.print(OS);
  64. return OS;
  65. }
  66. } // end namespace llvm.
  67. #endif