summaryrefslogtreecommitdiff
path: root/compiler_and_linker
diff options
context:
space:
mode:
Diffstat (limited to 'compiler_and_linker')
-rw-r--r--compiler_and_linker/FrontEnd/C/CPrep.c2
-rw-r--r--compiler_and_linker/unsorted/AddPropagation.c2
-rw-r--r--compiler_and_linker/unsorted/Alias.c4
-rw-r--r--compiler_and_linker/unsorted/CError.c10
-rw-r--r--compiler_and_linker/unsorted/CException.c4
-rw-r--r--compiler_and_linker/unsorted/CFunc.c2
-rw-r--r--compiler_and_linker/unsorted/CMachine.c6
-rw-r--r--compiler_and_linker/unsorted/CMangler.c10
-rw-r--r--compiler_and_linker/unsorted/CObjC.c18
-rw-r--r--compiler_and_linker/unsorted/CPreprocess.c6
-rw-r--r--compiler_and_linker/unsorted/CSOM.c2
-rw-r--r--compiler_and_linker/unsorted/CopyPropagation.c2
-rw-r--r--compiler_and_linker/unsorted/InlineAsmRegistersPPC.c12
-rw-r--r--compiler_and_linker/unsorted/IrOptimizer.c4
-rw-r--r--compiler_and_linker/unsorted/IroCSE.c2
-rw-r--r--compiler_and_linker/unsorted/IroDump.c7
-rw-r--r--compiler_and_linker/unsorted/IroEmptyLoop.c2
-rw-r--r--compiler_and_linker/unsorted/IroPointerAnalysis.c2
-rw-r--r--compiler_and_linker/unsorted/IroRangePropagation.c2
-rw-r--r--compiler_and_linker/unsorted/LoadDeletion.c2
-rw-r--r--compiler_and_linker/unsorted/LoopDetection.c6
-rw-r--r--compiler_and_linker/unsorted/ObjGenMachO.c12
-rw-r--r--compiler_and_linker/unsorted/PCodeInfo.c16
-rw-r--r--compiler_and_linker/unsorted/PCodeListing.c12
-rw-r--r--compiler_and_linker/unsorted/RegisterInfo.c10
-rw-r--r--compiler_and_linker/unsorted/uDump.c118
26 files changed, 188 insertions, 87 deletions
diff --git a/compiler_and_linker/FrontEnd/C/CPrep.c b/compiler_and_linker/FrontEnd/C/CPrep.c
index 36ba0f9..8392b44 100644
--- a/compiler_and_linker/FrontEnd/C/CPrep.c
+++ b/compiler_and_linker/FrontEnd/C/CPrep.c
@@ -2418,7 +2418,7 @@ static char *XpandSpecialMacro(Macro *macro) {
} else if (macro == &trgtM) {
return CPrep_CheckTarget() ? "1" : "0";
} else if (macro == &lineM) {
- sprintf(buf, "%ld", linenumber);
+ sprintf(buf, "%" PRId32, linenumber);
do_string:
strptr = aalloc(strlen(buf) + 1);
strcpy(strptr, buf);
diff --git a/compiler_and_linker/unsorted/AddPropagation.c b/compiler_and_linker/unsorted/AddPropagation.c
index f0e2b32..c163dc6 100644
--- a/compiler_and_linker/unsorted/AddPropagation.c
+++ b/compiler_and_linker/unsorted/AddPropagation.c
@@ -254,7 +254,7 @@ static Propagation add_prop = {
&propagateandremoveadd,
"ADD",
"ADDS",
- "a%ld",
+ "a " PRId32,
0
};
diff --git a/compiler_and_linker/unsorted/Alias.c b/compiler_and_linker/unsorted/Alias.c
index d8d883d..b86fb41 100644
--- a/compiler_and_linker/unsorted/Alias.c
+++ b/compiler_and_linker/unsorted/Alias.c
@@ -486,7 +486,7 @@ static Propagation alias_prop = {
&finishpropagatealiases,
"ALIAS",
"ALIASES",
- "A%ld",
+ "A%" PRId32,
1
};
@@ -616,7 +616,7 @@ void gather_alias_info(void) {
if (n_gathered_aliases != n_aliases) {
for (alias = aliases; alias; alias = alias->next) {
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);
for (member = alias->parents; member; member = member->nextParent) {
bitvectorsetbit(member->child->index, alias->vec24);
diff --git a/compiler_and_linker/unsorted/CError.c b/compiler_and_linker/unsorted/CError.c
index 4c7860d..c49e956 100644
--- a/compiler_and_linker/unsorted/CError.c
+++ b/compiler_and_linker/unsorted/CError.c
@@ -212,9 +212,9 @@ void CError_BufferAppendTemplDepType(CErrorBuffer *eb, TypeTemplDep *type) {
switch (type->dtype) {
case TEMPLDEP_ARGUMENT:
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
- sprintf(buf, "T%ld", type->u.pid.index);
+ sprintf(buf, "T%" PRId32, type->u.pid.index);
CError_BufferAppendString(eb, buf);
break;
case TEMPLDEP_QUALNAME:
@@ -465,7 +465,7 @@ void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
while (ty->type == TYPEARRAY) {
CError_BufferAppendChar(eb, '[');
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_BufferAppendChar(eb, ']');
@@ -480,7 +480,7 @@ void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
CError_BufferAppendString(eb, "T");
return;
case TYPEBITFIELD:
- sprintf(buf, "bitfield:%ld", TYPE_BITFIELD(ty)->unkB);
+ sprintf(buf, "bitfield:%" PRId32, TYPE_BITFIELD(ty)->unkB);
CError_BufferAppendString(eb, buf);
return;
default:
@@ -777,7 +777,7 @@ void CError_ErrorMessageVA(int code, const char *format, va_list list, Boolean f
p += 2;
continue;
case 'i':
- sprintf(unmangleBuf, "%ld", va_arg(list, SInt32));
+ sprintf(unmangleBuf, "%" PRId32, va_arg(list, SInt32));
CError_BufferAppendString(&eb, unmangleBuf);
p += 2;
continue;
diff --git a/compiler_and_linker/unsorted/CException.c b/compiler_and_linker/unsorted/CException.c
index c398afb..9bc9d83 100644
--- a/compiler_and_linker/unsorted/CException.c
+++ b/compiler_and_linker/unsorted/CException.c
@@ -659,7 +659,7 @@ static void CExcept_MangleClassName(TypeClass *tclass) {
if (!nspace->is_global && !nspace->is_templ && !nspace->name) {
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);
break;
}
@@ -734,7 +734,7 @@ static void CExcept_MangleClass(TypeClass *tclass) {
AppendGListByte(&name_mangle_list, '!');
if (bcl->offset) {
- sprintf(buf, "%ld!", bcl->offset);
+ sprintf(buf, "%" PRId32 "!", bcl->offset);
AppendGListName(&name_mangle_list, buf);
} else {
AppendGListByte(&name_mangle_list, '!');
diff --git a/compiler_and_linker/unsorted/CFunc.c b/compiler_and_linker/unsorted/CFunc.c
index 2e10bad..63a2493 100644
--- a/compiler_and_linker/unsorted/CFunc.c
+++ b/compiler_and_linker/unsorted/CFunc.c
@@ -953,7 +953,7 @@ static void CFunc_NameLocalStaticDataObject(Object *obj, char *str) {
if (!(cscope_currentfunc && (cscope_currentfunc->qual & Q_INLINE)) || CParser_HasInternalLinkage(cscope_currentfunc)) {
obj->name = CParser_AppendUniqueName(str);
} else {
- sprintf(buf, "$localstatic%ld$", cfunc_staticvarcount++);
+ sprintf(buf, "$localstatic%" PRId32 "$", cfunc_staticvarcount++);
name = CMangler_GetLinkName(cscope_currentfunc);
name = CParser_NameConcat(buf, name->name);
name = CParser_NameConcat(str, name->name);
diff --git a/compiler_and_linker/unsorted/CMachine.c b/compiler_and_linker/unsorted/CMachine.c
index 5849444..59344d7 100644
--- a/compiler_and_linker/unsorted/CMachine.c
+++ b/compiler_and_linker/unsorted/CMachine.c
@@ -24,9 +24,9 @@ TypeIntegral stunsignedlong = {TYPEINT, 4, IT_ULONG};
TypeIntegral stsignedlonglong = {TYPEINT, 8, IT_LONGLONG};
TypeIntegral stunsignedlonglong = {TYPEINT, 8, IT_ULONGLONG};
TypeIntegral stfloat = {TYPEFLOAT, 4, IT_FLOAT};
-TypeIntegral stshortdouble = {TYPEINT, 8, IT_SHORTDOUBLE};
-TypeIntegral stdouble = {TYPEINT, 8, IT_DOUBLE};
-TypeIntegral stlongdouble = {TYPEINT, 8, IT_LONGDOUBLE};
+TypeIntegral stshortdouble = {TYPEFLOAT, 8, IT_SHORTDOUBLE};
+TypeIntegral stdouble = {TYPEFLOAT, 8, IT_DOUBLE};
+TypeIntegral stlongdouble = {TYPEFLOAT, 8, IT_LONGDOUBLE};
static StructMember stVUC_unsignedchar15 = {NULL, (Type *) &stunsignedchar, NULL, 15, 0};
static StructMember stVUC_unsignedchar14 = {&stVUC_unsignedchar15, (Type *) &stunsignedchar, NULL, 14, 0};
diff --git a/compiler_and_linker/unsorted/CMangler.c b/compiler_and_linker/unsorted/CMangler.c
index c1b9618..f597d44 100644
--- a/compiler_and_linker/unsorted/CMangler.c
+++ b/compiler_and_linker/unsorted/CMangler.c
@@ -181,11 +181,11 @@ HashNameNode *CMangler_ThunkName(Object *vfunc, SInt32 this_delta, SInt32 return
name_mangle_list.size = 0;
if (return_delta == 0) {
if (ctoroffset < 0)
- sprintf(buf, "_@%ld@", -this_delta);
+ sprintf(buf, "_@%" PRId32 "@", -this_delta);
else
- sprintf(buf, "_@%ld@%ld@", -this_delta, ctoroffset);
+ sprintf(buf, "_@%" PRId32 "@%" PRId32 "@", -this_delta, ctoroffset);
} 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);
AppendGListID(&name_mangle_list, linkname->name + 1);
@@ -414,7 +414,7 @@ static void CMangler_MangleTypeAppend(Type *type, UInt32 qual) {
case TYPEARRAY:
AppendGListByte(&name_mangle_list, 'A');
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);
} else {
AppendGListByte(&name_mangle_list, '0');
@@ -516,7 +516,7 @@ static void CMangler_MangleArgs(FuncArg *args) {
if (args->type->type == TYPEPOINTER) {
ptr = *TYPE_POINTER(args->type);
ptr.qual &= ~(Q_CONST | Q_VOLATILE);
- CMangler_MangleTypeAppend((Type *) &ptr, args->qual);
+ CMangler_MangleTypeAppend(TYPE(&ptr), args->qual);
} else {
CMangler_MangleTypeAppend(args->type, 0);
}
diff --git a/compiler_and_linker/unsorted/CObjC.c b/compiler_and_linker/unsorted/CObjC.c
index 7685a33..7d761c5 100644
--- a/compiler_and_linker/unsorted/CObjC.c
+++ b/compiler_and_linker/unsorted/CObjC.c
@@ -312,7 +312,7 @@ static Object *CObjC_GetSelectorObject(ObjCSelector *sel) {
if (!sel->selobject) {
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->name = GetHashNameNodeExport(str);
@@ -348,7 +348,7 @@ static Object *CObjC_GetClassRefObject(TypeClass *tclass) {
if (!tclass->objcinfo->classrefobj) {
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->name = GetHashNameNodeExport(str);
@@ -1407,17 +1407,17 @@ static void CObjC_EncodeTypeMethod(ObjCMethod *meth, Boolean flag) {
else
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);
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);
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);
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);
- 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);
}
}
@@ -1529,7 +1529,7 @@ static void CObjC_EncodeType(Type *type, UInt32 qual, Boolean flag) {
case TYPEARRAY:
AppendGListByte(&name_mangle_list, '[');
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);
} else {
AppendGListByte(&name_mangle_list, '0');
@@ -1540,7 +1540,7 @@ static void CObjC_EncodeType(Type *type, UInt32 qual, Boolean flag) {
case TYPEBITFIELD:
AppendGListByte(&name_mangle_list, 'b');
- sprintf(buf, "%ld", TYPE_BITFIELD(type)->unkB);
+ sprintf(buf, "%" PRId32, TYPE_BITFIELD(type)->unkB);
AppendGListName(&name_mangle_list, buf);
return;
@@ -3003,7 +3003,7 @@ ENode *CObjC_ParseAtExpression(void) {
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->type = TYPE(strclass);
diff --git a/compiler_and_linker/unsorted/CPreprocess.c b/compiler_and_linker/unsorted/CPreprocess.c
index 116d5dc..4e6b3c0 100644
--- a/compiler_and_linker/unsorted/CPreprocess.c
+++ b/compiler_and_linker/unsorted/CPreprocess.c
@@ -24,9 +24,9 @@ void CPrep_PreprocessDumpFileInfo(Boolean flag) {
AppendGListName(&pplist, "\r");
if (copts.line_prepdump)
- size = sprintf(linebuf, "#line %ld\t\"", linenumber);
+ size = sprintf(linebuf, "#line % " PRId32 "\t\"", linenumber);
else
- size = sprintf(linebuf, "/* #line %ld\t\"", linenumber);
+ size = sprintf(linebuf, "/* #line % " PRId32 "\t\"", linenumber);
AppendGListData(&pplist, linebuf, size);
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);
if (copts.line_prepdump && flag)
diff --git a/compiler_and_linker/unsorted/CSOM.c b/compiler_and_linker/unsorted/CSOM.c
index 816c749..f0b1537 100644
--- a/compiler_and_linker/unsorted/CSOM.c
+++ b/compiler_and_linker/unsorted/CSOM.c
@@ -1929,7 +1929,7 @@ static ENode *CSOM_SOMGlueCall(TypeClass *tclass, SInt32 offset, Object *object)
ptr = CSOM_AppendString(ptr, numberbuf);
ptr = CSOM_AppendString(ptr, tclass->sominfo->classdataobject->name->name);
*(ptr++) = '_';
- sprintf(numberbuf, "%ld", offset);
+ sprintf(numberbuf, "%" PRId32, offset);
ptr = CSOM_AppendString(ptr, numberbuf);
*ptr = 0;
diff --git a/compiler_and_linker/unsorted/CopyPropagation.c b/compiler_and_linker/unsorted/CopyPropagation.c
index af451a0..6817d0d 100644
--- a/compiler_and_linker/unsorted/CopyPropagation.c
+++ b/compiler_and_linker/unsorted/CopyPropagation.c
@@ -459,7 +459,7 @@ static Propagation copy_prop = {
&propagateandremovecopy,
"COPY",
"COPIES",
- "c%ld",
+ "c%" PRId32,
0
};
diff --git a/compiler_and_linker/unsorted/InlineAsmRegistersPPC.c b/compiler_and_linker/unsorted/InlineAsmRegistersPPC.c
index 4fb77ba..c85b216 100644
--- a/compiler_and_linker/unsorted/InlineAsmRegistersPPC.c
+++ b/compiler_and_linker/unsorted/InlineAsmRegistersPPC.c
@@ -808,13 +808,13 @@ void InlineAsm_InitializeRegistersPPC(void) {
sprintf(buf, register_class_format[asmreg->rclass], asmreg->num);
break;
case RegClass_6:
- sprintf(buf, "crbit_%ld", asmreg->num);
+ sprintf(buf, "crbit_%" PRId32, asmreg->num);
break;
case RegClass_DCR:
- sprintf(buf, "DCR%ld", asmreg->num);
+ sprintf(buf, "DCR%" PRId32, asmreg->num);
break;
default:
- sprintf(buf, "{?}%ld", asmreg->num);
+ sprintf(buf, "{?}%" PRId32, asmreg->num);
break;
}
PPCError_Warning(100, obj->name->name, buf);
@@ -832,13 +832,13 @@ void InlineAsm_InitializeRegistersPPC(void) {
sprintf(buf, register_class_format[asmreg->rclass], asmreg->num);
break;
case RegClass_6:
- sprintf(buf, "crbit_%ld", asmreg->num);
+ sprintf(buf, "crbit_%" PRId32, asmreg->num);
break;
case RegClass_DCR:
- sprintf(buf, "DCR%ld", asmreg->num);
+ sprintf(buf, "DCR%" PRId32, asmreg->num);
break;
default:
- sprintf(buf, "{?}%ld", asmreg->num);
+ sprintf(buf, "{?}%" PRId32, asmreg->num);
break;
}
PPCError_Warning(100, obj->name->name, buf);
diff --git a/compiler_and_linker/unsorted/IrOptimizer.c b/compiler_and_linker/unsorted/IrOptimizer.c
index ae38df0..38c415e 100644
--- a/compiler_and_linker/unsorted/IrOptimizer.c
+++ b/compiler_and_linker/unsorted/IrOptimizer.c
@@ -121,6 +121,10 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) {
CError_ASSERT(234, stIsSetup);
+#ifdef CW_PATCH_DEBUG
+ IRO_Log = 1;
+#endif
+
DisableDueToAsm = 0;
FunctionName = func;
DoScalarize = 1;
diff --git a/compiler_and_linker/unsorted/IroCSE.c b/compiler_and_linker/unsorted/IroCSE.c
index 2311786..5fa9849 100644
--- a/compiler_and_linker/unsorted/IroCSE.c
+++ b/compiler_and_linker/unsorted/IroCSE.c
@@ -886,7 +886,7 @@ static void MoveCommonSub(IROExpr *expr) {
i1 = sz1;
i2 = sz2;
- while (i1 && i2 && array1[sz1 - 1] == array2[sz2 - 1]) {
+ while (i1 && i2 && array1[i1 - 1] == array2[i2 - 1]) {
i1--;
i2--;
}
diff --git a/compiler_and_linker/unsorted/IroDump.c b/compiler_and_linker/unsorted/IroDump.c
index 22f5041..da8f676 100644
--- a/compiler_and_linker/unsorted/IroDump.c
+++ b/compiler_and_linker/unsorted/IroDump.c
@@ -295,6 +295,9 @@ void IRO_DumpBits(char *name, BitVector *bv) {
}
void IRO_DumpAfterPhase(char *str, Boolean flag) {
+#ifdef CW_PATCH_DEBUG
+ flag = 1;
+#endif
if (flag) {
IRO_Dump("Dumping function %s after %s \n", FunctionName ? FunctionName->name->name : "Init-code", str);
IRO_Dump("--------------------------------------------------------------------------------\n");
@@ -441,6 +444,10 @@ void IRO_DumpExprs(void) {
}
void IRO_SetupDump(void) {
+#ifdef CW_PATCH_DEBUG
+ IRO_Log = 1;
+#endif
+
if (IRO_Log) {
if ((DumpFile = fopen("OPT.LOG", "wt")) == NULL)
IRO_Log = 0;
diff --git a/compiler_and_linker/unsorted/IroEmptyLoop.c b/compiler_and_linker/unsorted/IroEmptyLoop.c
index 780fb9b..1e319ab 100644
--- a/compiler_and_linker/unsorted/IroEmptyLoop.c
+++ b/compiler_and_linker/unsorted/IroEmptyLoop.c
@@ -149,7 +149,7 @@ static Boolean EmptyLoop(IRONode *fnode) {
}
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);
r21->last->type = IROLinearNop;
type20 = loop->induction->nd->rtype;
diff --git a/compiler_and_linker/unsorted/IroPointerAnalysis.c b/compiler_and_linker/unsorted/IroPointerAnalysis.c
index 0fb2498..45e4fe5 100644
--- a/compiler_and_linker/unsorted/IroPointerAnalysis.c
+++ b/compiler_and_linker/unsorted/IroPointerAnalysis.c
@@ -5312,7 +5312,7 @@ static void ParseLocationSet(LocationSet *loc, Type *rtype, Object *proc, Create
ep = CreateExtendedParam(NULL, NULL, obj, &epFlag);
} else {
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);
failed = 1;
}
diff --git a/compiler_and_linker/unsorted/IroRangePropagation.c b/compiler_and_linker/unsorted/IroRangePropagation.c
index 8fbc932..d15ef86 100644
--- a/compiler_and_linker/unsorted/IroRangePropagation.c
+++ b/compiler_and_linker/unsorted/IroRangePropagation.c
@@ -399,7 +399,7 @@ static Boolean ERfoldExpr(IROLinear *nd) {
EREandHasNoUse(range, val) &&
!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,
CInt64_GetULong(&range->upper),
CInt64_GetULong(&range->upper),
diff --git a/compiler_and_linker/unsorted/LoadDeletion.c b/compiler_and_linker/unsorted/LoadDeletion.c
index 8cc0f28..df6c8c3 100644
--- a/compiler_and_linker/unsorted/LoadDeletion.c
+++ b/compiler_and_linker/unsorted/LoadDeletion.c
@@ -37,7 +37,7 @@ static Propagation load_immediate_prop = {
&deleteload,
"LOAD IMMEDIATE",
"LOAD_IMMEDIATES",
- "l%ld",
+ "l%" PRId32,
0
};
diff --git a/compiler_and_linker/unsorted/LoopDetection.c b/compiler_and_linker/unsorted/LoopDetection.c
index f1513e0..6bb2d51 100644
--- a/compiler_and_linker/unsorted/LoopDetection.c
+++ b/compiler_and_linker/unsorted/LoopDetection.c
@@ -281,11 +281,11 @@ void insertpreheaderblock(Loop *loop) {
} else if (pcode27->op == PC_BCTR) {
if (pcode27->argCount > 1 && pcode27->args[1].kind == PCOp_MEMORY) {
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;
for (i = 0; i < obj->u.data.u.switchtable.size; i++) {
- if (array[i]->block == block28)
- array[i] = preheader->labels;
+ if (((PCodeLabel *) CTool_ResolveIndexToPointer(array[i]))->block == block28)
+ array[i] = CTool_CreateIndexFromPointer(preheader->labels);
}
} else {
CodeLabelList *cll;
diff --git a/compiler_and_linker/unsorted/ObjGenMachO.c b/compiler_and_linker/unsorted/ObjGenMachO.c
index 961d5bb..ee9bf77 100644
--- a/compiler_and_linker/unsorted/ObjGenMachO.c
+++ b/compiler_and_linker/unsorted/ObjGenMachO.c
@@ -74,7 +74,7 @@ static DefSectionInfo def_section_info[] = {
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_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_COMMON_VARS, SECT_COMMON_VARS, NULL, NULL, 0, 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) {
if (scan->somevalue)
- *((SInt32 *) (data + scan->offset)) = scan->somevalue;
+ *((SInt32 *) (data + scan->offset)) = CTool_EndianConvertWord32(scan->somevalue);
}
if (sectionID == SECT_8BYTE_LITERALS)
@@ -1583,8 +1583,8 @@ void ObjGen_DeclareExceptionTables(Object *object, SInt32 codesize, char *data,
flag22 = 0;
if (len == 8) {
- if ((*((UInt16 *) data) & 8) >> 3) {
- *((UInt16 *) data) &= ~8;
+ if (CTool_EndianConvertWord16(*((UInt16 *) data) & 8) >> 3) {
+ *((UInt16 *) data) = CTool_EndianConvertWord16(CTool_EndianConvertWord16(*((UInt16 *) data)) & ~8);
len = 4;
}
}
@@ -1644,8 +1644,8 @@ void ObjGen_DeclareExceptionTables(Object *object, SInt32 codesize, char *data,
RelocIndex++;
stuff[0] = 0;
- stuff[1] = ((len == 4) << 31) | (codesize & 0x7FFFFFFF);
- stuff[2] = (len == 4) ? *((UInt32 *) data) : 0;
+ stuff[1] = CTool_EndianConvertWord32(((len == 4) << 31) | (codesize & 0x7FFFFFFF));
+ stuff[2] = CTool_EndianConvertWord32((len == 4) ? CTool_EndianConvertWord32(*((UInt32 *) data)) : 0);
AppendGListData(gl, stuff, sizeof(stuff));
ObjGen_RelocateObj(section, offset, object, MW_RELOC_9);
diff --git a/compiler_and_linker/unsorted/PCodeInfo.c b/compiler_and_linker/unsorted/PCodeInfo.c
index 8f863f7..b2e2385 100644
--- a/compiler_and_linker/unsorted/PCodeInfo.c
+++ b/compiler_and_linker/unsorted/PCodeInfo.c
@@ -663,7 +663,7 @@ int expectandformatoperand(PCodeArg *operand, PCOpKind expectedKind, char a3, in
tmp = sprintf(buf, "%u", operand->data.imm.value);
break;
default:
- tmp = sprintf(buf, "%ld", operand->data.imm.value);
+ tmp = sprintf(buf, "%" PRId32, operand->data.imm.value);
break;
}
errorlen += tmp;
@@ -754,9 +754,9 @@ int expectandformatoperand(PCodeArg *operand, PCOpKind expectedKind, char a3, in
if (!operand->data.label.label->block)
tmp = sprintf(buf, "B<unknown>");
else
- tmp = sprintf(buf, "B%ld", operand->data.label.label->block->blockIndex);
+ tmp = sprintf(buf, "B%" PRId32, operand->data.label.label->block->blockIndex);
} else {
- tmp = sprintf(buf, "%.8lX", operand->data.label.label->block->codeOffset);
+ tmp = sprintf(buf, "%.8" PRIX32, operand->data.label.label->block->codeOffset);
}
errorlen += tmp;
break;
@@ -765,14 +765,14 @@ int expectandformatoperand(PCodeArg *operand, PCOpKind expectedKind, char a3, in
b_null = !operand->data.labeldiff.labelB->block;
if (operand->data.labeldiff.labelA->block == 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
- 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 {
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
- 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;
break;
@@ -1009,7 +1009,7 @@ void formatoperands(PCode *pcode, char *buf, int showBasicBlocks) {
case 'l':
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) {
buf += expectandformatoperand(pa, PCOp_LABELDIFF, 0, -1, buf);
} else if (pa->kind == PCOp_LABEL) {
diff --git a/compiler_and_linker/unsorted/PCodeListing.c b/compiler_and_linker/unsorted/PCodeListing.c
index c4425a7..0367250 100644
--- a/compiler_and_linker/unsorted/PCodeListing.c
+++ b/compiler_and_linker/unsorted/PCodeListing.c
@@ -57,26 +57,26 @@ static void pclistblock(PCodeBlock *block, char *format, UInt32 vecSize) {
char buf[500];
WeirdOperand dummyArg;
- fprintf(pcfile, ":{%4.4x}::::::::::::::::::::::::::::::::::::::::LOOPWEIGHT=%ld\n", block->flags, block->loopWeight);
- fprintf(pcfile, "B%ld: ", block->blockIndex);
+ fprintf(pcfile, ":{%4.4x}::::::::::::::::::::::::::::::::::::::::LOOPWEIGHT=%" PRId32 "\n", block->flags, block->loopWeight);
+ fprintf(pcfile, "B%" PRId32 ": ", block->blockIndex);
fprintf(pcfile, "Successors = { ");
for (link = block->successors; link; link = link->nextLink) {
if (link->block)
- fprintf(pcfile, "B%ld ", link->block->blockIndex);
+ fprintf(pcfile, "B%" PRId32 " ", link->block->blockIndex);
}
fprintf(pcfile, "} ");
fprintf(pcfile, "Predecessors = { ");
for (link = block->predecessors; link; link = link->nextLink) {
if (link->block)
- fprintf(pcfile, "B%ld ", link->block->blockIndex);
+ fprintf(pcfile, "B%" PRId32 " ", link->block->blockIndex);
}
if (block->labels) {
fprintf(pcfile, "} Labels = { ");
for (label = block->labels; label; label = label->nextLabel)
- fprintf(pcfile, "L%ld ", label->index);
+ fprintf(pcfile, "L%" PRId32 " ", label->index);
}
fprintf(pcfile, "}\n\n");
@@ -115,7 +115,7 @@ static void pclistblock(PCodeBlock *block, char *format, UInt32 vecSize) {
fprintf(
pcfile,
- " %.8lX %.8lX %4ld %-7s%c %s\n",
+ " %.8" PRIx32 " %.8" PRIx32 " %4" PRId32 " %-7s%c %s\n",
offset, opcode, latency,
opcodeinfo[instr->op].name, chr, buf
);
diff --git a/compiler_and_linker/unsorted/RegisterInfo.c b/compiler_and_linker/unsorted/RegisterInfo.c
index 13c519d..9365d11 100644
--- a/compiler_and_linker/unsorted/RegisterInfo.c
+++ b/compiler_and_linker/unsorted/RegisterInfo.c
@@ -106,15 +106,15 @@ static int first_nonvolatile_reg(RegClass rclass) {
void setup_diagnostic_reg_strings(void) {
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_format[RegClass_CRFIELD] = "cr%ld";
+ register_class_format[RegClass_CRFIELD] = "cr%" PRId32;
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_format[RegClass_FPR] = "f%ld";
+ register_class_format[RegClass_FPR] = "f%" PRId32;
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) {
diff --git a/compiler_and_linker/unsorted/uDump.c b/compiler_and_linker/unsorted/uDump.c
index 86a6e68..77ac238 100644
--- a/compiler_and_linker/unsorted/uDump.c
+++ b/compiler_and_linker/unsorted/uDump.c
@@ -3,6 +3,7 @@
#include "compiler/CInt64.h"
#include "compiler/CMachine.h"
#include "compiler/CMangler.h"
+#include "compiler/CParser.h"
#include "compiler/Exceptions.h"
#include "compiler/Switch.h"
#include "compiler/enode.h"
@@ -67,9 +68,92 @@ void SetupDumpIR(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) {
+#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) {
@@ -169,10 +253,15 @@ void DumpExpression(ENode *expr, int indent) {
switch (expr->type) {
case EINTCONST:
- if (expr->rtype->size > 4)
- fprintf(outfile, "[0x%.8lX%.8lX]", expr->data.intval.hi, expr->data.intval.lo);
- else
- fprintf(outfile, "[%ld]", expr->data.intval.lo);
+ if (expr->rtype->size > 4) {
+ fprintf(outfile,
+ "[0x%.8" PRIX32 "%.8" PRIX32 "]",
+ expr->data.intval.hi, expr->data.intval.lo);
+ } else {
+ fprintf(outfile,
+ "[%" PRId32 "]",
+ expr->data.intval.lo);
+ }
DumpType(expr->rtype);
fprintf(outfile, "\r");
return;
@@ -199,7 +288,8 @@ void DumpExpression(ENode *expr, int indent) {
return;
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[1],
expr->data.vector128val.ul[2],
@@ -278,7 +368,7 @@ void DumpExpression(ENode *expr, int indent) {
break;
case ENULLCHECK:
- fprintf(outfile, " unique [%ld]", expr->data.nullcheck.precompid);
+ fprintf(outfile, " unique [%" PRId32 "]", expr->data.nullcheck.precompid);
DumpType(expr->rtype);
fprintf(outfile, "\r");
DumpExpression(expr->data.nullcheck.nullcheckexpr, indent + 1);
@@ -287,7 +377,7 @@ void DumpExpression(ENode *expr, int indent) {
break;
case EPRECOMP:
- fprintf(outfile, " unique [%ld]", expr->data.precompid);
+ fprintf(outfile, " unique [%" PRId32 "]", expr->data.precompid);
DumpType(expr->rtype);
fprintf(outfile, "\r");
return;
@@ -317,7 +407,7 @@ void DumpExpression(ENode *expr, int indent) {
return;
case EDEFINE:
- fprintf(outfile, "[%.8lX]", expr);
+ fprintf(outfile, "[%.8" PRIX32 "]", expr);
DumpType(expr->rtype);
fputs("\r", outfile);
expr = expr->data.monadic;
@@ -325,7 +415,7 @@ void DumpExpression(ENode *expr, int indent) {
break;
case EREUSE:
- fprintf(outfile, "[%.8lX]", expr->data.monadic);
+ fprintf(outfile, "[%.8" PRIX32 "]", expr->data.monadic);
DumpType(expr->rtype);
fputs("\r", outfile);
return;
@@ -535,7 +625,7 @@ void DumpStack(ExceptionAction *act) {
break;
case EAT_DESTROYLOCALOFFSET:
fprintf(outfile,
- "EAT_DESTROYLOCALOFFSET %s(&%s+%ld)%s",
+ "EAT_DESTROYLOCALOFFSET %s(&%s+%" PRId32 ")%s",
CMangler_GetLinkName(act->data.destroy_local_offset.dtor)->name,
act->data.destroy_local_offset.local->name->name,
act->data.destroy_local_offset.offset,
@@ -553,14 +643,14 @@ void DumpStack(ExceptionAction *act) {
break;
case EAT_DESTROYBASE:
fprintf(outfile,
- "EAT_DESTROYBASE %s(this+%ld)%s",
+ "EAT_DESTROYBASE %s(this+%" PRId32 ")%s",
CMangler_GetLinkName(act->data.destroy_base.dtor)->name,
act->data.destroy_base.offset,
"\r");
break;
case EAT_DESTROYMEMBER:
fprintf(outfile,
- "EAT_DESTROYMEMBER %s(%s+%ld)%s",
+ "EAT_DESTROYMEMBER %s(%s+%" PRId32 ")%s",
CMangler_GetLinkName(act->data.destroy_member.dtor)->name,
act->data.destroy_member.objectptr->name->name,
act->data.destroy_member.offset,
@@ -568,7 +658,7 @@ void DumpStack(ExceptionAction *act) {
break;
case EAT_DESTROYMEMBERCOND:
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,
CMangler_GetLinkName(act->data.destroy_member_cond.dtor)->name,
act->data.destroy_member_cond.offset,
@@ -576,7 +666,7 @@ void DumpStack(ExceptionAction *act) {
break;
case EAT_DESTROYMEMBERARRAY:
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,
act->data.destroy_member_array.offset,
act->data.destroy_member_array.elements,