Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 1 | //===----- CGCall.h - Encapsulate calling convention details ----*- 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 | // These classes wrap the information about a call or function |
| 11 | // definition used to handle ABI compliancy. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef CLANG_CODEGEN_CGCALL_H |
| 16 | #define CLANG_CODEGEN_CGCALL_H |
| 17 | |
Daniel Dunbar | 40a6be6 | 2009-02-03 00:07:12 +0000 | [diff] [blame^] | 18 | #include <llvm/ADT/FoldingSet.h> |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 19 | #include "clang/AST/Type.h" |
| 20 | |
Daniel Dunbar | 46f45b9 | 2008-09-09 01:06:48 +0000 | [diff] [blame] | 21 | #include "CGValue.h" |
| 22 | |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 23 | namespace llvm { |
| 24 | class Function; |
Devang Patel | 761d7f7 | 2008-09-25 21:02:23 +0000 | [diff] [blame] | 25 | struct AttributeWithIndex; |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 26 | class Value; |
| 27 | |
| 28 | template<typename T, unsigned> class SmallVector; |
| 29 | } |
| 30 | |
| 31 | namespace clang { |
| 32 | class ASTContext; |
| 33 | class Decl; |
| 34 | class FunctionDecl; |
| 35 | class ObjCMethodDecl; |
Daniel Dunbar | 7c08651 | 2008-09-09 23:14:03 +0000 | [diff] [blame] | 36 | class VarDecl; |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 37 | |
| 38 | namespace CodeGen { |
Devang Patel | 761d7f7 | 2008-09-25 21:02:23 +0000 | [diff] [blame] | 39 | typedef llvm::SmallVector<llvm::AttributeWithIndex, 8> AttributeListType; |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 40 | |
| 41 | /// CallArgList - Type for representing both the value and type of |
| 42 | /// arguments in a call. |
Daniel Dunbar | 46f45b9 | 2008-09-09 01:06:48 +0000 | [diff] [blame] | 43 | typedef llvm::SmallVector<std::pair<RValue, QualType>, 16> CallArgList; |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 44 | |
Daniel Dunbar | 7c08651 | 2008-09-09 23:14:03 +0000 | [diff] [blame] | 45 | /// FunctionArgList - Type for representing both the decl and type |
| 46 | /// of parameters to a function. The decl must be either a |
| 47 | /// ParmVarDecl or ImplicitParamDecl. |
| 48 | typedef llvm::SmallVector<std::pair<const VarDecl*, QualType>, |
| 49 | 16> FunctionArgList; |
Daniel Dunbar | 5323a4b | 2008-09-10 00:32:18 +0000 | [diff] [blame] | 50 | |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 51 | /// CGFunctionInfo - Class to encapsulate the information about a |
| 52 | /// function definition. |
Daniel Dunbar | 40a6be6 | 2009-02-03 00:07:12 +0000 | [diff] [blame^] | 53 | class CGFunctionInfo : public llvm::FoldingSetNode { |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 54 | llvm::SmallVector<QualType, 16> ArgTypes; |
| 55 | |
| 56 | public: |
Daniel Dunbar | a0a99e0 | 2009-02-02 23:43:58 +0000 | [diff] [blame] | 57 | typedef llvm::SmallVector<QualType, 16>::const_iterator arg_iterator; |
| 58 | |
Daniel Dunbar | 541b63b | 2009-02-02 23:23:47 +0000 | [diff] [blame] | 59 | CGFunctionInfo(QualType ResTy, |
| 60 | const llvm::SmallVector<QualType, 16> &ArgTys); |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 61 | |
Daniel Dunbar | a0a99e0 | 2009-02-02 23:43:58 +0000 | [diff] [blame] | 62 | arg_iterator arg_begin() const; |
| 63 | arg_iterator arg_end() const; |
Daniel Dunbar | bb36d33 | 2009-02-02 21:43:58 +0000 | [diff] [blame] | 64 | |
| 65 | QualType getReturnType() const { return ArgTypes[0]; } |
Daniel Dunbar | 40a6be6 | 2009-02-03 00:07:12 +0000 | [diff] [blame^] | 66 | |
| 67 | void Profile(llvm::FoldingSetNodeID &ID) { |
| 68 | Profile(ID, getReturnType(), arg_begin(), arg_end()); |
| 69 | } |
| 70 | template<class Iterator> |
| 71 | static void Profile(llvm::FoldingSetNodeID &ID, |
| 72 | QualType ResTy, |
| 73 | Iterator begin, |
| 74 | Iterator end) { |
| 75 | ResTy.Profile(ID); |
| 76 | for (; begin != end; ++begin) |
| 77 | begin->Profile(ID); |
| 78 | } |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 79 | }; |
Daniel Dunbar | 0dbe227 | 2008-09-08 21:33:45 +0000 | [diff] [blame] | 80 | } // end namespace CodeGen |
| 81 | } // end namespace clang |
| 82 | |
| 83 | #endif |