blob: 4c79498c4626cbfaea73f8e6fe02428e3ece527e [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 Lattner8394d792007-06-05 20:53:16 +000053 class CastExpr;
Chris Lattner2b228c92007-06-15 21:34:29 +000054 class CallExpr;
Chris Lattnerf0106d22007-06-02 19:33:17 +000055 class UnaryOperator;
Chris Lattnerdb91b162007-06-02 00:16:28 +000056 class BinaryOperator;
Chris Lattner9369a562007-06-29 16:31:29 +000057 class CompoundAssignOperator;
Chris Lattnerd9d2fb12007-06-08 23:31:14 +000058 class ArraySubscriptExpr;
Chris Lattnerd268a7a2007-08-03 17:31:20 +000059 class OCUVectorElementExpr;
Chris Lattner6e9d9b32007-07-13 05:18:11 +000060 class ConditionalOperator;
Anders Carlsson625bfc82007-07-21 05:21:51 +000061 class PreDefinedExpr;
Chris Lattner208ae962007-05-30 17:57:17 +000062
Chris Lattner84915fa2007-06-02 04:16:21 +000063 class BlockVarDecl;
64 class EnumConstantDecl;
Chris Lattner53621a52007-06-13 20:44:40 +000065 class ParmVarDecl;
Chris Lattnerbed31442007-05-28 01:07:47 +000066namespace CodeGen {
67 class CodeGenModule;
68
Chris Lattnerd7f58862007-06-02 05:24:33 +000069
Chris Lattner8394d792007-06-05 20:53:16 +000070/// RValue - This trivial value class is used to represent the result of an
Chris Lattnerd7f58862007-06-02 05:24:33 +000071/// expression that is evaluated. It can be one of two things: either a simple
72/// LLVM SSA value, or the address of an aggregate value in memory. These two
73/// possibilities are discriminated by isAggregate/isScalar.
Chris Lattner8394d792007-06-05 20:53:16 +000074class RValue {
Chris Lattner23b7eb62007-06-15 23:05:46 +000075 llvm::Value *V;
Chris Lattnerdb91b162007-06-02 00:16:28 +000076 // TODO: Encode this into the low bit of pointer for more efficient
77 // return-by-value.
Chris Lattner5269c032007-05-30 21:03:58 +000078 bool IsAggregate;
Chris Lattner09153c02007-06-22 18:48:09 +000079
80 // FIXME: Aggregate rvalues need to retain information about whether they are
81 // volatile or not.
Chris Lattner5269c032007-05-30 21:03:58 +000082public:
83
84 bool isAggregate() const { return IsAggregate; }
85 bool isScalar() const { return !IsAggregate; }
86
87 /// getVal() - Return the Value* of this scalar value.
Chris Lattner23b7eb62007-06-15 23:05:46 +000088 llvm::Value *getVal() const {
Chris Lattner5269c032007-05-30 21:03:58 +000089 assert(!isAggregate() && "Not a scalar!");
90 return V;
91 }
92
Chris Lattner09153c02007-06-22 18:48:09 +000093 /// getAggregateAddr() - Return the Value* of the address of the aggregate.
94 llvm::Value *getAggregateAddr() const {
Chris Lattner5269c032007-05-30 21:03:58 +000095 assert(isAggregate() && "Not an aggregate!");
96 return V;
97 }
Chris Lattner208ae962007-05-30 17:57:17 +000098
Chris Lattner23b7eb62007-06-15 23:05:46 +000099 static RValue get(llvm::Value *V) {
Chris Lattner8394d792007-06-05 20:53:16 +0000100 RValue ER;
Chris Lattner208ae962007-05-30 17:57:17 +0000101 ER.V = V;
Chris Lattner5269c032007-05-30 21:03:58 +0000102 ER.IsAggregate = false;
Chris Lattner208ae962007-05-30 17:57:17 +0000103 return ER;
104 }
Chris Lattner23b7eb62007-06-15 23:05:46 +0000105 static RValue getAggregate(llvm::Value *V) {
Chris Lattner8394d792007-06-05 20:53:16 +0000106 RValue ER;
Chris Lattner208ae962007-05-30 17:57:17 +0000107 ER.V = V;
Chris Lattner5269c032007-05-30 21:03:58 +0000108 ER.IsAggregate = true;
Chris Lattner208ae962007-05-30 17:57:17 +0000109 return ER;
110 }
111};
Chris Lattnerd7f58862007-06-02 05:24:33 +0000112
113
114/// LValue - This represents an lvalue references. Because C/C++ allow
115/// bitfields, this is not a simple LLVM pointer, it may be a pointer plus a
116/// bitrange.
117class LValue {
118 // FIXME: Volatility. Restrict?
Chris Lattner8394d792007-06-05 20:53:16 +0000119 // alignment?
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000120
121 enum {
Chris Lattner9e751ca2007-08-02 23:37:31 +0000122 Simple, // This is a normal l-value, use getAddress().
123 VectorElt, // This is a vector element l-value (V[i]), use getVector*
124 BitField, // This is a bitfield l-value, use getBitfield*.
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000125 OCUVectorElt // This is an ocu vector subset, use getOCUVectorComp
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000126 } LVType;
127
Chris Lattnerd7f58862007-06-02 05:24:33 +0000128 llvm::Value *V;
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000129
130 union {
Chris Lattner9e751ca2007-08-02 23:37:31 +0000131 llvm::Value *VectorIdx; // Index into a vector subscript: V[i]
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000132 unsigned VectorElts; // Encoded OCUVector element subset: V.xyx
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000133 };
Chris Lattnerd7f58862007-06-02 05:24:33 +0000134public:
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000135 bool isSimple() const { return LVType == Simple; }
136 bool isVectorElt() const { return LVType == VectorElt; }
137 bool isBitfield() const { return LVType == BitField; }
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000138 bool isOCUVectorElt() const { return LVType == OCUVectorElt; }
Chris Lattner208ae962007-05-30 17:57:17 +0000139
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000140 // simple lvalue
141 llvm::Value *getAddress() const { assert(isSimple()); return V; }
142 // vector elt lvalue
143 llvm::Value *getVectorAddr() const { assert(isVectorElt()); return V; }
144 llvm::Value *getVectorIdx() const { assert(isVectorElt()); return VectorIdx; }
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000145 // ocu vector elements.
146 llvm::Value *getOCUVectorAddr() const { assert(isOCUVectorElt()); return V; }
147 unsigned getOCUVectorElts() const {
148 assert(isOCUVectorElt());
149 return VectorElts;
Chris Lattner9e751ca2007-08-02 23:37:31 +0000150 }
151
Chris Lattnerd7f58862007-06-02 05:24:33 +0000152
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000153 static LValue MakeAddr(llvm::Value *V) {
Chris Lattnerd7f58862007-06-02 05:24:33 +0000154 LValue R;
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000155 R.LVType = Simple;
Chris Lattnerd7f58862007-06-02 05:24:33 +0000156 R.V = V;
157 return R;
158 }
Chris Lattner08c4b9f2007-07-10 21:17:59 +0000159
160 static LValue MakeVectorElt(llvm::Value *Vec, llvm::Value *Idx) {
161 LValue R;
162 R.LVType = VectorElt;
163 R.V = Vec;
164 R.VectorIdx = Idx;
165 return R;
166 }
167
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000168 static LValue MakeOCUVectorElt(llvm::Value *Vec, unsigned Elements) {
Chris Lattner9e751ca2007-08-02 23:37:31 +0000169 LValue R;
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000170 R.LVType = OCUVectorElt;
Chris Lattner9e751ca2007-08-02 23:37:31 +0000171 R.V = Vec;
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000172 R.VectorElts = Elements;
Chris Lattner9e751ca2007-08-02 23:37:31 +0000173 return R;
174 }
Chris Lattnerd7f58862007-06-02 05:24:33 +0000175};
176
Chris Lattnerbed31442007-05-28 01:07:47 +0000177/// CodeGenFunction - This class organizes the per-function state that is used
178/// while generating LLVM code.
179class CodeGenFunction {
180 CodeGenModule &CGM; // Per-module state.
Chris Lattnerd1af2d22007-05-29 23:17:50 +0000181 TargetInfo &Target;
Chris Lattner23b7eb62007-06-15 23:05:46 +0000182 llvm::LLVMBuilder Builder;
Chris Lattner3f3dbee2007-06-02 03:19:07 +0000183
184 const FunctionDecl *CurFuncDecl;
Chris Lattnerac248202007-05-30 00:13:02 +0000185 llvm::Function *CurFn;
186
Chris Lattner03df1222007-06-02 04:53:11 +0000187 /// AllocaInsertPoint - This is an instruction in the entry block before which
188 /// we prefer to insert allocas.
189 llvm::Instruction *AllocaInsertPt;
190
Chris Lattner6db1fb82007-06-02 22:49:07 +0000191 const llvm::Type *LLVMIntTy;
Chris Lattnerd9d2fb12007-06-08 23:31:14 +0000192 unsigned LLVMPointerWidth;
Chris Lattner6db1fb82007-06-02 22:49:07 +0000193
Chris Lattner84915fa2007-06-02 04:16:21 +0000194 /// LocalDeclMap - This keeps track of the LLVM allocas or globals for local C
195 /// decls.
Chris Lattner23b7eb62007-06-15 23:05:46 +0000196 llvm::DenseMap<const Decl*, llvm::Value*> LocalDeclMap;
Chris Lattner84915fa2007-06-02 04:16:21 +0000197
Chris Lattnerac248202007-05-30 00:13:02 +0000198 /// LabelMap - This keeps track of the LLVM basic block for each C label.
Chris Lattner23b7eb62007-06-15 23:05:46 +0000199 llvm::DenseMap<const LabelStmt*, llvm::BasicBlock*> LabelMap;
Chris Lattnere73e4322007-07-16 21:28:45 +0000200
201 // BreakContinueStack - This keeps track of where break and continue
202 // statements should jump to.
203 struct BreakContinue {
204 BreakContinue(llvm::BasicBlock *bb, llvm::BasicBlock *cb)
205 : BreakBlock(bb), ContinueBlock(cb) {}
206
207 llvm::BasicBlock *BreakBlock;
208 llvm::BasicBlock *ContinueBlock;
209 };
210 llvm::SmallVector<BreakContinue, 8> BreakContinueStack;
211
Chris Lattnerbed31442007-05-28 01:07:47 +0000212public:
Chris Lattnerd1af2d22007-05-29 23:17:50 +0000213 CodeGenFunction(CodeGenModule &cgm);
Chris Lattnerbed31442007-05-28 01:07:47 +0000214
Chris Lattner6db1fb82007-06-02 22:49:07 +0000215 ASTContext &getContext() const;
216
Chris Lattner308f4312007-05-29 23:50:05 +0000217 void GenerateCode(const FunctionDecl *FD);
218
Chris Lattnerf033c142007-06-22 19:05:19 +0000219 const llvm::Type *ConvertType(QualType T);
Chris Lattnerac248202007-05-30 00:13:02 +0000220
Chris Lattner54fb19e2007-06-22 22:02:34 +0000221 /// hasAggregateLLVMType - Return true if the specified AST type will map into
222 /// an aggregate LLVM type or is void.
223 static bool hasAggregateLLVMType(QualType T);
224
Chris Lattnerac248202007-05-30 00:13:02 +0000225 /// getBasicBlockForLabel - Return the LLVM basicblock that the specified
226 /// label maps to.
227 llvm::BasicBlock *getBasicBlockForLabel(const LabelStmt *S);
228
229
Chris Lattner23b7eb62007-06-15 23:05:46 +0000230 void EmitBlock(llvm::BasicBlock *BB);
Chris Lattner84915fa2007-06-02 04:16:21 +0000231
Chris Lattnere9a64532007-06-22 21:44:33 +0000232 //===--------------------------------------------------------------------===//
233 // Helpers
234 //===--------------------------------------------------------------------===//
235
236 /// CreateTempAlloca - This creates a alloca and inserts it into the entry
237 /// block.
238 llvm::AllocaInst *CreateTempAlloca(const llvm::Type *Ty,
239 const char *Name = "tmp");
240
Chris Lattner8394d792007-06-05 20:53:16 +0000241 /// EvaluateExprAsBool - Perform the usual unary conversions on the specified
242 /// expression and compare the result against zero, returning an Int1Ty value.
Chris Lattner23b7eb62007-06-15 23:05:46 +0000243 llvm::Value *EvaluateExprAsBool(const Expr *E);
Chris Lattnere9a64532007-06-22 21:44:33 +0000244
Chris Lattnerac248202007-05-30 00:13:02 +0000245
Chris Lattnere9a64532007-06-22 21:44:33 +0000246 /// EmitLoadOfComplex - Given an RValue reference for a complex, emit code to
247 /// load the real and imaginary pieces, returning them as Real/Imag.
248 void EmitLoadOfComplex(RValue V, llvm::Value *&Real, llvm::Value *&Imag);
249
250 /// EmitStoreOfComplex - Store the specified real/imag parts into the
251 /// specified value pointer.
252 void EmitStoreOfComplex(llvm::Value *Real, llvm::Value *Imag,
253 llvm::Value *ResPtr);
254
Chris Lattner8394d792007-06-05 20:53:16 +0000255 //===--------------------------------------------------------------------===//
256 // Conversions
257 //===--------------------------------------------------------------------===//
258
259 /// EmitConversion - Convert the value specied by Val, whose type is ValTy, to
260 /// the type specified by DstTy, following the rules of C99 6.3.
Chris Lattnerf033c142007-06-22 19:05:19 +0000261 RValue EmitConversion(RValue Val, QualType ValTy, QualType DstTy);
Chris Lattner8394d792007-06-05 20:53:16 +0000262
263 /// ConvertScalarValueToBool - Convert the specified expression value to a
Chris Lattnerf0106d22007-06-02 19:33:17 +0000264 /// boolean (i1) truth value. This is equivalent to "Val == 0".
Chris Lattner23b7eb62007-06-15 23:05:46 +0000265 llvm::Value *ConvertScalarValueToBool(RValue Val, QualType Ty);
Chris Lattnerf0106d22007-06-02 19:33:17 +0000266
Chris Lattner308f4312007-05-29 23:50:05 +0000267 //===--------------------------------------------------------------------===//
Chris Lattner53621a52007-06-13 20:44:40 +0000268 // Declaration Emission
Chris Lattner84915fa2007-06-02 04:16:21 +0000269 //===--------------------------------------------------------------------===//
270
Chris Lattner1ad38f82007-06-09 01:20:56 +0000271 void EmitDecl(const Decl &D);
Chris Lattner84915fa2007-06-02 04:16:21 +0000272 void EmitEnumConstantDecl(const EnumConstantDecl &D);
Chris Lattner03df1222007-06-02 04:53:11 +0000273 void EmitBlockVarDecl(const BlockVarDecl &D);
274 void EmitLocalBlockVarDecl(const BlockVarDecl &D);
Chris Lattner53621a52007-06-13 20:44:40 +0000275 void EmitParmDecl(const ParmVarDecl &D, llvm::Value *Arg);
Chris Lattner03df1222007-06-02 04:53:11 +0000276
Chris Lattner84915fa2007-06-02 04:16:21 +0000277 //===--------------------------------------------------------------------===//
Chris Lattner308f4312007-05-29 23:50:05 +0000278 // Statement Emission
279 //===--------------------------------------------------------------------===//
280
281 void EmitStmt(const Stmt *S);
282 void EmitCompoundStmt(const CompoundStmt &S);
Chris Lattnerac248202007-05-30 00:13:02 +0000283 void EmitLabelStmt(const LabelStmt &S);
284 void EmitGotoStmt(const GotoStmt &S);
Chris Lattner5269c032007-05-30 21:03:58 +0000285 void EmitIfStmt(const IfStmt &S);
Chris Lattner946aa312007-06-05 03:59:43 +0000286 void EmitWhileStmt(const WhileStmt &S);
Chris Lattner8394d792007-06-05 20:53:16 +0000287 void EmitDoStmt(const DoStmt &S);
288 void EmitForStmt(const ForStmt &S);
Chris Lattner3f3dbee2007-06-02 03:19:07 +0000289 void EmitReturnStmt(const ReturnStmt &S);
Chris Lattner1ad38f82007-06-09 01:20:56 +0000290 void EmitDeclStmt(const DeclStmt &S);
Chris Lattnere73e4322007-07-16 21:28:45 +0000291 void EmitBreakStmt();
292 void EmitContinueStmt();
293
Chris Lattner208ae962007-05-30 17:57:17 +0000294 //===--------------------------------------------------------------------===//
Chris Lattnerd7f58862007-06-02 05:24:33 +0000295 // LValue Expression Emission
296 //===--------------------------------------------------------------------===//
Chris Lattner8394d792007-06-05 20:53:16 +0000297
298 /// EmitLValue - Emit code to compute a designator that specifies the location
299 /// of the expression.
300 ///
301 /// This can return one of two things: a simple address or a bitfield
302 /// reference. In either case, the LLVM Value* in the LValue structure is
303 /// guaranteed to be an LLVM pointer type.
304 ///
305 /// If this returns a bitfield reference, nothing about the pointee type of
306 /// the LLVM value is known: For example, it may not be a pointer to an
307 /// integer.
308 ///
309 /// If this returns a normal address, and if the lvalue's C type is fixed
310 /// size, this method guarantees that the returned pointer type will point to
311 /// an LLVM type of the same size of the lvalue's type. If the lvalue has a
312 /// variable length type, this is not possible.
313 ///
Chris Lattnerd7f58862007-06-02 05:24:33 +0000314 LValue EmitLValue(const Expr *E);
Chris Lattner8394d792007-06-05 20:53:16 +0000315
316 /// EmitLoadOfLValue - Given an expression that represents a value lvalue,
317 /// this method emits the address of the lvalue, then loads the result as an
318 /// rvalue, returning the rvalue.
319 RValue EmitLoadOfLValue(const Expr *E);
Chris Lattner9369a562007-06-29 16:31:29 +0000320 RValue EmitLoadOfLValue(LValue V, QualType LVType);
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000321 RValue EmitLoadOfOCUElementLValue(LValue V, QualType LVType);
Chris Lattner9369a562007-06-29 16:31:29 +0000322
Chris Lattner40ff7012007-08-03 16:18:34 +0000323
Chris Lattner8394d792007-06-05 20:53:16 +0000324 /// EmitStoreThroughLValue - Store the specified rvalue into the specified
325 /// lvalue, where both are guaranteed to the have the same type, and that type
326 /// is 'Ty'.
327 void EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty);
Chris Lattner41d480e2007-08-03 16:28:33 +0000328 void EmitStoreThroughOCUComponentLValue(RValue Src, LValue Dst, QualType Ty);
Chris Lattner8394d792007-06-05 20:53:16 +0000329
Chris Lattnerd7f58862007-06-02 05:24:33 +0000330 LValue EmitDeclRefLValue(const DeclRefExpr *E);
Chris Lattner4347e3692007-06-06 04:54:52 +0000331 LValue EmitStringLiteralLValue(const StringLiteral *E);
Anders Carlsson625bfc82007-07-21 05:21:51 +0000332 LValue EmitPreDefinedLValue(const PreDefinedExpr *E);
Chris Lattner8394d792007-06-05 20:53:16 +0000333 LValue EmitUnaryOpLValue(const UnaryOperator *E);
Chris Lattnerd9d2fb12007-06-08 23:31:14 +0000334 LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E);
Chris Lattnerd268a7a2007-08-03 17:31:20 +0000335 LValue EmitOCUVectorElementExpr(const OCUVectorElementExpr *E);
Chris Lattnerd7f58862007-06-02 05:24:33 +0000336
337 //===--------------------------------------------------------------------===//
Chris Lattner208ae962007-05-30 17:57:17 +0000338 // Expression Emission
339 //===--------------------------------------------------------------------===//
340
Chris Lattner8394d792007-06-05 20:53:16 +0000341 RValue EmitExprWithUsualUnaryConversions(const Expr *E, QualType &ResTy);
Chris Lattnercf250242007-06-03 02:02:44 +0000342 QualType EmitUsualArithmeticConversions(const BinaryOperator *E,
Chris Lattner8394d792007-06-05 20:53:16 +0000343 RValue &LHS, RValue &RHS);
Chris Lattner47c247e2007-06-29 17:26:27 +0000344 void EmitShiftOperands(const BinaryOperator *E, RValue &LHS, RValue &RHS);
345
Chris Lattnercd215f02007-06-29 16:52:55 +0000346 void EmitCompoundAssignmentOperands(const CompoundAssignOperator *CAO,
347 LValue &LHSLV, RValue &LHS, RValue &RHS);
348 RValue EmitCompoundAssignmentResult(const CompoundAssignOperator *E,
349 LValue LHSLV, RValue ResV);
350
351
Chris Lattner8394d792007-06-05 20:53:16 +0000352 RValue EmitExpr(const Expr *E);
353 RValue EmitIntegerLiteral(const IntegerLiteral *E);
Chris Lattner2ada32e2007-07-09 23:03:16 +0000354 RValue EmitFloatingLiteral(const FloatingLiteral *E);
Chris Lattner6e9d9b32007-07-13 05:18:11 +0000355 RValue EmitCharacterLiteral(const CharacterLiteral *E);
Chris Lattner40480052007-08-03 17:51:03 +0000356 RValue EmitTypesCompatibleExpr(const TypesCompatibleExpr *E);
Chris Lattner6e9d9b32007-07-13 05:18:11 +0000357
Chris Lattner388cf762007-07-13 20:25:53 +0000358 RValue EmitCastExpr(const Expr *Op, QualType DestTy);
Chris Lattner2b228c92007-06-15 21:34:29 +0000359 RValue EmitCallExpr(const CallExpr *E);
Chris Lattnera779b3d2007-07-10 21:58:36 +0000360 RValue EmitArraySubscriptExprRV(const ArraySubscriptExpr *E);
Chris Lattner8394d792007-06-05 20:53:16 +0000361
Chris Lattnerf0106d22007-06-02 19:33:17 +0000362 // Unary Operators.
Chris Lattner8394d792007-06-05 20:53:16 +0000363 RValue EmitUnaryOperator(const UnaryOperator *E);
Chris Lattnerdcca4872007-07-11 23:43:46 +0000364 RValue EmitUnaryIncDec (const UnaryOperator *E);
Chris Lattner8394d792007-06-05 20:53:16 +0000365 RValue EmitUnaryAddrOf (const UnaryOperator *E);
366 RValue EmitUnaryPlus (const UnaryOperator *E);
367 RValue EmitUnaryMinus (const UnaryOperator *E);
368 RValue EmitUnaryNot (const UnaryOperator *E);
369 RValue EmitUnaryLNot (const UnaryOperator *E);
Chris Lattner3f8c6e62007-07-18 18:12:07 +0000370 RValue EmitSizeAlignOf (QualType TypeToSize, QualType RetType,bool isSizeOf);
Chris Lattner8394d792007-06-05 20:53:16 +0000371 // FIXME: real/imag
Chris Lattnerf0106d22007-06-02 19:33:17 +0000372
Chris Lattnerdb91b162007-06-02 00:16:28 +0000373 // Binary Operators.
Chris Lattner8394d792007-06-05 20:53:16 +0000374 RValue EmitBinaryOperator(const BinaryOperator *E);
375 RValue EmitBinaryMul(const BinaryOperator *E);
376 RValue EmitBinaryDiv(const BinaryOperator *E);
377 RValue EmitBinaryRem(const BinaryOperator *E);
Chris Lattnerb25a9432007-06-29 17:03:06 +0000378 RValue EmitMul(RValue LHS, RValue RHS, QualType EltTy);
379 RValue EmitDiv(RValue LHS, RValue RHS, QualType EltTy);
380 RValue EmitRem(RValue LHS, RValue RHS, QualType EltTy);
Chris Lattnercd215f02007-06-29 16:52:55 +0000381 RValue EmitAdd(RValue LHS, RValue RHS, QualType EltTy);
Chris Lattnerd2b88ab2007-07-13 03:05:23 +0000382 RValue EmitPointerAdd(RValue LHS, QualType LHSTy,
383 RValue RHS, QualType RHSTy, QualType EltTy);
Chris Lattnercd215f02007-06-29 16:52:55 +0000384 RValue EmitSub(RValue LHS, RValue RHS, QualType EltTy);
Chris Lattnerd2b88ab2007-07-13 03:05:23 +0000385 RValue EmitPointerSub(RValue LHS, QualType LHSTy,
386 RValue RHS, QualType RHSTy, QualType EltTy);
Chris Lattner47c247e2007-06-29 17:26:27 +0000387 RValue EmitShl(RValue LHS, RValue RHS, QualType ResTy);
388 RValue EmitShr(RValue LHS, RValue RHS, QualType ResTy);
Chris Lattner1fde0b32007-06-20 18:30:55 +0000389 RValue EmitBinaryCompare(const BinaryOperator *E, unsigned UICmpOpc,
390 unsigned SICmpOpc, unsigned FCmpOpc);
Chris Lattnerb25a9432007-06-29 17:03:06 +0000391 RValue EmitAnd(RValue LHS, RValue RHS, QualType EltTy);
392 RValue EmitOr (RValue LHS, RValue RHS, QualType EltTy);
393 RValue EmitXor(RValue LHS, RValue RHS, QualType EltTy);
Chris Lattner8394d792007-06-05 20:53:16 +0000394 RValue EmitBinaryLAnd(const BinaryOperator *E);
395 RValue EmitBinaryLOr(const BinaryOperator *E);
396
397 RValue EmitBinaryAssign(const BinaryOperator *E);
Chris Lattner8394d792007-06-05 20:53:16 +0000398 RValue EmitBinaryComma(const BinaryOperator *E);
Chris Lattner6e9d9b32007-07-13 05:18:11 +0000399
400 // Conditional Operator.
401 RValue EmitConditionalOperator(const ConditionalOperator *E);
Chris Lattnerbed31442007-05-28 01:07:47 +0000402};
403} // end namespace CodeGen
404} // end namespace clang
Chris Lattnerbed31442007-05-28 01:07:47 +0000405
406#endif