Chris Lattner | a0fd5ee | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 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 | |
| 19 | namespace llvm { |
Chris Lattner | 676bf21 | 2008-04-13 07:32:11 +0000 | [diff] [blame] | 20 | class IRBuilder; |
Chris Lattner | a0fd5ee | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 21 | class Constant; |
| 22 | class Type; |
| 23 | class Value; |
| 24 | class Module; |
Chris Lattner | b326b17 | 2008-03-30 23:03:07 +0000 | [diff] [blame] | 25 | class Function; |
Chris Lattner | a0fd5ee | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 26 | } |
| 27 | |
Chris Lattner | b326b17 | 2008-03-30 23:03:07 +0000 | [diff] [blame] | 28 | |
Chris Lattner | a0fd5ee | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 29 | namespace clang { |
| 30 | namespace CodeGen { |
| 31 | |
| 32 | // Implements runtime-specific code generation functions |
| 33 | class CGObjCRuntime { |
| 34 | public: |
| 35 | virtual ~CGObjCRuntime(); |
| 36 | |
Chris Lattner | b326b17 | 2008-03-30 23:03:07 +0000 | [diff] [blame] | 37 | /// Generate an Objective-C message send operation |
Chris Lattner | 676bf21 | 2008-04-13 07:32:11 +0000 | [diff] [blame] | 38 | virtual llvm::Value *generateMessageSend(llvm::IRBuilder &Builder, |
Chris Lattner | a0fd5ee | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 39 | const llvm::Type *ReturnTy, |
Chris Lattner | b326b17 | 2008-03-30 23:03:07 +0000 | [diff] [blame] | 40 | llvm::Value *Sender, |
Chris Lattner | a0fd5ee | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 41 | llvm::Value *Receiver, |
Chris Lattner | b326b17 | 2008-03-30 23:03:07 +0000 | [diff] [blame] | 42 | llvm::Value *Selector, |
Chris Lattner | a0fd5ee | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 43 | llvm::Value** ArgV, |
| 44 | unsigned ArgC) = 0; |
Chris Lattner | b326b17 | 2008-03-30 23:03:07 +0000 | [diff] [blame] | 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; } |
Chris Lattner | a0fd5ee | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
Chris Lattner | b326b17 | 2008-03-30 23:03:07 +0000 | [diff] [blame] | 61 | /// Creates an instance of an Objective-C runtime class. |
| 62 | //TODO: This should include some way of selecting which runtime to target. |
| 63 | CGObjCRuntime *CreateObjCRuntime(llvm::Module &M, |
| 64 | const llvm::Type *LLVMIntType, |
| 65 | const llvm::Type *LLVMLongType); |
Chris Lattner | a0fd5ee | 2008-03-01 08:50:34 +0000 | [diff] [blame] | 66 | } |
| 67 | } |
| 68 | #endif |