blob: fd6eb481598e16dc21a73fe0b831c9c26369e93d [file] [log] [blame]
Daniel Dunbara8f02052008-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
18#include "clang/AST/Type.h"
19
Daniel Dunbar0a2da0f2008-09-09 01:06:48 +000020#include "CGValue.h"
21
Daniel Dunbara8f02052008-09-08 21:33:45 +000022namespace llvm {
23 class Function;
Devang Patela85a9ef2008-09-25 21:02:23 +000024 struct AttributeWithIndex;
Daniel Dunbara8f02052008-09-08 21:33:45 +000025 class Value;
26
27 template<typename T, unsigned> class SmallVector;
28}
29
30namespace clang {
31 class ASTContext;
32 class Decl;
33 class FunctionDecl;
34 class ObjCMethodDecl;
Daniel Dunbar96816832008-09-09 23:14:03 +000035 class VarDecl;
Daniel Dunbara8f02052008-09-08 21:33:45 +000036
37namespace CodeGen {
Devang Patela85a9ef2008-09-25 21:02:23 +000038 typedef llvm::SmallVector<llvm::AttributeWithIndex, 8> AttributeListType;
Daniel Dunbara8f02052008-09-08 21:33:45 +000039
40 /// CallArgList - Type for representing both the value and type of
41 /// arguments in a call.
Daniel Dunbar0a2da0f2008-09-09 01:06:48 +000042 typedef llvm::SmallVector<std::pair<RValue, QualType>, 16> CallArgList;
Daniel Dunbara8f02052008-09-08 21:33:45 +000043
Daniel Dunbar96816832008-09-09 23:14:03 +000044 /// FunctionArgList - Type for representing both the decl and type
45 /// of parameters to a function. The decl must be either a
46 /// ParmVarDecl or ImplicitParamDecl.
47 typedef llvm::SmallVector<std::pair<const VarDecl*, QualType>,
48 16> FunctionArgList;
Daniel Dunbarbccb0682008-09-10 00:32:18 +000049
50 // FIXME: This should be a better iterator type so that we can avoid
51 // construction of the ArgTypes smallvectors.
52 typedef llvm::SmallVector<QualType, 16>::const_iterator ArgTypeIterator;
Daniel Dunbar96816832008-09-09 23:14:03 +000053
Daniel Dunbara8f02052008-09-08 21:33:45 +000054 /// CGFunctionInfo - Class to encapsulate the information about a
55 /// function definition.
56 class CGFunctionInfo {
Daniel Dunbar3ad1f072008-09-10 04:01:49 +000057 bool IsVariadic;
Daniel Dunbara8f02052008-09-08 21:33:45 +000058
59 llvm::SmallVector<QualType, 16> ArgTypes;
60
61 public:
Daniel Dunbar3ad1f072008-09-10 04:01:49 +000062 CGFunctionInfo(const FunctionTypeNoProto *FTNP);
63 CGFunctionInfo(const FunctionTypeProto *FTP);
Daniel Dunbara8f02052008-09-08 21:33:45 +000064 CGFunctionInfo(const FunctionDecl *FD);
65 CGFunctionInfo(const ObjCMethodDecl *MD,
66 const ASTContext &Context);
Daniel Dunbarebbb8f32009-01-31 02:19:00 +000067 CGFunctionInfo(QualType ResTy, const CallArgList &Args,
68 bool _IsVariadic);
Daniel Dunbara8f02052008-09-08 21:33:45 +000069
Daniel Dunbar3ad1f072008-09-10 04:01:49 +000070 bool isVariadic() const { return IsVariadic; }
Daniel Dunbara8f02052008-09-08 21:33:45 +000071
Daniel Dunbarbccb0682008-09-10 00:32:18 +000072 ArgTypeIterator argtypes_begin() const;
73 ArgTypeIterator argtypes_end() const;
Daniel Dunbara8f02052008-09-08 21:33:45 +000074 };
Daniel Dunbara8f02052008-09-08 21:33:45 +000075} // end namespace CodeGen
76} // end namespace clang
77
78#endif