blob: 611304900f6237256b9d451b4341846cd85e049f [file] [log] [blame]
Daniel Dunbar0dbe2272008-09-08 21:33:45 +00001//===----- 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 Dunbar40a6be62009-02-03 00:07:12 +000018#include <llvm/ADT/FoldingSet.h>
Daniel Dunbar0dbe2272008-09-08 21:33:45 +000019#include "clang/AST/Type.h"
20
Daniel Dunbar46f45b92008-09-09 01:06:48 +000021#include "CGValue.h"
22
Daniel Dunbar0dbe2272008-09-08 21:33:45 +000023namespace llvm {
24 class Function;
Devang Patel761d7f72008-09-25 21:02:23 +000025 struct AttributeWithIndex;
Daniel Dunbar0dbe2272008-09-08 21:33:45 +000026 class Value;
27
28 template<typename T, unsigned> class SmallVector;
29}
30
31namespace clang {
32 class ASTContext;
33 class Decl;
34 class FunctionDecl;
35 class ObjCMethodDecl;
Daniel Dunbar7c086512008-09-09 23:14:03 +000036 class VarDecl;
Daniel Dunbar0dbe2272008-09-08 21:33:45 +000037
38namespace CodeGen {
Devang Patel761d7f72008-09-25 21:02:23 +000039 typedef llvm::SmallVector<llvm::AttributeWithIndex, 8> AttributeListType;
Daniel Dunbar0dbe2272008-09-08 21:33:45 +000040
41 /// CallArgList - Type for representing both the value and type of
42 /// arguments in a call.
Daniel Dunbar46f45b92008-09-09 01:06:48 +000043 typedef llvm::SmallVector<std::pair<RValue, QualType>, 16> CallArgList;
Daniel Dunbar0dbe2272008-09-08 21:33:45 +000044
Daniel Dunbar7c086512008-09-09 23:14:03 +000045 /// 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 Dunbar5323a4b2008-09-10 00:32:18 +000050
Daniel Dunbar0dbe2272008-09-08 21:33:45 +000051 /// CGFunctionInfo - Class to encapsulate the information about a
52 /// function definition.
Daniel Dunbar40a6be62009-02-03 00:07:12 +000053 class CGFunctionInfo : public llvm::FoldingSetNode {
Daniel Dunbar0dbe2272008-09-08 21:33:45 +000054 llvm::SmallVector<QualType, 16> ArgTypes;
55
56 public:
Daniel Dunbara0a99e02009-02-02 23:43:58 +000057 typedef llvm::SmallVector<QualType, 16>::const_iterator arg_iterator;
58
Daniel Dunbar541b63b2009-02-02 23:23:47 +000059 CGFunctionInfo(QualType ResTy,
60 const llvm::SmallVector<QualType, 16> &ArgTys);
Daniel Dunbar0dbe2272008-09-08 21:33:45 +000061
Daniel Dunbara0a99e02009-02-02 23:43:58 +000062 arg_iterator arg_begin() const;
63 arg_iterator arg_end() const;
Daniel Dunbarbb36d332009-02-02 21:43:58 +000064
65 QualType getReturnType() const { return ArgTypes[0]; }
Daniel Dunbar40a6be62009-02-03 00:07:12 +000066
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 Dunbar0dbe2272008-09-08 21:33:45 +000079 };
Daniel Dunbar0dbe2272008-09-08 21:33:45 +000080} // end namespace CodeGen
81} // end namespace clang
82
83#endif