blob: 3235034a0bac96a78a391fd1339a63c3912bce3d [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 Lattner8394d792007-06-05 20:53:16 +000051 class CastExpr;
Chris Lattner2b228c92007-06-15 21:34:29 +000052 class CallExpr;
Chris Lattnerf0106d22007-06-02 19:33:17 +000053 class UnaryOperator;
Chris Lattnerdb91b162007-06-02 00:16:28 +000054 class BinaryOperator;
Chris Lattner9369a562007-06-29 16:31:29 +000055 class CompoundAssignOperator;
Chris Lattnerd9d2fb12007-06-08 23:31:14 +000056 class ArraySubscriptExpr;
Chris Lattnerd268a7a2007-08-03 17:31:20 +000057 class OCUVectorElementExpr;
Chris Lattner6e9d9b32007-07-13 05:18:11 +000058 class ConditionalOperator;
Anders Carlsson625bfc82007-07-21 05:21:51 +000059 class PreDefinedExpr;
Chris Lattner208ae962007-05-30 17:57:17 +000060
Chris Lattner84915fa2007-06-02 04:16:21 +000061 class BlockVarDecl;
62 class EnumConstantDecl;
Chris Lattner53621a52007-06-13 20:44:40 +000063 class ParmVarDecl;
Chris Lattnerbed31442007-05-28 01:07:47 +000064namespace CodeGen {
65 class CodeGenModule;
66
Chris Lattnerd7f58862007-06-02 05:24:33 +000067
Chris Lattner8394d792007-06-05 20:53:16 +000068/// RValue - This trivial value class is used to represent the result of an
Chris Lattnerd7f58862007-06-02 05:24:33 +000069/// expression that is evaluated. It can be one of two things: either a simple
70/// LLVM SSA value, or the address of an aggregate value in memory. These two
71/// possibilities are discriminated by isAggregate/isScalar.
Chris Lattner8394d792007-06-05 20:53:16 +000072class RValue {
Chris Lattner23b7eb62007-06-15 23:05:46 +000073 llvm::Value *V;
Chris Lattnerdb91b162007-06-02 00:16:28 +000074 // TODO: Encode this into the low bit of pointer for more efficient
75 // return-by-value.
Chris Lattner5269c032007-05-30 21:03:58 +000076 bool IsAggregate;
Chris Lattner09153c02007-06-22 18:48:09 +000077
78 // FIXME: Aggregate rvalues need to retain information about whether they are
79 // volatile or not.
Chris Lattner5269c032007-05-30 21:03:58 +000080public:
81
82 bool isAggregate() const { return IsAggregate; }
83 bool isScalar() const { return !IsAggregate; }
84
85 /// getVal() - Return the Value* of this scalar value.
Chris Lattner23b7eb62007-06-15 23:05:46 +000086 llvm::Value *getVal() const {
Chris Lattner5269c032007-05-30 21:03:58 +000087 assert(!isAggregate() && "Not a scalar!");
88 return V;
89 }
90
Chris Lattner09153c02007-06-22 18:48:09 +000091 /// getAggregateAddr() - Return the Value* of the address of the aggregate.
92 llvm::Value *getAggregateAddr() const {
Chris Lattner5269c032007-05-30 21:03:58 +000093 assert(isAggregate() && "Not an aggregate!");
94 return V;
95 }
Chris Lattner208ae962007-05-30 17:57:17 +000096
Chris Lattner23b7eb62007-06-15 23:05:46 +000097 static RValue get(llvm::Value *V) {
Chris Lattner8394d792007-06-05 20:53:16 +000098 RValue ER;
Chris Lattner208ae962007-05-30 17:57:17 +000099 ER.V = V;
Chris Lattner5269c032007-05-30 21:03:58 +0000100 ER.IsAggregate = false;
Chris Lattner208ae962007-05-30 17:57:17 +0000101 return ER;
102 }
Chris Lattner23b7eb62007-06-15 23:05:46 +0000103 static RValue getAggregate(llvm::Value *V) {
Chris Lattner8394d792007-06-05 20:53:16 +0000104 RValue ER;
Chris Lattner208ae962007-05-30 17:57:17 +0000105 ER.V = V;
Chris Lattner5269c032007-05-30 21:03:58 +0000106 ER.IsAggregate = true;
Chris Lattner208ae962007-05-30 17:57:17 +0000107 return ER;
108 }
109};
Chris Lattnerd7f58862007-06-02 05:24:33 +0000110
111
112/// LValue - This represents an lvalue references. Because C/C++ allow
113/// bitfields, this is not a simple LLVM pointer, it may be a pointer plus a
114/// bitrange.
115class LValue {
116 // FIXME: Volatility. Restrict?
Chris Lattner8394d792007-06-05 20:53:16 +0000117 // alignment?
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000118
119 enum {
Chris Lattner9e751ca2007-08-02 23:37:31 +0000120 Simple, // This is a normal l-value, use getAddress().
121 VectorElt, // This is a vector element l-value (V[i]), use getVector*
122 BitField, // This is a bitfield l-value, use getBitfield*.
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000123 OCUVectorElt // This is an ocu vector subset, use getOCUVectorComp
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000124 } LVType;
125
Chris Lattnerd7f58862007-06-02 05:24:33 +0000126 llvm::Value *V;
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000127
128 union {
Chris Lattner9e751ca2007-08-02 23:37:31 +0000129 llvm::Value *VectorIdx; // Index into a vector subscript: V[i]
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000130 unsigned VectorElts; // Encoded OCUVector element subset: V.xyx
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000131 };
Chris Lattnerd7f58862007-06-02 05:24:33 +0000132public:
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000133 bool isSimple() const { return LVType == Simple; }
134 bool isVectorElt() const { return LVType == VectorElt; }
135 bool isBitfield() const { return LVType == BitField; }
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000136 bool isOCUVectorElt() const { return LVType == OCUVectorElt; }
Chris Lattner208ae962007-05-30 17:57:17 +0000137
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000138 // simple lvalue
139 llvm::Value *getAddress() const { assert(isSimple()); return V; }
140 // vector elt lvalue
141 llvm::Value *getVectorAddr() const { assert(isVectorElt()); return V; }
142 llvm::Value *getVectorIdx() const { assert(isVectorElt()); return VectorIdx; }
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000143 // ocu vector elements.
144 llvm::Value *getOCUVectorAddr() const { assert(isOCUVectorElt()); return V; }
145 unsigned getOCUVectorElts() const {
146 assert(isOCUVectorElt());
147 return VectorElts;
Chris Lattner9e751ca2007-08-02 23:37:31 +0000148 }
149
Chris Lattnerd7f58862007-06-02 05:24:33 +0000150
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000151 static LValue MakeAddr(llvm::Value *V) {
Chris Lattnerd7f58862007-06-02 05:24:33 +0000152 LValue R;
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000153 R.LVType = Simple;
Chris Lattnerd7f58862007-06-02 05:24:33 +0000154 R.V = V;
155 return R;
156 }
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000157
158 static LValue MakeVectorElt(llvm::Value *Vec, llvm::Value *Idx) {
159 LValue R;
160 R.LVType = VectorElt;
161 R.V = Vec;
162 R.VectorIdx = Idx;
163 return R;
164 }
165
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000166 static LValue MakeOCUVectorElt(llvm::Value *Vec, unsigned Elements) {
Chris Lattner9e751ca2007-08-02 23:37:31 +0000167 LValue R;
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000168 R.LVType = OCUVectorElt;
Chris Lattner9e751ca2007-08-02 23:37:31 +0000169 R.V = Vec;
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000170 R.VectorElts = Elements;
Chris Lattner9e751ca2007-08-02 23:37:31 +0000171 return R;
172 }
Chris Lattnerd7f58862007-06-02 05:24:33 +0000173};
174
Chris Lattnerbed31442007-05-28 01:07:47 +0000175/// CodeGenFunction - This class organizes the per-function state that is used
176/// while generating LLVM code.
177class CodeGenFunction {
178 CodeGenModule &CGM; // Per-module state.
Chris Lattnerd1af2d22007-05-29 23:17:50 +0000179 TargetInfo &Target;
Chris Lattner23b7eb62007-06-15 23:05:46 +0000180 llvm::LLVMBuilder Builder;
Chris Lattner3f3dbee2007-06-02 03:19:07 +0000181
182 const FunctionDecl *CurFuncDecl;
Chris Lattnerac248202007-05-30 00:13:02 +0000183 llvm::Function *CurFn;
184
Chris Lattner03df1222007-06-02 04:53:11 +0000185 /// AllocaInsertPoint - This is an instruction in the entry block before which
186 /// we prefer to insert allocas.
187 llvm::Instruction *AllocaInsertPt;
188
Chris Lattner6db1fb82007-06-02 22:49:07 +0000189 const llvm::Type *LLVMIntTy;
Chris Lattnerd9d2fb12007-06-08 23:31:14 +0000190 unsigned LLVMPointerWidth;
Chris Lattner6db1fb82007-06-02 22:49:07 +0000191
Chris Lattner84915fa2007-06-02 04:16:21 +0000192 /// LocalDeclMap - This keeps track of the LLVM allocas or globals for local C
193 /// decls.
Chris Lattner23b7eb62007-06-15 23:05:46 +0000194 llvm::DenseMap<const Decl*, llvm::Value*> LocalDeclMap;
Chris Lattner84915fa2007-06-02 04:16:21 +0000195
Chris Lattnerac248202007-05-30 00:13:02 +0000196 /// LabelMap - This keeps track of the LLVM basic block for each C label.
Chris Lattner23b7eb62007-06-15 23:05:46 +0000197 llvm::DenseMap<const LabelStmt*, llvm::BasicBlock*> LabelMap;
Chris Lattnere73e4322007-07-16 21:28:45 +0000198
199 // BreakContinueStack - This keeps track of where break and continue
200 // statements should jump to.
201 struct BreakContinue {
202 BreakContinue(llvm::BasicBlock *bb, llvm::BasicBlock *cb)
203 : BreakBlock(bb), ContinueBlock(cb) {}
204
205 llvm::BasicBlock *BreakBlock;
206 llvm::BasicBlock *ContinueBlock;
207 };
208 llvm::SmallVector<BreakContinue, 8> BreakContinueStack;
209
Chris Lattnerbed31442007-05-28 01:07:47 +0000210public:
Chris Lattnerd1af2d22007-05-29 23:17:50 +0000211 CodeGenFunction(CodeGenModule &cgm);
Chris Lattnerbed31442007-05-28 01:07:47 +0000212
Chris Lattner6db1fb82007-06-02 22:49:07 +0000213 ASTContext &getContext() const;
214
Chris Lattner308f4312007-05-29 23:50:05 +0000215 void GenerateCode(const FunctionDecl *FD);
216
Chris Lattnerf033c142007-06-22 19:05:19 +0000217 const llvm::Type *ConvertType(QualType T);
Chris Lattnerac248202007-05-30 00:13:02 +0000218
Chris Lattner54fb19e2007-06-22 22:02:34 +0000219 /// hasAggregateLLVMType - Return true if the specified AST type will map into
220 /// an aggregate LLVM type or is void.
221 static bool hasAggregateLLVMType(QualType T);
222
Chris Lattnerac248202007-05-30 00:13:02 +0000223 /// getBasicBlockForLabel - Return the LLVM basicblock that the specified
224 /// label maps to.
225 llvm::BasicBlock *getBasicBlockForLabel(const LabelStmt *S);
226
227
Chris Lattner23b7eb62007-06-15 23:05:46 +0000228 void EmitBlock(llvm::BasicBlock *BB);
Chris Lattner84915fa2007-06-02 04:16:21 +0000229
Chris Lattnere9a64532007-06-22 21:44:33 +0000230 //===--------------------------------------------------------------------===//
231 // Helpers
232 //===--------------------------------------------------------------------===//
233
234 /// CreateTempAlloca - This creates a alloca and inserts it into the entry
235 /// block.
236 llvm::AllocaInst *CreateTempAlloca(const llvm::Type *Ty,
237 const char *Name = "tmp");
238
Chris Lattner8394d792007-06-05 20:53:16 +0000239 /// EvaluateExprAsBool - Perform the usual unary conversions on the specified
240 /// expression and compare the result against zero, returning an Int1Ty value.
Chris Lattner23b7eb62007-06-15 23:05:46 +0000241 llvm::Value *EvaluateExprAsBool(const Expr *E);
Chris Lattnere9a64532007-06-22 21:44:33 +0000242
Chris Lattnerac248202007-05-30 00:13:02 +0000243
Chris Lattnere9a64532007-06-22 21:44:33 +0000244 /// EmitLoadOfComplex - Given an RValue reference for a complex, emit code to
245 /// load the real and imaginary pieces, returning them as Real/Imag.
246 void EmitLoadOfComplex(RValue V, llvm::Value *&Real, llvm::Value *&Imag);
247
248 /// EmitStoreOfComplex - Store the specified real/imag parts into the
249 /// specified value pointer.
250 void EmitStoreOfComplex(llvm::Value *Real, llvm::Value *Imag,
251 llvm::Value *ResPtr);
252
Chris Lattner8394d792007-06-05 20:53:16 +0000253 //===--------------------------------------------------------------------===//
254 // Conversions
255 //===--------------------------------------------------------------------===//
256
257 /// EmitConversion - Convert the value specied by Val, whose type is ValTy, to
258 /// the type specified by DstTy, following the rules of C99 6.3.
Chris Lattnerf033c142007-06-22 19:05:19 +0000259 RValue EmitConversion(RValue Val, QualType ValTy, QualType DstTy);
Chris Lattner8394d792007-06-05 20:53:16 +0000260
261 /// ConvertScalarValueToBool - Convert the specified expression value to a
Chris Lattnerf0106d22007-06-02 19:33:17 +0000262 /// boolean (i1) truth value. This is equivalent to "Val == 0".
Chris Lattner23b7eb62007-06-15 23:05:46 +0000263 llvm::Value *ConvertScalarValueToBool(RValue Val, QualType Ty);
Chris Lattnerf0106d22007-06-02 19:33:17 +0000264
Chris Lattner308f4312007-05-29 23:50:05 +0000265 //===--------------------------------------------------------------------===//
Chris Lattner53621a52007-06-13 20:44:40 +0000266 // Declaration Emission
Chris Lattner84915fa2007-06-02 04:16:21 +0000267 //===--------------------------------------------------------------------===//
268
Chris Lattner1ad38f82007-06-09 01:20:56 +0000269 void EmitDecl(const Decl &D);
Chris Lattner84915fa2007-06-02 04:16:21 +0000270 void EmitEnumConstantDecl(const EnumConstantDecl &D);
Chris Lattner03df1222007-06-02 04:53:11 +0000271 void EmitBlockVarDecl(const BlockVarDecl &D);
272 void EmitLocalBlockVarDecl(const BlockVarDecl &D);
Chris Lattner53621a52007-06-13 20:44:40 +0000273 void EmitParmDecl(const ParmVarDecl &D, llvm::Value *Arg);
Chris Lattner03df1222007-06-02 04:53:11 +0000274
Chris Lattner84915fa2007-06-02 04:16:21 +0000275 //===--------------------------------------------------------------------===//
Chris Lattner308f4312007-05-29 23:50:05 +0000276 // Statement Emission
277 //===--------------------------------------------------------------------===//
278
279 void EmitStmt(const Stmt *S);
280 void EmitCompoundStmt(const CompoundStmt &S);
Chris Lattnerac248202007-05-30 00:13:02 +0000281 void EmitLabelStmt(const LabelStmt &S);
282 void EmitGotoStmt(const GotoStmt &S);
Chris Lattner5269c032007-05-30 21:03:58 +0000283 void EmitIfStmt(const IfStmt &S);
Chris Lattner946aa312007-06-05 03:59:43 +0000284 void EmitWhileStmt(const WhileStmt &S);
Chris Lattner8394d792007-06-05 20:53:16 +0000285 void EmitDoStmt(const DoStmt &S);
286 void EmitForStmt(const ForStmt &S);
Chris Lattner3f3dbee2007-06-02 03:19:07 +0000287 void EmitReturnStmt(const ReturnStmt &S);
Chris Lattner1ad38f82007-06-09 01:20:56 +0000288 void EmitDeclStmt(const DeclStmt &S);
Chris Lattnere73e4322007-07-16 21:28:45 +0000289 void EmitBreakStmt();
290 void EmitContinueStmt();
291
Chris Lattner208ae962007-05-30 17:57:17 +0000292 //===--------------------------------------------------------------------===//
Chris Lattnerd7f58862007-06-02 05:24:33 +0000293 // LValue Expression Emission
294 //===--------------------------------------------------------------------===//
Chris Lattner8394d792007-06-05 20:53:16 +0000295
296 /// EmitLValue - Emit code to compute a designator that specifies the location
297 /// of the expression.
298 ///
299 /// This can return one of two things: a simple address or a bitfield
300 /// reference. In either case, the LLVM Value* in the LValue structure is
301 /// guaranteed to be an LLVM pointer type.
302 ///
303 /// If this returns a bitfield reference, nothing about the pointee type of
304 /// the LLVM value is known: For example, it may not be a pointer to an
305 /// integer.
306 ///
307 /// If this returns a normal address, and if the lvalue's C type is fixed
308 /// size, this method guarantees that the returned pointer type will point to
309 /// an LLVM type of the same size of the lvalue's type. If the lvalue has a
310 /// variable length type, this is not possible.
311 ///
Chris Lattnerd7f58862007-06-02 05:24:33 +0000312 LValue EmitLValue(const Expr *E);
Chris Lattner8394d792007-06-05 20:53:16 +0000313
314 /// EmitLoadOfLValue - Given an expression that represents a value lvalue,
315 /// this method emits the address of the lvalue, then loads the result as an
316 /// rvalue, returning the rvalue.
317 RValue EmitLoadOfLValue(const Expr *E);
Chris Lattner9369a562007-06-29 16:31:29 +0000318 RValue EmitLoadOfLValue(LValue V, QualType LVType);
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000319 RValue EmitLoadOfOCUElementLValue(LValue V, QualType LVType);
Chris Lattner9369a562007-06-29 16:31:29 +0000320
Chris Lattner40ff7012007-08-03 16:18:34 +0000321
Chris Lattner8394d792007-06-05 20:53:16 +0000322 /// EmitStoreThroughLValue - Store the specified rvalue into the specified
323 /// lvalue, where both are guaranteed to the have the same type, and that type
324 /// is 'Ty'.
325 void EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty);
Chris Lattner41d480e2007-08-03 16:28:33 +0000326 void EmitStoreThroughOCUComponentLValue(RValue Src, LValue Dst, QualType Ty);
Chris Lattner8394d792007-06-05 20:53:16 +0000327
Chris Lattnerd7f58862007-06-02 05:24:33 +0000328 LValue EmitDeclRefLValue(const DeclRefExpr *E);
Chris Lattner4347e3692007-06-06 04:54:52 +0000329 LValue EmitStringLiteralLValue(const StringLiteral *E);
Anders Carlsson625bfc82007-07-21 05:21:51 +0000330 LValue EmitPreDefinedLValue(const PreDefinedExpr *E);
Chris Lattner8394d792007-06-05 20:53:16 +0000331 LValue EmitUnaryOpLValue(const UnaryOperator *E);
Chris Lattnerd9d2fb12007-06-08 23:31:14 +0000332 LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E);
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000333 LValue EmitOCUVectorElementExpr(const OCUVectorElementExpr *E);
Chris Lattnerd7f58862007-06-02 05:24:33 +0000334
335 //===--------------------------------------------------------------------===//
Chris Lattner208ae962007-05-30 17:57:17 +0000336 // Expression Emission
337 //===--------------------------------------------------------------------===//
338
Chris Lattner8394d792007-06-05 20:53:16 +0000339 RValue EmitExprWithUsualUnaryConversions(const Expr *E, QualType &ResTy);
Chris Lattnercf250242007-06-03 02:02:44 +0000340 QualType EmitUsualArithmeticConversions(const BinaryOperator *E,
Chris Lattner8394d792007-06-05 20:53:16 +0000341 RValue &LHS, RValue &RHS);
Chris Lattner47c247e2007-06-29 17:26:27 +0000342 void EmitShiftOperands(const BinaryOperator *E, RValue &LHS, RValue &RHS);
343
Chris Lattnercd215f02007-06-29 16:52:55 +0000344 void EmitCompoundAssignmentOperands(const CompoundAssignOperator *CAO,
345 LValue &LHSLV, RValue &LHS, RValue &RHS);
346 RValue EmitCompoundAssignmentResult(const CompoundAssignOperator *E,
347 LValue LHSLV, RValue ResV);
348
349
Chris Lattner8394d792007-06-05 20:53:16 +0000350 RValue EmitExpr(const Expr *E);
351 RValue EmitIntegerLiteral(const IntegerLiteral *E);
Chris Lattner2ada32e2007-07-09 23:03:16 +0000352 RValue EmitFloatingLiteral(const FloatingLiteral *E);
Chris Lattner6e9d9b32007-07-13 05:18:11 +0000353 RValue EmitCharacterLiteral(const CharacterLiteral *E);
354
Chris Lattner388cf762007-07-13 20:25:53 +0000355 RValue EmitCastExpr(const Expr *Op, QualType DestTy);
Chris Lattner2b228c92007-06-15 21:34:29 +0000356 RValue EmitCallExpr(const CallExpr *E);
Chris Lattnera779b3d2007-07-10 21:58:36 +0000357 RValue EmitArraySubscriptExprRV(const ArraySubscriptExpr *E);
Chris Lattner8394d792007-06-05 20:53:16 +0000358
Chris Lattnerf0106d22007-06-02 19:33:17 +0000359 // Unary Operators.
Chris Lattner8394d792007-06-05 20:53:16 +0000360 RValue EmitUnaryOperator(const UnaryOperator *E);
Chris Lattnerdcca4872007-07-11 23:43:46 +0000361 RValue EmitUnaryIncDec (const UnaryOperator *E);
Chris Lattner8394d792007-06-05 20:53:16 +0000362 RValue EmitUnaryAddrOf (const UnaryOperator *E);
363 RValue EmitUnaryPlus (const UnaryOperator *E);
364 RValue EmitUnaryMinus (const UnaryOperator *E);
365 RValue EmitUnaryNot (const UnaryOperator *E);
366 RValue EmitUnaryLNot (const UnaryOperator *E);
Chris Lattner3f8c6e62007-07-18 18:12:07 +0000367 RValue EmitSizeAlignOf (QualType TypeToSize, QualType RetType,bool isSizeOf);
Chris Lattner8394d792007-06-05 20:53:16 +0000368 // FIXME: real/imag
Chris Lattnerf0106d22007-06-02 19:33:17 +0000369
Chris Lattnerdb91b162007-06-02 00:16:28 +0000370 // Binary Operators.
Chris Lattner8394d792007-06-05 20:53:16 +0000371 RValue EmitBinaryOperator(const BinaryOperator *E);
372 RValue EmitBinaryMul(const BinaryOperator *E);
373 RValue EmitBinaryDiv(const BinaryOperator *E);
374 RValue EmitBinaryRem(const BinaryOperator *E);
Chris Lattnerb25a9432007-06-29 17:03:06 +0000375 RValue EmitMul(RValue LHS, RValue RHS, QualType EltTy);
376 RValue EmitDiv(RValue LHS, RValue RHS, QualType EltTy);
377 RValue EmitRem(RValue LHS, RValue RHS, QualType EltTy);
Chris Lattnercd215f02007-06-29 16:52:55 +0000378 RValue EmitAdd(RValue LHS, RValue RHS, QualType EltTy);
Chris Lattnerd2b88ab2007-07-13 03:05:23 +0000379 RValue EmitPointerAdd(RValue LHS, QualType LHSTy,
380 RValue RHS, QualType RHSTy, QualType EltTy);
Chris Lattnercd215f02007-06-29 16:52:55 +0000381 RValue EmitSub(RValue LHS, RValue RHS, QualType EltTy);
Chris Lattnerd2b88ab2007-07-13 03:05:23 +0000382 RValue EmitPointerSub(RValue LHS, QualType LHSTy,
383 RValue RHS, QualType RHSTy, QualType EltTy);
Chris Lattner47c247e2007-06-29 17:26:27 +0000384 RValue EmitShl(RValue LHS, RValue RHS, QualType ResTy);
385 RValue EmitShr(RValue LHS, RValue RHS, QualType ResTy);
Chris Lattner1fde0b32007-06-20 18:30:55 +0000386 RValue EmitBinaryCompare(const BinaryOperator *E, unsigned UICmpOpc,
387 unsigned SICmpOpc, unsigned FCmpOpc);
Chris Lattnerb25a9432007-06-29 17:03:06 +0000388 RValue EmitAnd(RValue LHS, RValue RHS, QualType EltTy);
389 RValue EmitOr (RValue LHS, RValue RHS, QualType EltTy);
390 RValue EmitXor(RValue LHS, RValue RHS, QualType EltTy);
Chris Lattner8394d792007-06-05 20:53:16 +0000391 RValue EmitBinaryLAnd(const BinaryOperator *E);
392 RValue EmitBinaryLOr(const BinaryOperator *E);
393
394 RValue EmitBinaryAssign(const BinaryOperator *E);
Chris Lattner8394d792007-06-05 20:53:16 +0000395 RValue EmitBinaryComma(const BinaryOperator *E);
Chris Lattner6e9d9b32007-07-13 05:18:11 +0000396
397 // Conditional Operator.
398 RValue EmitConditionalOperator(const ConditionalOperator *E);
Chris Lattnerbed31442007-05-28 01:07:47 +0000399};
400} // end namespace CodeGen
401} // end namespace clang
Chris Lattnerbed31442007-05-28 01:07:47 +0000402
403#endif