LLVM API Documentation
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 = 0); 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 If this is a byval argument, return its alignment. 00063 unsigned getParamAlignment() const; 00064 00065 /// \brief Return true if this argument has the nest attribute on it in its 00066 /// containing function. 00067 bool hasNestAttr() const; 00068 00069 /// \brief Return true if this argument has the noalias attribute on it in its 00070 /// containing function. 00071 bool hasNoAliasAttr() const; 00072 00073 /// \brief Return true if this argument has the nocapture attribute on it in 00074 /// its containing function. 00075 bool hasNoCaptureAttr() const; 00076 00077 /// \brief Return true if this argument has the sret attribute on it in its 00078 /// containing function. 00079 bool hasStructRetAttr() const; 00080 00081 /// \brief Return true if this argument has the returned attribute on it in 00082 /// its containing function. 00083 bool hasReturnedAttr() const; 00084 00085 /// \brief Add a Attribute to an argument. 00086 void addAttr(AttributeSet AS); 00087 00088 /// \brief Remove a Attribute from an argument. 00089 void removeAttr(AttributeSet AS); 00090 00091 /// \brief Method for support type inquiry through isa, cast, and 00092 /// dyn_cast. 00093 static inline bool classof(const Value *V) { 00094 return V->getValueID() == ArgumentVal; 00095 } 00096 }; 00097 00098 } // End llvm namespace 00099 00100 #endif