Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +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" |
| 18 | #include "llvm/ADT/SmallVector.h" |
| 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; |
| 50 | class CharacterLiteral; |
Chris Lattner | 4ca7e75 | 2007-08-03 17:51:03 +0000 | [diff] [blame] | 51 | class TypesCompatibleExpr; |
| 52 | |
Chris Lattner | b2cb9cb | 2007-08-20 22:37:10 +0000 | [diff] [blame] | 53 | class ImplicitCastExpr; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 54 | class CastExpr; |
| 55 | class CallExpr; |
| 56 | class UnaryOperator; |
| 57 | class BinaryOperator; |
| 58 | class CompoundAssignOperator; |
| 59 | class ArraySubscriptExpr; |
Chris Lattner | a0d03a7 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 60 | class OCUVectorElementExpr; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 61 | class ConditionalOperator; |
Chris Lattner | 44fcf4f | 2007-08-04 00:20:15 +0000 | [diff] [blame] | 62 | class ChooseExpr; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 63 | class PreDefinedExpr; |
Anders Carlsson | a66cad4 | 2007-08-21 17:43:55 +0000 | [diff] [blame] | 64 | class ObjCStringLiteral; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 65 | |
| 66 | class BlockVarDecl; |
| 67 | class EnumConstantDecl; |
| 68 | class ParmVarDecl; |
| 69 | namespace CodeGen { |
| 70 | class CodeGenModule; |
| 71 | |
| 72 | |
| 73 | /// RValue - This trivial value class is used to represent the result of an |
Chris Lattner | e24c4cf | 2007-08-31 22:49:20 +0000 | [diff] [blame] | 74 | /// expression that is evaluated. It can be one of three things: either a |
| 75 | /// simple LLVM SSA value, a pair of SSA values for complex numbers, or the |
| 76 | /// address of an aggregate value in memory. |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 77 | class RValue { |
Chris Lattner | e24c4cf | 2007-08-31 22:49:20 +0000 | [diff] [blame] | 78 | llvm::Value *V1, *V2; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 79 | // TODO: Encode this into the low bit of pointer for more efficient |
| 80 | // return-by-value. |
Chris Lattner | e24c4cf | 2007-08-31 22:49:20 +0000 | [diff] [blame] | 81 | enum { Scalar, Complex, Aggregate } Flavor; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 82 | |
| 83 | // FIXME: Aggregate rvalues need to retain information about whether they are |
| 84 | // volatile or not. |
| 85 | public: |
| 86 | |
Chris Lattner | e24c4cf | 2007-08-31 22:49:20 +0000 | [diff] [blame] | 87 | bool isScalar() const { return Flavor == Scalar; } |
| 88 | bool isComplex() const { return Flavor == Complex; } |
| 89 | bool isAggregate() const { return Flavor == Aggregate; } |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 90 | |
Chris Lattner | e24c4cf | 2007-08-31 22:49:20 +0000 | [diff] [blame] | 91 | /// getScalar() - Return the Value* of this scalar value. |
| 92 | llvm::Value *getScalarVal() const { |
| 93 | assert(isScalar() && "Not a scalar!"); |
| 94 | return V1; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Chris Lattner | e24c4cf | 2007-08-31 22:49:20 +0000 | [diff] [blame] | 97 | /// getComplexVal - Return the real/imag components of this complex value. |
| 98 | /// |
| 99 | std::pair<llvm::Value *, llvm::Value *> getComplexVal() const { |
| 100 | return std::pair<llvm::Value *, llvm::Value *>(V1, V2); |
| 101 | } |
| 102 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 103 | /// getAggregateAddr() - Return the Value* of the address of the aggregate. |
| 104 | llvm::Value *getAggregateAddr() const { |
| 105 | assert(isAggregate() && "Not an aggregate!"); |
Chris Lattner | e24c4cf | 2007-08-31 22:49:20 +0000 | [diff] [blame] | 106 | return V1; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | static RValue get(llvm::Value *V) { |
| 110 | RValue ER; |
Chris Lattner | e24c4cf | 2007-08-31 22:49:20 +0000 | [diff] [blame] | 111 | ER.V1 = V; |
| 112 | ER.Flavor = Scalar; |
| 113 | return ER; |
| 114 | } |
| 115 | static RValue getComplex(llvm::Value *V1, llvm::Value *V2) { |
| 116 | RValue ER; |
| 117 | ER.V1 = V1; |
| 118 | ER.V2 = V2; |
| 119 | ER.Flavor = Complex; |
| 120 | return ER; |
| 121 | } |
| 122 | static RValue getComplex(const std::pair<llvm::Value *, llvm::Value *> &C) { |
| 123 | RValue ER; |
| 124 | ER.V1 = C.first; |
| 125 | ER.V2 = C.second; |
| 126 | ER.Flavor = Complex; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 127 | return ER; |
| 128 | } |
| 129 | static RValue getAggregate(llvm::Value *V) { |
| 130 | RValue ER; |
Chris Lattner | e24c4cf | 2007-08-31 22:49:20 +0000 | [diff] [blame] | 131 | ER.V1 = V; |
| 132 | ER.Flavor = Aggregate; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 133 | return ER; |
| 134 | } |
| 135 | }; |
| 136 | |
| 137 | |
| 138 | /// LValue - This represents an lvalue references. Because C/C++ allow |
| 139 | /// bitfields, this is not a simple LLVM pointer, it may be a pointer plus a |
| 140 | /// bitrange. |
| 141 | class LValue { |
| 142 | // FIXME: Volatility. Restrict? |
| 143 | // alignment? |
| 144 | |
| 145 | enum { |
Chris Lattner | 6552019 | 2007-08-02 23:37:31 +0000 | [diff] [blame] | 146 | Simple, // This is a normal l-value, use getAddress(). |
| 147 | VectorElt, // This is a vector element l-value (V[i]), use getVector* |
| 148 | BitField, // This is a bitfield l-value, use getBitfield*. |
Chris Lattner | a0d03a7 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 149 | OCUVectorElt // This is an ocu vector subset, use getOCUVectorComp |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 150 | } LVType; |
| 151 | |
| 152 | llvm::Value *V; |
| 153 | |
| 154 | union { |
Chris Lattner | 6552019 | 2007-08-02 23:37:31 +0000 | [diff] [blame] | 155 | llvm::Value *VectorIdx; // Index into a vector subscript: V[i] |
Chris Lattner | a0d03a7 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 156 | unsigned VectorElts; // Encoded OCUVector element subset: V.xyx |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 157 | }; |
| 158 | public: |
| 159 | bool isSimple() const { return LVType == Simple; } |
| 160 | bool isVectorElt() const { return LVType == VectorElt; } |
| 161 | bool isBitfield() const { return LVType == BitField; } |
Chris Lattner | a0d03a7 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 162 | bool isOCUVectorElt() const { return LVType == OCUVectorElt; } |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 163 | |
| 164 | // simple lvalue |
| 165 | llvm::Value *getAddress() const { assert(isSimple()); return V; } |
| 166 | // vector elt lvalue |
| 167 | llvm::Value *getVectorAddr() const { assert(isVectorElt()); return V; } |
| 168 | llvm::Value *getVectorIdx() const { assert(isVectorElt()); return VectorIdx; } |
Chris Lattner | a0d03a7 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 169 | // ocu vector elements. |
| 170 | llvm::Value *getOCUVectorAddr() const { assert(isOCUVectorElt()); return V; } |
| 171 | unsigned getOCUVectorElts() const { |
| 172 | assert(isOCUVectorElt()); |
| 173 | return VectorElts; |
Chris Lattner | 6552019 | 2007-08-02 23:37:31 +0000 | [diff] [blame] | 174 | } |
| 175 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 176 | |
| 177 | static LValue MakeAddr(llvm::Value *V) { |
| 178 | LValue R; |
| 179 | R.LVType = Simple; |
| 180 | R.V = V; |
| 181 | return R; |
| 182 | } |
| 183 | |
| 184 | static LValue MakeVectorElt(llvm::Value *Vec, llvm::Value *Idx) { |
| 185 | LValue R; |
| 186 | R.LVType = VectorElt; |
| 187 | R.V = Vec; |
| 188 | R.VectorIdx = Idx; |
| 189 | return R; |
| 190 | } |
| 191 | |
Chris Lattner | a0d03a7 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 192 | static LValue MakeOCUVectorElt(llvm::Value *Vec, unsigned Elements) { |
Chris Lattner | 6552019 | 2007-08-02 23:37:31 +0000 | [diff] [blame] | 193 | LValue R; |
Chris Lattner | a0d03a7 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 194 | R.LVType = OCUVectorElt; |
Chris Lattner | 6552019 | 2007-08-02 23:37:31 +0000 | [diff] [blame] | 195 | R.V = Vec; |
Chris Lattner | a0d03a7 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 196 | R.VectorElts = Elements; |
Chris Lattner | 6552019 | 2007-08-02 23:37:31 +0000 | [diff] [blame] | 197 | return R; |
| 198 | } |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 199 | }; |
| 200 | |
| 201 | /// CodeGenFunction - This class organizes the per-function state that is used |
| 202 | /// while generating LLVM code. |
| 203 | class CodeGenFunction { |
Chris Lattner | 41b1fca | 2007-08-26 23:13:56 +0000 | [diff] [blame] | 204 | public: |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 205 | CodeGenModule &CGM; // Per-module state. |
| 206 | TargetInfo &Target; |
Chris Lattner | 41b1fca | 2007-08-26 23:13:56 +0000 | [diff] [blame] | 207 | |
Chris Lattner | 5280c5f | 2007-08-21 16:57:55 +0000 | [diff] [blame] | 208 | typedef std::pair<llvm::Value *, llvm::Value *> ComplexPairTy; |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 209 | llvm::LLVMBuilder Builder; |
| 210 | |
| 211 | const FunctionDecl *CurFuncDecl; |
| 212 | llvm::Function *CurFn; |
| 213 | |
| 214 | /// AllocaInsertPoint - This is an instruction in the entry block before which |
| 215 | /// we prefer to insert allocas. |
| 216 | llvm::Instruction *AllocaInsertPt; |
| 217 | |
| 218 | const llvm::Type *LLVMIntTy; |
| 219 | unsigned LLVMPointerWidth; |
| 220 | |
Chris Lattner | 9fba49a | 2007-08-24 05:35:26 +0000 | [diff] [blame] | 221 | private: |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 222 | /// LocalDeclMap - This keeps track of the LLVM allocas or globals for local C |
| 223 | /// decls. |
| 224 | llvm::DenseMap<const Decl*, llvm::Value*> LocalDeclMap; |
| 225 | |
| 226 | /// LabelMap - This keeps track of the LLVM basic block for each C label. |
| 227 | llvm::DenseMap<const LabelStmt*, llvm::BasicBlock*> LabelMap; |
| 228 | |
| 229 | // BreakContinueStack - This keeps track of where break and continue |
| 230 | // statements should jump to. |
| 231 | struct BreakContinue { |
| 232 | BreakContinue(llvm::BasicBlock *bb, llvm::BasicBlock *cb) |
| 233 | : BreakBlock(bb), ContinueBlock(cb) {} |
| 234 | |
| 235 | llvm::BasicBlock *BreakBlock; |
| 236 | llvm::BasicBlock *ContinueBlock; |
| 237 | }; |
| 238 | llvm::SmallVector<BreakContinue, 8> BreakContinueStack; |
| 239 | |
| 240 | public: |
| 241 | CodeGenFunction(CodeGenModule &cgm); |
| 242 | |
| 243 | ASTContext &getContext() const; |
| 244 | |
| 245 | void GenerateCode(const FunctionDecl *FD); |
| 246 | |
| 247 | const llvm::Type *ConvertType(QualType T); |
| 248 | |
| 249 | /// hasAggregateLLVMType - Return true if the specified AST type will map into |
| 250 | /// an aggregate LLVM type or is void. |
| 251 | static bool hasAggregateLLVMType(QualType T); |
| 252 | |
| 253 | /// getBasicBlockForLabel - Return the LLVM basicblock that the specified |
| 254 | /// label maps to. |
| 255 | llvm::BasicBlock *getBasicBlockForLabel(const LabelStmt *S); |
| 256 | |
| 257 | |
| 258 | void EmitBlock(llvm::BasicBlock *BB); |
| 259 | |
| 260 | //===--------------------------------------------------------------------===// |
| 261 | // Helpers |
| 262 | //===--------------------------------------------------------------------===// |
| 263 | |
| 264 | /// CreateTempAlloca - This creates a alloca and inserts it into the entry |
| 265 | /// block. |
| 266 | llvm::AllocaInst *CreateTempAlloca(const llvm::Type *Ty, |
| 267 | const char *Name = "tmp"); |
| 268 | |
| 269 | /// EvaluateExprAsBool - Perform the usual unary conversions on the specified |
| 270 | /// expression and compare the result against zero, returning an Int1Ty value. |
| 271 | llvm::Value *EvaluateExprAsBool(const Expr *E); |
| 272 | |
Chris Lattner | e24c4cf | 2007-08-31 22:49:20 +0000 | [diff] [blame] | 273 | /// EmitAnyExpr - Emit code to compute the specified expression which can have |
| 274 | /// any type. The result is returned as an RValue struct. If this is an |
| 275 | /// aggregate expression, the aggloc/agglocvolatile arguments indicate where |
| 276 | /// the result should be returned. |
| 277 | RValue EmitAnyExpr(const Expr *E, llvm::Value *AggLoc = 0, |
| 278 | bool isAggLocVolatile = false); |
Devang Patel | 9729936 | 2007-09-28 21:49:18 +0000 | [diff] [blame^] | 279 | |
| 280 | /// isDummyBlock - Return true if BB is an empty basic block |
| 281 | /// with no predecessors. |
| 282 | static bool isDummyBlock(const llvm::BasicBlock *BB); |
| 283 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 284 | //===--------------------------------------------------------------------===// |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 285 | // Declaration Emission |
| 286 | //===--------------------------------------------------------------------===// |
| 287 | |
| 288 | void EmitDecl(const Decl &D); |
| 289 | void EmitEnumConstantDecl(const EnumConstantDecl &D); |
| 290 | void EmitBlockVarDecl(const BlockVarDecl &D); |
| 291 | void EmitLocalBlockVarDecl(const BlockVarDecl &D); |
| 292 | void EmitParmDecl(const ParmVarDecl &D, llvm::Value *Arg); |
| 293 | |
| 294 | //===--------------------------------------------------------------------===// |
| 295 | // Statement Emission |
| 296 | //===--------------------------------------------------------------------===// |
| 297 | |
| 298 | void EmitStmt(const Stmt *S); |
Chris Lattner | e24c4cf | 2007-08-31 22:49:20 +0000 | [diff] [blame] | 299 | RValue EmitCompoundStmt(const CompoundStmt &S, bool GetLast = false, |
| 300 | llvm::Value *AggLoc = 0, bool isAggVol = false); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 301 | void EmitLabelStmt(const LabelStmt &S); |
| 302 | void EmitGotoStmt(const GotoStmt &S); |
| 303 | void EmitIfStmt(const IfStmt &S); |
| 304 | void EmitWhileStmt(const WhileStmt &S); |
| 305 | void EmitDoStmt(const DoStmt &S); |
| 306 | void EmitForStmt(const ForStmt &S); |
| 307 | void EmitReturnStmt(const ReturnStmt &S); |
| 308 | void EmitDeclStmt(const DeclStmt &S); |
| 309 | void EmitBreakStmt(); |
| 310 | void EmitContinueStmt(); |
| 311 | |
| 312 | //===--------------------------------------------------------------------===// |
| 313 | // LValue Expression Emission |
| 314 | //===--------------------------------------------------------------------===// |
| 315 | |
| 316 | /// EmitLValue - Emit code to compute a designator that specifies the location |
| 317 | /// of the expression. |
| 318 | /// |
| 319 | /// This can return one of two things: a simple address or a bitfield |
| 320 | /// reference. In either case, the LLVM Value* in the LValue structure is |
| 321 | /// guaranteed to be an LLVM pointer type. |
| 322 | /// |
| 323 | /// If this returns a bitfield reference, nothing about the pointee type of |
| 324 | /// the LLVM value is known: For example, it may not be a pointer to an |
| 325 | /// integer. |
| 326 | /// |
| 327 | /// If this returns a normal address, and if the lvalue's C type is fixed |
| 328 | /// size, this method guarantees that the returned pointer type will point to |
| 329 | /// an LLVM type of the same size of the lvalue's type. If the lvalue has a |
| 330 | /// variable length type, this is not possible. |
| 331 | /// |
| 332 | LValue EmitLValue(const Expr *E); |
| 333 | |
| 334 | /// EmitLoadOfLValue - Given an expression that represents a value lvalue, |
| 335 | /// this method emits the address of the lvalue, then loads the result as an |
| 336 | /// rvalue, returning the rvalue. |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 337 | RValue EmitLoadOfLValue(LValue V, QualType LVType); |
Chris Lattner | a0d03a7 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 338 | RValue EmitLoadOfOCUElementLValue(LValue V, QualType LVType); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 339 | |
Chris Lattner | 944f796 | 2007-08-03 16:18:34 +0000 | [diff] [blame] | 340 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 341 | /// EmitStoreThroughLValue - Store the specified rvalue into the specified |
| 342 | /// lvalue, where both are guaranteed to the have the same type, and that type |
| 343 | /// is 'Ty'. |
| 344 | void EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty); |
Chris Lattner | 5bfdd23 | 2007-08-03 16:28:33 +0000 | [diff] [blame] | 345 | void EmitStoreThroughOCUComponentLValue(RValue Src, LValue Dst, QualType Ty); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 346 | |
| 347 | LValue EmitDeclRefLValue(const DeclRefExpr *E); |
| 348 | LValue EmitStringLiteralLValue(const StringLiteral *E); |
| 349 | LValue EmitPreDefinedLValue(const PreDefinedExpr *E); |
| 350 | LValue EmitUnaryOpLValue(const UnaryOperator *E); |
| 351 | LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E); |
Chris Lattner | a0d03a7 | 2007-08-03 17:31:20 +0000 | [diff] [blame] | 352 | LValue EmitOCUVectorElementExpr(const OCUVectorElementExpr *E); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 353 | |
| 354 | //===--------------------------------------------------------------------===// |
Chris Lattner | bdb8ffb | 2007-08-11 00:04:45 +0000 | [diff] [blame] | 355 | // Scalar Expression Emission |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 356 | //===--------------------------------------------------------------------===// |
| 357 | |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 358 | RValue EmitCallExpr(const CallExpr *E); |
Chris Lattner | 02c60f5 | 2007-08-31 04:44:06 +0000 | [diff] [blame] | 359 | RValue EmitCallExpr(llvm::Value *Callee, const CallExpr *E); |
Chris Lattner | 35055b8 | 2007-08-26 22:58:05 +0000 | [diff] [blame] | 360 | RValue EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 361 | |
Chris Lattner | 9fba49a | 2007-08-24 05:35:26 +0000 | [diff] [blame] | 362 | llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E); |
Anders Carlsson | a66cad4 | 2007-08-21 17:43:55 +0000 | [diff] [blame] | 363 | |
Chris Lattner | bdb8ffb | 2007-08-11 00:04:45 +0000 | [diff] [blame] | 364 | //===--------------------------------------------------------------------===// |
Chris Lattner | 41b1fca | 2007-08-26 23:13:56 +0000 | [diff] [blame] | 365 | // Expression Emission |
Chris Lattner | bdb8ffb | 2007-08-11 00:04:45 +0000 | [diff] [blame] | 366 | //===--------------------------------------------------------------------===// |
Chris Lattner | 41b1fca | 2007-08-26 23:13:56 +0000 | [diff] [blame] | 367 | |
| 368 | // Expressions are broken into three classes: scalar, complex, aggregate. |
Chris Lattner | bdb8ffb | 2007-08-11 00:04:45 +0000 | [diff] [blame] | 369 | |
Chris Lattner | 9fba49a | 2007-08-24 05:35:26 +0000 | [diff] [blame] | 370 | /// EmitScalarExpr - Emit the computation of the specified expression of |
| 371 | /// LLVM scalar type, returning the result. |
| 372 | llvm::Value *EmitScalarExpr(const Expr *E); |
| 373 | |
Chris Lattner | 4e05d1e | 2007-08-26 06:48:56 +0000 | [diff] [blame] | 374 | /// EmitScalarConversion - Emit a conversion from the specified type to the |
| 375 | /// specified destination type, both of which are LLVM scalar types. |
| 376 | llvm::Value *EmitScalarConversion(llvm::Value *Src, QualType SrcTy, |
| 377 | QualType DstTy); |
| 378 | |
Chris Lattner | fb182ee | 2007-08-26 16:34:22 +0000 | [diff] [blame] | 379 | /// EmitComplexToScalarConversion - Emit a conversion from the specified |
| 380 | /// complex type to the specified destination type, where the destination |
| 381 | /// type is an LLVM scalar type. |
| 382 | llvm::Value *EmitComplexToScalarConversion(ComplexPairTy Src, QualType SrcTy, |
| 383 | QualType DstTy); |
| 384 | |
Chris Lattner | 4e05d1e | 2007-08-26 06:48:56 +0000 | [diff] [blame] | 385 | |
Chris Lattner | bdb8ffb | 2007-08-11 00:04:45 +0000 | [diff] [blame] | 386 | /// EmitAggExpr - Emit the computation of the specified expression of |
| 387 | /// aggregate type. The result is computed into DestPtr. Note that if |
| 388 | /// DestPtr is null, the value of the aggregate expression is not needed. |
| 389 | void EmitAggExpr(const Expr *E, llvm::Value *DestPtr, bool VolatileDest); |
Chris Lattner | 8d0cc2f | 2007-08-21 05:54:00 +0000 | [diff] [blame] | 390 | |
| 391 | /// EmitComplexExpr - Emit the computation of the specified expression of |
Chris Lattner | 348c8a2 | 2007-08-23 23:43:33 +0000 | [diff] [blame] | 392 | /// complex type, returning the result. |
Chris Lattner | 5280c5f | 2007-08-21 16:57:55 +0000 | [diff] [blame] | 393 | ComplexPairTy EmitComplexExpr(const Expr *E); |
Chris Lattner | 348c8a2 | 2007-08-23 23:43:33 +0000 | [diff] [blame] | 394 | |
| 395 | /// EmitComplexExprIntoAddr - Emit the computation of the specified expression |
| 396 | /// of complex type, storing into the specified Value*. |
Chris Lattner | 8e1f6e0 | 2007-08-26 16:22:13 +0000 | [diff] [blame] | 397 | void EmitComplexExprIntoAddr(const Expr *E, llvm::Value *DestAddr, |
| 398 | bool DestIsVolatile); |
Chris Lattner | e24c4cf | 2007-08-31 22:49:20 +0000 | [diff] [blame] | 399 | /// LoadComplexFromAddr - Load a complex number from the specified address. |
| 400 | ComplexPairTy LoadComplexFromAddr(llvm::Value *SrcAddr, bool SrcIsVolatile); |
Chris Lattner | 4b00965 | 2007-07-25 00:24:17 +0000 | [diff] [blame] | 401 | }; |
| 402 | } // end namespace CodeGen |
| 403 | } // end namespace clang |
| 404 | |
| 405 | #endif |