mirror of https://git.wuffs.org/MWCC
fix lots more bugs, add better logging
This commit is contained in:
parent
00edfdb0d4
commit
5f3c8265f2
|
@ -15,7 +15,7 @@ Target *Target_New(const char *name, OSType cpu, OSType os, OSType lang) {
|
||||||
|
|
||||||
OS_ASSERT(25, Segments_Initialize(&targ->linkage.segs));
|
OS_ASSERT(25, Segments_Initialize(&targ->linkage.segs));
|
||||||
OS_ASSERT(28, Overlays_Initialize(&targ->linkage.overlays));
|
OS_ASSERT(28, Overlays_Initialize(&targ->linkage.overlays));
|
||||||
OS_ASSERT(35, Files_Initialize(&targ->files) && Files_Initialize(&targ->pchs) && VFiles_Initialize(&targ->virtualFiles) &&
|
OS_ASSERT(36, Files_Initialize(&targ->files) && Files_Initialize(&targ->pchs) && VFiles_Initialize(&targ->virtualFiles) &&
|
||||||
Paths_Initialize(&targ->sysPaths) && Paths_Initialize(&targ->userPaths) && Incls_Initialize(&targ->incls, targ));
|
Paths_Initialize(&targ->sysPaths) && Paths_Initialize(&targ->userPaths) && Incls_Initialize(&targ->incls, targ));
|
||||||
|
|
||||||
return targ;
|
return targ;
|
||||||
|
|
|
@ -2418,7 +2418,7 @@ static char *XpandSpecialMacro(Macro *macro) {
|
||||||
} else if (macro == &trgtM) {
|
} else if (macro == &trgtM) {
|
||||||
return CPrep_CheckTarget() ? "1" : "0";
|
return CPrep_CheckTarget() ? "1" : "0";
|
||||||
} else if (macro == &lineM) {
|
} else if (macro == &lineM) {
|
||||||
sprintf(buf, "%ld", linenumber);
|
sprintf(buf, "%" PRId32, linenumber);
|
||||||
do_string:
|
do_string:
|
||||||
strptr = aalloc(strlen(buf) + 1);
|
strptr = aalloc(strlen(buf) + 1);
|
||||||
strcpy(strptr, buf);
|
strcpy(strptr, buf);
|
||||||
|
|
|
@ -254,7 +254,7 @@ static Propagation add_prop = {
|
||||||
&propagateandremoveadd,
|
&propagateandremoveadd,
|
||||||
"ADD",
|
"ADD",
|
||||||
"ADDS",
|
"ADDS",
|
||||||
"a%ld",
|
"a " PRId32,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -486,7 +486,7 @@ static Propagation alias_prop = {
|
||||||
&finishpropagatealiases,
|
&finishpropagatealiases,
|
||||||
"ALIAS",
|
"ALIAS",
|
||||||
"ALIASES",
|
"ALIASES",
|
||||||
"A%ld",
|
"A%" PRId32,
|
||||||
1
|
1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -616,7 +616,7 @@ void gather_alias_info(void) {
|
||||||
if (n_gathered_aliases != n_aliases) {
|
if (n_gathered_aliases != n_aliases) {
|
||||||
for (alias = aliases; alias; alias = alias->next) {
|
for (alias = aliases; alias; alias = alias->next) {
|
||||||
if (alias->type == AliasType2) {
|
if (alias->type == AliasType2) {
|
||||||
alias->vec24 = lalloc(4 * ((n_aliases + 31) >> 35));
|
alias->vec24 = lalloc(4 * ((n_aliases + 31) >> 5));
|
||||||
bitvectorinitialize(alias->vec24, n_aliases, 0);
|
bitvectorinitialize(alias->vec24, n_aliases, 0);
|
||||||
for (member = alias->parents; member; member = member->nextParent) {
|
for (member = alias->parents; member; member = member->nextParent) {
|
||||||
bitvectorsetbit(member->child->index, alias->vec24);
|
bitvectorsetbit(member->child->index, alias->vec24);
|
||||||
|
|
|
@ -212,9 +212,9 @@ void CError_BufferAppendTemplDepType(CErrorBuffer *eb, TypeTemplDep *type) {
|
||||||
switch (type->dtype) {
|
switch (type->dtype) {
|
||||||
case TEMPLDEP_ARGUMENT:
|
case TEMPLDEP_ARGUMENT:
|
||||||
if (type->u.pid.nindex)
|
if (type->u.pid.nindex)
|
||||||
sprintf(buf, "T%ld_%ld", type->u.pid.nindex, type->u.pid.index);
|
sprintf(buf, "T%" PRId32 "%" PRId32, type->u.pid.nindex, type->u.pid.index);
|
||||||
else
|
else
|
||||||
sprintf(buf, "T%ld", type->u.pid.index);
|
sprintf(buf, "T%" PRId32, type->u.pid.index);
|
||||||
CError_BufferAppendString(eb, buf);
|
CError_BufferAppendString(eb, buf);
|
||||||
break;
|
break;
|
||||||
case TEMPLDEP_QUALNAME:
|
case TEMPLDEP_QUALNAME:
|
||||||
|
@ -465,7 +465,7 @@ void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
|
||||||
while (ty->type == TYPEARRAY) {
|
while (ty->type == TYPEARRAY) {
|
||||||
CError_BufferAppendChar(eb, '[');
|
CError_BufferAppendChar(eb, '[');
|
||||||
if (ty->size && TYPE_POINTER(ty)->target->size) {
|
if (ty->size && TYPE_POINTER(ty)->target->size) {
|
||||||
sprintf(buf, "%ld", ty->size / TYPE_POINTER(ty)->target->size);
|
sprintf(buf, "%" PRId32, ty->size / TYPE_POINTER(ty)->target->size);
|
||||||
CError_BufferAppendString(eb, buf);
|
CError_BufferAppendString(eb, buf);
|
||||||
}
|
}
|
||||||
CError_BufferAppendChar(eb, ']');
|
CError_BufferAppendChar(eb, ']');
|
||||||
|
@ -480,7 +480,7 @@ void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
|
||||||
CError_BufferAppendString(eb, "T");
|
CError_BufferAppendString(eb, "T");
|
||||||
return;
|
return;
|
||||||
case TYPEBITFIELD:
|
case TYPEBITFIELD:
|
||||||
sprintf(buf, "bitfield:%ld", TYPE_BITFIELD(ty)->unkB);
|
sprintf(buf, "bitfield:%" PRId32, TYPE_BITFIELD(ty)->unkB);
|
||||||
CError_BufferAppendString(eb, buf);
|
CError_BufferAppendString(eb, buf);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
@ -777,7 +777,7 @@ void CError_ErrorMessageVA(int code, const char *format, va_list list, Boolean f
|
||||||
p += 2;
|
p += 2;
|
||||||
continue;
|
continue;
|
||||||
case 'i':
|
case 'i':
|
||||||
sprintf(unmangleBuf, "%ld", va_arg(list, SInt32));
|
sprintf(unmangleBuf, "%" PRId32, va_arg(list, SInt32));
|
||||||
CError_BufferAppendString(&eb, unmangleBuf);
|
CError_BufferAppendString(&eb, unmangleBuf);
|
||||||
p += 2;
|
p += 2;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -659,7 +659,7 @@ static void CExcept_MangleClassName(TypeClass *tclass) {
|
||||||
if (!nspace->is_global && !nspace->is_templ && !nspace->name) {
|
if (!nspace->is_global && !nspace->is_templ && !nspace->name) {
|
||||||
CError_ASSERT(868, cscope_currentfunc != NULL);
|
CError_ASSERT(868, cscope_currentfunc != NULL);
|
||||||
|
|
||||||
sprintf(buf, "*%lx*%lx*", &cscope_currentfunc, &nspace);
|
sprintf(buf, "*%" PRIxPTR "*%" PRIxPTR "*", &cscope_currentfunc, &nspace);
|
||||||
AppendGListName(&name_mangle_list, buf);
|
AppendGListName(&name_mangle_list, buf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -734,7 +734,7 @@ static void CExcept_MangleClass(TypeClass *tclass) {
|
||||||
AppendGListByte(&name_mangle_list, '!');
|
AppendGListByte(&name_mangle_list, '!');
|
||||||
|
|
||||||
if (bcl->offset) {
|
if (bcl->offset) {
|
||||||
sprintf(buf, "%ld!", bcl->offset);
|
sprintf(buf, "%" PRId32 "!", bcl->offset);
|
||||||
AppendGListName(&name_mangle_list, buf);
|
AppendGListName(&name_mangle_list, buf);
|
||||||
} else {
|
} else {
|
||||||
AppendGListByte(&name_mangle_list, '!');
|
AppendGListByte(&name_mangle_list, '!');
|
||||||
|
|
|
@ -953,7 +953,7 @@ static void CFunc_NameLocalStaticDataObject(Object *obj, char *str) {
|
||||||
if (!(cscope_currentfunc && (cscope_currentfunc->qual & Q_INLINE)) || CParser_HasInternalLinkage(cscope_currentfunc)) {
|
if (!(cscope_currentfunc && (cscope_currentfunc->qual & Q_INLINE)) || CParser_HasInternalLinkage(cscope_currentfunc)) {
|
||||||
obj->name = CParser_AppendUniqueName(str);
|
obj->name = CParser_AppendUniqueName(str);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buf, "$localstatic%ld$", cfunc_staticvarcount++);
|
sprintf(buf, "$localstatic%" PRId32 "$", cfunc_staticvarcount++);
|
||||||
name = CMangler_GetLinkName(cscope_currentfunc);
|
name = CMangler_GetLinkName(cscope_currentfunc);
|
||||||
name = CParser_NameConcat(buf, name->name);
|
name = CParser_NameConcat(buf, name->name);
|
||||||
name = CParser_NameConcat(str, name->name);
|
name = CParser_NameConcat(str, name->name);
|
||||||
|
|
|
@ -24,9 +24,9 @@ TypeIntegral stunsignedlong = {TYPEINT, 4, IT_ULONG};
|
||||||
TypeIntegral stsignedlonglong = {TYPEINT, 8, IT_LONGLONG};
|
TypeIntegral stsignedlonglong = {TYPEINT, 8, IT_LONGLONG};
|
||||||
TypeIntegral stunsignedlonglong = {TYPEINT, 8, IT_ULONGLONG};
|
TypeIntegral stunsignedlonglong = {TYPEINT, 8, IT_ULONGLONG};
|
||||||
TypeIntegral stfloat = {TYPEFLOAT, 4, IT_FLOAT};
|
TypeIntegral stfloat = {TYPEFLOAT, 4, IT_FLOAT};
|
||||||
TypeIntegral stshortdouble = {TYPEINT, 8, IT_SHORTDOUBLE};
|
TypeIntegral stshortdouble = {TYPEFLOAT, 8, IT_SHORTDOUBLE};
|
||||||
TypeIntegral stdouble = {TYPEINT, 8, IT_DOUBLE};
|
TypeIntegral stdouble = {TYPEFLOAT, 8, IT_DOUBLE};
|
||||||
TypeIntegral stlongdouble = {TYPEINT, 8, IT_LONGDOUBLE};
|
TypeIntegral stlongdouble = {TYPEFLOAT, 8, IT_LONGDOUBLE};
|
||||||
|
|
||||||
static StructMember stVUC_unsignedchar15 = {NULL, (Type *) &stunsignedchar, NULL, 15, 0};
|
static StructMember stVUC_unsignedchar15 = {NULL, (Type *) &stunsignedchar, NULL, 15, 0};
|
||||||
static StructMember stVUC_unsignedchar14 = {&stVUC_unsignedchar15, (Type *) &stunsignedchar, NULL, 14, 0};
|
static StructMember stVUC_unsignedchar14 = {&stVUC_unsignedchar15, (Type *) &stunsignedchar, NULL, 14, 0};
|
||||||
|
|
|
@ -181,11 +181,11 @@ HashNameNode *CMangler_ThunkName(Object *vfunc, SInt32 this_delta, SInt32 return
|
||||||
name_mangle_list.size = 0;
|
name_mangle_list.size = 0;
|
||||||
if (return_delta == 0) {
|
if (return_delta == 0) {
|
||||||
if (ctoroffset < 0)
|
if (ctoroffset < 0)
|
||||||
sprintf(buf, "_@%ld@", -this_delta);
|
sprintf(buf, "_@%" PRId32 "@", -this_delta);
|
||||||
else
|
else
|
||||||
sprintf(buf, "_@%ld@%ld@", -this_delta, ctoroffset);
|
sprintf(buf, "_@%" PRId32 "@%" PRId32 "@", -this_delta, ctoroffset);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buf, "_@%ld@%ld@%ld@", -this_delta, ctoroffset, return_delta);
|
sprintf(buf, "_@%" PRId32 "@%" PRId32 "@%" PRId32 "@", -this_delta, ctoroffset, return_delta);
|
||||||
}
|
}
|
||||||
AppendGListName(&name_mangle_list, buf);
|
AppendGListName(&name_mangle_list, buf);
|
||||||
AppendGListID(&name_mangle_list, linkname->name + 1);
|
AppendGListID(&name_mangle_list, linkname->name + 1);
|
||||||
|
@ -414,7 +414,7 @@ static void CMangler_MangleTypeAppend(Type *type, UInt32 qual) {
|
||||||
case TYPEARRAY:
|
case TYPEARRAY:
|
||||||
AppendGListByte(&name_mangle_list, 'A');
|
AppendGListByte(&name_mangle_list, 'A');
|
||||||
if (TYPE_POINTER(type)->target->size) {
|
if (TYPE_POINTER(type)->target->size) {
|
||||||
sprintf(buf, "%ld", type->size / TYPE_POINTER(type)->target->size);
|
sprintf(buf, "%" PRId32 "", type->size / TYPE_POINTER(type)->target->size);
|
||||||
AppendGListName(&name_mangle_list, buf);
|
AppendGListName(&name_mangle_list, buf);
|
||||||
} else {
|
} else {
|
||||||
AppendGListByte(&name_mangle_list, '0');
|
AppendGListByte(&name_mangle_list, '0');
|
||||||
|
@ -516,7 +516,7 @@ static void CMangler_MangleArgs(FuncArg *args) {
|
||||||
if (args->type->type == TYPEPOINTER) {
|
if (args->type->type == TYPEPOINTER) {
|
||||||
ptr = *TYPE_POINTER(args->type);
|
ptr = *TYPE_POINTER(args->type);
|
||||||
ptr.qual &= ~(Q_CONST | Q_VOLATILE);
|
ptr.qual &= ~(Q_CONST | Q_VOLATILE);
|
||||||
CMangler_MangleTypeAppend((Type *) &ptr, args->qual);
|
CMangler_MangleTypeAppend(TYPE(&ptr), args->qual);
|
||||||
} else {
|
} else {
|
||||||
CMangler_MangleTypeAppend(args->type, 0);
|
CMangler_MangleTypeAppend(args->type, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,7 +312,7 @@ static Object *CObjC_GetSelectorObject(ObjCSelector *sel) {
|
||||||
|
|
||||||
if (!sel->selobject) {
|
if (!sel->selobject) {
|
||||||
nameobj = CObjC_SectionString(sel->name->name, SECT_OBJC_METH_VAR_NAMES);
|
nameobj = CObjC_SectionString(sel->name->name, SECT_OBJC_METH_VAR_NAMES);
|
||||||
sprintf(str, "L_OBJC_SELECTOR_REFERENCES_%ld", cobjc_selrefcount++);
|
sprintf(str, "L_OBJC_SELECTOR_REFERENCES_%" PRId32, cobjc_selrefcount++);
|
||||||
|
|
||||||
dataobj = CParser_NewCompilerDefDataObject();
|
dataobj = CParser_NewCompilerDefDataObject();
|
||||||
dataobj->name = GetHashNameNodeExport(str);
|
dataobj->name = GetHashNameNodeExport(str);
|
||||||
|
@ -348,7 +348,7 @@ static Object *CObjC_GetClassRefObject(TypeClass *tclass) {
|
||||||
|
|
||||||
if (!tclass->objcinfo->classrefobj) {
|
if (!tclass->objcinfo->classrefobj) {
|
||||||
nameobj = CObjC_SectionString(tclass->classname->name, SECT_OBJC_CLASS_NAMES);
|
nameobj = CObjC_SectionString(tclass->classname->name, SECT_OBJC_CLASS_NAMES);
|
||||||
sprintf(str, "L_OBJC_CLASS_REFERENCES_%ld", cobjc_classrefcount++);
|
sprintf(str, "L_OBJC_CLASS_REFERENCES_%" PRId32, cobjc_classrefcount++);
|
||||||
|
|
||||||
dataobj = CParser_NewCompilerDefDataObject();
|
dataobj = CParser_NewCompilerDefDataObject();
|
||||||
dataobj->name = GetHashNameNodeExport(str);
|
dataobj->name = GetHashNameNodeExport(str);
|
||||||
|
@ -1407,17 +1407,17 @@ static void CObjC_EncodeTypeMethod(ObjCMethod *meth, Boolean flag) {
|
||||||
else
|
else
|
||||||
AppendGListByte(&name_mangle_list, '@');
|
AppendGListByte(&name_mangle_list, '@');
|
||||||
|
|
||||||
sprintf(buf, "%ld", CodeGen_objc_method_args_size(meth));
|
sprintf(buf, "%" PRId32, CodeGen_objc_method_args_size(meth));
|
||||||
AppendGListName(&name_mangle_list, buf);
|
AppendGListName(&name_mangle_list, buf);
|
||||||
|
|
||||||
AppendGListByte(&name_mangle_list, '@');
|
AppendGListByte(&name_mangle_list, '@');
|
||||||
|
|
||||||
sprintf(buf, "%ld", CodeGen_objc_method_self_offset(meth));
|
sprintf(buf, "%" PRId32, CodeGen_objc_method_self_offset(meth));
|
||||||
AppendGListName(&name_mangle_list, buf);
|
AppendGListName(&name_mangle_list, buf);
|
||||||
|
|
||||||
AppendGListByte(&name_mangle_list, ':');
|
AppendGListByte(&name_mangle_list, ':');
|
||||||
|
|
||||||
sprintf(buf, "%ld", CodeGen_objc_method_sel_offset(meth));
|
sprintf(buf, "%" PRId32, CodeGen_objc_method_sel_offset(meth));
|
||||||
AppendGListName(&name_mangle_list, buf);
|
AppendGListName(&name_mangle_list, buf);
|
||||||
|
|
||||||
for (arg = meth->selector_args; arg; arg = arg->next) {
|
for (arg = meth->selector_args; arg; arg = arg->next) {
|
||||||
|
@ -1427,7 +1427,7 @@ static void CObjC_EncodeTypeMethod(ObjCMethod *meth, Boolean flag) {
|
||||||
|
|
||||||
CObjC_EncodeType(arg->type, 0, flag);
|
CObjC_EncodeType(arg->type, 0, flag);
|
||||||
|
|
||||||
sprintf(buf, "%ld", CodeGen_objc_method_arg_offset(meth, arg));
|
sprintf(buf, "%" PRId32, CodeGen_objc_method_arg_offset(meth, arg));
|
||||||
AppendGListName(&name_mangle_list, buf);
|
AppendGListName(&name_mangle_list, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1529,7 +1529,7 @@ static void CObjC_EncodeType(Type *type, UInt32 qual, Boolean flag) {
|
||||||
case TYPEARRAY:
|
case TYPEARRAY:
|
||||||
AppendGListByte(&name_mangle_list, '[');
|
AppendGListByte(&name_mangle_list, '[');
|
||||||
if (TPTR_TARGET(type)->size) {
|
if (TPTR_TARGET(type)->size) {
|
||||||
sprintf(buf, "%ld", type->size / TPTR_TARGET(type)->size);
|
sprintf(buf, "%" PRId32, type->size / TPTR_TARGET(type)->size);
|
||||||
AppendGListName(&name_mangle_list, buf);
|
AppendGListName(&name_mangle_list, buf);
|
||||||
} else {
|
} else {
|
||||||
AppendGListByte(&name_mangle_list, '0');
|
AppendGListByte(&name_mangle_list, '0');
|
||||||
|
@ -1540,7 +1540,7 @@ static void CObjC_EncodeType(Type *type, UInt32 qual, Boolean flag) {
|
||||||
|
|
||||||
case TYPEBITFIELD:
|
case TYPEBITFIELD:
|
||||||
AppendGListByte(&name_mangle_list, 'b');
|
AppendGListByte(&name_mangle_list, 'b');
|
||||||
sprintf(buf, "%ld", TYPE_BITFIELD(type)->unkB);
|
sprintf(buf, "%" PRId32, TYPE_BITFIELD(type)->unkB);
|
||||||
AppendGListName(&name_mangle_list, buf);
|
AppendGListName(&name_mangle_list, buf);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -3003,7 +3003,7 @@ ENode *CObjC_ParseAtExpression(void) {
|
||||||
|
|
||||||
data[2] = CTool_EndianConvertWord32(tksize - 1);
|
data[2] = CTool_EndianConvertWord32(tksize - 1);
|
||||||
|
|
||||||
sprintf(buf, "%ld", cobjc_stringcount++);
|
sprintf(buf, "%" PRId32, cobjc_stringcount++);
|
||||||
|
|
||||||
object = CObjC_MakeObject("L_NSConstantString_", buf, sizeof(data));
|
object = CObjC_MakeObject("L_NSConstantString_", buf, sizeof(data));
|
||||||
object->type = TYPE(strclass);
|
object->type = TYPE(strclass);
|
||||||
|
|
|
@ -24,9 +24,9 @@ void CPrep_PreprocessDumpFileInfo(Boolean flag) {
|
||||||
AppendGListName(&pplist, "\r");
|
AppendGListName(&pplist, "\r");
|
||||||
|
|
||||||
if (copts.line_prepdump)
|
if (copts.line_prepdump)
|
||||||
size = sprintf(linebuf, "#line %ld\t\"", linenumber);
|
size = sprintf(linebuf, "#line % " PRId32 "\t\"", linenumber);
|
||||||
else
|
else
|
||||||
size = sprintf(linebuf, "/* #line %ld\t\"", linenumber);
|
size = sprintf(linebuf, "/* #line % " PRId32 "\t\"", linenumber);
|
||||||
AppendGListData(&pplist, linebuf, size);
|
AppendGListData(&pplist, linebuf, size);
|
||||||
|
|
||||||
if (copts.fullpath_prepdump) {
|
if (copts.fullpath_prepdump) {
|
||||||
|
@ -49,7 +49,7 @@ void CPrep_PreprocessDumpFileInfo(Boolean flag) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size = sprintf(linebuf, "\"\t/* stack depth %ld */", filesp);
|
size = sprintf(linebuf, "\"\t/* stack depth % " PRId32 " */", filesp);
|
||||||
AppendGListData(&pplist, linebuf, size);
|
AppendGListData(&pplist, linebuf, size);
|
||||||
|
|
||||||
if (copts.line_prepdump && flag)
|
if (copts.line_prepdump && flag)
|
||||||
|
|
|
@ -1929,7 +1929,7 @@ static ENode *CSOM_SOMGlueCall(TypeClass *tclass, SInt32 offset, Object *object)
|
||||||
ptr = CSOM_AppendString(ptr, numberbuf);
|
ptr = CSOM_AppendString(ptr, numberbuf);
|
||||||
ptr = CSOM_AppendString(ptr, tclass->sominfo->classdataobject->name->name);
|
ptr = CSOM_AppendString(ptr, tclass->sominfo->classdataobject->name->name);
|
||||||
*(ptr++) = '_';
|
*(ptr++) = '_';
|
||||||
sprintf(numberbuf, "%ld", offset);
|
sprintf(numberbuf, "%" PRId32, offset);
|
||||||
ptr = CSOM_AppendString(ptr, numberbuf);
|
ptr = CSOM_AppendString(ptr, numberbuf);
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
|
|
||||||
|
|
|
@ -459,7 +459,7 @@ static Propagation copy_prop = {
|
||||||
&propagateandremovecopy,
|
&propagateandremovecopy,
|
||||||
"COPY",
|
"COPY",
|
||||||
"COPIES",
|
"COPIES",
|
||||||
"c%ld",
|
"c%" PRId32,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -808,13 +808,13 @@ void InlineAsm_InitializeRegistersPPC(void) {
|
||||||
sprintf(buf, register_class_format[asmreg->rclass], asmreg->num);
|
sprintf(buf, register_class_format[asmreg->rclass], asmreg->num);
|
||||||
break;
|
break;
|
||||||
case RegClass_6:
|
case RegClass_6:
|
||||||
sprintf(buf, "crbit_%ld", asmreg->num);
|
sprintf(buf, "crbit_%" PRId32, asmreg->num);
|
||||||
break;
|
break;
|
||||||
case RegClass_DCR:
|
case RegClass_DCR:
|
||||||
sprintf(buf, "DCR%ld", asmreg->num);
|
sprintf(buf, "DCR%" PRId32, asmreg->num);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf(buf, "{?}%ld", asmreg->num);
|
sprintf(buf, "{?}%" PRId32, asmreg->num);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PPCError_Warning(100, obj->name->name, buf);
|
PPCError_Warning(100, obj->name->name, buf);
|
||||||
|
@ -832,13 +832,13 @@ void InlineAsm_InitializeRegistersPPC(void) {
|
||||||
sprintf(buf, register_class_format[asmreg->rclass], asmreg->num);
|
sprintf(buf, register_class_format[asmreg->rclass], asmreg->num);
|
||||||
break;
|
break;
|
||||||
case RegClass_6:
|
case RegClass_6:
|
||||||
sprintf(buf, "crbit_%ld", asmreg->num);
|
sprintf(buf, "crbit_%" PRId32, asmreg->num);
|
||||||
break;
|
break;
|
||||||
case RegClass_DCR:
|
case RegClass_DCR:
|
||||||
sprintf(buf, "DCR%ld", asmreg->num);
|
sprintf(buf, "DCR%" PRId32, asmreg->num);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf(buf, "{?}%ld", asmreg->num);
|
sprintf(buf, "{?}%" PRId32, asmreg->num);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PPCError_Warning(100, obj->name->name, buf);
|
PPCError_Warning(100, obj->name->name, buf);
|
||||||
|
|
|
@ -121,6 +121,10 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) {
|
||||||
|
|
||||||
CError_ASSERT(234, stIsSetup);
|
CError_ASSERT(234, stIsSetup);
|
||||||
|
|
||||||
|
#ifdef CW_PATCH_DEBUG
|
||||||
|
IRO_Log = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
DisableDueToAsm = 0;
|
DisableDueToAsm = 0;
|
||||||
FunctionName = func;
|
FunctionName = func;
|
||||||
DoScalarize = 1;
|
DoScalarize = 1;
|
||||||
|
|
|
@ -886,7 +886,7 @@ static void MoveCommonSub(IROExpr *expr) {
|
||||||
|
|
||||||
i1 = sz1;
|
i1 = sz1;
|
||||||
i2 = sz2;
|
i2 = sz2;
|
||||||
while (i1 && i2 && array1[sz1 - 1] == array2[sz2 - 1]) {
|
while (i1 && i2 && array1[i1 - 1] == array2[i2 - 1]) {
|
||||||
i1--;
|
i1--;
|
||||||
i2--;
|
i2--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,6 +295,9 @@ void IRO_DumpBits(char *name, BitVector *bv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRO_DumpAfterPhase(char *str, Boolean flag) {
|
void IRO_DumpAfterPhase(char *str, Boolean flag) {
|
||||||
|
#ifdef CW_PATCH_DEBUG
|
||||||
|
flag = 1;
|
||||||
|
#endif
|
||||||
if (flag) {
|
if (flag) {
|
||||||
IRO_Dump("Dumping function %s after %s \n", FunctionName ? FunctionName->name->name : "Init-code", str);
|
IRO_Dump("Dumping function %s after %s \n", FunctionName ? FunctionName->name->name : "Init-code", str);
|
||||||
IRO_Dump("--------------------------------------------------------------------------------\n");
|
IRO_Dump("--------------------------------------------------------------------------------\n");
|
||||||
|
@ -441,6 +444,10 @@ void IRO_DumpExprs(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRO_SetupDump(void) {
|
void IRO_SetupDump(void) {
|
||||||
|
#ifdef CW_PATCH_DEBUG
|
||||||
|
IRO_Log = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (IRO_Log) {
|
if (IRO_Log) {
|
||||||
if ((DumpFile = fopen("OPT.LOG", "wt")) == NULL)
|
if ((DumpFile = fopen("OPT.LOG", "wt")) == NULL)
|
||||||
IRO_Log = 0;
|
IRO_Log = 0;
|
||||||
|
|
|
@ -149,7 +149,7 @@ static Boolean EmptyLoop(IRONode *fnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CanRemoveRedundantLoop(loop)) {
|
if (CanRemoveRedundantLoop(loop)) {
|
||||||
IRO_Dump("EmptyLoop: # of iterations =%ld, FinalStoreVal=%ld\n", CInt64_GetULong(&loop->x28), CInt64_GetULong(&loop->x30));
|
IRO_Dump("EmptyLoop: # of iterations =%" PRId32 ", FinalStoreVal=%" PRId32 "\n", CInt64_GetULong(&loop->x28), CInt64_GetULong(&loop->x30));
|
||||||
IRO_NopOut(r21->last->u.label.x4);
|
IRO_NopOut(r21->last->u.label.x4);
|
||||||
r21->last->type = IROLinearNop;
|
r21->last->type = IROLinearNop;
|
||||||
type20 = loop->induction->nd->rtype;
|
type20 = loop->induction->nd->rtype;
|
||||||
|
|
|
@ -5312,7 +5312,7 @@ static void ParseLocationSet(LocationSet *loc, Type *rtype, Object *proc, Create
|
||||||
ep = CreateExtendedParam(NULL, NULL, obj, &epFlag);
|
ep = CreateExtendedParam(NULL, NULL, obj, &epFlag);
|
||||||
} else {
|
} else {
|
||||||
char buf[64];
|
char buf[64];
|
||||||
sprintf(buf, "__parameter_representative(%ld)", obj->u.var.uid);
|
sprintf(buf, "__parameter_representative(%" PRId32 ")", obj->u.var.uid);
|
||||||
CError_Error(CErrorStr140, buf);
|
CError_Error(CErrorStr140, buf);
|
||||||
failed = 1;
|
failed = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,7 +399,7 @@ static Boolean ERfoldExpr(IROLinear *nd) {
|
||||||
EREandHasNoUse(range, val) &&
|
EREandHasNoUse(range, val) &&
|
||||||
!IRO_HasSideEffect(nd->u.diadic.left)
|
!IRO_HasSideEffect(nd->u.diadic.left)
|
||||||
) {
|
) {
|
||||||
IRO_Dump("eliminating redundant EAND %ld; upperBound==0x%x, lowerBound==0x%x, Constant==0x%x\n",
|
IRO_Dump("eliminating redundant EAND %" PRId32 "; upperBound==0x%x, lowerBound==0x%x, Constant==0x%x\n",
|
||||||
nd->index,
|
nd->index,
|
||||||
CInt64_GetULong(&range->upper),
|
CInt64_GetULong(&range->upper),
|
||||||
CInt64_GetULong(&range->upper),
|
CInt64_GetULong(&range->upper),
|
||||||
|
|
|
@ -37,7 +37,7 @@ static Propagation load_immediate_prop = {
|
||||||
&deleteload,
|
&deleteload,
|
||||||
"LOAD IMMEDIATE",
|
"LOAD IMMEDIATE",
|
||||||
"LOAD_IMMEDIATES",
|
"LOAD_IMMEDIATES",
|
||||||
"l%ld",
|
"l%" PRId32,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -281,11 +281,11 @@ void insertpreheaderblock(Loop *loop) {
|
||||||
} else if (pcode27->op == PC_BCTR) {
|
} else if (pcode27->op == PC_BCTR) {
|
||||||
if (pcode27->argCount > 1 && pcode27->args[1].kind == PCOp_MEMORY) {
|
if (pcode27->argCount > 1 && pcode27->args[1].kind == PCOp_MEMORY) {
|
||||||
Object *obj = pcode27->args[1].data.mem.obj;
|
Object *obj = pcode27->args[1].data.mem.obj;
|
||||||
PCodeLabel **array = (PCodeLabel **) obj->u.data.u.switchtable.data;
|
UInt32 *array = (UInt32 *) obj->u.data.u.switchtable.data;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < obj->u.data.u.switchtable.size; i++) {
|
for (i = 0; i < obj->u.data.u.switchtable.size; i++) {
|
||||||
if (array[i]->block == block28)
|
if (((PCodeLabel *) CTool_ResolveIndexToPointer(array[i]))->block == block28)
|
||||||
array[i] = preheader->labels;
|
array[i] = CTool_CreateIndexFromPointer(preheader->labels);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CodeLabelList *cll;
|
CodeLabelList *cll;
|
||||||
|
|
|
@ -74,7 +74,7 @@ static DefSectionInfo def_section_info[] = {
|
||||||
SECT_4BYTE_LITERALS, SECT_4BYTE_LITERALS, "__TEXT", "__literal4", 4, S_4BYTE_LITERALS,
|
SECT_4BYTE_LITERALS, SECT_4BYTE_LITERALS, "__TEXT", "__literal4", 4, S_4BYTE_LITERALS,
|
||||||
SECT_MOD_INIT_FUNC, SECT_MOD_INIT_FUNC, "__DATA", "__mod_init_func", 4, S_MOD_INIT_FUNC_POINTERS,
|
SECT_MOD_INIT_FUNC, SECT_MOD_INIT_FUNC, "__DATA", "__mod_init_func", 4, S_MOD_INIT_FUNC_POINTERS,
|
||||||
SECT_CONST, SECT_CONST, "__TEXT", "__const", 4, S_REGULAR,
|
SECT_CONST, SECT_CONST, "__TEXT", "__const", 4, S_REGULAR,
|
||||||
SECT_CONST_PTR, SECT_CONST_PTR, "__TEXT", "__const", 4, S_REGULAR,
|
SECT_CONST_PTR, SECT_CONST_PTR, "__DATA", "__const", 4, S_REGULAR,
|
||||||
SECT_NONLAZY_PTRS, SECT_NONLAZY_PTRS, "__DATA", "__nl_symbol_ptr", 4, S_NON_LAZY_SYMBOL_POINTERS,
|
SECT_NONLAZY_PTRS, SECT_NONLAZY_PTRS, "__DATA", "__nl_symbol_ptr", 4, S_NON_LAZY_SYMBOL_POINTERS,
|
||||||
SECT_COMMON_VARS, SECT_COMMON_VARS, NULL, NULL, 0, S_REGULAR,
|
SECT_COMMON_VARS, SECT_COMMON_VARS, NULL, NULL, 0, S_REGULAR,
|
||||||
SECT_16BYTE_LITERALS, SECT_16BYTE_LITERALS, "__DATA", "__literal16", 16, S_REGULAR,
|
SECT_16BYTE_LITERALS, SECT_16BYTE_LITERALS, "__DATA", "__literal16", 16, S_REGULAR,
|
||||||
|
@ -1090,7 +1090,7 @@ static void declaredata(Object *object, char *data, OLinkList *olinklist, UInt32
|
||||||
|
|
||||||
for (scan = olinklist; scan; scan = scan->next) {
|
for (scan = olinklist; scan; scan = scan->next) {
|
||||||
if (scan->somevalue)
|
if (scan->somevalue)
|
||||||
*((SInt32 *) (data + scan->offset)) = scan->somevalue;
|
*((SInt32 *) (data + scan->offset)) = CTool_EndianConvertWord32(scan->somevalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sectionID == SECT_8BYTE_LITERALS)
|
if (sectionID == SECT_8BYTE_LITERALS)
|
||||||
|
@ -1583,8 +1583,8 @@ void ObjGen_DeclareExceptionTables(Object *object, SInt32 codesize, char *data,
|
||||||
flag22 = 0;
|
flag22 = 0;
|
||||||
|
|
||||||
if (len == 8) {
|
if (len == 8) {
|
||||||
if ((*((UInt16 *) data) & 8) >> 3) {
|
if (CTool_EndianConvertWord16(*((UInt16 *) data) & 8) >> 3) {
|
||||||
*((UInt16 *) data) &= ~8;
|
*((UInt16 *) data) = CTool_EndianConvertWord16(CTool_EndianConvertWord16(*((UInt16 *) data)) & ~8);
|
||||||
len = 4;
|
len = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1644,8 +1644,8 @@ void ObjGen_DeclareExceptionTables(Object *object, SInt32 codesize, char *data,
|
||||||
RelocIndex++;
|
RelocIndex++;
|
||||||
|
|
||||||
stuff[0] = 0;
|
stuff[0] = 0;
|
||||||
stuff[1] = ((len == 4) << 31) | (codesize & 0x7FFFFFFF);
|
stuff[1] = CTool_EndianConvertWord32(((len == 4) << 31) | (codesize & 0x7FFFFFFF));
|
||||||
stuff[2] = (len == 4) ? *((UInt32 *) data) : 0;
|
stuff[2] = CTool_EndianConvertWord32((len == 4) ? CTool_EndianConvertWord32(*((UInt32 *) data)) : 0);
|
||||||
AppendGListData(gl, stuff, sizeof(stuff));
|
AppendGListData(gl, stuff, sizeof(stuff));
|
||||||
|
|
||||||
ObjGen_RelocateObj(section, offset, object, MW_RELOC_9);
|
ObjGen_RelocateObj(section, offset, object, MW_RELOC_9);
|
||||||
|
|
|
@ -663,7 +663,7 @@ int expectandformatoperand(PCodeArg *operand, PCOpKind expectedKind, char a3, in
|
||||||
tmp = sprintf(buf, "%u", operand->data.imm.value);
|
tmp = sprintf(buf, "%u", operand->data.imm.value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tmp = sprintf(buf, "%ld", operand->data.imm.value);
|
tmp = sprintf(buf, "%" PRId32, operand->data.imm.value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
errorlen += tmp;
|
errorlen += tmp;
|
||||||
|
@ -754,9 +754,9 @@ int expectandformatoperand(PCodeArg *operand, PCOpKind expectedKind, char a3, in
|
||||||
if (!operand->data.label.label->block)
|
if (!operand->data.label.label->block)
|
||||||
tmp = sprintf(buf, "B<unknown>");
|
tmp = sprintf(buf, "B<unknown>");
|
||||||
else
|
else
|
||||||
tmp = sprintf(buf, "B%ld", operand->data.label.label->block->blockIndex);
|
tmp = sprintf(buf, "B%" PRId32, operand->data.label.label->block->blockIndex);
|
||||||
} else {
|
} else {
|
||||||
tmp = sprintf(buf, "%.8lX", operand->data.label.label->block->codeOffset);
|
tmp = sprintf(buf, "%.8" PRIX32, operand->data.label.label->block->codeOffset);
|
||||||
}
|
}
|
||||||
errorlen += tmp;
|
errorlen += tmp;
|
||||||
break;
|
break;
|
||||||
|
@ -765,14 +765,14 @@ int expectandformatoperand(PCodeArg *operand, PCOpKind expectedKind, char a3, in
|
||||||
b_null = !operand->data.labeldiff.labelB->block;
|
b_null = !operand->data.labeldiff.labelB->block;
|
||||||
if (operand->data.labeldiff.labelA->block == NULL) {
|
if (operand->data.labeldiff.labelA->block == NULL) {
|
||||||
if (b_null)
|
if (b_null)
|
||||||
tmp = sprintf(buf, "%sB<unknown>-B<unknown>+%ld", refis1 ? "-" : "", operand->data.labeldiff.offset);
|
tmp = sprintf(buf, "%sB<unknown>-B<unknown>+%" PRId32, refis1 ? "-" : "", operand->data.labeldiff.offset);
|
||||||
else
|
else
|
||||||
tmp = sprintf(buf, "%sB<unknown>-B%ld+%ld", refis1 ? "-" : "", operand->data.labeldiff.labelB->block->blockIndex, operand->data.labeldiff.offset);
|
tmp = sprintf(buf, "%sB<unknown>-B%" PRId32 "+%" PRId32, refis1 ? "-" : "", operand->data.labeldiff.labelB->block->blockIndex, operand->data.labeldiff.offset);
|
||||||
} else {
|
} else {
|
||||||
if (b_null)
|
if (b_null)
|
||||||
tmp = sprintf(buf, "%sB%ld-B<unknown>+%ld", refis1 ? "-" : "", operand->data.labeldiff.labelA->block->blockIndex, operand->data.labeldiff.offset);
|
tmp = sprintf(buf, "%sB%" PRId32 "-B<unknown>+%" PRId32, refis1 ? "-" : "", operand->data.labeldiff.labelA->block->blockIndex, operand->data.labeldiff.offset);
|
||||||
else
|
else
|
||||||
tmp = sprintf(buf, "%sB%ld-B%ld+%ld", refis1 ? "-" : "", operand->data.labeldiff.labelA->block->blockIndex, operand->data.labeldiff.labelB->block->blockIndex, operand->data.labeldiff.offset);
|
tmp = sprintf(buf, "%sB%" PRId32 "-B%" PRId32 "+%" PRId32, refis1 ? "-" : "", operand->data.labeldiff.labelA->block->blockIndex, operand->data.labeldiff.labelB->block->blockIndex, operand->data.labeldiff.offset);
|
||||||
}
|
}
|
||||||
errorlen += tmp;
|
errorlen += tmp;
|
||||||
break;
|
break;
|
||||||
|
@ -1009,7 +1009,7 @@ void formatoperands(PCode *pcode, char *buf, int showBasicBlocks) {
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
if (pa->kind == PCOp_IMMEDIATE) {
|
if (pa->kind == PCOp_IMMEDIATE) {
|
||||||
buf += sprintf(buf, "*%s%ld", (pa->data.imm.value >= 0) ? "+" : "", pa->data.imm.value);
|
buf += sprintf(buf, "*%s%" PRId32, (pa->data.imm.value >= 0) ? "+" : "", pa->data.imm.value);
|
||||||
} else if (pa->kind == PCOp_LABELDIFF) {
|
} else if (pa->kind == PCOp_LABELDIFF) {
|
||||||
buf += expectandformatoperand(pa, PCOp_LABELDIFF, 0, -1, buf);
|
buf += expectandformatoperand(pa, PCOp_LABELDIFF, 0, -1, buf);
|
||||||
} else if (pa->kind == PCOp_LABEL) {
|
} else if (pa->kind == PCOp_LABEL) {
|
||||||
|
|
|
@ -57,26 +57,26 @@ static void pclistblock(PCodeBlock *block, char *format, UInt32 vecSize) {
|
||||||
char buf[500];
|
char buf[500];
|
||||||
WeirdOperand dummyArg;
|
WeirdOperand dummyArg;
|
||||||
|
|
||||||
fprintf(pcfile, ":{%4.4x}::::::::::::::::::::::::::::::::::::::::LOOPWEIGHT=%ld\n", block->flags, block->loopWeight);
|
fprintf(pcfile, ":{%4.4x}::::::::::::::::::::::::::::::::::::::::LOOPWEIGHT=%" PRId32 "\n", block->flags, block->loopWeight);
|
||||||
fprintf(pcfile, "B%ld: ", block->blockIndex);
|
fprintf(pcfile, "B%" PRId32 ": ", block->blockIndex);
|
||||||
|
|
||||||
fprintf(pcfile, "Successors = { ");
|
fprintf(pcfile, "Successors = { ");
|
||||||
for (link = block->successors; link; link = link->nextLink) {
|
for (link = block->successors; link; link = link->nextLink) {
|
||||||
if (link->block)
|
if (link->block)
|
||||||
fprintf(pcfile, "B%ld ", link->block->blockIndex);
|
fprintf(pcfile, "B%" PRId32 " ", link->block->blockIndex);
|
||||||
}
|
}
|
||||||
fprintf(pcfile, "} ");
|
fprintf(pcfile, "} ");
|
||||||
|
|
||||||
fprintf(pcfile, "Predecessors = { ");
|
fprintf(pcfile, "Predecessors = { ");
|
||||||
for (link = block->predecessors; link; link = link->nextLink) {
|
for (link = block->predecessors; link; link = link->nextLink) {
|
||||||
if (link->block)
|
if (link->block)
|
||||||
fprintf(pcfile, "B%ld ", link->block->blockIndex);
|
fprintf(pcfile, "B%" PRId32 " ", link->block->blockIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block->labels) {
|
if (block->labels) {
|
||||||
fprintf(pcfile, "} Labels = { ");
|
fprintf(pcfile, "} Labels = { ");
|
||||||
for (label = block->labels; label; label = label->nextLabel)
|
for (label = block->labels; label; label = label->nextLabel)
|
||||||
fprintf(pcfile, "L%ld ", label->index);
|
fprintf(pcfile, "L%" PRId32 " ", label->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(pcfile, "}\n\n");
|
fprintf(pcfile, "}\n\n");
|
||||||
|
@ -115,7 +115,7 @@ static void pclistblock(PCodeBlock *block, char *format, UInt32 vecSize) {
|
||||||
|
|
||||||
fprintf(
|
fprintf(
|
||||||
pcfile,
|
pcfile,
|
||||||
" %.8lX %.8lX %4ld %-7s%c %s\n",
|
" %.8" PRIx32 " %.8" PRIx32 " %4" PRId32 " %-7s%c %s\n",
|
||||||
offset, opcode, latency,
|
offset, opcode, latency,
|
||||||
opcodeinfo[instr->op].name, chr, buf
|
opcodeinfo[instr->op].name, chr, buf
|
||||||
);
|
);
|
||||||
|
|
|
@ -106,15 +106,15 @@ static int first_nonvolatile_reg(RegClass rclass) {
|
||||||
|
|
||||||
void setup_diagnostic_reg_strings(void) {
|
void setup_diagnostic_reg_strings(void) {
|
||||||
register_class_name[RegClass_SPR] = "SPR";
|
register_class_name[RegClass_SPR] = "SPR";
|
||||||
register_class_format[RegClass_SPR] = "spr%ld";
|
register_class_format[RegClass_SPR] = "spr%" PRId32;
|
||||||
register_class_name[RegClass_CRFIELD] = "CRFIELD";
|
register_class_name[RegClass_CRFIELD] = "CRFIELD";
|
||||||
register_class_format[RegClass_CRFIELD] = "cr%ld";
|
register_class_format[RegClass_CRFIELD] = "cr%" PRId32;
|
||||||
register_class_name[RegClass_VR] = "VR";
|
register_class_name[RegClass_VR] = "VR";
|
||||||
register_class_format[RegClass_VR] = "vr%ld";
|
register_class_format[RegClass_VR] = "vr%" PRId32;
|
||||||
register_class_name[RegClass_FPR] = "FPR";
|
register_class_name[RegClass_FPR] = "FPR";
|
||||||
register_class_format[RegClass_FPR] = "f%ld";
|
register_class_format[RegClass_FPR] = "f%" PRId32;
|
||||||
register_class_name[RegClass_GPR] = "GPR";
|
register_class_name[RegClass_GPR] = "GPR";
|
||||||
register_class_format[RegClass_GPR] = "r%ld";
|
register_class_format[RegClass_GPR] = "r%" PRId32;
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_target_registers(void) {
|
void init_target_registers(void) {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "compiler/CInt64.h"
|
#include "compiler/CInt64.h"
|
||||||
#include "compiler/CMachine.h"
|
#include "compiler/CMachine.h"
|
||||||
#include "compiler/CMangler.h"
|
#include "compiler/CMangler.h"
|
||||||
|
#include "compiler/CParser.h"
|
||||||
#include "compiler/Exceptions.h"
|
#include "compiler/Exceptions.h"
|
||||||
#include "compiler/Switch.h"
|
#include "compiler/Switch.h"
|
||||||
#include "compiler/enode.h"
|
#include "compiler/enode.h"
|
||||||
|
@ -67,9 +68,92 @@ void SetupDumpIR(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CleanupDumpIR(void) {
|
void CleanupDumpIR(void) {
|
||||||
|
#ifdef CW_PATCH_DEBUG
|
||||||
|
// this code is not based on the original as we don't have it
|
||||||
|
if (outfile) {
|
||||||
|
fclose(outfile);
|
||||||
|
outfile = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpIR(Statement *statements, Object *func) {
|
void DumpIR(Statement *statements, Object *func) {
|
||||||
|
#ifdef CW_PATCH_DEBUG
|
||||||
|
// this code is not based on the original as we don't have it
|
||||||
|
if (copts.debuglisting) {
|
||||||
|
if (!outfile)
|
||||||
|
outfile = fopen("irdump.txt", "a");
|
||||||
|
|
||||||
|
fputs("--- BEGIN IR DUMP ---\r", outfile);
|
||||||
|
while (statements) {
|
||||||
|
switch (statements->type) {
|
||||||
|
case ST_NOP:
|
||||||
|
fputs("ST_NOP\r", outfile);
|
||||||
|
break;
|
||||||
|
case ST_LABEL:
|
||||||
|
fputs("ST_LABEL\r", outfile);
|
||||||
|
break;
|
||||||
|
case ST_GOTO:
|
||||||
|
fputs("ST_GOTO\r", outfile);
|
||||||
|
break;
|
||||||
|
case ST_EXPRESSION:
|
||||||
|
fputs("ST_EXPRESSION\r", outfile);
|
||||||
|
DumpExpression(statements->expr, 1);
|
||||||
|
break;
|
||||||
|
case ST_SWITCH:
|
||||||
|
fputs("ST_SWITCH\r", outfile);
|
||||||
|
DumpExpression(statements->expr, 1);
|
||||||
|
break;
|
||||||
|
case ST_IFGOTO:
|
||||||
|
fputs("ST_IFGOTO\r", outfile);
|
||||||
|
DumpExpression(statements->expr, 1);
|
||||||
|
break;
|
||||||
|
case ST_IFNGOTO:
|
||||||
|
fputs("ST_IFNGOTO\r", outfile);
|
||||||
|
DumpExpression(statements->expr, 1);
|
||||||
|
break;
|
||||||
|
case ST_RETURN:
|
||||||
|
fputs("ST_RETURN\r", outfile);
|
||||||
|
if (statements->expr)
|
||||||
|
DumpExpression(statements->expr, 1);
|
||||||
|
break;
|
||||||
|
case ST_OVF:
|
||||||
|
fputs("ST_OVF\r", outfile);
|
||||||
|
break;
|
||||||
|
case ST_EXIT:
|
||||||
|
fputs("ST_EXIT\r", outfile);
|
||||||
|
break;
|
||||||
|
case ST_ENTRY:
|
||||||
|
fputs("ST_ENTRY\r", outfile);
|
||||||
|
break;
|
||||||
|
case ST_BEGINCATCH:
|
||||||
|
fputs("ST_BEGINCATCH\r", outfile);
|
||||||
|
break;
|
||||||
|
case ST_ENDCATCH:
|
||||||
|
fputs("ST_ENDCATCH\r", outfile);
|
||||||
|
break;
|
||||||
|
case ST_ENDCATCHDTOR:
|
||||||
|
fputs("ST_ENDCATCHDTOR\r", outfile);
|
||||||
|
break;
|
||||||
|
case ST_GOTOEXPR:
|
||||||
|
fputs("ST_GOTOEXPR\r", outfile);
|
||||||
|
break;
|
||||||
|
case ST_ASM:
|
||||||
|
fputs("ST_ASM\r", outfile);
|
||||||
|
break;
|
||||||
|
case ST_BEGINLOOP:
|
||||||
|
fputs("ST_BEGINLOOP\r", outfile);
|
||||||
|
break;
|
||||||
|
case ST_ENDLOOP:
|
||||||
|
fputs("ST_ENDLOOP\r", outfile);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
statements = statements->next;
|
||||||
|
}
|
||||||
|
fputs("--- END IR DUMP ---\r", outfile);
|
||||||
|
fflush(outfile);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpExpression(ENode *expr, int indent) {
|
void DumpExpression(ENode *expr, int indent) {
|
||||||
|
@ -169,10 +253,15 @@ void DumpExpression(ENode *expr, int indent) {
|
||||||
|
|
||||||
switch (expr->type) {
|
switch (expr->type) {
|
||||||
case EINTCONST:
|
case EINTCONST:
|
||||||
if (expr->rtype->size > 4)
|
if (expr->rtype->size > 4) {
|
||||||
fprintf(outfile, "[0x%.8lX%.8lX]", expr->data.intval.hi, expr->data.intval.lo);
|
fprintf(outfile,
|
||||||
else
|
"[0x%.8" PRIX32 "%.8" PRIX32 "]",
|
||||||
fprintf(outfile, "[%ld]", expr->data.intval.lo);
|
expr->data.intval.hi, expr->data.intval.lo);
|
||||||
|
} else {
|
||||||
|
fprintf(outfile,
|
||||||
|
"[%" PRId32 "]",
|
||||||
|
expr->data.intval.lo);
|
||||||
|
}
|
||||||
DumpType(expr->rtype);
|
DumpType(expr->rtype);
|
||||||
fprintf(outfile, "\r");
|
fprintf(outfile, "\r");
|
||||||
return;
|
return;
|
||||||
|
@ -199,7 +288,8 @@ void DumpExpression(ENode *expr, int indent) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case EVECTOR128CONST:
|
case EVECTOR128CONST:
|
||||||
fprintf(outfile, "[0x%.8lX%.8lX%.8lX%.8lX]",
|
fprintf(outfile,
|
||||||
|
"[0x%.8" PRIX32 "%.8" PRIX32 "%.8" PRIX32 "%.8" PRIX32 "]",
|
||||||
expr->data.vector128val.ul[0],
|
expr->data.vector128val.ul[0],
|
||||||
expr->data.vector128val.ul[1],
|
expr->data.vector128val.ul[1],
|
||||||
expr->data.vector128val.ul[2],
|
expr->data.vector128val.ul[2],
|
||||||
|
@ -278,7 +368,7 @@ void DumpExpression(ENode *expr, int indent) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENULLCHECK:
|
case ENULLCHECK:
|
||||||
fprintf(outfile, " unique [%ld]", expr->data.nullcheck.precompid);
|
fprintf(outfile, " unique [%" PRId32 "]", expr->data.nullcheck.precompid);
|
||||||
DumpType(expr->rtype);
|
DumpType(expr->rtype);
|
||||||
fprintf(outfile, "\r");
|
fprintf(outfile, "\r");
|
||||||
DumpExpression(expr->data.nullcheck.nullcheckexpr, indent + 1);
|
DumpExpression(expr->data.nullcheck.nullcheckexpr, indent + 1);
|
||||||
|
@ -287,7 +377,7 @@ void DumpExpression(ENode *expr, int indent) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EPRECOMP:
|
case EPRECOMP:
|
||||||
fprintf(outfile, " unique [%ld]", expr->data.precompid);
|
fprintf(outfile, " unique [%" PRId32 "]", expr->data.precompid);
|
||||||
DumpType(expr->rtype);
|
DumpType(expr->rtype);
|
||||||
fprintf(outfile, "\r");
|
fprintf(outfile, "\r");
|
||||||
return;
|
return;
|
||||||
|
@ -317,7 +407,7 @@ void DumpExpression(ENode *expr, int indent) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case EDEFINE:
|
case EDEFINE:
|
||||||
fprintf(outfile, "[%.8lX]", expr);
|
fprintf(outfile, "[%.8" PRIX32 "]", expr);
|
||||||
DumpType(expr->rtype);
|
DumpType(expr->rtype);
|
||||||
fputs("\r", outfile);
|
fputs("\r", outfile);
|
||||||
expr = expr->data.monadic;
|
expr = expr->data.monadic;
|
||||||
|
@ -325,7 +415,7 @@ void DumpExpression(ENode *expr, int indent) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EREUSE:
|
case EREUSE:
|
||||||
fprintf(outfile, "[%.8lX]", expr->data.monadic);
|
fprintf(outfile, "[%.8" PRIX32 "]", expr->data.monadic);
|
||||||
DumpType(expr->rtype);
|
DumpType(expr->rtype);
|
||||||
fputs("\r", outfile);
|
fputs("\r", outfile);
|
||||||
return;
|
return;
|
||||||
|
@ -535,7 +625,7 @@ void DumpStack(ExceptionAction *act) {
|
||||||
break;
|
break;
|
||||||
case EAT_DESTROYLOCALOFFSET:
|
case EAT_DESTROYLOCALOFFSET:
|
||||||
fprintf(outfile,
|
fprintf(outfile,
|
||||||
"EAT_DESTROYLOCALOFFSET %s(&%s+%ld)%s",
|
"EAT_DESTROYLOCALOFFSET %s(&%s+%" PRId32 ")%s",
|
||||||
CMangler_GetLinkName(act->data.destroy_local_offset.dtor)->name,
|
CMangler_GetLinkName(act->data.destroy_local_offset.dtor)->name,
|
||||||
act->data.destroy_local_offset.local->name->name,
|
act->data.destroy_local_offset.local->name->name,
|
||||||
act->data.destroy_local_offset.offset,
|
act->data.destroy_local_offset.offset,
|
||||||
|
@ -553,14 +643,14 @@ void DumpStack(ExceptionAction *act) {
|
||||||
break;
|
break;
|
||||||
case EAT_DESTROYBASE:
|
case EAT_DESTROYBASE:
|
||||||
fprintf(outfile,
|
fprintf(outfile,
|
||||||
"EAT_DESTROYBASE %s(this+%ld)%s",
|
"EAT_DESTROYBASE %s(this+%" PRId32 ")%s",
|
||||||
CMangler_GetLinkName(act->data.destroy_base.dtor)->name,
|
CMangler_GetLinkName(act->data.destroy_base.dtor)->name,
|
||||||
act->data.destroy_base.offset,
|
act->data.destroy_base.offset,
|
||||||
"\r");
|
"\r");
|
||||||
break;
|
break;
|
||||||
case EAT_DESTROYMEMBER:
|
case EAT_DESTROYMEMBER:
|
||||||
fprintf(outfile,
|
fprintf(outfile,
|
||||||
"EAT_DESTROYMEMBER %s(%s+%ld)%s",
|
"EAT_DESTROYMEMBER %s(%s+%" PRId32 ")%s",
|
||||||
CMangler_GetLinkName(act->data.destroy_member.dtor)->name,
|
CMangler_GetLinkName(act->data.destroy_member.dtor)->name,
|
||||||
act->data.destroy_member.objectptr->name->name,
|
act->data.destroy_member.objectptr->name->name,
|
||||||
act->data.destroy_member.offset,
|
act->data.destroy_member.offset,
|
||||||
|
@ -568,7 +658,7 @@ void DumpStack(ExceptionAction *act) {
|
||||||
break;
|
break;
|
||||||
case EAT_DESTROYMEMBERCOND:
|
case EAT_DESTROYMEMBERCOND:
|
||||||
fprintf(outfile,
|
fprintf(outfile,
|
||||||
"EAT_DESTROYMEMBERCOND if(%s) %s(this+%ld)%s",
|
"EAT_DESTROYMEMBERCOND if(%s) %s(this+%" PRId32 ")%s",
|
||||||
act->data.destroy_member_cond.cond->name->name,
|
act->data.destroy_member_cond.cond->name->name,
|
||||||
CMangler_GetLinkName(act->data.destroy_member_cond.dtor)->name,
|
CMangler_GetLinkName(act->data.destroy_member_cond.dtor)->name,
|
||||||
act->data.destroy_member_cond.offset,
|
act->data.destroy_member_cond.offset,
|
||||||
|
@ -576,7 +666,7 @@ void DumpStack(ExceptionAction *act) {
|
||||||
break;
|
break;
|
||||||
case EAT_DESTROYMEMBERARRAY:
|
case EAT_DESTROYMEMBERARRAY:
|
||||||
fprintf(outfile,
|
fprintf(outfile,
|
||||||
"EAT_DESTROYMEMBERARRAY %s(this+%ld)[%ld] size: %ld%s",
|
"EAT_DESTROYMEMBERARRAY %s(this+%" PRId32 ")[%" PRId32 "] size: %" PRId32 "%s",
|
||||||
CMangler_GetLinkName(act->data.destroy_member_array.dtor)->name,
|
CMangler_GetLinkName(act->data.destroy_member_array.dtor)->name,
|
||||||
act->data.destroy_member_array.offset,
|
act->data.destroy_member_array.offset,
|
||||||
act->data.destroy_member_array.elements,
|
act->data.destroy_member_array.elements,
|
||||||
|
|
|
@ -29,7 +29,15 @@
|
||||||
|
|
||||||
#define CW_INLINE inline
|
#define CW_INLINE inline
|
||||||
|
|
||||||
|
// format string specifiers
|
||||||
|
#define PRIxPTR "lx"
|
||||||
|
|
||||||
|
#define PRIx32 "lx"
|
||||||
|
#define PRIX32 "lX"
|
||||||
|
#define PRId32 "ld"
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
// expand this to nothing
|
// expand this to nothing
|
||||||
#define CW_PASCAL
|
#define CW_PASCAL
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#include "compiler/common.h"
|
#include "compiler/common.h"
|
||||||
|
|
||||||
#define CError_ASSERT(line, cond) if (!(cond)) { CError_Internal(__FILE__, line); }
|
#define CError_ASSERT(line, cond) do { if (!(cond)) { CError_Internal(__FILE__, line); } } while (0)
|
||||||
#define CError_FAIL(line, cond) if (cond) { CError_Internal(__FILE__, line); }
|
#define CError_FAIL(line, cond) do { if (cond) { CError_Internal(__FILE__, line); } } while (0)
|
||||||
#define CError_FATAL(line) do { CError_Internal(__FILE__, line); } while (0)
|
#define CError_FATAL(line) do { CError_Internal(__FILE__, line); } while (0)
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
Loading…
Reference in New Issue