Preamble += "#pragma section(\".inst_meth$B\", long, read, write)\n";
Preamble += "#pragma section(\".cls_meth$B\", long, read, write)\n";
Preamble += "#pragma section(\".objc_ivar$B\", long, read, write)\n";
-
+
// Add a constructor for creating temporary objects.
Preamble += "__rw_objc_super(struct objc_object *o, struct objc_object *s) "
": ";
/// SEL name;
/// };
-static void WriteModernMetadataDeclarations(std::string &Result) {
+static void WriteModernMetadataDeclarations(ASTContext *Context, std::string &Result) {
static bool meta_data_declared = false;
if (meta_data_declared)
return;
Result += "\tunsigned int const flags;\n";
Result += "\tunsigned int instanceStart;\n";
Result += "\tunsigned int const instanceSize;\n";
- // FIXME, Add 'reserved' field in 64bit abi mode!
- // Result += "\tunsigned int const reserved;
+ const llvm::Triple &Triple(Context->getTargetInfo().getTriple());
+ if (Triple.getArch() == llvm::Triple::x86_64)
+ Result += "\tunsigned int const reserved;\n";
Result += "\tconst unsigned char * const ivarLayout;\n";
Result += "\tconst char *const name;\n";
Result += "\tconst struct _method_list_t * const baseMethods;\n";
Result += InstanceStart; Result += ", ";
Result += InstanceSize; Result += ", \n";
Result += "\t";
- // FIXME. Initizlize 'reserved' field in 64bit abi mode!
- // uint32_t const reserved; // only when building for 64bit targets
- // Result += "(unsigned int)0, \n\t";
+ const llvm::Triple &Triple(Context->getTargetInfo().getTriple());
+ if (Triple.getArch() == llvm::Triple::x86_64)
+ // uint32_t const reserved; // only when building for 64bit targets
+ Result += "(unsigned int)0, \n\t";
// const uint8_t * const ivarLayout;
Result += "0, \n\t";
Result += "\""; Result += ClassName; Result += "\",\n\t";
// Do not synthesize the protocol more than once.
if (ObjCSynthesizedProtocols.count(PDecl->getCanonicalDecl()))
return;
- WriteModernMetadataDeclarations(Result);
+ WriteModernMetadataDeclarations(Context, Result);
if (ObjCProtocolDecl *Def = PDecl->getDefinition())
PDecl = Def;
assert(false &&
"Legacy implicit interface rewriting not supported in moder abi");
- WriteModernMetadataDeclarations(Result);
+ WriteModernMetadataDeclarations(Context, Result);
SmallVector<ObjCIvarDecl *, 8> IVars;
for (ObjCIvarDecl *IVD = CDecl->all_declared_ivar_begin();
/// implementation.
void RewriteModernObjC::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
std::string &Result) {
- WriteModernMetadataDeclarations(Result);
+ WriteModernMetadataDeclarations(Context, Result);
ObjCInterfaceDecl *ClassDecl = IDecl->getClassInterface();
// Find category declaration for this implementation.
ObjCCategoryDecl *CDecl=0;