blob: 71573df6799bb5e71473556fae76af7b5f501c64 [file] [log] [blame]
Chris Lattnerbed31442007-05-28 01:07:47 +00001//===--- CodeGenFunction.h - Per-Function state for LLVM CodeGen ----------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Chris Lattner and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This is the internal per-function state used for llvm translation.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef CODEGEN_CODEGENFUNCTION_H
15#define CODEGEN_CODEGENFUNCTION_H
16
Chris Lattnerac248202007-05-30 00:13:02 +000017#include "llvm/ADT/DenseMap.h"
Chris Lattnere73e4322007-07-16 21:28:45 +000018#include "llvm/ADT/SmallVector.h"
Chris Lattner308f4312007-05-29 23:50:05 +000019#include "llvm/Support/LLVMBuilder.h"
Chris Lattner2ccb73b2007-06-16 00:16:26 +000020#include <vector>
Chris Lattner308f4312007-05-29 23:50:05 +000021
Chris Lattnerbed31442007-05-28 01:07:47 +000022namespace llvm {
23 class Module;
Chris Lattner23b7eb62007-06-15 23:05:46 +000024}
25
Chris Lattnerbed31442007-05-28 01:07:47 +000026namespace clang {
27 class ASTContext;
Chris Lattner84915fa2007-06-02 04:16:21 +000028 class Decl;
Chris Lattnerbed31442007-05-28 01:07:47 +000029 class FunctionDecl;
Chris Lattner2ccb73b2007-06-16 00:16:26 +000030 class TargetInfo;
Chris Lattner2ccb73b2007-06-16 00:16:26 +000031 class QualType;
32 class FunctionTypeProto;
Chris Lattner84915fa2007-06-02 04:16:21 +000033
Chris Lattner308f4312007-05-29 23:50:05 +000034 class Stmt;
35 class CompoundStmt;
Chris Lattnerac248202007-05-30 00:13:02 +000036 class LabelStmt;
37 class GotoStmt;
Chris Lattner5269c032007-05-30 21:03:58 +000038 class IfStmt;
Chris Lattner946aa312007-06-05 03:59:43 +000039 class WhileStmt;
Chris Lattner8394d792007-06-05 20:53:16 +000040 class DoStmt;
41 class ForStmt;
Chris Lattner3f3dbee2007-06-02 03:19:07 +000042 class ReturnStmt;
Chris Lattner84915fa2007-06-02 04:16:21 +000043 class DeclStmt;
Chris Lattnerbed31442007-05-28 01:07:47 +000044
Chris Lattner208ae962007-05-30 17:57:17 +000045 class Expr;
Chris Lattnerd7f58862007-06-02 05:24:33 +000046 class DeclRefExpr;
Chris Lattner4347e3692007-06-06 04:54:52 +000047 class StringLiteral;
Chris Lattner208ae962007-05-30 17:57:17 +000048 class IntegerLiteral;
Chris Lattner2ada32e2007-07-09 23:03:16 +000049 class FloatingLiteral;
Chris Lattner6e9d9b32007-07-13 05:18:11 +000050 class CharacterLiteral;
Chris Lattner40480052007-08-03 17:51:03 +000051 class TypesCompatibleExpr;
52
Chris Lattner76ba8492007-08-20 22:37:10 +000053 class ImplicitCastExpr;
Chris Lattner8394d792007-06-05 20:53:16 +000054 class CastExpr;
Chris Lattner2b228c92007-06-15 21:34:29 +000055 class CallExpr;
Chris Lattnerf0106d22007-06-02 19:33:17 +000056 class UnaryOperator;
Chris Lattnerdb91b162007-06-02 00:16:28 +000057 class BinaryOperator;
Chris Lattner9369a562007-06-29 16:31:29 +000058 class CompoundAssignOperator;
Chris Lattnerd9d2fb12007-06-08 23:31:14 +000059 class ArraySubscriptExpr;
Chris Lattnerd268a7a2007-08-03 17:31:20 +000060 class OCUVectorElementExpr;
Chris Lattner6e9d9b32007-07-13 05:18:11 +000061 class ConditionalOperator;
Chris Lattner81a96882007-08-04 00:20:15 +000062 class ChooseExpr;
Anders Carlsson625bfc82007-07-21 05:21:51 +000063 class PreDefinedExpr;
Anders Carlsson76f4a902007-08-21 17:43:55 +000064 class ObjCStringLiteral;
Chris Lattner208ae962007-05-30 17:57:17 +000065
Chris Lattner84915fa2007-06-02 04:16:21 +000066 class BlockVarDecl;
67 class EnumConstantDecl;
Chris Lattner53621a52007-06-13 20:44:40 +000068 class ParmVarDecl;
Chris Lattnerbed31442007-05-28 01:07:47 +000069namespace CodeGen {
70 class CodeGenModule;
71
Chris Lattnerd7f58862007-06-02 05:24:33 +000072
Chris Lattner8394d792007-06-05 20:53:16 +000073/// RValue - This trivial value class is used to represent the result of an
Chris Lattnerd7f58862007-06-02 05:24:33 +000074/// expression that is evaluated. It can be one of two things: either a simple
75/// LLVM SSA value, or the address of an aggregate value in memory. These two
76/// possibilities are discriminated by isAggregate/isScalar.
Chris Lattner8394d792007-06-05 20:53:16 +000077class RValue {
Chris Lattner23b7eb62007-06-15 23:05:46 +000078 llvm::Value *V;
Chris Lattnerdb91b162007-06-02 00:16:28 +000079 // TODO: Encode this into the low bit of pointer for more efficient
80 // return-by-value.
Chris Lattner5269c032007-05-30 21:03:58 +000081 bool IsAggregate;
Chris Lattner09153c02007-06-22 18:48:09 +000082
83 // FIXME: Aggregate rvalues need to retain information about whether they are
84 // volatile or not.
Chris Lattner5269c032007-05-30 21:03:58 +000085public:
86
87 bool isAggregate() const { return IsAggregate; }
88 bool isScalar() const { return !IsAggregate; }
89
90 /// getVal() - Return the Value* of this scalar value.
Chris Lattner23b7eb62007-06-15 23:05:46 +000091 llvm::Value *getVal() const {
Chris Lattner5269c032007-05-30 21:03:58 +000092 assert(!isAggregate() && "Not a scalar!");
93 return V;
94 }
95
Chris Lattner09153c02007-06-22 18:48:09 +000096 /// getAggregateAddr() - Return the Value* of the address of the aggregate.
97 llvm::Value *getAggregateAddr() const {
Chris Lattner5269c032007-05-30 21:03:58 +000098 assert(isAggregate() && "Not an aggregate!");
99 return V;
100 }
Chris Lattner208ae962007-05-30 17:57:17 +0000101
Chris Lattner23b7eb62007-06-15 23:05:46 +0000102 static RValue get(llvm::Value *V) {
Chris Lattner8394d792007-06-05 20:53:16 +0000103 RValue ER;
Chris Lattner208ae962007-05-30 17:57:17 +0000104 ER.V = V;
Chris Lattner5269c032007-05-30 21:03:58 +0000105 ER.IsAggregate = false;
Chris Lattner208ae962007-05-30 17:57:17 +0000106 return ER;
107 }
Chris Lattner23b7eb62007-06-15 23:05:46 +0000108 static RValue getAggregate(llvm::Value *V) {
Chris Lattner8394d792007-06-05 20:53:16 +0000109 RValue ER;
Chris Lattner208ae962007-05-30 17:57:17 +0000110 ER.V = V;
Chris Lattner5269c032007-05-30 21:03:58 +0000111 ER.IsAggregate = true;
Chris Lattner208ae962007-05-30 17:57:17 +0000112 return ER;
113 }
114};
Chris Lattnerd7f58862007-06-02 05:24:33 +0000115
116
117/// LValue - This represents an lvalue references. Because C/C++ allow
118/// bitfields, this is not a simple LLVM pointer, it may be a pointer plus a
119/// bitrange.
120class LValue {
121 // FIXME: Volatility. Restrict?
Chris Lattner8394d792007-06-05 20:53:16 +0000122 // alignment?
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000123
124 enum {
Chris Lattner9e751ca2007-08-02 23:37:31 +0000125 Simple, // This is a normal l-value, use getAddress().
126 VectorElt, // This is a vector element l-value (V[i]), use getVector*
127 BitField, // This is a bitfield l-value, use getBitfield*.
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000128 OCUVectorElt // This is an ocu vector subset, use getOCUVectorComp
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000129 } LVType;
130
Chris Lattnerd7f58862007-06-02 05:24:33 +0000131 llvm::Value *V;
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000132
133 union {
Chris Lattner9e751ca2007-08-02 23:37:31 +0000134 llvm::Value *VectorIdx; // Index into a vector subscript: V[i]
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000135 unsigned VectorElts; // Encoded OCUVector element subset: V.xyx
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000136 };
Chris Lattnerd7f58862007-06-02 05:24:33 +0000137public:
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000138 bool isSimple() const { return LVType == Simple; }
139 bool isVectorElt() const { return LVType == VectorElt; }
140 bool isBitfield() const { return LVType == BitField; }
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000141 bool isOCUVectorElt() const { return LVType == OCUVectorElt; }
Chris Lattner208ae962007-05-30 17:57:17 +0000142
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000143 // simple lvalue
144 llvm::Value *getAddress() const { assert(isSimple()); return V; }
145 // vector elt lvalue
146 llvm::Value *getVectorAddr() const { assert(isVectorElt()); return V; }
147 llvm::Value *getVectorIdx() const { assert(isVectorElt()); return VectorIdx; }
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000148 // ocu vector elements.
149 llvm::Value *getOCUVectorAddr() const { assert(isOCUVectorElt()); return V; }
150 unsigned getOCUVectorElts() const {
151 assert(isOCUVectorElt());
152 return VectorElts;
Chris Lattner9e751ca2007-08-02 23:37:31 +0000153 }
154
Chris Lattnerd7f58862007-06-02 05:24:33 +0000155
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000156 static LValue MakeAddr(llvm::Value *V) {
Chris Lattnerd7f58862007-06-02 05:24:33 +0000157 LValue R;
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000158 R.LVType = Simple;
Chris Lattnerd7f58862007-06-02 05:24:33 +0000159 R.V = V;
160 return R;
161 }
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000162
163 static LValue MakeVectorElt(llvm::Value *Vec, llvm::Value *Idx) {
164 LValue R;
165 R.LVType = VectorElt;
166 R.V = Vec;
167 R.VectorIdx = Idx;
168 return R;
169 }
170
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000171 static LValue MakeOCUVectorElt(llvm::Value *Vec, unsigned Elements) {
Chris Lattner9e751ca2007-08-02 23:37:31 +0000172 LValue R;
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000173 R.LVType = OCUVectorElt;
Chris Lattner9e751ca2007-08-02 23:37:31 +0000174 R.V = Vec;
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000175 R.VectorElts = Elements;
Chris Lattner9e751ca2007-08-02 23:37:31 +0000176 return R;
177 }
Chris Lattnerd7f58862007-06-02 05:24:33 +0000178};
179
Chris Lattnerbed31442007-05-28 01:07:47 +0000180/// CodeGenFunction - This class organizes the per-function state that is used
181/// while generating LLVM code.
182class CodeGenFunction {
183 CodeGenModule &CGM; // Per-module state.
Chris Lattnerd1af2d22007-05-29 23:17:50 +0000184 TargetInfo &Target;
Chris Lattner4758b402007-08-21 04:25:47 +0000185public:
Chris Lattner96d72562007-08-21 16:57:55 +0000186 typedef std::pair<llvm::Value *, llvm::Value *> ComplexPairTy;
Chris Lattner23b7eb62007-06-15 23:05:46 +0000187 llvm::LLVMBuilder Builder;
Chris Lattner3f3dbee2007-06-02 03:19:07 +0000188
189 const FunctionDecl *CurFuncDecl;
Chris Lattnerac248202007-05-30 00:13:02 +0000190 llvm::Function *CurFn;
191
Chris Lattner03df1222007-06-02 04:53:11 +0000192 /// AllocaInsertPoint - This is an instruction in the entry block before which
193 /// we prefer to insert allocas.
194 llvm::Instruction *AllocaInsertPt;
195
Chris Lattner6db1fb82007-06-02 22:49:07 +0000196 const llvm::Type *LLVMIntTy;
Chris Lattnerd9d2fb12007-06-08 23:31:14 +0000197 unsigned LLVMPointerWidth;
Chris Lattner6db1fb82007-06-02 22:49:07 +0000198
Chris Lattner2da04b32007-08-24 05:35:26 +0000199private:
Chris Lattner84915fa2007-06-02 04:16:21 +0000200 /// LocalDeclMap - This keeps track of the LLVM allocas or globals for local C
201 /// decls.
Chris Lattner23b7eb62007-06-15 23:05:46 +0000202 llvm::DenseMap<const Decl*, llvm::Value*> LocalDeclMap;
Chris Lattner84915fa2007-06-02 04:16:21 +0000203
Chris Lattnerac248202007-05-30 00:13:02 +0000204 /// LabelMap - This keeps track of the LLVM basic block for each C label.
Chris Lattner23b7eb62007-06-15 23:05:46 +0000205 llvm::DenseMap<const LabelStmt*, llvm::BasicBlock*> LabelMap;
Chris Lattnere73e4322007-07-16 21:28:45 +0000206
207 // BreakContinueStack - This keeps track of where break and continue
208 // statements should jump to.
209 struct BreakContinue {
210 BreakContinue(llvm::BasicBlock *bb, llvm::BasicBlock *cb)
211 : BreakBlock(bb), ContinueBlock(cb) {}
212
213 llvm::BasicBlock *BreakBlock;
214 llvm::BasicBlock *ContinueBlock;
215 };
216 llvm::SmallVector<BreakContinue, 8> BreakContinueStack;
217
Chris Lattnerbed31442007-05-28 01:07:47 +0000218public:
Chris Lattnerd1af2d22007-05-29 23:17:50 +0000219 CodeGenFunction(CodeGenModule &cgm);
Chris Lattnerbed31442007-05-28 01:07:47 +0000220
Chris Lattner6db1fb82007-06-02 22:49:07 +0000221 ASTContext &getContext() const;
222
Chris Lattner308f4312007-05-29 23:50:05 +0000223 void GenerateCode(const FunctionDecl *FD);
224
Chris Lattnerf033c142007-06-22 19:05:19 +0000225 const llvm::Type *ConvertType(QualType T);
Chris Lattnerac248202007-05-30 00:13:02 +0000226
Chris Lattner54fb19e2007-06-22 22:02:34 +0000227 /// hasAggregateLLVMType - Return true if the specified AST type will map into
228 /// an aggregate LLVM type or is void.
229 static bool hasAggregateLLVMType(QualType T);
230
Chris Lattnerac248202007-05-30 00:13:02 +0000231 /// getBasicBlockForLabel - Return the LLVM basicblock that the specified
232 /// label maps to.
233 llvm::BasicBlock *getBasicBlockForLabel(const LabelStmt *S);
234
235
Chris Lattner23b7eb62007-06-15 23:05:46 +0000236 void EmitBlock(llvm::BasicBlock *BB);
Chris Lattner84915fa2007-06-02 04:16:21 +0000237
Chris Lattnere9a64532007-06-22 21:44:33 +0000238 //===--------------------------------------------------------------------===//
239 // Helpers
240 //===--------------------------------------------------------------------===//
241
242 /// CreateTempAlloca - This creates a alloca and inserts it into the entry
243 /// block.
244 llvm::AllocaInst *CreateTempAlloca(const llvm::Type *Ty,
245 const char *Name = "tmp");
246
Chris Lattner8394d792007-06-05 20:53:16 +0000247 /// EvaluateExprAsBool - Perform the usual unary conversions on the specified
248 /// expression and compare the result against zero, returning an Int1Ty value.
Chris Lattner23b7eb62007-06-15 23:05:46 +0000249 llvm::Value *EvaluateExprAsBool(const Expr *E);
Chris Lattnere9a64532007-06-22 21:44:33 +0000250
Chris Lattnerac248202007-05-30 00:13:02 +0000251
Chris Lattner8394d792007-06-05 20:53:16 +0000252 //===--------------------------------------------------------------------===//
253 // Conversions
254 //===--------------------------------------------------------------------===//
255
256 /// EmitConversion - Convert the value specied by Val, whose type is ValTy, to
257 /// the type specified by DstTy, following the rules of C99 6.3.
Chris Lattnerf033c142007-06-22 19:05:19 +0000258 RValue EmitConversion(RValue Val, QualType ValTy, QualType DstTy);
Chris Lattner8394d792007-06-05 20:53:16 +0000259
260 /// ConvertScalarValueToBool - Convert the specified expression value to a
Chris Lattnerf0106d22007-06-02 19:33:17 +0000261 /// boolean (i1) truth value. This is equivalent to "Val == 0".
Chris Lattner23b7eb62007-06-15 23:05:46 +0000262 llvm::Value *ConvertScalarValueToBool(RValue Val, QualType Ty);
Chris Lattnerf0106d22007-06-02 19:33:17 +0000263
Chris Lattner308f4312007-05-29 23:50:05 +0000264 //===--------------------------------------------------------------------===//
Chris Lattner53621a52007-06-13 20:44:40 +0000265 // Declaration Emission
Chris Lattner84915fa2007-06-02 04:16:21 +0000266 //===--------------------------------------------------------------------===//
267
Chris Lattner1ad38f82007-06-09 01:20:56 +0000268 void EmitDecl(const Decl &D);
Chris Lattner84915fa2007-06-02 04:16:21 +0000269 void EmitEnumConstantDecl(const EnumConstantDecl &D);
Chris Lattner03df1222007-06-02 04:53:11 +0000270 void EmitBlockVarDecl(const BlockVarDecl &D);
271 void EmitLocalBlockVarDecl(const BlockVarDecl &D);
Chris Lattner53621a52007-06-13 20:44:40 +0000272 void EmitParmDecl(const ParmVarDecl &D, llvm::Value *Arg);
Chris Lattner03df1222007-06-02 04:53:11 +0000273
Chris Lattner84915fa2007-06-02 04:16:21 +0000274 //===--------------------------------------------------------------------===//
Chris Lattner308f4312007-05-29 23:50:05 +0000275 // Statement Emission
276 //===--------------------------------------------------------------------===//
277
278 void EmitStmt(const Stmt *S);
279 void EmitCompoundStmt(const CompoundStmt &S);
Chris Lattnerac248202007-05-30 00:13:02 +0000280 void EmitLabelStmt(const LabelStmt &S);
281 void EmitGotoStmt(const GotoStmt &S);
Chris Lattner5269c032007-05-30 21:03:58 +0000282 void EmitIfStmt(const IfStmt &S);
Chris Lattner946aa312007-06-05 03:59:43 +0000283 void EmitWhileStmt(const WhileStmt &S);
Chris Lattner8394d792007-06-05 20:53:16 +0000284 void EmitDoStmt(const DoStmt &S);
285 void EmitForStmt(const ForStmt &S);
Chris Lattner3f3dbee2007-06-02 03:19:07 +0000286 void EmitReturnStmt(const ReturnStmt &S);
Chris Lattner1ad38f82007-06-09 01:20:56 +0000287 void EmitDeclStmt(const DeclStmt &S);
Chris Lattnere73e4322007-07-16 21:28:45 +0000288 void EmitBreakStmt();
289 void EmitContinueStmt();
290
Chris Lattner208ae962007-05-30 17:57:17 +0000291 //===--------------------------------------------------------------------===//
Chris Lattnerd7f58862007-06-02 05:24:33 +0000292 // LValue Expression Emission
293 //===--------------------------------------------------------------------===//
Chris Lattner8394d792007-06-05 20:53:16 +0000294
295 /// EmitLValue - Emit code to compute a designator that specifies the location
296 /// of the expression.
297 ///
298 /// This can return one of two things: a simple address or a bitfield
299 /// reference. In either case, the LLVM Value* in the LValue structure is
300 /// guaranteed to be an LLVM pointer type.
301 ///
302 /// If this returns a bitfield reference, nothing about the pointee type of
303 /// the LLVM value is known: For example, it may not be a pointer to an
304 /// integer.
305 ///
306 /// If this returns a normal address, and if the lvalue's C type is fixed
307 /// size, this method guarantees that the returned pointer type will point to
308 /// an LLVM type of the same size of the lvalue's type. If the lvalue has a
309 /// variable length type, this is not possible.
310 ///
Chris Lattnerd7f58862007-06-02 05:24:33 +0000311 LValue EmitLValue(const Expr *E);
Chris Lattner8394d792007-06-05 20:53:16 +0000312
313 /// EmitLoadOfLValue - Given an expression that represents a value lvalue,
314 /// this method emits the address of the lvalue, then loads the result as an
315 /// rvalue, returning the rvalue.
316 RValue EmitLoadOfLValue(const Expr *E);
Chris Lattner9369a562007-06-29 16:31:29 +0000317 RValue EmitLoadOfLValue(LValue V, QualType LVType);
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000318 RValue EmitLoadOfOCUElementLValue(LValue V, QualType LVType);
Chris Lattner9369a562007-06-29 16:31:29 +0000319
Chris Lattner40ff7012007-08-03 16:18:34 +0000320
Chris Lattner8394d792007-06-05 20:53:16 +0000321 /// EmitStoreThroughLValue - Store the specified rvalue into the specified
322 /// lvalue, where both are guaranteed to the have the same type, and that type
323 /// is 'Ty'.
324 void EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty);
Chris Lattner41d480e2007-08-03 16:28:33 +0000325 void EmitStoreThroughOCUComponentLValue(RValue Src, LValue Dst, QualType Ty);
Chris Lattner8394d792007-06-05 20:53:16 +0000326
Chris Lattnerd7f58862007-06-02 05:24:33 +0000327 LValue EmitDeclRefLValue(const DeclRefExpr *E);
Chris Lattner4347e3692007-06-06 04:54:52 +0000328 LValue EmitStringLiteralLValue(const StringLiteral *E);
Anders Carlsson625bfc82007-07-21 05:21:51 +0000329 LValue EmitPreDefinedLValue(const PreDefinedExpr *E);
Chris Lattner8394d792007-06-05 20:53:16 +0000330 LValue EmitUnaryOpLValue(const UnaryOperator *E);
Chris Lattnerd9d2fb12007-06-08 23:31:14 +0000331 LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E);
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000332 LValue EmitOCUVectorElementExpr(const OCUVectorElementExpr *E);
Chris Lattnerd7f58862007-06-02 05:24:33 +0000333
334 //===--------------------------------------------------------------------===//
Chris Lattner6278e6a2007-08-11 00:04:45 +0000335 // Scalar Expression Emission
Chris Lattner208ae962007-05-30 17:57:17 +0000336 //===--------------------------------------------------------------------===//
337
Chris Lattnercd215f02007-06-29 16:52:55 +0000338 void EmitCompoundAssignmentOperands(const CompoundAssignOperator *CAO,
339 LValue &LHSLV, RValue &LHS, RValue &RHS);
340 RValue EmitCompoundAssignmentResult(const CompoundAssignOperator *E,
341 LValue LHSLV, RValue ResV);
342
Chris Lattner08b15df2007-08-23 23:43:33 +0000343 /// EmitAnyExpr - Emit an expression of any type: scalar, complex, aggregate,
344 /// returning an rvalue corresponding to it. If NeedResult is false, the
345 /// result of the expression doesn't need to be generated into memory.
346 RValue EmitAnyExpr(const Expr *E, bool NeedResult = true);
347
Chris Lattner2b228c92007-06-15 21:34:29 +0000348 RValue EmitCallExpr(const CallExpr *E);
Anders Carlsson1d8e5212007-08-20 18:05:56 +0000349 RValue EmitBuiltinExpr(unsigned builtinID, const CallExpr *E);
Chris Lattner8394d792007-06-05 20:53:16 +0000350
Chris Lattner2da04b32007-08-24 05:35:26 +0000351 llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E);
Anders Carlsson76f4a902007-08-21 17:43:55 +0000352
Chris Lattner6278e6a2007-08-11 00:04:45 +0000353 //===--------------------------------------------------------------------===//
354 // Aggregate Expression Emission
355 //===--------------------------------------------------------------------===//
356
357 void EmitAggregateCopy(llvm::Value *DestPtr, llvm::Value *SrcPtr,
358 QualType EltTy);
359
Chris Lattner2da04b32007-08-24 05:35:26 +0000360 /// EmitScalarExpr - Emit the computation of the specified expression of
361 /// LLVM scalar type, returning the result.
362 llvm::Value *EmitScalarExpr(const Expr *E);
363
Chris Lattner3474c202007-08-26 06:48:56 +0000364 /// EmitScalarConversion - Emit a conversion from the specified type to the
365 /// specified destination type, both of which are LLVM scalar types.
366 llvm::Value *EmitScalarConversion(llvm::Value *Src, QualType SrcTy,
367 QualType DstTy);
368
369
Chris Lattner6278e6a2007-08-11 00:04:45 +0000370 /// EmitAggExpr - Emit the computation of the specified expression of
371 /// aggregate type. The result is computed into DestPtr. Note that if
372 /// DestPtr is null, the value of the aggregate expression is not needed.
373 void EmitAggExpr(const Expr *E, llvm::Value *DestPtr, bool VolatileDest);
Chris Lattnercbfc73b2007-08-21 05:54:00 +0000374
375 /// EmitComplexExpr - Emit the computation of the specified expression of
Chris Lattner08b15df2007-08-23 23:43:33 +0000376 /// complex type, returning the result.
Chris Lattner96d72562007-08-21 16:57:55 +0000377 ComplexPairTy EmitComplexExpr(const Expr *E);
Chris Lattner08b15df2007-08-23 23:43:33 +0000378
379 /// EmitComplexExprIntoAddr - Emit the computation of the specified expression
380 /// of complex type, storing into the specified Value*.
381 void EmitComplexExprIntoAddr(const Expr *E, llvm::Value *DestAddr);
Chris Lattnerbed31442007-05-28 01:07:47 +0000382};
383} // end namespace CodeGen
384} // end namespace clang
Chris Lattnerbed31442007-05-28 01:07:47 +0000385
386#endif