Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===--- 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 | |
| 17 | #include "llvm/ADT/DenseMap.h" |
Chris Lattner | da13870 | 2007-07-16 21:28:45 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/SmallVector.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 19 | #include "llvm/Support/LLVMBuilder.h" |
| 20 | #include <vector> |
| 21 | |
| 22 | namespace llvm { |
| 23 | class Module; |
| 24 | } |
| 25 | |
| 26 | namespace clang { |
| 27 | class ASTContext; |
| 28 | class Decl; |
| 29 | class FunctionDecl; |
| 30 | class TargetInfo; |
| 31 | class QualType; |
| 32 | class FunctionTypeProto; |
| 33 | |
| 34 | class Stmt; |
| 35 | class CompoundStmt; |
| 36 | class LabelStmt; |
| 37 | class GotoStmt; |
| 38 | class IfStmt; |
| 39 | class WhileStmt; |
| 40 | class DoStmt; |
| 41 | class ForStmt; |
| 42 | class ReturnStmt; |
| 43 | class DeclStmt; |
| 44 | |
| 45 | class Expr; |
| 46 | class DeclRefExpr; |
| 47 | class StringLiteral; |
| 48 | class IntegerLiteral; |
| 49 | class FloatingLiteral; |
Chris Lattner | b0a721a | 2007-07-13 05:18:11 +0000 | [diff] [blame] | 50 | class CharacterLiteral; |
Chris Lattner | 30bf3ae | 2007-08-03 17:51:03 +0000 | [diff] [blame] | 51 | class TypesCompatibleExpr; |
| 52 | |
Chris Lattner | 7016a70 | 2007-08-20 22:37:10 +0000 | [diff] [blame] | 53 | class ImplicitCastExpr; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 54 | class CastExpr; |
| 55 | class CallExpr; |
| 56 | class UnaryOperator; |
| 57 | class BinaryOperator; |
| 58 | class CompoundAssignOperator; |
| 59 | class ArraySubscriptExpr; |
Chris Lattner | 6481a57 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 60 | class OCUVectorElementExpr; |
Chris Lattner | b0a721a | 2007-07-13 05:18:11 +0000 | [diff] [blame] | 61 | class ConditionalOperator; |
Chris Lattner | 94f05e3 | 2007-08-04 00:20:15 +0000 | [diff] [blame] | 62 | class ChooseExpr; |
Anders Carlsson | 2274266 | 2007-07-21 05:21:51 +0000 | [diff] [blame] | 63 | class PreDefinedExpr; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 64 | |
| 65 | class BlockVarDecl; |
| 66 | class EnumConstantDecl; |
| 67 | class ParmVarDecl; |
| 68 | namespace CodeGen { |
| 69 | class CodeGenModule; |
| 70 | |
| 71 | |
| 72 | /// RValue - This trivial value class is used to represent the result of an |
| 73 | /// expression that is evaluated. It can be one of two things: either a simple |
| 74 | /// LLVM SSA value, or the address of an aggregate value in memory. These two |
| 75 | /// possibilities are discriminated by isAggregate/isScalar. |
| 76 | class RValue { |
| 77 | llvm::Value *V; |
| 78 | // TODO: Encode this into the low bit of pointer for more efficient |
| 79 | // return-by-value. |
| 80 | bool IsAggregate; |
| 81 | |
| 82 | // FIXME: Aggregate rvalues need to retain information about whether they are |
| 83 | // volatile or not. |
| 84 | public: |
| 85 | |
| 86 | bool isAggregate() const { return IsAggregate; } |
| 87 | bool isScalar() const { return !IsAggregate; } |
| 88 | |
| 89 | /// getVal() - Return the Value* of this scalar value. |
| 90 | llvm::Value *getVal() const { |
| 91 | assert(!isAggregate() && "Not a scalar!"); |
| 92 | return V; |
| 93 | } |
| 94 | |
| 95 | /// getAggregateAddr() - Return the Value* of the address of the aggregate. |
| 96 | llvm::Value *getAggregateAddr() const { |
| 97 | assert(isAggregate() && "Not an aggregate!"); |
| 98 | return V; |
| 99 | } |
| 100 | |
| 101 | static RValue get(llvm::Value *V) { |
| 102 | RValue ER; |
| 103 | ER.V = V; |
| 104 | ER.IsAggregate = false; |
| 105 | return ER; |
| 106 | } |
| 107 | static RValue getAggregate(llvm::Value *V) { |
| 108 | RValue ER; |
| 109 | ER.V = V; |
| 110 | ER.IsAggregate = true; |
| 111 | return ER; |
| 112 | } |
| 113 | }; |
| 114 | |
| 115 | |
| 116 | /// LValue - This represents an lvalue references. Because C/C++ allow |
| 117 | /// bitfields, this is not a simple LLVM pointer, it may be a pointer plus a |
| 118 | /// bitrange. |
| 119 | class LValue { |
| 120 | // FIXME: Volatility. Restrict? |
| 121 | // alignment? |
| 122 | |
| 123 | enum { |
Chris Lattner | 349aaec | 2007-08-02 23:37:31 +0000 | [diff] [blame] | 124 | Simple, // This is a normal l-value, use getAddress(). |
| 125 | VectorElt, // This is a vector element l-value (V[i]), use getVector* |
| 126 | BitField, // This is a bitfield l-value, use getBitfield*. |
Chris Lattner | 6481a57 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 127 | OCUVectorElt // This is an ocu vector subset, use getOCUVectorComp |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 128 | } LVType; |
| 129 | |
| 130 | llvm::Value *V; |
| 131 | |
| 132 | union { |
Chris Lattner | 349aaec | 2007-08-02 23:37:31 +0000 | [diff] [blame] | 133 | llvm::Value *VectorIdx; // Index into a vector subscript: V[i] |
Chris Lattner | 6481a57 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 134 | unsigned VectorElts; // Encoded OCUVector element subset: V.xyx |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 135 | }; |
| 136 | public: |
| 137 | bool isSimple() const { return LVType == Simple; } |
| 138 | bool isVectorElt() const { return LVType == VectorElt; } |
| 139 | bool isBitfield() const { return LVType == BitField; } |
Chris Lattner | 6481a57 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 140 | bool isOCUVectorElt() const { return LVType == OCUVectorElt; } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 141 | |
| 142 | // simple lvalue |
| 143 | llvm::Value *getAddress() const { assert(isSimple()); return V; } |
| 144 | // vector elt lvalue |
| 145 | llvm::Value *getVectorAddr() const { assert(isVectorElt()); return V; } |
| 146 | llvm::Value *getVectorIdx() const { assert(isVectorElt()); return VectorIdx; } |
Chris Lattner | 6481a57 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 147 | // ocu vector elements. |
| 148 | llvm::Value *getOCUVectorAddr() const { assert(isOCUVectorElt()); return V; } |
| 149 | unsigned getOCUVectorElts() const { |
| 150 | assert(isOCUVectorElt()); |
| 151 | return VectorElts; |
Chris Lattner | 349aaec | 2007-08-02 23:37:31 +0000 | [diff] [blame] | 152 | } |
| 153 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 154 | |
| 155 | static LValue MakeAddr(llvm::Value *V) { |
| 156 | LValue R; |
| 157 | R.LVType = Simple; |
| 158 | R.V = V; |
| 159 | return R; |
| 160 | } |
| 161 | |
| 162 | static LValue MakeVectorElt(llvm::Value *Vec, llvm::Value *Idx) { |
| 163 | LValue R; |
| 164 | R.LVType = VectorElt; |
| 165 | R.V = Vec; |
| 166 | R.VectorIdx = Idx; |
| 167 | return R; |
| 168 | } |
| 169 | |
Chris Lattner | 6481a57 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 170 | static LValue MakeOCUVectorElt(llvm::Value *Vec, unsigned Elements) { |
Chris Lattner | 349aaec | 2007-08-02 23:37:31 +0000 | [diff] [blame] | 171 | LValue R; |
Chris Lattner | 6481a57 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 172 | R.LVType = OCUVectorElt; |
Chris Lattner | 349aaec | 2007-08-02 23:37:31 +0000 | [diff] [blame] | 173 | R.V = Vec; |
Chris Lattner | 6481a57 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 174 | R.VectorElts = Elements; |
Chris Lattner | 349aaec | 2007-08-02 23:37:31 +0000 | [diff] [blame] | 175 | return R; |
| 176 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 177 | }; |
| 178 | |
| 179 | /// CodeGenFunction - This class organizes the per-function state that is used |
| 180 | /// while generating LLVM code. |
| 181 | class CodeGenFunction { |
| 182 | CodeGenModule &CGM; // Per-module state. |
| 183 | TargetInfo &Target; |
Chris Lattner | 9c03356 | 2007-08-21 04:25:47 +0000 | [diff] [blame] | 184 | public: |
Chris Lattner | 58dee10 | 2007-08-21 16:57:55 +0000 | [diff] [blame^] | 185 | typedef std::pair<llvm::Value *, llvm::Value *> ComplexPairTy; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 186 | llvm::LLVMBuilder Builder; |
Chris Lattner | 9c03356 | 2007-08-21 04:25:47 +0000 | [diff] [blame] | 187 | private: |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 188 | |
| 189 | const FunctionDecl *CurFuncDecl; |
| 190 | llvm::Function *CurFn; |
| 191 | |
| 192 | /// AllocaInsertPoint - This is an instruction in the entry block before which |
| 193 | /// we prefer to insert allocas. |
| 194 | llvm::Instruction *AllocaInsertPt; |
| 195 | |
| 196 | const llvm::Type *LLVMIntTy; |
| 197 | unsigned LLVMPointerWidth; |
| 198 | |
| 199 | /// LocalDeclMap - This keeps track of the LLVM allocas or globals for local C |
| 200 | /// decls. |
| 201 | llvm::DenseMap<const Decl*, llvm::Value*> LocalDeclMap; |
| 202 | |
| 203 | /// LabelMap - This keeps track of the LLVM basic block for each C label. |
| 204 | llvm::DenseMap<const LabelStmt*, llvm::BasicBlock*> LabelMap; |
Chris Lattner | da13870 | 2007-07-16 21:28:45 +0000 | [diff] [blame] | 205 | |
| 206 | // BreakContinueStack - This keeps track of where break and continue |
| 207 | // statements should jump to. |
| 208 | struct BreakContinue { |
| 209 | BreakContinue(llvm::BasicBlock *bb, llvm::BasicBlock *cb) |
| 210 | : BreakBlock(bb), ContinueBlock(cb) {} |
| 211 | |
| 212 | llvm::BasicBlock *BreakBlock; |
| 213 | llvm::BasicBlock *ContinueBlock; |
| 214 | }; |
| 215 | llvm::SmallVector<BreakContinue, 8> BreakContinueStack; |
| 216 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 217 | public: |
| 218 | CodeGenFunction(CodeGenModule &cgm); |
| 219 | |
| 220 | ASTContext &getContext() const; |
| 221 | |
| 222 | void GenerateCode(const FunctionDecl *FD); |
| 223 | |
| 224 | const llvm::Type *ConvertType(QualType T); |
| 225 | |
| 226 | /// hasAggregateLLVMType - Return true if the specified AST type will map into |
| 227 | /// an aggregate LLVM type or is void. |
| 228 | static bool hasAggregateLLVMType(QualType T); |
| 229 | |
| 230 | /// getBasicBlockForLabel - Return the LLVM basicblock that the specified |
| 231 | /// label maps to. |
| 232 | llvm::BasicBlock *getBasicBlockForLabel(const LabelStmt *S); |
| 233 | |
| 234 | |
| 235 | void EmitBlock(llvm::BasicBlock *BB); |
| 236 | |
| 237 | //===--------------------------------------------------------------------===// |
| 238 | // Helpers |
| 239 | //===--------------------------------------------------------------------===// |
| 240 | |
| 241 | /// CreateTempAlloca - This creates a alloca and inserts it into the entry |
| 242 | /// block. |
| 243 | llvm::AllocaInst *CreateTempAlloca(const llvm::Type *Ty, |
| 244 | const char *Name = "tmp"); |
| 245 | |
| 246 | /// EvaluateExprAsBool - Perform the usual unary conversions on the specified |
| 247 | /// expression and compare the result against zero, returning an Int1Ty value. |
| 248 | llvm::Value *EvaluateExprAsBool(const Expr *E); |
| 249 | |
| 250 | |
| 251 | /// EmitLoadOfComplex - Given an RValue reference for a complex, emit code to |
| 252 | /// load the real and imaginary pieces, returning them as Real/Imag. |
Chris Lattner | ee755f9 | 2007-08-21 04:59:27 +0000 | [diff] [blame] | 253 | void EmitLoadOfComplex(llvm::Value *SrcPtr, llvm::Value *&Real, |
| 254 | llvm::Value *&Imag); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 255 | |
| 256 | /// EmitStoreOfComplex - Store the specified real/imag parts into the |
| 257 | /// specified value pointer. |
| 258 | void EmitStoreOfComplex(llvm::Value *Real, llvm::Value *Imag, |
| 259 | llvm::Value *ResPtr); |
| 260 | |
| 261 | //===--------------------------------------------------------------------===// |
| 262 | // Conversions |
| 263 | //===--------------------------------------------------------------------===// |
| 264 | |
| 265 | /// EmitConversion - Convert the value specied by Val, whose type is ValTy, to |
| 266 | /// the type specified by DstTy, following the rules of C99 6.3. |
| 267 | RValue EmitConversion(RValue Val, QualType ValTy, QualType DstTy); |
| 268 | |
| 269 | /// ConvertScalarValueToBool - Convert the specified expression value to a |
| 270 | /// boolean (i1) truth value. This is equivalent to "Val == 0". |
| 271 | llvm::Value *ConvertScalarValueToBool(RValue Val, QualType Ty); |
| 272 | |
| 273 | //===--------------------------------------------------------------------===// |
| 274 | // Declaration Emission |
| 275 | //===--------------------------------------------------------------------===// |
| 276 | |
| 277 | void EmitDecl(const Decl &D); |
| 278 | void EmitEnumConstantDecl(const EnumConstantDecl &D); |
| 279 | void EmitBlockVarDecl(const BlockVarDecl &D); |
| 280 | void EmitLocalBlockVarDecl(const BlockVarDecl &D); |
| 281 | void EmitParmDecl(const ParmVarDecl &D, llvm::Value *Arg); |
| 282 | |
| 283 | //===--------------------------------------------------------------------===// |
| 284 | // Statement Emission |
| 285 | //===--------------------------------------------------------------------===// |
| 286 | |
| 287 | void EmitStmt(const Stmt *S); |
| 288 | void EmitCompoundStmt(const CompoundStmt &S); |
| 289 | void EmitLabelStmt(const LabelStmt &S); |
| 290 | void EmitGotoStmt(const GotoStmt &S); |
| 291 | void EmitIfStmt(const IfStmt &S); |
| 292 | void EmitWhileStmt(const WhileStmt &S); |
| 293 | void EmitDoStmt(const DoStmt &S); |
| 294 | void EmitForStmt(const ForStmt &S); |
| 295 | void EmitReturnStmt(const ReturnStmt &S); |
| 296 | void EmitDeclStmt(const DeclStmt &S); |
Chris Lattner | da13870 | 2007-07-16 21:28:45 +0000 | [diff] [blame] | 297 | void EmitBreakStmt(); |
| 298 | void EmitContinueStmt(); |
| 299 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 300 | //===--------------------------------------------------------------------===// |
| 301 | // LValue Expression Emission |
| 302 | //===--------------------------------------------------------------------===// |
| 303 | |
| 304 | /// EmitLValue - Emit code to compute a designator that specifies the location |
| 305 | /// of the expression. |
| 306 | /// |
| 307 | /// This can return one of two things: a simple address or a bitfield |
| 308 | /// reference. In either case, the LLVM Value* in the LValue structure is |
| 309 | /// guaranteed to be an LLVM pointer type. |
| 310 | /// |
| 311 | /// If this returns a bitfield reference, nothing about the pointee type of |
| 312 | /// the LLVM value is known: For example, it may not be a pointer to an |
| 313 | /// integer. |
| 314 | /// |
| 315 | /// If this returns a normal address, and if the lvalue's C type is fixed |
| 316 | /// size, this method guarantees that the returned pointer type will point to |
| 317 | /// an LLVM type of the same size of the lvalue's type. If the lvalue has a |
| 318 | /// variable length type, this is not possible. |
| 319 | /// |
| 320 | LValue EmitLValue(const Expr *E); |
| 321 | |
| 322 | /// EmitLoadOfLValue - Given an expression that represents a value lvalue, |
| 323 | /// this method emits the address of the lvalue, then loads the result as an |
| 324 | /// rvalue, returning the rvalue. |
| 325 | RValue EmitLoadOfLValue(const Expr *E); |
| 326 | RValue EmitLoadOfLValue(LValue V, QualType LVType); |
Chris Lattner | 6481a57 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 327 | RValue EmitLoadOfOCUElementLValue(LValue V, QualType LVType); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 328 | |
Chris Lattner | 34cdc86 | 2007-08-03 16:18:34 +0000 | [diff] [blame] | 329 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 330 | /// EmitStoreThroughLValue - Store the specified rvalue into the specified |
| 331 | /// lvalue, where both are guaranteed to the have the same type, and that type |
| 332 | /// is 'Ty'. |
| 333 | void EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty); |
Chris Lattner | 017d6aa | 2007-08-03 16:28:33 +0000 | [diff] [blame] | 334 | void EmitStoreThroughOCUComponentLValue(RValue Src, LValue Dst, QualType Ty); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 335 | |
| 336 | LValue EmitDeclRefLValue(const DeclRefExpr *E); |
| 337 | LValue EmitStringLiteralLValue(const StringLiteral *E); |
Anders Carlsson | 2274266 | 2007-07-21 05:21:51 +0000 | [diff] [blame] | 338 | LValue EmitPreDefinedLValue(const PreDefinedExpr *E); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 339 | LValue EmitUnaryOpLValue(const UnaryOperator *E); |
| 340 | LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E); |
Chris Lattner | 6481a57 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 341 | LValue EmitOCUVectorElementExpr(const OCUVectorElementExpr *E); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 342 | |
| 343 | //===--------------------------------------------------------------------===// |
Chris Lattner | 883f6a7 | 2007-08-11 00:04:45 +0000 | [diff] [blame] | 344 | // Scalar Expression Emission |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 345 | //===--------------------------------------------------------------------===// |
| 346 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 347 | void EmitCompoundAssignmentOperands(const CompoundAssignOperator *CAO, |
| 348 | LValue &LHSLV, RValue &LHS, RValue &RHS); |
| 349 | RValue EmitCompoundAssignmentResult(const CompoundAssignOperator *E, |
| 350 | LValue LHSLV, RValue ResV); |
| 351 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 352 | RValue EmitExpr(const Expr *E); |
| 353 | RValue EmitIntegerLiteral(const IntegerLiteral *E); |
| 354 | RValue EmitFloatingLiteral(const FloatingLiteral *E); |
Chris Lattner | b0a721a | 2007-07-13 05:18:11 +0000 | [diff] [blame] | 355 | RValue EmitCharacterLiteral(const CharacterLiteral *E); |
Chris Lattner | 30bf3ae | 2007-08-03 17:51:03 +0000 | [diff] [blame] | 356 | RValue EmitTypesCompatibleExpr(const TypesCompatibleExpr *E); |
Chris Lattner | b0a721a | 2007-07-13 05:18:11 +0000 | [diff] [blame] | 357 | |
Chris Lattner | 7016a70 | 2007-08-20 22:37:10 +0000 | [diff] [blame] | 358 | RValue EmitImplicitCastExpr(const ImplicitCastExpr *Op); |
Chris Lattner | d07eb3b | 2007-07-13 20:25:53 +0000 | [diff] [blame] | 359 | RValue EmitCastExpr(const Expr *Op, QualType DestTy); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 360 | RValue EmitCallExpr(const CallExpr *E); |
Anders Carlsson | 022012e | 2007-08-20 18:05:56 +0000 | [diff] [blame] | 361 | RValue EmitBuiltinExpr(unsigned builtinID, const CallExpr *E); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 362 | RValue EmitArraySubscriptExprRV(const ArraySubscriptExpr *E); |
| 363 | |
| 364 | // Unary Operators. |
| 365 | RValue EmitUnaryOperator(const UnaryOperator *E); |
Chris Lattner | 5727479 | 2007-07-11 23:43:46 +0000 | [diff] [blame] | 366 | RValue EmitUnaryIncDec (const UnaryOperator *E); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 367 | RValue EmitUnaryAddrOf (const UnaryOperator *E); |
| 368 | RValue EmitUnaryPlus (const UnaryOperator *E); |
| 369 | RValue EmitUnaryMinus (const UnaryOperator *E); |
| 370 | RValue EmitUnaryNot (const UnaryOperator *E); |
| 371 | RValue EmitUnaryLNot (const UnaryOperator *E); |
Chris Lattner | 5e3fbe5 | 2007-07-18 18:12:07 +0000 | [diff] [blame] | 372 | RValue EmitSizeAlignOf (QualType TypeToSize, QualType RetType,bool isSizeOf); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 373 | // FIXME: real/imag |
| 374 | |
| 375 | // Binary Operators. |
| 376 | RValue EmitBinaryOperator(const BinaryOperator *E); |
| 377 | RValue EmitBinaryMul(const BinaryOperator *E); |
| 378 | RValue EmitBinaryDiv(const BinaryOperator *E); |
| 379 | RValue EmitBinaryRem(const BinaryOperator *E); |
| 380 | RValue EmitMul(RValue LHS, RValue RHS, QualType EltTy); |
| 381 | RValue EmitDiv(RValue LHS, RValue RHS, QualType EltTy); |
| 382 | RValue EmitRem(RValue LHS, RValue RHS, QualType EltTy); |
| 383 | RValue EmitAdd(RValue LHS, RValue RHS, QualType EltTy); |
Chris Lattner | 8b9023b | 2007-07-13 03:05:23 +0000 | [diff] [blame] | 384 | RValue EmitPointerAdd(RValue LHS, QualType LHSTy, |
| 385 | RValue RHS, QualType RHSTy, QualType EltTy); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 386 | RValue EmitSub(RValue LHS, RValue RHS, QualType EltTy); |
Chris Lattner | 8b9023b | 2007-07-13 03:05:23 +0000 | [diff] [blame] | 387 | RValue EmitPointerSub(RValue LHS, QualType LHSTy, |
| 388 | RValue RHS, QualType RHSTy, QualType EltTy); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 389 | RValue EmitShl(RValue LHS, RValue RHS, QualType ResTy); |
| 390 | RValue EmitShr(RValue LHS, RValue RHS, QualType ResTy); |
| 391 | RValue EmitBinaryCompare(const BinaryOperator *E, unsigned UICmpOpc, |
| 392 | unsigned SICmpOpc, unsigned FCmpOpc); |
| 393 | RValue EmitAnd(RValue LHS, RValue RHS, QualType EltTy); |
| 394 | RValue EmitOr (RValue LHS, RValue RHS, QualType EltTy); |
| 395 | RValue EmitXor(RValue LHS, RValue RHS, QualType EltTy); |
| 396 | RValue EmitBinaryLAnd(const BinaryOperator *E); |
| 397 | RValue EmitBinaryLOr(const BinaryOperator *E); |
| 398 | |
| 399 | RValue EmitBinaryAssign(const BinaryOperator *E); |
| 400 | RValue EmitBinaryComma(const BinaryOperator *E); |
Chris Lattner | b0a721a | 2007-07-13 05:18:11 +0000 | [diff] [blame] | 401 | |
| 402 | // Conditional Operator. |
| 403 | RValue EmitConditionalOperator(const ConditionalOperator *E); |
Chris Lattner | 94f05e3 | 2007-08-04 00:20:15 +0000 | [diff] [blame] | 404 | RValue EmitChooseExpr(const ChooseExpr *E); |
Chris Lattner | 883f6a7 | 2007-08-11 00:04:45 +0000 | [diff] [blame] | 405 | |
| 406 | //===--------------------------------------------------------------------===// |
| 407 | // Aggregate Expression Emission |
| 408 | //===--------------------------------------------------------------------===// |
| 409 | |
| 410 | void EmitAggregateCopy(llvm::Value *DestPtr, llvm::Value *SrcPtr, |
| 411 | QualType EltTy); |
| 412 | |
| 413 | /// EmitAggExpr - Emit the computation of the specified expression of |
| 414 | /// aggregate type. The result is computed into DestPtr. Note that if |
| 415 | /// DestPtr is null, the value of the aggregate expression is not needed. |
| 416 | void EmitAggExpr(const Expr *E, llvm::Value *DestPtr, bool VolatileDest); |
Chris Lattner | b6ef18a | 2007-08-21 05:54:00 +0000 | [diff] [blame] | 417 | |
| 418 | /// EmitComplexExpr - Emit the computation of the specified expression of |
| 419 | /// complex type, ignoring the result. |
Chris Lattner | 58dee10 | 2007-08-21 16:57:55 +0000 | [diff] [blame^] | 420 | ComplexPairTy EmitComplexExpr(const Expr *E); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 421 | }; |
| 422 | } // end namespace CodeGen |
| 423 | } // end namespace clang |
| 424 | |
| 425 | #endif |