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.

98 lines
3.2 KiB

  1. //===-- llvm/MC/MachineLocation.h -------------------------------*- 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. // The MachineLocation class is used to represent a simple location in a machine
  10. // frame. Locations will be one of two forms; a register or an address formed
  11. // from a base address plus an offset. Register indirection can be specified by
  12. // using an offset of zero.
  13. //
  14. // The MachineMove class is used to represent abstract move operations in the
  15. // prolog/epilog of a compiled function. A collection of these objects can be
  16. // used by a debug consumer to track the location of values when unwinding stack
  17. // frames.
  18. //===----------------------------------------------------------------------===//
  19. #ifndef LLVM_MC_MACHINELOCATION_H
  20. #define LLVM_MC_MACHINELOCATION_H
  21. namespace llvm {
  22. class MCSymbol;
  23. class MachineLocation {
  24. private:
  25. bool IsRegister; // True if location is a register.
  26. unsigned Register; // gcc/gdb register number.
  27. int Offset; // Displacement if not register.
  28. public:
  29. enum {
  30. // The target register number for an abstract frame pointer. The value is
  31. // an arbitrary value that doesn't collide with any real target register.
  32. VirtualFP = ~0U
  33. };
  34. MachineLocation()
  35. : IsRegister(false), Register(0), Offset(0) {}
  36. explicit MachineLocation(unsigned R)
  37. : IsRegister(true), Register(R), Offset(0) {}
  38. MachineLocation(unsigned R, int O)
  39. : IsRegister(false), Register(R), Offset(O) {}
  40. bool operator==(const MachineLocation &Other) const {
  41. return IsRegister == Other.IsRegister && Register == Other.Register &&
  42. Offset == Other.Offset;
  43. }
  44. // Accessors
  45. bool isReg() const { return IsRegister; }
  46. unsigned getReg() const { return Register; }
  47. int getOffset() const { return Offset; }
  48. void setIsRegister(bool Is) { IsRegister = Is; }
  49. void setRegister(unsigned R) { Register = R; }
  50. void setOffset(int O) { Offset = O; }
  51. void set(unsigned R) {
  52. IsRegister = true;
  53. Register = R;
  54. Offset = 0;
  55. }
  56. void set(unsigned R, int O) {
  57. IsRegister = false;
  58. Register = R;
  59. Offset = O;
  60. }
  61. #ifndef NDEBUG
  62. void dump();
  63. #endif
  64. };
  65. /// MachineMove - This class represents the save or restore of a callee saved
  66. /// register that exception or debug info needs to know about.
  67. class MachineMove {
  68. private:
  69. /// Label - Symbol for post-instruction address when result of move takes
  70. /// effect.
  71. MCSymbol *Label;
  72. // Move to & from location.
  73. MachineLocation Destination, Source;
  74. public:
  75. MachineMove() : Label(0) {}
  76. MachineMove(MCSymbol *label, const MachineLocation &D,
  77. const MachineLocation &S)
  78. : Label(label), Destination(D), Source(S) {}
  79. // Accessors
  80. MCSymbol *getLabel() const { return Label; }
  81. const MachineLocation &getDestination() const { return Destination; }
  82. const MachineLocation &getSource() const { return Source; }
  83. };
  84. } // End llvm namespace
  85. #endif