blob: 9ee067bb2101fd5a8c703dc82f20d9e7a42ec9c2 [file] [log] [blame]
Chris Lattnera0fd5ee2008-03-01 08:50:34 +00001//===----- CGObjCRuntime.h - Emit LLVM Code from ASTs for a Module --------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This provides an abstract class for Objective-C code generation. Concrete
11// subclasses of this implement code generation for specific Objective-C
12// runtime libraries.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef CLANG_CODEGEN_OBCJRUNTIME_H
17#define CLANG_CODEGEN_OBCJRUNTIME_H
18
19namespace llvm {
Chris Lattner676bf212008-04-13 07:32:11 +000020 class IRBuilder;
Chris Lattnera0fd5ee2008-03-01 08:50:34 +000021 class Constant;
22 class Type;
23 class Value;
24 class Module;
Chris Lattnerb326b172008-03-30 23:03:07 +000025 class Function;
Chris Lattnera0fd5ee2008-03-01 08:50:34 +000026}
27
Chris Lattnerb326b172008-03-30 23:03:07 +000028
Chris Lattnera0fd5ee2008-03-01 08:50:34 +000029namespace clang {
30namespace CodeGen {
31
32// Implements runtime-specific code generation functions
33class CGObjCRuntime {
34public:
35 virtual ~CGObjCRuntime();
36
Chris Lattnerb326b172008-03-30 23:03:07 +000037 /// Generate an Objective-C message send operation
Chris Lattner676bf212008-04-13 07:32:11 +000038 virtual llvm::Value *generateMessageSend(llvm::IRBuilder &Builder,
Chris Lattnera0fd5ee2008-03-01 08:50:34 +000039 const llvm::Type *ReturnTy,
Chris Lattnerb326b172008-03-30 23:03:07 +000040 llvm::Value *Sender,
Chris Lattnera0fd5ee2008-03-01 08:50:34 +000041 llvm::Value *Receiver,
Chris Lattnerb326b172008-03-30 23:03:07 +000042 llvm::Value *Selector,
Chris Lattnera0fd5ee2008-03-01 08:50:34 +000043 llvm::Value** ArgV,
44 unsigned ArgC) = 0;
Chris Lattnerb326b172008-03-30 23:03:07 +000045 /// Generate the function required to register all Objective-C components in
46 /// this compilation unit with the runtime library.
47 virtual llvm::Function *ModuleInitFunction() { return 0; }
48 /// Generate a function preamble for a method with the specified types
49 virtual llvm::Function *MethodPreamble(const llvm::Type *ReturnTy,
50 const llvm::Type *SelfTy,
51 const llvm::Type **ArgTy,
52 unsigned ArgC,
53 bool isVarArg) = 0;
54 /// If instance variable addresses are determined at runtime then this should
55 /// return true, otherwise instance variables will be accessed directly from
56 /// the structure. If this returns true then @defs is invalid for this
57 /// runtime and a warning should be generated.
58 virtual bool LateBoundIVars() { return false; }
Chris Lattnera0fd5ee2008-03-01 08:50:34 +000059};
60
Chris Lattnerb326b172008-03-30 23:03:07 +000061/// Creates an instance of an Objective-C runtime class.
62//TODO: This should include some way of selecting which runtime to target.
63CGObjCRuntime *CreateObjCRuntime(llvm::Module &M,
64 const llvm::Type *LLVMIntType,
65 const llvm::Type *LLVMLongType);
Chris Lattnera0fd5ee2008-03-01 08:50:34 +000066}
67}
68#endif