LLVM API Documentation

Argument.h
Go to the documentation of this file.
00001 //===-- llvm/Argument.h - Definition of the Argument class ------*- 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 declares the Argument class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_IR_ARGUMENT_H
00015 #define LLVM_IR_ARGUMENT_H
00016 
00017 #include "llvm/ADT/Twine.h"
00018 #include "llvm/ADT/ilist_node.h"
00019 #include "llvm/IR/Attributes.h"
00020 #include "llvm/IR/Value.h"
00021 
00022 namespace llvm {
00023 
00024 template<typename ValueSubClass, typename ItemParentClass>
00025   class SymbolTableListTraits;
00026 
00027 /// \brief LLVM Argument representation
00028 ///
00029 /// This class represents an incoming formal argument to a Function. A formal
00030 /// argument, since it is ``formal'', does not contain an actual value but
00031 /// instead represents the type, argument number, and attributes of an argument
00032 /// for a specific function. When used in the body of said function, the
00033 /// argument of course represents the value of the actual argument that the
00034 /// function was called with.
00035 class Argument : public Value, public ilist_node<Argument> {
00036   virtual void anchor();
00037   Function *Parent;
00038 
00039   friend class SymbolTableListTraits<Argument, Function>;
00040   void setParent(Function *parent);
00041 
00042 public:
00043   /// \brief Constructor.
00044   ///
00045   /// If \p F is specified, the argument is inserted at the end of the argument
00046   /// list for \p F.
00047   explicit Argument(Type *Ty, const Twine &Name = "", Function *F = nullptr);
00048 
00049   inline const Function *getParent() const { return Parent; }
00050   inline       Function *getParent()       { return Parent; }
00051 
00052   /// \brief Return the index of this formal argument in its containing
00053   /// function.
00054   ///
00055   /// For example in "void foo(int a, float b)" a is 0 and b is 1.
00056   unsigned getArgNo() const;
00057 
00058   /// \brief Return true if this argument has the nonnull attribute on it in
00059   /// its containing function. Also returns true if at least one byte is known
00060   /// to be dereferenceable and the pointer is in addrspace(0).
00061   bool hasNonNullAttr() const;
00062 
00063   /// \brief If this argument has the dereferenceable attribute on it in its
00064   /// containing function, return the number of bytes known to be
00065   /// dereferenceable. Otherwise, zero is returned.
00066   uint64_t getDereferenceableBytes() const;
00067 
00068   /// \brief Return true if this argument has the byval attribute on it in its
00069   /// containing function.
00070   bool hasByValAttr() const;
00071 
00072   /// \brief Return true if this argument has the byval attribute or inalloca
00073   /// attribute on it in its containing function.  These attributes both
00074   /// represent arguments being passed by value.
00075   bool hasByValOrInAllocaAttr() const;
00076 
00077   /// \brief If this is a byval or inalloca argument, return its alignment.
00078   unsigned getParamAlignment() const;
00079 
00080   /// \brief Return true if this argument has the nest attribute on it in its
00081   /// containing function.
00082   bool hasNestAttr() const;
00083 
00084   /// \brief Return true if this argument has the noalias attribute on it in its
00085   /// containing function.
00086   bool hasNoAliasAttr() const;
00087 
00088   /// \brief Return true if this argument has the nocapture attribute on it in
00089   /// its containing function.
00090   bool hasNoCaptureAttr() const;
00091 
00092   /// \brief Return true if this argument has the sret attribute on it in its
00093   /// containing function.
00094   bool hasStructRetAttr() const;
00095 
00096   /// \brief Return true if this argument has the returned attribute on it in
00097   /// its containing function.
00098   bool hasReturnedAttr() const;
00099 
00100   /// \brief Return true if this argument has the readonly or readnone attribute
00101   /// on it in its containing function.
00102   bool onlyReadsMemory() const;
00103 
00104   /// \brief Return true if this argument has the inalloca attribute on it in
00105   /// its containing function.
00106   bool hasInAllocaAttr() const;
00107 
00108   /// \brief Return true if this argument has the zext attribute on it in its
00109   /// containing function.
00110   bool hasZExtAttr() const;
00111 
00112   /// \brief Return true if this argument has the sext attribute on it in its
00113   /// containing function.
00114   bool hasSExtAttr() const;
00115 
00116   /// \brief Add a Attribute to an argument.
00117   void addAttr(AttributeSet AS);
00118 
00119   /// \brief Remove a Attribute from an argument.
00120   void removeAttr(AttributeSet AS);
00121 
00122   /// \brief Method for support type inquiry through isa, cast, and
00123   /// dyn_cast.
00124   static inline bool classof(const Value *V) {
00125     return V->getValueID() == ArgumentVal;
00126   }
00127 };
00128 
00129 } // End llvm namespace
00130 
00131 #endif