Fix for pr2093: direct operands aren't necessarily addresses, so don't
[oota-llvm.git] / include / llvm / Argument.h
1 //===-- llvm/Argument.h - Definition of the Argument class ------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the Argument class. 
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ARGUMENT_H
15 #define LLVM_ARGUMENT_H
16
17 #include "llvm/Value.h"
18
19 namespace llvm {
20
21 template<typename ValueSubClass, typename ItemParentClass>
22   class SymbolTableListTraits;
23
24 /// A class to represent an incoming formal argument to a Function. An argument
25 /// is a very simple Value. It is essentially a named (optional) type. When used
26 /// in the body of a function, it represents the value of the actual argument
27 /// the function was called with.
28 /// @brief LLVM Argument representation  
29 class Argument : public Value {  // Defined in the Function.cpp file
30   Function *Parent;
31
32   Argument *Prev, *Next; // Next and Prev links for our intrusive linked list
33   void setNext(Argument *N) { Next = N; }
34   void setPrev(Argument *N) { Prev = N; }
35   friend class SymbolTableListTraits<Argument, Function>;
36   void setParent(Function *parent);
37
38 public:
39   /// Argument ctor - If Function argument is specified, this argument is
40   /// inserted at the end of the argument list for the function.
41   ///
42   explicit Argument(const Type *Ty, const std::string &Name = "",
43                     Function *F = 0);
44
45   inline const Function *getParent() const { return Parent; }
46   inline       Function *getParent()       { return Parent; }
47
48   /// getArgNo - Return the index of this formal argument in its containing
49   /// function.  For example in "void foo(int a, float b)" a is 0 and b is 1. 
50   unsigned getArgNo() const;
51   
52   /// hasByValAttr - Return true if this argument has the byval attribute on it
53   /// in its containing function.
54   bool hasByValAttr() const;
55
56   /// hasNoAliasAttr - Return true if this argument has the noalias attribute on
57   /// it in its containing function.
58   bool hasNoAliasAttr() const;
59   
60   /// hasSRetAttr - Return true if this argument has the sret attribute on it in
61   /// its containing function.
62   bool hasStructRetAttr() const;
63   
64   virtual void print(std::ostream &OS) const;
65   void print(std::ostream *OS) const {
66     if (OS) print(*OS);
67   }
68
69   /// classof - Methods for support type inquiry through isa, cast, and
70   /// dyn_cast:
71   ///
72   static inline bool classof(const Argument *) { return true; }
73   static inline bool classof(const Value *V) {
74     return V->getValueID() == ArgumentVal;
75   }
76   
77 private:
78   // getNext/Prev - Return the next or previous argument in the list.
79   Argument *getNext()       { return Next; }
80   const Argument *getNext() const { return Next; }
81   Argument *getPrev()       { return Prev; }
82   const Argument *getPrev() const { return Prev; }
83 };
84
85 } // End llvm namespace
86
87 #endif