2008-07-30 07:18:29 +08:00
|
|
|
//===-- CodeGenFunction.h - Per-Function state for LLVM CodeGen -*- C++ -*-===//
|
2007-05-24 14:29:05 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 03:59:25 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-05-24 14:29:05 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-02-09 07:14:22 +08:00
|
|
|
// This is the internal per-function state used for llvm translation.
|
2007-05-24 14:29:05 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-03-01 01:10:38 +08:00
|
|
|
#ifndef CLANG_CODEGEN_CODEGENFUNCTION_H
|
|
|
|
#define CLANG_CODEGEN_CODEGENFUNCTION_H
|
2007-05-24 14:29:05 +08:00
|
|
|
|
2008-03-31 07:03:07 +08:00
|
|
|
#include "clang/AST/Type.h"
|
2008-09-10 10:36:38 +08:00
|
|
|
#include "clang/AST/ExprCXX.h"
|
This patch is motivated by numerous strict-aliasing warnings when compiling
clang as a Release build.
The big change is that all AST nodes (subclasses of Stmt) whose children are
Expr* store their children as Stmt* or arrays of Stmt*. This is to remove
strict-aliasing warnings when using StmtIterator. None of the interfaces of any
of the classes have changed (except those with arg_iterators, see below), as the
accessor methods introduce the needed casts (via cast<>). While this extra
casting may seem cumbersome, it actually adds some important sanity checks
throughout the codebase, as clients using StmtIterator can potentially overwrite
children that are expected to be Expr* with Stmt* (that aren't Expr*). The casts
provide extra sanity checks that are operational in debug builds to catch
invariant violations such as these.
For classes that have arg_iterators (e.g., CallExpr), the definition of
arg_iterator has been replaced. Instead of it being Expr**, it is an actual
class (called ExprIterator) that wraps a Stmt**, and provides the necessary
operators for iteration. The nice thing about this class is that it also uses
cast<> to type-checking, which introduces extra sanity checks throughout the
codebase that are useful for debugging.
A few of the CodeGen functions that use arg_iterator (especially from
OverloadExpr) have been modified to take begin and end iterators instead of a
base Expr** and the number of arguments. This matches more with the abstraction
of iteration. This still needs to be cleaned up a little bit, as clients expect
that ExprIterator is a RandomAccessIterator (which we may or may not wish to
allow for efficiency of representation).
This is a fairly large patch. It passes the tests (except CodeGen/bitfield.c,
which was already broken) on both a Debug and Release build, but it should
obviously be reviewed.
llvm-svn: 52378
2008-06-17 10:43:46 +08:00
|
|
|
#include "clang/AST/ExprObjC.h"
|
2009-04-01 06:17:44 +08:00
|
|
|
#include "clang/Basic/TargetInfo.h"
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
#include "llvm/Support/ValueHandle.h"
|
2008-08-05 00:51:22 +08:00
|
|
|
#include <map>
|
2009-07-13 12:10:07 +08:00
|
|
|
#include "CodeGenModule.h"
|
2009-03-04 23:32:52 +08:00
|
|
|
#include "CGBlocks.h"
|
2008-11-01 09:53:16 +08:00
|
|
|
#include "CGBuilder.h"
|
2008-09-09 05:33:45 +08:00
|
|
|
#include "CGCall.h"
|
2009-04-17 08:06:03 +08:00
|
|
|
#include "CGCXX.h"
|
2008-08-23 11:46:30 +08:00
|
|
|
#include "CGValue.h"
|
|
|
|
|
2007-05-24 14:29:05 +08:00
|
|
|
namespace llvm {
|
2008-08-11 13:35:13 +08:00
|
|
|
class BasicBlock;
|
2009-08-12 01:46:57 +08:00
|
|
|
class LLVMContext;
|
2007-05-24 14:29:05 +08:00
|
|
|
class Module;
|
2008-09-30 09:06:03 +08:00
|
|
|
class SwitchInst;
|
2009-10-19 09:21:05 +08:00
|
|
|
class Twine;
|
2008-11-19 17:36:46 +08:00
|
|
|
class Value;
|
2007-06-16 07:05:46 +08:00
|
|
|
}
|
|
|
|
|
2007-05-24 14:29:05 +08:00
|
|
|
namespace clang {
|
|
|
|
class ASTContext;
|
2009-05-30 05:03:38 +08:00
|
|
|
class CXXDestructorDecl;
|
2009-09-28 02:58:34 +08:00
|
|
|
class CXXTryStmt;
|
2007-06-02 12:16:21 +08:00
|
|
|
class Decl;
|
2008-08-11 13:35:13 +08:00
|
|
|
class EnumConstantDecl;
|
2007-05-24 14:29:05 +08:00
|
|
|
class FunctionDecl;
|
2009-02-27 07:50:07 +08:00
|
|
|
class FunctionProtoType;
|
2008-08-11 13:35:13 +08:00
|
|
|
class LabelStmt;
|
2009-01-11 05:06:09 +08:00
|
|
|
class ObjCContainerDecl;
|
2008-09-24 12:00:38 +08:00
|
|
|
class ObjCInterfaceDecl;
|
|
|
|
class ObjCIvarDecl;
|
2008-03-31 07:03:07 +08:00
|
|
|
class ObjCMethodDecl;
|
2008-12-10 04:23:04 +08:00
|
|
|
class ObjCImplementationDecl;
|
2008-08-26 16:29:31 +08:00
|
|
|
class ObjCPropertyImplDecl;
|
2007-06-16 08:16:26 +08:00
|
|
|
class TargetInfo;
|
2008-08-11 13:35:13 +08:00
|
|
|
class VarDecl;
|
2009-04-26 09:32:48 +08:00
|
|
|
class ObjCForCollectionStmt;
|
|
|
|
class ObjCAtTryStmt;
|
|
|
|
class ObjCAtThrowStmt;
|
|
|
|
class ObjCAtSynchronizedStmt;
|
This patch is motivated by numerous strict-aliasing warnings when compiling
clang as a Release build.
The big change is that all AST nodes (subclasses of Stmt) whose children are
Expr* store their children as Stmt* or arrays of Stmt*. This is to remove
strict-aliasing warnings when using StmtIterator. None of the interfaces of any
of the classes have changed (except those with arg_iterators, see below), as the
accessor methods introduce the needed casts (via cast<>). While this extra
casting may seem cumbersome, it actually adds some important sanity checks
throughout the codebase, as clients using StmtIterator can potentially overwrite
children that are expected to be Expr* with Stmt* (that aren't Expr*). The casts
provide extra sanity checks that are operational in debug builds to catch
invariant violations such as these.
For classes that have arg_iterators (e.g., CallExpr), the definition of
arg_iterator has been replaced. Instead of it being Expr**, it is an actual
class (called ExprIterator) that wraps a Stmt**, and provides the necessary
operators for iteration. The nice thing about this class is that it also uses
cast<> to type-checking, which introduces extra sanity checks throughout the
codebase that are useful for debugging.
A few of the CodeGen functions that use arg_iterator (especially from
OverloadExpr) have been modified to take begin and end iterators instead of a
base Expr** and the number of arguments. This matches more with the abstraction
of iteration. This still needs to be cleaned up a little bit, as clients expect
that ExprIterator is a RandomAccessIterator (which we may or may not wish to
allow for efficiency of representation).
This is a fairly large patch. It passes the tests (except CodeGen/bitfield.c,
which was already broken) on both a Debug and Release build, but it should
obviously be reviewed.
llvm-svn: 52378
2008-06-17 10:43:46 +08:00
|
|
|
|
2007-05-24 14:29:05 +08:00
|
|
|
namespace CodeGen {
|
2007-05-28 09:07:47 +08:00
|
|
|
class CodeGenModule;
|
2007-10-23 10:10:49 +08:00
|
|
|
class CodeGenTypes;
|
2009-02-13 16:11:52 +08:00
|
|
|
class CGDebugInfo;
|
2009-02-03 05:43:58 +08:00
|
|
|
class CGFunctionInfo;
|
2009-02-09 07:14:22 +08:00
|
|
|
class CGRecordLayout;
|
|
|
|
|
2007-05-28 09:07:47 +08:00
|
|
|
/// CodeGenFunction - This class organizes the per-function state that is used
|
|
|
|
/// while generating LLVM code.
|
2009-03-05 02:17:45 +08:00
|
|
|
class CodeGenFunction : public BlockFunction {
|
2009-02-24 12:21:31 +08:00
|
|
|
CodeGenFunction(const CodeGenFunction&); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const CodeGenFunction&); // DO NOT IMPLEMENT
|
2007-08-27 07:13:56 +08:00
|
|
|
public:
|
2007-05-28 09:07:47 +08:00
|
|
|
CodeGenModule &CGM; // Per-module state.
|
2007-05-30 07:17:50 +08:00
|
|
|
TargetInfo &Target;
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2007-08-22 00:57:55 +08:00
|
|
|
typedef std::pair<llvm::Value *, llvm::Value *> ComplexPairTy;
|
2008-11-01 09:53:16 +08:00
|
|
|
CGBuilderTy Builder;
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-04-23 13:30:27 +08:00
|
|
|
/// CurFuncDecl - Holds the Decl for the current function or ObjC method.
|
|
|
|
/// This excludes BlockDecls.
|
2008-06-18 02:05:57 +08:00
|
|
|
const Decl *CurFuncDecl;
|
2009-04-23 13:30:27 +08:00
|
|
|
/// CurCodeDecl - This is the inner-most code context, which includes blocks.
|
|
|
|
const Decl *CurCodeDecl;
|
2009-02-03 06:03:45 +08:00
|
|
|
const CGFunctionInfo *CurFnInfo;
|
2008-03-31 07:03:07 +08:00
|
|
|
QualType FnRetTy;
|
2007-05-30 08:13:02 +08:00
|
|
|
llvm::Function *CurFn;
|
|
|
|
|
2008-09-10 05:00:17 +08:00
|
|
|
/// ReturnBlock - Unified return block.
|
|
|
|
llvm::BasicBlock *ReturnBlock;
|
2009-02-09 07:14:22 +08:00
|
|
|
/// ReturnValue - The temporary alloca to hold the return value. This is null
|
|
|
|
/// iff the function has no return value.
|
2008-09-10 05:00:17 +08:00
|
|
|
llvm::Instruction *ReturnValue;
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2007-06-02 12:53:11 +08:00
|
|
|
/// AllocaInsertPoint - This is an instruction in the entry block before which
|
|
|
|
/// we prefer to insert allocas.
|
2009-04-01 06:17:44 +08:00
|
|
|
llvm::AssertingVH<llvm::Instruction> AllocaInsertPt;
|
2008-08-05 00:51:22 +08:00
|
|
|
|
2007-06-03 06:49:07 +08:00
|
|
|
const llvm::Type *LLVMIntTy;
|
2007-10-17 23:00:17 +08:00
|
|
|
uint32_t LLVMPointerWidth;
|
2008-09-28 09:03:14 +08:00
|
|
|
|
|
|
|
public:
|
2009-02-10 14:07:49 +08:00
|
|
|
/// ObjCEHValueStack - Stack of Objective-C exception values, used for
|
|
|
|
/// rethrows.
|
2009-02-08 05:37:21 +08:00
|
|
|
llvm::SmallVector<llvm::Value*, 8> ObjCEHValueStack;
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-02-08 11:22:36 +08:00
|
|
|
/// PushCleanupBlock - Push a new cleanup entry on the stack and set the
|
|
|
|
/// passed in block as the cleanup block.
|
|
|
|
void PushCleanupBlock(llvm::BasicBlock *CleanupBlock);
|
2009-02-08 15:46:24 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// CleanupBlockInfo - A struct representing a popped cleanup block.
|
2009-02-08 15:46:24 +08:00
|
|
|
struct CleanupBlockInfo {
|
|
|
|
/// CleanupBlock - the cleanup block
|
|
|
|
llvm::BasicBlock *CleanupBlock;
|
2009-02-09 07:14:22 +08:00
|
|
|
|
|
|
|
/// SwitchBlock - the block (if any) containing the switch instruction used
|
|
|
|
/// for jumping to the final destination.
|
2009-02-08 15:46:24 +08:00
|
|
|
llvm::BasicBlock *SwitchBlock;
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-02-08 15:46:24 +08:00
|
|
|
/// EndBlock - the default destination for the switch instruction.
|
|
|
|
llvm::BasicBlock *EndBlock;
|
2009-02-09 07:14:22 +08:00
|
|
|
|
|
|
|
CleanupBlockInfo(llvm::BasicBlock *cb, llvm::BasicBlock *sb,
|
2009-02-08 15:46:24 +08:00
|
|
|
llvm::BasicBlock *eb)
|
|
|
|
: CleanupBlock(cb), SwitchBlock(sb), EndBlock(eb) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// PopCleanupBlock - Will pop the cleanup entry on the stack, process all
|
2009-02-09 07:14:22 +08:00
|
|
|
/// branch fixups and return a block info struct with the switch block and end
|
|
|
|
/// block.
|
2009-02-08 15:46:24 +08:00
|
|
|
CleanupBlockInfo PopCleanupBlock();
|
2009-02-09 07:14:22 +08:00
|
|
|
|
|
|
|
/// CleanupScope - RAII object that will create a cleanup block and set the
|
|
|
|
/// insert point to that block. When destructed, it sets the insert point to
|
|
|
|
/// the previous block and pushes a new cleanup entry on the stack.
|
2009-02-08 07:30:41 +08:00
|
|
|
class CleanupScope {
|
|
|
|
CodeGenFunction& CGF;
|
|
|
|
llvm::BasicBlock *CurBB;
|
2009-02-08 11:22:36 +08:00
|
|
|
llvm::BasicBlock *CleanupBB;
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-02-08 07:30:41 +08:00
|
|
|
public:
|
|
|
|
CleanupScope(CodeGenFunction &cgf)
|
|
|
|
: CGF(cgf), CurBB(CGF.Builder.GetInsertBlock()) {
|
2009-02-08 11:22:36 +08:00
|
|
|
CleanupBB = CGF.createBasicBlock("cleanup");
|
|
|
|
CGF.Builder.SetInsertPoint(CleanupBB);
|
2009-02-08 07:30:41 +08:00
|
|
|
}
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-02-08 07:30:41 +08:00
|
|
|
~CleanupScope() {
|
2009-02-08 11:22:36 +08:00
|
|
|
CGF.PushCleanupBlock(CleanupBB);
|
2009-07-19 14:58:07 +08:00
|
|
|
// FIXME: This is silly, move this into the builder.
|
|
|
|
if (CurBB)
|
|
|
|
CGF.Builder.SetInsertPoint(CurBB);
|
|
|
|
else
|
|
|
|
CGF.Builder.ClearInsertionPoint();
|
2009-02-08 07:30:41 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-02-08 07:50:39 +08:00
|
|
|
/// EmitCleanupBlocks - Takes the old cleanup stack size and emits the cleanup
|
|
|
|
/// blocks that have been added.
|
|
|
|
void EmitCleanupBlocks(size_t OldCleanupStackSize);
|
|
|
|
|
2009-02-08 08:50:42 +08:00
|
|
|
/// EmitBranchThroughCleanup - Emit a branch from the current insert block
|
|
|
|
/// through the cleanup handling code (if any) and then on to \arg Dest.
|
|
|
|
///
|
2009-02-09 07:14:22 +08:00
|
|
|
/// FIXME: Maybe this should really be in EmitBranch? Don't we always want
|
2009-02-08 08:50:42 +08:00
|
|
|
/// this behavior for branches?
|
|
|
|
void EmitBranchThroughCleanup(llvm::BasicBlock *Dest);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
/// PushConditionalTempDestruction - Should be called before a conditional
|
2009-06-04 10:22:12 +08:00
|
|
|
/// part of an expression is emitted. For example, before the RHS of the
|
|
|
|
/// expression below is emitted:
|
2009-09-09 23:08:12 +08:00
|
|
|
///
|
2009-06-04 10:22:12 +08:00
|
|
|
/// b && f(T());
|
|
|
|
///
|
|
|
|
/// This is used to make sure that any temporaryes created in the conditional
|
|
|
|
/// branch are only destroyed if the branch is taken.
|
|
|
|
void PushConditionalTempDestruction();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
/// PopConditionalTempDestruction - Should be called after a conditional
|
2009-06-04 10:22:12 +08:00
|
|
|
/// part of an expression has been emitted.
|
|
|
|
void PopConditionalTempDestruction();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-08-24 13:35:26 +08:00
|
|
|
private:
|
2009-02-13 16:11:52 +08:00
|
|
|
CGDebugInfo* DebugInfo;
|
2009-02-18 01:00:02 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// LabelIDs - Track arbitrary ids assigned to labels for use in implementing
|
|
|
|
/// the GCC address-of-label extension and indirect goto. IDs are assigned to
|
|
|
|
/// labels inside getIDForAddrOfLabel().
|
2008-08-05 00:51:22 +08:00
|
|
|
std::map<const LabelStmt*, unsigned> LabelIDs;
|
|
|
|
|
2009-10-13 14:55:33 +08:00
|
|
|
/// IndirectGotoSwitch - The first time an indirect goto is seen we create a
|
|
|
|
/// block with the switch for the indirect gotos. Every time we see the
|
|
|
|
/// address of a label taken, we add the label to the indirect goto. Every
|
|
|
|
/// subsequent indirect goto is codegen'd as a jump to the
|
|
|
|
/// IndirectGotoSwitch's basic block.
|
|
|
|
llvm::SwitchInst *IndirectGotoSwitch;
|
2008-08-05 00:51:22 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// LocalDeclMap - This keeps track of the LLVM allocas or globals for local C
|
|
|
|
/// decls.
|
2007-06-16 07:05:46 +08:00
|
|
|
llvm::DenseMap<const Decl*, llvm::Value*> LocalDeclMap;
|
2007-06-02 12:16:21 +08:00
|
|
|
|
2007-05-30 08:13:02 +08:00
|
|
|
/// LabelMap - This keeps track of the LLVM basic block for each C label.
|
2007-06-16 07:05:46 +08:00
|
|
|
llvm::DenseMap<const LabelStmt*, llvm::BasicBlock*> LabelMap;
|
2009-02-09 07:14:22 +08:00
|
|
|
|
|
|
|
// BreakContinueStack - This keeps track of where break and continue
|
2009-02-10 13:52:02 +08:00
|
|
|
// statements should jump to.
|
2007-07-17 05:28:45 +08:00
|
|
|
struct BreakContinue {
|
2009-02-10 13:52:02 +08:00
|
|
|
BreakContinue(llvm::BasicBlock *bb, llvm::BasicBlock *cb)
|
|
|
|
: BreakBlock(bb), ContinueBlock(cb) {}
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2007-07-17 05:28:45 +08:00
|
|
|
llvm::BasicBlock *BreakBlock;
|
|
|
|
llvm::BasicBlock *ContinueBlock;
|
2009-02-09 07:14:22 +08:00
|
|
|
};
|
2007-07-17 05:28:45 +08:00
|
|
|
llvm::SmallVector<BreakContinue, 8> BreakContinueStack;
|
2008-09-28 09:03:14 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// SwitchInsn - This is nearest current switch instruction. It is null if if
|
|
|
|
/// current context is not in a switch.
|
2007-10-05 07:45:31 +08:00
|
|
|
llvm::SwitchInst *SwitchInsn;
|
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// CaseRangeBlock - This block holds if condition check for last case
|
2007-10-10 01:08:50 +08:00
|
|
|
/// statement range in current switch instruction.
|
2007-10-09 04:57:48 +08:00
|
|
|
llvm::BasicBlock *CaseRangeBlock;
|
|
|
|
|
2009-02-24 01:26:39 +08:00
|
|
|
/// InvokeDest - This is the nearest exception target for calls
|
|
|
|
/// which can unwind, when exceptions are being used.
|
|
|
|
llvm::BasicBlock *InvokeDest;
|
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
// VLASizeMap - This keeps track of the associated size for each VLA type.
|
2009-08-15 10:50:32 +08:00
|
|
|
// We track this by the size expression rather than the type itself because
|
|
|
|
// in certain situations, like a const qualifier applied to an VLA typedef,
|
|
|
|
// multiple VLA types can share the same size expression.
|
2009-02-09 07:14:22 +08:00
|
|
|
// FIXME: Maybe this could be a stack of maps that is pushed/popped as we
|
|
|
|
// enter/leave scopes.
|
2009-08-15 10:50:32 +08:00
|
|
|
llvm::DenseMap<const Expr*, llvm::Value*> VLASizeMap;
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-02-10 04:20:56 +08:00
|
|
|
/// DidCallStackSave - Whether llvm.stacksave has been called. Used to avoid
|
|
|
|
/// calling llvm.stacksave for multiple VLAs in the same scope.
|
|
|
|
bool DidCallStackSave;
|
2009-02-18 01:00:02 +08:00
|
|
|
|
2009-02-08 06:53:43 +08:00
|
|
|
struct CleanupEntry {
|
|
|
|
/// CleanupBlock - The block of code that does the actual cleanup.
|
|
|
|
llvm::BasicBlock *CleanupBlock;
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-02-08 06:53:43 +08:00
|
|
|
/// Blocks - Basic blocks that were emitted in the current cleanup scope.
|
2009-02-08 15:46:24 +08:00
|
|
|
std::vector<llvm::BasicBlock *> Blocks;
|
2009-02-08 06:53:43 +08:00
|
|
|
|
|
|
|
/// BranchFixups - Branch instructions to basic blocks that haven't been
|
|
|
|
/// inserted into the current function yet.
|
2009-02-08 15:46:24 +08:00
|
|
|
std::vector<llvm::BranchInst *> BranchFixups;
|
2009-02-08 06:53:43 +08:00
|
|
|
|
|
|
|
explicit CleanupEntry(llvm::BasicBlock *cb)
|
|
|
|
: CleanupBlock(cb) {}
|
|
|
|
};
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-02-08 06:53:43 +08:00
|
|
|
/// CleanupEntries - Stack of cleanup entries.
|
|
|
|
llvm::SmallVector<CleanupEntry, 8> CleanupEntries;
|
|
|
|
|
2009-02-08 08:16:35 +08:00
|
|
|
typedef llvm::DenseMap<llvm::BasicBlock*, size_t> BlockScopeMap;
|
|
|
|
|
|
|
|
/// BlockScopes - Map of which "cleanup scope" scope basic blocks have.
|
|
|
|
BlockScopeMap BlockScopes;
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-04-05 04:47:02 +08:00
|
|
|
/// CXXThisDecl - When parsing an C++ function, this will hold the implicit
|
|
|
|
/// 'this' declaration.
|
|
|
|
ImplicitParamDecl *CXXThisDecl;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-04 02:54:26 +08:00
|
|
|
/// CXXLiveTemporaryInfo - Holds information about a live C++ temporary.
|
|
|
|
struct CXXLiveTemporaryInfo {
|
|
|
|
/// Temporary - The live temporary.
|
|
|
|
const CXXTemporary *Temporary;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-04 02:54:26 +08:00
|
|
|
/// ThisPtr - The pointer to the temporary.
|
|
|
|
llvm::Value *ThisPtr;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-04 02:54:26 +08:00
|
|
|
/// DtorBlock - The destructor block.
|
|
|
|
llvm::BasicBlock *DtorBlock;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-04 02:54:26 +08:00
|
|
|
/// CondPtr - If this is a conditional temporary, this is the pointer to
|
|
|
|
/// the condition variable that states whether the destructor should be
|
|
|
|
/// called or not.
|
|
|
|
llvm::Value *CondPtr;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-04 02:54:26 +08:00
|
|
|
CXXLiveTemporaryInfo(const CXXTemporary *temporary,
|
2009-06-04 03:05:16 +08:00
|
|
|
llvm::Value *thisptr, llvm::BasicBlock *dtorblock,
|
|
|
|
llvm::Value *condptr)
|
2009-09-09 23:08:12 +08:00
|
|
|
: Temporary(temporary), ThisPtr(thisptr), DtorBlock(dtorblock),
|
2009-06-04 02:54:26 +08:00
|
|
|
CondPtr(condptr) { }
|
|
|
|
};
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-06-04 02:54:26 +08:00
|
|
|
llvm::SmallVector<CXXLiveTemporaryInfo, 4> LiveTemporaries;
|
2009-06-04 10:22:12 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
/// ConditionalTempDestructionStack - Contains the number of live temporaries
|
2009-06-04 10:22:12 +08:00
|
|
|
/// when PushConditionalTempDestruction was called. This is used so that
|
|
|
|
/// we know how many temporaries were created by a certain expression.
|
|
|
|
llvm::SmallVector<size_t, 4> ConditionalTempDestructionStack;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-09-12 10:14:24 +08:00
|
|
|
|
|
|
|
/// ByrefValueInfoMap - For each __block variable, contains a pair of the LLVM
|
|
|
|
/// type as well as the field number that contains the actual data.
|
|
|
|
llvm::DenseMap<const ValueDecl *, std::pair<const llvm::Type *,
|
|
|
|
unsigned> > ByRefValueInfo;
|
|
|
|
|
|
|
|
/// getByrefValueFieldNumber - Given a declaration, returns the LLVM field
|
|
|
|
/// number that holds the value.
|
|
|
|
unsigned getByRefValueLLVMField(const ValueDecl *VD) const;
|
|
|
|
|
2007-05-28 09:07:47 +08:00
|
|
|
public:
|
2007-05-30 07:17:50 +08:00
|
|
|
CodeGenFunction(CodeGenModule &cgm);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2007-06-03 06:49:07 +08:00
|
|
|
ASTContext &getContext() const;
|
2009-02-13 16:11:52 +08:00
|
|
|
CGDebugInfo *getDebugInfo() { return DebugInfo; }
|
2007-06-03 06:49:07 +08:00
|
|
|
|
2009-02-24 01:26:39 +08:00
|
|
|
llvm::BasicBlock *getInvokeDest() { return InvokeDest; }
|
|
|
|
void setInvokeDest(llvm::BasicBlock *B) { InvokeDest = B; }
|
|
|
|
|
2009-07-15 07:10:40 +08:00
|
|
|
llvm::LLVMContext &getLLVMContext() { return VMContext; }
|
2009-07-13 12:10:07 +08:00
|
|
|
|
2009-02-24 01:26:39 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Objective-C
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
2008-03-31 07:03:07 +08:00
|
|
|
void GenerateObjCMethod(const ObjCMethodDecl *OMD);
|
2008-08-26 16:29:31 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
void StartObjCMethod(const ObjCMethodDecl *MD,
|
2009-01-11 05:06:09 +08:00
|
|
|
const ObjCContainerDecl *CD);
|
2008-08-26 16:29:31 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// GenerateObjCGetter - Synthesize an Objective-C property getter function.
|
2008-12-10 04:23:04 +08:00
|
|
|
void GenerateObjCGetter(ObjCImplementationDecl *IMP,
|
|
|
|
const ObjCPropertyImplDecl *PID);
|
2008-08-26 16:29:31 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// GenerateObjCSetter - Synthesize an Objective-C property setter function
|
|
|
|
/// for the given property.
|
2008-12-10 04:23:04 +08:00
|
|
|
void GenerateObjCSetter(ObjCImplementationDecl *IMP,
|
|
|
|
const ObjCPropertyImplDecl *PID);
|
2008-08-26 16:29:31 +08:00
|
|
|
|
2009-02-22 04:00:35 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Block Bits
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
2009-02-26 07:33:13 +08:00
|
|
|
llvm::Value *BuildBlockLiteralTmp(const BlockExpr *);
|
2009-03-26 01:58:24 +08:00
|
|
|
llvm::Constant *BuildDescriptorBlockDecl(bool BlockHasCopyDispose,
|
|
|
|
uint64_t Size,
|
2009-03-07 10:35:30 +08:00
|
|
|
const llvm::StructType *,
|
|
|
|
std::vector<HelperInfo> *);
|
2009-02-22 04:00:35 +08:00
|
|
|
|
2009-03-01 03:01:03 +08:00
|
|
|
llvm::Function *GenerateBlockFunction(const BlockExpr *BExpr,
|
2009-02-22 04:00:35 +08:00
|
|
|
const BlockInfo& Info,
|
2009-03-21 05:53:12 +08:00
|
|
|
const Decl *OuterFuncDecl,
|
2009-03-14 07:34:28 +08:00
|
|
|
llvm::DenseMap<const Decl*, llvm::Value*> ldm,
|
2009-02-26 07:33:13 +08:00
|
|
|
uint64_t &Size, uint64_t &Align,
|
2009-03-05 16:32:30 +08:00
|
|
|
llvm::SmallVector<const Expr *, 8> &subBlockDeclRefDecls,
|
|
|
|
bool &subBlockHasCopyDispose);
|
2009-02-22 04:00:35 +08:00
|
|
|
|
2009-03-21 05:53:12 +08:00
|
|
|
void BlockForwardSelf();
|
2009-02-22 04:00:35 +08:00
|
|
|
llvm::Value *LoadBlockStruct();
|
|
|
|
|
2009-02-28 17:07:16 +08:00
|
|
|
llvm::Value *GetAddrOfBlockDecl(const BlockDeclRefExpr *E);
|
2009-09-09 10:51:03 +08:00
|
|
|
const llvm::Type *BuildByRefType(const ValueDecl *D);
|
2009-03-04 11:23:46 +08:00
|
|
|
|
2009-09-11 08:07:24 +08:00
|
|
|
void GenerateCode(GlobalDecl GD, llvm::Function *Fn);
|
|
|
|
void StartFunction(GlobalDecl GD, QualType RetTy,
|
2008-09-10 07:14:03 +08:00
|
|
|
llvm::Function *Fn,
|
2008-10-19 02:22:23 +08:00
|
|
|
const FunctionArgList &Args,
|
|
|
|
SourceLocation StartLoc);
|
2008-11-12 07:11:34 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitReturnBlock - Emit the unified return block, trying to avoid its
|
|
|
|
/// emission when possible.
|
2009-01-27 07:27:52 +08:00
|
|
|
void EmitReturnBlock();
|
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// FinishFunction - Complete IR generation of the current function. It is
|
|
|
|
/// legal to call this function even if there is no current insertion point.
|
2008-08-26 16:29:31 +08:00
|
|
|
void FinishFunction(SourceLocation EndLoc=SourceLocation());
|
2008-09-10 07:27:19 +08:00
|
|
|
|
2009-08-19 05:59:28 +08:00
|
|
|
/// GenerateVtable - Generate the vtable for the given type.
|
2009-08-01 02:25:34 +08:00
|
|
|
llvm::Value *GenerateVtable(const CXXRecordDecl *RD);
|
|
|
|
|
2009-09-05 02:27:16 +08:00
|
|
|
/// GenerateThunk - Generate a thunk for the given method
|
|
|
|
llvm::Constant *GenerateThunk(llvm::Function *Fn, const CXXMethodDecl *MD,
|
2009-09-05 15:20:32 +08:00
|
|
|
bool Extern, int64_t nv, int64_t v);
|
2009-09-12 07:25:56 +08:00
|
|
|
llvm::Constant *GenerateCovariantThunk(llvm::Function *Fn,
|
|
|
|
const CXXMethodDecl *MD, bool Extern,
|
|
|
|
int64_t nv_t, int64_t v_t,
|
|
|
|
int64_t nv_r, int64_t v_r);
|
2009-09-05 02:27:16 +08:00
|
|
|
|
2009-09-14 13:32:02 +08:00
|
|
|
void EmitCtorPrologue(const CXXConstructorDecl *CD, CXXCtorType Type);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-09-14 13:32:02 +08:00
|
|
|
void SynthesizeCXXCopyConstructor(const CXXConstructorDecl *Ctor,
|
|
|
|
CXXCtorType Type,
|
2009-08-09 03:31:03 +08:00
|
|
|
llvm::Function *Fn,
|
|
|
|
const FunctionArgList &Args);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-08-13 05:14:35 +08:00
|
|
|
void SynthesizeCXXCopyAssignment(const CXXMethodDecl *CD,
|
|
|
|
llvm::Function *Fn,
|
|
|
|
const FunctionArgList &Args);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-09-14 13:32:02 +08:00
|
|
|
void SynthesizeDefaultConstructor(const CXXConstructorDecl *Ctor,
|
|
|
|
CXXCtorType Type,
|
2009-08-11 02:46:38 +08:00
|
|
|
llvm::Function *Fn,
|
|
|
|
const FunctionArgList &Args);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-09-14 13:32:02 +08:00
|
|
|
void SynthesizeDefaultDestructor(const CXXDestructorDecl *Dtor,
|
|
|
|
CXXDtorType Type,
|
|
|
|
llvm::Function *Fn,
|
|
|
|
const FunctionArgList &Args);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-07-31 01:49:11 +08:00
|
|
|
/// EmitDtorEpilogue - Emit all code that comes at the end of class's
|
2009-09-09 23:08:12 +08:00
|
|
|
/// destructor. This is to call destructors on members and base classes
|
2009-07-31 01:49:11 +08:00
|
|
|
/// in reverse order of their construction.
|
2009-09-14 13:32:02 +08:00
|
|
|
void EmitDtorEpilogue(const CXXDestructorDecl *Dtor,
|
|
|
|
CXXDtorType Type);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitFunctionProlog - Emit the target specific LLVM code to load the
|
|
|
|
/// arguments for the given function. This is also responsible for naming the
|
|
|
|
/// LLVM function arguments.
|
2009-02-03 06:03:45 +08:00
|
|
|
void EmitFunctionProlog(const CGFunctionInfo &FI,
|
|
|
|
llvm::Function *Fn,
|
2008-09-10 07:27:19 +08:00
|
|
|
const FunctionArgList &Args);
|
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitFunctionEpilog - Emit the target specific LLVM code to return the
|
|
|
|
/// given temporary.
|
2009-02-03 06:03:45 +08:00
|
|
|
void EmitFunctionEpilog(const CGFunctionInfo &FI, llvm::Value *ReturnValue);
|
2008-09-10 07:27:19 +08:00
|
|
|
|
2009-02-04 07:03:55 +08:00
|
|
|
const llvm::Type *ConvertTypeForMem(QualType T);
|
2007-06-23 03:05:19 +08:00
|
|
|
const llvm::Type *ConvertType(QualType T);
|
2008-04-04 12:07:35 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// LoadObjCSelf - Load the value of self. This function is only valid while
|
|
|
|
/// generating code for an Objective-C method.
|
2008-04-04 12:07:35 +08:00
|
|
|
llvm::Value *LoadObjCSelf();
|
2009-02-09 07:14:22 +08:00
|
|
|
|
|
|
|
/// TypeOfSelfObject - Return type of object that this self represents.
|
2009-02-03 08:09:52 +08:00
|
|
|
QualType TypeOfSelfObject();
|
2008-06-18 02:05:57 +08:00
|
|
|
|
2007-06-23 06:02:34 +08:00
|
|
|
/// hasAggregateLLVMType - Return true if the specified AST type will map into
|
|
|
|
/// an aggregate LLVM type or is void.
|
|
|
|
static bool hasAggregateLLVMType(QualType T);
|
2008-11-11 10:29:29 +08:00
|
|
|
|
|
|
|
/// createBasicBlock - Create an LLVM basic block.
|
2009-02-09 07:14:22 +08:00
|
|
|
llvm::BasicBlock *createBasicBlock(const char *Name="",
|
2008-11-11 10:29:29 +08:00
|
|
|
llvm::Function *Parent=0,
|
|
|
|
llvm::BasicBlock *InsertBefore=0) {
|
2008-11-12 08:01:12 +08:00
|
|
|
#ifdef NDEBUG
|
2009-08-14 05:57:51 +08:00
|
|
|
return llvm::BasicBlock::Create(VMContext, "", Parent, InsertBefore);
|
2008-11-12 08:01:12 +08:00
|
|
|
#else
|
2009-08-14 05:57:51 +08:00
|
|
|
return llvm::BasicBlock::Create(VMContext, Name, Parent, InsertBefore);
|
2008-11-12 08:01:12 +08:00
|
|
|
#endif
|
2008-11-11 10:29:29 +08:00
|
|
|
}
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2007-05-30 08:13:02 +08:00
|
|
|
/// getBasicBlockForLabel - Return the LLVM basicblock that the specified
|
|
|
|
/// label maps to.
|
|
|
|
llvm::BasicBlock *getBasicBlockForLabel(const LabelStmt *S);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-04-01 12:37:47 +08:00
|
|
|
/// SimplifyForwardingBlocks - If the given basic block is only a
|
|
|
|
/// branch to another basic block, simplify it. This assumes that no
|
|
|
|
/// other code could potentially reference the basic block.
|
|
|
|
void SimplifyForwardingBlocks(llvm::BasicBlock *BB);
|
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitBlock - Emit the given block \arg BB and set it as the insert point,
|
|
|
|
/// adding a fall-through branch from the current insert block if
|
|
|
|
/// necessary. It is legal to call this function even if there is no current
|
|
|
|
/// insertion point.
|
2008-11-13 09:24:05 +08:00
|
|
|
///
|
2009-02-09 07:14:22 +08:00
|
|
|
/// IsFinished - If true, indicates that the caller has finished emitting
|
|
|
|
/// branches to the given block and does not expect to emit code into it. This
|
|
|
|
/// means the block can be ignored if it is unreachable.
|
2008-11-13 09:24:05 +08:00
|
|
|
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false);
|
2008-11-11 12:34:23 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitBranch - Emit a branch to the specified basic block from the current
|
|
|
|
/// insert block, taking care to avoid creation of branches from dummy
|
|
|
|
/// blocks. It is legal to call this function even if there is no current
|
|
|
|
/// insertion point.
|
2008-11-12 06:06:59 +08:00
|
|
|
///
|
2009-02-09 07:14:22 +08:00
|
|
|
/// This function clears the current insertion point. The caller should follow
|
|
|
|
/// calls to this function with calls to Emit*Block prior to generation new
|
|
|
|
/// code.
|
2008-11-11 17:41:28 +08:00
|
|
|
void EmitBranch(llvm::BasicBlock *Block);
|
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// HaveInsertPoint - True if an insertion point is defined. If not, this
|
|
|
|
/// indicates that the current code being emitted is unreachable.
|
|
|
|
bool HaveInsertPoint() const {
|
2008-11-12 07:11:34 +08:00
|
|
|
return Builder.GetInsertBlock() != 0;
|
|
|
|
}
|
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EnsureInsertPoint - Ensure that an insertion point is defined so that
|
|
|
|
/// emitted IR has a place to go. Note that by definition, if this function
|
|
|
|
/// creates a block then that block is unreachable; callers may do better to
|
|
|
|
/// detect when no insertion point is defined and simply skip IR generation.
|
2008-11-12 07:11:34 +08:00
|
|
|
void EnsureInsertPoint() {
|
|
|
|
if (!HaveInsertPoint())
|
|
|
|
EmitBlock(createBasicBlock());
|
|
|
|
}
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2008-08-16 08:56:44 +08:00
|
|
|
/// ErrorUnsupported - Print out an error that codegen doesn't support the
|
2007-12-02 09:43:38 +08:00
|
|
|
/// specified stmt yet.
|
2008-09-04 11:43:08 +08:00
|
|
|
void ErrorUnsupported(const Stmt *S, const char *Type,
|
|
|
|
bool OmitOnError=false);
|
2007-06-02 12:16:21 +08:00
|
|
|
|
2007-06-23 05:44:33 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Helpers
|
|
|
|
//===--------------------------------------------------------------------===//
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-09-25 03:53:00 +08:00
|
|
|
Qualifiers MakeQualifiers(QualType T) {
|
|
|
|
Qualifiers Quals = T.getQualifiers();
|
|
|
|
Quals.setObjCGCAttr(getContext().getObjCGCAttrKind(T));
|
|
|
|
return Quals;
|
|
|
|
}
|
|
|
|
|
2007-06-23 05:44:33 +08:00
|
|
|
/// CreateTempAlloca - This creates a alloca and inserts it into the entry
|
|
|
|
/// block.
|
|
|
|
llvm::AllocaInst *CreateTempAlloca(const llvm::Type *Ty,
|
2009-10-19 09:21:05 +08:00
|
|
|
const llvm::Twine &Name = "tmp");
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2007-06-06 04:53:16 +08:00
|
|
|
/// EvaluateExprAsBool - Perform the usual unary conversions on the specified
|
|
|
|
/// expression and compare the result against zero, returning an Int1Ty value.
|
2007-06-16 07:05:46 +08:00
|
|
|
llvm::Value *EvaluateExprAsBool(const Expr *E);
|
2007-06-23 05:44:33 +08:00
|
|
|
|
2007-09-01 06:49:20 +08:00
|
|
|
/// EmitAnyExpr - Emit code to compute the specified expression which can have
|
|
|
|
/// any type. The result is returned as an RValue struct. If this is an
|
|
|
|
/// aggregate expression, the aggloc/agglocvolatile arguments indicate where
|
|
|
|
/// the result should be returned.
|
2009-05-27 06:03:21 +08:00
|
|
|
///
|
|
|
|
/// \param IgnoreResult - True if the resulting value isn't used.
|
2009-02-09 07:14:22 +08:00
|
|
|
RValue EmitAnyExpr(const Expr *E, llvm::Value *AggLoc = 0,
|
2009-08-16 15:36:22 +08:00
|
|
|
bool IsAggLocVolatile = false, bool IgnoreResult = false,
|
|
|
|
bool IsInitializer = false);
|
2007-09-29 05:49:18 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
// EmitVAListRef - Emit a "reference" to a va_list; this is either the address
|
|
|
|
// or the value of the expression, depending on how va_list is defined.
|
2009-01-21 01:46:04 +08:00
|
|
|
llvm::Value *EmitVAListRef(const Expr *E);
|
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitAnyExprToTemp - Similary to EmitAnyExpr(), however, the result will
|
|
|
|
/// always be accessible even if no aggregate location is provided.
|
2009-08-16 15:36:22 +08:00
|
|
|
RValue EmitAnyExprToTemp(const Expr *E, bool IsAggLocVolatile = false,
|
|
|
|
bool IsInitializer = false);
|
2008-09-09 09:06:48 +08:00
|
|
|
|
2009-05-24 06:29:41 +08:00
|
|
|
/// EmitAggregateCopy - Emit an aggrate copy.
|
|
|
|
///
|
|
|
|
/// \param isVolatile - True iff either the source or the destination is
|
|
|
|
/// volatile.
|
2008-09-10 04:49:46 +08:00
|
|
|
void EmitAggregateCopy(llvm::Value *DestPtr, llvm::Value *SrcPtr,
|
2009-05-24 06:29:41 +08:00
|
|
|
QualType EltTy, bool isVolatile=false);
|
2008-09-10 04:49:46 +08:00
|
|
|
|
|
|
|
void EmitAggregateClear(llvm::Value *DestPtr, QualType Ty);
|
|
|
|
|
2007-10-05 07:45:31 +08:00
|
|
|
/// StartBlock - Start new block named N. If insert block is a dummy block
|
|
|
|
/// then reuse it.
|
|
|
|
void StartBlock(const char *N);
|
|
|
|
|
2008-02-27 05:41:45 +08:00
|
|
|
/// GetAddrOfStaticLocalVar - Return the address of a static local variable.
|
2008-04-16 06:42:06 +08:00
|
|
|
llvm::Constant *GetAddrOfStaticLocalVar(const VarDecl *BVD);
|
2008-05-22 08:50:06 +08:00
|
|
|
|
2008-09-11 17:15:33 +08:00
|
|
|
/// GetAddrOfLocalVar - Return the address of a local variable.
|
|
|
|
llvm::Value *GetAddrOfLocalVar(const VarDecl *VD);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2008-05-22 08:50:06 +08:00
|
|
|
/// getAccessedFieldNo - Given an encoded value and a result number, return
|
|
|
|
/// the input field number being accessed.
|
|
|
|
static unsigned getAccessedFieldNo(unsigned Idx, const llvm::Constant *Elts);
|
|
|
|
|
2008-08-05 00:51:22 +08:00
|
|
|
unsigned GetIDForAddrOfLabel(const LabelStmt *L);
|
2009-10-13 14:55:33 +08:00
|
|
|
llvm::BasicBlock *GetIndirectGotoBlock();
|
2008-08-05 00:51:22 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitMemSetToZero - Generate code to memset a value of the given type to 0.
|
2008-08-31 03:51:14 +08:00
|
|
|
void EmitMemSetToZero(llvm::Value *DestPtr, QualType Ty);
|
2008-11-04 13:30:00 +08:00
|
|
|
|
|
|
|
// EmitVAArg - Generate code to get an argument from the passed in pointer
|
|
|
|
// and update it accordingly. The return value is a pointer to the argument.
|
|
|
|
// FIXME: We should be able to get rid of this method and use the va_arg
|
2009-02-09 07:14:22 +08:00
|
|
|
// instruction in LLVM instead once it works well enough.
|
2008-11-04 13:30:00 +08:00
|
|
|
llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty);
|
2008-12-21 04:27:15 +08:00
|
|
|
|
2008-12-21 04:46:34 +08:00
|
|
|
// EmitVLASize - Generate code for any VLA size expressions that might occur
|
|
|
|
// in a variably modified type. If Ty is a VLA, will return the value that
|
|
|
|
// corresponds to the size in bytes of the VLA type. Will return 0 otherwise.
|
2009-07-19 14:58:07 +08:00
|
|
|
///
|
|
|
|
/// This function can be called with a null (unreachable) insert point.
|
2008-12-21 04:46:34 +08:00
|
|
|
llvm::Value *EmitVLASize(QualType Ty);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2008-12-12 15:19:02 +08:00
|
|
|
// GetVLASize - Returns an LLVM value that corresponds to the size in bytes
|
|
|
|
// of a variable length array type.
|
|
|
|
llvm::Value *GetVLASize(const VariableArrayType *);
|
|
|
|
|
2009-04-15 00:58:56 +08:00
|
|
|
/// LoadCXXThis - Load the value of 'this'. This function is only valid while
|
|
|
|
/// generating code for an C++ member function.
|
|
|
|
llvm::Value *LoadCXXThis();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-09-12 12:26:35 +08:00
|
|
|
/// GetAddressCXXOfBaseClass - This function will add the necessary delta
|
2009-07-29 01:38:28 +08:00
|
|
|
/// to the load of 'this' and returns address of the base class.
|
2009-09-09 23:08:12 +08:00
|
|
|
// FIXME. This currently only does a derived to non-virtual base conversion.
|
2009-07-29 01:38:28 +08:00
|
|
|
// Other kinds of conversions will come later.
|
2009-09-12 12:26:35 +08:00
|
|
|
llvm::Value *GetAddressCXXOfBaseClass(llvm::Value *BaseValue,
|
|
|
|
const CXXRecordDecl *ClassDecl,
|
|
|
|
const CXXRecordDecl *BaseClassDecl,
|
|
|
|
bool NullCheckValue);
|
2009-09-29 11:13:20 +08:00
|
|
|
|
2009-10-07 06:43:30 +08:00
|
|
|
llvm::Value *
|
|
|
|
GetVirtualCXXBaseClassOffset(llvm::Value *This,
|
|
|
|
const CXXRecordDecl *ClassDecl,
|
|
|
|
const CXXRecordDecl *BaseClassDecl);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
void EmitClassAggrMemberwiseCopy(llvm::Value *DestValue,
|
2009-08-22 02:30:26 +08:00
|
|
|
llvm::Value *SrcValue,
|
2009-08-22 06:34:55 +08:00
|
|
|
const ArrayType *Array,
|
|
|
|
const CXXRecordDecl *BaseClassDecl,
|
|
|
|
QualType Ty);
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
void EmitClassAggrCopyAssignment(llvm::Value *DestValue,
|
2009-08-22 06:34:55 +08:00
|
|
|
llvm::Value *SrcValue,
|
2009-08-22 02:30:26 +08:00
|
|
|
const ArrayType *Array,
|
|
|
|
const CXXRecordDecl *BaseClassDecl,
|
|
|
|
QualType Ty);
|
|
|
|
|
2009-08-08 07:51:33 +08:00
|
|
|
void EmitClassMemberwiseCopy(llvm::Value *DestValue, llvm::Value *SrcValue,
|
2009-09-09 23:08:12 +08:00
|
|
|
const CXXRecordDecl *ClassDecl,
|
2009-08-09 07:32:22 +08:00
|
|
|
const CXXRecordDecl *BaseClassDecl,
|
|
|
|
QualType Ty);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-08-13 07:34:46 +08:00
|
|
|
void EmitClassCopyAssignment(llvm::Value *DestValue, llvm::Value *SrcValue,
|
2009-09-09 23:08:12 +08:00
|
|
|
const CXXRecordDecl *ClassDecl,
|
2009-08-13 07:34:46 +08:00
|
|
|
const CXXRecordDecl *BaseClassDecl,
|
|
|
|
QualType Ty);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type,
|
2009-04-17 08:06:03 +08:00
|
|
|
llvm::Value *This,
|
|
|
|
CallExpr::const_arg_iterator ArgBeg,
|
|
|
|
CallExpr::const_arg_iterator ArgEnd);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-08-20 04:55:16 +08:00
|
|
|
void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
|
2009-09-23 10:45:36 +08:00
|
|
|
const ConstantArrayType *ArrayTy,
|
|
|
|
llvm::Value *ArrayPtr);
|
|
|
|
void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
|
|
|
|
llvm::Value *NumElements,
|
|
|
|
llvm::Value *ArrayPtr);
|
2009-04-17 08:06:03 +08:00
|
|
|
|
2009-08-21 04:54:15 +08:00
|
|
|
void EmitCXXAggrDestructorCall(const CXXDestructorDecl *D,
|
|
|
|
const ArrayType *Array,
|
|
|
|
llvm::Value *This);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-05-30 05:03:38 +08:00
|
|
|
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type,
|
|
|
|
llvm::Value *This);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-05-31 08:34:10 +08:00
|
|
|
void PushCXXTemporary(const CXXTemporary *Temporary, llvm::Value *Ptr);
|
2009-06-04 03:05:16 +08:00
|
|
|
void PopCXXTemporary();
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-05-31 09:40:14 +08:00
|
|
|
llvm::Value *EmitCXXNewExpr(const CXXNewExpr *E);
|
2009-08-17 05:13:42 +08:00
|
|
|
void EmitCXXDeleteExpr(const CXXDeleteExpr *E);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-06-02 12:16:21 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
2007-06-14 04:44:40 +08:00
|
|
|
// Declaration Emission
|
2007-06-02 12:16:21 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-07-19 14:58:07 +08:00
|
|
|
/// EmitDecl - Emit a declaration.
|
|
|
|
///
|
|
|
|
/// This function can be called with a null (unreachable) insert point.
|
2007-06-09 09:20:56 +08:00
|
|
|
void EmitDecl(const Decl &D);
|
2009-07-19 14:58:07 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
/// EmitBlockVarDecl - Emit a block variable declaration.
|
2009-07-19 14:58:07 +08:00
|
|
|
///
|
|
|
|
/// This function can be called with a null (unreachable) insert point.
|
2008-04-16 06:42:06 +08:00
|
|
|
void EmitBlockVarDecl(const VarDecl &D);
|
2009-07-19 14:58:07 +08:00
|
|
|
|
|
|
|
/// EmitLocalBlockVarDecl - Emit a local block variable declaration.
|
|
|
|
///
|
|
|
|
/// This function can be called with a null (unreachable) insert point.
|
2008-04-16 06:42:06 +08:00
|
|
|
void EmitLocalBlockVarDecl(const VarDecl &D);
|
2009-07-19 14:58:07 +08:00
|
|
|
|
2008-04-16 06:42:06 +08:00
|
|
|
void EmitStaticBlockVarDecl(const VarDecl &D);
|
2008-08-16 11:19:19 +08:00
|
|
|
|
|
|
|
/// EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
|
|
|
|
void EmitParmDecl(const VarDecl &D, llvm::Value *Arg);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2007-05-30 07:50:05 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Statement Emission
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitStopPoint - Emit a debug stoppoint if we are emitting debug info.
|
2008-11-12 16:21:33 +08:00
|
|
|
void EmitStopPoint(const Stmt *S);
|
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitStmt - Emit the code for the statement \arg S. It is legal to call
|
|
|
|
/// this function even if there is no current insertion point.
|
|
|
|
///
|
|
|
|
/// This function may clear the current insertion point; callers should use
|
|
|
|
/// EnsureInsertPoint if they wish to subsequently generate code without first
|
|
|
|
/// calling EmitBlock, EmitBranch, or EmitStmt.
|
2007-05-30 07:50:05 +08:00
|
|
|
void EmitStmt(const Stmt *S);
|
2008-11-12 07:11:34 +08:00
|
|
|
|
2008-11-12 16:21:33 +08:00
|
|
|
/// EmitSimpleStmt - Try to emit a "simple" statement which does not
|
2009-02-09 07:14:22 +08:00
|
|
|
/// necessarily require an insertion point or debug information; typically
|
|
|
|
/// because the statement amounts to a jump or a container of other
|
|
|
|
/// statements.
|
2008-11-12 16:21:33 +08:00
|
|
|
///
|
|
|
|
/// \return True if the statement was handled.
|
|
|
|
bool EmitSimpleStmt(const Stmt *S);
|
|
|
|
|
2007-09-01 06:49:20 +08:00
|
|
|
RValue EmitCompoundStmt(const CompoundStmt &S, bool GetLast = false,
|
|
|
|
llvm::Value *AggLoc = 0, bool isAggVol = false);
|
2008-11-12 07:11:34 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitLabel - Emit the block for the given label. It is legal to call this
|
|
|
|
/// function even if there is no current insertion point.
|
2008-07-27 04:23:23 +08:00
|
|
|
void EmitLabel(const LabelStmt &S); // helper for EmitLabelStmt.
|
2008-11-12 07:11:34 +08:00
|
|
|
|
2007-05-30 08:13:02 +08:00
|
|
|
void EmitLabelStmt(const LabelStmt &S);
|
|
|
|
void EmitGotoStmt(const GotoStmt &S);
|
2008-08-05 00:51:22 +08:00
|
|
|
void EmitIndirectGotoStmt(const IndirectGotoStmt &S);
|
2007-05-31 05:03:58 +08:00
|
|
|
void EmitIfStmt(const IfStmt &S);
|
2007-06-05 11:59:43 +08:00
|
|
|
void EmitWhileStmt(const WhileStmt &S);
|
2007-06-06 04:53:16 +08:00
|
|
|
void EmitDoStmt(const DoStmt &S);
|
|
|
|
void EmitForStmt(const ForStmt &S);
|
2007-06-02 11:19:07 +08:00
|
|
|
void EmitReturnStmt(const ReturnStmt &S);
|
2007-06-09 09:20:56 +08:00
|
|
|
void EmitDeclStmt(const DeclStmt &S);
|
2008-11-12 16:21:33 +08:00
|
|
|
void EmitBreakStmt(const BreakStmt &S);
|
|
|
|
void EmitContinueStmt(const ContinueStmt &S);
|
2007-10-05 07:45:31 +08:00
|
|
|
void EmitSwitchStmt(const SwitchStmt &S);
|
|
|
|
void EmitDefaultStmt(const DefaultStmt &S);
|
|
|
|
void EmitCaseStmt(const CaseStmt &S);
|
2007-10-09 04:57:48 +08:00
|
|
|
void EmitCaseStmtRange(const CaseStmt &S);
|
2008-02-06 00:35:33 +08:00
|
|
|
void EmitAsmStmt(const AsmStmt &S);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2008-08-31 03:51:14 +08:00
|
|
|
void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S);
|
2008-09-09 18:04:29 +08:00
|
|
|
void EmitObjCAtTryStmt(const ObjCAtTryStmt &S);
|
|
|
|
void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S);
|
2008-11-16 05:26:17 +08:00
|
|
|
void EmitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt &S);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-09-28 02:58:34 +08:00
|
|
|
void EmitCXXTryStmt(const CXXTryStmt &S);
|
|
|
|
|
2007-06-02 13:24:33 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// LValue Expression Emission
|
|
|
|
//===--------------------------------------------------------------------===//
|
2007-06-06 04:53:16 +08:00
|
|
|
|
2009-02-05 15:09:07 +08:00
|
|
|
/// GetUndefRValue - Get an appropriate 'undef' rvalue for the given type.
|
|
|
|
RValue GetUndefRValue(QualType Ty);
|
|
|
|
|
2009-01-10 00:50:52 +08:00
|
|
|
/// EmitUnsupportedRValue - Emit a dummy r-value using the type of E
|
|
|
|
/// and issue an ErrorUnsupported style diagnostic (using the
|
|
|
|
/// provided Name).
|
|
|
|
RValue EmitUnsupportedRValue(const Expr *E,
|
|
|
|
const char *Name);
|
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitUnsupportedLValue - Emit a dummy l-value using the type of E and issue
|
|
|
|
/// an ErrorUnsupported style diagnostic (using the provided Name).
|
2008-08-26 04:45:57 +08:00
|
|
|
LValue EmitUnsupportedLValue(const Expr *E,
|
|
|
|
const char *Name);
|
|
|
|
|
2007-06-06 04:53:16 +08:00
|
|
|
/// EmitLValue - Emit code to compute a designator that specifies the location
|
|
|
|
/// of the expression.
|
|
|
|
///
|
|
|
|
/// This can return one of two things: a simple address or a bitfield
|
|
|
|
/// reference. In either case, the LLVM Value* in the LValue structure is
|
|
|
|
/// guaranteed to be an LLVM pointer type.
|
|
|
|
///
|
|
|
|
/// If this returns a bitfield reference, nothing about the pointee type of
|
|
|
|
/// the LLVM value is known: For example, it may not be a pointer to an
|
|
|
|
/// integer.
|
|
|
|
///
|
|
|
|
/// If this returns a normal address, and if the lvalue's C type is fixed
|
|
|
|
/// size, this method guarantees that the returned pointer type will point to
|
|
|
|
/// an LLVM type of the same size of the lvalue's type. If the lvalue has a
|
|
|
|
/// variable length type, this is not possible.
|
|
|
|
///
|
2007-06-02 13:24:33 +08:00
|
|
|
LValue EmitLValue(const Expr *E);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-02-10 08:57:50 +08:00
|
|
|
/// EmitLoadOfScalar - Load a scalar value from an address, taking
|
|
|
|
/// care to appropriately convert from the memory representation to
|
|
|
|
/// the LLVM value representation.
|
2009-02-18 01:00:02 +08:00
|
|
|
llvm::Value *EmitLoadOfScalar(llvm::Value *Addr, bool Volatile,
|
2009-02-10 08:57:50 +08:00
|
|
|
QualType Ty);
|
|
|
|
|
|
|
|
/// EmitStoreOfScalar - Store a scalar value to an address, taking
|
|
|
|
/// care to appropriately convert from the memory representation to
|
|
|
|
/// the LLVM value representation.
|
2009-02-18 01:00:02 +08:00
|
|
|
void EmitStoreOfScalar(llvm::Value *Value, llvm::Value *Addr,
|
2009-05-20 02:50:41 +08:00
|
|
|
bool Volatile, QualType Ty);
|
2009-02-10 08:57:50 +08:00
|
|
|
|
2007-06-06 04:53:16 +08:00
|
|
|
/// EmitLoadOfLValue - Given an expression that represents a value lvalue,
|
|
|
|
/// this method emits the address of the lvalue, then loads the result as an
|
|
|
|
/// rvalue, returning the rvalue.
|
2007-06-30 00:31:29 +08:00
|
|
|
RValue EmitLoadOfLValue(LValue V, QualType LVType);
|
2008-04-19 07:10:10 +08:00
|
|
|
RValue EmitLoadOfExtVectorElementLValue(LValue V, QualType LVType);
|
2008-01-23 04:17:04 +08:00
|
|
|
RValue EmitLoadOfBitfieldLValue(LValue LV, QualType ExprType);
|
2008-08-29 16:11:39 +08:00
|
|
|
RValue EmitLoadOfPropertyRefLValue(LValue LV, QualType ExprType);
|
2008-11-23 06:30:21 +08:00
|
|
|
RValue EmitLoadOfKVCRefLValue(LValue LV, QualType ExprType);
|
2007-06-30 00:31:29 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2007-06-06 04:53:16 +08:00
|
|
|
/// EmitStoreThroughLValue - Store the specified rvalue into the specified
|
|
|
|
/// lvalue, where both are guaranteed to the have the same type, and that type
|
|
|
|
/// is 'Ty'.
|
|
|
|
void EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty);
|
2008-04-19 07:10:10 +08:00
|
|
|
void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst,
|
|
|
|
QualType Ty);
|
2008-08-29 16:11:39 +08:00
|
|
|
void EmitStoreThroughPropertyRefLValue(RValue Src, LValue Dst, QualType Ty);
|
2008-11-23 06:30:21 +08:00
|
|
|
void EmitStoreThroughKVCRefLValue(RValue Src, LValue Dst, QualType Ty);
|
2008-11-19 17:36:46 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitStoreThroughLValue - Store Src into Dst with same constraints as
|
|
|
|
/// EmitStoreThroughLValue.
|
2008-11-19 17:36:46 +08:00
|
|
|
///
|
2009-02-09 07:14:22 +08:00
|
|
|
/// \param Result [out] - If non-null, this will be set to a Value* for the
|
|
|
|
/// bit-field contents after the store, appropriate for use as the result of
|
|
|
|
/// an assignment to the bit-field.
|
2008-11-19 17:36:46 +08:00
|
|
|
void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, QualType Ty,
|
|
|
|
llvm::Value **Result=0);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2007-12-29 13:02:41 +08:00
|
|
|
// Note: only availabe for agg return types
|
2008-09-04 11:20:13 +08:00
|
|
|
LValue EmitBinaryOperatorLValue(const BinaryOperator *E);
|
2009-02-12 04:59:32 +08:00
|
|
|
// Note: only available for agg return types
|
2007-12-29 13:02:41 +08:00
|
|
|
LValue EmitCallExprLValue(const CallExpr *E);
|
2009-02-12 04:59:32 +08:00
|
|
|
// Note: only available for agg return types
|
|
|
|
LValue EmitVAArgExprLValue(const VAArgExpr *E);
|
2007-06-02 13:24:33 +08:00
|
|
|
LValue EmitDeclRefLValue(const DeclRefExpr *E);
|
2007-06-06 12:54:52 +08:00
|
|
|
LValue EmitStringLiteralLValue(const StringLiteral *E);
|
2009-02-25 06:18:39 +08:00
|
|
|
LValue EmitObjCEncodeExprLValue(const ObjCEncodeExpr *E);
|
2008-10-18 05:58:32 +08:00
|
|
|
LValue EmitPredefinedFunctionName(unsigned Type);
|
2008-08-10 09:53:14 +08:00
|
|
|
LValue EmitPredefinedLValue(const PredefinedExpr *E);
|
2007-06-06 04:53:16 +08:00
|
|
|
LValue EmitUnaryOpLValue(const UnaryOperator *E);
|
2007-06-09 07:31:14 +08:00
|
|
|
LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E);
|
2008-04-19 07:10:10 +08:00
|
|
|
LValue EmitExtVectorElementExpr(const ExtVectorElementExpr *E);
|
2007-10-23 10:10:49 +08:00
|
|
|
LValue EmitMemberExpr(const MemberExpr *E);
|
2008-05-14 07:18:27 +08:00
|
|
|
LValue EmitCompoundLiteralLValue(const CompoundLiteralExpr *E);
|
2009-09-16 00:35:24 +08:00
|
|
|
LValue EmitConditionalOperatorLValue(const ConditionalOperator *E);
|
2009-03-19 02:28:57 +08:00
|
|
|
LValue EmitCastLValue(const CastExpr *E);
|
2008-02-09 16:50:58 +08:00
|
|
|
|
2009-04-22 13:08:15 +08:00
|
|
|
llvm::Value *EmitIvarOffset(const ObjCInterfaceDecl *Interface,
|
2008-09-24 12:00:38 +08:00
|
|
|
const ObjCIvarDecl *Ivar);
|
2008-02-09 16:50:58 +08:00
|
|
|
LValue EmitLValueForField(llvm::Value* Base, FieldDecl* Field,
|
2008-06-14 07:01:12 +08:00
|
|
|
bool isUnion, unsigned CVRQualifiers);
|
2009-02-03 08:09:52 +08:00
|
|
|
LValue EmitLValueForIvar(QualType ObjectTy,
|
|
|
|
llvm::Value* Base, const ObjCIvarDecl *Ivar,
|
2008-09-24 12:00:38 +08:00
|
|
|
unsigned CVRQualifiers);
|
|
|
|
|
2008-12-16 04:35:07 +08:00
|
|
|
LValue EmitLValueForBitfield(llvm::Value* Base, FieldDecl* Field,
|
2009-02-04 03:03:09 +08:00
|
|
|
unsigned CVRQualifiers);
|
2008-12-16 04:35:07 +08:00
|
|
|
|
2009-02-28 17:07:16 +08:00
|
|
|
LValue EmitBlockDeclRefLValue(const BlockDeclRefExpr *E);
|
|
|
|
|
2008-09-10 10:36:38 +08:00
|
|
|
LValue EmitCXXConditionDeclLValue(const CXXConditionDeclExpr *E);
|
2009-05-31 07:23:33 +08:00
|
|
|
LValue EmitCXXConstructLValue(const CXXConstructExpr *E);
|
2009-05-31 07:30:54 +08:00
|
|
|
LValue EmitCXXBindTemporaryLValue(const CXXBindTemporaryExpr *E);
|
2009-09-14 09:10:45 +08:00
|
|
|
LValue EmitCXXExprWithTemporariesLValue(const CXXExprWithTemporaries *E);
|
|
|
|
|
2008-08-23 18:51:21 +08:00
|
|
|
LValue EmitObjCMessageExprLValue(const ObjCMessageExpr *E);
|
2008-03-31 07:03:07 +08:00
|
|
|
LValue EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E);
|
2008-08-29 16:11:39 +08:00
|
|
|
LValue EmitObjCPropertyRefLValue(const ObjCPropertyRefExpr *E);
|
2009-08-21 01:02:02 +08:00
|
|
|
LValue EmitObjCKVCRefLValue(const ObjCImplicitSetterGetterRefExpr *E);
|
2009-04-26 03:35:26 +08:00
|
|
|
LValue EmitObjCSuperExprLValue(const ObjCSuperExpr *E);
|
|
|
|
LValue EmitStmtExprLValue(const StmtExpr *E);
|
2008-08-23 18:51:21 +08:00
|
|
|
|
2007-05-31 01:57:17 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
2007-08-11 08:04:45 +08:00
|
|
|
// Scalar Expression Emission
|
2007-05-31 01:57:17 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitCall - Generate a call of the given function, expecting the given
|
|
|
|
/// result type, and using the given argument list which specifies both the
|
|
|
|
/// LLVM arguments and the types they were derived from.
|
2009-02-21 02:06:48 +08:00
|
|
|
///
|
|
|
|
/// \param TargetDecl - If given, the decl of the function in a
|
|
|
|
/// direct call; used to set attributes on the call (noreturn,
|
|
|
|
/// etc.).
|
2009-02-03 06:03:45 +08:00
|
|
|
RValue EmitCall(const CGFunctionInfo &FnInfo,
|
|
|
|
llvm::Value *Callee,
|
2009-02-21 02:06:48 +08:00
|
|
|
const CallArgList &Args,
|
|
|
|
const Decl *TargetDecl = 0);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-05-27 09:22:39 +08:00
|
|
|
RValue EmitCall(llvm::Value *Callee, QualType FnType,
|
|
|
|
CallExpr::const_arg_iterator ArgBeg,
|
|
|
|
CallExpr::const_arg_iterator ArgEnd,
|
|
|
|
const Decl *TargetDecl = 0);
|
2007-06-16 05:34:29 +08:00
|
|
|
RValue EmitCallExpr(const CallExpr *E);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-08-27 04:46:33 +08:00
|
|
|
llvm::Value *BuildVirtualCall(const CXXMethodDecl *MD, llvm::Value *&This,
|
|
|
|
const llvm::Type *Ty);
|
2009-05-12 07:37:08 +08:00
|
|
|
RValue EmitCXXMemberCall(const CXXMethodDecl *MD,
|
|
|
|
llvm::Value *Callee,
|
|
|
|
llvm::Value *This,
|
|
|
|
CallExpr::const_arg_iterator ArgBeg,
|
|
|
|
CallExpr::const_arg_iterator ArgEnd);
|
2009-04-04 06:50:24 +08:00
|
|
|
RValue EmitCXXMemberCallExpr(const CXXMemberCallExpr *E);
|
2009-10-04 03:43:08 +08:00
|
|
|
RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E);
|
This patch is motivated by numerous strict-aliasing warnings when compiling
clang as a Release build.
The big change is that all AST nodes (subclasses of Stmt) whose children are
Expr* store their children as Stmt* or arrays of Stmt*. This is to remove
strict-aliasing warnings when using StmtIterator. None of the interfaces of any
of the classes have changed (except those with arg_iterators, see below), as the
accessor methods introduce the needed casts (via cast<>). While this extra
casting may seem cumbersome, it actually adds some important sanity checks
throughout the codebase, as clients using StmtIterator can potentially overwrite
children that are expected to be Expr* with Stmt* (that aren't Expr*). The casts
provide extra sanity checks that are operational in debug builds to catch
invariant violations such as these.
For classes that have arg_iterators (e.g., CallExpr), the definition of
arg_iterator has been replaced. Instead of it being Expr**, it is an actual
class (called ExprIterator) that wraps a Stmt**, and provides the necessary
operators for iteration. The nice thing about this class is that it also uses
cast<> to type-checking, which introduces extra sanity checks throughout the
codebase that are useful for debugging.
A few of the CodeGen functions that use arg_iterator (especially from
OverloadExpr) have been modified to take begin and end iterators instead of a
base Expr** and the number of arguments. This matches more with the abstraction
of iteration. This still needs to be cleaned up a little bit, as clients expect
that ExprIterator is a RandomAccessIterator (which we may or may not wish to
allow for efficiency of representation).
This is a fairly large patch. It passes the tests (except CodeGen/bitfield.c,
which was already broken) on both a Debug and Release build, but it should
obviously be reviewed.
llvm-svn: 52378
2008-06-17 10:43:46 +08:00
|
|
|
|
2009-05-27 12:18:27 +08:00
|
|
|
RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E,
|
|
|
|
const CXXMethodDecl *MD);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-10-04 03:43:08 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
RValue EmitBuiltinExpr(const FunctionDecl *FD,
|
2009-02-17 06:43:43 +08:00
|
|
|
unsigned BuiltinID, const CallExpr *E);
|
2007-06-06 04:53:16 +08:00
|
|
|
|
2009-02-12 08:39:25 +08:00
|
|
|
RValue EmitBlockCallExpr(const CallExpr *E);
|
2009-02-18 01:00:02 +08:00
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// EmitTargetBuiltinExpr - Emit the given builtin call. Returns 0 if the call
|
|
|
|
/// is unhandled by the current target.
|
2008-10-10 08:24:54 +08:00
|
|
|
llvm::Value *EmitTargetBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
|
|
|
|
|
2007-12-10 07:17:02 +08:00
|
|
|
llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
|
|
|
|
llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2007-12-11 03:35:18 +08:00
|
|
|
llvm::Value *EmitShuffleVector(llvm::Value* V1, llvm::Value *V2, ...);
|
2007-12-30 10:59:45 +08:00
|
|
|
llvm::Value *EmitVector(llvm::Value * const *Vals, unsigned NumVals,
|
|
|
|
bool isSplat = false);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2008-08-20 08:28:19 +08:00
|
|
|
llvm::Value *EmitObjCProtocolExpr(const ObjCProtocolExpr *E);
|
2007-08-24 13:35:26 +08:00
|
|
|
llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E);
|
2008-06-25 01:04:18 +08:00
|
|
|
llvm::Value *EmitObjCSelectorExpr(const ObjCSelectorExpr *E);
|
2008-08-23 11:46:30 +08:00
|
|
|
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E);
|
2008-11-23 02:39:36 +08:00
|
|
|
RValue EmitObjCPropertyGet(const Expr *E);
|
2009-03-21 03:18:21 +08:00
|
|
|
RValue EmitObjCSuperPropertyGet(const Expr *Exp, const Selector &S);
|
2008-11-23 06:30:21 +08:00
|
|
|
void EmitObjCPropertySet(const Expr *E, RValue Src);
|
2009-03-21 03:18:21 +08:00
|
|
|
void EmitObjCSuperPropertySet(const Expr *E, const Selector &S, RValue Src);
|
2008-06-25 01:04:18 +08:00
|
|
|
|
|
|
|
|
2009-05-20 08:24:07 +08:00
|
|
|
/// EmitReferenceBindingToExpr - Emits a reference binding to the passed in
|
|
|
|
/// expression. Will emit a temporary variable if E is not an LValue.
|
2009-08-16 15:36:22 +08:00
|
|
|
RValue EmitReferenceBindingToExpr(const Expr* E, QualType DestType,
|
|
|
|
bool IsInitializer = false);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-08-11 08:04:45 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
2007-08-27 07:13:56 +08:00
|
|
|
// Expression Emission
|
2007-08-11 08:04:45 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
2007-08-27 07:13:56 +08:00
|
|
|
|
|
|
|
// Expressions are broken into three classes: scalar, complex, aggregate.
|
2009-02-09 07:14:22 +08:00
|
|
|
|
|
|
|
/// EmitScalarExpr - Emit the computation of the specified expression of LLVM
|
|
|
|
/// scalar type, returning the result.
|
2009-08-16 15:36:22 +08:00
|
|
|
llvm::Value *EmitScalarExpr(const Expr *E , bool IgnoreResultAssign = false);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2007-08-26 14:48:56 +08:00
|
|
|
/// EmitScalarConversion - Emit a conversion from the specified type to the
|
|
|
|
/// specified destination type, both of which are LLVM scalar types.
|
|
|
|
llvm::Value *EmitScalarConversion(llvm::Value *Src, QualType SrcTy,
|
|
|
|
QualType DstTy);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2007-08-27 00:34:22 +08:00
|
|
|
/// EmitComplexToScalarConversion - Emit a conversion from the specified
|
2009-02-09 07:14:22 +08:00
|
|
|
/// complex type to the specified destination type, where the destination type
|
|
|
|
/// is an LLVM scalar type.
|
2007-08-27 00:34:22 +08:00
|
|
|
llvm::Value *EmitComplexToScalarConversion(ComplexPairTy Src, QualType SrcTy,
|
|
|
|
QualType DstTy);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
|
|
|
|
2007-08-11 08:04:45 +08:00
|
|
|
/// EmitAggExpr - Emit the computation of the specified expression of
|
|
|
|
/// aggregate type. The result is computed into DestPtr. Note that if
|
|
|
|
/// DestPtr is null, the value of the aggregate expression is not needed.
|
2009-05-27 06:03:21 +08:00
|
|
|
void EmitAggExpr(const Expr *E, llvm::Value *DestPtr, bool VolatileDest,
|
2009-09-01 03:33:16 +08:00
|
|
|
bool IgnoreResult = false, bool IsInitializer = false,
|
|
|
|
bool RequiresGCollection = false);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-07-08 09:18:33 +08:00
|
|
|
/// EmitGCMemmoveCollectable - Emit special API for structs with object
|
|
|
|
/// pointers.
|
|
|
|
void EmitGCMemmoveCollectable(llvm::Value *DestPtr, llvm::Value *SrcPtr,
|
2009-09-01 03:33:16 +08:00
|
|
|
QualType Ty);
|
2009-07-08 09:18:33 +08:00
|
|
|
|
2007-08-21 13:54:00 +08:00
|
|
|
/// EmitComplexExpr - Emit the computation of the specified expression of
|
2007-08-24 07:43:33 +08:00
|
|
|
/// complex type, returning the result.
|
2009-05-29 23:46:01 +08:00
|
|
|
ComplexPairTy EmitComplexExpr(const Expr *E, bool IgnoreReal = false,
|
|
|
|
bool IgnoreImag = false,
|
|
|
|
bool IgnoreRealAssign = false,
|
|
|
|
bool IgnoreImagAssign = false);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2007-08-24 07:43:33 +08:00
|
|
|
/// EmitComplexExprIntoAddr - Emit the computation of the specified expression
|
|
|
|
/// of complex type, storing into the specified Value*.
|
2007-08-27 00:22:13 +08:00
|
|
|
void EmitComplexExprIntoAddr(const Expr *E, llvm::Value *DestAddr,
|
|
|
|
bool DestIsVolatile);
|
2008-08-30 13:35:15 +08:00
|
|
|
|
|
|
|
/// StoreComplexToAddr - Store a complex number into the specified address.
|
|
|
|
void StoreComplexToAddr(ComplexPairTy V, llvm::Value *DestAddr,
|
|
|
|
bool DestIsVolatile);
|
2007-09-01 06:49:20 +08:00
|
|
|
/// LoadComplexFromAddr - Load a complex number from the specified address.
|
|
|
|
ComplexPairTy LoadComplexFromAddr(llvm::Value *SrcAddr, bool SrcIsVolatile);
|
2008-05-08 13:58:21 +08:00
|
|
|
|
2009-02-26 03:24:29 +08:00
|
|
|
/// CreateStaticBlockVarDecl - Create a zero-initialized LLVM global
|
|
|
|
/// for a static block var decl.
|
|
|
|
llvm::GlobalVariable * CreateStaticBlockVarDecl(const VarDecl &D,
|
|
|
|
const char *Separator,
|
|
|
|
llvm::GlobalValue::LinkageTypes
|
|
|
|
Linkage);
|
|
|
|
|
2009-08-09 05:45:14 +08:00
|
|
|
/// EmitStaticCXXBlockVarDeclInit - Create the initializer for a C++
|
2009-02-26 03:24:29 +08:00
|
|
|
/// runtime initialized static block var decl.
|
2009-08-09 05:45:14 +08:00
|
|
|
void EmitStaticCXXBlockVarDeclInit(const VarDecl &D,
|
|
|
|
llvm::GlobalVariable *GV);
|
2008-08-23 00:00:37 +08:00
|
|
|
|
2009-08-09 05:45:14 +08:00
|
|
|
/// EmitCXXGlobalVarDeclInit - Create the initializer for a C++
|
|
|
|
/// variable with global storage.
|
|
|
|
void EmitCXXGlobalVarDeclInit(const VarDecl &D, llvm::Constant *DeclPtr);
|
|
|
|
|
|
|
|
/// EmitCXXGlobalDtorRegistration - Emits a call to register the global ptr
|
|
|
|
/// with the C++ runtime so that its destructor will be called at exit.
|
|
|
|
void EmitCXXGlobalDtorRegistration(const CXXDestructorDecl *Dtor,
|
|
|
|
llvm::Constant *DeclPtr);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
/// GenerateCXXGlobalInitFunc - Generates code for initializing global
|
2009-08-09 07:24:23 +08:00
|
|
|
/// variables.
|
|
|
|
void GenerateCXXGlobalInitFunc(llvm::Function *Fn,
|
|
|
|
const VarDecl **Decls,
|
|
|
|
unsigned NumDecls);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-05-04 01:47:16 +08:00
|
|
|
void EmitCXXConstructExpr(llvm::Value *Dest, const CXXConstructExpr *E);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-05-31 07:23:33 +08:00
|
|
|
RValue EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
|
2009-09-09 23:08:12 +08:00
|
|
|
llvm::Value *AggLoc = 0,
|
2009-08-16 15:36:22 +08:00
|
|
|
bool IsAggLocVolatile = false,
|
|
|
|
bool IsInitializer = false);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-08-05 00:51:22 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Internal Helpers
|
|
|
|
//===--------------------------------------------------------------------===//
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2008-11-11 15:41:27 +08:00
|
|
|
/// ContainsLabel - Return true if the statement contains a label in it. If
|
|
|
|
/// this statement is not executed normally, it not containing a label means
|
|
|
|
/// that we can just remove the code.
|
|
|
|
static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts = false);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2008-11-12 18:12:14 +08:00
|
|
|
/// ConstantFoldsToSimpleInteger - If the specified expression does not fold
|
2008-11-12 16:04:58 +08:00
|
|
|
/// to a constant, or if it does but contains a label, return 0. If it
|
|
|
|
/// constant folds to 'true' and does not contain a label, return 1, if it
|
|
|
|
/// constant folds to 'false' and does not contain a label, return -1.
|
|
|
|
int ConstantFoldsToSimpleInteger(const Expr *Cond);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2008-11-12 16:04:58 +08:00
|
|
|
/// EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g. for an
|
|
|
|
/// if statement) to the specified blocks. Based on the condition, this might
|
|
|
|
/// try to simplify the codegen of the conditional based on the branch.
|
Make emission of 'if' conditions much more sophisticated when we
have a condition that is an &&/||. Before we used to compile things like this:
int test() {
if (x && y) foo(); else bar();
}
into:
%0 = load i32* @x ; <i32> [#uses=1]
%1 = icmp ne i32 %0, 0 ; <i1> [#uses=1]
br i1 %1, label %land_rhs, label %land_cont
land_rhs: ; preds = %entry
%2 = load i32* @y ; <i32> [#uses=1]
%3 = icmp ne i32 %2, 0 ; <i1> [#uses=1]
br label %land_cont
land_cont: ; preds = %land_rhs, %entry
%4 = phi i1 [ false, %entry ], [ %3, %land_rhs ] ; <i1> [#uses=1]
br i1 %4, label %ifthen, label %ifelse
ifthen: ; preds = %land_cont
%call = call i32 (...)* @foo() ; <i32> [#uses=0]
br label %ifend
ifelse: ; preds = %land_cont
%call1 = call i32 (...)* @bar() ; <i32> [#uses=0]
br label %ifend
ifend: ; preds = %ifelse, %ifthen
Now we turn it into the much more svelte code:
%0 = load i32* @x ; <i32> [#uses=1]
%1 = icmp ne i32 %0, 0 ; <i1> [#uses=1]
br i1 %1, label %land_lhs_true, label %ifelse
land_lhs_true: ; preds = %entry
%2 = load i32* @y ; <i32> [#uses=1]
%3 = icmp ne i32 %2, 0 ; <i1> [#uses=1]
br i1 %3, label %ifthen, label %ifelse
ifthen: ; preds = %land_lhs_true
%call = call i32 (...)* @foo() ; <i32> [#uses=0]
br label %ifend
ifelse: ; preds = %land_lhs_true, %entry
%call1 = call i32 (...)* @bar() ; <i32> [#uses=0]
br label %ifend
ifend: ; preds = %ifelse, %ifthen
Note the lack of a phi node.
This shrinks the -O0 .ll file for 176.gcc/expr.c from 43176 to 40267 lines.
llvm-svn: 59111
2008-11-12 15:46:33 +08:00
|
|
|
void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock,
|
2008-11-12 18:12:14 +08:00
|
|
|
llvm::BasicBlock *FalseBlock);
|
2008-11-12 16:04:58 +08:00
|
|
|
private:
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2008-09-24 12:00:38 +08:00
|
|
|
void EmitReturnOfRValue(RValue RV, QualType Ty);
|
|
|
|
|
2008-09-17 08:51:38 +08:00
|
|
|
/// ExpandTypeFromArgs - Reconstruct a structure of type \arg Ty
|
|
|
|
/// from function arguments into \arg Dst. See ABIArgInfo::Expand.
|
|
|
|
///
|
|
|
|
/// \param AI - The first function argument of the expansion.
|
|
|
|
/// \return The argument following the last expanded function
|
|
|
|
/// argument.
|
2009-02-09 07:14:22 +08:00
|
|
|
llvm::Function::arg_iterator
|
2008-09-17 08:51:38 +08:00
|
|
|
ExpandTypeFromArgs(QualType Ty, LValue Dst,
|
|
|
|
llvm::Function::arg_iterator AI);
|
|
|
|
|
2009-02-09 07:14:22 +08:00
|
|
|
/// ExpandTypeToArgs - Expand an RValue \arg Src, with the LLVM type for \arg
|
|
|
|
/// Ty, into individual arguments on the provided vector \arg Args. See
|
|
|
|
/// ABIArgInfo::Expand.
|
|
|
|
void ExpandTypeToArgs(QualType Ty, RValue Src,
|
2008-09-17 08:51:38 +08:00
|
|
|
llvm::SmallVector<llvm::Value*, 16> &Args);
|
2009-01-12 03:40:10 +08:00
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
llvm::Value* EmitAsmInput(const AsmStmt &S,
|
2009-05-04 14:56:16 +08:00
|
|
|
const TargetInfo::ConstraintInfo &Info,
|
2009-01-12 03:40:10 +08:00
|
|
|
const Expr *InputExpr, std::string &ConstraintStr);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-02-08 07:50:39 +08:00
|
|
|
/// EmitCleanupBlock - emits a single cleanup block.
|
|
|
|
void EmitCleanupBlock();
|
|
|
|
|
2009-02-08 08:50:42 +08:00
|
|
|
/// AddBranchFixup - adds a branch instruction to the list of fixups for the
|
|
|
|
/// current cleanup scope.
|
|
|
|
void AddBranchFixup(llvm::BranchInst *BI);
|
2009-02-09 07:14:22 +08:00
|
|
|
|
2009-04-09 04:47:54 +08:00
|
|
|
/// EmitCallArg - Emit a single call argument.
|
|
|
|
RValue EmitCallArg(const Expr *E, QualType ArgType);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-09 04:47:54 +08:00
|
|
|
/// EmitCallArgs - Emit call arguments for a function.
|
2009-09-09 23:08:12 +08:00
|
|
|
/// The CallArgTypeInfo parameter is used for iterating over the known
|
2009-04-19 04:20:22 +08:00
|
|
|
/// argument types of the function being called.
|
|
|
|
template<typename T>
|
|
|
|
void EmitCallArgs(CallArgList& Args, const T* CallArgTypeInfo,
|
2009-04-09 04:47:54 +08:00
|
|
|
CallExpr::const_arg_iterator ArgBeg,
|
2009-04-19 04:20:22 +08:00
|
|
|
CallExpr::const_arg_iterator ArgEnd) {
|
|
|
|
CallExpr::const_arg_iterator Arg = ArgBeg;
|
|
|
|
|
|
|
|
// First, use the argument types that the type info knows about
|
|
|
|
if (CallArgTypeInfo) {
|
|
|
|
for (typename T::arg_type_iterator I = CallArgTypeInfo->arg_type_begin(),
|
|
|
|
E = CallArgTypeInfo->arg_type_end(); I != E; ++I, ++Arg) {
|
|
|
|
QualType ArgType = *I;
|
|
|
|
|
|
|
|
assert(getContext().getCanonicalType(ArgType.getNonReferenceType()).
|
2009-09-09 23:08:12 +08:00
|
|
|
getTypePtr() ==
|
|
|
|
getContext().getCanonicalType(Arg->getType()).getTypePtr() &&
|
2009-04-19 04:20:22 +08:00
|
|
|
"type mismatch in call argument!");
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
Args.push_back(std::make_pair(EmitCallArg(*Arg, ArgType),
|
2009-04-19 04:20:22 +08:00
|
|
|
ArgType));
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
|
|
|
// Either we've emitted all the call args, or we have a call to a
|
2009-04-19 04:20:22 +08:00
|
|
|
// variadic function.
|
2009-09-09 23:08:12 +08:00
|
|
|
assert((Arg == ArgEnd || CallArgTypeInfo->isVariadic()) &&
|
2009-04-19 04:20:22 +08:00
|
|
|
"Extra arguments in non-variadic function!");
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-19 04:20:22 +08:00
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-19 04:20:22 +08:00
|
|
|
// If we still have any arguments, emit them using the type of the argument.
|
|
|
|
for (; Arg != ArgEnd; ++Arg) {
|
|
|
|
QualType ArgType = Arg->getType();
|
|
|
|
Args.push_back(std::make_pair(EmitCallArg(*Arg, ArgType),
|
|
|
|
ArgType));
|
|
|
|
}
|
|
|
|
}
|
2007-05-24 14:29:05 +08:00
|
|
|
};
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-19 04:20:22 +08:00
|
|
|
|
2007-05-24 14:29:05 +08:00
|
|
|
} // end namespace CodeGen
|
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
#endif
|