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 byval attribute on it in its
00059   /// containing function.
00060   bool hasByValAttr() const;
00061 
00062   /// \brief Return true if this argument has the byval attribute or inalloca
00063   /// attribute on it in its containing function.  These attributes both
00064   /// represent arguments being passed by value.
00065   bool hasByValOrInAllocaAttr() const;
00066 
00067   /// \brief If this is a byval or inalloca argument, return its alignment.
00068   unsigned getParamAlignment() const;
00069 
00070   /// \brief Return true if this argument has the nest attribute on it in its
00071   /// containing function.
00072   bool hasNestAttr() const;
00073 
00074   /// \brief Return true if this argument has the noalias attribute on it in its
00075   /// containing function.
00076   bool hasNoAliasAttr() const;
00077 
00078   /// \brief Return true if this argument has the nocapture attribute on it in
00079   /// its containing function.
00080   bool hasNoCaptureAttr() const;
00081 
00082   /// \brief Return true if this argument has the sret attribute on it in its
00083   /// containing function.
00084   bool hasStructRetAttr() const;
00085 
00086   /// \brief Return true if this argument has the returned attribute on it in
00087   /// its containing function.
00088   bool hasReturnedAttr() const;
00089 
00090   /// \brief Return true if this argument has the readonly or readnone attribute
00091   /// on it in its containing function.
00092   bool onlyReadsMemory() const;
00093 
00094   /// \brief Return true if this argument has the inalloca attribute on it in
00095   /// its containing function.
00096   bool hasInAllocaAttr() const;
00097 
00098   /// \brief Add a Attribute to an argument.
00099   void addAttr(AttributeSet AS);
00100 
00101   /// \brief Remove a Attribute from an argument.
00102   void removeAttr(AttributeSet AS);
00103 
00104   /// \brief Method for support type inquiry through isa, cast, and
00105   /// dyn_cast.
00106   static inline bool classof(const Value *V) {
00107     return V->getValueID() == ArgumentVal;
00108   }
00109 };
00110 
00111 } // End llvm namespace
00112 
00113 #endif