Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:33

0001 //===-- llvm/CodeGen/PseudoSourceValue.h ------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file contains the declaration of the PseudoSourceValue class.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
0014 #define LLVM_CODEGEN_PSEUDOSOURCEVALUE_H
0015 
0016 namespace llvm {
0017 
0018 class GlobalValue;
0019 class MachineFrameInfo;
0020 class MachineMemOperand;
0021 class MIRFormatter;
0022 class PseudoSourceValue;
0023 class raw_ostream;
0024 class TargetMachine;
0025 
0026 raw_ostream &operator<<(raw_ostream &OS, const PseudoSourceValue* PSV);
0027 
0028 /// Special value supplied for machine level alias analysis. It indicates that
0029 /// a memory access references the functions stack frame (e.g., a spill slot),
0030 /// below the stack frame (e.g., argument space), or constant pool.
0031 class PseudoSourceValue {
0032 public:
0033   enum PSVKind : unsigned {
0034     Stack,
0035     GOT,
0036     JumpTable,
0037     ConstantPool,
0038     FixedStack,
0039     GlobalValueCallEntry,
0040     ExternalSymbolCallEntry,
0041     TargetCustom
0042   };
0043 
0044 private:
0045   unsigned Kind;
0046   unsigned AddressSpace;
0047   friend raw_ostream &llvm::operator<<(raw_ostream &OS,
0048                                        const PseudoSourceValue* PSV);
0049 
0050   friend class MachineMemOperand; // For printCustom().
0051   friend class MIRFormatter;      // For printCustom().
0052 
0053   /// Implement printing for PseudoSourceValue. This is called from
0054   /// Value::print or Value's operator<<.
0055   virtual void printCustom(raw_ostream &O) const;
0056 
0057 public:
0058   explicit PseudoSourceValue(unsigned Kind, const TargetMachine &TM);
0059 
0060   virtual ~PseudoSourceValue();
0061 
0062   unsigned kind() const { return Kind; }
0063 
0064   bool isStack() const { return Kind == Stack; }
0065   bool isGOT() const { return Kind == GOT; }
0066   bool isConstantPool() const { return Kind == ConstantPool; }
0067   bool isJumpTable() const { return Kind == JumpTable; }
0068 
0069   unsigned getAddressSpace() const { return AddressSpace; }
0070 
0071   unsigned getTargetCustom() const {
0072     return (Kind >= TargetCustom) ? ((Kind+1) - TargetCustom) : 0;
0073   }
0074 
0075   /// Test whether the memory pointed to by this PseudoSourceValue has a
0076   /// constant value.
0077   virtual bool isConstant(const MachineFrameInfo *) const;
0078 
0079   /// Test whether the memory pointed to by this PseudoSourceValue may also be
0080   /// pointed to by an LLVM IR Value.
0081   virtual bool isAliased(const MachineFrameInfo *) const;
0082 
0083   /// Return true if the memory pointed to by this PseudoSourceValue can ever
0084   /// alias an LLVM IR Value.
0085   virtual bool mayAlias(const MachineFrameInfo *) const;
0086 };
0087 
0088 /// A specialized PseudoSourceValue for holding FixedStack values, which must
0089 /// include a frame index.
0090 class FixedStackPseudoSourceValue : public PseudoSourceValue {
0091   const int FI;
0092 
0093 public:
0094   explicit FixedStackPseudoSourceValue(int FI, const TargetMachine &TM)
0095       : PseudoSourceValue(FixedStack, TM), FI(FI) {}
0096 
0097   static bool classof(const PseudoSourceValue *V) {
0098     return V->kind() == FixedStack;
0099   }
0100 
0101   bool isConstant(const MachineFrameInfo *MFI) const override;
0102 
0103   bool isAliased(const MachineFrameInfo *MFI) const override;
0104 
0105   bool mayAlias(const MachineFrameInfo *) const override;
0106 
0107   void printCustom(raw_ostream &OS) const override;
0108 
0109   int getFrameIndex() const { return FI; }
0110 };
0111 
0112 class CallEntryPseudoSourceValue : public PseudoSourceValue {
0113 protected:
0114   CallEntryPseudoSourceValue(unsigned Kind, const TargetMachine &TM);
0115 
0116 public:
0117   bool isConstant(const MachineFrameInfo *) const override;
0118   bool isAliased(const MachineFrameInfo *) const override;
0119   bool mayAlias(const MachineFrameInfo *) const override;
0120 };
0121 
0122 /// A specialized pseudo source value for holding GlobalValue values.
0123 class GlobalValuePseudoSourceValue : public CallEntryPseudoSourceValue {
0124   const GlobalValue *GV;
0125 
0126 public:
0127   GlobalValuePseudoSourceValue(const GlobalValue *GV, const TargetMachine &TM);
0128 
0129   static bool classof(const PseudoSourceValue *V) {
0130     return V->kind() == GlobalValueCallEntry;
0131   }
0132 
0133   const GlobalValue *getValue() const { return GV; }
0134 };
0135 
0136 /// A specialized pseudo source value for holding external symbol values.
0137 class ExternalSymbolPseudoSourceValue : public CallEntryPseudoSourceValue {
0138   const char *ES;
0139 
0140 public:
0141   ExternalSymbolPseudoSourceValue(const char *ES, const TargetMachine &TM);
0142 
0143   static bool classof(const PseudoSourceValue *V) {
0144     return V->kind() == ExternalSymbolCallEntry;
0145   }
0146 
0147   const char *getSymbol() const { return ES; }
0148 };
0149 
0150 } // end namespace llvm
0151 
0152 #endif