PseudoSourceValue.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //===-- llvm/CodeGen/PseudoSourceValue.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. //
  10. // This file contains the declaration of the PseudoSourceValue class.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
  14. #define LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
  15. #include "llvm/IR/Value.h"
  16. namespace llvm {
  17. class MachineFrameInfo;
  18. class MachineMemOperand;
  19. class raw_ostream;
  20. raw_ostream &operator<<(raw_ostream &OS, const MachineMemOperand &MMO);
  21. /// PseudoSourceValue - Special value supplied for machine level alias
  22. /// analysis. It indicates that a memory access references the functions
  23. /// stack frame (e.g., a spill slot), below the stack frame (e.g., argument
  24. /// space), or constant pool.
  25. class PseudoSourceValue {
  26. private:
  27. friend class MachineMemOperand; // For printCustom().
  28. /// printCustom - Implement printing for PseudoSourceValue. This is called
  29. /// from Value::print or Value's operator<<.
  30. ///
  31. virtual void printCustom(raw_ostream &O) const;
  32. public:
  33. /// isFixed - Whether this is a FixedStackPseudoSourceValue.
  34. bool isFixed;
  35. explicit PseudoSourceValue(bool isFixed = false);
  36. virtual ~PseudoSourceValue();
  37. /// isConstant - Test whether the memory pointed to by this
  38. /// PseudoSourceValue has a constant value.
  39. ///
  40. virtual bool isConstant(const MachineFrameInfo *) const;
  41. /// isAliased - Test whether the memory pointed to by this
  42. /// PseudoSourceValue may also be pointed to by an LLVM IR Value.
  43. virtual bool isAliased(const MachineFrameInfo *) const;
  44. /// mayAlias - Return true if the memory pointed to by this
  45. /// PseudoSourceValue can ever alias an LLVM IR Value.
  46. virtual bool mayAlias(const MachineFrameInfo *) const;
  47. /// A pseudo source value referencing a fixed stack frame entry,
  48. /// e.g., a spill slot.
  49. static const PseudoSourceValue *getFixedStack(int FI);
  50. /// A pseudo source value referencing the area below the stack frame of
  51. /// a function, e.g., the argument space.
  52. static const PseudoSourceValue *getStack();
  53. /// A pseudo source value referencing the global offset table
  54. /// (or something the like).
  55. static const PseudoSourceValue *getGOT();
  56. /// A pseudo source value referencing the constant pool. Since constant
  57. /// pools are constant, this doesn't need to identify a specific constant
  58. /// pool entry.
  59. static const PseudoSourceValue *getConstantPool();
  60. /// A pseudo source value referencing a jump table. Since jump tables are
  61. /// constant, this doesn't need to identify a specific jump table.
  62. static const PseudoSourceValue *getJumpTable();
  63. };
  64. /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue
  65. /// for holding FixedStack values, which must include a frame
  66. /// index.
  67. class FixedStackPseudoSourceValue : public PseudoSourceValue {
  68. const int FI;
  69. public:
  70. explicit FixedStackPseudoSourceValue(int fi) :
  71. PseudoSourceValue(true), FI(fi) {}
  72. /// classof - Methods for support type inquiry through isa, cast, and
  73. /// dyn_cast:
  74. ///
  75. static inline bool classof(const PseudoSourceValue *V) {
  76. return V->isFixed == true;
  77. }
  78. bool isConstant(const MachineFrameInfo *MFI) const override;
  79. bool isAliased(const MachineFrameInfo *MFI) const override;
  80. bool mayAlias(const MachineFrameInfo *) const override;
  81. void printCustom(raw_ostream &OS) const override;
  82. int getFrameIndex() const { return FI; }
  83. };
  84. } // End llvm namespace
  85. #endif