CGObjCRuntime.h revision 50b36741673258aaebcd3c7fe1260031901cae57
1//===----- 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 {
20  class IRBuilder;
21  class Constant;
22  class Type;
23  class Value;
24  class Module;
25  class Function;
26}
27
28
29namespace clang {
30namespace CodeGen {
31
32// Implements runtime-specific code generation functions
33class CGObjCRuntime {
34public:
35  virtual ~CGObjCRuntime();
36
37  /// Generate an Objective-C message send operation
38  virtual llvm::Value *generateMessageSend(llvm::IRBuilder &Builder,
39                                           const llvm::Type *ReturnTy,
40                                           llvm::Value *Sender,
41                                           llvm::Value *Receiver,
42                                           llvm::Value *Selector,
43                                           llvm::Value** ArgV,
44                                           unsigned ArgC) = 0;
45  /// 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; }
59};
60
61/// 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);
66}
67}
68#endif
69