1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===-- llvm/Argument.h - Definition of the Argument class ------*- C++ -*-===// 2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// The LLVM Compiler Infrastructure 4894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 5894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file is distributed under the University of Illinois Open Source 6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// License. See LICENSE.TXT for details. 7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===// 9894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 10894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// This file declares the Argument class. 11894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 12894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman//===----------------------------------------------------------------------===// 13894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifndef LLVM_ARGUMENT_H 15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#define LLVM_ARGUMENT_H 16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Value.h" 18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/Attributes.h" 19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/ADT/ilist_node.h" 20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "llvm/ADT/Twine.h" 21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumannamespace llvm { 23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 24894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumantemplate<typename ValueSubClass, typename ItemParentClass> 25894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman class SymbolTableListTraits; 26894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 27894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// A class to represent an incoming formal argument to a Function. An argument 28894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// is a very simple Value. It is essentially a named (optional) type. When used 29894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// in the body of a function, it represents the value of the actual argument 30894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// the function was called with. 31894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/// @brief LLVM Argument representation 32894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanclass Argument : public Value, public ilist_node<Argument> { 33894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman Function *Parent; 34894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 35894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman friend class SymbolTableListTraits<Argument, Function>; 36894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void setParent(Function *parent); 37894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumanpublic: 39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// Argument ctor - If Function argument is specified, this argument is 40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// inserted at the end of the argument list for the function. 41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// 4219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman explicit Argument(Type *Ty, const Twine &Name = "", Function *F = 0); 43894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 44894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman inline const Function *getParent() const { return Parent; } 45894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman inline Function *getParent() { return Parent; } 46894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 47894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// getArgNo - Return the index of this formal argument in its containing 48894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// function. For example in "void foo(int a, float b)" a is 0 and b is 1. 49894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman unsigned getArgNo() const; 50894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 51894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// hasByValAttr - Return true if this argument has the byval attribute on it 52894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// in its containing function. 53894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool hasByValAttr() const; 5419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 5519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman /// getParamAlignment - If this is a byval argument, return its alignment. 5619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman unsigned getParamAlignment() const; 57894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 58894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// hasNestAttr - Return true if this argument has the nest attribute on 59894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// it in its containing function. 60894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool hasNestAttr() const; 61894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 62894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// hasNoAliasAttr - Return true if this argument has the noalias attribute on 63894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// it in its containing function. 64894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool hasNoAliasAttr() const; 65894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 66894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// hasNoCaptureAttr - Return true if this argument has the nocapture 67894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// attribute on it in its containing function. 68894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool hasNoCaptureAttr() const; 69894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 70894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// hasSRetAttr - Return true if this argument has the sret attribute on it in 71894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// its containing function. 72894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool hasStructRetAttr() const; 73894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 74894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// addAttr - Add a Attribute to an argument 75894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void addAttr(Attributes); 76894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 77894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// removeAttr - Remove a Attribute from an argument 78894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void removeAttr(Attributes); 79894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 80894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// classof - Methods for support type inquiry through isa, cast, and 81894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// dyn_cast: 82894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman /// 83894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman static inline bool classof(const Argument *) { return true; } 84894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman static inline bool classof(const Value *V) { 85894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return V->getValueID() == ArgumentVal; 86894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 87894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman}; 88894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 89894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} // End llvm namespace 90894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 91894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif 92