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,
+ 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 ?