LLVM API Documentation

PseudoSourceValue.h
Go to the documentation of this file.
00001 //===-- llvm/CodeGen/PseudoSourceValue.h ------------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains the declaration of the PseudoSourceValue class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
00015 #define LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
00016 
00017 #include "llvm/IR/Value.h"
00018 
00019 namespace llvm {
00020   class MachineFrameInfo;
00021   class MachineMemOperand;
00022   class raw_ostream;
00023 
00024   raw_ostream &operator<<(raw_ostream &OS, const MachineMemOperand &MMO);
00025 
00026   /// PseudoSourceValue - Special value supplied for machine level alias
00027   /// analysis. It indicates that a memory access references the functions
00028   /// stack frame (e.g., a spill slot), below the stack frame (e.g., argument
00029   /// space), or constant pool.
00030   class PseudoSourceValue {
00031   private:
00032     friend raw_ostream &llvm::operator<<(raw_ostream &OS,
00033                                          const MachineMemOperand &MMO);
00034 
00035     /// printCustom - Implement printing for PseudoSourceValue. This is called
00036     /// from Value::print or Value's operator<<.
00037     ///
00038     virtual void printCustom(raw_ostream &O) const;
00039 
00040   public:
00041     /// isFixed - Whether this is a FixedStackPseudoSourceValue.
00042     bool isFixed;
00043 
00044     explicit PseudoSourceValue(bool isFixed = false);
00045 
00046     virtual ~PseudoSourceValue();
00047 
00048     /// isConstant - Test whether the memory pointed to by this
00049     /// PseudoSourceValue has a constant value.
00050     ///
00051     virtual bool isConstant(const MachineFrameInfo *) const;
00052 
00053     /// isAliased - Test whether the memory pointed to by this
00054     /// PseudoSourceValue may also be pointed to by an LLVM IR Value.
00055     virtual bool isAliased(const MachineFrameInfo *) const;
00056 
00057     /// mayAlias - Return true if the memory pointed to by this
00058     /// PseudoSourceValue can ever alias an LLVM IR Value.
00059     virtual bool mayAlias(const MachineFrameInfo *) const;
00060 
00061     /// A pseudo source value referencing a fixed stack frame entry,
00062     /// e.g., a spill slot.
00063     static const PseudoSourceValue *getFixedStack(int FI);
00064 
00065     /// A pseudo source value referencing the area below the stack frame of
00066     /// a function, e.g., the argument space.
00067     static const PseudoSourceValue *getStack();
00068 
00069     /// A pseudo source value referencing the global offset table
00070     /// (or something the like).
00071     static const PseudoSourceValue *getGOT();
00072 
00073     /// A pseudo source value referencing the constant pool. Since constant
00074     /// pools are constant, this doesn't need to identify a specific constant
00075     /// pool entry.
00076     static const PseudoSourceValue *getConstantPool();
00077 
00078     /// A pseudo source value referencing a jump table. Since jump tables are
00079     /// constant, this doesn't need to identify a specific jump table.
00080     static const PseudoSourceValue *getJumpTable();
00081   };
00082 
00083   /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue
00084   /// for holding FixedStack values, which must include a frame
00085   /// index.
00086   class FixedStackPseudoSourceValue : public PseudoSourceValue {
00087     const int FI;
00088   public:
00089     explicit FixedStackPseudoSourceValue(int fi) :
00090         PseudoSourceValue(true), FI(fi) {}
00091 
00092     /// classof - Methods for support type inquiry through isa, cast, and
00093     /// dyn_cast:
00094     ///
00095     static inline bool classof(const PseudoSourceValue *V) {
00096       return V->isFixed == true;
00097     }
00098 
00099     bool isConstant(const MachineFrameInfo *MFI) const override;
00100 
00101     bool isAliased(const MachineFrameInfo *MFI) const override;
00102 
00103     bool mayAlias(const MachineFrameInfo *) const override;
00104 
00105     void printCustom(raw_ostream &OS) const override;
00106 
00107     int getFrameIndex() const { return FI; }
00108   };
00109 } // End llvm namespace
00110 
00111 #endif