Move SLEB/ULEB size calculation routines from AsmPrinter to TargetAsmInfo. This makes...
[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 #include "llvm/ParameterAttributes.h"
19
20 namespace llvm {
21
22 template<typename ValueSubClass, typename ItemParentClass>
23   class SymbolTableListTraits;
24
25 /// A class to represent an incoming formal argument to a Function. An argument
26 /// is a very simple Value. It is essentially a named (optional) type. When used
27 /// in the body of a function, it represents the value of the actual argument
28 /// the function was called with.
29 /// @brief LLVM Argument representation  
30 class Argument : public Value, public ilist_node<Argument> {
31   Function *Parent;
32
33   friend class SymbolTableListTraits<Argument, Function>;
34   void setParent(Function *parent);
35
36 public:
37   /// Argument ctor - If Function argument is specified, this argument is
38   /// inserted at the end of the argument list for the function.
39   ///
40   explicit Argument(const Type *Ty, const std::string &Name = "",
41                     Function *F = 0);
42
43   inline const Function *getParent() const { return Parent; }
44   inline       Function *getParent()       { return Parent; }
45
46   /// getArgNo - Return the index of this formal argument in its containing
47   /// function.  For example in "void foo(int a, float b)" a is 0 and b is 1. 
48   unsigned getArgNo() const;
49   
50   /// hasByValAttr - Return true if this argument has the byval attribute on it
51   /// in its containing function.
52   bool hasByValAttr() const;
53
54   /// hasNoAliasAttr - Return true if this argument has the noalias attribute on
55   /// it in its containing function.
56   bool hasNoAliasAttr() const;
57   
58   /// hasSRetAttr - Return true if this argument has the sret attribute on it in
59   /// its containing function.
60   bool hasStructRetAttr() const;
61
62   /// addAttr - Add a ParamAttr to an argument
63   void addAttr(ParameterAttributes);
64   
65   /// removeAttr - Remove a ParamAttr from an argument
66   void removeAttr(ParameterAttributes);
67
68   virtual void print(std::ostream &OS) const;
69   void print(std::ostream *OS) const {
70     if (OS) print(*OS);
71   }
72
73   /// classof - Methods for support type inquiry through isa, cast, and
74   /// dyn_cast:
75   ///
76   static inline bool classof(const Argument *) { return true; }
77   static inline bool classof(const Value *V) {
78     return V->getValueID() == ArgumentVal;
79   }
80 };
81
82 } // End llvm namespace
83
84 #endif