[cfe-dev] More Objective-C code generation
Devang Patel
dpatel at apple.com
Mon Mar 17 13:23:09 PDT 2008
David,
Here is my initial feedback.
+ // FIXME: Should be host native word size
+ IntTy = llvm::Type::Int32Ty;
+ PtrToInt8Ty = llvm::PointerType::getUnqual(IntTy);
Use getIntWidth() from TargetInfo here.
+#define GEP(value, index) \
+ (Builder.CreateGEP(value, \
+ llvm::ConstantInt::get(llvm::Type::Int32Ty, index)))
Please avoid such macros.
+ llvm::Value *cmd;
+ // Look up the selector.
+ if(SelTypes == 0) {
+ llvm::Constant *SelFunction =
+ TheModule.getOrInsertFunction("sel_get_uid", SelectorTy,
PtrToInt8Ty, NULL);
+ cmd = Builder.CreateCall(SelFunction, &SelName, &SelName+1);
+ }
+ else {
+ llvm::Constant *SelFunction =
+ TheModule.getOrInsertFunction("sel_get_typed_uid",
+ SelectorTy,
+ PtrToInt8Ty,
+ PtrToInt8Ty,
+ NULL);
+ cmd = Builder.CreateCall(SelFunction, &SelName, &SelName+1);
+ }
You can move CreateCall outside if {} else {}
+// Generates a MethodList. Used in construction of a objc_class and
+// objc_category structures.
Please start using doxygen style comments for new code.
+ llvm::Value *GenerateIvarList(llvm::LLVMFoldingBuilder &Builder,
+ std::vector<llvm::Constant*> MethodNames,
+ std::vector<llvm::Constant*> MethodTypes,
+ std::vector<llvm::Constant*> MethodIMPs);
+ llvm::Value *GenerateMethodList(llvm::LLVMFoldingBuilder &Builder,
+ std::vector<llvm::Constant*> MethodNames,
+ std::vector<llvm::Constant*> MethodTypes,
+ std::vector<llvm::Constant*> MethodIMPs);
};
Use SmallVectors, instead of std::vectors and pass their references.
+ // Array of method structures
+ llvm::Type *ObjCMethodArrayTy = llvm::ArrayType::get(ObjCMethodTy,
+ MethodNames.size());
What if MethodNames is empty ?
+ // FIXME: This should use an iterator. And possibly a more sensible
+ // data structure than just three vectors.
+ for(unsigned int i=0 ; i<1 ; i++) {
i < 1 ?
Yes, using an iterator is a good idea.
+ // Array of method structures
+ llvm::Type *ObjCIvarArrayTy = llvm::ArrayType::get(ObjCIvarTy,
+ IvarNames.size());
What if IvarNames is empty ?
On Mar 16, 2008, at 10:48 AM, David Chisnall wrote:
> Nothing particularly interesting. This includes code for generating
> method and instance variable lists, which are part of the structures
> used to implement classes and categories. I thought I'd send them
> for inspection before I diverge too much from the tree.
>
> They're not connected to anything yet, but since they're the most
> compilcated parts of the class structure, and we can now generate
> initialisation functions I should be able to add support for
> generating simple classes fairly soon.
>
> David
>
> <clang.diff>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-
Devang
More information about the cfe-dev
mailing list