 |
|
 |
|
| Files: |
1 |
|
Branches Taken: |
80.0% |
4 / 5 |
| Generated: |
2010-02-10 01:31 |
|
Branches Executed: |
100.0% |
5 / 5 |
| |
|
Line Coverage: |
100.0% |
36 / 36 |
| |
 |
|
 |
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 :
18 : #include "llvm/ADT/FoldingSet.h"
19 : #include "llvm/Value.h"
20 : #include "clang/AST/Type.h"
21 :
22 : #include "CGValue.h"
23 :
24 : // FIXME: Restructure so we don't have to expose so much stuff.
25 : #include "ABIInfo.h"
26 :
27 : namespace llvm {
28 : struct AttributeWithIndex;
29 : class Function;
30 : class Type;
31 : class Value;
32 :
33 : template<typename T, unsigned> class SmallVector;
34 : }
35 :
36 : namespace clang {
37 : class ASTContext;
38 : class Decl;
39 : class FunctionDecl;
40 : class ObjCMethodDecl;
41 : class VarDecl;
42 :
43 : namespace CodeGen {
44 : typedef llvm::SmallVector<llvm::AttributeWithIndex, 8> AttributeListType;
45 :
46 : /// CallArgList - Type for representing both the value and type of
47 : /// arguments in a call.
48 : typedef llvm::SmallVector<std::pair<RValue, QualType>, 16> CallArgList;
49 :
50 : /// FunctionArgList - Type for representing both the decl and type
51 : /// of parameters to a function. The decl must be either a
52 : /// ParmVarDecl or ImplicitParamDecl.
53 : typedef llvm::SmallVector<std::pair<const VarDecl*, QualType>,
54 : 16> FunctionArgList;
55 :
56 : /// CGFunctionInfo - Class to encapsulate the information about a
57 : /// function definition.
58 : class CGFunctionInfo : public llvm::FoldingSetNode {
59 6632: struct ArgInfo {
60 : QualType type;
61 : ABIArgInfo info;
62 : };
63 :
64 : /// The LLVM::CallingConv to use for this function (as specified by the
65 : /// user).
66 : unsigned CallingConvention;
67 :
68 : /// The LLVM::CallingConv to actually use for this function, which may
69 : /// depend on the ABI.
70 : unsigned EffectiveCallingConvention;
71 :
72 : /// Whether this function is noreturn.
73 : bool NoReturn;
74 :
75 : unsigned NumArgs;
76 : ArgInfo *Args;
77 :
78 : public:
79 : typedef const ArgInfo *const_arg_iterator;
80 : typedef ArgInfo *arg_iterator;
81 :
82 : CGFunctionInfo(unsigned CallingConvention,
83 : bool NoReturn,
84 : QualType ResTy,
85 : const llvm::SmallVector<QualType, 16> &ArgTys);
2818: branch 0 taken
0: branch 1 not taken
86 2818: ~CGFunctionInfo() { delete[] Args; }
87 :
88 17752: const_arg_iterator arg_begin() const { return Args + 1; }
89 11821: const_arg_iterator arg_end() const { return Args + 1 + NumArgs; }
90 16313: arg_iterator arg_begin() { return Args + 1; }
91 16313: arg_iterator arg_end() { return Args + 1 + NumArgs; }
92 :
93 5927: unsigned arg_size() const { return NumArgs; }
94 :
95 6161: bool isNoReturn() const { return NoReturn; }
96 :
97 : /// getCallingConvention - Return the user specified calling
98 : /// convention.
99 13431: unsigned getCallingConvention() const { return CallingConvention; }
100 :
101 : /// getEffectiveCallingConvention - Return the actual calling convention to
102 : /// use, which may depend on the ABI.
103 6161: unsigned getEffectiveCallingConvention() const {
104 6161: return EffectiveCallingConvention;
105 : }
106 73: void setEffectiveCallingConvention(unsigned Value) {
107 73: EffectiveCallingConvention = Value;
108 73: }
109 :
110 32071: QualType getReturnType() const { return Args[0].type; }
111 :
112 3927: ABIArgInfo &getReturnInfo() { return Args[0].info; }
113 22850: const ABIArgInfo &getReturnInfo() const { return Args[0].info; }
114 :
115 13431: void Profile(llvm::FoldingSetNodeID &ID) {
116 13431: ID.AddInteger(getCallingConvention());
117 13431: ID.AddBoolean(NoReturn);
118 13431: getReturnType().Profile(ID);
15372: branch 2 taken
13431: branch 3 taken
119 28803: for (arg_iterator it = arg_begin(), ie = arg_end(); it != ie; ++it)
120 15372: it->type.Profile(ID);
121 13431: }
122 : template<class Iterator>
123 : static void Profile(llvm::FoldingSetNodeID &ID,
124 : unsigned CallingConvention,
125 : bool NoReturn,
126 : QualType ResTy,
127 : Iterator begin,
128 14606: Iterator end) {
129 14606: ID.AddInteger(CallingConvention);
130 14606: ID.AddBoolean(NoReturn);
131 14606: ResTy.Profile(ID);
16803: branch 0 taken
132 31409: for (; begin != end; ++begin)
133 16803: begin->Profile(ID);
134 14606: }
135 : };
136 :
137 : /// ReturnValueSlot - Contains the address where the return value of a
138 : /// function can be stored, and whether the address is volatile or not.
139 : class ReturnValueSlot {
140 : llvm::PointerIntPair<llvm::Value *, 1, bool> Value;
141 :
142 : public:
143 3624: ReturnValueSlot() {}
144 36: ReturnValueSlot(llvm::Value *Value, bool IsVolatile)
145 36: : Value(Value, IsVolatile) {}
146 :
147 : bool isNull() const { return !getValue(); }
148 :
149 36: bool isVolatile() const { return Value.getInt(); }
150 92: llvm::Value *getValue() const { return Value.getPointer(); }
151 : };
152 :
153 : } // end namespace CodeGen
154 : } // end namespace clang
155 :
156 : #endif
Generated: 2010-02-10 01:31 by zcov