diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-01-11 22:29:53 +0000 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-01-11 22:29:53 +0000 |
commit | 0bec4f557a96e1a40437cf5af20cc78a5eec8a63 (patch) | |
tree | c1e05ec804c43aa5a8f5f21b0ed02d0587d29563 /compiler_and_linker | |
parent | aec1b8dddc68ecb8288ec6132932e4c7b4bca09f (diff) | |
download | MWCC-0bec4f557a96e1a40437cf5af20cc78a5eec8a63.tar.gz MWCC-0bec4f557a96e1a40437cf5af20cc78a5eec8a63.zip |
getting closer
Diffstat (limited to '')
73 files changed, 9161 insertions, 2052 deletions
diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c index 31b718f..db6165c 100644 --- a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c @@ -21,16 +21,16 @@ int TargetSetWarningFlags(short val, Boolean set) { case 'Uv': pWarningC.warn_unusedvar = set; break; case 'Ua': pWarningC.warn_unusedarg = set; break; case 'Ec': pWarningC.warn_extracomma = set; break; - case 'Pe': pWarningC.pedantic = set; break; + case 'Pd': pWarningC.pedantic = set; break; case 'Hv': pWarningC.warn_hidevirtual = set; break; case 'Ic': pWarningC.warn_implicitconv = set; break; case 'Ni': pWarningC.warn_notinlined = set; break; case 'Sc': pWarningC.warn_structclass = set; break; - case 'Pa': pExtraWarningC.warn_padding = set ? 1 : 2; break; - case 'Nu': pExtraWarningC.warn_resultnotused = set ? 1 : 2; break; - case 'Se': pExtraWarningC.warn_no_side_effect = set ? 1 : 2; break; - case 'PI': pExtraWarningC.warn_ptr_int_conv = set ? 1 : 2; break; - case 'La': pExtraWarningC.warn_largeargs = set ? 1 : 2; break; + case 'Pa': pExtraWarningC.warn_padding = set ? PR_ON : PR_OFF; break; + case 'Nu': pExtraWarningC.warn_resultnotused = set ? PR_ON : PR_OFF; break; + case 'Se': pExtraWarningC.warn_no_side_effect = set ? PR_ON : PR_OFF; break; + case 'PI': pExtraWarningC.warn_ptr_int_conv = set ? PR_ON : PR_OFF; break; + case 'La': pExtraWarningC.warn_largeargs = set ? PR_ON : PR_OFF; break; case 'We': pWarningC.warningerrors = set; break; case 'Cp': pFrontEndC.checkprotos = set; break; default: return 0; @@ -64,15 +64,15 @@ void TargetDisplayWarningOptions(Handle txt) { HPrintF(txt, "\t- 'inline' not performed\n"); if (pWarningC.warn_structclass) HPrintF(txt, "\t- struct/class conflict\n"); - if (pExtraWarningC.warn_largeargs) + if (pExtraWarningC.warn_largeargs == 1) HPrintF(txt, "\t- large args passed to unprototyped functions\n"); - if (pExtraWarningC.warn_padding) + if (pExtraWarningC.warn_padding == 1) HPrintF(txt, "\t- padding added between struct members\n"); - if (pExtraWarningC.warn_resultnotused) + if (pExtraWarningC.warn_resultnotused == 1) HPrintF(txt, "\t- result of non-void function call not used\n"); - if (pExtraWarningC.warn_no_side_effect) + if (pExtraWarningC.warn_no_side_effect == 1) HPrintF(txt, "\t- use of expressions as statements without side effects\n"); - if (pExtraWarningC.warn_ptr_int_conv) + if (pExtraWarningC.warn_ptr_int_conv == 1) HPrintF(txt, "\t- implicit integer/pointer conversions\n"); if (pFrontEndC.checkprotos) HPrintF(txt, "\t- checking prototypes\n"); diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c index fc6206c..5965d11 100644 --- a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c @@ -85,7 +85,7 @@ CWPLUGIN_ENTRY (CWPlugin_GetPanelList)(const CWPanelList **panelList) { } static CWPLUGIN_ENTRY (CmdLine_GetObjectFlags)(const CWObjectFlags **objectFlags) { - static const CWObjectFlags sFlags = { + static const CWObjectFlags myFlags = { 2, 0x80000000, ".o", @@ -101,7 +101,7 @@ static CWPLUGIN_ENTRY (CmdLine_GetObjectFlags)(const CWObjectFlags **objectFlags CWFOURCHAR('C','W','I','E'), CWFOURCHAR('T','E','X','T') }; - *objectFlags = &sFlags; + *objectFlags = &myFlags; return 0; } @@ -361,8 +361,7 @@ static const char *STR10000[] = { "possible unwanted ';'", "possible unwanted assignment", "possible unwanted compare", - "illegal implicit conversion from '%t' to", - "'%t'", + "illegal implicit conversion from '%t' to\n'%t'", "local data >32k", "illegal jump past initializer", "illegal ctor initializer", @@ -370,12 +369,10 @@ static const char *STR10000[] = { "cannot construct %t's direct member '%u'", "#if nesting overflow", "illegal empty declaration", - "illegal implicit enum conversion from '%t' to", - "'%t'", + "illegal implicit enum conversion from '%t' to\n'%t'", "illegal use of #pragma parameter", "virtual functions cannot be pascal functions", - "illegal implicit const/volatile pointer conversion from '%t' to", - "'%t'", + "illegal implicit const/volatile pointer conversion from '%t' to\n'%t'", "illegal use of non-static member", "illegal precompiled header version", "illegal precompiled header compiler flags or target", @@ -399,23 +396,14 @@ static const char *STR10000[] = { "illegal constructor/destructor declaration", "'catch' expected", "#include nesting overflow", - "cannot convert", - "'%t' to", - "'%t'", - "type mismatch", - "'%t' and", - "'%t'", + "cannot convert\n'%t' to\n'%t'", + "type mismatch\n'%t' and\n'%t'", "class type expected", - "illegal explicit conversion from '%t' to", - "'%t'", + "illegal explicit conversion from '%t' to\n'%t'", "function call '*' does not match", - "identifier '%u' redeclared", - "was declared as: '%t'", - "now declared as: '%t'", + "identifier '%u' redeclared\nwas declared as: '%t'\nnow declared as: '%t'", "cannot throw class with ambiguous base class ('%u')", - "class '%t': '%o' has more than one final overrider:", - "'%o'", - "and '%o'", + "class '%t': '%o' has more than one final overrider:\n'%o'\nand '%o'", "exception handling option is disabled", "cannot delete pointer to const", "cannot destroy const object", @@ -469,9 +457,7 @@ static const char *STR10000[] = { "illegal use of 'super'", "illegal message receiver", "receiver cannot handle this message", - "ambiguous message selector", - "used: '%m'", - "also had: '%m'", + "ambiguous message selector\nused: '%m'\nalso had: '%m'", "unknown message selector", "illegal use of Objective-C object", "protocol '%u' redefined", diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c index b62d413..a0cf8c7 100644 --- a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c @@ -94,7 +94,7 @@ static CWPLUGIN_ENTRY (PPCLibImport_GetFileTypeMappings)(const OSFileTypeMapping } static CWPLUGIN_ENTRY (PPCLibImport_GetObjectFlags)(const CWObjectFlags **objectFlags) { - static const CWObjectFlags sFlags = { + static const CWObjectFlags myFlags = { 2, 0, NULL, @@ -110,7 +110,7 @@ static CWPLUGIN_ENTRY (PPCLibImport_GetObjectFlags)(const CWObjectFlags **object 0, 0 }; - *objectFlags = &sFlags; + *objectFlags = &myFlags; return 0; } diff --git a/compiler_and_linker/FrontEnd/C/CPrep.c b/compiler_and_linker/FrontEnd/C/CPrep.c index f38c504..80472b1 100644 --- a/compiler_and_linker/FrontEnd/C/CPrep.c +++ b/compiler_and_linker/FrontEnd/C/CPrep.c @@ -1,16 +1,25 @@ -#include "compiler.h" +#include "compiler/CPrep.h" +#include "compiler/CBrowse.h" +#include "compiler/CCompiler.h" #include "compiler/CError.h" +#include "compiler/CException.h" #include "compiler/CInt64.h" -#include "compiler/objects.h" -#include "compiler/scopes.h" -#include "compiler/tokens.h" -#include "cos.h" #include "compiler/CMachine.h" #include "compiler/CParser.h" -#include "compiler/CPrep.h" +#include "compiler/CPrec.h" +#include "compiler/CPreprocess.h" #include "compiler/CPrepTokenizer.h" #include "compiler/CScope.h" +#include "compiler/CSOM.h" #include "compiler/CodeGen.h" +#include "compiler/CompilerTools.h" +#include "compiler/FuncLevelAsmPPC.h" +#include "compiler/IroPointerAnalysis.h" +#include "compiler/ObjGenMachO.h" +#include "compiler/objects.h" +#include "compiler/scopes.h" +#include "compiler/tokens.h" +#include "cos.h" #ifdef __MWERKS__ #pragma options align=mac68k @@ -31,17 +40,16 @@ enum { IfState_1 = 1, IfState_2 = 2, IfState_3 = 3, - IfState_4 = 4, - IfState_5 = 5 + IfState_4 = 4 }; // forward declarations -static PrepValue CPrep_ParseCond(); -static PrepValue CPrep_ParseBinary(PrepValue *rhs, short op); +static PrepValue CPrep_ParseCond(void); +static PrepValue CPrep_ParseBinary(PrepValue *rhs, short precLimit); static char *XpandMacro(Macro *macro); static void prepmacro(Macro *macro); -static void prepifskip(); -static void gotonexttoken(); +static void prepifskip(void); +static void gotonexttoken(void); extern SInt16 *CLT_filesp; extern CPrepFileInfo **CLT_filestack; @@ -305,7 +313,7 @@ static void cannotopenerror(StringPtr filename, Boolean err) { if (prep_file) { was_prep_error = 1; - CError_Error(151, fname); + CError_Error(CErrorStr151, fname); if (err) longjmp(errorreturn, 1); } else { @@ -325,7 +333,7 @@ void CPrep_InsertSpecialMacro(Macro *macro, char *name) { insertmacro(macro); } -void CPrep_InsertSpecialMacros() { +void CPrep_InsertSpecialMacros(void) { CPrep_InsertSpecialMacro(&lineM, "__LINE__"); CPrep_InsertSpecialMacro(&fileM, "__FILE__"); CPrep_InsertSpecialMacro(&dateM, "__DATE__"); @@ -343,7 +351,7 @@ void CPrep_InsertSpecialMacros() { CodeGen_InsertSpecialMacros(); } -void CPrep_RemoveSpecialMacros() { +void CPrep_RemoveSpecialMacros(void) { Macro **scan; int x; @@ -359,11 +367,11 @@ void CPrep_RemoveSpecialMacros() { } } -static void CPrep_Reconfig() { +static void CPrep_Reconfig(void) { cprep_idarray['$'] = copts.dollar_identifiers != 0; } -Boolean setupprep() { +Boolean setupprep(void) { int x; now_time = time(NULL); @@ -436,7 +444,7 @@ Boolean setupprep() { return 0; } -void cleanupprep() { +void cleanupprep(void) { while (filesp >= 0) popfile(); @@ -494,7 +502,7 @@ static Boolean setupfile(StringPtr filename, Boolean flag1, Boolean flag2) { if (filesp >= 31) { was_prep_error = 1; - CError_ErrorTerm(243); + CError_ErrorTerm(CErrorStr243); return 0; } @@ -657,11 +665,10 @@ void CPrep_TokenStreamSetState(SInt32 *state) { ts_current = ts_first + *state; } -void CPrep_UnLex() { +void CPrep_UnLex(void) { ++ts_preread_elements; --ts_current; -#line 900 - CError_ASSERT(ts_current >= ts_first); + CError_ASSERT(900, ts_current >= ts_first); } void CPrep_TokenStreamSetCurState(SInt32 *state) { @@ -726,7 +733,7 @@ loop: } if (!t) return 0; - if (t == TK_NEG7) { + if (t == TK_EOL) { t = lex(); v++; } @@ -795,7 +802,7 @@ loop: return v; } -void CPrep_StreamGetBlock(TStream *stream, CPrepStreamFuncPtr func, int arg) { +void CPrep_StreamGetBlock(TokenStream *stream, CPrepStreamFuncPtr func, int arg) { Boolean save_eoltokens; SInt32 start_offset; Boolean tryflag; @@ -814,20 +821,20 @@ void CPrep_StreamGetBlock(TStream *stream, CPrepStreamFuncPtr func, int arg) { tryflag = 1; case ':': if (!(count = CPrep_StreamSkipToBrace(func, 0))) { - CError_Error(121); + CError_Error(CErrorStr121); cprep_eoltokens = save_eoltokens; return; } case '{': break; default: - CError_Error(121); + CError_Error(CErrorStr121); cprep_eoltokens = save_eoltokens; return; } if (!(count = CPrep_StreamSkipBlock(func, count))) { - CError_Error(121); + CError_Error(CErrorStr121); cprep_eoltokens = save_eoltokens; return; } @@ -835,12 +842,12 @@ void CPrep_StreamGetBlock(TStream *stream, CPrepStreamFuncPtr func, int arg) { if (tryflag) { tryloop: switch (lex()) { - case TK_NEG7: + case TK_EOL: count++; goto tryloop; case TK_CATCH: if (!(count = CPrep_StreamSkipToBrace(func, count)) || !(count = CPrep_StreamSkipBlock(func, count))) { - CError_Error(242); + CError_Error(CErrorStr242); cprep_eoltokens = save_eoltokens; return; } @@ -848,7 +855,7 @@ void CPrep_StreamGetBlock(TStream *stream, CPrepStreamFuncPtr func, int arg) { goto tryloop; break; default: - CError_Error(242); + CError_Error(CErrorStr242); cprep_eoltokens = save_eoltokens; return; } @@ -860,7 +867,7 @@ void CPrep_StreamGetBlock(TStream *stream, CPrepStreamFuncPtr func, int arg) { memcpy(stream->firsttoken, ts_first + start_offset, count * sizeof(TStreamElement)); } -void CPrep_StreamGetSemicolon(TStream *stream, CPrepStreamFuncPtr func) { +void CPrep_StreamGetSemicolon(TokenStream *stream, CPrepStreamFuncPtr func) { SInt32 count; SInt32 start_offset; Boolean save_eoltokens; @@ -887,7 +894,7 @@ void CPrep_StreamGetSemicolon(TStream *stream, CPrepStreamFuncPtr func) { cprep_eoltokens = save_eoltokens; } -void CPrep_StreamGetTemplate(TStream *stream, CPrepStreamFuncPtr func) { +void CPrep_StreamGetTemplate(TokenStream *stream, CPrepStreamFuncPtr func) { SInt32 count; SInt32 start_offset; Boolean save_eoltokens; @@ -903,9 +910,9 @@ void CPrep_StreamGetTemplate(TStream *stream, CPrepStreamFuncPtr func) { loop: switch (tk) { case 0: - CError_ErrorTerm(102); + CError_ErrorTerm(CErrorStr102); case '}': - CError_Error(229); + CError_Error(CErrorStr229); return; case ';': count++; @@ -940,7 +947,7 @@ loop: if (level <= 0) break; if (!(tk = lex())) - CError_ErrorTerm(102); + CError_ErrorTerm(CErrorStr102); } while (1); if (lookahead() == ';') { tk = lex(); @@ -954,7 +961,7 @@ loop: cprep_eoltokens = save_eoltokens; } -void CPrep_StreamInsert(TStream *stream, SInt32 *state) { +void CPrep_StreamInsert(TokenStream *stream, SInt32 *state) { if (ts_preread_elements + (ts_current - ts_first) + stream->tokens >= ts_elements) CPrep_TSBufferGrow(stream->tokens); if (ts_preread_elements) @@ -964,7 +971,7 @@ void CPrep_StreamInsert(TStream *stream, SInt32 *state) { CPrep_TokenStreamGetState(state); } -void CPrep_StreamRemove(TStream *stream, SInt32 *state) { +void CPrep_StreamRemove(TokenStream *stream, SInt32 *state) { TStreamElement *end; SInt32 amount; @@ -979,14 +986,13 @@ void CPrep_StreamRemove(TStream *stream, SInt32 *state) { } void CPrep_RemoveTokens(SInt32 amount) { -#line 1296 - CError_ASSERT(ts_preread_elements >= amount); + CError_ASSERT(1296, ts_preread_elements >= amount); ts_preread_elements -= amount; memmove(ts_current, ts_current + amount, sizeof(TStreamElement) * ts_preread_elements); } -void CPrep_TokenStreamFlush() { +void CPrep_TokenStreamFlush(void) { if (!ts_preread_elements) ts_current = ts_first; } @@ -1060,7 +1066,7 @@ static int CPrep_TokenSize(char *str) { return 1; } -TStreamElement *CPrep_CurStreamElement() { +TStreamElement *CPrep_CurStreamElement(void) { static TStreamElement dummyelement; if (ts_first < ts_current) return ts_current - 1; @@ -1091,10 +1097,8 @@ void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SIn if (!token && ts_first < ts_current) prevtoken = ts_current - 1; - if (prevtoken && !prevtoken->tokenfile) { -#line 1454 - CError_FATAL(); - } + if (prevtoken && !prevtoken->tokenfile) + CError_FATAL(1454); if (was_prep_error || !prevtoken) { if (!prep_file) @@ -1147,13 +1151,13 @@ void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SIn while (r5 < 80 && (r7 - r5) >= r4 && r7[-r5] != '\r') r5++; r5--; - while ((c = r7[-r5]) && (c == ' ' || c == '\t' || c == 4)) + while ((c = r7[-r5]) && (c == ' ' || c == '\t' || c == TK_4)) r5--; r6 = 0; while ((c = r7[-r5]) != '\r' && c && r6 < 126) { if (!r5) *tokenoffset = r6; - if (c != 4) { + if (c != TK_4) { buf1[r6++] = (c != '\t') ? c : ' '; } r5--; @@ -1200,7 +1204,7 @@ void CPrep_ErrorName(short code, const char *name) { in_assembler = 0; was_prep_error = 1; if (code == 102 && (tokenstacklevel > 0 || pos < prep_file_end)) - CError_Error(105, name); + CError_Error(CErrorStr105, name); else CError_Error(code, name); in_assembler = save; @@ -1238,18 +1242,20 @@ void CPrep_ErrorMessageVA(int code, const char *format, va_list list, Boolean fl in_assembler = save; } -void popfile() { - // r5 and r6 are swapped, not sure why +void popfile(void) { + CPrepFileInfo *file; + if (filesp >= 0) { CWReleaseFileText(cparamblkptr->context, prep_file->textbuffer); prep_file->textbuffer = NULL; if (--filesp >= 0) { - prep_file = filestack[filesp]; - prep_file_start = prep_file->textbuffer; - prep_file_end = prep_file->textbuffer + prep_file->textlength; - pos = prep_file_start + prep_file->pos; - linenumber = prep_file->linenumber; - cprep_hasprepline = prep_file->hasprepline; + file = filestack[filesp]; + prep_file = file; + prep_file_start = file->textbuffer; + prep_file_end = file->textbuffer + file->textlength; + pos = prep_file_start + file->pos; + linenumber = file->linenumber; + cprep_hasprepline = file->hasprepline; at_linestart = 1; } if (preprocessing_only && !copts.simple_prepdump) @@ -1257,7 +1263,7 @@ void popfile() { } } -static SInt32 prepoffset() { +static SInt32 prepoffset(void) { if (filesp > 0) return filestack[0]->pos; else if (tokenstacklevel) @@ -1266,7 +1272,7 @@ static SInt32 prepoffset() { return pos - filestack[0]->textbuffer; } -static SInt32 prepoffset2() { +static SInt32 prepoffset2(void) { return lineoffset; } @@ -1396,8 +1402,7 @@ void CPrep_GetFileOffsetInfo2(FileOffsetInfo *foi, SInt32 *pLine, HashNameNode * } *pLine = foi->tokenline; -#line 2010 - CError_ASSERT(*pLine >= 0); + CError_ASSERT(2010, *pLine >= 0); *pName = foi->file ? foi->file->nameNode : NULL; } @@ -1484,14 +1489,14 @@ UInt8 C_Compiler(CParams *param) { if (tokenstacklevel) { was_prep_error = 1; - CError_ErrorTerm(119); + CError_ErrorTerm(CErrorStr119); } else if (iflevel) { was_prep_error = 0; ts.tokenfile = ifstack[iflevel - 1].file; ts.tokenoffset = ifstack[iflevel - 1].pos; if (iflevel) CError_SetErrorToken(&ts); - CError_ErrorTerm(119); + CError_ErrorTerm(CErrorStr119); } if (!anyerrors) { @@ -1536,7 +1541,7 @@ UInt8 C_Compiler(CParams *param) { static void pushtokenseq(Macro *macro) { if (tokenstacklevel >= 128) { was_prep_error = 1; - CError_ErrorTerm(111); + CError_ErrorTerm(CErrorStr111); } else { tokenstack[tokenstacklevel].pos = pos; tokenstack[tokenstacklevel].macrostart = macrostart; @@ -1548,7 +1553,7 @@ static void pushtokenseq(Macro *macro) { } } -void poptokenseq() { +void poptokenseq(void) { if (!--tokenstacklevel && dofreeaheap) freeaheap(); @@ -1586,7 +1591,7 @@ static Boolean is_nextchar(short t) { return 0; } -static Macro *ismacroname() { +static Macro *ismacroname(void) { Macro *scan; Boolean save_macrocheck; HashNameNode *name = tkidentifier; @@ -1675,7 +1680,7 @@ static Macro *ismacroname5(char *str) { return NULL; } -static Macro *ismacroname3() { +static Macro *ismacroname3(void) { Macro *scan; HashNameNode *name = tkidentifier; @@ -1716,7 +1721,7 @@ static Macro *ismacroname4(HashNameNode *name) { return scan; } -void foundnl() { +void foundnl(void) { if (!tokenstacklevel) { if (preprocessing_only) CPrep_PreprocessDumpNewLine(); @@ -1727,7 +1732,7 @@ void foundnl() { } } -void newline() { +void newline(void) { foundnl(); nlflag = 1; at_linestart = 1; @@ -1739,7 +1744,7 @@ void newline() { } } -static void gotonexttoken() { +static void gotonexttoken(void) { char *save_pos; Macro *macro; char c; @@ -1777,7 +1782,7 @@ loop: } } -short notendofline() { +short notendofline(void) { char *save_pos; Macro *macro; char c; @@ -1809,80 +1814,286 @@ loop: static void CPrep_MacroRedefError(char *name, Boolean *flag) { if (!*flag) { if (copts.gcc_extensions) { - CPrep_WarningName(108, name); + CPrep_WarningName(CErrorStr108, name); } else if (copts.cpp_extensions) { if (copts.pedantic) - CPrep_WarningName(108, name); + CPrep_WarningName(CErrorStr108, name); } else { - CPrep_ErrorName(108, name); + CPrep_ErrorName(CErrorStr108, name); } *flag = 1; } } -static void goendofline() { +static void goendofline(void) { if (notendofline()) { - CPrep_Error(113); + CPrep_Error(CErrorStr113); skipendofline(); } } -static void CPrep_Define() { +static void CPrep_Define(void) { Macro *existing_macro; // r31 - HashNameNode *name; // r29 - short r28; // r28 - Boolean r27; // r27 Macro *macro; // r20 + HashNameNode *name; // r29 + HashNameNode **names; // r20 short t; // r17 + short i; + short argCount; // r28 + char *ptr19; + char *ptr17; + Boolean hasVarArgs; // r27 + Boolean isPrecedingTokenAnArg; + Boolean tokenPasteFlag; Boolean error_flag; + HashNameNode *myNameList[128]; macrocheck = 0; nlflag = 0; t = lexidentifier(); if (nlflag) { - CPrep_Error(112); + CPrep_Error(CErrorStr112); skipendofline(); } if (t != TK_IDENTIFIER) { - CPrep_Error(107); + CPrep_Error(CErrorStr107); skipendofline(); return; } - macro = ismacroname3(); + existing_macro = ismacroname3(); name = tkidentifier; error_flag = 0; - r27 = 0; + hasVarArgs = 0; if (prepcurchar() == '(') { - r28 = 1; + argCount = 1; pos = nextcharpos; - // fix me + if (existing_macro) + names = existing_macro->names; + else + names = NULL; + + do { + t = lexidentifier(); + if (t != TK_IDENTIFIER) + break; + + if (nlflag) { + CPrep_Error(CErrorStr112); + return; + } + + if (!strcmp(tkidentifier->name, "__VA_ARGS__")) { + CPrep_ErrorName(CErrorStr365, tkidentifier->name); + return; + } + + for (i = 1; i < argCount; i++) { + if (!strcmp(tkidentifier->name, myNameList[i - 1]->name)) { + CPrep_ErrorName(CErrorStr365, tkidentifier->name); + return; + } + } + + myNameList[argCount - 1] = tkidentifier; + + if (existing_macro) { + if ((existing_macro->xC & 0x7FFF) < argCount) + CPrep_MacroRedefError(name->name, &error_flag); + if (names[argCount - 1] != tkidentifier && !copts.cpp_extensions) + CPrep_MacroRedefError(name->name, &error_flag); + } + + if (argCount >= 128) + CError_Error(CErrorStr110); + else + argCount++; + + t = plex(); + if (nlflag) { + CPrep_Error(CErrorStr112); + return; + } + } while (t == ','); + + if (nlflag) { + CPrep_Error(CErrorStr112); + return; + } + + if (t == TK_ELLIPSIS) { + hasVarArgs = 1; + myNameList[argCount - 1] = GetHashNameNode("__VA_ARGS__"); + if (argCount >= 128) + CError_Error(CErrorStr110); + else + argCount++; + + t = plex(); + if (nlflag) { + CPrep_Error(CErrorStr112); + return; + } + } + + if (t != ')') { + CPrep_Error(CErrorStr109); + skipendofline(); + return; + } + + macro = galloc(sizeof(Macro) + sizeof(HashNameNode *) + sizeof(HashNameNode *) * (argCount - 2)); } else { macro = galloc(sizeof(Macro)); - r28 = 0; + argCount = 0; } - if (existing_macro && (existing_macro->xC & 0x7FFF) != r28) + if (existing_macro && (existing_macro->xC & 0x7FFF) != argCount) CPrep_MacroRedefError(name->name, &error_flag); macro->name = name; - macro->xC = r27 ? (r28 | 0x8000) : r28; + macro->xC = hasVarArgs ? (argCount | 0x8000) : argCount; macro->is_special = 0; macro->xF = 0; - if (r28 > 1) { - // fix me - } + for (i = 1; i < argCount; i++) + macro->names[i - 1] = myNameList[i - 1]; mlist.size = 0; if (notendofline()) { - // fix me + while (1) { + tokenPasteFlag = 0; + innerLoop: + isPrecedingTokenAnArg = 0; + ptr19 = pos; + spaceskip = 0; + t = prepnextchar(); + + switch (t) { + case 0: + CPrep_Error(CErrorStr102); + break; + + case '"': + case '\'': + CPrep_MatchChar(t, 1); + AppendGListData(&mlist, ptr19, pos - ptr19); + break; + + case '#': + ptr17 = pos; + if (prepnextchar() == '#') + CPrep_Error(CErrorStr117); + pos = ptr17; + + if (notendofline()) { + t = prepnextchar(); + if ((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z') || t == '_') { + pos = ReadIdentifier(pos - 1); + for (i = 1; i < argCount; i++) { + if (tkidentifier == macro->names[i - 1]) + break; + } + + if (i < argCount) { + AppendGListByte(&mlist, TK_MACRO_ARG_HASH); + AppendGListByte(&mlist, i); + break; + } + } + } + + if (copts.ANSI_strict) + CPrep_Error(CErrorStr117); + AppendGListByte(&mlist, '#'); + pos = ptr17; + break; + + default: + if ((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z') || t == '_') { + pos = ReadIdentifier(pos - 1); + for (i = 1; i < argCount; i++) { + if (tkidentifier == macro->names[i - 1]) + break; + } + + if (i < argCount) { + AppendGListByte(&mlist, tokenPasteFlag ? TK_MACRO_ARG_2 : TK_MACRO_ARG_1); + AppendGListByte(&mlist, i); + isPrecedingTokenAnArg = 1; + } else { + AppendGListName(&mlist, tkidentifier->name); + } + } else { + AppendGListByte(&mlist, t); + } + } + + if (!notendofline()) + break; + + ptr17 = pos; + if (prepnextchar() == '#' && prepnextchar() == '#') { + if (!notendofline()) + CPrep_Error(CErrorStr117); + if (isPrecedingTokenAnArg) + (*mlist.data)[mlist.size - 2] = TK_MACRO_ARG_2; + tokenPasteFlag = 1; + goto innerLoop; + } + pos = ptr17; + + if (spaceskip) + AppendGListByte(&mlist, ' '); + } + } + + macrocheck = 1; + + if (mlist.size > 0) { + AppendGListByte(&mlist, 0); + if (mlist.size > 0x20000) { + CPrep_Error(CErrorStr111); + return; + } + + if (existing_macro) { + if (!existing_macro->c || memcmp(*mlist.data, existing_macro->c, mlist.size)) + CPrep_MacroRedefError(name->name, &error_flag); + } + + macro->c = galloc(mlist.size); + memcpy(macro->c, *mlist.data, mlist.size); } else { - // fix me + macro->c = NULL; + if (existing_macro && existing_macro->c) + CPrep_MacroRedefError(name->name, &error_flag); + } + + if (existing_macro && error_flag) + return; + + macro->next = macrohashtable[macro->name->hashval]; + macrohashtable[macro->name->hashval] = macro; + + if (cparamblkptr->browseOptions.recordMacros && prep_file->recordbrowseinfo) { + CBrowse_NewMacro(macro, prep_file, gDirectiveStart, pos - prep_file_start + 1); + } + + if (error_flag) { + macro = macrohashtable[macro->name->hashval]; + while (1) { + if (macro->next == existing_macro) { + macro->next = macro->next->next; + break; + } + macro = macro->next; + CError_ASSERT(2847, macro); + } } } -static void prepundefine() { +static void prepundefine(void) { short t; Macro *macro; Macro **scan; @@ -1891,10 +2102,10 @@ static void prepundefine() { nlflag = 0; t = lexidentifier(); if (nlflag) { - CPrep_Error(112); + CPrep_Error(CErrorStr112); skipendofline(); } else if (t != TK_IDENTIFIER) { - CPrep_Error(107); + CPrep_Error(CErrorStr107); skipendofline(); } else { name = tkidentifier; @@ -1909,12 +2120,121 @@ static void prepundefine() { } } -static Boolean CPrep_CheckTarget() {} -static Boolean CPrep_CheckOption() {} -static char *CPrep_XpandDefinedCheck(char *) {} +static Boolean CPrep_CheckTarget(void) { + Boolean result; + + if (!notendofline()) { + CError_Error(CErrorStr112); + return 0; + } + + if (plex() != '(') { + CError_Error(CErrorStr114); + return 0; + } + + if (!notendofline()) { + CError_Error(CErrorStr112); + return 0; + } + + if (plex() != TK_STRING) { + CError_Error(CErrorStr120); + return 0; + } + + result = !strcmp(cparams.targetName, tkstring); + + if (!notendofline()) { + CError_Error(CErrorStr112); + return 0; + } + + if (plex() != ')') { + CError_Error(CErrorStr115); + return 0; + } + + return result; +} + +static Boolean CPrep_CheckOption(void) { + UInt16 offset; + UInt8 *ptr; + struct CompilerOption *option; + Boolean result; + + if (!notendofline()) { + CError_Error(CErrorStr112); + return 0; + } + + if (plex() != '(') { + CError_Error(CErrorStr114); + return 0; + } + + if (!notendofline()) { + CError_Error(CErrorStr112); + return 0; + } + + if (lexidentifier() != TK_IDENTIFIER) { + CError_Error(CErrorStr107); + return 0; + } + + if (!strcmp(tkidentifier->name, "scheduling")) { + result = copts.schedule_mode != 0; + } else if (!strcmp(tkidentifier->name, "precompile")) { + result = cparamblkptr->isPrecompiling == 1; + } else if (!strcmp(tkidentifier->name, "preprocess")) { + result = cparamblkptr->isPreprocessing; + } else { + for (option = compileroptions; option->name; option++) { + if (!strcmp(tkidentifier->name, option->name)) { + offset = option->bits & OPT_OFFSET_MASK; + ptr = (UInt8 *) (offset + (intptr_t) &copts); + result = *ptr; + if (offset == OPT_OFFSET(booltruefalse) && !copts.cplusplus) + result = 0; + goto gotResult; + } + } + result = 0; + } + +gotResult: + if (!notendofline()) { + CError_Error(CErrorStr112); + return 0; + } + + if (plex() != ')') { + CError_Error(CErrorStr115); + return 0; + } + + return result; +} + +static char *CPrep_XpandDefinedCheck(char *str) { + while (*str == ' ' || (*str >= 9 && *str <= 12)) + str++; + + if (*str == '(') { + str++; + while (*str == ' ' || (*str >= 9 && *str <= 12)) + str++; + } + + if ((*str >= 'a' && *str <= 'z') || (*str >= 'A' && *str <= 'Z') || *str == '_') + return ReadIdentifier(str); + + return NULL; +} static char *XpandString(Macro *macro, char *somepos) { - // almost matches, r22 and r23 are swapped at the end short start_level; char *curpos; char *tmp; @@ -1923,7 +2243,6 @@ static char *XpandString(Macro *macro, char *somepos) { char *macro_output; Macro *macro2; int c; - char *resultptr; pushtokenseq(macro); macropos = somepos; @@ -1971,7 +2290,7 @@ static char *XpandString(Macro *macro, char *somepos) { tmplen = mlist.size; if (tmplen > 0x20000) { macropos = pos; - CPrep_Error(111); + CPrep_Error(CErrorStr111); return ""; } curpos = aalloc(tmplen); @@ -2049,16 +2368,43 @@ static char *XpandString(Macro *macro, char *somepos) { AppendGListByte(&mlist, 0); skip_null_term: if ((tmplen = mlist.size) > 0x20000) { - CPrep_Error(111); + CPrep_Error(CErrorStr111); return ""; - } else { - resultptr = aalloc(tmplen); - memcpy(resultptr, *mlist.data, tmplen); - return resultptr; } + + tmp = aalloc(tmplen); + memcpy(tmp, *mlist.data, tmplen); + return tmp; } char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2) { + FSSpec spec; + Str255 filename; + int size; + char *src; + char *dst; + + COS_FileGetFSSpecInfo(&filestack[flag1 ? 0 : filesp]->textfile, NULL, NULL, filename); + + size = filename[0]; + if (!buffer) + buffer = galloc(size + 3); + + dst = buffer; + + if (flag2) + *(dst++) = '"'; + + src = (char *) filename; + while (size-- > 0) + *(dst++) = *(++src); + + if (flag2) + *(dst++) = '"'; + + *(dst++) = 0; + + return buffer; } static char *XpandSpecialMacro(Macro *macro) { @@ -2113,6 +2459,230 @@ static char *XpandSpecialMacro(Macro *macro) { } static char *XpandMacro(Macro *macro) { + void **buf1; + void **buf2; + Boolean hasVarArgs; + int argCount; + int maxArgs; + char *p; + char *p2; + char *input; + short ch; + short t; + short i; + short depth; + short spaceFlag; + Boolean inVarArgs; + SInt32 tmplen; + + if (macro->is_special) + return XpandSpecialMacro(macro); + + argCount = macro->xC & 0x7FFF; + hasVarArgs = (macro->xC & 0x8000) != 0; + + if (argCount) { + gotonexttoken(); + CError_ASSERT(3293, prepnextchar() == '('); + if (argCount > 1) { + inVarArgs = hasVarArgs && argCount == 2; + maxArgs = argCount - 1; + buf1 = aalloc(sizeof(void *) * maxArgs); + buf2 = aalloc(sizeof(void *) * maxArgs); + i = 1; + while (i < argCount) { + spaceFlag = 1; + depth = 0; + mlist.size = 0; + restart1: + spaceskip = 0; + restart2: + t = prepnextchar(); + switch (t) { + case '\r': + foundnl(); + spaceskip = 1; + goto restart2; + case '\t': + case '\n': + case '\v': + case '\f': + case ' ': + spaceskip = 1; + goto restart2; + case 0: + if (tokenstacklevel != 0) { + poptokenseq(); + goto restart2; + } + CPrep_Error(CErrorStr102); + break; + case '"': + case '\'': + p = pos - 1; + CPrep_MatchChar(t, 0); + AppendGListData(&mlist, p, pos - p); + goto restart1; + case ')': + if (--depth < 0) { + if (++i >= argCount) + break; + macropos = pos; + CPrep_Error(CErrorStr116); + return ""; + } + goto do_default; + case ',': + if (depth <= 0 && !inVarArgs) { + i++; + if (hasVarArgs && i == maxArgs) { + inVarArgs = 1; + } else if (i >= argCount) { + macropos = pos; + CPrep_Error(CErrorStr115); + return ""; + } + break; + } + goto do_default; + case '(': + depth++; + default: + do_default: + if (spaceskip && !spaceFlag) + AppendGListByte(&mlist, ' '); + AppendGListByte(&mlist, t); + spaceFlag = 0; + goto restart1; + } + + buf2[i - 2] = buf1[i - 2] = NULL; + if (mlist.size > 0) { + AppendGListByte(&mlist, 0); + tmplen = mlist.size; + if (tmplen <= 0x20000) { + buf1[i - 2] = aalloc(tmplen); + memcpy(buf1[i - 2], *mlist.data, tmplen); + } else { + CPrep_Error(CErrorStr111); + } + } + } + } else { + gotonexttoken(); + if (prepnextchar() != ')') { + macropos = pos; + CPrep_Error(CErrorStr115); + } + } + } + + if (!macro->c) + return ""; + + if (argCount <= 1 && hasVarArgs == 0) + return XpandString(macro, macro->c); + + input = macro->c; + mlist.size = 0; + while ((ch = *(input++))) { + switch (ch) { + case '"': + case '\'': + p = input - 1; + input = CPrep_MatchChar2(input, ch, 0); + AppendGListData(&mlist, p, input - p); + break; + + case TK_MACRO_ARG_2: + p = buf1[*(input++) - 1]; + if (p) { + while (1) { + switch (*p) { + case 0: + break; + case TK_4: + case TK_5: + p++; + continue; + default: + AppendGListByte(&mlist, *(p++)); + continue; + } + break; + } + } + break; + + case TK_MACRO_ARG_HASH: + AppendGListByte(&mlist, '"'); + p = buf1[*(input++) - 1]; + if (p) { + while ((ch = *(p++))) { + switch (ch) { + case TK_4: + case TK_5: + break; + case '"': + AppendGListByte(&mlist, '\\'); + case '\'': + AppendGListByte(&mlist, ch); + while (*p && *p != ch) { + if (*p == '"' || *p == '\\') + AppendGListByte(&mlist, '\\'); + AppendGListByte(&mlist, *(p++)); + } + if (*p == '"') + AppendGListByte(&mlist, '\\'); + if (*p) + AppendGListByte(&mlist, *(p++)); + break; + default: + AppendGListByte(&mlist, ch); + break; + } + } + } + AppendGListByte(&mlist, '"'); + break; + + case TK_MACRO_ARG_1: + i = *(input++) - 1; + p = buf2[i]; + if (!p) { + if (!buf1[i]) + break; + + tmplen = mlist.size; + p2 = aalloc(tmplen); + memcpy(p2, *mlist.data, tmplen); + p = buf2[i] = XpandString(NULL, buf1[i]); + mlist.size = 0; + AppendGListData(&mlist, p2, tmplen); + } + + while (*p) + AppendGListByte(&mlist, *(p++)); + + if (p[-1] == '>' && *input == '>') + AppendGListByte(&mlist, ' '); + break; + + default: + AppendGListByte(&mlist, ch); + } + } + + AppendGListByte(&mlist, 0); + + if (mlist.size > 0x20000) { + CPrep_Error(CErrorStr111); + return ""; + } else { + p = aalloc(mlist.size); + memcpy(p, *mlist.data, mlist.size); + return XpandString(macro, p); + } } static void prepmacro(Macro *macro) { @@ -2133,7 +2703,7 @@ static void prepmacro(Macro *macro) { spaceskip = save_spaceskip; } -Boolean macrotest() { +Boolean macrotest(void) { Macro *macro; if ((macro = ismacroname())) { prepmacro(macro); @@ -2147,7 +2717,7 @@ short CPrep_PragmaLex(Boolean no_err) { if (notendofline()) return plex(); if (!no_err) - CPrep_Error(113); + CPrep_Error(CErrorStr113); return 0; } @@ -2209,7 +2779,7 @@ static void CPrep_PragmaImExport(int flags) { OBJECT(list->object)->flags |= flags; break; default: - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); return; } } @@ -2222,7 +2792,7 @@ static void CPrep_PragmaImExport(int flags) { } while (plex() == ',' && notendofline()); if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } static void pragma_on_off_reset(UInt32 bits) { @@ -2258,15 +2828,14 @@ static void pragma_on_off_reset(UInt32 bits) { else if ((bits & OPT_OFFSET_MASK) == OPT_OFFSET(lib_export)) imex_flags = OBJECT_FLAGS_60; else -#line 3610 - CError_FATAL(); + CError_FATAL(3610); CPrep_PragmaImExport(imex_flags); return; } } if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } static HashNameNode *CPrep_PragmaOnceName(StringPtr name, Boolean flag) { @@ -2291,20 +2860,20 @@ static HashNameNode *CPrep_PragmaOnceName(StringPtr name, Boolean flag) { return GetHashNameNodeExport(myname); } -static void pragma_precompile_target() { +static void pragma_precompile_target(void) { if (!notendofline()) { - CPrep_Error(112); + CPrep_Error(CErrorStr112); return; } if (plex() != TK_STRING) { - CPrep_Error(117); + CPrep_Error(CErrorStr117); skipendofline(); return; } if (ispascalstring) { - CPrep_Error(101); + CPrep_Error(CErrorStr101); skipendofline(); return; } @@ -2319,15 +2888,15 @@ static void CPrep_DefinePragmaOnceMacro(StringPtr name, Boolean flag) { namenode = CPrep_PragmaOnceName(name, flag); if (!ismacroname4(namenode)) { - macro = galloc(sizeof(Macro)); - memclrw(macro, sizeof(Macro)); + macro = galloc(sizeof(Macro) + sizeof(HashNameNode *)); + memclrw(macro, sizeof(Macro) + sizeof(HashNameNode *)); macro->name = namenode; macro->next = macrohashtable[namenode->hashval]; macrohashtable[namenode->hashval] = macro; } } -static void CPrep_PragmaOnce() { +static void CPrep_PragmaOnce(void) { if (notendofline()) { if (plex() == TK_IDENTIFIER) { if (!strcmp(tkidentifier->name, "on")) { @@ -2339,7 +2908,7 @@ static void CPrep_PragmaOnce() { } } if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } else { Str255 filename; COS_FileGetFSSpecInfo(&prep_file->textfile, NULL, NULL, filename); @@ -2347,7 +2916,7 @@ static void CPrep_PragmaOnce() { } } -static void CPrep_PragmaUnused() { +static void CPrep_PragmaUnused(void) { NameSpace *nspace; NameSpaceObjectList *list; short t; @@ -2366,7 +2935,7 @@ static void CPrep_PragmaUnused() { list = CScope_GetLocalObject(nspace, tkidentifier); if (list && list->object->otype == OT_OBJECT && OBJECT(list->object)->datatype == DLOCAL) { - OBJECT(list->object)->flags |= OBJECT_FLAGS_UNUSED; + OBJECT(list->object)->flags |= OBJECT_FLAGS_1; if (notendofline()) { t = plex(); if (t == ')') @@ -2381,17 +2950,17 @@ static void CPrep_PragmaUnused() { } if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } -static void CPrep_PragmaInlineDepth() { +static void CPrep_PragmaInlineDepth(void) { int lv; if (notendofline() && plex() == '(' && notendofline()) { switch (plex()) { case TK_IDENTIFIER: if (strcmp(tkidentifier->name, "smart")) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); else copts.inlinelevel = 0; break; @@ -2400,78 +2969,78 @@ static void CPrep_PragmaInlineDepth() { if (lv >= 0 && lv <= 1024) copts.inlinelevel = lv ? lv : -1; else - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); break; default: - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); return; } if (!notendofline() || plex() != ')') { - CPrep_Warning(115); + CPrep_Warning(CErrorStr115); } if (notendofline()) { - CPrep_Warning(113); + CPrep_Warning(CErrorStr113); skipendofline(); } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } } -static void CPrep_PragmaInlineMaxSize() { +static void CPrep_PragmaInlineMaxSize(void) { if (notendofline() && plex() == '(' && notendofline()) { switch (plex()) { case TK_INTCONST: copts.inline_max_size = CInt64_GetULong(&tkintconst); break; default: - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); return; } if (!notendofline() || plex() != ')') { - CPrep_Warning(115); + CPrep_Warning(CErrorStr115); } if (notendofline()) { - CPrep_Warning(113); + CPrep_Warning(CErrorStr113); skipendofline(); } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } } -static void CPrep_PragmaInlineMaxTotalSize() { +static void CPrep_PragmaInlineMaxTotalSize(void) { if (notendofline() && plex() == '(' && notendofline()) { switch (plex()) { case TK_INTCONST: copts.inline_max_total_size = CInt64_GetULong(&tkintconst); break; default: - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); return; } if (!notendofline() || plex() != ')') { - CPrep_Warning(115); + CPrep_Warning(CErrorStr115); } if (notendofline()) { - CPrep_Warning(113); + CPrep_Warning(CErrorStr113); skipendofline(); } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } } -static void pragma_segment() { +static void pragma_segment(void) { short i; short t; char name[256]; @@ -2490,17 +3059,17 @@ static void pragma_segment() { name[i] = 0; if (!i || i >= 255) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); copts.forcedSegment = GetHashNameNodeExport(name); ObjGen_SegmentName(); } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } } -static void pragma_options() { +static void pragma_options(void) { if (notendofline() && plex() == TK_IDENTIFIER && !strcmp(tkidentifier->name, "align") && notendofline() && plex() == '=' && notendofline() && plex() == TK_IDENTIFIER) { if (!strcmp(tkidentifier->name, "reset")) { CPrep_PopOption(OPT_OFFSET(align_mode)); @@ -2524,18 +3093,18 @@ static void pragma_options() { } if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); return; done: if (notendofline()) { - CPrep_Error(113); + CPrep_Error(CErrorStr113); skipendofline(); } } -static void pragma_push() { +static void pragma_push(void) { struct COptsPush *push; push = galloc(sizeof(struct COptsPush)); @@ -2545,17 +3114,17 @@ static void pragma_push() { push->opts = copts; } -static void pragma_pop() { +static void pragma_pop(void) { if (coptpushs) { copts = coptpushs->opts; coptpushs = coptpushs->next; CMach_Configure(); } else { - CPrep_Error(237); + CPrep_Error(CErrorStr237); } } -static void pragma_overload() { +static void pragma_overload(void) { Object *obj; if (cparamblkptr->isPreprocessing) { @@ -2567,19 +3136,19 @@ static void pragma_overload() { tk = lex(); if ((obj = CParser_ParseObject())) { if (obj->sclass && obj->sclass != 0x103) - CPrep_Error(177); + CPrep_Error(CErrorStr177); obj->qual |= Q_OVERLOAD; } else { - CPrep_Error(186); + CPrep_Error(CErrorStr186); } if (nlflag) - CPrep_Error(112); + CPrep_Error(CErrorStr112); if (tk != ';') - CPrep_Error(123); + CPrep_Error(CErrorStr123); } -static void pragma_optimization_level() { +static void pragma_optimization_level(void) { short t; int lv; @@ -2589,14 +3158,14 @@ static void pragma_optimization_level() { lv = CInt64_GetULong(&tkintconst); if (lv >= 0 && lv <= 4) { if (copts.crippled && lv > 1) { - CPrep_Warning(385); + CPrep_Warning(CErrorStr385); lv = 1; } CPrep_PushOption(OPT_OFFSET(optimizationlevel), lv); CodeGen_UpdateOptimizerOptions(); CodeGen_UpdateBackEndOptions(); } else { - CPrep_Error(154); + CPrep_Error(CErrorStr154); skipendofline(); } } else if (t == TK_IDENTIFIER && !strcmp(tkidentifier->name, "reset")) { @@ -2604,17 +3173,17 @@ static void pragma_optimization_level() { CodeGen_UpdateOptimizerOptions(); CodeGen_UpdateBackEndOptions(); } else { - CPrep_Error(105); + CPrep_Error(CErrorStr105); skipendofline(); } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); } } -static void pragma_opt_unroll_count() { +static void pragma_opt_unroll_count(void) { short t; int lv; @@ -2627,7 +3196,7 @@ static void pragma_opt_unroll_count() { CodeGen_UpdateOptimizerOptions(); CodeGen_UpdateBackEndOptions(); } else { - CPrep_Error(154); + CPrep_Error(CErrorStr154); skipendofline(); } } else if (t == TK_IDENTIFIER && !strcmp(tkidentifier->name, "reset")) { @@ -2635,17 +3204,17 @@ static void pragma_opt_unroll_count() { CodeGen_UpdateOptimizerOptions(); CodeGen_UpdateBackEndOptions(); } else { - CPrep_Error(105); + CPrep_Error(CErrorStr105); skipendofline(); } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); } } -static void pragma_opt_unroll_instr_count() { +static void pragma_opt_unroll_instr_count(void) { short t; int lv; @@ -2658,7 +3227,7 @@ static void pragma_opt_unroll_instr_count() { CodeGen_UpdateOptimizerOptions(); CodeGen_UpdateBackEndOptions(); } else { - CPrep_Error(154); + CPrep_Error(CErrorStr154); skipendofline(); } } else if (t == TK_IDENTIFIER && !strcmp(tkidentifier->name, "reset")) { @@ -2666,17 +3235,17 @@ static void pragma_opt_unroll_instr_count() { CodeGen_UpdateOptimizerOptions(); CodeGen_UpdateBackEndOptions(); } else { - CPrep_Error(105); + CPrep_Error(CErrorStr105); skipendofline(); } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); } } -static void pragma_pack() { +static void pragma_pack(void) { int t; int i; Boolean did_push; @@ -2697,7 +3266,7 @@ static void pragma_pack() { cprep_packstack[cprep_packstackp].align_mode = copts.align_mode; did_push = 1; } else { - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } } else if (!strcmp(tkidentifier->name, "pop")) { if (cprep_packstackp < 128) { @@ -2705,7 +3274,7 @@ static void pragma_pack() { cprep_packstackp++; did_pop = 1; } else { - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } } else { if (did_push) { @@ -2719,10 +3288,10 @@ static void pragma_pack() { copts.align_mode = cprep_packstack[i].align_mode; cprep_packstackp = i + 1; } else { - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } } else { - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } did_pop = 0; did_push = 0; @@ -2750,7 +3319,7 @@ static void pragma_pack() { break; default: if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } } did_pop = 0; @@ -2765,15 +3334,15 @@ static void pragma_pack() { } while (1); } if (t != ')' && copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); macrocheck = 0; } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } } -static void pragma_comment() { +static void pragma_comment(void) { int t; short start_tokenstacklevel = tokenstacklevel; @@ -2799,13 +3368,13 @@ static void pragma_comment() { } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); return; } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); return; } @@ -2825,25 +3394,25 @@ static void pragma_comment() { } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); return; } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); return; } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); return; } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); return; } @@ -2851,17 +3420,17 @@ static void pragma_comment() { if (t != ')') { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); } } -static void pragma_message() { +static void pragma_message(void) { int t; short start_tokenstacklevel; char str[128]; @@ -2893,22 +3462,22 @@ static void pragma_message() { skipendofline(); } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); } } else if (plex() != ')') { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); } } -static void preppragma() { +static void preppragma(void) { struct CompilerOption *opt; Boolean save_eoltokens; @@ -2998,14 +3567,14 @@ static void preppragma() { } } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); skipendofline(); macrocheck = 1; return; } foundOption: if (notendofline()) { - CPrep_Error(113); + CPrep_Error(CErrorStr113); skipendofline(); } CPrep_Reconfig(); @@ -3025,13 +3594,13 @@ static void prepinclude(Boolean flag) { StringPtr ptr; if (!notendofline()) { - CPrep_Error(112); + CPrep_Error(CErrorStr112); return; } t = prepcurchar(); if (t != '"' && t != '<') { - CPrep_Error(117); + CPrep_Error(CErrorStr117); skipendofline(); return; } @@ -3043,10 +3612,10 @@ static void prepinclude(Boolean flag) { if (!copts.flat_include) r29 = 0; len = 0; - while ((t = prepnextstringchar(save_pos, 1)) != '>') { - if (t != 5) { + while ((t = prepnextstringchar((StringPtr) save_pos, 1)) != '>') { + if (t != TK_5) { if (len > 254) { - CPrep_Error(106); + CPrep_Error(CErrorStr106); skipendofline(); return; } @@ -3062,7 +3631,7 @@ static void prepinclude(Boolean flag) { macrocheck = 0; buf[1] = 0; if (t != TK_STRING) { - CPrep_Error(117); + CPrep_Error(CErrorStr117); skipendofline(); return; } @@ -3104,19 +3673,19 @@ all_done: setupfile(ptr, r29, flag); } -static void prepline() { +static void prepline(void) { short t; short len; char buf[256]; cprep_hasprepline = 1; if (!notendofline()) { - CPrep_Error(112); + CPrep_Error(CErrorStr112); return; } if (plex() != TK_INTCONST) { - CPrep_Error(117); + CPrep_Error(CErrorStr117); skipendofline(); return; } @@ -3124,7 +3693,7 @@ static void prepline() { linenumber = CInt64_GetULong(&tkintconst) - 1; if (notendofline()) { if (prepnextchar() != '"') { - CPrep_Error(117); + CPrep_Error(CErrorStr117); skipendofline(); return; } @@ -3134,7 +3703,7 @@ static void prepline() { if (!t) break; if (len > 252) { - CPrep_Error(106); + CPrep_Error(CErrorStr106); skipendofline(); return; } @@ -3152,79 +3721,174 @@ static void prepline() { } } -static TypeIntegral *CPrep_GetPrepType(PrepValue *pv) { +static Type *CPrep_GetPrepType(PrepValue *pv) { if (copts.longlong_prepeval || copts.c9x) { if (pv->is_unsigned) - return &stunsignedlonglong; + return TYPE(&stunsignedlonglong); else - return &stsignedlonglong; + return TYPE(&stsignedlonglong); } else { if (pv->is_unsigned) - return &stunsignedlong; + return TYPE(&stunsignedlong); else - return &stsignedlong; + return TYPE(&stsignedlong); } } -static PrepValue CPrep_ParseUnary() { +static PrepValue CPrep_ParseUnary(void) { + PrepValue val; + + if (!notendofline()) { + CPrep_Error(CErrorStr112); + val.val = cint64_zero; + val.is_unsigned = 0; + } else { + switch (plex()) { + case '-': + val = CPrep_ParseUnary(); + val.val = CMach_CalcIntMonadic(CPrep_GetPrepType(&val), '-', val.val); + return val; + + case '+': + val = CPrep_ParseUnary(); + return val; + + case '!': + val = CPrep_ParseUnary(); + CInt64_SetLong(&val.val, CInt64_IsZero(&val.val)); + return val; + + case '~': + val = CPrep_ParseUnary(); + val.val = CMach_CalcIntMonadic(CPrep_GetPrepType(&val), '~', val.val); + return val; + + case '(': + val = CPrep_ParseCond(); + if (exprtk != ')') { + CPrep_Error(CErrorStr115); + return val; + } + break; + + case TK_TRUE: + val.val = cint64_one; + val.is_unsigned = 1; + break; + + default: + CPrep_Error(CErrorStr141); + case TK_FALSE: + val.val = cint64_zero; + val.is_unsigned = 1; + break; + + case TK_INTCONST: + val.val = tkintconst; + val.is_unsigned = (tksize == IT_ULONGLONG || tksize == IT_ULONG || tksize == IT_UINT || tksize == IT_UCHAR); + break; + case TK_IDENTIFIER: + val.val = cint64_zero; + val.is_unsigned = 0; + if (!strcmp("defined", tkidentifier->name)) { + macrocheck = 0; + if (!notendofline()) { + CPrep_Error(CErrorStr112); + break; + } + + if ((exprtk = plex()) == '(') { + if (!notendofline()) { + CPrep_Error(CErrorStr112); + macrocheck = 1; + break; + } + + if (lexidentifier() != TK_IDENTIFIER) { + CPrep_Error(CErrorStr107); + macrocheck = 1; + break; + } + + if (ismacroname3()) + val.val = cint64_one; + + if (!notendofline()) { + CPrep_Error(CErrorStr112); + macrocheck = 1; + break; + } + + if (plex() != ')') + CPrep_Error(CErrorStr115); + } else if (exprtk == TK_IDENTIFIER) { + if (ismacroname3()) + val.val = cint64_one; + } else { + CPrep_Error(CErrorStr107); + } + + macrocheck = 1; + } + break; + } + } + + exprtk = notendofline() ? plex() : (short) 0; + return val; } -static PrepValue CPrep_ParseBinary(PrepValue *rhs, short op) { - // i need a lot of fixing :( +static PrepValue CPrep_ParseBinary(PrepValue *rhs, short precLimit) { PrepValue a; PrepValue b; - short t; - short op2; - short op3; - short prec2; - short prec3; + short op; + short prec; + short newprec; - if (!rhs) { + if (!rhs) a = CPrep_ParseUnary(); - } else { + else a = *rhs; - } - op2 = op; -restart: - op3 = exprtk; - prec3 = GetPrec(op3); - if (!prec3) { - return a; - } - if (!notendofline()) { - CPrep_Error(112); - return a; - } - b = CPrep_ParseUnary(); - prec3 = prec3; // variable change situation? - do { - if (exprtk == ')' || !notendofline()) { - if (b.is_unsigned) - a.is_unsigned = 1; - a.val = CMach_CalcIntDiadic((Type *) CPrep_GetPrepType(&a), a.val, t, b.val); + while (1) { + if (!(prec = GetPrec(op = exprtk))) return a; - } - op = GetPrec(exprtk); - if (!op) { - CPrep_Error(141); + if (!notendofline()) { + CPrep_Error(CErrorStr112); return a; } - if (prec3 >= prec2) { - if (b.is_unsigned) - a.is_unsigned = 1; - a.val = CMach_CalcIntDiadic((Type *) CPrep_GetPrepType(&a), a.val, t, b.val); - if (GetPrec(op) > op2) - goto restart; - return a; + + b = CPrep_ParseUnary(); + while (1) { + if (exprtk == ')' || !notendofline()) { + if (b.is_unsigned) + a.is_unsigned = 1; + a.val = CMach_CalcIntDiadic(CPrep_GetPrepType(&a), a.val, op, b.val); + return a; + } + + if (!(newprec = GetPrec(exprtk))) { + CPrep_Error(CErrorStr141); + return a; + } + + if (prec >= newprec) { + if (b.is_unsigned) + a.is_unsigned = 1; + a.val = CMach_CalcIntDiadic(CPrep_GetPrepType(&a), a.val, op, b.val); + if (GetPrec(newprec) <= precLimit) + return a; + break; + } else { + b = CPrep_ParseBinary(&b, prec); + } } - b = CPrep_ParseBinary(&b, prec3); - } while (1); + } } -static PrepValue CPrep_ParseCond() { +static PrepValue CPrep_ParseCond(void) { PrepValue a; PrepValue b; PrepValue c; @@ -3233,15 +3897,15 @@ static PrepValue CPrep_ParseCond() { if (exprtk == '?') { b = CPrep_ParseCond(); if (!notendofline()) { - CPrep_Error(112); + CPrep_Error(CErrorStr112); return a; } if (exprtk != ':') { - CPrep_Error(170); + CPrep_Error(CErrorStr170); return a; } if (!notendofline()) { - CPrep_Error(112); + CPrep_Error(CErrorStr112); return a; } c = CPrep_ParseCond(); @@ -3251,7 +3915,7 @@ static PrepValue CPrep_ParseCond() { return a; } -static void doevalconstexpr() { +static void doevalconstexpr(void) { PrepValue v; macrocheck = 1; @@ -3259,10 +3923,10 @@ static void doevalconstexpr() { cprep_incondexpr = 1; v = CPrep_ParseCond(); if (exprtk) - CPrep_Error(141); + CPrep_Error(CErrorStr141); cprep_incondexpr = 0; if (nlflag) - CPrep_Error(112); + CPrep_Error(CErrorStr112); else goendofline(); tkintconst = v.val; @@ -3270,7 +3934,7 @@ static void doevalconstexpr() { static void pushifstate(SInt16 state) { if (iflevel >= 64) { - CPrep_Error(215); + CPrep_Error(CErrorStr215); } else { ifstack[iflevel].state = state; ifstack[iflevel].file = prep_file; @@ -3279,9 +3943,9 @@ static void pushifstate(SInt16 state) { } } -static void popifstate() { +static void popifstate(void) { if (iflevel <= 0) { - CPrep_Error(117); + CPrep_Error(CErrorStr117); } else { switch (ifstack[iflevel - 1].state) { case IfState_1: @@ -3303,7 +3967,7 @@ static void popifstate() { } } -static void positiveif() { +static void positiveif(void) { pushifstate(IfState_0); } @@ -3316,7 +3980,7 @@ static void negativeif(Boolean flag) { } } -static void prepif() { +static void prepif(void) { if (iflevel > 0) { switch (ifstack[iflevel - 1].state) { case IfState_1: @@ -3335,7 +3999,7 @@ static void prepif() { positiveif(); } -static void prepifdef() { +static void prepifdef(void) { if (iflevel > 0) { switch (ifstack[iflevel - 1].state) { case IfState_1: @@ -3349,13 +4013,13 @@ static void prepifdef() { macrocheck = 0; if (!notendofline()) { - CPrep_Error(112); + CPrep_Error(CErrorStr112); negativeif(1); return; } if (lexidentifier() != TK_IDENTIFIER) { - CPrep_Error(107); + CPrep_Error(CErrorStr107); negativeif(1); return; } @@ -3368,7 +4032,7 @@ static void prepifdef() { negativeif(1); } -static void prepifndef() { +static void prepifndef(void) { if (iflevel > 0) { switch (ifstack[iflevel - 1].state) { case IfState_1: @@ -3382,13 +4046,13 @@ static void prepifndef() { macrocheck = 0; if (!notendofline()) { - CPrep_Error(112); + CPrep_Error(CErrorStr112); negativeif(1); return; } if (lexidentifier() != TK_IDENTIFIER) { - CPrep_Error(107); + CPrep_Error(CErrorStr107); negativeif(1); return; } @@ -3401,9 +4065,9 @@ static void prepifndef() { negativeif(1); } -static void prepelif() { +static void prepelif(void) { if (iflevel <= 0 || ifstack[iflevel - 1].state == IfState_2 || ifstack[iflevel - 1].state == IfState_4) { - CPrep_Error(118); + CPrep_Error(CErrorStr118); skipendofline(); return; } @@ -3423,14 +4087,13 @@ static void prepelif() { prepifskip(); break; default: -#line 5700 - CError_FATAL(); + CError_FATAL(5700); } } -static void prepelse() { +static void prepelse(void) { if (iflevel <= 0 || ifstack[iflevel - 1].state == IfState_2 || ifstack[iflevel - 1].state == IfState_4) { - CPrep_Error(118); + CPrep_Error(CErrorStr118); skipendofline(); return; } @@ -3452,14 +4115,13 @@ static void prepelse() { ifstack[iflevel - 1].state = IfState_4; break; default: -#line 5738 - CError_FATAL(); + CError_FATAL(5738); } } -static void prependif() { +static void prependif(void) { if (iflevel <= 0) { - CPrep_Error(118); + CPrep_Error(CErrorStr118); skipendofline(); return; } @@ -3474,7 +4136,7 @@ static void prependif() { popifstate(); } -static void prepifskip() { +static void prepifskip(void) { // this function does something very weird with its code generation that i can't match TStreamElement ts; short t; @@ -3484,70 +4146,74 @@ static void prepifskip() { case IfState_1: case IfState_3: case IfState_4: - restart: - t = prepskipnextchar(); - pos = nextcharpos; - switch (t) { - case 0: - if (tokenstacklevel > 0) { - poptokenseq(); - } else if (tokenstacklevel > 0 || pos >= prep_file_end) { - if (filesp > 0) { - popfile(); - } else { - was_prep_error = 0; - ts.tokenfile = ifstack[iflevel - 1].file; - ts.tokenoffset = ifstack[iflevel - 1].pos; - CError_SetErrorToken(&ts); - CError_ErrorTerm(119); - iflevel = 0; - return; - } - } else { - CPrep_Error(105); - } - goto restart; - case '\r': - newline(); - goto restart; - case '"': - skipendoflinematch(pos, '"'); - goto restart; - case '\'': - skipendoflinematch(pos, '"'); - goto restart; - case '#': - t = prepskipnextchar(); - pos = nextcharpos; - switch (t) { - case '\r': - goto restart; - case 0: - CPrep_Error(102); - default: - pos = ReadIdentifier(pos - 1); - if (!strcmp("if", tkidentifier->name)) { - prepif(); - } else if (!strcmp("ifdef", tkidentifier->name)) { - prepifdef(); - } else if (!strcmp("ifndef", tkidentifier->name)) { - prepifndef(); - } else if (!strcmp("elif", tkidentifier->name)) { - prepelif(); - } else if (!strcmp("else", tkidentifier->name)) { - prepelse(); - } else if (!strcmp("endif", tkidentifier->name)) { - prependif(); + while (1) { + t = prepskipnextchar(); + pos = nextcharpos; + switch (t) { + case 0: + if (tokenstacklevel > 0) { + poptokenseq(); + } else if (tokenstacklevel > 0 || pos >= prep_file_end) { + if (filesp > 0) { + popfile(); } else { - skipendofline(); - goto restart; + was_prep_error = 0; + ts.tokenfile = ifstack[iflevel - 1].file; + ts.tokenoffset = ifstack[iflevel - 1].pos; + CError_SetErrorToken(&ts); + CError_ErrorTerm(CErrorStr119); + iflevel = 0; + return; } - } - break; - default: - skipendofline(); - goto restart; + } else { + CPrep_Error(CErrorStr105); + } + continue; + case '\r': + newline(); + continue; + case '"': + skipendoflinematch((StringPtr) pos, '"'); + continue; + case '\'': + skipendoflinematch((StringPtr) pos, '"'); + continue; + case '#': + t = prepskipnextchar(); + pos = nextcharpos; + switch (t) { + case '\r': + continue; + case 0: + CPrep_Error(CErrorStr102); + default: + pos = ReadIdentifier(pos - 1); + if (!strcmp("if", tkidentifier->name)) { + prepif(); + } else if (!strcmp("ifdef", tkidentifier->name)) { + prepifdef(); + } else if (!strcmp("ifndef", tkidentifier->name)) { + prepifndef(); + } else if (!strcmp("elif", tkidentifier->name)) { + prepelif(); + } else if (!strcmp("else", tkidentifier->name)) { + prepelse(); + } else if (!strcmp("endif", tkidentifier->name)) { + prependif(); + } else { + skipendofline(); + continue; + } + } + break; + default: + skipendofline(); + continue; + } + break; } + break; + case IfState_2: default: return; } @@ -3555,7 +4221,7 @@ static void prepifskip() { } } -void preprocessor() { +void preprocessor(void) { short t; gDirectiveStart = pos - prep_file_start; @@ -3564,7 +4230,7 @@ void preprocessor() { switch (t) { case 0: - CPrep_Error(102); + CPrep_Error(CErrorStr102); case '\r': return; } @@ -3591,7 +4257,7 @@ void preprocessor() { return; } if (!strcmp("error", tkidentifier->name)) { - CPrep_Error(318); + CPrep_Error(CErrorStr318); CError_ResetErrorSkip(); skipendofline(); macrocheck = 1; @@ -3604,7 +4270,7 @@ void preprocessor() { } if (!copts.ANSI_strict) { if (!strcmp("warning", tkidentifier->name)) { - CPrep_Warning(337); + CPrep_Warning(CErrorStr337); skipendofline(); macrocheck = 1; return; @@ -3652,7 +4318,7 @@ void preprocessor() { return; } } - CPrep_Error(104); + CPrep_Error(CErrorStr104); skipendofline(); macrocheck = 1; } @@ -3661,7 +4327,7 @@ SInt32 CPrep_BrowserTokenOffset(FileOffsetInfo *foi) { return foi->tokenoffset; } -SInt32 CPrep_BrowserFileOffset() { +SInt32 CPrep_BrowserFileOffset(void) { if (ts_first < ts_current) return ts_current[-1].tokenoffset + 1; else if (tokenstacklevel) @@ -3693,6 +4359,6 @@ void CPrep_BrowserFilePosition(CPrepFileInfo **fileinfo, SInt32 *offset) { } } -CPrepFileInfo *CPrep_BrowserCurrentFile() { +CPrepFileInfo *CPrep_BrowserCurrentFile(void) { return prep_file; } diff --git a/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c b/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c index 4ea0fb0..4c36aab 100644 --- a/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c +++ b/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c @@ -91,7 +91,7 @@ loop: for (;;) { if (!(c = *(p++))) { if (tokenstacklevel > 0 || p >= (StringPtr) prep_file_end) { - CPrep_Error(103); + CPrep_Error(CErrorStr103); nextcharpos = (char *) p - 1; return c; } @@ -235,7 +235,7 @@ loop: if (!(c = *(p++))) { if (tokenstacklevel > 0 || p >= (StringPtr) prep_file_end) { pos = (char *) p - 1; - CPrep_Error(103); + CPrep_Error(CErrorStr103); return c; } p[-1] = ' '; @@ -411,12 +411,12 @@ void CPrep_MatchChar(char ch, Boolean flag) { loop: if (!(c = *(p++))) { if (tokenstacklevel > 0 || p >= prep_file_end) - CPrep_Error(102); + CPrep_Error(CErrorStr102); else if (ch == '"') - CPrep_Error(101); + CPrep_Error(CErrorStr101); else if (ch == '\'') - CPrep_Error(100); - CPrep_Error(117); + CPrep_Error(CErrorStr100); + CPrep_Error(CErrorStr117); pos = p - 1; return; } @@ -427,7 +427,7 @@ loop: foundnl(); if (*p == '\n') p++; - CPrep_Error(112); + CPrep_Error(CErrorStr112); pos = p; return; } @@ -487,12 +487,12 @@ char *CPrep_MatchChar2(char *start, char ch, Boolean flag) { loop: if (!(c = *(p++))) { if (tokenstacklevel > 0 || p >= prep_file_end) - CPrep_Error(102); + CPrep_Error(CErrorStr102); else if (ch == '"') - CPrep_Error(101); + CPrep_Error(CErrorStr101); else if (ch == '\'') - CPrep_Error(100); - CPrep_Error(117); + CPrep_Error(CErrorStr100); + CPrep_Error(CErrorStr117); return p - 1; } @@ -502,7 +502,7 @@ loop: foundnl(); if (*p == '\n') p++; - CPrep_Error(112); + CPrep_Error(CErrorStr112); return p; } haveBackslash = 0; @@ -700,7 +700,7 @@ static short intsuffix(short token, Boolean flag) { } if ((t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z') || (t == '_') || (t >= '0' && t <= '9')) - CPrep_Error(105); + CPrep_Error(CErrorStr105); if (!is_longlong && !is_long) { if (!is_unsigned && CInt64_IsInRange(tkintconst, stsignedint.size)) @@ -720,7 +720,7 @@ static short intsuffix(short token, Boolean flag) { if (CInt64_IsInURange(tkintconst, stsignedlonglong.size)) return IT_ULONGLONG; } - CError_Error(154); + CError_Error(CErrorStr154); tkintconst = cint64_zero; return IT_INT; } @@ -766,7 +766,7 @@ static short floatsuffix(short token) { } if ((token >= 'a' && token <= 'z') || (token >= 'A' && token <= 'Z') || (token == '_') || (token >= '0' && token <= '9')) { - CPrep_Error(105); + CPrep_Error(CErrorStr105); whichtype = IT_DOUBLE; } @@ -819,7 +819,7 @@ static SInt32 nextchar(StringPtr str) { case 'x': chr = tohex(prepnextstringchar(str, 1)); if (chr == -1) { - CPrep_Error(100); + CPrep_Error(CErrorStr100); return ' '; } out_of_bounds = 0; @@ -830,7 +830,7 @@ static SInt32 nextchar(StringPtr str) { out_of_bounds = 1; } if (out_of_bounds) - CError_Error(100); + CError_Error(CErrorStr100); break; default: if (t >= '0' && t <= '7') { @@ -845,7 +845,7 @@ static SInt32 nextchar(StringPtr str) { i++; } if (out_of_bounds) - CError_Error(100); + CError_Error(CErrorStr100); } else { chr = t; } @@ -1018,7 +1018,7 @@ void skipendofline(void) { if ((ch = *(p++)) == 0) { if (tokenstacklevel > 0 || p >= (StringPtr) prep_file_end) { pos = (char *) p - 1; - CPrep_Error(103); + CPrep_Error(CErrorStr103); return; } p[-1] = ' '; @@ -1084,12 +1084,12 @@ void CPrep_SkipAsmComment(void) { macrocheck = save_macrocheck; } -static short tille(void) { return TK_NEG6; } +static short tille(void) { return TK_ILLEGAL; } static short tcret(void) { newline(); if (cprep_eoltokens) - return TK_NEG7; + return TK_EOL; else return 0; } @@ -1107,7 +1107,7 @@ static short tapos(short _t) { start = (StringPtr) pos; t = nextchar((StringPtr) pos); if ((t == '\'' || t == 0 || t == '\r') && !was_escchar) { - CPrep_Error(100); + CPrep_Error(CErrorStr100); tkintconst = cint64_zero; tksize = IT_INT; return TK_INTCONST; @@ -1170,7 +1170,7 @@ static short tapos(short _t) { while (1) { if ((t2 == 0 || t2 == '\r') && !was_escchar) { - CPrep_Error(100); + CPrep_Error(CErrorStr100); break; } @@ -1183,7 +1183,7 @@ static short tapos(short _t) { break; if (i >= stunsignedlonglong.size) { - CPrep_Error(100); + CPrep_Error(CErrorStr100); break; } } @@ -1237,9 +1237,9 @@ static short tquot(short t) { c = nextchar(start_pos); if ((c == '"' || c == '\r' || c == 0) && !was_escchar) { if (c == 0 && (tokenstacklevel > 0 || pos >= prep_file_end)) - CPrep_Error(102); + CPrep_Error(CErrorStr102); else if (c != '"') - CPrep_Error(101); + CPrep_Error(CErrorStr101); break; } if ((size + type->size) >= maxstringsize) { @@ -1262,7 +1262,7 @@ static short tquot(short t) { if (ispascalstring) { if (size > 255 && type->size == 1) { - CPrep_Error(106); + CPrep_Error(CErrorStr106); size = 255; } CInt64_SetLong(&ch64, size / type->size); @@ -1571,7 +1571,7 @@ static short tzero(short t) { case 'e': pos = CMach_FloatScan(p, &tkfloatconst, &floatFailed); if (floatFailed) - CPrep_Error(154); + CPrep_Error(CErrorStr154); tksize = floatsuffix(prepcurchar()); return TK_FLOATCONST; } @@ -1580,7 +1580,7 @@ static short tzero(short t) { } if (failed) { - CPrep_Error(154); + CPrep_Error(CErrorStr154); tkintconst = cint64_zero; } @@ -1601,7 +1601,7 @@ static short tpoin(void) { if (ch >= '0' && ch <= '9') { pos = CMach_FloatScan(p, &tkfloatconst, &failed); if (failed) - CPrep_Error(154); + CPrep_Error(CErrorStr154); tksize = floatsuffix(prepcurchar()); return TK_FLOATCONST; } @@ -1631,13 +1631,13 @@ static short tnumb(short t) { if (ch == '.' || ch == 'e' || ch == 'E') { pos = CMach_FloatScan(p, &tkfloatconst, &floatFailed); if (floatFailed) - CPrep_Error(154); + CPrep_Error(CErrorStr154); tksize = floatsuffix(prepcurchar()); return TK_FLOATCONST; } if (failed) { - CPrep_Error(154); + CPrep_Error(CErrorStr154); tkintconst = cint64_zero; } @@ -1744,12 +1744,12 @@ static short tchrc(void) { if (copts.cplusplus) { if (!strcmp("const_cast", tkidentifier->name)) { if (copts.ecplusplus) - CPrep_Warning(339); + CPrep_Warning(CErrorStr339); return TK_CONST_CAST; } if (!strcmp("catch", tkidentifier->name)) { if (copts.ecplusplus) - CPrep_Warning(339); + CPrep_Warning(CErrorStr339); return TK_CATCH; } if (!strcmp("class", tkidentifier->name)) @@ -1778,7 +1778,7 @@ static short tchrd(void) { return TK_DELETE; if (!strcmp("dynamic_cast", tkidentifier->name)) { if (copts.ecplusplus) - CPrep_Warning(339); + CPrep_Warning(CErrorStr339); return TK_DYNAMIC_CAST; } } @@ -1875,7 +1875,7 @@ static short tchrm(void) { return 0; if (copts.cplusplus && !strcmp("mutable", tkidentifier->name)) { if (copts.ecplusplus) - CPrep_Warning(339); + CPrep_Warning(CErrorStr339); return TK_MUTABLE; } return TK_IDENTIFIER; @@ -1891,7 +1891,7 @@ static short tchrn(short t) { return TK_NEW; if (!strcmp("namespace", tkidentifier->name)) { if (copts.ecplusplus) - CPrep_Warning(339); + CPrep_Warning(CErrorStr339); return TK_NAMESPACE; } if (!in_assembler && !preprocessing_only) { @@ -1957,7 +1957,7 @@ static short tchrr(void) { return TK_RETURN; if (copts.cplusplus && !strcmp("reinterpret_cast", tkidentifier->name)) { if (copts.ecplusplus) - CPrep_Warning(339); + CPrep_Warning(CErrorStr339); return TK_REINTERPRET_CAST; } if (copts.c9x && !strcmp("restrict", tkidentifier->name)) @@ -1984,7 +1984,7 @@ static short tchrs(void) { return TK_SWITCH; if (copts.cplusplus && !strcmp("static_cast", tkidentifier->name)) { if (copts.ecplusplus) - CPrep_Warning(339); + CPrep_Warning(CErrorStr339); return TK_STATIC_CAST; } return TK_IDENTIFIER; @@ -2006,27 +2006,27 @@ static short tchrt(void) { return TK_TRUE; if (!strcmp("template", tkidentifier->name)) { if (copts.ecplusplus) - CPrep_Warning(339); + CPrep_Warning(CErrorStr339); return TK_TEMPLATE; } if (!strcmp("try", tkidentifier->name)) { if (copts.ecplusplus) - CPrep_Warning(339); + CPrep_Warning(CErrorStr339); return TK_TRY; } if (!strcmp("throw", tkidentifier->name)) { if (copts.ecplusplus) - CPrep_Warning(339); + CPrep_Warning(CErrorStr339); return TK_THROW; } if (!strcmp("typeid", tkidentifier->name)) { if (copts.ecplusplus) - CPrep_Warning(339); + CPrep_Warning(CErrorStr339); return TK_TYPEID; } if (!strcmp("typename", tkidentifier->name)) { if (copts.ecplusplus) - CPrep_Warning(339); + CPrep_Warning(CErrorStr339); return TK_TYPENAME; } } @@ -2044,7 +2044,7 @@ static short tchru(void) { return TK_UNSIGNED; if (copts.cplusplus && !strcmp("using", tkidentifier->name)) { if (copts.ecplusplus) - CPrep_Warning(339); + CPrep_Warning(CErrorStr339); return TK_USING; } return TK_IDENTIFIER; @@ -2151,7 +2151,7 @@ static short tdoll(short t) { static short tisid(void) { if (!tokenstacklevel) - CError_Error(105); + CError_Error(CErrorStr105); return 0; } @@ -2161,7 +2161,7 @@ static short tnull(short t) { return t; } else { pos[-1] = -64; - return TK_NEG6; + return TK_ILLEGAL; } } @@ -2169,7 +2169,7 @@ static short t0x1a(void) { if (*pos == 0) return 0; else - return TK_NEG6; + return TK_ILLEGAL; } typedef short (*TokenizePtr)(short); @@ -2228,7 +2228,7 @@ short lookahead_noeol(void) { CPrep_TokenStreamGetState(&state); do { t = lex(); - } while (t == TK_NEG7); + } while (t == TK_EOL); CPrep_TokenStreamSetState(&state); return t; @@ -2303,7 +2303,7 @@ static void CPrep_StringConCat(Boolean flag) { ch = lex(); elem = --ts_current; memmove(elem, elem + 1, sizeof(TStreamElement) * ts_preread_elements); - } while (ch == TK_NEG7); + } while (ch == TK_EOL); chunk = lalloc(sizeof(StringChunk)); chunk->next = chunks; @@ -2330,7 +2330,7 @@ short lex(void) { short t; while (1) { - if (ts_preread_elements > 0) + if (ts_preread_elements <= 0) break; t = ts_current->tokentype; @@ -2353,7 +2353,7 @@ short lex(void) { tksize = ts_current->data.tkstring.size; ispascalstring = ts_current->subtype; break; - case TK_NEG7: + case TK_EOL: nlflag = 1; if (!cprep_eoltokens) { ts_current++; @@ -2414,7 +2414,7 @@ short lex(void) { return t; } break; - case TK_NEG6: + case TK_ILLEGAL: ts_current++; CError_Error(CErrorStr105); ts_current--; diff --git a/compiler_and_linker/FrontEnd/C/CScope.c b/compiler_and_linker/FrontEnd/C/CScope.c index f15787c..a59a8a7 100644 --- a/compiler_and_linker/FrontEnd/C/CScope.c +++ b/compiler_and_linker/FrontEnd/C/CScope.c @@ -1,17 +1,29 @@ -#include "compiler.h" +#include "compiler/CScope.h" +#include "compiler/CClass.h" +#include "compiler/CDecl.h" #include "compiler/CError.h" #include "compiler/CMangler.h" #include "compiler/CParser.h" #include "compiler/CPrep.h" -#include "compiler/CScope.h" +#include "compiler/CPrepTokenizer.h" +#include "compiler/CTemplateClass.h" +#include "compiler/CTemplateNew.h" +#include "compiler/CTemplateTools.h" +#include "compiler/CompilerTools.h" #include "compiler/enode.h" #include "compiler/objects.h" #include "compiler/scopes.h" #include "compiler/templates.h" #include "compiler/types.h" +typedef enum ELookupType { + Lookup_0, + Lookup_1, + Lookup_2 +} ELookupType; + static Boolean cscope_isambig; -static UInt8 cscope_lookuptype; +static ELookupType cscope_lookuptype; static SInt32 cscope_foundclassoffset; static TemplClass *cscope_foundtemplate; static TypeClass *cscope_foundclass; @@ -23,14 +35,14 @@ TypeClass *cscope_currentclass; NameSpace *cscope_current; NameSpace *cscope_root; -void CScope_Setup() { +void CScope_Setup(void) { cscope_current = cscope_root = CScope_NewHashNameSpace(0); cscope_currentclass = NULL; cscope_currentfunc = NULL; cscope_is_member_func = 0; } -void CScope_Cleanup() { +void CScope_Cleanup(void) { } void CScope_GetScope(CScopeSave *save) { @@ -113,16 +125,15 @@ void CScope_RestoreScope(CScopeSave *saved) { } static Boolean CScope_ObjectIsFunction(Object *obj) { - return obj->otype == OT_OBJECT && obj->type->type == TYPEFUNC; + return obj->otype == OT_OBJECT && IS_TYPE_FUNC(obj->type); } -Boolean CScope_IsEmptySymTable() { +Boolean CScope_IsEmptySymTable(void) { NameSpaceObjectList *scan; NameSpaceName *nsname; int i; -#line 232 - CError_ASSERT(cscope_root->is_hash); + CError_ASSERT(232, cscope_root->is_hash); i = 0; do { @@ -157,9 +168,9 @@ static void CScope_AppendNameSpaceName(NameSpaceName *nsn) { static void CScope_AmbigNameError(NameSpace *nspace1, NameSpace *nspace2, HashNameNode *name) { if (name && nspace1 != nspace2) { - CError_Error(319, CError_GetNameString(nspace1, name), CError_GetNameString(nspace2, name)); + CError_Error(CErrorStr319, CError_GetNameString(nspace1, name), CError_GetNameString(nspace2, name)); } else { - CError_Error(188, nspace2); + CError_Error(CErrorStr188, nspace2); } } @@ -248,8 +259,7 @@ NameSpaceObjectList *CScope_InsertName(NameSpace *nspace, HashNameNode *name) { static NameSpaceObjectList *CScope_AppendName(NameSpace *nspace, HashNameNode *name) { NameSpaceName *nsname; NameSpaceName *scan; -#line 387 - CError_ASSERT(!nspace->is_hash); + CError_ASSERT(387, !nspace->is_hash); if (nspace->is_global) nsname = galloc(sizeof(NameSpaceName)); @@ -327,14 +337,13 @@ restart: case TYPEMEMBERPOINTER: list = CScope_BuildTypeAssociatedNameSpaceList(list, TYPE_MEMBER_POINTER(type)->ty1); type = TYPE_MEMBER_POINTER(type)->ty2; - if (type->type != TYPECLASS) + if (!IS_TYPE_CLASS(type)) break; case TYPECLASS: list = CScope_AddNameSpaceToList(list, TYPE_CLASS(type)->nspace); break; default: -#line 494 - CError_FATAL(); + CError_FATAL(494); } return list; @@ -366,7 +375,7 @@ NameSpaceObjectList *CScope_ArgumentDependentNameLookup(NameSpaceObjectList *lis for (iscan = CScope_FindQualName(scan->nspace, name); iscan; iscan = iscan->next) { if (iscan->object->otype != OT_OBJECT) continue; - if (OBJECT(iscan->object)->type->type != TYPEFUNC) + if (!IS_TYPE_FUNC(OBJECT(iscan->object)->type)) continue; if (flag && (TYPE_FUNC(OBJECT(iscan->object)->type)->flags & FUNC_FLAGS_METHOD)) continue; @@ -441,16 +450,14 @@ Boolean CScope_IsStdNameSpace(NameSpace *nspace) { } Boolean CScope_IsEmptyNameSpace(NameSpace *nspace) { -#line 664 - CError_ASSERT(!nspace->is_hash); + CError_ASSERT(664, !nspace->is_hash); return !nspace->data.list; } void CScope_MergeNameSpace(NameSpace *dst, NameSpace *src) { NameSpaceName *nsname; -#line 678 - CError_ASSERT(!dst->is_hash && !src->is_hash); + CError_ASSERT(678, !dst->is_hash && !src->is_hash); if ((nsname = dst->data.list)) { while (nsname->next) @@ -473,19 +480,19 @@ void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj) { newlist = lalloc(sizeof(NameSpaceObjectList)); if (obj->otype == OT_NAMESPACE || objlist->object->otype == OT_NAMESPACE) { - CError_Error(322/*, objlist->object*/); + CError_Error(CErrorStr322/*, objlist->object*/); return; } if (obj->otype == OT_TYPETAG) { do { if (objlist->object->otype == OT_TYPETAG) { - CError_Error(322/*, objlist->object*/); + CError_Error(CErrorStr322/*, objlist->object*/); return; } if (copts.cplusplus && objlist->object->otype == OT_TYPE && !is_typesame(OBJ_TYPE_TAG(obj)->type, OBJ_TYPE(objlist->object)->type)) { - CError_Error(332); + CError_Error(CErrorStr332); return; } @@ -501,12 +508,11 @@ void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj) { if (objlist->object->otype == OT_TYPETAG) { if (copts.cplusplus && obj->otype == OT_TYPE && !is_typesame(OBJ_TYPE(obj)->type, OBJ_TYPE_TAG(objlist->object)->type)) { - CError_Error(332); + CError_Error(CErrorStr332); return; } -#line 739 - CError_ASSERT(!objlist->next); + CError_ASSERT(739, !objlist->next); newlist->object = objlist->object; newlist->next = NULL; @@ -516,7 +522,7 @@ void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj) { } if (!copts.cplusplus || !CScope_ObjectIsFunction(OBJECT(obj))) { - CError_Error(322); + CError_Error(CErrorStr322); return; } @@ -530,7 +536,7 @@ void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj) { } if (!CScope_ObjectIsFunction(OBJECT(objlist->object))) { - CError_Error(322); + CError_Error(CErrorStr322); return; } @@ -597,8 +603,7 @@ NameSpaceLookupList *CScope_BuildNameSpaceLookupList(NameSpace *nspace) { goto foundIt; } } -#line 853 - CError_FATAL(); + CError_FATAL(853); foundIt: for (current2 = currentL->namespaces; current2; current2 = current2->next) { if (current2->nspace == current->nspace) @@ -718,8 +723,7 @@ restart: case OT_NAMESPACE: return OBJ_NAMESPACE(list->object)->nspace; default: -#line 1052 - CError_FATAL(); + CError_FATAL(1052); break; case OT_ENUMCONST: case OT_MEMBERVAR: @@ -728,10 +732,10 @@ restart: goto restart; } - if (type->type != TYPECLASS) { - if (type->type == TYPETEMPLATE) + if (!IS_TYPE_CLASS(type)) { + if (IS_TYPE_TEMPLATE(type)) return NULL; - CError_Error(320); + CError_Error(CErrorStr320); if (fail) *fail = 1; return NULL; @@ -741,13 +745,13 @@ restart: } static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClass *tclass, SInt32 offset) { - // does not match, r24 and r23 are swapped at the end x.x Boolean fail; NameSpace *nspace; NameSpaceObjectList *list; - ClassList *base; TypeClass *bestClass; - BClassList *bestBase, *n; + BClassList *bestBase; + ClassList *base; + BClassList *n; BClassList *candidate; SInt32 thisoffset; BClassList *newlist; @@ -761,7 +765,7 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas } switch (cscope_lookuptype) { - case 2: + case Lookup_2: fail = 0; if ((nspace = CScope_ExtractNameSpace(list, &fail))) { if (cscope_foundclass) { @@ -780,20 +784,20 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas newlist = lalloc(sizeof(BClassList)); newlist->next = NULL; - newlist->type = (Type *) tclass; + newlist->type = TYPE(tclass); return newlist; } if (fail) return NULL; break; - case 0: + case Lookup_0: if (cscope_foundclass) { if ( list->object->otype == OT_TYPETAG && result->nsol_14->object->otype == OT_TYPETAG - && OBJ_TYPE_TAG(list->object)->type->type == TYPECLASS - && OBJ_TYPE_TAG(result->nsol_14->object)->type->type == TYPECLASS + && IS_TYPE_CLASS(OBJ_TYPE_TAG(list->object)->type) + && IS_TYPE_CLASS(OBJ_TYPE_TAG(result->nsol_14->object)->type) && (TYPE_CLASS(OBJ_TYPE_TAG(list->object)->type)->flags & CLASS_FLAGS_800) && (TYPE_CLASS(OBJ_TYPE_TAG(result->nsol_14->object)->type)->flags & CLASS_FLAGS_800) && TEMPL_CLASS_INST(OBJ_TYPE_TAG(list->object)->type)->templ == TEMPL_CLASS_INST(OBJ_TYPE_TAG(result->nsol_14->object)->type)->templ @@ -816,9 +820,9 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas result->nsol_14 = list; newlist = lalloc(sizeof(BClassList)); newlist->next = NULL; - newlist->type = (Type *) tclass; + newlist->type = TYPE(tclass); return newlist; - case 1: + case Lookup_1: for (; list; list = list->next) { if (list->object->otype == OT_TYPETAG) { if (cscope_foundclass) { @@ -836,14 +840,13 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas result->x8 = OBJ_TYPE_TAG(list->object)->type; newlist = lalloc(sizeof(BClassList)); newlist->next = NULL; - newlist->type = (Type *) tclass; + newlist->type = TYPE(tclass); return newlist; } } break; default: -#line 1202 - CError_FATAL(); + CError_FATAL(1202); } } @@ -852,7 +855,7 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas if ((candidate = CScope_RecFindClassMember(result, base->base, thisoffset))) { n = lalloc(sizeof(BClassList)); n->next = candidate; - n->type = (Type *) tclass; + n->type = TYPE(tclass); if (bestBase && bestClass == cscope_foundclass) { if (CClass_IsMoreAccessiblePath(n, bestBase)) bestBase = n; @@ -866,7 +869,7 @@ static BClassList *CScope_RecFindClassMember(CScopeParseResult *result, TypeClas return bestBase; } -static Boolean CScope_FindClassMember(CScopeParseResult *result, NameSpace *nspace, HashNameNode *name, UInt8 lookupType) { +static Boolean CScope_FindClassMember(CScopeParseResult *result, NameSpace *nspace, HashNameNode *name, ELookupType lookupType) { BClassList *bcl; BClassList *scan; @@ -907,11 +910,11 @@ static BClassList *CScope_GetAccessPathRec(TypeClass *src, TypeClass *dest, SInt if (src == dest) { if (cscope_foundclass && cscope_foundclassoffset != offset) - CError_Error(188); + CError_Error(CErrorStr188); list = lalloc(sizeof(BClassList)); list->next = NULL; - list->type = (Type *) src; + list->type = TYPE(src); cscope_foundclass = src; cscope_foundclassoffset = offset; return list; @@ -925,7 +928,7 @@ static BClassList *CScope_GetAccessPathRec(TypeClass *src, TypeClass *dest, SInt if (best) { list = lalloc(sizeof(BClassList)); list->next = best; - list->type = (Type *) src; + list->type = TYPE(src); return list; } @@ -946,7 +949,7 @@ static NameSpace *CScope_FindLookupNameSpace(CScopeNSIterator *iterator, NameSpa Boolean fail = 0; if (lookup->nspace->theclass) { - if (CScope_FindClassMember(iterator->result, lookup->nspace, name, 2)) { + if (CScope_FindClassMember(iterator->result, lookup->nspace, name, Lookup_2)) { retnspace = iterator->result->nspace_0; iterator->result->nspace_0 = NULL; return retnspace; @@ -1106,7 +1109,7 @@ static NameSpaceObjectList *CScope_NSIteratorFind(CScopeNSIterator *iterator, Ha if (iterator->lookup->namespaces) return CScope_FindLookupName(iterator->lookup, name, NULL); if (iterator->lookup->nspace->theclass) { - if (CScope_FindClassMember(iterator->result, iterator->lookup->nspace, name, 0)) { + if (CScope_FindClassMember(iterator->result, iterator->lookup->nspace, name, Lookup_0)) { list = iterator->result->nsol_14; iterator->result->nsol_14 = NULL; return list; @@ -1119,7 +1122,7 @@ static NameSpaceObjectList *CScope_NSIteratorFind(CScopeNSIterator *iterator, Ha return list; } else { if (iterator->nspace->theclass) { - if (CScope_FindClassMember(iterator->result, iterator->nspace, name, 0)) { + if (CScope_FindClassMember(iterator->result, iterator->nspace, name, Lookup_0)) { list = iterator->result->nsol_14; iterator->result->nsol_14 = NULL; return list; @@ -1163,7 +1166,7 @@ static NameSpace *CScope_NSIteratorFindNameSpace(CScopeNSIterator *iterator, Has if (iterator->lookup->namespaces) return CScope_FindLookupNameSpace(iterator, iterator->lookup, name); if (iterator->lookup->nspace->theclass) { - if (CScope_FindClassMember(iterator->result, iterator->lookup->nspace, name, 2)) { + if (CScope_FindClassMember(iterator->result, iterator->lookup->nspace, name, Lookup_2)) { nspace = iterator->result->nspace_0; iterator->result->nspace_0 = NULL; return nspace; @@ -1176,7 +1179,7 @@ static NameSpace *CScope_NSIteratorFindNameSpace(CScopeNSIterator *iterator, Has return CScope_ExtractNameSpace(list, NULL); } else { if (iterator->nspace->theclass) { - if (CScope_FindClassMember(iterator->result, iterator->nspace, name, 2)) { + if (CScope_FindClassMember(iterator->result, iterator->nspace, name, Lookup_2)) { nspace = iterator->result->nspace_0; iterator->result->nspace_0 = NULL; return nspace; @@ -1196,7 +1199,7 @@ static Boolean CScope_SetupParseNameResult(CScopeParseResult *result, NameSpaceO if (!list->next || list->next->object->otype == OT_TYPETAG) { switch (list->object->otype) { case OT_NAMESPACE: - CError_Error(321); + CError_Error(CErrorStr321); return 0; case OT_TYPE: result->x8 = OBJ_TYPE(list->object)->type; @@ -1207,7 +1210,7 @@ static Boolean CScope_SetupParseNameResult(CScopeParseResult *result, NameSpaceO break; case OT_TYPETAG: result->x8 = OBJ_TYPE_TAG(list->object)->type; - result->xC = NULL; + result->xC = 0; result->obj_10 = list->object; result->name_4 = name; result->x20 = 1; @@ -1226,18 +1229,17 @@ Boolean CScope_FindQualifiedClassMember(CScopeParseResult *result, TypeClass *tc NameSpaceObjectList *list; memclrw(result, sizeof(CScopeParseResult)); - CDecl_CompleteType((Type *) tclass); + CDecl_CompleteType(TYPE(tclass)); - if (CScope_FindClassMember(result, tclass->nspace, name, 0)) { + if (CScope_FindClassMember(result, tclass->nspace, name, Lookup_0)) { list = result->nsol_14; -#line 1780 - CError_ASSERT(list); + CError_ASSERT(1780, list); result->nsol_14 = NULL; if (CScope_SetupParseNameResult(result, list, name) && !result->x8) return 1; else - CError_Error(340, name->name); + CError_Error(CErrorStr340, name->name); } return 0; @@ -1252,7 +1254,7 @@ static NameSpace *CScope_FindQualifiedNameSpace(CScopeParseResult *result, NameS Boolean fail = 0; if (nspace->theclass) { - if (CScope_FindClassMember(result, nspace, name, 2)) { + if (CScope_FindClassMember(result, nspace, name, Lookup_2)) { nspace = result->nspace_0; result->nspace_0 = NULL; return nspace; @@ -1291,8 +1293,8 @@ static NameSpaceObjectList *CScope_FindQualifiedName(CScopeParseResult *result, NameSpaceLookupList *lookup; if (nspace->theclass) { - CDecl_CompleteType((Type *) nspace->theclass); - if (CScope_FindClassMember(result, nspace, name, 0)) { + CDecl_CompleteType(TYPE(nspace->theclass)); + if (CScope_FindClassMember(result, nspace, name, Lookup_0)) { list = result->nsol_14; result->nsol_14 = NULL; return list; @@ -1324,8 +1326,8 @@ static Boolean CScope_FindQualifiedTag(CScopeParseResult *result, NameSpace *nsp NameSpaceList *scan; if (nspace->theclass) { - CDecl_CompleteType((Type *) nspace->theclass); - return CScope_FindClassMember(result, nspace, name, 1) != 0; + CDecl_CompleteType(TYPE(nspace->theclass)); + return CScope_FindClassMember(result, nspace, name, Lookup_1) != 0; } if ((list = CScope_FindQualName(nspace, name))) { @@ -1439,46 +1441,46 @@ Type *CScope_GetTagType(NameSpace *nspace, HashNameNode *name) { } static Boolean CScope_DependentTemplateMember(CScopeParseResult *result, TypeTemplDep *ttempldep, Boolean flag1, Boolean flag2) { - // does not match, sign extension/caching mishap SInt32 streamstate; short token; - short token2; TypeTemplDep *newtype; TypeTemplDep *newtype2; CPrep_TokenStreamGetState(&streamstate); -#line 2026 - CError_ASSERT(lex() == TK_COLON_COLON); + token = lex(); + CError_ASSERT(2026, token == TK_COLON_COLON); - do { + while (1) { token = lex(); if (token == TK_OPERATOR && flag1) { if (!CParser_ParseOperatorName(NULL, 1, 1)) return 0; - newtype = CDecl_NewTemplDepType(TEMPLDEP_QUALNAME); + newtype = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALNAME)); newtype->u.qual.type = ttempldep; newtype->u.qual.name = tkidentifier; CPrep_TokenStreamSetState(&streamstate); lex(); tk = lex(); - result->x8 = (Type *) newtype; + result->x8 = TYPE(newtype); return 1; - } else if (token == TK_TEMPLATE) { + } + + if (token == TK_TEMPLATE) { if (lex() != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } CPrep_TokenStreamGetState(&streamstate); - newtype = CDecl_NewTemplDepType(TEMPLDEP_QUALNAME); + newtype = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALNAME)); newtype->u.qual.type = ttempldep; newtype->u.qual.name = tkidentifier; - if ((token2 = lex()) != '<') { - CError_Error(230); + if ((token = lex()) != '<') { + CError_Error(CErrorStr230); return 0; } - tk = token2; - newtype2 = CDecl_NewTemplDepType(TEMPLDEP_QUALTEMPL); + tk = token; + newtype2 = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALTEMPL)); newtype2->u.qualtempl.type = newtype; newtype2->u.qualtempl.args = CTempl_ParseUncheckTemplArgs(NULL, 1); CPrep_TokenStreamGetState(&streamstate); @@ -1487,27 +1489,29 @@ static Boolean CScope_DependentTemplateMember(CScopeParseResult *result, TypeTem continue; } else { CPrep_TokenStreamSetState(&streamstate); - result->x8 = (Type *) newtype2; + result->x8 = TYPE(newtype2); return 1; } - } else if (token == TK_IDENTIFIER) { - newtype = CDecl_NewTemplDepType(TEMPLDEP_QUALNAME); + } + + if (token == TK_IDENTIFIER) { + newtype = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALNAME)); newtype->u.qual.type = ttempldep; newtype->u.qual.name = tkidentifier; tk = token; CPrep_TokenStreamGetState(&streamstate); - token2 = lex(); + token = lex(); tkidentifier = newtype->u.qual.name; - if (token2 == TK_COLON_COLON) { + if (token == TK_COLON_COLON) { ttempldep = newtype; continue; } - if ((token2 == '<') && !flag2) { - tk = token2; + if ((token == '<') && !flag2) { + tk = token; newtype2 = newtype; - newtype = CDecl_NewTemplDepType(TEMPLDEP_QUALTEMPL); + newtype = TYPE_TEMPLATE(CDecl_NewTemplDepType(TEMPLDEP_QUALTEMPL)); newtype->u.qualtempl.type = newtype2; newtype->u.qualtempl.args = CTempl_ParseUncheckTemplArgs(NULL, 1); @@ -1519,35 +1523,40 @@ static Boolean CScope_DependentTemplateMember(CScopeParseResult *result, TypeTem } CPrep_TokenStreamSetState(&streamstate); - result->x8 = (Type *) newtype; - return 1; - } else { - CPrep_TokenStreamSetState(&streamstate); - result->x8 = (Type *) ttempldep; + result->x8 = TYPE(newtype); return 1; } - } while (1); + + CPrep_TokenStreamSetState(&streamstate); + result->x8 = TYPE(ttempldep); + return 1; + } } static Boolean CScope_CheckDtorName(TypeClass *tclass, Boolean *flag) { if ((tk = lex()) != TK_IDENTIFIER) - CError_Error(107); + CError_Error(CErrorStr107); if (tclass) { *flag = 0; - if ((tclass->classname == tkidentifier) || (CScope_GetType(tclass->nspace, tkidentifier, NULL) == (Type *) tclass) || (CScope_GetType(cscope_current, tkidentifier, NULL) == (Type *) tclass)) { + if ( + (tclass->classname == tkidentifier) || + (CScope_GetType(tclass->nspace, tkidentifier, NULL) == TYPE(tclass)) || + (CScope_GetType(cscope_current, tkidentifier, NULL) == TYPE(tclass)) + ) + { if (!CClass_Destructor(tclass)) *flag = 1; if ((tclass->flags & CLASS_FLAGS_800) && (lookahead() == '<')) { tk = lex(); if (!CTemplTool_EqualArgs(TEMPL_CLASS_INST(tclass)->inst_args, CTempl_ParseUncheckTemplArgs(NULL, 0))) - CError_Error(374); + CError_Error(CErrorStr374); } return 1; } } - CError_Error(141); + CError_Error(CErrorStr141); return 0; } @@ -1561,7 +1570,7 @@ static Boolean CScope_ParseQualifiedName(CScopeParseResult *result, NameSpace *n switch (tk) { case TK_TEMPLATE: if ((tk = lex()) != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } case TK_IDENTIFIER: @@ -1589,7 +1598,7 @@ static Boolean CScope_ParseQualifiedName(CScopeParseResult *result, NameSpace *n flag = 1; break; default: - CError_Error(107); + CError_Error(CErrorStr107); return 0; } @@ -1599,13 +1608,13 @@ static Boolean CScope_ParseQualifiedName(CScopeParseResult *result, NameSpace *n return 1; } if (nspace->theclass && !(nspace->theclass->flags & CLASS_FLAGS_2)) - CError_Error(136, nspace->theclass, 0); + CError_Error(CErrorStr136, nspace->theclass, 0); else - CError_Error(140, saveidentifier->name); + CError_Error(CErrorStr140, saveidentifier->name); return 0; } - if (result->x8 && (result->x8->type == TYPECLASS) && (lookahead() == '<')) { + if (result->x8 && IS_TYPE_CLASS(result->x8) && (lookahead() == '<')) { tclass = TYPE_CLASS(result->x8); if (tclass->flags & CLASS_FLAGS_800) tclass = TYPE_CLASS(TEMPL_CLASS_INST(tclass)->templ); @@ -1613,8 +1622,8 @@ static Boolean CScope_ParseQualifiedName(CScopeParseResult *result, NameSpace *n return 1; tk = lex(); - result->x8 = CTempl_ClassGetType(tclass); - if ((result->x8->type == TYPECLASS) && (lookahead() == TK_COLON_COLON)) { + result->x8 = CTempl_ClassGetType(TEMPL_CLASS(tclass)); + if (IS_TYPE_CLASS(result->x8) && (lookahead() == TK_COLON_COLON)) { lex(); tk = lex(); result->x1D = 1; @@ -1638,7 +1647,7 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) { if (!copts.cplusplus) { memclrw(result, sizeof(CScopeParseResult)); if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } @@ -1658,8 +1667,7 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) { if ((tk == TK_COLON_COLON || tk == TK_IDENTIFIER) && CScope_ParseQualifiedNameSpace(result, 1, 1)) { if (result->x8) return 1; -#line 2313 - CError_ASSERT(result->nspace_0); + CError_ASSERT(2313, result->nspace_0); } else { memclrw(result, sizeof(CScopeParseResult)); result->nspace_0 = cscope_current; @@ -1668,10 +1676,10 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) { switch (tk) { case TK_TEMPLATE: if (!result->x1D) - CError_Error(373); + CError_Error(CErrorStr373); if ((tk = lex()) != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } case TK_IDENTIFIER: @@ -1693,13 +1701,13 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) { name = destructor_name_node; break; default: - CError_Error(107); + CError_Error(CErrorStr107); return 0; } if (result->x1D) { if (!(list = CScope_FindQualifiedName(result, result->nspace_0, name, &result->nspace_0))) { - CError_Error(140, CError_GetNameString(result->nspace_0, name)); + CError_Error(CErrorStr140, CError_GetNameString(result->nspace_0, name)); return 0; } else { return CScope_SetupParseNameResult(result, list, name); @@ -1715,7 +1723,7 @@ Boolean CScope_ParseExprName(CScopeParseResult *result) { } while (CScope_NSIteratorNext(&iterator)); if (result->x1D) { - CError_Error(140, name->name); + CError_Error(CErrorStr140, name->name); return 0; } else { result->nspace_0 = cscope_current; @@ -1737,7 +1745,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) { if (!copts.cplusplus) { non_cpp_mode: if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } memclrw(result, sizeof(CScopeParseResult)); @@ -1756,7 +1764,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) { return 0; } else { if ((tk != TK_COLON_COLON) && (tk != TK_IDENTIFIER)) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } @@ -1767,8 +1775,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) { return 1; nspace = result->nspace_0; -#line 2435 - CError_ASSERT(nspace); + CError_ASSERT(2435, nspace); switch (tk) { case TK_OPERATOR: @@ -1779,7 +1786,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) { } CScope_RestoreScope(&save); if (op) - CError_Error(121); + CError_Error(CErrorStr121); result->x21 = 1; return 1; case TK_IDENTIFIER: @@ -1789,26 +1796,26 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) { break; case '~': if (!nspace->theclass) { - CError_Error(121); + CError_Error(CErrorStr121); return 0; } tk = lex(); if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } if (nspace->theclass->classname != tkidentifier) - CError_Error(121); + CError_Error(CErrorStr121); name = destructor_name_node; break; default: - CError_Error(107); + CError_Error(CErrorStr107); return 0; } if (result->x1D) { if (!(list = CScope_FindQualifiedName(result, result->nspace_0, name, &result->nspace_0))) { - CError_Error(140, name->name); + CError_Error(CErrorStr140, name->name); return 0; } else { return CScope_SetupParseNameResult(result, list, name); @@ -1823,7 +1830,7 @@ Boolean CScope_ParseDeclName(CScopeParseResult *result) { } } while (CScope_NSIteratorNext(&iterator)); - CError_Error(140, name->name); + CError_Error(CErrorStr140, name->name); return 0; } } @@ -1851,9 +1858,9 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, if (tk != TK_TEMPLATE) return nspace != NULL; if (!result->x1D) - CError_Error(373); + CError_Error(CErrorStr373); if ((tk = lex()) != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } } @@ -1871,12 +1878,11 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, // list = r21 for (list = CScope_NSIteratorFind(&iterator, name); list; list = list->next) { if (list->object->otype == OT_NAMESPACE) { -#line 2565 - CError_ASSERT(!nspace || !nspace->theclass); + CError_ASSERT(2565, !nspace || !nspace->theclass); result->nspace_0 = nspace = OBJ_NAMESPACE(list->object)->nspace; if ((tk = lex()) != TK_COLON_COLON) { - CError_Error(321); + CError_Error(CErrorStr321); return 0; } @@ -1891,24 +1897,23 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, result->x8 = type; return 1; } else { - CError_Error(121); + CError_Error(CErrorStr121); return 0; } } parse_thing: if (t == '<') { if (TYPE_CLASS(type)->flags & CLASS_FLAGS_800) { - type = (Type *) TEMPL_CLASS_INST(type)->templ; + type = TYPE(TEMPL_CLASS_INST(type)->templ); } else if (!(TYPE_CLASS(type)->flags & CLASS_FLAGS_100)) { result->x8 = type; return 1; } } if ((tk = lex()) == '<') { -#line 2609 - CError_ASSERT(TYPE_CLASS(type)->flags & CLASS_FLAGS_100); - type2 = CTempl_ClassGetType(TYPE_CLASS(type)); - if (type2->type == TYPETEMPLATE) { + CError_ASSERT(2609, TYPE_CLASS(type)->flags & CLASS_FLAGS_100); + type2 = CTempl_ClassGetType(TEMPL_CLASS(type)); + if (IS_TYPE_TEMPLATE(type2)) { if (lookahead() != TK_COLON_COLON) { result->x8 = type2; return 1; @@ -1926,8 +1931,7 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, tk = lex(); CDecl_CompleteType(type2); } else { -#line 2632 - CError_ASSERT(tk == TK_COLON_COLON); + CError_ASSERT(2632, tk == TK_COLON_COLON); if (!(TYPE_CLASS(type)->flags & CLASS_FLAGS_100) || CParser_CheckTemplateClassUsage(TEMPL_CLASS(type), 1)) result->nspace_0 = nspace = TYPE_CLASS(type)->nspace; CDecl_CompleteType(type); @@ -1939,10 +1943,10 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, } if (list->object->otype == OT_TYPE) { type2 = OBJ_TYPE(list->object)->type; - if (type2->type != TYPECLASS) { - if (type2->type == TYPETEMPLATE) { + if (!IS_TYPE_CLASS(type2)) { + if (IS_TYPE_TEMPLATE(type2)) { if (TYPE_TEMPLATE(type2)->dtype == TEMPLDEP_ARGUMENT && TYPE_TEMPLATE(type2)->u.pid.type == TPT_TEMPLATE) { - type2 = CTempl_ParseTemplTemplParam(type2); + type2 = CTempl_ParseTemplTemplParam(TYPE_TEMPLATE(type2)); if ((type2->type != TYPETEMPLATE) || ((t = lookahead()) != TK_COLON_COLON)) { result->x8 = type2; return 1; @@ -1955,7 +1959,7 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, result->x8 = type2; return 1; } else { - CError_Error(121); + CError_Error(CErrorStr121); return 0; } } else { @@ -1967,8 +1971,7 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, result->x8 = type2; return 1; } -#line 2686 - CError_ASSERT(tk == TK_COLON_COLON); + CError_ASSERT(2686, tk == TK_COLON_COLON); if (!type2->size) CDecl_CompleteType(type2); result->nspace_0 = nspace = TYPE_CLASS(type2)->nspace; @@ -1982,7 +1985,7 @@ Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, } } while (CScope_NSIteratorNext(&iterator)); - CError_Error(140, name->name); + CError_Error(CErrorStr140, name->name); return 0; } @@ -1995,7 +1998,7 @@ Boolean CScope_ParseElaborateName(CScopeParseResult *result) { if (!copts.cplusplus) { memclrw(result, sizeof(CScopeParseResult)); if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } @@ -2014,32 +2017,31 @@ Boolean CScope_ParseElaborateName(CScopeParseResult *result) { return 1; } else { if ((tk != TK_COLON_COLON) && (tk != TK_IDENTIFIER)) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } if (!CScope_ParseQualifiedNameSpace(result, 0, 0)) { result->nspace_0 = cscope_current; if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } name = tkidentifier; } else { if (result->x8) return 1; -#line 2760 - CError_ASSERT(result->nspace_0); + CError_ASSERT(2760, result->nspace_0); if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return 0; } name = tkidentifier; if (result->x1D) { if (result->nspace_0->theclass) - return CScope_FindClassMember(result, result->nspace_0, name, 1) != 0; + return CScope_FindClassMember(result, result->nspace_0, name, Lookup_1) != 0; else return CScope_FindQualifiedTag(result, result->nspace_0, name); } @@ -2145,7 +2147,7 @@ Boolean CScope_FindClassMemberObject(TypeClass *tclass, CScopeParseResult *resul memclrw(result, sizeof(CScopeParseResult)); - if (CScope_FindClassMember(result, tclass->nspace, name, 0)) { + if (CScope_FindClassMember(result, tclass->nspace, name, Lookup_0)) { list = result->nsol_14; result->nsol_14 = NULL; if (list && list->object->otype == OT_OBJECT) @@ -2285,7 +2287,7 @@ NameSpaceObjectList *CScope_GetLocalObject(NameSpace *nspace, HashNameNode *name case OT_OBJECT: return CScope_GetLocalObjects(list); default: - CError_Error(122, name->name); + CError_Error(CErrorStr122, name->name); return NULL; case OT_TYPETAG: break; @@ -2323,7 +2325,7 @@ BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass) { list = CScope_GetBaseAccessPathEnd(list); for (scan = list; scan; scan = scan->next) { - if (scan->type == (Type *) tclass) + if (scan->type == TYPE(tclass)) return scan; } @@ -2334,8 +2336,7 @@ BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass) { return list2; } } -#line 3217 - CError_FATAL(); + CError_FATAL(3217); } return NULL; @@ -2344,9 +2345,9 @@ BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass) { static Boolean CScope_FixMemberResult(TypeClass *tclass, CScopeParseResult *result) { if (!(result->bcl_18 = CScope_GetClassAccessPath(result->bcl_18, tclass))) { if (result->name_4) - CError_Error(150, result->name_4->name); + CError_Error(CErrorStr150, result->name_4->name); else - CError_Error(328); + CError_Error(CErrorStr328); return 0; } else { return 1; @@ -2364,10 +2365,10 @@ Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boo if (!CScope_ParseExprName(result)) return 0; - if (result->x8 && result->x8->type == TYPETEMPLATE && TYPE_TEMPLATE(result->x8)->dtype == TEMPLDEP_QUALNAME) { + if (result->x8 && IS_TYPE_TEMPLATE(result->x8) && TYPE_TEMPLATE(result->x8)->dtype == TEMPLDEP_QUALNAME) { if (flag) return 1; - CError_Error(340, TYPE_TEMPLATE(result->x8)->u.qual.name->name); + CError_Error(CErrorStr340, TYPE_TEMPLATE(result->x8)->u.qual.name->name); result->x8 = NULL; return 0; } @@ -2385,7 +2386,7 @@ Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boo switch (t) { case TK_COLON_COLON: memclrw(result, sizeof(CScopeParseResult)); - if (!CScope_FindClassMember(result, tclass->nspace, name, 2)) + if (!CScope_FindClassMember(result, tclass->nspace, name, Lookup_2)) goto restart; break; case '<': @@ -2402,7 +2403,7 @@ Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boo } if (!(list = CScope_FindQualifiedName(result, tclass->nspace, destructor_name_node, &result->nspace_0))) { - CError_Error(140, CError_GetNameString(result->nspace_0, destructor_name_node)); + CError_Error(CErrorStr140, CError_GetNameString(result->nspace_0, destructor_name_node)); return 0; } else { return CScope_SetupParseNameResult(result, list, destructor_name_node); @@ -2424,7 +2425,7 @@ static void CScope_AddUsingObject(BClassList *bcl, NameSpace *nspace, ObjBase *o if (bcl) { if (!nspace->theclass) - CError_Error(200); + CError_Error(CErrorStr200); else CClass_CheckPathAccess(bcl, NULL, obj->access); } @@ -2461,15 +2462,15 @@ static void CScope_AddUsingObject(BClassList *bcl, NameSpace *nspace, ObjBase *o *OBJ_MEMBER_VAR(copy) = *OBJ_MEMBER_VAR(obj); copy->access = access; pathcopy = CScope_GetClassAccessPath(CClass_GetPathCopy(bcl, 1), nspace->theclass); - if (pathcopy && pathcopy->type == (Type *) nspace->theclass) { + if (pathcopy && pathcopy->type == TYPE(nspace->theclass)) { OBJ_MEMBER_VAR_PATH(copy)->has_path = 1; OBJ_MEMBER_VAR_PATH(copy)->path = pathcopy; } else { - CError_Error(221); + CError_Error(CErrorStr221); } CScope_AddObject(nspace, OBJ_MEMBER_VAR(copy)->name, copy); } else { - CError_Error(221); + CError_Error(CErrorStr221); } } else if (obj->otype == OT_OBJECT) { if (!nspace->theclass) { @@ -2492,17 +2493,17 @@ static void CScope_AddUsingObject(BClassList *bcl, NameSpace *nspace, ObjBase *o OBJECT(copy)->u.alias.member = NULL; OBJECT(copy)->u.alias.offset = 0; - if (OBJECT(copy)->type->type == TYPEFUNC && (TYPE_FUNC(OBJECT(copy)->type)->flags & FUNC_FLAGS_METHOD) && !TYPE_METHOD(OBJECT(copy)->type)->x26) { + if (IS_TYPE_NONSTATIC_METHOD(OBJECT(copy)->type)) { if (!(tclass = nspace->theclass) || !(OBJECT(copy)->u.alias.member = CScope_GetClassAccessPath( - CClass_GetPathCopy(bcl, 1), tclass)) || (OBJECT(copy)->u.alias.member->type != (Type *) nspace->theclass)) { - CError_Error(221); + CClass_GetPathCopy(bcl, 1), tclass)) || (OBJECT(copy)->u.alias.member->type != TYPE(nspace->theclass))) { + CError_Error(CErrorStr221); OBJECT(copy)->u.alias.member = NULL; } } CScope_AddObject(nspace, OBJECT(copy)->name, copy); } else { - CError_Error(200); + CError_Error(CErrorStr200); } } @@ -2511,8 +2512,8 @@ void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, Hash NameSpaceObjectList *scan; memclrw(&result, sizeof(CScopeParseResult)); - if (!CScope_FindClassMember(&result, tclass2->nspace, name, 0) || !CScope_FixMemberResult(tclass, &result)) { - CError_Error(340, name->name); + if (!CScope_FindClassMember(&result, tclass2->nspace, name, Lookup_0) || !CScope_FixMemberResult(tclass, &result)) { + CError_Error(CErrorStr340, name->name); return; } @@ -2530,32 +2531,34 @@ void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, Hash if (result.obj_10) CScope_AddUsingObject(result.bcl_18, tclass->nspace, result.obj_10, result.name_4, access); else - CError_Error(340, name->name); + CError_Error(CErrorStr340, name->name); } } -void CScope_ParseUsingDeclaration(NameSpace *nspace, short access, Boolean flag) { - // almost matches, slight bit of register weirdness +void CScope_ParseUsingDeclaration(NameSpace *nspace, AccessType access, Boolean flag) { + NameSpace *saveNSpace; + Boolean flag_r27; + Boolean flag_r26; + NameSpaceObjectList *scan; CScopeParseResult result; if (nspace->theclass) { - Boolean flag_r27 = (TYPE_CLASS(nspace->theclass)->flags & CLASS_FLAGS_100) ? 1 : 0; - Boolean flag_r26 = 0; + flag_r27 = (TYPE_CLASS(nspace->theclass)->flags & CLASS_FLAGS_100) ? 1 : 0; + flag_r26 = 0; if (tk == TK_TYPENAME) { if (!flag_r27) - CError_Error(200); + CError_Error(CErrorStr200); flag_r26 = 1; tk = lex(); } if (!CScope_ParseMemberName(nspace->theclass, &result, flag_r27)) { - CError_Error(200); + CError_Error(CErrorStr200); return; } - if (result.x8 && result.x8->type == TYPETEMPLATE && TYPE_TEMPLATE(result.x8)->dtype == TEMPLDEP_QUALNAME) { -#line 3578 - CError_ASSERT(flag_r27); + if (result.x8 && IS_TYPE_TEMPLATE(result.x8) && TYPE_TEMPLATE(result.x8)->dtype == TEMPLDEP_QUALNAME) { + CError_ASSERT(3578, flag_r27); if (flag_r26) { ObjType *objtype = galloc(sizeof(ObjType)); @@ -2565,32 +2568,34 @@ void CScope_ParseUsingDeclaration(NameSpace *nspace, short access, Boolean flag) objtype->type = result.x8; CScope_AddObject(nspace, TYPE_TEMPLATE(result.x8)->u.qual.name, OBJ_BASE(objtype)); } else { - CTemplClass_RegisterUsingDecl(TEMPL_CLASS(nspace->theclass), result.x8, access); + CTemplClass_RegisterUsingDecl( + TEMPL_CLASS(nspace->theclass), + TYPE_TEMPLATE(result.x8), + access); } if ((tk = lex()) != ';') - CError_Error(123); + CError_Error(CErrorStr123); return; } if (!result.x1D) { - CError_Error(200); + CError_Error(CErrorStr200); return; } } else { - NameSpace *savenspace = cscope_current; + saveNSpace = cscope_current; cscope_current = nspace; if (!CScope_ParseExprName(&result) || !result.x1D) { - cscope_current = savenspace; - CError_Error(200); + cscope_current = saveNSpace; + CError_Error(CErrorStr200); return; } else { - cscope_current = savenspace; + cscope_current = saveNSpace; } } if (result.nsol_14) { - NameSpaceObjectList *scan; for (scan = result.nsol_14; scan; scan = scan->next) { if (scan->object->otype == OT_OBJECT) CScope_AddUsingObject(result.bcl_18, nspace, scan->object, result.name_4, access); @@ -2599,11 +2604,11 @@ void CScope_ParseUsingDeclaration(NameSpace *nspace, short access, Boolean flag) if (result.obj_10) CScope_AddUsingObject(result.bcl_18, nspace, result.obj_10, result.name_4, access); else - CError_Error(200); + CError_Error(CErrorStr200); } if ((tk = lex()) != ';') - CError_Error(123); + CError_Error(CErrorStr123); } static NameSpace *CScope_ParseQualifiedNamespaceSpecifier(NameSpace *nspace) { @@ -2620,7 +2625,7 @@ static NameSpace *CScope_ParseQualifiedNamespaceSpecifier(NameSpace *nspace) { do { if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); break; } @@ -2631,7 +2636,7 @@ static NameSpace *CScope_ParseQualifiedNamespaceSpecifier(NameSpace *nspace) { goto some_goto; } } while (CScope_NSIteratorNext(&iterator)); - CError_Error(140, tkidentifier->name); + CError_Error(CErrorStr140, tkidentifier->name); some_goto: if ((tk = lex()) != TK_COLON_COLON) break; @@ -2656,17 +2661,17 @@ void CScope_ParseNameSpaceAlias(HashNameNode *name) { objns->nspace = CScope_ParseQualifiedNamespaceSpecifier(cscope_current); CScope_AddObject(cscope_current, name, OBJ_BASE(objns)); } else if (list->object->otype != OT_NAMESPACE) { - CError_Error(320); + CError_Error(CErrorStr320); tk = lex(); CScope_ParseQualifiedNamespaceSpecifier(cscope_current); } else { tk = lex(); if (CScope_ParseQualifiedNamespaceSpecifier(cscope_current) != OBJ_NAMESPACE(list->object)->nspace) - CError_Error(122, name->name); + CError_Error(CErrorStr122, name->name); } if (tk != ';') - CError_Error(123); + CError_Error(CErrorStr123); } void CScope_ParseUsingDirective(NameSpace *nspace) { @@ -2686,9 +2691,9 @@ void CScope_ParseUsingDirective(NameSpace *nspace) { nspace->usings = list; } } else { - CError_Error(321); + CError_Error(CErrorStr321); } if (tk != ';') - CError_Error(123); + CError_Error(CErrorStr123); } diff --git a/compiler_and_linker/FrontEnd/Common/CompilerTools.c b/compiler_and_linker/FrontEnd/Common/CompilerTools.c index 131aa8e..fff4809 100644 --- a/compiler_and_linker/FrontEnd/Common/CompilerTools.c +++ b/compiler_and_linker/FrontEnd/Common/CompilerTools.c @@ -53,7 +53,7 @@ unsigned char *CTool_CtoPstr(char *cstr) { return (unsigned char *) cstr; } -static void GListError() { +static void GListError(void) { if (GListErrorProc) GListErrorProc(); } @@ -465,7 +465,7 @@ HashNameNode *GetHashNameNodeByID(SInt32 id) { return NULL; } -void NameHashExportReset() { +void NameHashExportReset(void) { HashNameNode *node; short i; @@ -540,13 +540,13 @@ void NameHashWriteTargetEndianNameTable(GList *glist) { AppendGListByte(glist, 0); } -void InitNameHash() { +void InitNameHash(void) { name_hash_nodes = galloc(2048 * sizeof(HashNameNode *)); memclrw(name_hash_nodes, 2048 * sizeof(HashNameNode *)); hash_name_id = 1; } -SInt32 CTool_TotalHeapSize() { +SInt32 CTool_TotalHeapSize(void) { HeapBlock *blockp; SInt32 size = 0; @@ -718,7 +718,7 @@ short initgheap(heaperror_t heaperrorproc) { return 0; } -heaperror_t getheaperror() { +heaperror_t getheaperror(void) { return heaperror; } @@ -740,7 +740,7 @@ static void relheap(HeapMem *heapp) { memclrw(heapp, sizeof(HeapMem)); } -void releaseheaps() { +void releaseheaps(void) { relheap(&gheap); relheap(&lheap); relheap(&aheap); @@ -748,11 +748,11 @@ void releaseheaps() { relheap(&bheap); } -void releasegheap() { +void releasegheap(void) { relheap(&gheap); } -void releaseoheap() { +void releaseoheap(void) { relheap(&gheap); oheap.allocsize = 0x40000; MoreHeapSpace(&oheap, 0); @@ -823,17 +823,16 @@ void *balloc(SInt32 s) { return cp; } -void locklheap() { +void locklheap(void) { lheaplockcount++; } -void unlocklheap() { +void unlocklheap(void) { if (lheaplockcount > 0) --lheaplockcount; } -void freelheap() { - // possible inline or macro? +void freelheap(void) { HeapBlock *blockp; if (lheaplockcount == 0) { @@ -849,7 +848,7 @@ void freelheap() { } } -void freeaheap() { +void freeaheap(void) { HeapBlock *blockp; blockp = aheap.blocks; @@ -863,7 +862,7 @@ void freeaheap() { } } -void freeoheap() { +void freeoheap(void) { HeapBlock *blockp; blockp = oheap.blocks; @@ -877,7 +876,7 @@ void freeoheap() { } } -void freebheap() { +void freebheap(void) { HeapBlock *blockp; blockp = bheap.blocks; diff --git a/compiler_and_linker/unsorted/AddPropagation.c b/compiler_and_linker/unsorted/AddPropagation.c index 2084f75..f0e2b32 100644 --- a/compiler_and_linker/unsorted/AddPropagation.c +++ b/compiler_and_linker/unsorted/AddPropagation.c @@ -51,8 +51,8 @@ static int addpropagatestouse(int candidateID, int useID) { return 0; } - if (useInstr->flags & (fPCodeFlag2 | fPCodeFlag4)) { - if (PCODE_FLAG_SET_F(useInstr) & fPCodeFlag2000000) + if (useInstr->flags & (fIsRead | fIsWrite)) { + if (PCODE_FLAG_SET_F(useInstr) & fUpdatesPtr) return 0; } else if (useInstr->op == PC_ADDI) { if (useInstr->args[2].kind != PCOp_IMMEDIATE) @@ -124,7 +124,7 @@ static int addpropagatestouse(int candidateID, int useID) { } if ( - (useInstr->flags & fPCodeFlag4) && + (useInstr->flags & fIsWrite) && useInstr->args[0].kind == PCOp_REGISTER && useInstr->args[0].arg == RegClass_GPR && useInstr->args[0].data.reg.reg == reg1 @@ -168,7 +168,7 @@ static int addpropagatestouse(int candidateID, int useID) { } } - if ((useInstr->flags & (fPCodeFlag2 | fPCodeFlag4 | fPCodeFlag20000 | fPCodeFlag40000)) && object) + if ((useInstr->flags & (fIsRead | fIsWrite | fPCodeFlag20000 | fPCodeFlag40000)) && object) useInstr->alias = make_alias(object, offset, nbytes_loaded_or_stored_by(useInstr)); return 1; @@ -190,10 +190,10 @@ static void propagateandremoveadd(int id) { useInstr = Uses[list->id].pcode; if (instr->op == PC_ADD) { - if (useInstr->flags & (fPCodeFlag2 | fPCodeFlag4)) { + if (useInstr->flags & (fIsRead | fIsWrite)) { if (useInstr->args[2].kind != PCOp_REGISTER) { useInstr->op += 2; - useInstr->flags |= fPCodeFlag20; + useInstr->flags |= fIsPtrOp; } useInstr->args[1] = instr->args[1]; useInstr->args[2] = instr->args[2]; @@ -227,13 +227,13 @@ static void propagateandremoveadd(int id) { SInt32 newValue = useInstr->args[2].data.imm.value + instr->args[2].data.imm.value; useInstr->args[2] = instr->args[2]; useInstr->args[2].data.imm.value = newValue; - useInstr->flags |= fPCodeFlag20; + useInstr->flags |= fIsPtrOp; } else if (instr->args[2].kind == PCOp_MEMORY) { SInt32 newValue = useInstr->args[2].data.imm.value + instr->args[2].data.mem.offset; useInstr->args[2] = instr->args[2]; useInstr->args[2].data.mem.offset = newValue; - useInstr->flags &= ~fPCodeFlag20; - if (useInstr->flags & (fPCodeFlag2 | fPCodeFlag4 | fPCodeFlag20000 | fPCodeFlag40000)) + useInstr->flags &= ~fIsPtrOp; + if (useInstr->flags & (fIsRead | fIsWrite | fPCodeFlag20000 | fPCodeFlag40000)) useInstr->alias = make_alias( useInstr->args[2].data.mem.obj, useInstr->args[2].data.mem.offset, diff --git a/compiler_and_linker/unsorted/Alias.c b/compiler_and_linker/unsorted/Alias.c index 4a2f176..d8d883d 100644 --- a/compiler_and_linker/unsorted/Alias.c +++ b/compiler_and_linker/unsorted/Alias.c @@ -257,7 +257,7 @@ static int addresspropagatestouse(int candidateID, int useID) { CError_ASSERT(478, object->otype == OT_OBJECT); - if ((candidate_pcode->flags & (fPCodeFlag2 | fPCodeFlag4)) && (candidate_pcode->flags & fPCodeFlag2000000)) { + if ((candidate_pcode->flags & (fIsRead | fIsWrite)) && (candidate_pcode->flags & fUpdatesPtr)) { reg = candidate_pcode->args[1].data.reg.reg; offset = 0; flag24 = 1; @@ -282,7 +282,7 @@ static int addresspropagatestouse(int candidateID, int useID) { } if ( - !(use_pcode->flags & (fPCodeFlag2 | fPCodeFlag4)) && + !(use_pcode->flags & (fIsRead | fIsWrite)) && use_pcode->op != PC_ADDI && use_pcode->op != PC_ADD && use_pcode->op != PC_ADDIS @@ -293,7 +293,7 @@ static int addresspropagatestouse(int candidateID, int useID) { } if ( - (use_pcode->flags & (fPCodeFlag4 | fPCodeFlag40000)) && + (use_pcode->flags & (fIsWrite | fPCodeFlag40000)) && use_pcode->args[0].kind == PCOp_REGISTER && use_pcode->args[0].arg == RegClass_GPR && use_pcode->args[0].data.reg.reg == reg && @@ -363,7 +363,7 @@ static int addresspropagatestouse(int candidateID, int useID) { add_alias_member(worst_case, make_alias(object, 0, 0)); } - if (use_pcode->flags & (fPCodeFlag2 | fPCodeFlag4)) + if (use_pcode->flags & (fIsRead | fIsWrite)) size = nbytes_loaded_or_stored_by(use_pcode); if (use_pcode->args[2].kind == PCOp_REGISTER) { @@ -435,7 +435,7 @@ static int addresspropagatestouse(int candidateID, int useID) { use_pcode->op == PC_ADDI || use_pcode->op == PC_ADD || use_pcode->op == PC_ADDIS || - ((candidate_pcode->flags & (fPCodeFlag2 | fPCodeFlag4)) && (candidate_pcode->flags & fPCodeFlag2000000)) + ((candidate_pcode->flags & (fIsRead | fIsWrite)) && (candidate_pcode->flags & fUpdatesPtr)) ) recursive_propagation = 1; } @@ -454,7 +454,7 @@ static int addresspropagatestouse(int candidateID, int useID) { use_pcode->op == PC_ADDI || use_pcode->op == PC_ADD || use_pcode->op == PC_ADDIS || - ((use_pcode->flags & (fPCodeFlag2 | fPCodeFlag4)) && (use_pcode->flags & fPCodeFlag2000000)) + ((use_pcode->flags & (fIsRead | fIsWrite)) && (use_pcode->flags & fUpdatesPtr)) ) { if (alias->type == AliasType2) add_alias_member(worst_case, alias); @@ -519,15 +519,15 @@ void gather_alias_info(void) { bitvectorcopy(myvec, usedefinfo[block->blockIndex].defvec8, number_of_Defs); for (pcode = block->firstPCode; pcode; pcode = pcode->nextPCode) { - if (pcode->flags & (fPCodeFlag2 | fPCodeFlag4 | fPCodeFlag20000 | fPCodeFlag40000)) { + if (pcode->flags & (fIsRead | fIsWrite | fPCodeFlag20000 | fPCodeFlag40000)) { if (!pcode->alias) { pcode->alias = worst_case; } else { if ((pcode->alias->type == AliasType0 || pcode->alias->type == AliasType1) && pcode->alias->size == nbytes_loaded_or_stored_by(pcode)) { - pcode->flags &= ~fPCodeFlag20; + pcode->flags &= ~fIsPtrOp; } else { - pcode->flags |= fPCodeFlag20; + pcode->flags |= fIsPtrOp; } if (pcode->alias != worst_case) { @@ -536,7 +536,7 @@ void gather_alias_info(void) { op = pcode->args; for (i = 0; i < pcode->argCount; i++, op++) { if ( - (!(pcode->flags & (fPCodeFlag4 | fPCodeFlag40000)) || op != pcode->args) && + (!(pcode->flags & (fIsWrite | fPCodeFlag40000)) || op != pcode->args) && op->kind == PCOp_REGISTER && (RegClass) op->arg == RegClass_GPR && (op->data.reg.effect & EffectRead) @@ -576,7 +576,7 @@ void gather_alias_info(void) { } if (alias_choice == worst_case) { - pcode->flags |= fPCodeFlag20; + pcode->flags |= fIsPtrOp; if (pcode->alias->type == AliasType2) add_alias_member(worst_case, pcode->alias); else @@ -589,7 +589,7 @@ void gather_alias_info(void) { } } } else { - if ((pcode->flags & fPCodeFlag8) && !pcode->alias) + if ((pcode->flags & fIsCall) && !pcode->alias) pcode->alias = worst_case; } @@ -607,7 +607,7 @@ void gather_alias_info(void) { } else { for (block = pcbasicblocks; block; block = block->nextBlock) { for (pcode = block->firstPCode; pcode; pcode = pcode->nextPCode) { - if ((pcode->flags & (fPCodeFlag2 | fPCodeFlag4 | fPCodeFlag8 | fPCodeFlag20000 | fPCodeFlag40000)) && !pcode->alias) + if ((pcode->flags & (fIsRead | fIsWrite | fIsCall | fPCodeFlag20000 | fPCodeFlag40000)) && !pcode->alias) pcode->alias = worst_case; } } diff --git a/compiler_and_linker/unsorted/CABI.c b/compiler_and_linker/unsorted/CABI.c index 91883f5..853a053 100644 --- a/compiler_and_linker/unsorted/CABI.c +++ b/compiler_and_linker/unsorted/CABI.c @@ -2013,7 +2013,7 @@ ENode *CABI_DestroyObject(Object *dtor, ENode *objexpr, CABIDestroyMode mode, Bo if (flag1) expr->data.funccall.funcref->flags |= ENODE_FLAG_80; expr->data.funccall.functype = TYPE_FUNC(dtor->type); - dtor->flags |= OBJECT_FLAGS_UNUSED; + dtor->flags |= OBJECT_FLAGS_1; list = lalloc(sizeof(ENodeList)); list->node = objexpr; diff --git a/compiler_and_linker/unsorted/CClass.c b/compiler_and_linker/unsorted/CClass.c index 961d99b..7123a93 100644 --- a/compiler_and_linker/unsorted/CClass.c +++ b/compiler_and_linker/unsorted/CClass.c @@ -1273,7 +1273,7 @@ static Object *CClass_FindCovariantFunction(Object *func, Type *type) { nsol = CScope_FindName( TYPE_METHOD(func->type)->theclass->nspace, - CMangler_GetCovariantFunctionName(func, type)); + CMangler_GetCovariantFunctionName(func, TYPE_CLASS(type))); CError_ASSERT(1754, nsol && !nsol->next && nsol->object->otype == OT_OBJECT); @@ -1287,7 +1287,7 @@ static ObjectList *CClass_DeclareCovariantFuncs(ObjectList *list, Object *func, ObjectList *newlist; for (types = CClass_GetCoVariantClassList(NULL, tclass, func, 1); types; types = types->next) { - name = CMangler_GetCovariantFunctionName(func, types->type); + name = CMangler_GetCovariantFunctionName(func, TYPE_CLASS(types->type)); newfunc = galloc(sizeof(Object)); memclrw(newfunc, sizeof(Object)); diff --git a/compiler_and_linker/unsorted/CCompiler.c b/compiler_and_linker/unsorted/CCompiler.c index 6159517..1bac511 100644 --- a/compiler_and_linker/unsorted/CCompiler.c +++ b/compiler_and_linker/unsorted/CCompiler.c @@ -3,6 +3,8 @@ #include "compiler/CPrep.h" #include "compiler/CompilerTools.h" #include "compiler/CodeGen.h" +#include "compiler/CodeGenOptPPC.h" +#include "compiler/IrOptimizer.h" #include "compiler/types.h" #include "pref_structs.h" @@ -72,7 +74,7 @@ static int setup_param_block(CWPluginContext context) { return CWGetTargetName(context, target_name, sizeof(target_name)) == cwNoErr; } -static short store_compile_results() { +static short store_compile_results(void) { CWResult result; if (cparams.objectDataHandle) @@ -181,7 +183,7 @@ static void initialize_compiler_options(CParams *params) { copts.text = CWFOURCHAR('T','E','X','T'); } -static void GetLicense() { +static void GetLicense(void) { if (!license_cookie) { crippled = 1; CWCheckoutLicense(cparams.context, "MacOS_Plugins_MacOS_Unlimited", "7", 2, NULL, &license_cookie); @@ -195,7 +197,7 @@ static void GetLicense() { } } -static void ReleaseLicense() { +static void ReleaseLicense(void) { if (license_cookie && using_license_manager) CWCheckinLicense(cparams.context, license_cookie); using_license_manager = 0; diff --git a/compiler_and_linker/unsorted/CDecl.c b/compiler_and_linker/unsorted/CDecl.c index 0ee3cf8..789c6d8 100644 --- a/compiler_and_linker/unsorted/CDecl.c +++ b/compiler_and_linker/unsorted/CDecl.c @@ -104,12 +104,12 @@ static void CDecl_ParseCPPFuncDecl(TypeFunc *tfunc) { for (;;) { if (tk == TK_CONST) { if (tfunc->flags & FUNC_FLAGS_CONST) - CError_Warning(313, "const"); + CError_Warning(CErrorStr313, "const"); tfunc->flags |= FUNC_FLAGS_CONST; tk = lex(); } else if (tk == TK_VOLATILE) { if (tfunc->flags & FUNC_FLAGS_VOLATILE) - CError_Warning(313, "volatile"); + CError_Warning(CErrorStr313, "volatile"); tfunc->flags |= FUNC_FLAGS_VOLATILE; tk = lex(); } else { @@ -125,7 +125,7 @@ void CDecl_NewConvFuncType(DeclInfo *declinfo) { TypeFunc *tfunc; if (tk != '(') - CError_Error(114); + CError_Error(CErrorStr114); else tk = lex(); @@ -133,7 +133,7 @@ void CDecl_NewConvFuncType(DeclInfo *declinfo) { tk = lex(); if (tk != ')') - CError_Error(115); + CError_Error(CErrorStr115); else tk = lex(); @@ -181,14 +181,14 @@ void CDecl_CompleteType(Type *type) { Boolean IsCompleteType(Type *type) { switch (type->type) { case TYPEVOID: - CError_Error(126); + CError_Error(CErrorStr126); return 0; case TYPEFUNC: - CError_Error(146); + CError_Error(CErrorStr146); return 0; case TYPESTRUCT: if (!type->size) { - CError_Error(136, type, 0); + CError_Error(CErrorStr136, type, 0); return 0; } return 1; @@ -201,13 +201,13 @@ Boolean IsCompleteType(Type *type) { ) ) { - CError_Error(136, type, 0); + CError_Error(CErrorStr136, type, 0); return 0; } return 1; default: if (!type->size) { - CError_Error(145); + CError_Error(CErrorStr145); return 0; } return 1; @@ -217,10 +217,10 @@ Boolean IsCompleteType(Type *type) { Boolean CanAllocObject(Type *type) { switch (type->type) { case TYPEVOID: - CError_Error(126); + CError_Error(CErrorStr126); return 0; case TYPEFUNC: - CError_Error(146); + CError_Error(CErrorStr146); return 0; case TYPECLASS: if (TYPE_CLASS(type)->flags & CLASS_FLAGS_ABSTRACT) { @@ -238,11 +238,11 @@ Boolean CanCreateObject(Type *type) { if (IS_TYPE_CLASS(type)) { if (TYPE_CLASS(type)->flags & CLASS_FLAGS_1) { - CError_Error(191); + CError_Error(CErrorStr191); return 0; } if (TYPE_CLASS(type)->objcinfo) { - CError_Error(307); + CError_Error(CErrorStr307); return 0; } } @@ -259,7 +259,7 @@ static Boolean CanCreateHandleMemberObject(Type *type) { if (IS_TYPE_CLASS(type)) { if (CClass_Destructor(TYPE_CLASS(type)) || CClass_Constructor(TYPE_CLASS(type))) { - CError_Error(191); + CError_Error(CErrorStr191); return 0; } } @@ -333,12 +333,12 @@ Boolean CDecl_CheckArrayIntegr(Type *type) { return 0; if (IS_TYPE_CLASS(type) && TYPE_CLASS(type)->sominfo) { - CError_Error(289); + CError_Error(CErrorStr289); return 0; } if (IS_TYPE_REFERENCE(type)) { - CError_Error(196); + CError_Error(CErrorStr196); return 0; } @@ -350,7 +350,7 @@ static Boolean checkfuncintegr(Type *type) { return 1; if (IS_TYPE_CLASS(type) && TYPE_CLASS(type)->sominfo) { - CError_Error(283); + CError_Error(CErrorStr283); return 0; } @@ -370,7 +370,7 @@ void CDecl_ParseDirectFuncDecl(DeclInfo *declinfo) { } else { list = parameter_type_list(declinfo); if (tk != ')') - CError_ErrorSkip(115); + CError_ErrorSkip(CErrorStr115); else tk = lex(); } @@ -387,7 +387,7 @@ void CDecl_ParseDirectFuncDecl(DeclInfo *declinfo) { if (copts.cplusplus) { CDecl_ParseCPPFuncDecl(tfunc); if (declinfo->storageclass == TK_TYPEDEF && tfunc->exspecs) - CError_Error(264); + CError_Error(CErrorStr264); } scandirectdecl1(declinfo); @@ -418,7 +418,7 @@ static void scandirectdecl1(DeclInfo *declinfo) { expr = CExpr_IntegralConstOrDepExpr(); if (!ENODE_IS(expr, EINTCONST)) { if (tk != ']') - CError_ErrorSkip(125); + CError_ErrorSkip(CErrorStr125); else tk = lex(); declinfo->x47 = 1; @@ -433,13 +433,13 @@ static void scandirectdecl1(DeclInfo *declinfo) { } len = expr->data.intval; if (CInt64_IsNegative(&len)) { - CError_Error(124); + CError_Error(CErrorStr124); len = cint64_one; } else if (CInt64_IsZero(&len)) { if (!copts.ANSI_strict && declinfo->x50) { flag = 1; } else { - CError_Error(124); + CError_Error(CErrorStr124); len = cint64_one; } } @@ -452,12 +452,12 @@ static void scandirectdecl1(DeclInfo *declinfo) { else len = expr->data.intval; } else { - CError_Error(124); + CError_Error(CErrorStr124); } } if (tk != ']') - CError_ErrorSkip(125); + CError_ErrorSkip(CErrorStr125); else tk = lex(); } @@ -543,12 +543,12 @@ static void substitute_type(Type *type1, Type *type2) { } type1 = TYPE_TEMPLATE(type1)->u.array.type; } else { - CError_Error(146); + CError_Error(CErrorStr146); return; } break; default: - CError_Error(121); + CError_Error(CErrorStr121); return; } } @@ -563,7 +563,7 @@ static void scandecl(DeclInfo *declinfo) { scandeclarator(declinfo); if (tk != ')') - CError_ErrorSkip(115); + CError_ErrorSkip(CErrorStr115); else tk = lex(); @@ -581,7 +581,7 @@ static void scandecl(DeclInfo *declinfo) { static Boolean CDecl_ParseOperatorDecl(DeclInfo *declinfo) { if (declinfo->x3E) { - CError_Error(121); + CError_Error(CErrorStr121); return 0; } @@ -622,7 +622,7 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) { Boolean r6; if (!IS_TYPE_FUNC(declinfo->thetype)) { - CError_Error(193); + CError_Error(CErrorStr193); return 0; } @@ -639,7 +639,7 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) { case TK_DELETE_ARRAY: break; default: - CError_Error(205); + CError_Error(CErrorStr205); } } @@ -659,7 +659,7 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) { case TK_DELETE_ARRAY: break; default: - CError_Error(205); + CError_Error(CErrorStr205); } } } @@ -667,7 +667,7 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) { r27 = OpMysteryValue3; } } else { - CError_Error(193); + CError_Error(CErrorStr193); return 0; } @@ -676,52 +676,52 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) { case TK_NEW: case TK_NEW_ARRAY: if (r6 || !is_typesame(functype, (Type *) &void_ptr) || r27 < OpMysteryValue1 || args->type != CABI_GetSizeTType()) { - CError_Error(193); + CError_Error(CErrorStr193); return 0; } return 1; case TK_DELETE: case TK_DELETE_ARRAY: if (r6 || !IS_TYPE_VOID(functype) || r27 < OpMysteryValue1 || !is_typesame(args->type, (Type *) &void_ptr)) { - CError_Error(193); + CError_Error(CErrorStr193); return 0; } return 1; case '=': if (!r6) { - CError_Error(193); + CError_Error(CErrorStr193); return 0; } break; case '(': if (!r6) { - CError_Error(193); + CError_Error(CErrorStr193); return 0; } return 1; case '[': if (!r6) { - CError_Error(193); + CError_Error(CErrorStr193); return 0; } break; case TK_ARROW: if (r27 != OpMysteryValue1 || r6 == 0) { - CError_Error(193); + CError_Error(CErrorStr193); return 0; } return 1; case TK_INCREMENT: case TK_DECREMENT: if (r27 == OpMysteryValue2 && secondarg->type != (Type *) &stsignedint) { - CError_Error(193); + CError_Error(CErrorStr193); return 0; } break; } if (flag && !r6) { - CError_Error(193); + CError_Error(CErrorStr193); return 0; } @@ -779,7 +779,7 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) { break; } - CError_Error(193); + CError_Error(CErrorStr193); return 0; } @@ -799,7 +799,7 @@ static void scandirectdeclarator(DeclInfo *declinfo, NameSpace *nspace) { CScope_RestoreScope(&scopesave); return; } else { - CError_Error(121); + CError_Error(CErrorStr121); if (nspace) CScope_RestoreScope(&scopesave); return; @@ -829,7 +829,7 @@ static void scandirectdeclarator(DeclInfo *declinfo, NameSpace *nspace) { } if (declinfo->name) - CError_Error(121); + CError_Error(CErrorStr121); CDecl_ParseDirectFuncDecl(declinfo); if (nspace) @@ -856,16 +856,16 @@ static void scandirectdeclarator(DeclInfo *declinfo, NameSpace *nspace) { if (IS_TYPE_FUNC(declinfo->thetype)) TYPE_FUNC(declinfo->thetype)->flags |= FUNC_FLAGS_40; else - CError_Error(121); + CError_Error(CErrorStr121); } else { - CError_Error(114); + CError_Error(CErrorStr114); } return; } flag = 1; } else if (tk != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); CScope_RestoreScope(&scopesave); return; } else { @@ -873,7 +873,7 @@ static void scandirectdeclarator(DeclInfo *declinfo, NameSpace *nspace) { } if (declinfo->name) { - CError_Error(121); + CError_Error(CErrorStr121); CScope_RestoreScope(&scopesave); return; } @@ -884,7 +884,7 @@ static void scandirectdeclarator(DeclInfo *declinfo, NameSpace *nspace) { tk = lex(); } else if (tk == TK_IDENTIFIER) { if (declinfo->name) - CError_Error(121); + CError_Error(CErrorStr121); declinfo->name = tkidentifier; tk = lex(); } else if (tk == TK_OPERATOR) { @@ -911,12 +911,12 @@ void makememberpointertype(DeclInfo *declinfo, TypeClass *tclass, UInt32 qual) { TypeFunc *tfunc; if (tclass->flags & CLASS_FLAGS_1) { - CError_Error(191); + CError_Error(CErrorStr191); declinfo->thetype = (Type *) &stsignedint; return; } if (tclass->sominfo) { - CError_Error(290); + CError_Error(CErrorStr290); declinfo->thetype = (Type *) &stsignedint; return; } @@ -951,17 +951,17 @@ void CDecl_ScanPointer(DeclInfo *declinfo, NameSpace *nspace, Boolean flag) { switch (tk) { case TK_CONST: if (qual & Q_CONST) - CError_Error(121); + CError_Error(CErrorStr121); qual |= Q_CONST; continue; case TK_VOLATILE: if (qual & Q_VOLATILE) - CError_Error(121); + CError_Error(CErrorStr121); qual |= Q_VOLATILE; continue; case TK_RESTRICT: if (qual & Q_RESTRICT) - CError_Error(121); + CError_Error(CErrorStr121); qual |= Q_RESTRICT; continue; default: @@ -971,7 +971,7 @@ void CDecl_ScanPointer(DeclInfo *declinfo, NameSpace *nspace, Boolean flag) { } if (IS_TYPE_REFERENCE(declinfo->thetype) || ((qual & Q_REFERENCE) && IS_TYPE_VOID(declinfo->thetype))) { - CError_Error(196); + CError_Error(CErrorStr196); return; } @@ -1013,7 +1013,7 @@ void CDecl_ScanPointer(DeclInfo *declinfo, NameSpace *nspace, Boolean flag) { declinfo->x20 = pr.x8; return; } - CError_Error(121); + CError_Error(CErrorStr121); } } break; @@ -1083,7 +1083,7 @@ void scandeclarator(DeclInfo *declinfo) { return; } } - CError_Error(121); + CError_Error(CErrorStr121); } break; } @@ -1111,7 +1111,7 @@ void conversion_type_name(DeclInfo *declinfo) { if (pr.nspace_0 && pr.nspace_0->theclass && tk == '*') CDecl_ScanPointer(&subdeclinfo, pr.nspace_0, 0); else - CError_Error(121); + CError_Error(CErrorStr121); } break; } @@ -1131,14 +1131,14 @@ static void scaninlinefunc(Object *obj) { r29 = 0; while (1) { if (r29 >= 256) { - CError_Error(127); + CError_Error(CErrorStr127); r29 = 255; } val = CExpr_IntegralConstExpr(); array[r29++] = CInt64_GetULong(&val); if (tk != '}') { if (tk != ',') - CError_Error(116); + CError_Error(CErrorStr116); tk = lex(); } else { tk = lex(); @@ -1158,7 +1158,7 @@ static void scaninlinefunc(Object *obj) { memcpy(obj->u.ifunc.data, array, obj->u.ifunc.size); if (tk != ';') - CError_Error(123); + CError_Error(CErrorStr123); } typedef enum { @@ -1200,7 +1200,7 @@ static Object *CDecl_OverloadFunctionObject(NameSpaceObjectList *list, DeclInfo if (IS_TYPEFUNC_METHOD(scanfunc)) { switch (mode) { case OverloadMode0: - CError_Error(197); + CError_Error(CErrorStr197); break; case OverloadMode1: if (!TYPE_METHOD(scanfunc)->x26) @@ -1220,14 +1220,14 @@ static Object *CDecl_OverloadFunctionObject(NameSpaceObjectList *list, DeclInfo } } else { if (mode) - CError_Error(197); + CError_Error(CErrorStr197); } compareresult = CParser_CompareArgLists(args, scanargs); if (compareresult == 1) { if (scanfunc->flags & FUNC_FLAGS_40) { if (!(tfunc->flags & FUNC_FLAGS_40)) { - CError_Error(197); + CError_Error(CErrorStr197); break; } if (!is_typesame(tfunc->functype, scanfunc->functype)) @@ -1235,7 +1235,7 @@ static Object *CDecl_OverloadFunctionObject(NameSpaceObjectList *list, DeclInfo if ((tfunc->qual & (Q_CONST | Q_PASCAL)) != (scanfunc->qual & (Q_CONST | Q_PASCAL))) continue; if ((tfunc->flags & (FUNC_FLAGS_F0000000 | FUNC_FLAGS_PASCAL)) != (scanfunc->flags & (FUNC_FLAGS_F0000000 | FUNC_FLAGS_PASCAL))) { - CError_Error(197); + CError_Error(CErrorStr197); break; } if (tfunc->exspecs || scanfunc->exspecs) @@ -1244,12 +1244,12 @@ static Object *CDecl_OverloadFunctionObject(NameSpaceObjectList *list, DeclInfo } if (tfunc->flags & FUNC_FLAGS_40) { - CError_Error(197); + CError_Error(CErrorStr197); break; } if (!is_typesame(tfunc->functype, scanfunc->functype) || ((tfunc->qual & (Q_CONST | Q_PASCAL)) != (scanfunc->qual & (Q_CONST | Q_PASCAL))) || ((tfunc->flags & (FUNC_FLAGS_F0000000 | FUNC_FLAGS_PASCAL)) != (scanfunc->flags & (FUNC_FLAGS_F0000000 | FUNC_FLAGS_PASCAL)))) { - CError_Error(197); + CError_Error(CErrorStr197); break; } @@ -1260,7 +1260,7 @@ static Object *CDecl_OverloadFunctionObject(NameSpaceObjectList *list, DeclInfo return obj; } else if (compareresult == 2) { - CError_Error(197); + CError_Error(CErrorStr197); break; } } @@ -1271,12 +1271,12 @@ static Object *CDecl_OverloadFunctionObject(NameSpaceObjectList *list, DeclInfo } if (!outflag) { - CError_Error(197); + CError_Error(CErrorStr197); return NULL; } if (declinfo->nspace) - CError_Error(336); + CError_Error(CErrorStr336); *outflag = 1; obj = CParser_NewFunctionObject(declinfo); @@ -1286,7 +1286,7 @@ static Object *CDecl_OverloadFunctionObject(NameSpaceObjectList *list, DeclInfo for (scan = list; scan; scan = scan->next) { if (scan->object->otype == OT_OBJECT && IS_TYPE_FUNC(OBJECT(scan->object)->type)) { if (TYPE_FUNC(OBJECT(scan->object)->type)->flags & FUNC_FLAGS_PASCAL) - CError_Error(226); + CError_Error(CErrorStr226); } } } @@ -1294,7 +1294,7 @@ static Object *CDecl_OverloadFunctionObject(NameSpaceObjectList *list, DeclInfo if (copts.cplusplus && declinfo->x4E) { for (scan = list; scan; scan = scan->next) { if (scan->object->otype == OT_OBJECT && !(OBJECT(scan->object)->qual & Q_80000)) - CError_Error(197); + CError_Error(CErrorStr197); } } @@ -1327,7 +1327,7 @@ void MergeDefaultArgs(FuncArg *a, FuncArg *b) { b->dexpr = NULL; b = b->next; } - CError_Error(205); + CError_Error(CErrorStr205); return; } scan_b = scan_b->next; @@ -1350,7 +1350,7 @@ void MergeDefaultArgs(FuncArg *a, FuncArg *b) { b->dexpr = NULL; b = b->next; } - CError_Error(205); + CError_Error(CErrorStr205); return; } else { scan_a = scan_a->next; @@ -1382,7 +1382,7 @@ void CheckDefaultArgs(FuncArg *args) { args->dexpr = NULL; args = args->next; } - CError_Error(205); + CError_Error(CErrorStr205); return; } scan = scan->next; @@ -1392,7 +1392,7 @@ void CheckDefaultArgs(FuncArg *args) { static void CDecl_FuncRedeclCheck(Object *obj, DeclInfo *declinfo, Boolean flag) { if (declinfo->storageclass == TK_STATIC && obj->sclass != TK_STATIC) { if (copts.cplusplus) - CError_Error(260); + CError_Error(CErrorStr260); else obj->sclass = TK_STATIC; } @@ -1428,7 +1428,7 @@ Object *CDecl_GetFunctionObject(DeclInfo *declinfo, NameSpace *nspace, Boolean * switch (TYPE_FUNC(declinfo->thetype)->functype->type) { case TYPEFUNC: case TYPEARRAY: - CError_Error(128); + CError_Error(CErrorStr128); TYPE_FUNC(declinfo->thetype)->functype = (Type *) &stsignedint; break; } @@ -1438,14 +1438,14 @@ Object *CDecl_GetFunctionObject(DeclInfo *declinfo, NameSpace *nspace, Boolean * if (!nspace2->theclass->size) CDecl_CompleteType((Type *) nspace2->theclass); if (!(list = CScope_GetLocalObject(nspace2, declinfo->name))) { - CError_Error(140, declinfo->name->name); + CError_Error(CErrorStr140, declinfo->name->name); return NULL; } obj = OBJECT(list->object); type = obj->type; if (!IS_TYPE_FUNC(type)) { - CError_Error(249, CError_GetObjectName(obj), type, obj->qual, declinfo->thetype, declinfo->qual); + CError_Error(CErrorStr249, CError_GetObjectName(obj), type, obj->qual, declinfo->thetype, declinfo->qual); return NULL; } @@ -1483,7 +1483,7 @@ Object *CDecl_GetFunctionObject(DeclInfo *declinfo, NameSpace *nspace, Boolean * tmp = *TYPE_METHOD(obj->type); *(TYPE_FUNC(&tmp)) = *TYPE_FUNC(declinfo->thetype); tmp.flags |= FUNC_FLAGS_METHOD; - CError_Error(249, CError_GetObjectName(obj), obj->type, obj->qual, &tmp, declinfo->qual); + CError_Error(CErrorStr249, CError_GetObjectName(obj), obj->type, obj->qual, &tmp, declinfo->qual); } if (TYPE_FUNC(declinfo->thetype)->exspecs || TYPE_FUNC(obj->type)->exspecs) @@ -1493,12 +1493,12 @@ Object *CDecl_GetFunctionObject(DeclInfo *declinfo, NameSpace *nspace, Boolean * CDecl_FuncRedeclCheck(obj, declinfo, 0); if (declinfo->x3C) { if (obj->nspace->theclass && !(obj->nspace->theclass->flags & CLASS_FLAGS_800)) - CError_Error(335); + CError_Error(CErrorStr335); declinfo->x3C = 0; } } else { if (TYPE_FUNC(declinfo->thetype)->flags & (FUNC_FLAGS_VOLATILE | FUNC_FLAGS_CONST)) - CError_Error(384); + CError_Error(CErrorStr384); if (declinfo->x3E && !CDecl_CheckOperatorType(declinfo, 0)) return NULL; @@ -1519,7 +1519,7 @@ Object *CDecl_GetFunctionObject(DeclInfo *declinfo, NameSpace *nspace, Boolean * } else { obj = OBJECT(list->object); if (!is_typesame(declinfo->thetype, obj->type) || (declinfo->qual & (Q_CONST | Q_PASCAL)) != (obj->qual & (Q_CONST | Q_PASCAL))) { - CError_Error(249, CError_GetObjectName(obj), obj->type, obj->qual, declinfo->thetype, declinfo->qual); + CError_Error(CErrorStr249, CError_GetObjectName(obj), obj->type, obj->qual, declinfo->thetype, declinfo->qual); r27 = 1; if (!IS_TYPE_FUNC(obj->type)) return NULL; @@ -1530,13 +1530,13 @@ Object *CDecl_GetFunctionObject(DeclInfo *declinfo, NameSpace *nspace, Boolean * CDecl_FuncRedeclCheck(obj, declinfo, *pflag); } else { if (declinfo->nspace) - CError_Error(336); + CError_Error(CErrorStr336); if (declinfo->has_expltargs) { if (declinfo->name) - CError_Error(140, declinfo->name->name); + CError_Error(CErrorStr140, declinfo->name->name); else - CError_Error(127); + CError_Error(CErrorStr127); } obj = CParser_NewFunctionObject(declinfo); @@ -1545,7 +1545,7 @@ Object *CDecl_GetFunctionObject(DeclInfo *declinfo, NameSpace *nspace, Boolean * if (pflag) *pflag = 1; else - CError_Error(127); + CError_Error(CErrorStr127); CheckDefaultArgs(TYPE_FUNC(obj->type)->args); CScope_AddObject(nspace2, declinfo->name, OBJ_BASE(obj)); @@ -1566,9 +1566,9 @@ void CDecl_TypedefDeclarator(DeclInfo *declinfo) { CError_QualifierCheck(declinfo->qual & ~(Q_ALIGNED_MASK | Q_REFERENCE | Q_PASCAL | Q_VOLATILE | Q_CONST)); if (declinfo->x48 || declinfo->x44) - CError_Error(121); + CError_Error(CErrorStr121); if (declinfo->x3E) - CError_Error(193); + CError_Error(CErrorStr193); objt = NULL; list = CScope_FindName(nspace, declinfo->name); @@ -1580,11 +1580,11 @@ void CDecl_TypedefDeclarator(DeclInfo *declinfo) { case OT_TYPETAG: break; case OT_NAMESPACE: - CError_Error(321); + CError_Error(CErrorStr321); return; case OT_ENUMCONST: case OT_OBJECT: - CError_Error(322); + CError_Error(CErrorStr322); return; default: CError_FATAL(2156); @@ -1594,12 +1594,12 @@ void CDecl_TypedefDeclarator(DeclInfo *declinfo) { if (objt) { const UInt32 mask = Q_ALIGNED_MASK | Q_REFERENCE | Q_PASCAL | Q_VOLATILE | Q_CONST; if (!is_typesame(objt->type, declinfo->thetype) || (objt->qual & mask) != (declinfo->qual & mask)) { - CError_Error(249, declinfo->name->name, objt->type, objt->qual, declinfo->thetype, declinfo->qual); + CError_Error(CErrorStr249, declinfo->name->name, objt->type, objt->qual, declinfo->thetype, declinfo->qual); } else if (!copts.cplusplus && (copts.pedantic || copts.ANSI_strict)) { if (copts.pedantic) - CError_Warning(122, declinfo->name->name); + CError_Warning(CErrorStr122, declinfo->name->name); else - CError_Error(122, declinfo->name->name); + CError_Error(CErrorStr122, declinfo->name->name); } return; } @@ -1643,9 +1643,9 @@ static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag) CError_QualifierCheck(declinfo->qual & ~(Q_ALIGNED_MASK | Q_OVERLOAD | Q_20000 | Q_PASCAL | Q_VOLATILE | Q_CONST)); if (declinfo->x48 || declinfo->x44) - CError_Error(121); + CError_Error(CErrorStr121); if (declinfo->x3E) - CError_Error(193); + CError_Error(CErrorStr193); obj = NULL; list = CScope_FindName(nspace, declinfo->name); @@ -1654,19 +1654,19 @@ static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag) case OT_OBJECT: obj = OBJECT(list->object); if (flag) - CError_Error(122, declinfo->name->name); + CError_Error(CErrorStr122, declinfo->name->name); break; case OT_TYPETAG: break; case OT_NAMESPACE: - CError_Error(321); + CError_Error(CErrorStr321); return; case OT_ENUMCONST: case OT_TYPE: - CError_Error(322); + CError_Error(CErrorStr322); break; case OT_MEMBERVAR: - CError_Error(221); + CError_Error(CErrorStr221); break; default: CError_FATAL(2281); @@ -1703,17 +1703,17 @@ static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag) tmpflag = is_typesame(declinfo->thetype, obj->type); if (!tmpflag || (obj->qual & (Q_PASCAL | Q_VOLATILE | Q_CONST)) != (declinfo->qual & (Q_PASCAL | Q_VOLATILE | Q_CONST))) - CError_Error(249, CError_GetObjectName(obj), obj->type, obj->qual, declinfo->thetype, declinfo->qual); + CError_Error(CErrorStr249, CError_GetObjectName(obj), obj->type, obj->qual, declinfo->thetype, declinfo->qual); if (obj->qual & Q_10000) { if (tk == ',' || tk == ';') return; - CError_Error(333, obj); + CError_Error(CErrorStr333, obj); } if (declinfo->storageclass != TK_EXTERN) { if (obj->sclass != TK_EXTERN && declinfo->storageclass && obj->sclass != declinfo->storageclass) - CError_Error(333, obj); + CError_Error(CErrorStr333, obj); if (tmpflag) { obj->sclass = declinfo->storageclass; @@ -1728,9 +1728,9 @@ static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag) } } else { if (declinfo->nspace) - CError_Error(336); + CError_Error(CErrorStr336); if (IS_TYPE_CLASS(declinfo->thetype) && TYPE_CLASS(declinfo->thetype)->sominfo) - CError_Error(288); + CError_Error(CErrorStr288); if (!CanCreateObject(declinfo->thetype)) declinfo->thetype = (Type *) &stsignedint; @@ -1771,7 +1771,7 @@ static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag) obj->u.data.u.intconst = expr->data.intval; obj->qual |= Q_10000 | Q_20000; } else { - CError_Error(354, obj->name->name); + CError_Error(CErrorStr354, obj->name->name); } } } @@ -1784,17 +1784,17 @@ Boolean CDecl_FunctionDeclarator(DeclInfo *declinfo, NameSpace *nspace, Boolean if (obj) { if (declinfo->x44 || tk == '{' || tk == TK_TRY || (declinfo->x4B && tk == ':') || (!copts.cplusplus && isdeclaration(0, 0, 0, 0))) { if (!flag || cscope_currentfunc) { - CError_Error(127); + CError_Error(CErrorStr127); if (cscope_currentfunc) return 0; } if (obj->nspace == cscope_root && !strcmp(obj->name->name, "main")) { if (obj->sclass == TK_STATIC || (copts.ANSI_strict && TYPE_FUNC(obj->type)->functype != (Type *) &stsignedint)) - CError_Error(334); + CError_Error(CErrorStr334); } else if (copts.require_prototypes && (pflag || declinfo->x64)) { if (obj->sclass != TK_STATIC && !(obj->qual & Q_INLINE) && !obj->nspace->is_unnamed) - CError_Warning(178); + CError_Warning(CErrorStr178); } CFunc_ParseFuncDef(obj, declinfo, NULL, 0, 0, NULL); @@ -1826,7 +1826,7 @@ static void CDecl_ParseSpecialMember(DeclInfo *declinfo, Boolean flag) { } if (!r28->nspace->theclass) { - CError_Error(121); + CError_Error(CErrorStr121); return; } @@ -1860,10 +1860,10 @@ static void CDecl_ParseSpecialMember(DeclInfo *declinfo, Boolean flag) { if (flag) CDecl_FunctionDeclarator(declinfo, NULL, 1, 1); } else { - CError_Error(121); + CError_Error(CErrorStr121); } } else { - CError_Error(114); + CError_Error(CErrorStr114); } return; } else if (TYPE_FUNC(r28->type)->flags & FUNC_FLAGS_40) { @@ -1882,10 +1882,10 @@ static void CDecl_ParseSpecialMember(DeclInfo *declinfo, Boolean flag) { if (flag) CDecl_FunctionDeclarator(declinfo, NULL, 1, 1); } else { - CError_Error(121); + CError_Error(CErrorStr121); } } else { - CError_Error(114); + CError_Error(CErrorStr114); } return; } else { @@ -1907,12 +1907,12 @@ static void CDecl_ParseSpecialMember(DeclInfo *declinfo, Boolean flag) { return; } } else { - CError_Error(114); + CError_Error(CErrorStr114); } } } - CError_Error(121); + CError_Error(CErrorStr121); } void CDecl_ScanDeclarator(DeclInfo *declinfo) { @@ -1929,12 +1929,12 @@ void CDecl_ScanDeclarator(DeclInfo *declinfo) { } scandeclarator(declinfo); if (!declinfo->name) { - CError_Error(121); + CError_Error(CErrorStr121); return; } if (declinfo->storageclass && declinfo->storageclass != TK_EXTERN) - CError_Error(177); + CError_Error(CErrorStr177); if (IS_TYPE_FUNC(declinfo->thetype)) { CDecl_GetFunctionObject(declinfo, NULL, NULL, 1); @@ -1942,16 +1942,16 @@ void CDecl_ScanDeclarator(DeclInfo *declinfo) { } if (declinfo->x48 || declinfo->x44) - CError_Error(121); + CError_Error(CErrorStr121); if (declinfo->x3E) - CError_Error(193); + CError_Error(CErrorStr193); if ( (declinfo->qual & ~(Q_ALIGNED_MASK | Q_OVERLOAD | Q_20000 | Q_PASCAL | Q_VOLATILE | Q_CONST)) || (declinfo->storageclass == TK_TYPEDEF && (declinfo->qual & ~(Q_ALIGNED_MASK | Q_REFERENCE | Q_PASCAL | Q_VOLATILE | Q_CONST))) ) - CError_Error(176); + CError_Error(CErrorStr176); } void scandeclaratorlist(DeclInfo *declinfo) { @@ -1981,7 +1981,7 @@ void scandeclaratorlist(DeclInfo *declinfo) { declinfo->name = NULL; scandeclarator(declinfo); if (!declinfo->name) { - CError_Error(121); + CError_Error(CErrorStr121); break; } @@ -2007,7 +2007,7 @@ void scandeclaratorlist(DeclInfo *declinfo) { } if (tk != ';') - CError_Error(123); + CError_Error(CErrorStr123); } static TypeIntegral *CDecl_FindSignedType(short size) { @@ -2165,7 +2165,7 @@ static TypeEnum *CDecl_OldParseEnumList(TypeEnum *tenum, HashNameNode *name) { if (!copts.warn_extracomma) break; } - CError_Warning(107); + CError_Warning(CErrorStr107); break; } @@ -2198,7 +2198,7 @@ static TypeEnum *CDecl_OldParseEnumList(TypeEnum *tenum, HashNameNode *name) { r23 = 0; } else { if (r23) - CError_Error(154); + CError_Error(CErrorStr154); if (!r24 || !CInt64_IsNegative(&val)) { if (CInt64_GreaterU(val, minimum)) { @@ -2216,10 +2216,10 @@ static TypeEnum *CDecl_OldParseEnumList(TypeEnum *tenum, HashNameNode *name) { if (copts.enumsalwaysint) { if (copts.ANSI_strict) { if (!CInt64_IsInRange(val, stsignedint.size)) - CError_Error(154); + CError_Error(CErrorStr154); } else { if (!CInt64_IsInRange(val, stsignedint.size) && !CInt64_IsInURange(val, stunsignedint.size)) - CError_Error(154); + CError_Error(CErrorStr154); } } else if (r24) { switch (basetype->size) { @@ -2239,12 +2239,12 @@ static TypeEnum *CDecl_OldParseEnumList(TypeEnum *tenum, HashNameNode *name) { if (!copts.ANSI_strict && CInt64_IsInRange(maximum, 4) && CInt64_IsInURange(minimum, 4)) break; if (overflowed) - CError_Error(154); + CError_Error(CErrorStr154); break; } case 8: if (CInt64_Equal(val, minimum) && CInt64_IsNegative(&val)) - CError_Error(154); + CError_Error(CErrorStr154); break; default: CError_FATAL(3071); @@ -2265,7 +2265,7 @@ static TypeEnum *CDecl_OldParseEnumList(TypeEnum *tenum, HashNameNode *name) { basetype = TYPE(CDecl_FindUnsignedType(8)); if (basetype->size != 8) { if (overflowed) - CError_Error(154); + CError_Error(CErrorStr154); break; } case 8: @@ -2318,7 +2318,7 @@ static TypeEnum *CDecl_OldParseEnumList(TypeEnum *tenum, HashNameNode *name) { oec->type = TYPE(tenum); if (tk != '}') - CError_ErrorSkip(130); + CError_ErrorSkip(CErrorStr130); else tk = lex(); @@ -2363,14 +2363,14 @@ void CDecl_ComputeUnderlyingEnumType(TypeEnum *tenum) { } if (CInt64_IsNegative(&maximum)) - CError_Error(154); + CError_Error(CErrorStr154); t = 0; do { r26 = TYPE(CDecl_IterateIntegralEnumType(&t)); if (!r26) { r26 = TYPE(&stsignedlong); - CError_Error(154); + CError_Error(CErrorStr154); break; } @@ -2392,7 +2392,7 @@ void CDecl_ComputeUnderlyingEnumType(TypeEnum *tenum) { r26 = TYPE(CDecl_IterateUIntegralEnumType(&t)); if (!r26) { r26 = TYPE(&stunsignedlong); - CError_Error(154); + CError_Error(CErrorStr154); break; } if (CInt64_IsInURange(val, r26->size)) @@ -2510,9 +2510,9 @@ static TypeEnum *CDecl_ParseEnumList(TypeEnum *tenum, HashNameNode *name) { if (copts.cpp_extensions) break; } - CError_Warning(107); + CError_Warning(CErrorStr107); } else { - CError_Error(107); + CError_Error(CErrorStr107); } break; } @@ -2587,7 +2587,7 @@ static TypeEnum *CDecl_ParseEnumList(TypeEnum *tenum, HashNameNode *name) { } if (overflowed) - CError_Error(154); + CError_Error(CErrorStr154); oec->val = val; oec->type = basetype; @@ -2615,7 +2615,7 @@ static TypeEnum *CDecl_ParseEnumList(TypeEnum *tenum, HashNameNode *name) { oec->type = TYPE(tenum); if (tk != '}') - CError_ErrorSkip(130); + CError_ErrorSkip(CErrorStr130); else tk = lex(); @@ -2641,7 +2641,7 @@ void scanenum(DeclInfo *declinfo) { lex(); do_shit: if (type->size || !IS_TYPE_ENUM(type)) { - CError_Error(122, name->name); + CError_Error(CErrorStr122, name->name); declinfo->thetype = TYPE(CDecl_ParseEnumList(NULL, NULL)); return; } @@ -2669,7 +2669,7 @@ void scanenum(DeclInfo *declinfo) { if (CScope_ParseElaborateName(&pr)) { if ((type = pr.x8)) { if (!IS_TYPE_ENUM(type)) - CError_Error(121); + CError_Error(CErrorStr121); if ((tk = lex()) == '{') goto do_shit; declinfo->thetype = type; @@ -2680,11 +2680,11 @@ void scanenum(DeclInfo *declinfo) { declinfo->thetype = TYPE(CDecl_ParseEnumList(NULL, pr.name_4)); return; } else { - CError_Error(140, pr.name_4->name); + CError_Error(CErrorStr140, pr.name_4->name); } } } else { - CError_Error(121); + CError_Error(CErrorStr121); } declinfo->thetype = TYPE(&stsignedint); @@ -2712,7 +2712,7 @@ void CDecl_ScanStructDeclarator(BigDeclInfo *bde) { bde->declinfo2.x50 = 1; scandeclarator(&bde->declinfo2); if (!bde->declinfo2.name) { - CError_Error(131); + CError_Error(CErrorStr131); return; } @@ -2724,7 +2724,7 @@ void CDecl_ScanStructDeclarator(BigDeclInfo *bde) { if (!IsCompleteType(type)) return; if (tk != ';' || lookahead() != '}') { - CError_Error(145); + CError_Error(CErrorStr145); return; } } @@ -2736,7 +2736,7 @@ void CDecl_ScanStructDeclarator(BigDeclInfo *bde) { } if (IS_TYPE_CLASS(bde->declinfo2.thetype) && TYPE_CLASS(bde->declinfo2.thetype)->sominfo) { - CError_Error(287); + CError_Error(CErrorStr287); return; } @@ -2747,11 +2747,11 @@ void CDecl_ScanStructDeclarator(BigDeclInfo *bde) { if (!IS_TYPE_INT_OR_ENUM(bde->declinfo2.thetype)) { if (CTemplTool_IsTemplateArgumentDependentType(bde->declinfo2.thetype)) goto fuckup; - CError_Error(138); + CError_Error(CErrorStr138); bde->declinfo2.thetype = TYPE(&stunsignedint); } else if (copts.ANSI_strict && !copts.cplusplus) { if (bde->declinfo2.thetype != TYPE(&stsignedint) && bde->declinfo2.thetype != TYPE(&stunsignedint)) { - CError_Error(138); + CError_Error(CErrorStr138); bde->declinfo2.thetype = TYPE(&stunsignedint); } } @@ -2767,7 +2767,7 @@ void CDecl_ScanStructDeclarator(BigDeclInfo *bde) { bits = 32; break; default: - CError_Error(138); + CError_Error(CErrorStr138); return; } fuckup: @@ -2784,12 +2784,12 @@ fuckup: val = CInt64_GetULong(&expr->data.intval); if (is_bitfield) { if (val < 0 || val > bits) { - CError_Error(138); + CError_Error(CErrorStr138); return; } } else { if (val <= 0 || val > bits) { - CError_Error(138); + CError_Error(CErrorStr138); return; } } @@ -2849,7 +2849,7 @@ static void CDecl_LayoutStruct(TypeStruct *tstruct) { r23 = 1; while (innermember) { if (ismember(tstruct, innermember->name)) - CError_Error(133, innermember->name->name); + CError_Error(CErrorStr133, innermember->name->name); if (r23) { member->type = innermember->type; member->name = innermember->name; @@ -2911,14 +2911,14 @@ static void CDecl_LayoutStruct(TypeStruct *tstruct) { prev = NULL; while (member) { if (prev && (prev->offset + prev->type->size) < member->offset) { - CError_Warning(350, member->offset - (prev->offset + prev->type->size), prev->name->name); + CError_Warning(CErrorStr350, member->offset - (prev->offset + prev->type->size), prev->name->name); } prev = member; member = member->next; } if (prev && (prev->offset + prev->type->size) < tstruct->size) { - CError_Warning(350, tstruct->size - (prev->offset + prev->type->size), prev->name->name); + CError_Warning(CErrorStr350, tstruct->size - (prev->offset + prev->type->size), prev->name->name); } } } @@ -2935,14 +2935,14 @@ static SInt32 scanstructdeclarationlist(TypeStruct *tstruct, Boolean flag) { CPrep_NewFileOffsetInfo(&member_fileoffset, NULL); CObjC_ParseDefs(tstruct); if ((tk = lex()) != '}') - CError_Error(130); + CError_Error(CErrorStr130); } else { do { CPrep_NewFileOffsetInfo(&member_fileoffset, NULL); memclrw(&bde.declinfo, sizeof(DeclInfo)); CParser_GetDeclSpecs(&bde.declinfo, 0); if (bde.declinfo.storageclass || bde.declinfo.x44) { - CError_Error(131); + CError_Error(CErrorStr131); tstruct->members = NULL; return -1; } @@ -2951,12 +2951,12 @@ static SInt32 scanstructdeclarationlist(TypeStruct *tstruct, Boolean flag) { while (1) { CDecl_ScanStructDeclarator(&bde); if (!CanCreateObject(bde.declinfo2.thetype)) { - CError_Error(131); + CError_Error(CErrorStr131); bde.xCD = 0; } if (bde.declinfo2.x3E) { - CError_Error(131); + CError_Error(CErrorStr131); bde.xCD = 0; } @@ -2973,7 +2973,7 @@ static SInt32 scanstructdeclarationlist(TypeStruct *tstruct, Boolean flag) { CBrowse_AddStructMember(member, CPrep_BrowserTokenOffset(&member_fileoffset) + 1, CPrep_BrowserFileOffset()); } } else { - CError_Error(133, bde.declinfo2.name->name); + CError_Error(CErrorStr133, bde.declinfo2.name->name); } } @@ -2987,12 +2987,12 @@ static SInt32 scanstructdeclarationlist(TypeStruct *tstruct, Boolean flag) { member->type = bde.declinfo.thetype; appendmember(tstruct, member); } else { - CError_Error(131); + CError_Error(CErrorStr131); } if (tk != ';') { tstruct->members = NULL; - CError_Error(123); + CError_Error(CErrorStr123); return -1; } @@ -3055,7 +3055,7 @@ void scanstruct(DeclInfo *declinfo, short structtype) { type = (Type *) CDecl_DefineStruct(name, structtype); if (!IS_TYPE_STRUCT(type) || TYPE_STRUCT(type)->stype != structtype) { - CError_Error(132, name->name); + CError_Error(CErrorStr132, name->name); declinfo->thetype = type; return; } @@ -3066,7 +3066,7 @@ void scanstruct(DeclInfo *declinfo, short structtype) { } if (type->size) { - CError_Error(132, name->name); + CError_Error(CErrorStr132, name->name); type = (Type *) CDecl_DefineStruct(NULL, structtype); } } else { @@ -3077,7 +3077,7 @@ void scanstruct(DeclInfo *declinfo, short structtype) { } } } else if (tk != '{') { - CError_Error(131); + CError_Error(CErrorStr131); declinfo->thetype = (Type *) &stsignedint; return; } else { @@ -3098,7 +3098,7 @@ void scanstruct(DeclInfo *declinfo, short structtype) { } static void InlineFunctionObject(Object *obj, TypeClass *tclass) { - TStream stream; + TokenStream stream; CPrepFileInfo *file; obj->qual |= Q_INLINE; @@ -3151,16 +3151,16 @@ TypeMethod *CDecl_MakeTypeMemberFunc(TypeFunc *tfunc, TypeClass *tclass, Boolean CDecl_AddThisPointerArgument(TYPE_FUNC(method), tclass); if ((flag || (tfunc->flags & (FUNC_FLAGS_1000 | FUNC_FLAGS_2000))) && (tfunc->flags & (FUNC_FLAGS_CONST | FUNC_FLAGS_VOLATILE))) - CError_Error(384); + CError_Error(CErrorStr384); return method; } static void CDecl_MakeFunctionVirtual(TypeClass *tclass, Object *func) { if (is_pascal_object(func)) - CError_Error(219); + CError_Error(CErrorStr219); if (tclass->mode == CLASS_MODE_1) - CError_Error(352, func); + CError_Error(CErrorStr352, func); func->datatype = DVFUNC; } @@ -3172,7 +3172,7 @@ static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *d Boolean outflag; if (IS_TYPE_ARRAY(TYPE_FUNC(declinfo->thetype)->functype) || IS_TYPE_FUNC(TYPE_FUNC(declinfo->thetype)->functype)) { - CError_Error(128); + CError_Error(CErrorStr128); TYPE_FUNC(declinfo->thetype)->functype = (Type *) &stsignedint; } @@ -3189,7 +3189,7 @@ static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *d if ((list = CScope_FindName(tclass->nspace, declinfo->name))) { if (list->object->otype != OT_TYPETAG) { if (list->object->otype != OT_OBJECT || !IS_TYPE_FUNC(OBJECT(list->object)->type)) - CError_Error(133, declinfo->name->name); + CError_Error(CErrorStr133, declinfo->name->name); } else { list = NULL; } @@ -3214,7 +3214,7 @@ static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *d if (outflag) tfunc->x1E = ++decle->x8; else - CError_Error(133, CError_GetObjectName(obj)); + CError_Error(CErrorStr133, CError_GetObjectName(obj)); } else { tfunc->x1E = ++decle->x8; obj = CParser_NewFunctionObject(declinfo); @@ -3239,18 +3239,18 @@ static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *d if ((flag1 || r31) && flag3 && (tk == '=')) { if ((tk = lex()) == TK_INTCONST) { if (!CInt64_IsZero(&tkintconst)) - CError_Error(121); + CError_Error(CErrorStr121); tfunc->flags |= FUNC_FLAGS_8; tclass->flags |= CLASS_FLAGS_ABSTRACT; tk = lex(); } else { - CError_Error(121); + CError_Error(CErrorStr121); } } if (flag3 && ((tk == '{') || (tk == TK_TRY) || ((tk == ':') && CClass_IsConstructor(obj)))) { if (declinfo->x49) - CError_Error(127); + CError_Error(CErrorStr127); InlineFunctionObject(obj, NULL); } @@ -3390,14 +3390,14 @@ static void CDecl_ParseFriendDecl(TypeClass *tclass) { declinfo.x4C = 1; CParser_GetDeclSpecs(&declinfo, 1); if (declinfo.storageclass) { - CError_Error(177); + CError_Error(CErrorStr177); declinfo.storageclass = 0; } declinfo.x4C = 0; if (tk == ';') { if (!r27) - CError_Error(201); + CError_Error(CErrorStr201); if (IS_TYPE_CLASS(declinfo.thetype)) { if (!(TYPE_CLASS(declinfo.thetype)->flags & CLASS_FLAGS_100) || CParser_CheckTemplateClassUsage(TEMPL_CLASS(declinfo.thetype), 1)) { @@ -3410,7 +3410,7 @@ static void CDecl_ParseFriendDecl(TypeClass *tclass) { if (IS_TYPE_TEMPLATE(declinfo.thetype) && is_templ) CTemplClass_RegisterFriend(TEMPL_CLASS(tclass), &declinfo); else - CError_Error(201); + CError_Error(CErrorStr201); } } else { if (declinfo.x14 || declinfo.x10) { @@ -3420,7 +3420,7 @@ static void CDecl_ParseFriendDecl(TypeClass *tclass) { if (obj) CDecl_AddFriend(tclass, obj, NULL); if (tk != ';') - CError_Error(123); + CError_Error(CErrorStr123); else tk = lex(); } @@ -3453,7 +3453,7 @@ static void CDecl_ParseFriendDecl(TypeClass *tclass) { CTemplClass_RegisterFriend(TEMPL_CLASS(tclass), &declinfo); } } else { - CError_Error(201); + CError_Error(CErrorStr201); } if (tk != ',') @@ -3466,7 +3466,7 @@ static void CDecl_ParseFriendDecl(TypeClass *tclass) { if (tk == ';') tk = lex(); else - CError_Error(123); + CError_Error(CErrorStr123); } static ObjMemberVar *CDecl_InstanceDataDeclarator(DeclE *decle, TypeClass *tclass, Type *type, UInt32 qual, HashNameNode *name, short access) { @@ -3477,15 +3477,15 @@ static ObjMemberVar *CDecl_InstanceDataDeclarator(DeclE *decle, TypeClass *tclas if (name && (list = CScope_FindName(tclass->nspace, name))) { switch (list->object->otype) { case OT_NAMESPACE: - CError_Error(321); + CError_Error(CErrorStr321); return NULL; case OT_ENUMCONST: case OT_TYPE: case OT_OBJECT: - CError_Error(322); + CError_Error(CErrorStr322); return NULL; case OT_MEMBERVAR: - CError_Error(122, name->name); + CError_Error(CErrorStr122, name->name); return NULL; case OT_TYPETAG: break; @@ -3526,7 +3526,7 @@ static ObjMemberVar *CDecl_InstanceDataDeclarator(DeclE *decle, TypeClass *tclas void CDecl_CheckCtorIntegrity(FuncArg *args, TypeClass *tclass) { if (args && args->type == TYPE(tclass)) { if (!args->next || args->next->dexpr) { - CError_Error(239); + CError_Error(CErrorStr239); args->type = &stvoid; } } @@ -3576,7 +3576,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) } else { for (; nspace; nspace = nspace->parent) { if (!nspace->name && !nspace->theclass && nspace->parent && !nspace->is_templ) { - CError_Error(347); + CError_Error(CErrorStr347); break; } } @@ -3592,14 +3592,14 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) switch (tk) { case TK_UU_DECLSPEC: if ((tk = lex()) != '(') - CError_Error(114); + CError_Error(CErrorStr114); memclrw(&declinfo, sizeof(DeclInfo)); CParser_ParseDeclSpec(&declinfo, 1); r21 |= declinfo.qual; r20 |= declinfo.exportflags; r18 = declinfo.section; if ((tk = lex()) != ')') - CError_Error(115); + CError_Error(CErrorStr115); tk = lex(); goto restart2; case TK_PRIVATE: @@ -3612,9 +3612,9 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) global_access = access = ACCESSPUBLIC; check_access: if (r22 || r20) - CError_Error(121); + CError_Error(CErrorStr121); if ((tk = lex()) != ':') - CError_Error(170); + CError_Error(CErrorStr170); else tk = lex(); goto restart; @@ -3651,7 +3651,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) continue; if (tk == '~') goto restart2; - CError_Error(107); + CError_Error(CErrorStr107); } if (t == '(') { @@ -3673,7 +3673,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) bde.declinfo2.thetype = CTemplTool_ResolveMemberSelfRefs(TEMPL_CLASS(tclass), bde.declinfo2.thetype, &bde.declinfo2.qual); if (tclass->sominfo) { if (TYPE_FUNC(bde.declinfo2.thetype)->args) - CError_Error(272); + CError_Error(CErrorStr272); bde.declinfo2.qual |= Q_VIRTUAL; } else { CDecl_CheckCtorIntegrity(TYPE_FUNC(bde.declinfo2.thetype)->args, tclass); @@ -3686,12 +3686,12 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) bde.declinfo2.qual |= r21; CDecl_AddFunctionMember(decle, tclass, &bde.declinfo2, access, 0, 0, 1, 0); } else { - CError_Error(241); + CError_Error(CErrorStr241); } if (tk == ';') tk = lex(); else - CError_Error(123); + CError_Error(CErrorStr123); goto restart; } } @@ -3711,7 +3711,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) goto restart; case '~': if ((tk = lex()) != TK_IDENTIFIER || tkidentifier != tclass->classname) { - CError_Error(241); + CError_Error(CErrorStr241); goto restart; } CError_QualifierCheck(r22 & ~(Q_VIRTUAL | Q_INLINE | Q_ASM)); @@ -3722,7 +3722,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) memclrw(&bde.declinfo, sizeof(DeclInfo)); CParser_GetDeclSpecs(&bde.declinfo, 0); if (tk != '(' || bde.declinfo.thetype != TYPE(tclass) || bde.declinfo.nspace) { - CError_Error(241); + CError_Error(CErrorStr241); goto restart; } CPrep_UnLex(); @@ -3750,15 +3750,15 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) bde.declinfo2.qual |= r21; CDecl_AddFunctionMember(decle, tclass, &bde.declinfo2, access, 1, 0, 1, 0); } else { - CError_Error(133, CError_GetFunctionName(tclass->nspace, destructor_name_node, NULL)); + CError_Error(CErrorStr133, CError_GetFunctionName(tclass->nspace, destructor_name_node, NULL)); } } else { - CError_Error(146); + CError_Error(CErrorStr146); } if (tk == ';') tk = lex(); else - CError_Error(123); + CError_Error(CErrorStr123); goto restart; case TK_OPERATOR: if (CMangler_OperatorName(lookahead())) { @@ -3782,7 +3782,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) if (tk == ';') tk = lex(); else - CError_Error(123); + CError_Error(CErrorStr123); goto restart; } case TK_FRIEND: @@ -3815,7 +3815,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) case TK_MUTABLE: break; default: - CError_Error(177); + CError_Error(CErrorStr177); bde.declinfo.storageclass = 0; } @@ -3825,7 +3825,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) if (r17) bde.declinfo2.thetype = CTemplTool_ResolveMemberSelfRefs(TEMPL_CLASS(tclass), bde.declinfo2.thetype, &bde.declinfo2.qual); if (bde.declinfo2.nspace) - CError_Error(200); + CError_Error(CErrorStr200); if (bde.declinfo2.x3E) { if (bde.declinfo.storageclass == TK_MUTABLE) CError_QualifierCheck(Q_MUTABLE); @@ -3843,9 +3843,9 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) break; default: if (bde.declinfo2.storageclass == TK_STATIC) - CError_Error(193); + CError_Error(CErrorStr193); if (tclass->sominfo) - CError_Error(193); + CError_Error(CErrorStr193); } bde.declinfo2.storageclass = 0; @@ -3856,11 +3856,11 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) if (tclass->sominfo) CSOM_FixNewDeleteFunctype(TYPE_FUNC(bde.declinfo2.thetype)); } else { - CError_Error(121); + CError_Error(CErrorStr121); } } else if (bde.xCD) { if (bde.declinfo2.name == constructor_name_node || bde.declinfo2.name == destructor_name_node) - CError_Error(241); + CError_Error(CErrorStr241); switch (bde.declinfo2.storageclass) { case TK_TYPEDEF: CError_QualifierCheck(bde.declinfo2.qual & Q_VIRTUAL); @@ -3869,12 +3869,12 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) case TK_STATIC: CError_QualifierCheck(bde.declinfo2.qual & Q_VIRTUAL); if (tclass->sominfo) - CError_Error(271); + CError_Error(CErrorStr271); if (IS_TYPE_FUNC(bde.declinfo2.thetype)) { bde.declinfo2.qual |= r21; bde.declinfo2.storageclass = 0; if (bde.declinfo2.name == tclass->classname) - CError_Error(241); + CError_Error(CErrorStr241); CDecl_AddFunctionMember(decle, tclass, &bde.declinfo2, access, 0, 0, 1, 1); } else { CDecl_ExtractClassExportFlags(&bde.declinfo2, tclass->eflags); @@ -3886,7 +3886,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) case TK_MUTABLE: if (IS_TYPE_FUNC(bde.declinfo2.thetype)) { if (bde.declinfo2.name == tclass->classname) - CError_Error(241); + CError_Error(CErrorStr241); if (bde.declinfo.storageclass == TK_MUTABLE) CError_QualifierCheck(Q_MUTABLE); bde.declinfo2.qual |= r21; @@ -3901,7 +3901,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) } break; default: - CError_Error(177); + CError_Error(CErrorStr177); } } @@ -3928,7 +3928,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) // this should be 70148 i think if (tk != ';') { - CError_Error(123); + CError_Error(CErrorStr123); return; } CPrep_TokenStreamFlush(); @@ -3988,18 +3988,18 @@ Boolean CDecl_CheckNewBase(TypeClass *tclass, TypeClass *baseclass, Boolean is_v ClassList *scan; if (tclass == baseclass) { - CError_Error(131); + CError_Error(CErrorStr131); return 0; } if (!(baseclass->flags & CLASS_FLAGS_2)) { - CError_Error(136, baseclass, 0); + CError_Error(CErrorStr136, baseclass, 0); return 0; } if (baseclass->flags & CLASS_FLAGS_10) { if (is_virtual || tclass->bases) { - CError_Error(191); + CError_Error(CErrorStr191); return 0; } tclass->flags |= CLASS_FLAGS_10; @@ -4007,7 +4007,7 @@ Boolean CDecl_CheckNewBase(TypeClass *tclass, TypeClass *baseclass, Boolean is_v if (baseclass->flags & CLASS_FLAGS_1) { if (is_virtual || tclass->bases) { - CError_Error(191); + CError_Error(CErrorStr191); return 0; } tclass->flags |= CLASS_FLAGS_1; @@ -4015,25 +4015,25 @@ Boolean CDecl_CheckNewBase(TypeClass *tclass, TypeClass *baseclass, Boolean is_v if (baseclass->sominfo) { if (!is_virtual) - CError_Error(268); + CError_Error(CErrorStr268); CSOM_MakeSOMClass(tclass); } else if (tclass->sominfo) { - CError_Error(267); + CError_Error(CErrorStr267); } if (tclass->bases && (tclass->flags & CLASS_FLAGS_10) && (tclass->flags & CLASS_FLAGS_10)) { - CError_Error(131); + CError_Error(CErrorStr131); return 0; } if (copts.ecplusplus && (is_virtual || tclass->bases)) { - CError_Error(339); + CError_Error(CErrorStr339); return 0; } for (scan = tclass->bases; scan; scan = scan->next) { if (scan->base == baseclass) { - CError_Error(131); + CError_Error(CErrorStr131); return 0; } } @@ -4091,7 +4091,7 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t if (tk == TK_VIRTUAL) { if (is_virtual) - CError_Error(121); + CError_Error(CErrorStr121); is_virtual = 1; tk = lex(); } @@ -4099,11 +4099,11 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t if (CScope_ParseDeclName(&pr)) { if (!pr.x8) { if (!pr.name_4) { - CError_Error(121); + CError_Error(CErrorStr121); } else if (tk == TK_IDENTIFIER && pr.name_4 == tkidentifier) { goto special_parsing; } - CError_Error(140, tkidentifier->name); + CError_Error(CErrorStr140, tkidentifier->name); continue; } @@ -4119,7 +4119,7 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t } if (!IS_TYPE_CLASS(pr.x8) || (TYPE_CLASS(pr.x8)->flags & CLASS_FLAGS_100)) { - CError_Error(131); + CError_Error(CErrorStr131); continue; } baseclass = TYPE_CLASS(pr.x8); @@ -4127,14 +4127,14 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t special_parsing: if (!strcmp(tkidentifier->name, "HandleObject")) { if (tclass->bases) - CError_Error(191); + CError_Error(CErrorStr191); tclass->flags |= CLASS_FLAGS_10 | CLASS_FLAGS_1; tk = lex(); break; } if (!strcmp(tkidentifier->name, "SingleObject") || !strcmp(tkidentifier->name, "SingleInheritance")) { if (tclass->bases) - CError_Error(191); + CError_Error(CErrorStr191); tclass->flags |= CLASS_FLAGS_10; tk = lex(); break; @@ -4146,7 +4146,7 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t } if (!strcmp(tkidentifier->name, "__somobject")) { if (!is_virtual) - CError_Error(268); + CError_Error(CErrorStr268); CSOM_MakeSOMClass(tclass); tk = lex(); break; @@ -4157,7 +4157,7 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t break; } - CError_Error(140, tkidentifier->name); + CError_Error(CErrorStr140, tkidentifier->name); continue; } @@ -4533,7 +4533,7 @@ static void CDecl_SetupClassLayout(DeclE *decle, TypeClass *tclass, ObjBase **ob decle->xA = i - 1; } } else if (TYPE_FUNC(obj->type)->flags & FUNC_FLAGS_8) { - CError_Error(351, obj); + CError_Error(CErrorStr351, obj); TYPE_FUNC(obj->type)->flags &= ~FUNC_FLAGS_8; } } else { @@ -4668,11 +4668,11 @@ void CDecl_ParseClassDeclSpec(UInt8 *declspec) { if (declinfo.exportflags & EXPORT_FLAGS_EXPORT) *declspec |= CLASS_EFLAGS_EXPORT; if ((tk = lex()) != ')') - CError_Error(115); + CError_Error(CErrorStr115); else tk = lex(); } else { - CError_Error(114); + CError_Error(CErrorStr114); } } @@ -4736,7 +4736,7 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class return; } if (!IS_TYPE_TEMPLATE(search) || !(tclass = TYPE_CLASS(CTemplTool_GetSelfRefTemplate(search)))) { - CError_Error(132, classname->name); + CError_Error(CErrorStr132, classname->name); tclass = CDecl_DefineClass(cscope_current, NULL, NULL, mode, 0, 1); break; } @@ -4746,9 +4746,9 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class if (tclass->mode != mode) { if ((mode == CLASS_FLAGS_2 && tclass->mode == CLASS_MODE_0) || (mode == CLASS_MODE_0 && tclass->mode == CLASS_MODE_2)) { if (copts.warn_structclass) - CError_Warning(343); + CError_Warning(CErrorStr343); } else { - CError_Error(132, classname); + CError_Error(CErrorStr132, classname); } } tclass->eflags |= class_declspec; @@ -4763,7 +4763,7 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class } default: if (!CScope_ParseElaborateName(&pr)) { - CError_Error(121); + CError_Error(CErrorStr121); declinfo->thetype = (Type *) &stsignedint; return; } @@ -4783,20 +4783,20 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class declinfo->thetype = (Type *) tclass; if (tk == ':' || tk == '{') { if (declinfo->x4C) - CError_Error(201); + CError_Error(CErrorStr201); if (tclass->flags & CLASS_FLAGS_2) { if ((tclass->flags & CLASS_FLAGS_100) && !TEMPL_CLASS(tclass)->instances && !(TEMPL_CLASS(tclass)->flags & TEMPLCLASS_FLAGS_2)) { tclass = TYPE_CLASS(CDecl_SpecializeTemplateClass(TEMPL_CLASS(tclass))); } else { - CError_Error(132, tclass->classname->name); + CError_Error(CErrorStr132, tclass->classname->name); tclass = CDecl_DefineClass(cscope_current, NULL, NULL, mode, 0, 1); } } for (nspace = cscope_current; nspace; nspace = nspace->parent) { if (nspace == tclass->nspace) { - CError_Error(132, tclass->classname->name); + CError_Error(CErrorStr132, tclass->classname->name); tclass = CDecl_DefineClass(cscope_current, NULL, NULL, mode, 0, 1); break; } @@ -4833,7 +4833,7 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class CBrowse_EndClass(offset, &gl); } } else { - CError_Error(135); + CError_Error(CErrorStr135); } if (is_templ) diff --git a/compiler_and_linker/unsorted/CError.c b/compiler_and_linker/unsorted/CError.c index a7ade45..4c7860d 100644 --- a/compiler_and_linker/unsorted/CError.c +++ b/compiler_and_linker/unsorted/CError.c @@ -26,7 +26,7 @@ char cerror_synchdata[32]; short cerror_synchoffset; int CError_BreakPointcount; -void CError_Init() { +void CError_Init(void) { cerror_errorcount = 0; cerror_lasterrorline = -1; cerror_token = 0; @@ -38,7 +38,7 @@ void CError_SetErrorToken(TStreamElement *token) { cerror_token = token; } -void CError_SetNullErrorToken() { +void CError_SetNullErrorToken(void) { cerror_token = (TStreamElement *) -1; } @@ -52,7 +52,7 @@ void CError_UnlockErrorPos(TStreamElement **saved) { cerror_locktoken = *saved; } -void CError_ResetErrorSkip() { +void CError_ResetErrorSkip(void) { cerror_lasterrorline = -1; } @@ -925,7 +925,7 @@ void CError_OverloadedFunctionError2(Object *obj, ObjectList *olst, ENodeList *a } current->next = NULL; - CError_ErrorFuncCall(392, &first, argNodes); + CError_ErrorFuncCall(CErrorStr392, &first, argNodes); } void CError_OverloadedFunctionError(Object *obj, ObjectList *olst) { @@ -936,7 +936,7 @@ void CError_OverloadedFunctionError(Object *obj, ObjectList *olst) { if (trychain) longjmp(trychain->jmpbuf, 1); - CError_GetErrorString(string, 199); + CError_GetErrorString(string, CErrorStr199); CError_BufferInit(&eb, buf, sizeof(buf)); CError_BufferAppendString(&eb, string); @@ -960,9 +960,9 @@ void CError_OverloadedFunctionError(Object *obj, ObjectList *olst) { void CError_AbstractClassError(TypeClass *tclass) { Object *result = CClass_CheckPures(tclass); if (!result) - CError_Error(372, tclass, 0); + CError_Error(CErrorStr372, tclass, 0); else - CError_Error(194, result); + CError_Error(CErrorStr194, result); } void CError_Warning(int code, ...) { @@ -989,23 +989,23 @@ void CError_Internal(char *filename, int line) { CError_BreakPoint(0, 0); } -void CError_ExpressionTooComplex() { +void CError_ExpressionTooComplex(void) { CompilerGetCString(6, string); CError_ErrorMessage(10002, string, 1, 0); longjmp(errorreturn, 1); } -void CError_NoMem() { +void CError_NoMem(void) { cprep_nomem_exit = 1; longjmp(errorreturn, 1); } -void CError_UserBreak() { +void CError_UserBreak(void) { CompilerGetCString(8, string); longjmp(errorreturn, 1); } -void CError_CannotOpen() { +void CError_CannotOpen(void) { CompilerGetCString(9, string); CWReportMessage(cparamblkptr->context, NULL, string, NULL, messagetypeError, 0); longjmp(errorreturn, 1); diff --git a/compiler_and_linker/unsorted/CExpr.c b/compiler_and_linker/unsorted/CExpr.c index f305fc9..8deb0ed 100644 --- a/compiler_and_linker/unsorted/CExpr.c +++ b/compiler_and_linker/unsorted/CExpr.c @@ -823,11 +823,11 @@ static ENode *CExpr_ParseExplicitConversion(Type *type, UInt32 qual) { if (tk == '(') tk = lex(); else - CError_Error(114); + CError_Error(CErrorStr114); args = CExpr_ScanExpressionList(1); if (tk != ')') { - CError_Error(115); + CError_Error(CErrorStr115); return nullnode(); } @@ -930,7 +930,7 @@ ENode *CExpr_MakeNameLookupResultExpr(CScopeParseResult *pr) { expr->data.intval = OBJ_ENUM_CONST(pr->obj_10)->val; return expr; case OT_MEMBERVAR: - CError_Error(0xDD); + CError_Error(CErrorStr221); return nullnode(); default: CError_FATAL(1268); @@ -1079,19 +1079,19 @@ static ENode *CExpr_ParseNameResultExpr(CScopeParseResult *pr, ENode *expr, Bool } if (CClass_IsDestructor(OBJECT(pr->obj_10))) { if ((tk = lex()) != '(') { - CError_Error(114); + CError_Error(CErrorStr114); return nullnode(); } if ((tk = lex()) != ')') { - CError_Error(115); + CError_Error(CErrorStr115); return nullnode(); } if (!expr && (!cscope_currentfunc || !cscope_currentclass || !cscope_is_member_func)) { - CError_Error(221); + CError_Error(CErrorStr221); return nullnode(); } if (pr->isambig) - CError_Error(188); + CError_Error(CErrorStr188); if ((expr = CExpr_GetClassAccessNode(pr->bcl_18, NULL, expr, OBJECT(pr->obj_10), pr->obj_10->access, 1))) { tk = lex(); @@ -1136,7 +1136,7 @@ static ENode *CExpr_ParseNameResultExpr(CScopeParseResult *pr, ENode *expr, Bool case OT_MEMBERVAR: if (!flag1 || expr || !pr->x1D) { if (pr->isambig) - CError_Error(188); + CError_Error(CErrorStr188); result = checkreference(CExpr_MemberVarAccess(pr->bcl_18, OBJ_MEMBER_VAR(pr->obj_10), expr)); tk = lex(); return result; @@ -1242,7 +1242,7 @@ static ENode *CExpr_ParseNameResultExpr(CScopeParseResult *pr, ENode *expr, Bool } if (copts.require_prototypes) - CError_Error(178); + CError_Error(CErrorStr178); tfunc = galloc(sizeof(TypeFunc)); memclrw(tfunc, sizeof(TypeFunc)); @@ -1271,7 +1271,7 @@ static ENode *CExpr_ParseRotate(Boolean is_right) { ENode *expr2; if (lex() != '(') { - CError_Error(114); + CError_Error(CErrorStr114); return nullnode(); } @@ -1279,7 +1279,7 @@ static ENode *CExpr_ParseRotate(Boolean is_right) { expr1 = assignment_expression(); if (tk != ',') { - CError_Error(116); + CError_Error(CErrorStr116); return nullnode(); } @@ -1287,7 +1287,7 @@ static ENode *CExpr_ParseRotate(Boolean is_right) { expr2 = assignment_expression(); if (tk != ')') { - CError_Error(115); + CError_Error(CErrorStr115); return nullnode(); } @@ -1309,22 +1309,22 @@ static ENode *CExpr_ParseNextArg(void) { SInt32 rounded_size; if ((tk = lex()) != '(') { - CError_Error(114); + CError_Error(CErrorStr114); return nullnode(); } if ((tk = lex()) != TK_IDENTIFIER) { - CError_Error(0x6B); + CError_Error(CErrorStr107); return nullnode(); } list = CScope_FindObjectList(&pr, tkidentifier); if (!list) { - CError_Error(140, tkidentifier->name); + CError_Error(CErrorStr140, tkidentifier->name); return nullnode(); } if (list->object->otype != OT_OBJECT || OBJECT(list->object)->datatype != DLOCAL) { - CError_Error(140, tkidentifier->name); + CError_Error(CErrorStr140, tkidentifier->name); return nullnode(); } @@ -1334,7 +1334,7 @@ static ENode *CExpr_ParseNextArg(void) { expr->rtype = TYPE(&void_ptr); if ((tk = lex()) != ')') { - CError_Error(115); + CError_Error(CErrorStr115); return expr; } else { tk = lex(); @@ -1356,10 +1356,10 @@ static ENode *CExpr_ParseVecStep(void) { CParser_GetDeclSpecs(&di, 0); scandeclarator(&di); if (di.name) - CError_Error(121); + CError_Error(CErrorStr121); if (tk != ')') - CError_ErrorSkip(115); + CError_ErrorSkip(CErrorStr115); else tk = lex(); @@ -1369,7 +1369,7 @@ static ENode *CExpr_ParseVecStep(void) { } else { expr = unary_expression(); if (ENODE_IS(expr, EINDIRECT) && ENODE_IS(expr->data.monadic, EBITFIELD)) - CError_Error(144); + CError_Error(CErrorStr144); type = expr->rtype; } @@ -1395,7 +1395,7 @@ static ENode *CExpr_ParseVecStep(void) { PPCError_Error(104, "vec_step", "vec_step", type, 0); } } else { - CError_Error(114); + CError_Error(CErrorStr114); } return expr; @@ -1459,7 +1459,7 @@ static SInt32 CExpr_BuiltInComputeType(Type *type) { case TYPEFUNC: return 0x8000; default: - CError_Error(146); + CError_Error(CErrorStr146); case TYPEVOID: return 0; } @@ -1506,10 +1506,10 @@ static Type *CExpr_ParseTypeExpression(Boolean *outflag) { CParser_GetDeclSpecs(&di, 0); scandeclarator(&di); if (di.name) - CError_Error(121); + CError_Error(CErrorStr121); if (tk != ')') - CError_ErrorSkip(115); + CError_ErrorSkip(CErrorStr115); else tk = lex(); @@ -1519,7 +1519,7 @@ static Type *CExpr_ParseTypeExpression(Boolean *outflag) { } else { expr = unary_expression(); if (ENODE_IS(expr, EINDIRECT) && ENODE_IS(expr->data.monadic, EBITFIELD)) - CError_Error(144); + CError_Error(CErrorStr144); if (outflag) *outflag = ENODE_IS(expr, EINTCONST) && CInt64_IsZero(&expr->data.intval); @@ -1544,7 +1544,7 @@ static ENode *CExpr_ParseBuiltin_isintconst(void) { tk = lex(); if (tk != '(') - CError_ErrorSkip(121); + CError_ErrorSkip(CErrorStr121); else tk = lex(); @@ -1552,7 +1552,7 @@ static ENode *CExpr_ParseBuiltin_isintconst(void) { CInt64_SetLong(&expr->data.intval, 1); if (tk != ')') - CError_ErrorSkip(115); + CError_ErrorSkip(CErrorStr115); else tk = lex(); @@ -1645,7 +1645,7 @@ static ENode *primary_expression(Boolean flag) { tk = lex(); expr = s_expression(); if (tk != ')') - CError_ErrorSkip(115); + CError_ErrorSkip(CErrorStr115); else tk = lex(); if (ENODE_IS(expr, EASS)) @@ -1680,7 +1680,7 @@ static ENode *primary_expression(Boolean flag) { return nullnode(); } - CError_ErrorSkip(141); + CError_ErrorSkip(CErrorStr141); return nullnode(); } @@ -1690,7 +1690,7 @@ static ENode *CExpr_SimpleExplicitConversion(void) { memclrw(&di, sizeof(DeclInfo)); if (!copts.cpp_extensions && tk != TK_UU_TYPEOF_UU && tk != TK_TYPENAME && lookahead() != '(') - CError_Error(114); + CError_Error(CErrorStr114); CParser_GetDeclSpecs(&di, 0); return CExpr_ParseExplicitConversion(di.thetype, di.qual); @@ -1701,7 +1701,7 @@ static ENode *CExpr_NewPTMFCall(void) { CExpr_ScanExpressionList(1); if (tk != ')') { - CError_Error(115); + CError_Error(CErrorStr115); return nullnode(); } else { CError_FATAL(2465); @@ -1721,7 +1721,7 @@ static ENode *call_ptmf(ENode *expr) { args = CExpr_ScanExpressionList(1); if (tk != ')') { - CError_Error(115); + CError_Error(CErrorStr115); return nullnode(); } @@ -1785,12 +1785,12 @@ loop: goto loop; } else { if (!is_typesame(pr.x8, expr->rtype)) - CError_Error(146); + CError_Error(CErrorStr146); if (tk == TK_COLON_COLON && ((tk = lex()) == '~') && ((tk = lex()) == TK_IDENTIFIER)) { parse_dtor: if (CScope_FindTypeName(nspace, tkidentifier, &pr) && !pr.nspace_0) { if (!is_typesame(pr.x8, expr->rtype)) - CError_Error(146); + CError_Error(CErrorStr146); tk = lex(); goto parsed; } @@ -1801,7 +1801,7 @@ loop: memclrw(&di, sizeof(DeclInfo)); CParser_GetDeclSpecs(&di, 0); if (di.storageclass || di.qual || !is_typesame(di.thetype, expr->rtype)) - CError_Error(146); + CError_Error(CErrorStr146); if (tk == TK_COLON_COLON && ((tk = lex()) == '~')) { is_tilde: if ((tk = lex()) == TK_IDENTIFIER) @@ -1809,22 +1809,22 @@ loop: memclrw(&di, sizeof(DeclInfo)); CParser_GetDeclSpecs(&di, 0); if (di.storageclass || !is_typesame(di.thetype, expr->rtype)) - CError_Error(146); + CError_Error(CErrorStr146); goto parsed; } } - CError_Error(141); + CError_Error(CErrorStr141); return NULL; parsed: if (tk == '(') { if ((tk = lex()) != ')') - CError_Error(115); + CError_Error(CErrorStr115); else tk = lex(); } else { - CError_Error(114); + CError_Error(CErrorStr114); } expr = makemonadicnode(expr, ETYPCON); @@ -1900,7 +1900,7 @@ loop: if (copts.cplusplus && CExpr_CheckOperator('[', expr, subexpr, &conv)) { if ((expr = conv.x0)) { if (tk != ']') - CError_ErrorSkip(125); + CError_ErrorSkip(CErrorStr125); else tk = lex(); goto loop; @@ -1915,14 +1915,14 @@ loop: } else if (IS_TYPE_POINTER(subexpr->rtype)) { expr = padd(subexpr, expr); } else { - CError_Error(148); + CError_Error(CErrorStr148); goto dont_do_indirect; } expr = makemonadicnode(expr, EINDIRECT); expr->rtype = TPTR_TARGET(expr->rtype); dont_do_indirect: if (tk != ']') - CError_ErrorSkip(125); + CError_ErrorSkip(CErrorStr125); else tk = lex(); goto loop; @@ -1943,7 +1943,7 @@ loop: tk = lex(); args = CExpr_ScanExpressionList(1); if (tk != ')') - CError_Error(115); + CError_Error(CErrorStr115); if (ENODE_IS(funcexpr, ETEMPLDEP)) { expr = CExpr_NewENode(EFUNCCALL); @@ -1968,7 +1968,7 @@ loop: } if (!IS_TYPE_POINTER(expr->rtype)) { - CError_ErrorSkip(148); + CError_ErrorSkip(CErrorStr148); return expr; } @@ -1989,20 +1989,20 @@ loop: return subexpr; if (!(TYPE_CLASS(expr->rtype)->flags & CLASS_FLAGS_2)) - CError_Error(136, expr->rtype, 0); + CError_Error(CErrorStr136, expr->rtype, 0); if ((tk = lex()) == TK_TEMPLATE && (tk = lex()) != TK_IDENTIFIER) - CError_Error(107); + CError_Error(CErrorStr107); if (CScope_ParseMemberName(TYPE_CLASS(expr->rtype), &pr, 0)) { if (pr.x1C) { if ((tk = lex()) == '(') { if ((tk = lex()) != ')') - CError_Error(115); + CError_Error(CErrorStr115); else tk = lex(); } else { - CError_Error(114); + CError_Error(CErrorStr114); } expr = makemonadicnode(expr, ETYPCON); @@ -2016,7 +2016,7 @@ loop: if (!IS_TYPE_STRUCT(expr->rtype) || TYPE_STRUCT(expr->rtype)->stype > STRUCT_TYPE_3) { if (copts.cplusplus && (subexpr = CExpr_DummyDestr(expr))) return subexpr; - CError_ErrorSkip(149); + CError_ErrorSkip(CErrorStr149); return expr; } if (!ENODE_IS(expr, EINDIRECT)) { @@ -2036,21 +2036,21 @@ loop: expr = tmp; } if ((tk = lex()) != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return expr; } member = ismember(TYPE_STRUCT(expr->rtype), tkidentifier); if (!member) { if (!expr->rtype->size) - CError_Error(136, expr->rtype, 0); + CError_Error(CErrorStr136, expr->rtype, 0); else - CError_Error(150, tkidentifier->name); + CError_Error(CErrorStr150, tkidentifier->name); return expr; } if (!IS_TYPE_POINTER(expr->data.monadic->rtype)) { - CError_ErrorSkip(149); + CError_ErrorSkip(CErrorStr149); return expr; } @@ -2103,7 +2103,7 @@ static ENode *CExpr_ParseSizeof(void) { type = CExpr_ParseTypeExpression(NULL); if (IS_TYPE_CLASS(type) && TYPE_CLASS(type)->sominfo) - CError_Error(286); + CError_Error(CErrorStr286); if (CTemplTool_IsTemplateArgumentDependentType(type)) { expr = CExpr_NewTemplDepENode(TDE_SIZEOF); @@ -2116,9 +2116,9 @@ static ENode *CExpr_ParseSizeof(void) { return intconstnode(CABI_GetSizeTType(), 1); if (IS_TYPE_CLASS(type) || IS_TYPE_STRUCT(type)) - CError_Error(136, type, 0); + CError_Error(CErrorStr136, type, 0); else - CError_Error(146); + CError_Error(CErrorStr146); } return intconstnode(CABI_GetSizeTType(), type->size); @@ -2129,7 +2129,7 @@ SInt32 scansizeof(void) { expr = CExpr_ParseSizeof(); if (!ENODE_IS(expr, EINTCONST)) { - CError_Error(190); + CError_Error(CErrorStr190); return 0; } @@ -2143,7 +2143,7 @@ static ENode *CExpr_ParseAlignof(void) { type = CExpr_ParseTypeExpression(NULL); if (IS_TYPE_CLASS(type) && TYPE_CLASS(type)->sominfo) - CError_Error(364); + CError_Error(CErrorStr364); if (CTemplTool_IsTemplateArgumentDependentType(type)) { expr = CExpr_NewTemplDepENode(TDE_ALIGNOF); @@ -2153,9 +2153,9 @@ static ENode *CExpr_ParseAlignof(void) { if (type->size == 0) { if (IS_TYPE_CLASS(type) || IS_TYPE_STRUCT(type)) - CError_Error(136, type, 0); + CError_Error(CErrorStr136, type, 0); else - CError_Error(146); + CError_Error(CErrorStr146); } align = CMach_GetTypeAlign(type); @@ -2170,7 +2170,7 @@ SInt32 scanalignof(void) { expr = CExpr_ParseAlignof(); if (!ENODE_IS(expr, EINTCONST)) { - CError_Error(190); + CError_Error(CErrorStr190); return 0; } @@ -2193,7 +2193,7 @@ ENode *getnodeaddress(ENode *expr, Boolean flag) { expr = CExpr_LValue(expr, flag, flag); if (!ENODE_IS(expr, EINDIRECT)) { if (!flag) - CError_Error(142); + CError_Error(CErrorStr142); return nullnode(); } } else { @@ -2203,7 +2203,7 @@ ENode *getnodeaddress(ENode *expr, Boolean flag) { cscope_currentfunc && cscope_currentclass && expr->data.monadic->data.objref == CClass_ThisSelfObject()) - CError_Error(189); + CError_Error(CErrorStr189); } result = lalloc(sizeof(ENode)); @@ -2226,17 +2226,17 @@ restart: goto restart; } if (obj->datatype == DINLINEFUNC) - CError_Error(175); + CError_Error(CErrorStr175); obj->flags |= OBJECT_FLAGS_2; if (flag && !copts.cplusplus && obj->sclass == TK_REGISTER) - CError_Error(163); + CError_Error(CErrorStr163); break; case EFUNCCALL: if (flag && !IS_TYPE_POINTER_ONLY(result->data.monadic->data.funccall.functype->functype)) - CError_Warning(142); + CError_Warning(CErrorStr142); break; case EBITFIELD: - CError_Error(144); + CError_Error(CErrorStr144); return nullnode(); } @@ -2270,7 +2270,7 @@ static ENode *CExpr_MakeStaticMemberList(NameSpaceObjectList *list) { } if (!newlist) { - CError_Warning(331); + CError_Warning(CErrorStr331); return nullnode(); } @@ -2303,12 +2303,12 @@ ENode *getpointertomemberfunc(ENode *expr, Type *type, Boolean flag) { CError_ASSERT(3442, ENODE_IS(expr, EMEMBER)); if (expr->data.emember->expr && !copts.cpp_extensions) - CError_Error(141); + CError_Error(CErrorStr141); if (!copts.cpp_extensions) { if (!(expr->data.emember->x11 && expr->data.emember->pr_1D)) { if (type && IS_TYPE_MEMBERPOINTER(type)) - CError_Warning(331); + CError_Warning(CErrorStr331); } } @@ -2323,7 +2323,7 @@ ENode *getpointertomemberfunc(ENode *expr, Type *type, Boolean flag) { } } if (!list) { - CError_Error(146); + CError_Error(CErrorStr146); return nullnode(); } } else { @@ -2342,7 +2342,7 @@ ENode *getpointertomemberfunc(ENode *expr, Type *type, Boolean flag) { CError_ASSERT(3503, obj->otype == OT_OBJECT && IS_TYPE_NONSTATIC_METHOD(obj->type)); if (TYPE_FUNC(obj->type)->flags & FUNC_FLAGS_100000) - CError_Error(190); + CError_Error(CErrorStr190); ptmtype = CExpr_NewPTMType(expr->data.emember, obj); tmethod = TYPE_METHOD(obj->type); @@ -2377,7 +2377,7 @@ static ENode *getpointertomember(ENode *expr) { CError_ASSERT(3554, ENODE_IS(expr, EMEMBER)); if (expr->data.emember->expr) - CError_Error(141); + CError_Error(CErrorStr141); expr->data.emember->x11 = 1; if (!expr->data.emember->list->next) { @@ -2417,7 +2417,7 @@ ENode *CExpr_New_ELOGNOT_Node(ENode *input) { expr = CExpr_ConvertToCondition(expr); break; default: - CError_Error(144); + CError_Error(CErrorStr144); return expr; } @@ -2466,7 +2466,7 @@ ENode *CExpr_New_EMONMIN_Node(ENode *input) { } return CExpr_UnaryFloatExpression(makemonadicnode(expr, EMONMIN)); default: - CError_Error(144); + CError_Error(CErrorStr144); return expr; } } @@ -2599,7 +2599,7 @@ ENode *unary_expression(void) { } if (!IS_TYPE_POINTER(expr->rtype)) { - CError_Error(148); + CError_Error(CErrorStr148); return expr; } @@ -2625,7 +2625,7 @@ ENode *unary_expression(void) { case TYPEARRAY: return expr; default: - CError_Error(144); + CError_Error(CErrorStr144); return expr; } @@ -2649,7 +2649,7 @@ ENode *unary_expression(void) { break; if ((tk = lex()) != TK_IDENTIFIER) { - CError_Error(107); + CError_Error(CErrorStr107); return nullnode(); } @@ -2730,7 +2730,7 @@ ENode *PointerToMemberCast(ENode *expr, TypeMemberPointer *tm1, TypeMemberPointe } if (isambig) - CError_Error(188); + CError_Error(CErrorStr188); if ((pathoffset = CClass_GetPathOffset(path)) < 0) goto failed; @@ -2742,7 +2742,7 @@ ENode *PointerToMemberCast(ENode *expr, TypeMemberPointer *tm1, TypeMemberPointe if (tm1->size != tm2->size) { failed: - CError_Error(247, tm1, 0, tm2, 0); + CError_Error(CErrorStr247, tm1, 0, tm2, 0); return nullnode(); } @@ -2794,7 +2794,7 @@ static ENode *CExpr_MemberPointerCast(ENode *expr, TypeMemberPointer *type, UInt expr = CExpr_MemberPointerConversion(expr, type, 1); if (!IS_TYPE_MEMBERPOINTER(expr->rtype)) { - CError_Error(164); + CError_Error(CErrorStr164); return nullnode(); } @@ -2820,7 +2820,7 @@ ENode *do_typecast(ENode *expr, Type *type, UInt32 qual) { switch (type->type) { case TYPEARRAY: - CError_Error(247, expr->rtype, ENODE_QUALS(expr), type, qual); + CError_Error(CErrorStr247, expr->rtype, ENODE_QUALS(expr), type, qual); return expr; case TYPEMEMBERPOINTER: if (!IS_TYPE_CLASS(expr->rtype)) @@ -2833,7 +2833,7 @@ ENode *do_typecast(ENode *expr, Type *type, UInt32 qual) { return CExpr_AssignmentPromotion(expr, type, flags, 1); if (ENODE_IS(expr, EOBJREF) && IS_TYPE_NONSTATIC_METHOD(expr->data.objref->type)) { - CError_Error(221); + CError_Error(CErrorStr221); return nullnode(); } @@ -2869,7 +2869,7 @@ ENode *do_typecast(ENode *expr, Type *type, UInt32 qual) { return assign_node; } - CError_Error(247, expr->rtype, ENODE_QUALS(expr), type, qual); + CError_Error(CErrorStr247, expr->rtype, ENODE_QUALS(expr), type, qual); return nullnode(); } @@ -2913,7 +2913,7 @@ ENode *do_typecast(ENode *expr, Type *type, UInt32 qual) { } if (!(IS_TYPE_POINTER_ONLY(expr->rtype) && !IS_TYPE_FLOAT(type))) - CError_Error(247, expr->rtype, ENODE_QUALS(expr), type, qual); + CError_Error(CErrorStr247, expr->rtype, ENODE_QUALS(expr), type, qual); if (ENODE_IS(expr, ETYPCON) && ENODE_IS(tmp = expr->data.monadic, EINTCONST)) { tmp->rtype = type; @@ -2948,7 +2948,7 @@ ENode *do_typecast(ENode *expr, Type *type, UInt32 qual) { if (!IS_TYPE_INT(expr->rtype)) { if (!IS_TYPE_ENUM(expr->rtype)) { - CError_Error(247, expr->rtype, ENODE_QUALS(expr), type, qual); + CError_Error(CErrorStr247, expr->rtype, ENODE_QUALS(expr), type, qual); return expr; } expr = forceintegral(expr); @@ -2969,7 +2969,7 @@ ENode *do_typecast(ENode *expr, Type *type, UInt32 qual) { if ((tmp = CodeGen_HandleTypeCast(expr, type, qual))) return tmp; - CError_Error(247, expr->rtype, ENODE_QUALS(expr), type, qual); + CError_Error(CErrorStr247, expr->rtype, ENODE_QUALS(expr), type, qual); return nullnode(); } @@ -2996,18 +2996,18 @@ ENode *cast_expression(void) { scandeclarator(&di); if (tk != ')') - CError_ErrorSkip(115); + CError_ErrorSkip(CErrorStr115); else tk = lex(); if (di.name) - CError_Error(164); + CError_Error(CErrorStr164); if (copts.altivec_model && tk == '(' && IS_TYPE_VECTOR(di.thetype)) { tk = lex(); expr = s_expression(); if (tk != ')') - CError_ErrorSkip(115); + CError_ErrorSkip(CErrorStr115); else tk = lex(); @@ -3067,7 +3067,7 @@ restart: } if (!IS_TYPE_POINTER(left->rtype)) { - CError_Error(148); + CError_Error(CErrorStr148); return left; } @@ -3079,16 +3079,16 @@ restart: tk = lex(); right = pointer_generation(cast_expression()); if (!ENODE_IS(left, EINDIRECT)) { - CError_Error(142); + CError_Error(CErrorStr142); return left; } common_part: if (!IS_TYPE_CLASS(left->rtype)) { - CError_Error(149); + CError_Error(CErrorStr149); return left; } if (!IS_TYPE_MEMBERPOINTER(right->rtype)) { - CError_Error(144); + CError_Error(CErrorStr144); return left; } if (left->rtype != TYPE_MEMBER_POINTER(right->rtype)->ty2) { @@ -3100,7 +3100,7 @@ restart: 0, 1, 1); left->rtype = TYPE_MEMBER_POINTER(right->rtype)->ty2; } else { - CError_Error(146); + CError_Error(CErrorStr146); return left; } } @@ -3212,7 +3212,7 @@ ENode *CExpr_New_EMODULO_Node(ENode *left, ENode *right, Boolean no_warning) { if (iszero(right)) { if (!no_warning) - CError_Warning(139); + CError_Warning(CErrorStr139); return left; } @@ -3346,34 +3346,34 @@ static ENode *pointercompare(ENodeType nt, ENode *left, ENode *right) { } else if (CClass_IsBaseClass(TYPE_CLASS(rtype), TYPE_CLASS(ltype), NULL, 0, 1)) { right = CExpr_SafeClassPointerCast(right, TYPE_CLASS(rtype), TYPE_CLASS(ltype), 0, 1); } else { - CError_Error(245, left->rtype, ENODE_QUALS(left), right->rtype, ENODE_QUALS(right)); + CError_Error(CErrorStr245, left->rtype, ENODE_QUALS(left), right->rtype, ENODE_QUALS(right)); } } else { - CError_Error(245, left->rtype, ENODE_QUALS(left), right->rtype, ENODE_QUALS(right)); + CError_Error(CErrorStr245, left->rtype, ENODE_QUALS(left), right->rtype, ENODE_QUALS(right)); } } } else if (!is_typeequal(left->rtype, right->rtype)) { if (!copts.objective_c || !CObjC_IsCompatibleType(left->rtype, right->rtype)) { - CError_Error(245, left->rtype, ENODE_QUALS(left), right->rtype, ENODE_QUALS(right)); + CError_Error(CErrorStr245, left->rtype, ENODE_QUALS(left), right->rtype, ENODE_QUALS(right)); } } } else if (nt == EEQU || nt == ENOTEQU) { if (IS_TYPE_INT(ltype)) { if (!(ENODE_IS(left, EINTCONST) && CInt64_IsZero(&left->data.intval))) - CError_Error(144); + CError_Error(CErrorStr144); CError_ASSERT(4847, IS_TYPE_POINTER_ONLY(rtype)); left->rtype = TYPE(&stunsignedlong); } else if (IS_TYPE_INT(rtype)) { if (!(ENODE_IS(right, EINTCONST) && CInt64_IsZero(&right->data.intval))) - CError_Error(144); + CError_Error(CErrorStr144); CError_ASSERT(4855, IS_TYPE_POINTER_ONLY(ltype)); right->rtype = TYPE(&stunsignedlong); } else if (!is_typeequal(ltype, rtype)) { - CError_Error(245, left->rtype, ENODE_QUALS(left), right->rtype, ENODE_QUALS(right)); + CError_Error(CErrorStr245, left->rtype, ENODE_QUALS(left), right->rtype, ENODE_QUALS(right)); } } else { if (!is_typeequal(ltype, rtype)) - CError_Error(245, left->rtype, ENODE_QUALS(left), right->rtype, ENODE_QUALS(right)); + CError_Error(CErrorStr245, left->rtype, ENODE_QUALS(left), right->rtype, ENODE_QUALS(right)); } return logicalexpression(makediadicnode(left, right, nt)); @@ -3538,12 +3538,12 @@ ENode *memberpointercompare(ENodeType nt, ENode *left, ENode *right) { if (!IS_TYPE_MEMBERPOINTER(left->rtype)) { if (!(IS_TYPE_INT(left->rtype) && ENODE_IS(left, EINTCONST) && CInt64_IsZero(&left->data.intval))) { - CError_Error(144); + CError_Error(CErrorStr144); return nullnode(); } } else if (!IS_TYPE_MEMBERPOINTER(right->rtype)) { if (!(IS_TYPE_INT(right->rtype) && ENODE_IS(right, EINTCONST) && CInt64_IsZero(&right->data.intval))) { - CError_Error(144); + CError_Error(CErrorStr144); return nullnode(); } } else if (!is_typeequal(left->rtype, right->rtype)) { @@ -3788,7 +3788,7 @@ ENode *CExpr_New_ELAND_Node(ENode *left, ENode *right) { left = CExpr_ConvertToCondition(left); break; default: - CError_Error(144); + CError_Error(CErrorStr144); left = nullnode(); } switch (right->rtype->type) { @@ -3802,7 +3802,7 @@ ENode *CExpr_New_ELAND_Node(ENode *left, ENode *right) { right = CExpr_ConvertToCondition(right); break; default: - CError_Error(144); + CError_Error(CErrorStr144); right = nullnode(); } @@ -3873,7 +3873,7 @@ ENode *CExpr_New_ELOR_Node(ENode *left, ENode *right) { left = CExpr_ConvertToCondition(left); break; default: - CError_Error(144); + CError_Error(CErrorStr144); left = nullnode(); } switch (right->rtype->type) { @@ -3887,7 +3887,7 @@ ENode *CExpr_New_ELOR_Node(ENode *left, ENode *right) { right = CExpr_ConvertToCondition(right); break; default: - CError_Error(144); + CError_Error(CErrorStr144); right = nullnode(); } @@ -4134,7 +4134,7 @@ ENode *CExpr_New_ECOND_Node(ENode *cond, ENode *expr1, ENode *expr2) { expr2 = pointer_generation(expr2); if (!IS_TYPE_INT_OR_FLOAT(cond->rtype) && !IS_TYPE_POINTER_ONLY(cond->rtype)) { - CError_Error(144); + CError_Error(CErrorStr144); return nullnode(); } @@ -4197,7 +4197,7 @@ ENode *CExpr_New_ECOND_Node(ENode *cond, ENode *expr1, ENode *expr2) { expr2 = conv.right; } else if (CExpr_CanImplicitlyConvert(expr1, expr2->rtype, ENODE_QUALS(expr2))) { if (CExpr_CanImplicitlyConvert(expr2, expr1->rtype, ENODE_QUALS(expr1))) - CError_Error(188); + CError_Error(CErrorStr188); expr1 = CExpr_Convert(expr1, expr2->rtype, ENODE_QUALS(expr2), 0, 1); } else if (CExpr_CanImplicitlyConvert(expr2, expr1->rtype, ENODE_QUALS(expr1))) { expr2 = CExpr_Convert(expr2, expr1->rtype, ENODE_QUALS(expr1), 0, 1); @@ -4295,7 +4295,7 @@ ENode *CExpr_New_ECOND_Node(ENode *cond, ENode *expr1, ENode *expr2) { expr2 = CExpr_Convert(expr2, expr1->rtype, ENODE_QUALS(expr1), 0, 1); } else if (CExpr_CanImplicitlyConvert(expr1, expr2->rtype, ENODE_QUALS(expr2))) { if (CExpr_CanImplicitlyConvert(expr2, expr1->rtype, ENODE_QUALS(expr1))) - CError_Error(188); + CError_Error(CErrorStr188); expr1 = CExpr_Convert(expr1, expr2->rtype, ENODE_QUALS(expr2), 0, 1); } else if (CExpr_CanImplicitlyConvert(expr2, expr1->rtype, ENODE_QUALS(expr1))) { expr2 = CExpr_Convert(expr2, expr1->rtype, ENODE_QUALS(expr1), 0, 1); @@ -4306,7 +4306,7 @@ ENode *CExpr_New_ECOND_Node(ENode *cond, ENode *expr1, ENode *expr2) { break; default: failed: - CError_Error(245, expr1->rtype, ENODE_QUALS(expr1), expr2->rtype, ENODE_QUALS(expr2)); + CError_Error(CErrorStr245, expr1->rtype, ENODE_QUALS(expr1), expr2->rtype, ENODE_QUALS(expr2)); return nullnode(); } @@ -4335,7 +4335,7 @@ static ENode *conditional_expression(void) { if (!IS_TYPE_TEMPLDEPEXPR(cond->rtype)) { cond = CExpr_ConvertToCondition(cond); if (!IS_TYPE_INT_OR_FLOAT(cond->rtype) && !IS_TYPE_POINTER_ONLY(cond->rtype)) { - CError_Error(144); + CError_Error(CErrorStr144); return nullnode(); } } else { @@ -4345,7 +4345,7 @@ static ENode *conditional_expression(void) { tk = lex(); expr1 = expression(); if (tk != ':') - CError_ErrorSkip(141); + CError_ErrorSkip(CErrorStr141); else tk = lex(); @@ -4408,7 +4408,7 @@ static ENode *makeassignmentnode(ENode *left, ENodeType nt, short token) { return conv.x0; } if (IS_TYPE_CLASS(left->rtype) && CClass_AssignmentOperator(TYPE_CLASS(left->rtype))) - CError_Error(144); + CError_Error(CErrorStr144); } continue_anyway: if (IS_TYPE_ARRAY(left->rtype)) { @@ -4417,7 +4417,7 @@ continue_anyway: tmp->flags = left->flags; return tmp; } - CError_Error(144); + CError_Error(CErrorStr144); return nullnode(); } @@ -4425,19 +4425,19 @@ continue_anyway: if (nt != EASS) { if (!IS_TYPE_INT(right->rtype)) { if (!IS_TYPE_ENUM(right->rtype)) { - CError_Error(144); + CError_Error(CErrorStr144); return left; } right = forceintegral(right); } if (!IS_TYPE_INT(left->rtype)) { if (copts.cplusplus) { - CError_Error(144); + CError_Error(CErrorStr144); return left; } left = forceintegral(left); if (!IS_TYPE_INT(left->rtype)) { - CError_Error(144); + CError_Error(CErrorStr144); return left; } } @@ -4445,7 +4445,7 @@ continue_anyway: } if (IS_TYPE_CLASS(left->rtype) && TYPE_CLASS(left->rtype)->sominfo) { - CError_Error(285); + CError_Error(CErrorStr285); return left; } @@ -4515,7 +4515,7 @@ static ENode *makepassignmentnode(ENode *left, ENodeType nt, short token) { } if (is_array) - CError_Error(144); + CError_Error(CErrorStr144); switch (left->rtype->type) { case TYPEINT: @@ -4524,13 +4524,13 @@ static ENode *makepassignmentnode(ENode *left, ENodeType nt, short token) { break; case TYPEENUM: if (copts.cplusplus) { - CError_Error(144); + CError_Error(CErrorStr144); return left; } left = forceintegral(left); break; default: - CError_Error(144); + CError_Error(CErrorStr144); return left; } @@ -4554,7 +4554,7 @@ static ENode *makepassignmentnode(ENode *left, ENodeType nt, short token) { return left; } } - CError_Error(144); + CError_Error(CErrorStr144); return left; } else { return CExpr_MakeOpAssNode(left, right, nt); @@ -4576,7 +4576,7 @@ static ENode *makemulassignmentnode(ENode *left, ENodeType nt, short token) { return conv.x0; } if (!IS_TYPE_INT(left->rtype) && !(IS_TYPE_FLOAT(left->rtype) && nt != EMODASS)) { - CError_Error(144); + CError_Error(CErrorStr144); return nullnode(); } left = CExpr_LValue(left, 1, 1); @@ -4584,7 +4584,7 @@ static ENode *makemulassignmentnode(ENode *left, ENodeType nt, short token) { if (IS_TYPE_ENUM(left->rtype)) left = forceintegral(left); if (!IS_TYPE_INT(left->rtype) && !(IS_TYPE_FLOAT(left->rtype) && nt != EMODASS)) { - CError_Error(144); + CError_Error(CErrorStr144); return nullnode(); } @@ -4594,13 +4594,13 @@ static ENode *makemulassignmentnode(ENode *left, ENodeType nt, short token) { } if (is_array) - CError_Error(144); + CError_Error(CErrorStr144); if (IS_TYPE_ENUM(right->rtype)) right = forceintegral(right); if (IS_TYPE_INT(left->rtype) && IS_TYPE_FLOAT(right->rtype) && nt == EMODASS) { - CError_Error(144); + CError_Error(CErrorStr144); return nullnode(); } @@ -4655,7 +4655,7 @@ ENode *assignment_expression(void) { expr = makemulassignmentnode(expr, EDIVASS, tk); if (ENODE_IS(expr, EDIVASS)) { if (iszero(expr->data.diadic.right) && !IS_TYPE_FLOAT(expr->rtype)) { - CError_Warning(139); + CError_Warning(CErrorStr139); return expr->data.diadic.left; } if (CExpr_IsOne(expr->data.diadic.right)) @@ -4666,7 +4666,7 @@ ENode *assignment_expression(void) { expr = makemulassignmentnode(expr, EMODASS, tk); if (ENODE_IS(expr, EMODASS)) { if (iszero(expr->data.diadic.right)) { - CError_Warning(139); + CError_Warning(CErrorStr139); return expr->data.diadic.left; } } @@ -4798,14 +4798,14 @@ void CExpr_CheckUnusedExpression(ENode *expr) { while (ENODE_IS(scan, ETYPCON)) scan = scan->data.monadic; if (ENODE_IS(scan, EEQU)) { - CError_Warning(208); + CError_Warning(CErrorStr208); return; } } if (copts.warn_no_side_effect) { if (!CExpr_HasSideEffect(expr)) { - CError_Warning(369); + CError_Warning(CErrorStr369); return; } } @@ -4837,7 +4837,7 @@ void CExpr_CheckUnusedExpression(ENode *expr) { if (!ENODE_IS(arg->node, ETEMP)) return; } - CError_Warning(370); + CError_Warning(CErrorStr370); } } } @@ -4884,7 +4884,7 @@ CInt64 CExpr_IntegralConstExprType(Type **tint) { } } - CError_Error(124); + CError_Error(CErrorStr124); *tint = TYPE(&stchar); return cint64_zero; } @@ -4908,7 +4908,7 @@ ENode *CExpr_IntegralConstOrDepExpr(void) { if (CTemplTool_IsTemplateArgumentDependentExpression(expr)) return expr; - CError_Error(124); + CError_Error(CErrorStr124); expr = nullnode(); expr->rtype = TYPE(&stchar); return expr; @@ -4922,7 +4922,7 @@ CInt64 CExpr_IntegralConstExpr(void) { void CExpr_CheckUnwantedAssignment(ENode *expr) { if (copts.warn_possunwant) { if (ENODE_IS(expr, EASS) && !(expr->flags & ENODE_FLAG_80)) - CError_Warning(207); + CError_Warning(CErrorStr207); } } @@ -4953,7 +4953,7 @@ Boolean CExpr_ParseAsmExpr(Object **objptr, CInt64 *valptr) { case EMEMBER: if (expr->data.emember->list->object->otype == OT_OBJECT) { if (expr->data.emember->list->next && expr->data.emember->list->next->object->otype == OT_OBJECT) - CError_Error(199); + CError_Error(CErrorStr199); *objptr = OBJECT(expr->data.emember->list->object); while ((*objptr)->datatype == DALIAS) *objptr = (*objptr)->u.alias.object; @@ -4961,11 +4961,11 @@ Boolean CExpr_ParseAsmExpr(Object **objptr, CInt64 *valptr) { } break; case EOBJLIST: - CError_Error(199); + CError_Error(CErrorStr199); return 0; } } - CError_Error(155); + CError_Error(CErrorStr155); return 0; } diff --git a/compiler_and_linker/unsorted/CExpr2.c b/compiler_and_linker/unsorted/CExpr2.c index e2284d7..609cd43 100644 --- a/compiler_and_linker/unsorted/CExpr2.c +++ b/compiler_and_linker/unsorted/CExpr2.c @@ -389,7 +389,7 @@ ENode *stringconstnode(char *str) { ENode *forceintegral(ENode *expr) { if (!IS_TYPE_ENUM(expr->rtype)) { - CError_Error(144); + CError_Error(CErrorStr144); return nullnode(); } else { expr->rtype = TYPE_ENUM(expr->rtype)->enumtype; @@ -631,7 +631,7 @@ void CExpr_ArithmeticConversion(ENode **left, ENode **right) { (*left)->rtype = TYPE_ENUM((*left)->rtype)->enumtype; break; default: - CError_Error(144); + CError_Error(CErrorStr144); (*left) = nullnode(); } @@ -643,7 +643,7 @@ void CExpr_ArithmeticConversion(ENode **left, ENode **right) { (*right)->rtype = TYPE_ENUM((*right)->rtype)->enumtype; break; default: - CError_Error(144); + CError_Error(CErrorStr144); (*right) = nullnode(); } @@ -741,7 +741,7 @@ ENode *CExpr_TempModifyExpr(ENode *expr) { tempnode = CExpr_NewETEMPNode(type, 1); eanode = CExpr_GetEA(expr); if (!eanode) { - CError_Error(142); + CError_Error(CErrorStr142); return expr; } @@ -840,7 +840,7 @@ loop: case EINDIRECT: if (flag2) { if (!CExpr_IsLValue(expr)) - CError_Warning(142); + CError_Warning(CErrorStr142); if ( ENODE_IS(expr->data.monadic, EOBJREF) && @@ -848,11 +848,11 @@ loop: cscope_currentfunc && cscope_currentclass && expr->data.monadic->data.objref == CClass_ThisSelfObject()) - CError_Error(189); + CError_Error(CErrorStr189); } if (flag1) { if (CParser_IsConst(expr->rtype, expr->flags & ENODE_FLAG_QUALS)) - CError_Error(179); + CError_Error(CErrorStr179); } return expr; case EPREINC: @@ -877,7 +877,7 @@ loop: tmpnode->rtype = expr->rtype; return tmpnode; } - CError_Error(190); + CError_Error(CErrorStr190); return expr; } break; @@ -904,7 +904,7 @@ loop: } if (flag2) - CError_Error(142); + CError_Error(CErrorStr142); return expr; } @@ -912,7 +912,7 @@ ENode *CExpr_MakeObjRefNode(Object *obj, Boolean flag) { ENode *expr; if (obj->sclass == TK_TYPEDEF) { - CError_Error(141); + CError_Error(CErrorStr141); return intconstnode((Type *) &void_ptr, 0); } @@ -925,7 +925,7 @@ ENode *CExpr_MakeObjRefNode(Object *obj, Boolean flag) { if (!IS_TYPE_FUNC(obj->type)) expr->flags = obj->qual & ENODE_FLAG_QUALS; if (flag) - obj->flags |= OBJECT_FLAGS_UNUSED; + obj->flags |= OBJECT_FLAGS_1; return expr; } @@ -995,7 +995,7 @@ ENode *CExpr_AdjustFunctionCall(ENode *expr) { CDecl_CompleteType(expr->data.funccall.functype->functype); case TYPESTRUCT: if (!expr->data.funccall.functype->functype->size) - CError_Error(136, expr->data.funccall.functype->functype, 0); + CError_Error(CErrorStr136, expr->data.funccall.functype->functype, 0); } if (CMach_GetFunctionResultClass(expr->data.funccall.functype)) { @@ -1429,7 +1429,7 @@ static short std_assign_check_overload(NameSpaceObjectList *list, TemplArg *temp assign_node = expr; expr->rtype = CDecl_NewPointerType(used_obj->type); expr->flags = obj->qual & ENODE_FLAG_QUALS; - used_obj->flags |= OBJECT_FLAGS_UNUSED; + used_obj->flags |= OBJECT_FLAGS_1; if (used_obj->datatype == DINLINEFUNC) CError_Error(CErrorStr175); } @@ -1957,7 +1957,7 @@ short user_assign_check(ENode *expr, Type *type, UInt32 qual, Boolean flag1, Boo r13 = TYPE_METHOD(r26->type); CError_ASSERT(2537, r13->flags & FUNC_FLAGS_METHOD); r15b = create_objectrefnode(r26); - r26->flags |= OBJECT_FLAGS_UNUSED; + r26->flags |= OBJECT_FLAGS_1; r14d = lalloc(sizeof(ENodeList)); r14d->next = NULL; expr = getnodeaddress(expr, 0); @@ -2023,7 +2023,7 @@ ENode *CExpr_ConvertToCondition(ENode *expr) { case TYPECLASS: return CExpr_Convert(expr, TYPE(&stbool), 0, 0, 1); default: - CError_Error(376, expr->rtype, expr->flags & ENODE_FLAG_QUALS); + CError_Error(CErrorStr376, expr->rtype, expr->flags & ENODE_FLAG_QUALS); return nullnode(); } } @@ -2457,7 +2457,7 @@ static ENode *CExpr_GenericCall(ENode *funcexpr, ENodeList *argexprs, TypeFunc * callexpr->data.funccall.funcref->rtype = CDecl_NewPointerType(TYPE(tfunc)); callexpr->data.funccall.args = argexprs; callexpr->data.funccall.functype = tfunc; - funcexpr->data.objref->flags |= OBJECT_FLAGS_UNUSED; + funcexpr->data.objref->flags |= OBJECT_FLAGS_1; return CExpr_AdjustFunctionCall(callexpr); } @@ -3413,7 +3413,7 @@ ENode *CExpr_ConstructObject(TypeClass *tclass, ENode *addr_expr, ENodeList *arg CExpr_AssignmentPromotion(args->node, TYPE(tclass), 0, 1), EASS); } - CError_Error(174); + CError_Error(CErrorStr174); } return addr_expr; } @@ -3430,7 +3430,7 @@ static ENode *CExpr_DeleteFuncCall(Object *obj, ENode *arg, Type *type, Boolean expr->rtype = &stvoid; expr->data.funccall.funcref = create_objectrefnode(obj); expr->data.funccall.functype = TYPE_FUNC(obj->type); - obj->flags |= OBJECT_FLAGS_UNUSED; + obj->flags |= OBJECT_FLAGS_1; list = lalloc(sizeof(ENodeList)); list->node = arg; @@ -3504,7 +3504,7 @@ static ENode *CExpr_PlacementDeleteCall(Type *type, ENode *expr, Object *obj, Bo result->rtype = &stvoid; result->data.funccall.funcref = create_objectrefnode(funcobj); result->data.funccall.functype = TYPE_FUNC(funcobj->type); - funcobj->flags |= OBJECT_FLAGS_UNUSED; + funcobj->flags |= OBJECT_FLAGS_1; list = lalloc(sizeof(ENodeList)); list->node = create_objectnode(obj); @@ -3784,7 +3784,7 @@ static ENode *CExpr_NewArray(Type *type, UInt32 qual, ENodeList *nodelist, Boole if (CClass_Constructor(TYPE_CLASS(innertype))) { ctor = CClass_DefaultConstructor(TYPE_CLASS(innertype)); if (ctor) { - ctor->flags |= OBJECT_FLAGS_UNUSED; + ctor->flags |= OBJECT_FLAGS_1; } else { ctor = CClass_DummyDefaultConstructor(TYPE_CLASS(innertype)); if (!ctor) @@ -4187,7 +4187,7 @@ ENode *scandelete(Boolean flag) { result_expr = CABI_DestroyObject(dtor, expr, 2, 0, 0); result_expr->rtype = TYPE(&void_ptr); result_expr = funccallexpr(obj, result_expr, NULL, NULL, NULL); - obj->flags |= OBJECT_FLAGS_UNUSED; + obj->flags |= OBJECT_FLAGS_1; } if (is_virtual) { diff --git a/compiler_and_linker/unsorted/CExprConvMatch.c b/compiler_and_linker/unsorted/CExprConvMatch.c index 7fdce02..24afb62 100644 --- a/compiler_and_linker/unsorted/CExprConvMatch.c +++ b/compiler_and_linker/unsorted/CExprConvMatch.c @@ -567,7 +567,7 @@ static Boolean CExpr_OverloadFuncMatch(NameSpaceObjectList *list, TemplArg *temp *outExpr = expr; expr->rtype = CDecl_NewPointerType(object26->type); expr->flags = object->qual & ENODE_FLAG_QUALS; - object26->flags |= OBJECT_FLAGS_UNUSED; + object26->flags |= OBJECT_FLAGS_1; if (object26->datatype == DINLINEFUNC) CError_Error(CErrorStr175); } @@ -1086,7 +1086,7 @@ static ENode *CExpr_UserConversion(ENode *expr, Type *type2, UInt32 qual2, Impli CError_ASSERT(1416, IS_TYPEFUNC_METHOD(tfunc23)); funcref = create_objectrefnode(object28); - object28->flags |= OBJECT_FLAGS_UNUSED; + object28->flags |= OBJECT_FLAGS_1; arglist = lalloc(sizeof(ENodeList)); arglist->next = NULL; diff --git a/compiler_and_linker/unsorted/CFunc.c b/compiler_and_linker/unsorted/CFunc.c index 94a2c9e..2e10bad 100644 --- a/compiler_and_linker/unsorted/CFunc.c +++ b/compiler_and_linker/unsorted/CFunc.c @@ -601,7 +601,7 @@ void CFunc_WarnUnused(void) { ObjectList *list; for (list = locals; list; list = list->next) { if ( - !(list->object->flags & OBJECT_FLAGS_UNUSED) && + !(list->object->flags & OBJECT_FLAGS_1) && !IsTempName(list->object->name) && !(list->object->qual & Q_10000) ) @@ -616,7 +616,7 @@ void CFunc_WarnUnused(void) { ObjectList *list; for (list = arguments; list; list = list->next) { if ( - !(list->object->flags & OBJECT_FLAGS_UNUSED) && + !(list->object->flags & OBJECT_FLAGS_1) && !IsTempName(list->object->name) && list->object->name != this_name_node && list->object->name != self_name_node @@ -3035,11 +3035,11 @@ void CFunc_ParseFuncDef(Object *func, DeclInfo *di, TypeClass *tclass, Boolean i CheckCLabels(); - if (nameobj_func && (nameobj_func->flags & OBJECT_FLAGS_UNUSED)) + if (nameobj_func && (nameobj_func->flags & OBJECT_FLAGS_1)) CInit_DeclareData(nameobj_func->u.alias.object, func->name->name, NULL, strlen(func->name->name) + 1); - if (nameobj_FUNCTION && (nameobj_FUNCTION->flags & OBJECT_FLAGS_UNUSED)) + if (nameobj_FUNCTION && (nameobj_FUNCTION->flags & OBJECT_FLAGS_1)) CInit_DeclareData(nameobj_FUNCTION->u.alias.object, func->name->name, NULL, strlen(func->name->name) + 1); - if (nameobj_pretty && (nameobj_pretty->flags & OBJECT_FLAGS_UNUSED)) + if (nameobj_pretty && (nameobj_pretty->flags & OBJECT_FLAGS_1)) CInit_DeclareData(nameobj_pretty->u.alias.object, prettyname, NULL, strlen(prettyname) + 1); if (!fatalerrors) { diff --git a/compiler_and_linker/unsorted/CInit.c b/compiler_and_linker/unsorted/CInit.c index a76bdab..180f098 100644 --- a/compiler_and_linker/unsorted/CInit.c +++ b/compiler_and_linker/unsorted/CInit.c @@ -180,7 +180,7 @@ static CInit_Initializer *CInit_ParseInitializerList(void) { return r30; if (tk != ',') { - CError_Error(116); + CError_Error(CErrorStr116); return r30; } } while ((tk = lex()) != '}'); @@ -271,12 +271,12 @@ static Stage CInit_ParseNextInit(CInit_Stuff2 *s) { if (tk == ')') tk = lex(); else - CError_Error(115); + CError_Error(CErrorStr115); if (tk == '(') tk = lex(); else - CError_Error(114); + CError_Error(CErrorStr114); s->x24++; t = lookahead(); if (t == TK_UU_VECTOR || (t == TK_IDENTIFIER && !strcmp("vector", tkidentifier->name))) @@ -305,7 +305,7 @@ static Stage CInit_ParseNextInit(CInit_Stuff2 *s) { } if (s->x24) { if (tk != ')') - CError_Error(174); + CError_Error(CErrorStr174); if (s->x24 > 1) { s->x24--; tk = lex(); @@ -313,7 +313,7 @@ static Stage CInit_ParseNextInit(CInit_Stuff2 *s) { } } else { if (tk != '}') - CError_Error(174); + CError_Error(CErrorStr174); } s->stage = Stage3; return Stage3; @@ -357,7 +357,7 @@ static void CInit_CloseInitList(void) { tk = lex(); if (tk != '}') - CError_ErrorSkip(130); + CError_ErrorSkip(CErrorStr130); else tk = lex(); } @@ -434,7 +434,7 @@ static Object *CInit_CreateStaticDataObject(Type *type, UInt32 qual, HashNameNod return obj; } -static Type *CInit_GetRegMemType() { +static Type *CInit_GetRegMemType(void) { return CDecl_NewStructType(void_ptr.size * 3, CMach_GetTypeAlign((Type *) &void_ptr)); } @@ -470,7 +470,7 @@ static void CInit_InitNonConst(CInit_Stuff *s, Type *type, ENode *expr) { s->x4->x1C = entry; } } else { - CError_Error(124); + CError_Error(CErrorStr124); } } @@ -577,7 +577,7 @@ static void CInit_InitTypePointer(CInit_Stuff *s, ENode *expr, TypePointer *tptr CInit_InitNonConst(s, TYPE(tptr), expr); } } else { - CError_Error(174); + CError_Error(CErrorStr174); } } @@ -592,7 +592,7 @@ static void CInit_InitTypeInt(CInit_Stuff *s, ENode *expr, TypeIntegral *tint, U CInit_InitNonConst(s, TYPE(tint), expr); } } else { - CError_Error(174); + CError_Error(CErrorStr174); } } @@ -605,7 +605,7 @@ static void CInit_InitTypeFloat(CInit_Stuff *s, ENode *expr, TypeIntegral *tint, CInit_InitNonConst(s, TYPE(tint), expr); } } else { - CError_Error(174); + CError_Error(CErrorStr174); } } @@ -618,7 +618,7 @@ static void CInit_InitTypeEnum(CInit_Stuff *s, ENode *expr, TypeEnum *tenum, UIn CInit_InitNonConst(s, TYPE(tenum), expr); } } else { - CError_Error(174); + CError_Error(CErrorStr174); } } @@ -671,7 +671,7 @@ static void CInit_InitTypeBitfield(CInit_Stuff *s, ENode *expr, TypeBitfield *tb CInit_InitNonConst(s, TYPE(tbitfield), expr); } } else { - CError_Error(174); + CError_Error(CErrorStr174); } } @@ -689,7 +689,7 @@ static void CInit_InitTypeArray(CInit_Stuff *s, CInit_Stuff2 *s2, TypePointer *t is_zero_size = tptr->size == 0; targetsize = tptr->target->size; if (!targetsize) { - CError_Error(145); + CError_Error(CErrorStr145); return; } @@ -700,7 +700,7 @@ static void CInit_InitTypeArray(CInit_Stuff *s, CInit_Stuff2 *s2, TypePointer *t flag = 1; if (CInit_ParseNextInit(s2) == Stage3) { if (is_zero_size) - CError_Error(174); + CError_Error(CErrorStr174); tk = lex(); return; } @@ -714,7 +714,7 @@ static void CInit_InitTypeArray(CInit_Stuff *s, CInit_Stuff2 *s2, TypePointer *t case Stage2: break; default: - CError_Error(174); + CError_Error(CErrorStr174); return; } @@ -723,7 +723,7 @@ static void CInit_InitTypeArray(CInit_Stuff *s, CInit_Stuff2 *s2, TypePointer *t if (s2->stage == Stage2 && ENODE_IS(s2->expr, ESTRINGCONST) && (is_char_ptr || is_wchar_ptr)) { if (IS_TYPE_POINTER_ONLY(s2->expr->rtype) && tptr->target->size != TYPE_POINTER(s2->expr->rtype)->target->size) - CError_Warning(174); + CError_Warning(CErrorStr174); size = tmp = s2->expr->data.string.size; if (is_zero_size) { tptr->size = s2->expr->data.string.size; @@ -734,7 +734,7 @@ static void CInit_InitTypeArray(CInit_Stuff *s, CInit_Stuff2 *s2, TypePointer *t } else { if (s2->expr->data.string.size > tptr->size) { if (copts.cplusplus || (s2->expr->data.string.size - 1) > tptr->size) - CError_Error(147); + CError_Error(CErrorStr147); s2->expr->data.string.size = tptr->size; size = tptr->size; } @@ -742,7 +742,7 @@ static void CInit_InitTypeArray(CInit_Stuff *s, CInit_Stuff2 *s2, TypePointer *t } } else { if (!flag && errorflag) { - CError_Error(174); + CError_Error(CErrorStr174); return; } @@ -760,7 +760,7 @@ static void CInit_InitTypeArray(CInit_Stuff *s, CInit_Stuff2 *s2, TypePointer *t } else { if (tptr->size <= i * targetsize) { i--; - CError_Error(147); + CError_Error(CErrorStr147); } s->size = start + i * targetsize; CInit_InitType(s, s2, tptr->target, qual, 0); @@ -777,7 +777,7 @@ static void CInit_InitTypeArray(CInit_Stuff *s, CInit_Stuff2 *s2, TypePointer *t tk = lex(); return; default: - CError_Error(130); + CError_Error(CErrorStr130); return; } @@ -791,10 +791,10 @@ static void CInit_InitTypeArray(CInit_Stuff *s, CInit_Stuff2 *s2, TypePointer *t tk = lex(); return; case Stage2: - CError_Error(147); + CError_Error(CErrorStr147); return; default: - CError_Error(130); + CError_Error(CErrorStr130); } } } @@ -813,7 +813,7 @@ static void CInit_InitTypeStruct(CInit_Stuff *s, CInit_Stuff2 *s2, const TypeStr tstruct = TYPE_STRUCT(s2->type); if (!(member = tstruct->members)) { - CError_Error(145); + CError_Error(CErrorStr145); return; } @@ -835,7 +835,7 @@ static void CInit_InitTypeStruct(CInit_Stuff *s, CInit_Stuff2 *s2, const TypeStr case Stage2: break; default: - CError_Error(174); + CError_Error(CErrorStr174); return; } @@ -851,7 +851,7 @@ static void CInit_InitTypeStruct(CInit_Stuff *s, CInit_Stuff2 *s2, const TypeStr s->size = start + member->offset; if (!member->type->size) { if (!errorflag || !IS_TYPE_ARRAY(member->type)) { - CError_Error(147); + CError_Error(CErrorStr147); if (!IS_TYPE_ARRAY(member->type)) return; } @@ -882,10 +882,10 @@ static void CInit_InitTypeStruct(CInit_Stuff *s, CInit_Stuff2 *s2, const TypeStr tk = lex(); return; case Stage2: - CError_Error(147); + CError_Error(CErrorStr147); return; default: - CError_Error(130); + CError_Error(CErrorStr130); return; } } @@ -911,7 +911,7 @@ static void CInit_InitTypeStruct(CInit_Stuff *s, CInit_Stuff2 *s2, const TypeStr for (i = 1; i < 16; i++) p[i] = val; } else { - CError_Error(174); + CError_Error(CErrorStr174); } } break; @@ -927,7 +927,7 @@ static void CInit_InitTypeStruct(CInit_Stuff *s, CInit_Stuff2 *s2, const TypeStr for (i = 1; i < 8; i++) p[i] = val; } else { - CError_Error(174); + CError_Error(CErrorStr174); } } break; @@ -943,7 +943,7 @@ static void CInit_InitTypeStruct(CInit_Stuff *s, CInit_Stuff2 *s2, const TypeStr for (i = 1; i < 4; i++) p[i] = val; } else { - CError_Error(174); + CError_Error(CErrorStr174); } } break; @@ -951,7 +951,7 @@ static void CInit_InitTypeStruct(CInit_Stuff *s, CInit_Stuff2 *s2, const TypeStr } return; default: - CError_Error(174); + CError_Error(CErrorStr174); return; } } @@ -981,7 +981,7 @@ static void CInit_InitTypeClass(CInit_Stuff *s, CInit_Stuff2 *s2, TypeClass *tcl TypePointer arraytype; if (tclass->bases || tclass->vtable) { - CError_Error(174); + CError_Error(CErrorStr174); return; } @@ -1003,7 +1003,7 @@ static void CInit_InitTypeClass(CInit_Stuff *s, CInit_Stuff2 *s2, TypeClass *tcl case Stage2: break; default: - CError_Error(174); + CError_Error(CErrorStr174); return; } @@ -1016,13 +1016,13 @@ static void CInit_InitTypeClass(CInit_Stuff *s, CInit_Stuff2 *s2, TypeClass *tcl for (ivar = tclass->ivars; ivar; ivar = ivar->next) { if (ivar->access != ACCESSPUBLIC) { - CError_Error(174); + CError_Error(CErrorStr174); break; } } if (!(ivar = tclass->ivars)) { - CError_Error(147); + CError_Error(CErrorStr147); return; } start = s->size; @@ -1030,7 +1030,7 @@ static void CInit_InitTypeClass(CInit_Stuff *s, CInit_Stuff2 *s2, TypeClass *tcl s->size = start + ivar->offset; if (!ivar->type->size) { if (!errorflag || !IS_TYPE_ARRAY(ivar->type)) { - CError_Error(147); + CError_Error(CErrorStr147); if (!IS_TYPE_ARRAY(ivar->type)) return; } @@ -1050,10 +1050,10 @@ static void CInit_InitTypeClass(CInit_Stuff *s, CInit_Stuff2 *s2, TypeClass *tcl tk = lex(); return; case Stage2: - CError_Error(147); + CError_Error(CErrorStr147); return; default: - CError_Error(130); + CError_Error(CErrorStr130); return; } } @@ -1068,7 +1068,7 @@ static void CInit_InitTypeClass(CInit_Stuff *s, CInit_Stuff2 *s2, TypeClass *tcl tk = lex(); break; default: - CError_Error(174); + CError_Error(CErrorStr174); } return; } @@ -1080,7 +1080,7 @@ static void CInit_InitType(CInit_Stuff *s, CInit_Stuff2 *s2, Type *type, UInt32 switch (type->type) { case TYPEVOID: - CError_Error(174); + CError_Error(CErrorStr174); break; case TYPEINT: case TYPEFLOAT: @@ -1098,7 +1098,7 @@ static void CInit_InitType(CInit_Stuff *s, CInit_Stuff2 *s2, Type *type, UInt32 break; } if (s2->stage != Stage2) { - CError_Error(174); + CError_Error(CErrorStr174); return; } @@ -1131,10 +1131,10 @@ static void CInit_InitType(CInit_Stuff *s, CInit_Stuff2 *s2, Type *type, UInt32 tk = lex(); break; case Stage2: - CError_Error(147); + CError_Error(CErrorStr147); break; default: - CError_Error(130); + CError_Error(CErrorStr130); } } break; @@ -1165,7 +1165,7 @@ static void CInit_InitData(CInit_Stuff *s, Type *type, UInt32 qual, Boolean flag if (IS_TYPE_ARRAY(type)) s->bufferSize = 16 * TYPE_POINTER(type)->target->size; else - CError_Error(145); + CError_Error(CErrorStr145); } else { s->bufferSize = type->size; } @@ -1199,7 +1199,7 @@ static void CInit_InitData(CInit_Stuff *s, Type *type, UInt32 qual, Boolean flag s->buffer = buffer; } } else { - CError_Error(174); + CError_Error(CErrorStr174); } s->size = size; @@ -1282,7 +1282,7 @@ static Boolean CInit_ConstructGlobalObject(Object *obj, TypeClass *tclass, ENode if (tk == ')') tk = lex(); else - CError_Error(115); + CError_Error(CErrorStr115); } else if (valueexpr) { list = lalloc(sizeof(ENodeList)); list->node = valueexpr; @@ -1300,7 +1300,7 @@ static Boolean CInit_ConstructGlobalObject(Object *obj, TypeClass *tclass, ENode if (tk == '=') { ctorflag = 0; if (list) - CError_Error(174); + CError_Error(CErrorStr174); list = lalloc(sizeof(ENodeList)); list->next = NULL; @@ -1310,12 +1310,12 @@ static Boolean CInit_ConstructGlobalObject(Object *obj, TypeClass *tclass, ENode expr = CExpr_ConstructObject(tclass, expr, list, 0, 1, 0, 1, ctorflag); if (expr->rtype->type != TYPEPOINTER) { - CError_Error(174); + CError_Error(CErrorStr174); return 1; } } else { if (list) - CError_Error(174); + CError_Error(CErrorStr174); } if (dtor) @@ -1353,7 +1353,7 @@ static Boolean CInit_ConstructAutoObject(TypeClass *tclass, ENode *expr, SInt32 if (tk == ')') tk = lex(); else - CError_Error(115); + CError_Error(CErrorStr115); } else if (expr) { r30 = lalloc(sizeof(ENodeList)); r30->node = expr; @@ -1366,7 +1366,7 @@ static Boolean CInit_ConstructAutoObject(TypeClass *tclass, ENode *expr, SInt32 r24 = 1; if (tk == '=') { if (r30) - CError_Error(174); + CError_Error(CErrorStr174); r30 = lalloc(sizeof(ENodeList)); r30->next = NULL; tk = lex(); @@ -1384,7 +1384,7 @@ static Boolean CInit_ConstructAutoObject(TypeClass *tclass, ENode *expr, SInt32 r29 = CExpr_ConstructObject(tclass, r29, r30, 0, 1, 0, 1, r24); if (!IS_TYPE_POINTER_ONLY(r29->rtype)) { - CError_Error(174); + CError_Error(CErrorStr174); return 1; } r29 = makemonadicnode(r29, EINDIRECT); @@ -1392,7 +1392,7 @@ static Boolean CInit_ConstructAutoObject(TypeClass *tclass, ENode *expr, SInt32 cinit_initinfo->insert_expr_cb(r29); } else { if (r30) - CError_Error(174); + CError_Error(CErrorStr174); if (dtor) r29 = cinit_initinfo->register_object_cb(TYPE(tclass), cinit_initinfo->obj1C, offset, 0); cinit_initinfo->insert_expr_cb(r29); @@ -1421,7 +1421,7 @@ static void CInit_ExprPointer(TypePointer *tptr, ENode *expr) { cinit_initinfo->expr_cb(TYPE(tptr), expr, 0); cinit_initinfo->expr_cb_called = 1; } else { - CError_Error(124); + CError_Error(CErrorStr124); } cinit_initinfo->expr_offset += 4; @@ -1436,7 +1436,7 @@ static void CInit_ExprInt(TypeIntegral *tint, ENode *expr) { cinit_initinfo->expr_cb(TYPE(tint), expr, 0); cinit_initinfo->expr_cb_called = 1; } else { - CError_Error(124); + CError_Error(CErrorStr124); } cinit_initinfo->expr_offset += tint->size; @@ -1449,7 +1449,7 @@ static void CInit_ExprFloat(TypeIntegral *tint, ENode *expr) { cinit_initinfo->expr_cb(TYPE(tint), expr, 0); cinit_initinfo->expr_cb_called = 1; } else { - CError_Error(124); + CError_Error(CErrorStr124); } cinit_initinfo->expr_offset += tint->size; @@ -1462,7 +1462,7 @@ static void CInit_ExprEnum(TypeEnum *tenum, ENode *expr) { cinit_initinfo->expr_cb(TYPE(tenum), expr, 0); cinit_initinfo->expr_cb_called = 1; } else { - CError_Error(124); + CError_Error(CErrorStr124); } cinit_initinfo->expr_offset += tenum->size; @@ -1475,7 +1475,7 @@ static void CInit_ExprMemberPointer(TypeMemberPointer *tmptr, ENode *expr) { cinit_initinfo->expr_cb(TYPE(tmptr), expr, 0); cinit_initinfo->expr_cb_called = 1; } else { - CError_Error(124); + CError_Error(CErrorStr124); } cinit_initinfo->expr_offset += tmptr->size; @@ -1504,11 +1504,11 @@ static void CInit_TypeExpr(Type *type, ENode *expr) { cinit_initinfo->expr_cb(type, expr, 0); cinit_initinfo->expr_cb_called = 1; } else { - CError_Error(124); + CError_Error(CErrorStr124); } break; case TYPEARRAY: - CError_Error(174); + CError_Error(CErrorStr174); break; default: CError_FATAL(2082); @@ -1533,7 +1533,7 @@ static void CInit_Bitfield(TypeBitfield *tbitfield) { if (ENODE_IS(expr, EINTCONST)) CInit_SetBitfield(tbitfield, (UInt8 *) cinit_initinfo->buffer + cinit_initinfo->expr_offset, expr->data.intval); else - CError_Error(124); + CError_Error(CErrorStr124); if (r30) CInit_CloseInitList(); @@ -1553,13 +1553,13 @@ static void CInit_Array(TypePointer *tptr, UInt32 qual, Boolean flag) { targetsize2 = tptr->target->size; if (!tptr->target->size) { if (!IS_TYPE_ARRAY(tptr->target)) { - CError_Error(145); + CError_Error(CErrorStr145); return; } targetsize1 = tptr->target->size; targetsize2 = tptr->target->size; if (!tptr->target->size) { - CError_Error(145); + CError_Error(CErrorStr145); return; } } @@ -1570,7 +1570,7 @@ static void CInit_Array(TypePointer *tptr, UInt32 qual, Boolean flag) { in_block = 1; if (flag && !(tk == TK_STRING && is_char_ptr) && !(tk == TK_STRING_WIDE && is_wchar_ptr)) { if (tk != '{') { - CError_ErrorSkip(135); + CError_ErrorSkip(CErrorStr135); return; } tk = lex(); @@ -1585,7 +1585,7 @@ static void CInit_Array(TypePointer *tptr, UInt32 qual, Boolean flag) { if (tptr->size) { if (tksize > tptr->size) { if (copts.cplusplus || (tksize - (is_wchar_ptr ? stwchar.size : 1)) > tptr->size) - CError_Error(147); + CError_Error(CErrorStr147); tksize = tptr->size; } memcpy(cinit_initinfo->buffer + cinit_initinfo->expr_offset, tkstring, tksize); @@ -1618,7 +1618,7 @@ static void CInit_Array(TypePointer *tptr, UInt32 qual, Boolean flag) { cinit_initinfo->expr_cb(tptr->target, NULL, 1); cinit_initinfo->expr_cb_called = 1; } else { - CError_Error(174); + CError_Error(CErrorStr174); } i++; } @@ -1640,7 +1640,7 @@ static void CInit_Array(TypePointer *tptr, UInt32 qual, Boolean flag) { cinit_initinfo->expr_cb(tptr->target, conv_assignment_expression(), 1); cinit_initinfo->expr_cb_called = 1; } else { - CError_Error(174); + CError_Error(CErrorStr174); } } else { CInit_Type(tptr->target, qual, 0); @@ -1648,7 +1648,7 @@ static void CInit_Array(TypePointer *tptr, UInt32 qual, Boolean flag) { } else { if (tptr->size <= i * targetsize1) { i--; - CError_Error(147); + CError_Error(CErrorStr147); } cinit_initinfo->expr_offset = start + i * targetsize2; @@ -1657,7 +1657,7 @@ static void CInit_Array(TypePointer *tptr, UInt32 qual, Boolean flag) { cinit_initinfo->expr_cb(tptr->target, conv_assignment_expression(), 1); cinit_initinfo->expr_cb_called = 1; } else { - CError_Error(174); + CError_Error(CErrorStr174); } } else { CInit_Type(tptr->target, qual, 0); @@ -1671,7 +1671,7 @@ static void CInit_Array(TypePointer *tptr, UInt32 qual, Boolean flag) { if (tk != '}') { if (tk != ',') { - CError_ErrorSkip(121); + CError_ErrorSkip(CErrorStr121); in_block = 0; i++; goto innerloop; @@ -1688,7 +1688,7 @@ static void CInit_Struct(TypeStruct *tstruct, Boolean flag) { Boolean in_block; if (!(member = tstruct->members)) { - CError_Error(145); + CError_Error(CErrorStr145); return; } @@ -1711,7 +1711,7 @@ static void CInit_Struct(TypeStruct *tstruct, Boolean flag) { if (tk != '{') { if (flag) - CError_ErrorSkip(135); + CError_ErrorSkip(CErrorStr135); in_block = 0; } else { in_block = 1; @@ -1725,7 +1725,7 @@ static void CInit_Struct(TypeStruct *tstruct, Boolean flag) { cinit_initinfo->expr_offset = start + member->offset; if (!member->type->size && IS_TYPE_ARRAY(member->type)) { - CError_Error(147); + CError_Error(CErrorStr147); break; } @@ -1734,7 +1734,7 @@ static void CInit_Struct(TypeStruct *tstruct, Boolean flag) { break; if (tk != ',') { - CError_Error(121); + CError_Error(CErrorStr121); break; } @@ -1746,7 +1746,7 @@ static void CInit_Struct(TypeStruct *tstruct, Boolean flag) { if (!in_block) break; if ((tk = lex()) != '}') { - CError_Error(147); + CError_Error(CErrorStr147); break; } } else { @@ -1772,7 +1772,7 @@ static void CInit_Class(TypeClass *tclass, Boolean flag) { } if (tclass->bases || tclass->vtable) { - CError_Error(174); + CError_Error(CErrorStr174); return; } @@ -1789,7 +1789,7 @@ static void CInit_Class(TypeClass *tclass, Boolean flag) { break; if (!ivar->type->size && IS_TYPE_ARRAY(ivar->type)) { - CError_Error(147); + CError_Error(CErrorStr147); break; } @@ -1800,7 +1800,7 @@ static void CInit_Class(TypeClass *tclass, Boolean flag) { break; if (tk != ',') { - CError_Error(121); + CError_Error(CErrorStr121); break; } @@ -1812,7 +1812,7 @@ static void CInit_Class(TypeClass *tclass, Boolean flag) { if (!in_block) break; if ((tk = lex()) != '}') { - CError_Error(147); + CError_Error(CErrorStr147); break; } } else { @@ -1821,11 +1821,11 @@ static void CInit_Class(TypeClass *tclass, Boolean flag) { } } else { if (in_block && tk != '}') - CError_Error(147); + CError_Error(CErrorStr147); } } else { if (in_block) - CError_Error(174); + CError_Error(CErrorStr174); CInit_TypeExpr(TYPE(tclass), CExpr_AssignmentPromotion(conv_assignment_expression(), TYPE(tclass), 0, 1)); } @@ -1840,7 +1840,7 @@ static void CInit_Type(Type *type, UInt32 qual, Boolean flag) { switch (type->type) { case TYPEVOID: - CError_Error(174); + CError_Error(CErrorStr174); break; case TYPEINT: case TYPEFLOAT: @@ -1885,7 +1885,7 @@ static void CInit_GlobalStaticInit(Type *type, ENode *valueexpr, Boolean flag) { } else { expr = create_objectrefnode(cinit_initinfo->obj); if (!IS_TYPE_POINTER_ONLY(expr->rtype)) { - CError_Error(174); + CError_Error(CErrorStr174); return; } TYPE_POINTER(expr->rtype)->target = type; @@ -1920,7 +1920,7 @@ static void CInit_AutoInit(Type *type, ENode *valueexpr, Boolean flag) { } expr = create_objectrefnode(cinit_initinfo->obj1C); if (!IS_TYPE_POINTER_ONLY(expr->rtype)) { - CError_Error(174); + CError_Error(CErrorStr174); return; } TYPE_POINTER(expr->rtype)->target = type; @@ -1932,7 +1932,7 @@ static void CInit_AutoInit(Type *type, ENode *valueexpr, Boolean flag) { tmp->rtype = type; expr = makediadicnode(tmp, valueexpr, EASS); if (!copts.cplusplus) - CError_Error(124); + CError_Error(CErrorStr124); cinit_initinfo->insert_expr_cb(expr); } } @@ -1961,11 +1961,11 @@ static ENode *CInit_GenericData(Object *obj, Type *type, UInt32 qual, ExprCB exp if (tk == '(') { if (IS_TYPE_ARRAY(type)) - CError_Error(174); + CError_Error(CErrorStr174); tk = lex(); expr = CExpr_AssignmentPromotion(assignment_expression(), type, qual, 1); if (tk != ')') - CError_ErrorSkip(115); + CError_ErrorSkip(CErrorStr115); else tk = lex(); goto jump_ahead; @@ -1975,7 +1975,7 @@ static ENode *CInit_GenericData(Object *obj, Type *type, UInt32 qual, ExprCB exp switch (type->type) { case TYPECLASS: if (tk == '{' && CClass_Constructor(TYPE_CLASS(type))) - CError_Error(174); + CError_Error(CErrorStr174); case TYPESTRUCT: if (tk != '{') goto generic_type; @@ -2195,7 +2195,7 @@ static void CInit_InitializeClassArray(Object *obj, TypeClass *tclass, Boolean f if (!ctor) { ctor = CClass_DummyDefaultConstructor(tclass); if (!ctor) { - CError_Error(203); + CError_Error(CErrorStr203); return; } } @@ -2314,7 +2314,7 @@ static ENode *CInit_GlobalTempNode(Type *type, Boolean flag) { node = create_objectrefnode(CInit_CreateStaticData(type)); if (IS_TYPE_CLASS(type) && (dtor = CClass_Destructor(TYPE_CLASS(type))) && !copts.no_static_dtors) { if (flag) - CError_Error(190); + CError_Error(CErrorStr190); funcnode = galloc(sizeof(ENode)); funcnode->type = EFUNCCALL; @@ -2340,7 +2340,7 @@ static void CInit_RefInit(Type *type, ENode *expr, Boolean flag) { objexpr = create_objectrefnode(cinit_initinfo->obj); if (!IS_TYPE_POINTER_ONLY(objexpr->rtype)) { - CError_Error(174); + CError_Error(CErrorStr174); return; } TYPE_POINTER(objexpr->rtype)->target = type; @@ -2575,7 +2575,7 @@ void CInit_InitializeAutoData(Object *obj, InsertExprCB insert_cb, RegisterObjec tk = lex(); expr = conv_assignment_expression(); if (tk != ')') - CError_Error(115); + CError_Error(CErrorStr115); tk = lex(); } else if (tk == '=' && ((tk = lex()) == '{' || IS_TYPE_ARRAY(obj->type))) { insert_cb(CInit_AutoObject(obj, obj->type, obj->qual)); @@ -2586,7 +2586,7 @@ void CInit_InitializeAutoData(Object *obj, InsertExprCB insert_cb, RegisterObjec expr = CExpr_AssignmentPromotion(expr, obj->type, obj->qual & (Q_CONST | Q_VOLATILE), 1); insert_cb(makediadicnode(create_objectnode2(obj), expr, EASS)); } else if (copts.cplusplus && is_const_object(obj)) { - CError_Error(224); + CError_Error(CErrorStr224); } return; @@ -2626,13 +2626,13 @@ void CInit_InitializeAutoData(Object *obj, InsertExprCB insert_cb, RegisterObjec CFunc_CheckClassCtors(TYPE_CLASS(obj->type)); if ((IS_TYPE_REFERENCE(obj->type) || is_const_object(obj)) && copts.cplusplus) - CError_Error(224); + CError_Error(CErrorStr224); } else { if (obj->type->size || IS_TYPE_ARRAY(obj->type)) { if ((expr = CInit_GenericData(NULL, obj->type, obj->qual, CInit_AutoInit, 0))) insert_cb(makediadicnode(create_objectnode2(obj), expr, EASS)); } else { - CError_Error(145); + CError_Error(CErrorStr145); } } @@ -2675,7 +2675,7 @@ void CInit_InitializeStaticData(Object *obj, InitExprRegisterCB cb) { } } else { if (copts.cplusplus && is_const_object(obj)) - CError_Error(224); + CError_Error(CErrorStr224); if (is_const_object(obj)) CInit_DeclareReadOnlyData(obj, NULL, NULL, obj->type->size); @@ -2723,13 +2723,13 @@ void CInit_InitializeStaticData(Object *obj, InitExprRegisterCB cb) { CFunc_CheckClassCtors(TYPE_CLASS(obj->type)); if ((IS_TYPE_REFERENCE(obj->type) || is_const_object(obj)) && copts.cplusplus) - CError_Error(224); + CError_Error(CErrorStr224); } else { if (obj->type->size || IS_TYPE_ARRAY(obj->type)) { if ((expr = CInit_GenericData(obj, obj->type, obj->qual, CInit_GlobalStaticInit, 1))) cb(makediadicnode(create_objectnode2(obj), expr, EASS)); } else { - CError_Error(145); + CError_Error(CErrorStr145); } } @@ -2770,7 +2770,7 @@ void CInit_InitializeData(Object *obj) { } } else { if (obj->flags & OBJECT_FLAGS_4) - CError_Error(329, obj); + CError_Error(CErrorStr329, obj); obj->flags |= OBJECT_FLAGS_4; needs_construction = 0; @@ -2803,7 +2803,7 @@ void CInit_InitializeData(Object *obj) { if (!needs_construction && copts.cplusplus) { if (IS_TYPE_REFERENCE(obj->type) || is_const_object(obj)) - CError_Error(224); + CError_Error(CErrorStr224); } if (IsCompleteType(obj->type)) CInit_DeclareData(obj, NULL, NULL, obj->type->size); @@ -2813,13 +2813,13 @@ void CInit_InitializeData(Object *obj) { } if (obj->flags & OBJECT_FLAGS_4) - CError_Error(329, obj); + CError_Error(CErrorStr329, obj); if (CInit_IsSimpleStructArrayInit(obj->type)) { if (tk == '=') tk = lex(); else - CError_Error(121); + CError_Error(CErrorStr121); CInit_GlobalObject(obj); return; } @@ -2838,7 +2838,7 @@ void CInit_InitializeData(Object *obj) { } if (obj->type->size == 0 && !IS_TYPE_ARRAY(obj->type)) { - CError_Error(145); + CError_Error(CErrorStr145); CInit_CleanupInitInfo(&initinfo); return; } @@ -2977,7 +2977,7 @@ void CInit_RewriteString(ENode *expr, Boolean flag) { Boolean is_wide; if (cparamblkptr->isPrecompiling == 1) - CError_Error(180); + CError_Error(CErrorStr180); CError_ASSERT(4220, expr->rtype->type == TYPEPOINTER); diff --git a/compiler_and_linker/unsorted/CInline.c b/compiler_and_linker/unsorted/CInline.c index 2ab6568..85cdf83 100644 --- a/compiler_and_linker/unsorted/CInline.c +++ b/compiler_and_linker/unsorted/CInline.c @@ -3458,7 +3458,7 @@ void CInline_AddDefaultFunctionAction(Object *object) { cinline_actionlist = action; } -void CInline_AddInlineFunctionAction(Object *object, TypeClass *tclass, FileOffsetInfo *fileoffset, TStream *stream, Boolean flag) { +void CInline_AddInlineFunctionAction(Object *object, TypeClass *tclass, FileOffsetInfo *fileoffset, TokenStream *stream, Boolean flag) { CI_Action *action; for (action = flag ? cinline_tactionlist : cinline_actionlist; action; action = action->next) { diff --git a/compiler_and_linker/unsorted/CInt64.c b/compiler_and_linker/unsorted/CInt64.c index ce2c45c..449e068 100644 --- a/compiler_and_linker/unsorted/CInt64.c +++ b/compiler_and_linker/unsorted/CInt64.c @@ -8,7 +8,7 @@ const CInt64 cint64_min = {0x80000000, 0}; #define SHIFT_LEFT_ONE(a, b) do { a <<= 1; if (b & 0x80000000) { a |= 1; } b <<= 1; } while(0) -void CInt64_Init() { +void CInt64_Init(void) { } CInt64 CInt64_Not(CInt64 input) { diff --git a/compiler_and_linker/unsorted/CMachine.c b/compiler_and_linker/unsorted/CMachine.c index 2b1440f..4bde879 100644 --- a/compiler_and_linker/unsorted/CMachine.c +++ b/compiler_and_linker/unsorted/CMachine.c @@ -6,6 +6,7 @@ #include "compiler/CPrep.h" #include "compiler/CPrepTokenizer.h" #include "compiler/CompilerTools.h" +#include "compiler/ScanFloat.h" #include "compiler/objects.h" #include "compiler/types.h" @@ -126,7 +127,7 @@ static short cmach_packsize[] = { static SInt16 CMach_GetQualifiedTypeAlign(Type *type, Boolean flag); static SInt16 CMach_GetMemberAlignment(Type *type, SInt32 align, Boolean flag); -void CMach_Configure() { +void CMach_Configure(void) { } SInt32 CMach_GetQUALalign(UInt32 qual) { @@ -170,8 +171,7 @@ SInt32 CMach_GetQUALalign(UInt32 qual) { } SInt32 CMach_ArgumentAlignment(Type *type) { - // does not match - registers - UInt8 save_align_mode; + char save_align_mode; UInt8 save_oldalignment; SInt32 align; @@ -252,13 +252,13 @@ CInt64 CMach_CalcIntDiadic(Type *type, CInt64 left, short op, CInt64 right) { break; case '/': if (CInt64_IsZero(&right)) - CError_Warning(139); + CError_Warning(CErrorStr139); else left = CInt64_DivU(left, right); break; case '%': if (CInt64_IsZero(&right)) - CError_Warning(139); + CError_Warning(CErrorStr139); else left = CInt64_ModU(left, right); break; @@ -302,13 +302,13 @@ CInt64 CMach_CalcIntDiadic(Type *type, CInt64 left, short op, CInt64 right) { left = CInt64_Or(left, right); break; case TK_LOGICAL_AND: - CInt64_SetLong(&left, (CInt64_IsZero(&left) == 0 && CInt64_IsZero(&right) == 0)); + CInt64_SetLong(&left, (!CInt64_IsZero(&left) && !CInt64_IsZero(&right))); break; case TK_LOGICAL_OR: - CInt64_SetLong(&left, (CInt64_IsZero(&left) == 0 || CInt64_IsZero(&right) == 0)); + CInt64_SetLong(&left, (!CInt64_IsZero(&left) || !CInt64_IsZero(&right))); break; default: - CError_Error(120); + CError_Error(CErrorStr120); } switch (type->size) { @@ -350,13 +350,13 @@ CInt64 CMach_CalcIntDiadic(Type *type, CInt64 left, short op, CInt64 right) { break; case '/': if (CInt64_IsZero(&right)) - CError_Warning(139); + CError_Warning(CErrorStr139); else left = CInt64_Div(left, right); break; case '%': if (CInt64_IsZero(&right)) - CError_Warning(139); + CError_Warning(CErrorStr139); else left = CInt64_Mod(left, right); break; @@ -400,13 +400,13 @@ CInt64 CMach_CalcIntDiadic(Type *type, CInt64 left, short op, CInt64 right) { left = CInt64_Or(left, right); break; case TK_LOGICAL_AND: - CInt64_SetLong(&left, (CInt64_IsZero(&left) == 0 && CInt64_IsZero(&right) == 0)); + CInt64_SetLong(&left, (!CInt64_IsZero(&left) && !CInt64_IsZero(&right))); break; case TK_LOGICAL_OR: - CInt64_SetLong(&left, (CInt64_IsZero(&left) == 0 || CInt64_IsZero(&right) == 0)); + CInt64_SetLong(&left, (!CInt64_IsZero(&left) || !CInt64_IsZero(&right))); break; default: - CError_Error(120); + CError_Error(CErrorStr120); } switch (type->size) { @@ -456,7 +456,7 @@ CInt64 CMach_CalcIntMonadic(Type *type, short op, CInt64 val) { val = CInt64_Not(val); break; default: - CError_Error(120); + CError_Error(CErrorStr120); } switch (type->size) { @@ -500,7 +500,7 @@ CInt64 CMach_CalcIntMonadic(Type *type, short op, CInt64 val) { val = CInt64_Not(val); break; default: - CError_Error(120); + CError_Error(CErrorStr120); } switch (type->size) { @@ -683,7 +683,7 @@ char *CMach_FloatScan(char *input, Float *result, Boolean *fail) { char *outpos; if (!(outpos = ScanFloat(input, &resultval, fail))) - CError_ErrorTerm(154); + CError_ErrorTerm(CErrorStr154); if (*fail) result->value = 0.0; @@ -768,9 +768,9 @@ void CMach_PrintFloat(char *buf, Float val) { sprintf(buf, "%g", f); } -void CMach_PragmaParams() { +void CMach_PragmaParams(void) { if (copts.warn_illpragma) - CError_Warning(186, 0); + CError_Warning(CErrorStr186, 0); while (notendofline()) lex(); @@ -835,37 +835,49 @@ static SInt32 CMach_GetPPCTypeAlign(Type *type, Boolean flag1, Boolean flag2) { return align; } -static SInt16 CMach_GetQualifiedStructAlign(TypeStruct *tstruct, Boolean flag) { +static SInt16 CMach_GetQualifiedStructAlign(const TypeStruct *tstruct, Boolean flag) { StructMember *member; SInt32 best; SInt32 align; Boolean isFirst; - // very close to matching but tstruct->stype gets cached when it should not be - if (tstruct->stype >= STRUCT_TYPE_4 && tstruct->stype <= STRUCT_TYPE_E) { + if (tstruct->stype >= STRUCT_TYPE_4 && tstruct->stype <= STRUCT_TYPE_E) return 16; - } else { - - switch (copts.align_mode) { - case AlignMode3_1Byte: - case AlignMode8_Packed: - return 1; - case AlignMode0_Mac68k: - return 2; - case AlignMode1_Mac68k4byte: - return (tstruct->size <= 2) ? 2 : 4; - } - if (tstruct->size <= 1) + switch (copts.align_mode) { + case AlignMode3_1Byte: + case AlignMode8_Packed: return 1; - best = 1; - switch (copts.align_mode) { - default: - CError_FATAL(1026); - case AlignMode4_2Byte: - case AlignMode5_4Byte: - case AlignMode6_8Byte: - case AlignMode7_16Byte: + case AlignMode0_Mac68k: + return 2; + case AlignMode1_Mac68k4byte: + return (tstruct->size <= 2) ? 2 : 4; + } + + if (tstruct->size <= 1) + return 1; + + best = 1; + switch (copts.align_mode) { + default: + CError_FATAL(1026); + case AlignMode4_2Byte: + case AlignMode5_4Byte: + case AlignMode6_8Byte: + case AlignMode7_16Byte: + for (member = tstruct->members; member; member = member->next) { + align = CMach_GetQualifiedTypeAlign(member->type, flag); + if (align > best) + best = align; + if (flag) { + align = CMach_GetQUALalign(member->qual); + if (align > best) + best = align; + } + } + return best; + case AlignMode2_PPC: + if (copts.oldalignment) { for (member = tstruct->members; member; member = member->next) { align = CMach_GetQualifiedTypeAlign(member->type, flag); if (align > best) @@ -876,46 +888,32 @@ static SInt16 CMach_GetQualifiedStructAlign(TypeStruct *tstruct, Boolean flag) { best = align; } } - return best; - case AlignMode2_PPC: - if (copts.oldalignment) { - for (member = tstruct->members; member; member = member->next) { - align = CMach_GetQualifiedTypeAlign(member->type, flag); - if (align > best) - best = align; - if (flag) { - align = CMach_GetQUALalign(member->qual); - if (align > best) - best = align; - } - } - } else if (tstruct->stype == STRUCT_TYPE_UNION) { - for (member = tstruct->members; member; member = member->next) { - align = CMach_GetPPCTypeAlign(member->type, 1, flag); + } else if (TYPE_STRUCT(tstruct)->stype == STRUCT_TYPE_UNION) { + for (member = tstruct->members; member; member = member->next) { + align = CMach_GetPPCTypeAlign(member->type, 1, flag); + if (align > best) + best = align; + if (flag) { + align = CMach_GetQUALalign(member->qual); if (align > best) best = align; - if (flag) { - align = CMach_GetQUALalign(member->qual); - if (align > best) - best = align; - } } - } else { - isFirst = 1; - for (member = tstruct->members; member; member = member->next) { - align = CMach_GetPPCTypeAlign(member->type, isFirst || (best >= 8), flag); + } + } else { + isFirst = 1; + for (member = tstruct->members; member; member = member->next) { + align = CMach_GetPPCTypeAlign(member->type, isFirst || (best >= 8), flag); + if (align > best) + best = align; + if (flag) { + align = CMach_GetQUALalign(member->qual); if (align > best) best = align; - if (flag) { - align = CMach_GetQUALalign(member->qual); - if (align > best) - best = align; - } - isFirst = 0; } + isFirst = 0; } - return best; - } + } + return best; } } @@ -1029,7 +1027,7 @@ static SInt16 CMach_GetWinMinimizeAlign(SInt16 align) { } static SInt16 CMach_GetQualifiedTypeAlign(Type *type, Boolean flag) { - Boolean r31; + Boolean isWin; SInt16 align; if (type->type == TYPESTRUCT && TYPE_STRUCT(type)->stype >= STRUCT_TYPE_4 && TYPE_STRUCT(type)->stype <= STRUCT_TYPE_E) @@ -1043,10 +1041,10 @@ static SInt16 CMach_GetQualifiedTypeAlign(Type *type, Boolean flag) { case AlignMode5_4Byte: case AlignMode6_8Byte: case AlignMode7_16Byte: - r31 = 1; + isWin = 1; break; default: - r31 = 0; + isWin = 0; break; } @@ -1059,7 +1057,7 @@ restart: case TYPEENUM: type = TYPE_ENUM(type)->enumtype; case TYPEINT: - if (r31) + if (isWin) return CMach_GetWinTypeAlign(type); if (type->size == 1) return 1; @@ -1069,7 +1067,7 @@ restart: return 4; return 2; case TYPEFLOAT: - if (r31) + if (isWin) return CMach_GetWinTypeAlign(type); switch (copts.align_mode) { case AlignMode0_Mac68k: @@ -1085,7 +1083,7 @@ restart: } case TYPEMEMBERPOINTER: case TYPEPOINTER: - if (r31) + if (isWin) return CMach_GetWinTypeAlign(type); if (copts.align_mode == AlignMode0_Mac68k) return 2; @@ -1093,7 +1091,7 @@ restart: return 4; case TYPEARRAY: if (copts.align_array_members) { - if (r31) + if (isWin) return CMach_GetWinTypeAlign(type); if (type->size == 1) return 1; @@ -1115,7 +1113,7 @@ restart: align = TYPE_STRUCT(type)->align; else align = CMach_GetQualifiedStructAlign(TYPE_STRUCT(type), flag); - if (r31) + if (isWin) return CMach_GetWinMinimizeAlign(align); else return align; @@ -1124,7 +1122,7 @@ restart: align = TYPE_CLASS(type)->align; else align = CMach_GetQualifiedClassAlign(TYPE_CLASS(type), flag); - if (r31) + if (isWin) return CMach_GetWinMinimizeAlign(align); else return align; @@ -1150,7 +1148,7 @@ static SInt16 CMach_GetMemberAlignment(Type *type, SInt32 var, Boolean flag) { if (align < 1) align = 1; - if (type->type == TYPESTRUCT && TYPE_STRUCT(type)->stype >= STRUCT_TYPE_4 && TYPE_STRUCT(type)->stype <= STRUCT_TYPE_E && align < 16) + if (IS_TYPE_VECTOR(type) && align < 16) align = 16; switch (copts.align_mode) { @@ -1197,7 +1195,7 @@ void CMach_StructLayoutInitOffset(SInt32 offset) { cmach_curbfsize = 0; } -SInt32 CMach_StructLayoutGetCurSize() { +SInt32 CMach_StructLayoutGetCurSize(void) { return cmach_structoffset; } @@ -1323,7 +1321,7 @@ Boolean CMach_PassResultInHiddenArg(Type *type) { } } -char *CMach_GetCPU() { +char *CMach_GetCPU(void) { switch (copts.cpu) { case CPU_PPC401: return "__PPC401__"; case CPU_PPC403: return "__PPC403__"; @@ -1379,7 +1377,7 @@ SInt32 CMach_RoundedSizeOf(Object *object) { return (size + align) & ~align; } -void CMach_ReInitRuntimeObjects() { +void CMach_ReInitRuntimeObjects(void) { HashNameNode *e0 = GetHashNameNodeExport("[0]"); HashNameNode *e1 = GetHashNameNodeExport("[1]"); HashNameNode *e2 = GetHashNameNodeExport("[2]"); diff --git a/compiler_and_linker/unsorted/CParser.c b/compiler_and_linker/unsorted/CParser.c index 85ccf26..214061d 100644 --- a/compiler_and_linker/unsorted/CParser.c +++ b/compiler_and_linker/unsorted/CParser.c @@ -459,7 +459,7 @@ Boolean CParser_ParseOperatorName(short *token, Boolean flag1, Boolean flag2) { if (lookahead() == '[') { lex(); if (lex() != ']') - CError_Error(125); + CError_Error(CErrorStr125); //if (tk == TK_NEW) // tk = TK_NEW_ARRAY; //else @@ -469,14 +469,14 @@ Boolean CParser_ParseOperatorName(short *token, Boolean flag1, Boolean flag2) { break; case '(': if ((tk = lex()) != ')') { - CError_Error(204); + CError_Error(CErrorStr204); return 0; } tk = '('; break; case '[': if ((tk = lex()) != ']') { - CError_Error(204); + CError_Error(CErrorStr204); return 0; } tk = '['; @@ -502,7 +502,7 @@ Boolean CParser_ParseOperatorName(short *token, Boolean flag1, Boolean flag2) { *token = 0; return 1; } else { - CError_Error(204); + CError_Error(CErrorStr204); return 0; } } @@ -906,7 +906,7 @@ Object *CParser_FindDeallocationObject(Type *type, FuncArg *args, Boolean flag1, } if (list) - CError_Warning(375, type, 0); + CError_Warning(CErrorStr375, type, 0); list = (retry_flag && copts.array_new_delete) ? &dela_fobj->first : &delp_fobj->first; first_time = 0; @@ -1823,7 +1823,7 @@ static Type *getthetype(short token, short size, short signedness) { case TK_VOID: return TYPE(&stvoid); default: - CError_Error(121); + CError_Error(CErrorStr121); return TYPE(&stvoid); } } @@ -1863,7 +1863,7 @@ static void CParser_ParseAttributeFunctionSummary(DeclInfo *declinfo) { Boolean flag; if ((tk = lex()) != '(') { - CError_Error(114); + CError_Error(CErrorStr114); return; } @@ -1880,7 +1880,7 @@ static void CParser_ParseAttributeFunctionSummary(DeclInfo *declinfo) { flag = 0; } else { lex(); - CError_Error(121); + CError_Error(CErrorStr121); return; } @@ -1893,7 +1893,7 @@ static void CParser_ParseAttributeFunctionSummary(DeclInfo *declinfo) { lex(); if (tk != ')') - CError_Error(121); + CError_Error(CErrorStr121); } void CParser_ParseAttribute(Type *type, DeclInfo *declinfo) { @@ -1902,21 +1902,21 @@ void CParser_ParseAttribute(Type *type, DeclInfo *declinfo) { do { if ((tk = lex()) != '(') { - CError_Error(121); + CError_Error(CErrorStr121); return; } if ((tk = lex()) != '(') { - CError_Error(121); + CError_Error(CErrorStr121); return; } if ((tk = lex()) != TK_IDENTIFIER && tk != TK_CONST) { - CError_Error(121); + CError_Error(CErrorStr121); return; } if (!strcmp(tkidentifier->name, "aligned") || !strcmp(tkidentifier->name, "__aligned__")) { if ((tk = lex()) != '(') { - CError_Error(121); + CError_Error(CErrorStr121); return; } @@ -1939,7 +1939,7 @@ void CParser_ParseAttribute(Type *type, DeclInfo *declinfo) { case 0x2000: break; default: - CError_Error(124); + CError_Error(CErrorStr124); return; } if (type) { @@ -1954,7 +1954,7 @@ void CParser_ParseAttribute(Type *type, DeclInfo *declinfo) { type->size += CABI_StructSizeAlignValue(type, type->size); } } else { - CError_Error(149); + CError_Error(CErrorStr149); } } else if (declinfo) { declinfo->qual &= ~Q_ALIGNED_MASK; @@ -2006,67 +2006,67 @@ void CParser_ParseAttribute(Type *type, DeclInfo *declinfo) { break; } } else { - CError_Error(359); + CError_Error(CErrorStr359); } if (tk != ')') { - CError_Error(121); + CError_Error(CErrorStr121); return; } } else if (!strcmp(tkidentifier->name, "nothrow") || !strcmp(tkidentifier->name, "__nothrow__")) { if (declinfo && declinfo->thetype && IS_TYPE_FUNC(declinfo->thetype)) TYPE_FUNC(declinfo->thetype)->flags |= FUNC_FLAGS_NOTHROW; else - CError_Error(359); + CError_Error(CErrorStr359); } else if (!strcmp("function_summary", tkidentifier->name)) { CParser_ParseAttributeFunctionSummary(declinfo); } else if (!strcmp(tkidentifier->name, "packed") || !strcmp(tkidentifier->name, "__packed__")) { - CError_Error(359); + CError_Error(CErrorStr359); } else if (!strcmp(tkidentifier->name, "unused") || !strcmp(tkidentifier->name, "__unused__")) { } else if (!strcmp(tkidentifier->name, "noreturn") || !strcmp(tkidentifier->name, "__noreturn__")) { } else if (tk == TK_CONST || !strcmp(tkidentifier->name, "__const__")) { } else if (!strcmp(tkidentifier->name, "format") || !strcmp(tkidentifier->name, "__format__")) { - CError_Warning(359); + CError_Warning(CErrorStr359); if ((tk = lex()) != '(') { - CError_Warning(114); + CError_Warning(CErrorStr114); return; } tk = lex(); if ((tk = lex()) != ',') { - CError_Warning(116); + CError_Warning(CErrorStr116); return; } tk = lex(); if ((tk = lex()) != ',') { - CError_Warning(116); + CError_Warning(CErrorStr116); return; } tk = lex(); if ((tk = lex()) != ')') { - CError_Warning(115); + CError_Warning(CErrorStr115); return; } } else if (!strcmp(tkidentifier->name, "mode") || !strcmp(tkidentifier->name, "__mode__")) { - CError_Warning(359); + CError_Warning(CErrorStr359); if ((tk = lex()) != '(') { - CError_Warning(114); + CError_Warning(CErrorStr114); return; } tk = lex(); if ((tk = lex()) != ')') { - CError_Warning(115); + CError_Warning(CErrorStr115); return; } } else { - CError_Error(359); + CError_Error(CErrorStr359); } if ((tk = lex()) != ')') { - CError_Error(121); + CError_Error(CErrorStr121); return; } if ((tk = lex()) != ')') { - CError_Error(121); + CError_Error(CErrorStr121); return; } tk = lex(); @@ -2084,10 +2084,10 @@ static void CParser_ParseTypeOf(DeclInfo *declinfo) { CParser_GetDeclSpecs(&subdi, 0); scandeclarator(&subdi); if (subdi.name) - CError_Error(121); + CError_Error(CErrorStr121); if (tk != ')') - CError_ErrorSkip(115); + CError_ErrorSkip(CErrorStr115); else tk = lex(); @@ -2095,7 +2095,7 @@ static void CParser_ParseTypeOf(DeclInfo *declinfo) { } else { expr = unary_expression(); if (ENODE_IS(expr, EINDIRECT) && ENODE_IS(expr->data.monadic, EBITFIELD)) - CError_Error(144); + CError_Error(CErrorStr144); TypedefDeclInfo(declinfo, expr->rtype, expr->flags & ENODE_FLAG_QUALS); } } @@ -2103,7 +2103,7 @@ static void CParser_ParseTypeOf(DeclInfo *declinfo) { void CParser_ParseDeclSpec(DeclInfo *declinfo, Boolean flag) { if ((tk = lex()) != TK_IDENTIFIER) { if (tk != TK_EXPORT) - CError_Error(107); + CError_Error(CErrorStr107); else declinfo->exportflags |= EXPORT_FLAGS_EXPORT; } else if (!strcmp("internal", tkidentifier->name)) { @@ -2146,7 +2146,7 @@ static int CParser_GetVectorDeclSpec(Type **type) { return 1; } default: - CError_Error(121); + CError_Error(CErrorStr121); } break; case TK_SIGNED: @@ -2184,7 +2184,7 @@ static int CParser_GetVectorDeclSpec(Type **type) { return 1; } default: - CError_Error(121); + CError_Error(CErrorStr121); } break; case TK_UNSIGNED: @@ -2222,7 +2222,7 @@ static int CParser_GetVectorDeclSpec(Type **type) { return 1; } default: - CError_Error(121); + CError_Error(CErrorStr121); } break; case TK_BOOL: @@ -2260,7 +2260,7 @@ static int CParser_GetVectorDeclSpec(Type **type) { return 1; } default: - CError_Error(121); + CError_Error(CErrorStr121); } break; case TK_SHORT: @@ -2310,7 +2310,7 @@ static int CParser_GetVectorDeclSpec(Type **type) { return 1; } default: - CError_Error(121); + CError_Error(CErrorStr121); } break; case TK_IDENTIFIER: @@ -2322,7 +2322,7 @@ static int CParser_GetVectorDeclSpec(Type **type) { return 1; } default: - CError_Error(121); + CError_Error(CErrorStr121); } break; case TK_LONG: @@ -2368,7 +2368,7 @@ static int CParser_GetVectorDeclSpec(Type **type) { return 1; } default: - CError_Error(121); + CError_Error(CErrorStr121); } break; case TK_IDENTIFIER: @@ -2380,7 +2380,7 @@ static int CParser_GetVectorDeclSpec(Type **type) { return 1; } default: - CError_Error(121); + CError_Error(CErrorStr121); } break; case TK_INT: @@ -2453,7 +2453,7 @@ static int CParser_GetVectorDeclSpec(Type **type) { return 1; } default: - CError_Error(121); + CError_Error(CErrorStr121); } break; case TK_LONG: @@ -2496,7 +2496,7 @@ static int CParser_GetVectorDeclSpec(Type **type) { } } default: - CError_Error(121); + CError_Error(CErrorStr121); } break; case TK_FLOAT: @@ -2546,7 +2546,7 @@ static int CParser_GetVectorDeclSpec(Type **type) { } } default: - CError_Error(121); + CError_Error(CErrorStr121); } return 0; @@ -2560,7 +2560,7 @@ Boolean CParser_CheckTemplateClassUsage(TemplClass *tmclass, Boolean flag) { while (1) { if (!nspace) { if (flag) - CError_Error(230); + CError_Error(CErrorStr230); return 0; } if (nspace->theclass == TYPE_CLASS(tmclass)) @@ -2623,7 +2623,7 @@ restart: case TK_TYPEDEF: case TK_MUTABLE: if (di->storageclass) - CError_Error(121); + CError_Error(CErrorStr121); di->storageclass = tk; break; case TK_CONST: @@ -2701,10 +2701,10 @@ restart: break; case TK_UU_DECLSPEC: if ((tk = lex()) != '(') - CError_Error(114); + CError_Error(CErrorStr114); CParser_ParseDeclSpec(di, 0); if ((tk = lex()) != ')') - CError_Error(115); + CError_Error(CErrorStr115); break; case TK_ASM: if (di->qual & Q_ASM) @@ -2718,74 +2718,74 @@ restart: break; case TK_SHORT: if (typesize || (typetoken && typetoken != TK_INT && typetoken != TK_DOUBLE)) - CError_Error(121); + CError_Error(CErrorStr121); typesize = 1; break; case TK_LONG: if (copts.longlong) { if (typetoken && typetoken != TK_INT && typetoken != TK_DOUBLE) - CError_Error(121); + CError_Error(CErrorStr121); if (typesize) { if (typesize != 2 || typetoken == TK_DOUBLE) - CError_Error(121); + CError_Error(CErrorStr121); typesize = 3; } else { typesize = 2; } } else { if (typesize || (typetoken && typetoken != TK_INT && typetoken != TK_DOUBLE)) - CError_Error(121); + CError_Error(CErrorStr121); typesize = 2; } break; case TK_SIGNED: if (signedness || (typetoken && typetoken != TK_INT && typetoken != TK_CHAR)) - CError_Error(121); + CError_Error(CErrorStr121); signedness = -1; break; case TK_UNSIGNED: if (signedness || (typetoken && typetoken != TK_INT && typetoken != TK_CHAR)) - CError_Error(121); + CError_Error(CErrorStr121); signedness = 1; break; case TK_VOID: if (typetoken || typesize || signedness) - CError_Error(121); + CError_Error(CErrorStr121); typetoken = TK_VOID; break; case TK_FLOAT: if (typetoken || typesize || signedness) - CError_Error(121); + CError_Error(CErrorStr121); typetoken = TK_FLOAT; break; case TK_BOOL: if (typetoken || typesize) - CError_Error(121); + CError_Error(CErrorStr121); typetoken = TK_BOOL; break; case TK_CHAR: if (typetoken || typesize) - CError_Error(121); + CError_Error(CErrorStr121); typetoken = TK_CHAR; break; case TK_WCHAR_T: if (typetoken || typesize || signedness) - CError_Error(121); + CError_Error(CErrorStr121); typetoken = TK_WCHAR_T; break; case TK_INT: if (typetoken) - CError_Error(121); + CError_Error(CErrorStr121); typetoken = TK_INT; break; case TK_DOUBLE: if (typetoken || signedness) - CError_Error(121); + CError_Error(CErrorStr121); typetoken = TK_DOUBLE; break; case TK_STRUCT: if (typetoken || signedness || typesize) - CError_Error(121); + CError_Error(CErrorStr121); tk = lex(); scanstruct(di, STRUCT_TYPE_STRUCT); if (tk == TK_UU_ATTRIBUTE_UU) @@ -2797,7 +2797,7 @@ restart: return; case TK_CLASS: if (typetoken || signedness || typesize) - CError_Error(121); + CError_Error(CErrorStr121); tk = lex(); CDecl_ParseClass(di, CLASS_MODE_2, 1, 0); if (tk == TK_UU_ATTRIBUTE_UU) @@ -2809,7 +2809,7 @@ restart: return; case TK_UNION: if (typetoken || signedness || typesize) - CError_Error(121); + CError_Error(CErrorStr121); tk = lex(); scanstruct(di, STRUCT_TYPE_UNION); if (tk == TK_UU_ATTRIBUTE_UU) @@ -2821,7 +2821,7 @@ restart: return; case TK_ENUM: if (typetoken || signedness || typesize) - CError_Error(121); + CError_Error(CErrorStr121); tk = lex(); scanenum(di); if (tk == TK_UU_ATTRIBUTE_UU) @@ -2833,11 +2833,11 @@ restart: return; case TK_TYPENAME: if (typetoken || signedness || typesize || di->x53) - CError_Error(121); + CError_Error(CErrorStr121); di->x53 = 1; tk = lex(); if (tk != TK_COLON_COLON && tk != TK_IDENTIFIER) { - CError_Error(121); + CError_Error(CErrorStr121); break; } goto some_shared_label; @@ -2847,7 +2847,7 @@ restart: goto some_shared_label; case TK_UU_VECTOR: if (typetoken || signedness || typesize) - CError_Error(121); + CError_Error(CErrorStr121); handle_vector: if (CParser_GetVectorDeclSpec(&di->thetype)) { if (tk == TK_CONST) { @@ -2855,7 +2855,7 @@ restart: di->qual |= Q_CONST; tk = lex(); } else { - CError_Error(121); + CError_Error(CErrorStr121); } } if (tk == TK_VOLATILE) { @@ -2863,7 +2863,7 @@ restart: di->qual |= Q_VOLATILE; tk = lex(); } else { - CError_Error(121); + CError_Error(CErrorStr121); } } return; @@ -2871,7 +2871,7 @@ restart: break; case TK_UU_TYPEOF_UU: if (typetoken || signedness || typesize) - CError_Error(121); + CError_Error(CErrorStr121); CParser_ParseTypeOf(di); typetoken = -1; goto bailOut; @@ -2897,11 +2897,11 @@ restart: case TPT_TYPE: break; case TPT_NONTYPE: - CError_Error(348); + CError_Error(CErrorStr348); pr.x8 = TYPE(&stsignedint); break; case TPT_TEMPLATE: - CError_Error(230); + CError_Error(CErrorStr230); pr.x8 = TYPE(&stsignedint); break; default: @@ -2910,7 +2910,7 @@ restart: break; case TEMPLDEP_QUALNAME: if (!di->x53 && !pr.x20 && di->x55) - CError_Error(355); + CError_Error(CErrorStr355); break; case TEMPLDEP_TEMPLATE: case TEMPLDEP_ARRAY: @@ -2926,13 +2926,13 @@ restart: if (!CParser_CheckTemplateClassUsage(TEMPL_CLASS(pr.x8), 0)) { if (di->x56) { if (di->qual) - CError_Error(121); + CError_Error(CErrorStr121); di->thetype = pr.x8; di->x57 = 1; tk = lex(); return; } else { - CError_Error(230); + CError_Error(CErrorStr230); pr.x8 = TYPE(&stsignedint); } } @@ -2952,7 +2952,7 @@ restart: if (IS_TYPE_FUNC(OBJECT(di->x14->object)->type) && ((TYPE_FUNC(OBJECT(di->x14->object)->type)->flags & FUNC_FLAGS_1000) | FUNC_FLAGS_2000)) r23 = 0; } else { - CError_Error(121); + CError_Error(CErrorStr121); } } } else if (pr.obj_10) { @@ -2964,20 +2964,20 @@ restart: if (IS_TYPE_FUNC(di->x10->type) && ((TYPE_FUNC(di->x10->type)->flags & FUNC_FLAGS_1000) | FUNC_FLAGS_2000)) r23 = 0; } else { - CError_Error(121); + CError_Error(CErrorStr121); } } break; case OT_ENUMCONST: case OT_MEMBERVAR: - CError_Error(121); + CError_Error(CErrorStr121); break; default: CError_FATAL(4217); } } else if (pr.name_4) { if (copts.cplusplus) - CError_Error(121); + CError_Error(CErrorStr121); } else if (pr.x21) { CPrep_TokenStreamSetState(&state); CPrep_UnLex(); @@ -2994,9 +2994,9 @@ restart: di->x4A = 1; if (r23) { if (!di->storageclass && !di->qual && !di->exportflags) - CError_Error(121); + CError_Error(CErrorStr121); else - CError_Warning(349); + CError_Warning(CErrorStr349); } } if (typetoken >= 0) @@ -3008,7 +3008,7 @@ restart: return; case ';': if (!typetoken && !signedness && !typesize && copts.warn_emptydecl) - CError_Warning(216); + CError_Warning(CErrorStr216); if (typetoken >= 0) di->thetype = getthetype(typetoken, typesize, signedness); return; @@ -3116,13 +3116,13 @@ void CParser_CheckAnonymousUnion(DeclInfo *di, Boolean flag) { if (!di->storageclass && !di->qual) return; } - CError_Warning(216); + CError_Warning(CErrorStr216); } return; } if (!flag && di->storageclass != TK_STATIC) - CError_Error(177); + CError_Error(CErrorStr177); if (flag && di->storageclass != TK_STATIC) { obj = CParser_NewLocalDataObject(di, 1); @@ -3210,7 +3210,7 @@ Object *CParser_ParseObject(void) { return OBJECT(list->object); obj = OBJECT(list->object); - CError_Error(249, CError_GetObjectName(obj), obj->type, obj->qual, di.thetype, di.qual); + CError_Error(CErrorStr249, CError_GetObjectName(obj), obj->type, obj->qual, di.thetype, di.qual); } } @@ -3228,7 +3228,7 @@ void CParser_ParseGlobalDeclaration(void) { memclrw(&di, sizeof(DeclInfo)); CParser_GetDeclSpecs(&di, 1); if (di.storageclass == TK_REGISTER || di.storageclass == TK_AUTO) { - CError_Error(177); + CError_Error(CErrorStr177); di.storageclass = 0; } @@ -3239,7 +3239,7 @@ void CParser_ParseGlobalDeclaration(void) { tk = lex(); } else { - CError_Error(102); + CError_Error(CErrorStr102); } } @@ -3257,7 +3257,7 @@ static void CParser_ParseLinkageSpecification(DeclInfo *di) { r29 = 8; r28 = 1; } else { - CError_Error(121); + CError_Error(CErrorStr121); r29 = 0; r28 = 1; } @@ -3265,7 +3265,7 @@ static void CParser_ParseLinkageSpecification(DeclInfo *di) { if ((tk = lex()) == '{') { while (1) { if ((tk = lex()) == 0) { - CError_Error(130); + CError_Error(CErrorStr130); return; } @@ -3292,7 +3292,7 @@ static void CParser_ParseLinkageSpecification(DeclInfo *di) { if (di->storageclass != TK_TYPEDEF) { if (di->storageclass && copts.pedantic) - CError_Warning(177); + CError_Warning(CErrorStr177); if (!di->storageclass) di->storageclass = TK_EXTERN; } @@ -3321,7 +3321,7 @@ static void CParser_ParseNameSpace(DeclInfo *di) { } } else { if (tk != '{') { - CError_Error(107); + CError_Error(CErrorStr107); return; } name = CParser_GetUnnamedNameSpaceName(); @@ -3352,20 +3352,20 @@ static void CParser_ParseNameSpace(DeclInfo *di) { CScope_AddObject(cscope_current, name, OBJ_BASE(objns)); } else { if (list->object->otype != OT_NAMESPACE) - CError_Error(320); + CError_Error(CErrorStr320); else nspace = OBJ_NAMESPACE(list->object)->nspace; } if (tk != '{') { - CError_Error(135); + CError_Error(CErrorStr135); return; } CScope_SetNameSpaceScope(nspace, &save); while (1) { if ((tk = lex()) == 0) { - CError_Error(130); + CError_Error(CErrorStr130); break; } @@ -3400,9 +3400,9 @@ static void CParser_ParseDeclaration(DeclInfo *di) { CParser_ParseNameSpace(di); break; case TK_EXPORT: - CError_Error(190); + CError_Error(CErrorStr190); if ((tk = lex()) != TK_TEMPLATE) { - CError_Error(121); + CError_Error(CErrorStr121); return; } case TK_TEMPLATE: @@ -3427,7 +3427,7 @@ static void CParser_ParseDeclaration(DeclInfo *di) { default: CParser_GetDeclSpecs(di, 1); if ((di->storageclass == TK_REGISTER || di->storageclass == TK_AUTO) != 0) { - CError_Error(177); + CError_Error(CErrorStr177); di->storageclass = 0; } if (tk != ';') @@ -3442,7 +3442,7 @@ void cparser(void) { DeclInfo di; if (copts.crippled && copts.optimizationlevel > 1) { - CError_Warning(385); + CError_Warning(CErrorStr385); copts.optimizationlevel = 1; CodeGen_UpdateOptimizerOptions(); CodeGen_UpdateBackEndOptions(); @@ -3459,7 +3459,7 @@ void cparser(void) { } while (tk && (tk = lex())); } else { if (!copts.cplusplus && copts.ANSI_strict) - CError_Error(102); + CError_Error(CErrorStr102); } CInit_DefineTentativeData(); diff --git a/compiler_and_linker/unsorted/CPrec.c b/compiler_and_linker/unsorted/CPrec.c index 6e0692b..75608bf 100644 --- a/compiler_and_linker/unsorted/CPrec.c +++ b/compiler_and_linker/unsorted/CPrec.c @@ -172,7 +172,7 @@ static TemplArg *CPrec_GetTemplateArgPatch(TemplArg *arg); static NameSpaceObjectList *CPrec_GetNameSpaceObjectListPatch(NameSpaceObjectList *nsol); static OSErr CPrec_FlushBufferCheck(void); -void SetupPrecompiler(void) { +void SetupPrecompiler(Boolean isPrecompiling) { cprec_refnum = 0; cprec_glist.data = NULL; cprec_header = NULL; @@ -1455,7 +1455,7 @@ static TStreamElement *CPrec_GetTStreamPatch(TStreamElement *tokens, SInt32 coun case TK_STRING_WIDE: CPrec_RawMemPatch(¤t->data.tkstring.data, tokens->data.tkstring.data, tokens->data.tkstring.size); break; - case TK_NEG7: + case TK_EOL: break; default: if (tokens->tokentype < 0) diff --git a/compiler_and_linker/unsorted/CTemplateClass.c b/compiler_and_linker/unsorted/CTemplateClass.c index e0813e8..e180159 100644 --- a/compiler_and_linker/unsorted/CTemplateClass.c +++ b/compiler_and_linker/unsorted/CTemplateClass.c @@ -255,7 +255,7 @@ TemplClassInst *CTemplClass_GetInstance(TemplClass *tmclass, TemplArg *inst_args return CTemplClass_NewInstance(tmclass, inst_args, oargs); } -TemplateMember *CTemplClass_DefineMember(TemplClass *tmclass, Object *object, FileOffsetInfo *foi, TStream *stream) { +TemplateMember *CTemplClass_DefineMember(TemplClass *tmclass, Object *object, FileOffsetInfo *foi, TokenStream *stream) { TemplateMember *member; for (member = tmclass->members; member; member = member->next) { diff --git a/compiler_and_linker/unsorted/CTemplateNew.c b/compiler_and_linker/unsorted/CTemplateNew.c index 4fdfc37..ddda594 100644 --- a/compiler_and_linker/unsorted/CTemplateNew.c +++ b/compiler_and_linker/unsorted/CTemplateNew.c @@ -787,7 +787,7 @@ static void *CTempl_ParseMemberFunction(int unk1, int unk2, int unk3, Object *fu static void CTempl_ParseMember(TemplParam *params, TemplClass *templ, DeclInfo *di, SInt32 *startOffset) { Object *object; NameSpaceObjectList *nsol; - TStream stream; + TokenStream stream; CPrepFileInfo *file; SInt32 offset; Boolean saveForceLoc; diff --git a/compiler_and_linker/unsorted/CTemplateTools.c b/compiler_and_linker/unsorted/CTemplateTools.c index 1d79ce0..bc7f8be 100644 --- a/compiler_and_linker/unsorted/CTemplateTools.c +++ b/compiler_and_linker/unsorted/CTemplateTools.c @@ -1005,7 +1005,7 @@ static TemplClassInst *CTemplTool_FindNestedClassInstance(TemplClass *a, TemplCl break; if ((inst->theclass.flags & (CLASS_FLAGS_2 | CLASS_FLAGS_800)) == CLASS_FLAGS_800) - CTempl_InstantiateTemplateClass(inst); + CTempl_InstantiateTemplateClass(TYPE_CLASS(inst)); } return inst; diff --git a/compiler_and_linker/unsorted/CodeGen.c b/compiler_and_linker/unsorted/CodeGen.c index 8268736..b79b423 100644 --- a/compiler_and_linker/unsorted/CodeGen.c +++ b/compiler_and_linker/unsorted/CodeGen.c @@ -873,7 +873,7 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B } if (cparamblkptr->isPrecompiling == 1) - CError_Error(180); + CError_Error(CErrorStr180); if (!func) { func = createstaticinitobject(); @@ -919,7 +919,7 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B initpcode(); pclabel(prologue = makepcblock(), makepclabel()); - prologue->flags |= fPCBlockFlag1; + prologue->flags |= fIsProlog; pclabel(tmp = makepcblock(), makepclabel()); pcbranch(prologue, tmp->labels); @@ -1019,7 +1019,7 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B current_statement = NULL; epilogue = pclastblock; - pclastblock->flags |= fPCBlockFlag2; + pclastblock->flags |= fIsEpilogue; pccomputepredecessors(); deleteunreachableblocks(); @@ -1278,18 +1278,18 @@ void CodeGen_ParseDeclSpec(HashNameNode *identifier, DeclInfo *declinfo) { declinfo->storageclass = TK_EXTERN; declinfo->exportflags = EXPORT_FLAGS_INTERNAL; } else { - CError_Error(176); + CError_Error(CErrorStr176); } } static void CodeGen_EOLCheck(void) { short t; - if (plex() != TK_NEG7) { - CPrep_Error(113); + if (plex() != TK_EOL) { + CPrep_Error(CErrorStr113); do { t = plex(); - } while (t != TK_NEG7 && t != 0); + } while (t != TK_EOL && t != 0); } } @@ -1346,7 +1346,7 @@ static void pragma_scheduling(void) { PPCError_Error(115); return; } - CPrep_Error(186); + CPrep_Error(CErrorStr186); return; } @@ -1382,7 +1382,7 @@ static void pragma_scheduling(void) { cpu = 9; break; default: - CPrep_Error(186); + CPrep_Error(CErrorStr186); return; } schedule_for(cpu); @@ -1390,7 +1390,7 @@ static void pragma_scheduling(void) { } if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } static SInt32 CodeGen_ParseLongIntegerORonORoff(void) { @@ -1403,7 +1403,7 @@ static SInt32 CodeGen_ParseLongIntegerORonORoff(void) { if (!tkintconst.hi) result = CInt64_GetULong(&tkintconst); else - CPrep_Error(154); + CPrep_Error(CErrorStr154); CodeGen_EOLCheck(); } else if (t == TK_IDENTIFIER) { if (!strcmp(tkidentifier->name, "on")) { @@ -1415,11 +1415,11 @@ static SInt32 CodeGen_ParseLongIntegerORonORoff(void) { return 0; } if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); return 0; } else { if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); } return result; @@ -1443,7 +1443,7 @@ void CodeGen_ParsePragma(HashNameNode *name) { copts.report_heap_info = CInt64_GetULong(&tkintconst); if (copts.report_heap_info < 0) { copts.report_heap_info = 0; - CError_Error(186); + CError_Error(CErrorStr186); } } else if (t == TK_IDENTIFIER) { if (!strcmp(tkidentifier->name, "off")) { @@ -1451,11 +1451,11 @@ void CodeGen_ParsePragma(HashNameNode *name) { } else if (!strcmp(tkidentifier->name, "on")) { copts.report_heap_info = 1; } else { - CError_Error(186); + CError_Error(CErrorStr186); return; } } else { - CError_Error(186); + CError_Error(CErrorStr186); } CodeGen_EOLCheck(); return; @@ -1474,11 +1474,11 @@ void CodeGen_ParsePragma(HashNameNode *name) { } else if (!strcmp(tkidentifier->name, "on")) { copts.ppc_unroll_speculative = 1; } else { - CError_Error(186); + CError_Error(CErrorStr186); return; } } else { - CError_Error(186); + CError_Error(CErrorStr186); } CodeGen_EOLCheck(); return; @@ -1490,7 +1490,7 @@ void CodeGen_ParsePragma(HashNameNode *name) { copts.ppc_unroll_instructions_limit = CInt64_GetULong(&tkintconst); if (copts.ppc_unroll_instructions_limit < 0) { copts.ppc_unroll_instructions_limit = 0; - CError_Error(186); + CError_Error(CErrorStr186); } } else if (t == TK_IDENTIFIER) { if (!strcmp(tkidentifier->name, "off")) { @@ -1498,11 +1498,11 @@ void CodeGen_ParsePragma(HashNameNode *name) { } else if (!strcmp(tkidentifier->name, "on")) { copts.ppc_unroll_instructions_limit = 70; } else { - CError_Error(186); + CError_Error(CErrorStr186); return; } } else { - CError_Error(186); + CError_Error(CErrorStr186); } CodeGen_EOLCheck(); return; @@ -1514,10 +1514,10 @@ void CodeGen_ParsePragma(HashNameNode *name) { value = CInt64_GetULong(&tkintconst); if (value < 0) { copts.gen_fsel = 0; - CError_Error(186); + CError_Error(CErrorStr186); } else if (value > 255) { copts.gen_fsel = 255; - CError_Error(186); + CError_Error(CErrorStr186); } else { copts.gen_fsel = value; } @@ -1529,11 +1529,11 @@ void CodeGen_ParsePragma(HashNameNode *name) { } else if (!strcmp(tkidentifier->name, "always")) { copts.gen_fsel = 255; } else { - CError_Error(186); + CError_Error(CErrorStr186); return; } } else { - CError_Error(186); + CError_Error(CErrorStr186); } CodeGen_EOLCheck(); return; @@ -1545,7 +1545,7 @@ void CodeGen_ParsePragma(HashNameNode *name) { copts.ppc_unroll_factor_limit = CInt64_GetULong(&tkintconst); if (copts.ppc_unroll_factor_limit < 0) { copts.ppc_unroll_factor_limit = 0; - CError_Error(186); + CError_Error(CErrorStr186); } } else if (t == TK_IDENTIFIER) { if (!strcmp(tkidentifier->name, "off")) { @@ -1553,11 +1553,11 @@ void CodeGen_ParsePragma(HashNameNode *name) { } else if (!strcmp(tkidentifier->name, "on")) { copts.ppc_unroll_factor_limit = 10; } else { - CError_Error(186); + CError_Error(CErrorStr186); return; } } else { - CError_Error(186); + CError_Error(CErrorStr186); } CodeGen_EOLCheck(); return; @@ -1570,11 +1570,11 @@ void CodeGen_ParsePragma(HashNameNode *name) { } else if (!strcmp(tkidentifier->name, "on")) { copts.altivec_model = 1; } else { - CError_Error(186); + CError_Error(CErrorStr186); return; } } else { - CError_Error(186); + CError_Error(CErrorStr186); } CodeGen_EOLCheck(); return; @@ -1591,11 +1591,11 @@ void CodeGen_ParsePragma(HashNameNode *name) { } else if (!strcmp(tkidentifier->name, "reset")) { CPrep_PopOption(OPT_OFFSET(altivec_vrsave)); } else { - CError_Error(186); + CError_Error(CErrorStr186); return; } } else { - CError_Error(186); + CError_Error(CErrorStr186); } CodeGen_EOLCheck(); return; @@ -1768,11 +1768,11 @@ void CodeGen_ParsePragma(HashNameNode *name) { } else if (!strcmp(tkidentifier->name, "on")) { no_descriptors = 0; } else { - CError_Error(186); + CError_Error(CErrorStr186); return; } } else { - CError_Error(186); + CError_Error(CErrorStr186); } CodeGen_EOLCheck(); @@ -1787,11 +1787,11 @@ void CodeGen_ParsePragma(HashNameNode *name) { } else if (!strcmp(tkidentifier->name, "on")) { copts.codegen_dynamic = 1; } else { - CError_Error(186); + CError_Error(CErrorStr186); return; } } else { - CError_Error(186); + CError_Error(CErrorStr186); } CodeGen_EOLCheck(); @@ -1809,11 +1809,11 @@ void CodeGen_ParsePragma(HashNameNode *name) { copts.codegen_pic = 0; } } else { - CError_Error(186); + CError_Error(CErrorStr186); return; } } else { - CError_Error(186); + CError_Error(CErrorStr186); } CodeGen_EOLCheck(); @@ -1827,11 +1827,11 @@ void CodeGen_ParsePragma(HashNameNode *name) { } else if (!strcmp(tkidentifier->name, "on")) { copts.no_implicit_templates = 0; } else { - CError_Error(186); + CError_Error(CErrorStr186); return; } } else { - CError_Error(186); + CError_Error(CErrorStr186); } CodeGen_EOLCheck(); @@ -1845,11 +1845,11 @@ void CodeGen_ParsePragma(HashNameNode *name) { } else if (!strcmp(tkidentifier->name, "on")) { copts.no_common = 0; } else { - CError_Error(186); + CError_Error(CErrorStr186); return; } } else { - CError_Error(186); + CError_Error(CErrorStr186); } CodeGen_EOLCheck(); @@ -1866,7 +1866,7 @@ void CodeGen_ParsePragma(HashNameNode *name) { } } } else { - CError_Error(186); + CError_Error(CErrorStr186); } CodeGen_EOLCheck(); @@ -1874,12 +1874,12 @@ void CodeGen_ParsePragma(HashNameNode *name) { } if (copts.warn_illpragma) - CPrep_Warning(186); + CPrep_Warning(CErrorStr186); - if (plex() != TK_NEG7) { + if (plex() != TK_EOL) { do { t = plex(); - } while (t != TK_NEG7 && t != 0); + } while (t != TK_EOL && t != 0); } } diff --git a/compiler_and_linker/unsorted/CodeMotion.c b/compiler_and_linker/unsorted/CodeMotion.c index 00e8015..8ce2962 100644 --- a/compiler_and_linker/unsorted/CodeMotion.c +++ b/compiler_and_linker/unsorted/CodeMotion.c @@ -16,12 +16,12 @@ static int isloopinvariant(PCode *pcode, Loop *loop, UInt32 *vec, int flag1, int RegUseOrDef *list; int i; - if (pcode->flags & (fPCodeFlag2 | fPCodeFlag4 | fPCodeFlag20000 | fPCodeFlag40000)) { + if (pcode->flags & (fIsRead | fIsWrite | fPCodeFlag20000 | fPCodeFlag40000)) { if (pcode->alias) { if (pcode->alias->type == AliasType2 || (pcode->flags & (fIsVolatile | fSideEffects))) return 0; - if (pcode->flags & fPCodeFlag2) { + if (pcode->flags & fIsRead) { for (list = findobjectusedef(pcode->alias->object)->defs; list; list = list->next) { if ( may_alias(pcode, Defs[list->id].pcode) && @@ -32,7 +32,7 @@ static int isloopinvariant(PCode *pcode, Loop *loop, UInt32 *vec, int flag1, int } } - if (pcode->flags & fPCodeFlag4) { + if (pcode->flags & fIsWrite) { for (list = findobjectusedef(pcode->alias->object)->uses; list; list = list->next) { if ( may_alias(pcode, Uses[list->id].pcode) && @@ -46,7 +46,7 @@ static int isloopinvariant(PCode *pcode, Loop *loop, UInt32 *vec, int flag1, int } } - if ((pcode->flags & fPCodeFlag4) && !bitvectorgetbit(pcode->block->blockIndex, loop->vec2C)) + if ((pcode->flags & fIsWrite) && !bitvectorgetbit(pcode->block->blockIndex, loop->vec2C)) return 0; op = pcode->args; @@ -54,7 +54,7 @@ static int isloopinvariant(PCode *pcode, Loop *loop, UInt32 *vec, int flag1, int while (i--) { switch (op->kind) { case PCOp_MEMORY: - if ((pcode->flags & fPCodeFlag2) && ((pcode->flags == 0) & 0x40)) { + if ((pcode->flags & fIsRead) && ((pcode->flags == 0) & 0x40)) { for (list = findobjectusedef(op->data.mem.obj)->defs; list; list = list->next) { if ( may_alias(pcode, Defs[list->id].pcode) && @@ -64,7 +64,7 @@ static int isloopinvariant(PCode *pcode, Loop *loop, UInt32 *vec, int flag1, int return 0; } } - if (pcode->flags & fPCodeFlag4) { + if (pcode->flags & fIsWrite) { for (list = findobjectusedef(op->data.mem.obj)->uses; list; list = list->next) { if ( may_alias(pcode, Uses[list->id].pcode) && @@ -390,8 +390,8 @@ static int srawi_addze_isloopinvariant(PCode *pcode, Loop *loop, UInt32 *vec) { nextInstr->op == PC_ADDZE && pcode->args[0].data.reg.reg == nextInstr->args[0].data.reg.reg && nextInstr->args[0].data.reg.reg == nextInstr->args[1].data.reg.reg && - !(pcode->flags & (fPCodeFlag8 | fPCodeFlag20 | fIsVolatile | fSideEffects)) && - !(nextInstr->flags & (fPCodeFlag8 | fPCodeFlag20 | fIsVolatile | fSideEffects)) && + !(pcode->flags & (fIsCall | fIsPtrOp | fIsVolatile | fSideEffects)) && + !(nextInstr->flags & (fIsCall | fIsPtrOp | fIsVolatile | fSideEffects)) && isloopinvariant(pcode, loop, vec, 1, 0) && srawi_addze_maymove(pcode, loop) ) { @@ -469,7 +469,7 @@ static void movecmptopreheader(Loop *loop, PCodeBlock *block, PCode *pc1, PCode PCode *pc3; preheader = loop->preheader; - if (PCODE_FLAG_SET_F(pc1) & fPCodeFlag20000000) { + if (PCODE_FLAG_SET_F(pc1) & fRecordBit) { moveinvariantcomputation(pc1, loop); } else { deletepcode(pc1); @@ -651,7 +651,7 @@ static void simpleunswitchloop(Loop *loop) { myvec = oalloc(4 * ((number_of_Defs + 31) >> 5)); bitvectorcopy(myvec, usedefinfo[block26->blockIndex].defvec8, number_of_Defs); for (pc25 = loop->preheader->nextBlock->firstPCode; pc25; pc25 = pc25->nextPCode) { - if (!(PCODE_FLAG_SET_F(pc25) & (fPCodeFlag8 | fPCodeFlag20 | fIsVolatile | fSideEffects | fPCodeFlag20000000))) { + if (!(PCODE_FLAG_SET_F(pc25) & (fIsCall | fIsPtrOp | fIsVolatile | fSideEffects | fRecordBit))) { if (isloopinvariant(pc25, loop, myvec, 0, 1)) break; } @@ -670,7 +670,7 @@ static void simpleunswitchloop(Loop *loop) { pc29 = pc25->block->lastPCode; if ( !pc29 || - !(pc29->flags & fPCodeFlag1) || + !(pc29->flags & fIsBranch) || pc29->args[0].kind != PCOp_REGISTER || pc29->args[0].arg != RegClass_CRFIELD ) @@ -850,9 +850,9 @@ static void moveinvariantsfromloop(Loop *loop) { bitvectorcopy(myvec, usedefinfo[block->blockIndex].defvec8, number_of_Defs); for (instr = block->firstPCode; instr; instr = nextInstr) { nextInstr = instr->nextPCode; - if (!(instr->flags & fPCodeFlag1) && instr->argCount) { + if (!(instr->flags & fIsBranch) && instr->argCount) { if ( - !(instr->flags & (fPCodeFlag8 | fPCodeFlag20 | fIsVolatile | fSideEffects)) && + !(instr->flags & (fIsCall | fIsPtrOp | fIsVolatile | fSideEffects)) && isloopinvariant(instr, loop, myvec, 0, 0) && maymove(instr, loop) ) { diff --git a/compiler_and_linker/unsorted/Coloring.c b/compiler_and_linker/unsorted/Coloring.c index f8ba156..82a87f3 100644 --- a/compiler_and_linker/unsorted/Coloring.c +++ b/compiler_and_linker/unsorted/Coloring.c @@ -197,7 +197,7 @@ static void rewritepcode(void) { } if ( - (instr->flags & fPCodeFlag10) && + (instr->flags & fIsMove) && (instr->args[1].arg == coloring_class) && instr->args[1].data.reg.reg == instr->args[0].data.reg.reg ) diff --git a/compiler_and_linker/unsorted/ConstantPropagation.c b/compiler_and_linker/unsorted/ConstantPropagation.c index 4fe1d06..2b40453 100644 --- a/compiler_and_linker/unsorted/ConstantPropagation.c +++ b/compiler_and_linker/unsorted/ConstantPropagation.c @@ -128,7 +128,7 @@ static int isunsignedloadoperand(PCodeArg *op) { PCode *instr; if ((instr = defininginstruction[op->data.reg.reg])) { - if (instr->flags & fPCodeFlag2) { + if (instr->flags & fIsRead) { if (instr->op >= PC_LHZ && instr->op <= PC_LHZUX) return 2; if (instr->op >= PC_LBZ && instr->op <= PC_LBZUX) @@ -173,7 +173,7 @@ static int issignedloadoperand(PCodeArg *op) { PCode *instr; if ((instr = defininginstruction[op->data.reg.reg])) { - if (instr->flags & fPCodeFlag2) { + if (instr->flags & fIsRead) { if (instr->op >= PC_LHA && instr->op <= PC_LHAUX) return 2; } else if (instr->op == PC_EXTSB) { @@ -223,7 +223,7 @@ static void propagateconstantstoblock(PCodeBlock *block) { break; case PC_RLWINM: if ( - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(instr) & fRecordBit) && instr->args[2].data.imm.value == 0 && instr->args[4].data.imm.value == 31 ) @@ -279,7 +279,7 @@ static void propagateconstantstoblock(PCodeBlock *block) { break; case PC_EXTSH: - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) break; if (isconstantoperand(&instr->args[1], &value1)) { @@ -303,7 +303,7 @@ static void propagateconstantstoblock(PCodeBlock *block) { break; case PC_EXTSB: - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) break; if ( @@ -332,7 +332,7 @@ static void propagateconstantstoblock(PCodeBlock *block) { break; case PC_ADDI: - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) break; immAddend = instr->args[2].data.imm.value; @@ -352,7 +352,7 @@ static void propagateconstantstoblock(PCodeBlock *block) { break; case PC_ADD: - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) break; if (isconstantoperand(&instr->args[2], &value1)) { @@ -418,7 +418,7 @@ static void propagateconstantstoblock(PCodeBlock *block) { instr->args[1] = stackInstr->args[1]; instr->args[2] = stackInstr->args[2]; instr->args[2].data.imm.value = value1 + addend; - if (instr->flags & (fPCodeFlag2 | fPCodeFlag4 | fPCodeFlag20000 | fPCodeFlag40000)) + if (instr->flags & (fIsRead | fIsWrite | fPCodeFlag20000 | fPCodeFlag40000)) instr->alias = make_alias(instr->args[2].data.imm.obj, instr->args[2].data.imm.value, 1); propagatedconstants = 1; changed = 1; @@ -428,7 +428,7 @@ static void propagateconstantstoblock(PCodeBlock *block) { break; case PC_OR: - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) break; value1 = 0; @@ -494,7 +494,7 @@ static void propagateconstantstoblock(PCodeBlock *block) { break; case PC_SUBF: - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) break; if (isconstantoperand(&instr->args[1], &value1) && FITS_IN_SHORT(-value1)) { @@ -559,7 +559,7 @@ static void propagateconstantstoblock(PCodeBlock *block) { instr->args[1] = stackInstr->args[1]; instr->args[2] = stackInstr->args[2]; instr->args[2].data.imm.value = value1 + addend; - if (instr->flags & (fPCodeFlag2 | fPCodeFlag4 | fPCodeFlag20000 | fPCodeFlag40000)) + if (instr->flags & (fIsRead | fIsWrite | fPCodeFlag20000 | fPCodeFlag40000)) instr->alias = make_alias(instr->args[2].data.imm.obj, instr->args[2].data.imm.value, nbytes_loaded_or_stored_by(instr)); propagatedconstants = 1; diff --git a/compiler_and_linker/unsorted/CopyPropagation.c b/compiler_and_linker/unsorted/CopyPropagation.c index 8662f61..af451a0 100644 --- a/compiler_and_linker/unsorted/CopyPropagation.c +++ b/compiler_and_linker/unsorted/CopyPropagation.c @@ -65,7 +65,7 @@ static void computecandidatelist(void) { bitvectorcopy(vec, usedefinfo[block->blockIndex].usevec1C, number_of_Uses); candidate = &Candidates[firstcandidateinblock[block->blockIndex] + ncandidatesinblock[block->blockIndex] - 1]; for (pcode = block->lastPCode; pcode; pcode = pcode->prevPCode) { - if (!(pcode->flags & fPCodeFlag1) && pcode->argCount) { + if (!(pcode->flags & fIsBranch) && pcode->argCount) { if (is_candidate(pcode)) { reg = pcode->args[0].data.reg.reg; candidate->pcode = pcode; @@ -80,7 +80,7 @@ static void computecandidatelist(void) { } } - if ((pcode->flags & fPCodeFlag2 | fPCodeFlag4) && (pcode->flags & fPCodeFlag2000000)) { + if ((pcode->flags & fIsRead | fIsWrite) && (pcode->flags & fUpdatesPtr)) { for (list = reg_Uses[pcode->args[1].arg][pcode->args[1].data.reg.reg]; list; list = list->next) { if (bitvectorgetbit(list->id, vec)) { newlist = oalloc(sizeof(RegUseOrDef)); @@ -147,7 +147,7 @@ static void computelocalpropinfo(Boolean flag) { if (flag) { for (pcode = block->firstPCode; pcode; pcode = pcode->nextPCode) { - if (!(pcode->flags & fPCodeFlag1) && pcode->argCount) { + if (!(pcode->flags & fIsBranch) && pcode->argCount) { i = pcode->argCount; op = pcode->args; while (i--) { @@ -176,7 +176,7 @@ static void computelocalpropinfo(Boolean flag) { } } else { for (pcode = block->firstPCode; pcode; pcode = pcode->nextPCode) { - if (!(pcode->flags & fPCodeFlag1) && pcode->argCount) { + if (!(pcode->flags & fIsBranch) && pcode->argCount) { i = pcode->argCount; op = pcode->args; while (i--) { @@ -286,7 +286,7 @@ int precedes(PCode *a, PCode *b) { static int canidatepropagatestoalluses(int id) { RegUseOrDef *list; - if (PCODE_FLAG_SET_F(Candidates[id].pcode) & (fPCodeFlag20000000 | fSideEffects)) + if (PCODE_FLAG_SET_F(Candidates[id].pcode) & (fRecordBit | fSideEffects)) return 0; for (list = Candidates[id].list; list; list = list->next) { @@ -349,7 +349,7 @@ void propagateinstructions(Object *proc, Propagation *config, int passCount, Boo } static int is_copy(PCode *pcode) { - return (pcode->flags & fPCodeFlag10) && (pcode->args[0].data.reg.reg >= n_real_registers[pcode->args[0].arg]); + return (pcode->flags & fIsMove) && (pcode->args[0].data.reg.reg >= n_real_registers[pcode->args[0].arg]); } static int copypropagatestouse(int candidateID, int useID) { @@ -368,7 +368,7 @@ static int copypropagatestouse(int candidateID, int useID) { reg1 = pcode->args[0].data.reg.reg; reg2 = pcode->args[1].data.reg.reg; - if (use->pcode->flags & fPCodeFlag10) + if (use->pcode->flags & fIsMove) return 0; if (rclass == RegClass_GPR && use->pcode->op == PC_RLWIMI && use->pcode->args[0].data.reg.reg == reg1) diff --git a/compiler_and_linker/unsorted/Exceptions.c b/compiler_and_linker/unsorted/Exceptions.c index cd25577..14627cf 100644 --- a/compiler_and_linker/unsorted/Exceptions.c +++ b/compiler_and_linker/unsorted/Exceptions.c @@ -756,7 +756,7 @@ static int mergeexceptionactions(void) { return 0; for (pca = pc_actions; pca; pca = pca->next) { - if (pca->firstInstr->block->flags & fPCBlockFlag20) + if (pca->firstInstr->block->flags & fDeleted) deleteexceptionaction(pca); } diff --git a/compiler_and_linker/unsorted/FuncLevelAsmPPC.c b/compiler_and_linker/unsorted/FuncLevelAsmPPC.c index e7fe347..6122800 100644 --- a/compiler_and_linker/unsorted/FuncLevelAsmPPC.c +++ b/compiler_and_linker/unsorted/FuncLevelAsmPPC.c @@ -85,7 +85,7 @@ void assign_local_addresses(void) { for (list = locals; list; list = list->next) { vi = CodeGen_GetNewVarInfo(); list->object->u.var.info = vi; - list->object->flags |= OBJECT_FLAGS_UNUSED; + list->object->flags |= OBJECT_FLAGS_1; vi->used = 1; } @@ -122,7 +122,7 @@ static void FuncAsm_PreScanDirectives(void) { while (tk == TK_IDENTIFIER && (directive = InlineAsm_IsDirective(AssemblerType_0))) { InlineAsm_ProcessDirective(directive); - if (tk == ';' || tk == TK_NEG7) { + if (tk == ';' || tk == TK_EOL) { CPrep_TokenStreamFlush(); tk = lex(); } else { @@ -274,7 +274,7 @@ void Assembler(Object *func) { branch_label(makepclabel()); epilogue = pclastblock; - pclastblock->flags |= fPCBlockFlag2; + pclastblock->flags |= fIsEpilogue; CheckCLabels(); if (fatalerrors) @@ -325,7 +325,7 @@ void Assembler(Object *func) { branch_label(makepclabel()); epilogue = pclastblock; - pclastblock->flags |= fPCBlockFlag2; + pclastblock->flags |= fIsEpilogue; pccomputepredecessors(); if (copts.debuglisting) diff --git a/compiler_and_linker/unsorted/GCCInlineAsm.c b/compiler_and_linker/unsorted/GCCInlineAsm.c index d0ae953..897df9b 100644 --- a/compiler_and_linker/unsorted/GCCInlineAsm.c +++ b/compiler_and_linker/unsorted/GCCInlineAsm.c @@ -31,7 +31,7 @@ void InlineAsm_SkipComment(void) { static char gcc_parse_attribute(void) { char ch; - while (tk == TK_NEG7) + while (tk == TK_EOL) tk = lex(); if (tk != '"') @@ -57,7 +57,7 @@ static void gcc_parse_name(Boolean flag, char attribute) { ENode *tempexpr; Statement *stmt; - while (tk == TK_NEG7) + while (tk == TK_EOL) tk = lex(); if (tk != '(') @@ -220,7 +220,7 @@ void InlineAsm_gcc_parse(void) { gcc_name_list_index = -1; cprep_eoltokens = 0; - if (tk == TK_NEG7) + if (tk == TK_EOL) tk = lex(); gcc_parse_output(); diff --git a/compiler_and_linker/unsorted/GenStabs.c b/compiler_and_linker/unsorted/GenStabs.c index 0563efe..4dfe371 100644 --- a/compiler_and_linker/unsorted/GenStabs.c +++ b/compiler_and_linker/unsorted/GenStabs.c @@ -709,7 +709,7 @@ static int StabTypeID(Type *type) { id = local_enum(type); break; case TYPESTRUCT: - if (IS_TYPESTRUCT_VECTOR(type)) { + if (IS_TYPESTRUCT_VECTOR(TYPE_STRUCT(type))) { switch (TYPE_STRUCT(type)->stype) { case STRUCT_TYPE_4: return StabType_VectorUChar; case STRUCT_TYPE_5: return StabType_VectorSChar; diff --git a/compiler_and_linker/unsorted/InlineAsm.c b/compiler_and_linker/unsorted/InlineAsm.c index e800327..ba6d2f2 100644 --- a/compiler_and_linker/unsorted/InlineAsm.c +++ b/compiler_and_linker/unsorted/InlineAsm.c @@ -35,7 +35,7 @@ void InlineAsm_SyntaxError(short code) { if (backtracking) longjmp(backtrack, 1); - if (tk == TK_NEG7 || tk == ';') + if (tk == TK_EOL || tk == ';') code = CErrorStr112; CError_Error(code); } @@ -357,7 +357,7 @@ HashNameNode *MakeLocalLabel(CInt64 num) { return GetHashNameNodeExport(buf); } -static void ScanOptionalLabel() { +static void ScanOptionalLabel(void) { if (tk == TK_INTCONST) { if (lookahead() == ':') { InlineAsm_DefineLabel(MakeLocalLabel(tkintconst)); @@ -385,17 +385,17 @@ static void ScanOptionalLabel() { static void ScanStatements(volatile short endToken, UInt8 mode) { if (setjmp(InlineAsm_assemblererror)) { - while (tk != TK_NEG7 && tk != endToken && tk != '}' && tk) + while (tk != TK_EOL && tk != endToken && tk != '}' && tk) tk = lex(); - if (tk == ';' || tk == TK_NEG7) + if (tk == ';' || tk == TK_EOL) tk = lex(); } else { InlineAsm_Initialize(mode); InlineAsm_gccmode = 0; if (setjmp(InlineAsm_assemblererror)) { - while (tk != ';' && tk != TK_NEG7 && tk != endToken && tk != '}' && tk) + while (tk != ';' && tk != TK_EOL && tk != endToken && tk != '}' && tk) tk = lex(); - if (tk == ';' || tk == TK_NEG7) + if (tk == ';' || tk == TK_EOL) tk = lex(); } @@ -431,7 +431,7 @@ static void ScanStatements(volatile short endToken, UInt8 mode) { InlineAsm_gcc_parse(); } - if (tk == ';' || tk == TK_NEG7) { + if (tk == ';' || tk == TK_EOL) { CPrep_TokenStreamFlush(); tk = lex(); } else if (tk != endToken) { diff --git a/compiler_and_linker/unsorted/InlineAsmPPC.c b/compiler_and_linker/unsorted/InlineAsmPPC.c index e3a5f98..834432c 100644 --- a/compiler_and_linker/unsorted/InlineAsmPPC.c +++ b/compiler_and_linker/unsorted/InlineAsmPPC.c @@ -630,7 +630,7 @@ static void memoryoperand(IAOperand *op, InlineAsm *ia, Boolean flag, short effe CError_Error(CErrorStr155); } - expr.object->flags |= OBJECT_FLAGS_UNUSED; + expr.object->flags |= OBJECT_FLAGS_1; return; } @@ -679,7 +679,7 @@ static void memoryoperand(IAOperand *op, InlineAsm *ia, Boolean flag, short effe op[0].u.obj.obj = expr.xC; op[0].u.obj.offset = expr.value; - expr.xC->flags |= OBJECT_FLAGS_UNUSED; + expr.xC->flags |= OBJECT_FLAGS_1; return; } @@ -732,7 +732,7 @@ static void registeroperand(IAOperand *op, char rclass, short effect) { op->u.reg.num = num; op->u.reg.effect = effect; if (obj) { - reg->object->flags |= OBJECT_FLAGS_UNUSED; + reg->object->flags |= OBJECT_FLAGS_1; Registers_GetVarInfo(obj)->flags |= VarInfoFlag40; } } else if (rclass == RegClass_CRFIELD) { @@ -994,11 +994,11 @@ static InlineAsm *InlineAsm_ScanAssemblyOperands(IAMnemonic *mnemonic) { info = &opcodeinfo[mnemonic->x4]; argcount = info->x8; - if (PCODE_FLAG_SET_F(info) & fPCodeFlag8000000) + if (PCODE_FLAG_SET_F(info) & fCanSetRecordBit) argcount++; - if (!(PCODE_FLAG_SET_F(info) & fPCodeFlag10000000) && (PCODE_FLAG_SET_F(info) & fPCodeFlag4000000)) + if (!(PCODE_FLAG_SET_F(info) & fSetsCarry) && (PCODE_FLAG_SET_F(info) & fCanSetCarry)) argcount++; - if (PCODE_FLAG_SET_T(info) & fPCodeFlag2000000) + if (PCODE_FLAG_SET_T(info) & fCanLink) argcount++; buffersize = sizeof(InlineAsm) + sizeof(IAOperand) * argcount; @@ -1669,7 +1669,7 @@ void InlineAsm_ProcessDirective(SInt32 directive) { CError_Error(CErrorStr166); tk = lex(); - if (tk != TK_NEG7 && tk != ';') + if (tk != TK_EOL && tk != ';') fralloc_parameter_area_size = getimmediateoperand(0x20, 0x7FFE); requires_frame = 1; @@ -1832,9 +1832,9 @@ void InlineAsm_ScanAssemblyInstruction(void) { CError_Error(CErrorStr261); info = &opcodeinfo[mnemonic->x4]; - flag3 = (FLAG_SET_F(info->flags) & fPCodeFlag4000000) && (mnemonic->x10 & 0x400); - flag4 = (FLAG_SET_T(info->flags) & fPCodeFlag20000000) && (mnemonic->x10 & 2); - flag5 = (FLAG_SET_T(info->flags) & fPCodeFlag2000000) && (mnemonic->x10 & 1); + flag3 = (FLAG_SET_F(info->flags) & fCanSetCarry) && (mnemonic->x10 & 0x400); + flag4 = (FLAG_SET_T(info->flags) & fCanBeAbsolute) && (mnemonic->x10 & 2); + flag5 = (FLAG_SET_T(info->flags) & fCanLink) && (mnemonic->x10 & 1); if ((cpu == CPUMask_Generic) && (cpu & CPUFLAG_LOW_MASK) != ((cpu & mnemonic->cpu) & CPUFLAG_LOW_MASK)) { CError_Error(CErrorStr152); @@ -1912,10 +1912,10 @@ static PCode *InlineAsm_TranslateIRtoPCodePPC(InlineAsm *ia, int argcount, Assem extra_args = 0; reg = 0; - if ((PCODE_FLAG_SET_F(info) & fPCodeFlag8000000) && !(PCODE_FLAG_SET_F(info) & fPCodeFlag20000000)) + if ((PCODE_FLAG_SET_F(info) & fCanSetRecordBit) && !(PCODE_FLAG_SET_F(info) & fRecordBit)) extra_args++; - if (!(PCODE_FLAG_SET_F(info) & fPCodeFlag10000000) && (PCODE_FLAG_SET_F(info) & fPCodeFlag4000000)) + if (!(PCODE_FLAG_SET_F(info) & fSetsCarry) && (PCODE_FLAG_SET_F(info) & fCanSetCarry)) extra_args++; if (argcount < ia->argcount) { @@ -1976,8 +1976,8 @@ static PCode *InlineAsm_TranslateIRtoPCodePPC(InlineAsm *ia, int argcount, Assem case IAOpnd_Imm: dest->kind = PCOp_IMMEDIATE; dest->data.imm.value = src->u.imm.value; - if (pc->flags & (fPCodeFlag2 | fPCodeFlag4)) - pc->flags |= fPCodeFlag20; + if (pc->flags & (fIsRead | fIsWrite)) + pc->flags |= fIsPtrOp; dest->data.imm.obj = NULL; break; @@ -2062,7 +2062,7 @@ static PCode *InlineAsm_TranslateIRtoPCodePPC(InlineAsm *ia, int argcount, Assem dest->arg = src->u.obj.unk; dest->data.mem.obj = src->u.obj.obj; dest->data.mem.offset = src->u.obj.offset; - if (pc->flags & (fPCodeFlag2 | fPCodeFlag4 | fPCodeFlag20000 | fPCodeFlag40000)) { + if (pc->flags & (fIsRead | fIsWrite | fPCodeFlag20000 | fPCodeFlag40000)) { pc->alias = make_alias(dest->data.mem.obj, dest->data.mem.offset, nbytes_loaded_or_stored_by(pc)); if (is_volatile_object(dest->data.mem.obj)) pc->flags |= fIsVolatile; @@ -2076,8 +2076,8 @@ static PCode *InlineAsm_TranslateIRtoPCodePPC(InlineAsm *ia, int argcount, Assem src->u.labdiff.label1->pclabel = makepclabel(); if (src->u.labdiff.label2->pclabel == NULL) src->u.labdiff.label2->pclabel = makepclabel(); - if (pc->flags & (fPCodeFlag2 | fPCodeFlag4)) - pc->flags |= fPCodeFlag20; + if (pc->flags & (fIsRead | fIsWrite)) + pc->flags |= fIsPtrOp; dest->kind = PCOp_LABELDIFF; dest->data.labeldiff.labelA = src->u.labdiff.label1->pclabel; dest->data.labeldiff.labelB = src->u.labdiff.label2->pclabel; @@ -2127,21 +2127,21 @@ void InlineAsm_TranslateIRtoPCode(Statement *stmt) { setpcodeflags(fSideEffects); if (ia->flags2 & IAFlagsB_1) { - if (PCODE_FLAG_SET_F(pc) & fPCodeFlag8000000) + if (PCODE_FLAG_SET_F(pc) & fCanSetRecordBit) pcsetrecordbit(pclastblock->lastPCode); else CError_Error(CErrorStr261); } if (ia->flags2 & IAFlagsB_2) { - if (PCODE_FLAG_SET_F(pc) & fPCodeFlag4000000) + if (PCODE_FLAG_SET_F(pc) & fCanSetCarry) setpcodeflags(fOverflow); // idk? else CError_Error(CErrorStr261); } if (ia->flags2 & IAFlagsB_4) { - if (PCODE_FLAG_SET_T(pc) & fPCodeFlag20000000) { + if (PCODE_FLAG_SET_T(pc) & fCanBeAbsolute) { int i; for (i = 0; i < pc->argCount; i++) { if (pc->args[i].kind == PCOp_LABEL || pc->args[i].kind == PCOp_MEMORY) { @@ -2149,18 +2149,18 @@ void InlineAsm_TranslateIRtoPCode(Statement *stmt) { break; } } - setpcodeflags(fAbsolute); // idk? + setpcodeflags(fAbsolute); } else { CError_Error(CErrorStr261); } } if (ia->flags2 & IAFlagsB_8) { - if (PCODE_FLAG_SET_T(pc) & fPCodeFlag2000000) { + if (PCODE_FLAG_SET_T(pc) & fCanLink) { pcsetlinkbit(pclastblock->lastPCode); if (!(ia->flags & IAFlag2)) { - pclastblock->lastPCode->flags &= ~fPCodeFlag8; - pclastblock->lastPCode->flags |= fPCodeFlag1; + pclastblock->lastPCode->flags &= ~fIsCall; + pclastblock->lastPCode->flags |= fIsBranch; } makes_call = 1; } else { @@ -2169,9 +2169,9 @@ void InlineAsm_TranslateIRtoPCode(Statement *stmt) { } if (ia->flags2 & IAFlagsB_10) - setpcodeflags(fPCodeFlag8000000); + setpcodeflags(fCanSetRecordBit); if (ia->flags2 & IAFlagsB_20) - setpcodeflags(fPCodeFlag4000000); + setpcodeflags(fCanSetCarry); if (OPCODE_PART_1(opcodeinfo[pc->op].insn) == 16) { PCodeLabel *dest = NULL; @@ -2260,7 +2260,7 @@ static void savepicbase(short reg, HashNameNode *name) { } static SInt32 InlineAsm_OpcodeSize(InlineAsm *ia) { - if (opcodeinfo[ia->opcode].flags & (fPCodeFlag2 | fPCodeFlag4)) { + if (opcodeinfo[ia->opcode].flags & (fIsRead | fIsWrite)) { switch (ia->opcode) { case PC_LBZ: case PC_LBZU: @@ -2353,11 +2353,11 @@ static SInt32 InlineAsm_OpcodeSize(InlineAsm *ia) { CError_FATAL(3924); } } else { - if (opcodeinfo[ia->opcode].flags & fPCodeFlag80000000) + if (opcodeinfo[ia->opcode].flags & fOpTypeGPR) return 4; - if (opcodeinfo[ia->opcode].flags & fPCodeFlag40000000) + if (opcodeinfo[ia->opcode].flags & fOpTypeFPR) return 8; - if (opcodeinfo[ia->opcode].flags & (fPCodeFlag80000000 | fPCodeFlag40000000)) + if (opcodeinfo[ia->opcode].flags & fOpTypeVR) return 16; if (opcodeinfo[ia->opcode].flags & fSideEffects) { @@ -2395,17 +2395,17 @@ void CodeGen_GetAsmEffects(Statement *stmt, IAEffects *effects) { effects->x0 = 0; effects->x5 = 0; - if (info->flags & fPCodeFlag20) { - if (info->flags & fPCodeFlag2) + if (info->flags & fIsPtrOp) { + if (info->flags & fIsRead) effects->x1 = 1; - if (info->flags & fPCodeFlag4) + if (info->flags & fIsWrite) effects->x2 = 1; } - if (PCODE_FLAG_SET_T(info) & fPCodeFlag2000000) { + if (PCODE_FLAG_SET_T(info) & fCanLink) { if (ia->flags2 & IAFlagsB_8) effects->x4 = 1; - else if ((info->flags & fPCodeFlag8) || (info->flags & fPCodeFlag4)) + else if ((info->flags & fIsCall) || (info->flags & fIsWrite)) effects->x3 = 1; if (ia->opcode == PC_B) { @@ -2450,13 +2450,13 @@ void CodeGen_GetAsmEffects(Statement *stmt, IAEffects *effects) { case IAOpnd_3: case IAOpnd_4: if (op->u.obj.obj) { - if (info->flags & fPCodeFlag2) { + if (info->flags & fIsRead) { effects->operands[effects->numoperands].type = IAEffect_0; effects->operands[effects->numoperands].object = op->u.obj.obj; effects->operands[effects->numoperands].offset = op->u.obj.offset; effects->operands[effects->numoperands].size = InlineAsm_OpcodeSize(ia); effects->numoperands++; - } else if (!(info->flags & (fPCodeFlag1 | fPCodeFlag8))) { + } else if (!(info->flags & (fIsBranch | fIsCall))) { effects->operands[effects->numoperands].type = IAEffect_3; effects->operands[effects->numoperands].object = op->u.obj.obj; effects->operands[effects->numoperands].offset = op->u.obj.offset; @@ -2510,7 +2510,7 @@ void CodeGen_GetAsmEffects(Statement *stmt, IAEffects *effects) { case IAOpnd_3: case IAOpnd_4: if (op->u.obj.obj) { - if (info->flags & fPCodeFlag4) { + if (info->flags & fIsWrite) { effects->operands[effects->numoperands].type = IAEffect_1; effects->operands[effects->numoperands].object = op->u.obj.obj; effects->operands[effects->numoperands].offset = op->u.obj.offset; @@ -2524,7 +2524,7 @@ void CodeGen_GetAsmEffects(Statement *stmt, IAEffects *effects) { CError_ASSERT(4151, (UInt32) effects->numoperands <= IAMaxOperands); } - if ((info->flags & (fPCodeFlag1 | fPCodeFlag8)) && (SInt32)effects->numlabels == 0) + if ((info->flags & (fIsBranch | fIsCall)) && (SInt32)effects->numlabels == 0) effects->x3 = 1; } @@ -2556,7 +2556,7 @@ void CodeGen_PropagateIntoAsm(Statement *stmt, Object *obj, ENode *expr) { break; case IAOpnd_3: case IAOpnd_4: - if (!(opcodeinfo[ia->opcode].flags & (fPCodeFlag4 | fPCodeFlag40000)) && + if (!(opcodeinfo[ia->opcode].flags & (fIsWrite | fPCodeFlag40000)) && ia->args[i].u.obj.obj == obj) ia->args[i].u.obj.obj = newobj; break; diff --git a/compiler_and_linker/unsorted/InlineAsmRegisters.c b/compiler_and_linker/unsorted/InlineAsmRegisters.c index 8dfba1e..251c345 100644 --- a/compiler_and_linker/unsorted/InlineAsmRegisters.c +++ b/compiler_and_linker/unsorted/InlineAsmRegisters.c @@ -14,7 +14,7 @@ typedef struct HashedRegister { static HashedRegister *hashedregisters[64]; -void InlineAsm_InitializeRegisters() { +void InlineAsm_InitializeRegisters(void) { SInt32 i; for (i = 0; i < 64; i++) diff --git a/compiler_and_linker/unsorted/InstrSelection.c b/compiler_and_linker/unsorted/InstrSelection.c index 1916711..0ea8bf9 100644 --- a/compiler_and_linker/unsorted/InstrSelection.c +++ b/compiler_and_linker/unsorted/InstrSelection.c @@ -139,7 +139,7 @@ void gen_POSTINCDEC(ENode *expr, short outputReg, short outputRegHi, Operand *ou output->reg = (outputReg && outputReg != objReg) ? outputReg : ALLOC_FPR(); emitpcode(PC_FMR, output->reg, objReg); fval = one_point_zero; - load_floating_constant(constReg = ALLOC_FPR(), type, &fval.value); + load_floating_constant(constReg = ALLOC_FPR(), type, &fval); if (ENODE_IS(expr, EPOSTINC)) { emitpcode((type->size == 4) ? PC_FADDS : PC_FADD, objReg, objReg, constReg); @@ -157,7 +157,7 @@ void gen_POSTINCDEC(ENode *expr, short outputReg, short outputRegHi, Operand *ou emitpcode(PC_FMR, output->reg, b.reg); fval = one_point_zero; - load_floating_constant(constReg = ALLOC_FPR(), type, &fval.value); + load_floating_constant(constReg = ALLOC_FPR(), type, &fval); finalReg = ALLOC_FPR(); if (ENODE_IS(expr, EPOSTINC)) @@ -2907,351 +2907,340 @@ void gen_condition(ENode *cond, Operand *output) { void gen_condition_gpr(ENode *cond, Operand *output, short outputReg) { ENode *left; ENode *right; - Operand op1; + Operand condOp; + int finalReg; int tmpReg; - int reg; + int tmpReg2; + int tmpReg3; + int tmpReg4; int a; int b; left = cond->data.diadic.left; right = cond->data.diadic.right; - memclrw(&op1, sizeof(Operand)); + memclrw(&condOp, sizeof(Operand)); if (!IS_TYPE_FLOAT(left->rtype)) { + Operand op1; Operand op2; - Operand op3; - Operand op4; + Operand opTmp; + memclrw(&op1, sizeof(Operand)); memclrw(&op2, sizeof(Operand)); - memclrw(&op3, sizeof(Operand)); - memclrw(&op4, sizeof(Operand)); + memclrw(&opTmp, sizeof(Operand)); if (right->hascall) { - GEN_NODE(right, &op3); + GEN_NODE(right, &op2); if (!IS_INT_CONST_ZERO(right)) { if (right->rtype->size < 4) - extend32(&op3, right->rtype, 0); - ENSURE_GPR(&op3, right->rtype, 0); + extend32(&op2, right->rtype, 0); + ENSURE_GPR(&op2, right->rtype, 0); } - GEN_NODE(left, &op2); + GEN_NODE(left, &op1); if (left->rtype->size < 4) - extend32(&op2, left->rtype, 0); - ENSURE_GPR(&op2, left->rtype, 0); + extend32(&op1, left->rtype, 0); + ENSURE_GPR(&op1, left->rtype, 0); } else { - GEN_NODE(left, &op2); - ENSURE_GPR(&op2, left->rtype, 0); + GEN_NODE(left, &op1); + ENSURE_GPR(&op1, left->rtype, 0); if (left->rtype->size < 4) - extend32(&op2, left->rtype, 0); + extend32(&op1, left->rtype, 0); - GEN_NODE(right, &op3); + GEN_NODE(right, &op2); if (!IS_INT_CONST_ZERO(right)) { if (right->rtype->size < 4) - extend32(&op3, right->rtype, 0); - ENSURE_GPR(&op3, right->rtype, 0); + extend32(&op2, right->rtype, 0); + ENSURE_GPR(&op2, right->rtype, 0); } } switch (cond->type) { case EEQU: if ( - copts.peephole && - IS_INT_CONST(right) && - pclastblock->pcodeCount > 0) { + copts.peephole && + IS_INT_CONST(right) && + pclastblock->pcodeCount > 0 && + pclastblock->lastPCode->op == PC_RLWINM && + pclastblock->lastPCode->args[0].data.reg.reg == op1.reg + ) + { PCode *pc = pclastblock->lastPCode; - if (pc->op == PC_RLWINM && pc->args[0].data.reg.reg == op2.reg) { - SInt32 r6 = pc->args[2].data.imm.value; - SInt32 r7 = pc->args[3].data.imm.value; - SInt32 r3 = right->data.intval.lo; - if (r7 == pc->args[4].data.imm.value) { - reg = outputReg ? outputReg : ALLOC_GPR(); - if (r3 != (r3 & 1)) { - emitpcode(PC_LI, reg, 0); - } else if (r3 == 0) { - int tmpreg = ALLOC_GPR(); - emitpcode( - PC_RLWINM, tmpreg, - pc->args[1].data.reg.reg, - (r6 + r7 + 1) & 31, 31, 31); - emitpcode(PC_XORI, reg, tmpreg, 1); - } else if (r3 == 1) { - emitpcode( - PC_RLWINM, reg, - pc->args[1].data.reg.reg, - (r6 + r7 + 1) & 31, 31, 31); - } else { - CError_FATAL(5434); - } - output->optype = OpndType_GPR; - output->reg = reg; - return; + SInt32 a = pc->args[2].data.imm.value; + SInt32 b = pc->args[3].data.imm.value; + SInt32 value = right->data.intval.lo; + if (b == pc->args[4].data.imm.value) { + finalReg = outputReg ? outputReg : ALLOC_GPR(); + + if (value != (value & 1)) { + emitpcode(PC_LI, finalReg, 0); + } else if (value == 0) { + tmpReg = ALLOC_GPR(); + emitpcode( + PC_RLWINM, tmpReg, + pc->args[1].data.reg.reg, + (a + b + 1) & 31, 31, 31); + emitpcode(PC_XORI, finalReg, tmpReg, 1); + } else if (value == 1) { + emitpcode( + PC_RLWINM, finalReg, + pc->args[1].data.reg.reg, + (a + b + 1) & 31, 31, 31); + } else { + CError_FATAL(5434); } + output->optype = OpndType_GPR; + output->reg = finalReg; + return; } } if (IS_INT_CONST_ZERO(right)) { - //int tmpReg = ALLOC_GPR(); // affected - int tmpReg; - int t = used_virtual_registers[RegClass_GPR]; - used_virtual_registers[RegClass_GPR]++; - emitpcode(PC_CNTLZW, t, op2.reg, 0); - tmpReg = t; - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_RLWINM, reg, tmpReg, 27, 5, 31); + tmpReg = ALLOC_GPR(); + emitpcode(PC_CNTLZW, tmpReg, op1.reg, 0); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_RLWINM, finalReg, tmpReg, 27, 5, 31); output->optype = OpndType_GPR; - output->reg = reg; + output->reg = finalReg; return; } else { - int tmpReg, tmpReg2; - tmpReg = ALLOC_GPR(); // affected - emitpcode(PC_SUBF, tmpReg, op2.reg, op3.reg); + tmpReg = ALLOC_GPR(); + emitpcode(PC_SUBF, tmpReg, op1.reg, op2.reg); tmpReg2 = ALLOC_GPR(); emitpcode(PC_CNTLZW, tmpReg2, tmpReg); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_RLWINM, reg, tmpReg2, 27, 5, 31); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_RLWINM, finalReg, tmpReg2, 27, 5, 31); output->optype = OpndType_GPR; - output->reg = reg; + output->reg = finalReg; return; } case ENOTEQU: if ( - copts.peephole && - IS_INT_CONST(right) && - pclastblock->pcodeCount > 0) { + copts.peephole && + IS_INT_CONST(right) && + pclastblock->pcodeCount > 0 && + pclastblock->lastPCode->op == PC_RLWINM && + pclastblock->lastPCode->args[0].data.reg.reg == op1.reg + ) + { PCode *pc = pclastblock->lastPCode; - if (pc->op == PC_RLWINM && pc->args[0].data.reg.reg == op2.reg) { - SInt32 r6 = pc->args[2].data.imm.value; - SInt32 r7 = pc->args[3].data.imm.value; - SInt32 r3 = right->data.intval.lo; - if (r7 == pc->args[4].data.imm.value) { - reg = outputReg ? outputReg : ALLOC_GPR(); - if (r3 != (r3 & 1)) { - emitpcode(PC_LI, reg, 1); - } else if (r3 == 0) { - emitpcode( - PC_RLWINM, reg, - pc->args[1].data.reg.reg, - (r6 + r7 + 1) & 31, 31, 31); - } else if (r3 == 1) { - int tmpreg = ALLOC_GPR(); // affected - emitpcode( - PC_RLWINM, tmpreg, - pc->args[1].data.reg.reg, - (r6 + r7 + 1) & 31, 31, 31); - emitpcode(PC_XORI, reg, tmpreg, 1); - } else { - CError_FATAL(5503); - } - output->optype = OpndType_GPR; - output->reg = reg; - return; + SInt32 a = pc->args[2].data.imm.value; + SInt32 b = pc->args[3].data.imm.value; + SInt32 value = right->data.intval.lo; + if (b == pc->args[4].data.imm.value) { + finalReg = outputReg ? outputReg : ALLOC_GPR(); + + if (value != (value & 1)) { + emitpcode(PC_LI, finalReg, 1); + } else if (value == 0) { + emitpcode( + PC_RLWINM, finalReg, + pc->args[1].data.reg.reg, + (a + b + 1) & 31, 31, 31); + } else if (value == 1) { + tmpReg = ALLOC_GPR(); + emitpcode( + PC_RLWINM, tmpReg, + pc->args[1].data.reg.reg, + (a + b + 1) & 31, 31, 31); + emitpcode(PC_XORI, finalReg, tmpReg, 1); + } else { + CError_FATAL(5503); } + output->optype = OpndType_GPR; + output->reg = finalReg; + return; } } if (IS_INT_CONST_ZERO(right)) { if (copts.optimize_for_size) { - int tmpReg; - tmpReg = ALLOC_GPR(); // affected - emitpcode(PC_ADDIC, tmpReg, op2.reg, -1); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_SUBFE, reg, tmpReg, op2.reg); - } else { - int tmpReg, tmpReg2; - // tmpReg, tmpReg2 swap - tmpReg = ALLOC_GPR(); - emitpcode(PC_NEG, tmpReg, op2.reg); - tmpReg2 = ALLOC_GPR(); - emitpcode(PC_OR, tmpReg2, tmpReg, op2.reg); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_RLWINM, reg, tmpReg2, 1, 31, 31); - } - output->optype = OpndType_GPR; - output->reg = reg; - return; - } else { - if (copts.optimize_for_size) { - int tmpReg, tmpReg2; - // tmpReg, tmpReg2 swap tmpReg = ALLOC_GPR(); - emitpcode(PC_SUBF, tmpReg, op2.reg, op3.reg); - tmpReg2 = ALLOC_GPR(); - emitpcode(PC_ADDIC, tmpReg2, tmpReg, -1); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_SUBFE, reg, tmpReg2, tmpReg); + emitpcode(PC_ADDIC, tmpReg, op1.reg, -1); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SUBFE, finalReg, tmpReg, op1.reg); } else { - int tmpReg, tmpReg2, tmpReg3; - // tmpReg, tmpReg2 swap tmpReg = ALLOC_GPR(); - emitpcode(PC_SUBF, tmpReg, op2.reg, op3.reg); + emitpcode(PC_NEG, tmpReg, op1.reg); tmpReg2 = ALLOC_GPR(); - emitpcode(PC_SUBF, tmpReg2, op3.reg, op2.reg); - tmpReg3 = ALLOC_GPR(); - emitpcode(PC_OR, tmpReg3, tmpReg, tmpReg2); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_RLWINM, reg, tmpReg3, 1, 31, 31); + emitpcode(PC_OR, tmpReg2, tmpReg, op1.reg); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_RLWINM, finalReg, tmpReg2, 1, 31, 31); } output->optype = OpndType_GPR; - output->reg = reg; + output->reg = finalReg; return; } + if (copts.optimize_for_size) { + tmpReg = ALLOC_GPR(); + emitpcode(PC_SUBF, tmpReg, op1.reg, op2.reg); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_ADDIC, tmpReg2, tmpReg, -1); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SUBFE, finalReg, tmpReg2, tmpReg); + } else { + tmpReg = ALLOC_GPR(); + emitpcode(PC_SUBF, tmpReg, op1.reg, op2.reg); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_SUBF, tmpReg2, op2.reg, op1.reg); + tmpReg3 = ALLOC_GPR(); + emitpcode(PC_OR, tmpReg3, tmpReg, tmpReg2); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_RLWINM, finalReg, tmpReg3, 1, 31, 31); + } + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + case EGREATEREQU: if (!is_unsigned(left->rtype) && IS_INT_CONST_ZERO(right)) { - int tmpReg; tmpReg = ALLOC_GPR(); - emitpcode(PC_RLWINM, tmpReg, op2.reg, 1, 31, 31); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_XORI, reg, tmpReg, 1); + emitpcode(PC_RLWINM, tmpReg, op1.reg, 1, 31, 31); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_XORI, finalReg, tmpReg, 1); output->optype = OpndType_GPR; - output->reg = reg; + output->reg = finalReg; return; } - op4 = op3; - op3 = op2; - op2 = op4; + opTmp = op2; + op2 = op1; + op1 = opTmp; + case ELESSEQU: if (is_unsigned(left->rtype)) { if (copts.optimize_for_size) { - int tmpReg, tmpReg2; tmpReg = ALLOC_GPR(); emitpcode(PC_LI, tmpReg, -1); tmpReg2 = ALLOC_GPR(); - emitpcode(PC_SUBFC, tmpReg2, op2.reg, op3.reg); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_SUBFZE, reg, tmpReg); + emitpcode(PC_SUBFC, tmpReg2, op1.reg, op2.reg); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SUBFZE, finalReg, tmpReg); } else { - int tmpReg, tmpReg2, tmpReg3, tmpReg4; tmpReg = ALLOC_GPR(); - emitpcode(PC_SUBF, tmpReg, op2.reg, op3.reg); + emitpcode(PC_SUBF, tmpReg, op1.reg, op2.reg); tmpReg2 = ALLOC_GPR(); - emitpcode(PC_ORC, tmpReg2, op3.reg, op2.reg); + emitpcode(PC_ORC, tmpReg2, op2.reg, op1.reg); tmpReg3 = ALLOC_GPR(); emitpcode(PC_RLWINM, tmpReg3, tmpReg, 31, 1, 31); tmpReg4 = ALLOC_GPR(); emitpcode(PC_SUBF, tmpReg4, tmpReg3, tmpReg2); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_RLWINM, reg, tmpReg4, 1, 31, 31); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_RLWINM, finalReg, tmpReg4, 1, 31, 31); } output->optype = OpndType_GPR; - output->reg = reg; + output->reg = finalReg; return; } if (IS_INT_CONST_ZERO(right)) { - int tmpReg, tmpReg2; tmpReg = ALLOC_GPR(); emitpcode(PC_LI, tmpReg, 1); tmpReg2 = ALLOC_GPR(); - emitpcode(PC_CNTLZW, tmpReg2, op2.reg); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_RLWNM, reg, tmpReg, tmpReg2, 31, 31); - output->optype = OpndType_GPR; - output->reg = reg; - return; - } else { - int tmpReg, tmpReg2, tmpReg3; - tmpReg2 = ALLOC_GPR(); - emitpcode(PC_SRAWI, tmpReg2, op3.reg, 31); - tmpReg = ALLOC_GPR(); - emitpcode(PC_RLWINM, tmpReg, op2.reg, 1, 31, 31); - tmpReg3 = ALLOC_GPR(); - emitpcode(PC_SUBFC, tmpReg3, op2.reg, op3.reg); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_ADDE, reg, tmpReg2, tmpReg); + emitpcode(PC_CNTLZW, tmpReg2, op1.reg); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_RLWNM, finalReg, tmpReg, tmpReg2, 31, 31); output->optype = OpndType_GPR; - output->reg = reg; + output->reg = finalReg; return; } + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_SRAWI, tmpReg2, op2.reg, 31); + tmpReg = ALLOC_GPR(); + emitpcode(PC_RLWINM, tmpReg, op1.reg, 1, 31, 31); + tmpReg3 = ALLOC_GPR(); + emitpcode(PC_SUBFC, tmpReg3, op1.reg, op2.reg); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_ADDE, finalReg, tmpReg2, tmpReg); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + case EGREATER: if (!is_unsigned(left->rtype) && IS_INT_CONST_ZERO(right)) { - int tmpReg, tmpReg2; tmpReg = ALLOC_GPR(); - emitpcode(PC_NEG, tmpReg, op2.reg); + emitpcode(PC_NEG, tmpReg, op1.reg); tmpReg2 = ALLOC_GPR(); - emitpcode(PC_ANDC, tmpReg2, tmpReg, op2.reg); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_RLWINM, reg, tmpReg2, 1, 31, 31); + emitpcode(PC_ANDC, tmpReg2, tmpReg, op1.reg); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_RLWINM, finalReg, tmpReg2, 1, 31, 31); output->optype = OpndType_GPR; - output->reg = reg; + output->reg = finalReg; return; } - op4 = op3; - op3 = op2; - op2 = op4; + opTmp = op2; + op2 = op1; + op1 = opTmp; + case ELESS: if (is_unsigned(left->rtype)) { if (left->rtype->size <= 2) { - int tmpReg; tmpReg = ALLOC_GPR(); - emitpcode(PC_SUBF, tmpReg, op3.reg, op2.reg); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_RLWINM, reg, tmpReg, 1, 31, 31); + emitpcode(PC_SUBF, tmpReg, op2.reg, op1.reg); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_RLWINM, finalReg, tmpReg, 1, 31, 31); output->optype = OpndType_GPR; - output->reg = reg; + output->reg = finalReg; } else { if (copts.optimize_for_size) { - int tmpReg, tmpReg2; tmpReg = ALLOC_GPR(); - emitpcode(PC_SUBFC, tmpReg, op3.reg, op2.reg); + emitpcode(PC_SUBFC, tmpReg, op2.reg, op1.reg); tmpReg2 = ALLOC_GPR(); emitpcode(PC_SUBFE, tmpReg2, tmpReg, tmpReg); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_NEG, reg, tmpReg2); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_NEG, finalReg, tmpReg2); } else { - int tmpReg, tmpReg2, tmpReg3; tmpReg = ALLOC_GPR(); - emitpcode(PC_XOR, tmpReg, op3.reg, op2.reg); + emitpcode(PC_XOR, tmpReg, op2.reg, op1.reg); tmpReg2 = ALLOC_GPR(); emitpcode(PC_CNTLZW, tmpReg2, tmpReg); tmpReg3 = ALLOC_GPR(); - emitpcode(PC_SLW, tmpReg3, op3.reg, tmpReg2); - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_RLWINM, reg, tmpReg3, 1, 31, 31); + emitpcode(PC_SLW, tmpReg3, op2.reg, tmpReg2); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_RLWINM, finalReg, tmpReg3, 1, 31, 31); } output->optype = OpndType_GPR; - output->reg = reg; + output->reg = finalReg; return; } return; - } else { - if (IS_INT_CONST_ZERO(right)) { - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_RLWINM, reg, op2.reg, 1, 31, 31); - output->optype = OpndType_GPR; - output->reg = reg; - return; - } else { - int tmpReg, tmpReg2, tmpReg3, tmpReg4; - tmpReg = ALLOC_GPR(); - emitpcode(PC_XOR, tmpReg, op3.reg, op2.reg); - tmpReg2 = ALLOC_GPR(); - emitpcode(PC_SRAWI, tmpReg2, tmpReg, 1); - tmpReg3 = ALLOC_GPR(); - emitpcode(PC_AND, tmpReg3, tmpReg, op3.reg); - tmpReg4 = ALLOC_GPR(); - emitpcode(PC_SUBF, tmpReg4, tmpReg3, tmpReg2); + } - reg = outputReg ? outputReg : ALLOC_GPR(); - emitpcode(PC_RLWINM, reg, tmpReg4, 1, 31, 31); - output->optype = OpndType_GPR; - output->reg = reg; - return; - } + if (IS_INT_CONST_ZERO(right)) { + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_RLWINM, finalReg, op1.reg, 1, 31, 31); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; } + tmpReg = ALLOC_GPR(); + emitpcode(PC_XOR, tmpReg, op2.reg, op1.reg); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_SRAWI, tmpReg2, tmpReg, 1); + tmpReg3 = ALLOC_GPR(); + emitpcode(PC_AND, tmpReg3, tmpReg, op2.reg); + tmpReg4 = ALLOC_GPR(); + emitpcode(PC_SUBF, tmpReg4, tmpReg3, tmpReg2); + + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_RLWINM, finalReg, tmpReg4, 1, 31, 31); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + default: CError_FATAL(5777); } } - gen_condition(cond, &op1); + gen_condition(cond, &condOp); emitpcode(PC_MFCR, tmpReg = used_virtual_registers[RegClass_GPR]++); a = 0; - b = op1.reg * 4; - switch (op1.regOffset) { + b = condOp.reg * 4; + switch (condOp.regOffset) { case ENOTEQU: a = 1; case EEQU: @@ -3267,18 +3256,349 @@ void gen_condition_gpr(ENode *cond, Operand *output, short outputReg) { break; } - reg = outputReg ? outputReg : ALLOC_GPR(); + finalReg = outputReg ? outputReg : ALLOC_GPR(); if (a) { emitpcode(PC_RLWINM, tmpReg, tmpReg, b + 1, 31, 31); - emitpcode(PC_XORI, reg, tmpReg, 1); + emitpcode(PC_XORI, finalReg, tmpReg, 1); } else { - emitpcode(PC_RLWINM, reg, tmpReg, b + 1, 31, 31); + emitpcode(PC_RLWINM, finalReg, tmpReg, b + 1, 31, 31); } output->optype = OpndType_GPR; - output->reg = reg; + output->reg = finalReg; } void gen_negated_condition_gpr(ENode *cond, Operand *output, short outputReg) { + ENode *left; + ENode *right; + Operand op1; + Operand op2; + Operand opTmp; + int finalReg; + int tmpReg; + int tmpReg2; + int tmpReg3; + + left = cond->data.diadic.left; + right = cond->data.diadic.right; + CError_ASSERT(5843, TYPE_FITS_IN_REGISTER(left->rtype) && TYPE_FITS_IN_REGISTER(right->rtype)); + + memclrw(&op1, sizeof(Operand)); + memclrw(&op2, sizeof(Operand)); + memclrw(&opTmp, sizeof(Operand)); + + if (right->hascall) { + GEN_NODE(right, &op2); + if (!IS_INT_CONST_ZERO(right)) { + if (right->rtype->size < 4) + extend32(&op2, right->rtype, 0); + ENSURE_GPR(&op2, right->rtype, 0); + } + + GEN_NODE(left, &op1); + if (left->rtype->size < 4) + extend32(&op1, left->rtype, 0); + ENSURE_GPR(&op1, left->rtype, 0); + } else { + GEN_NODE(left, &op1); + ENSURE_GPR(&op1, left->rtype, 0); + if (left->rtype->size < 4) + extend32(&op1, left->rtype, 0); + + GEN_NODE(right, &op2); + if (!IS_INT_CONST_ZERO(right)) { + if (right->rtype->size < 4) + extend32(&op2, right->rtype, 0); + ENSURE_GPR(&op2, right->rtype, 0); + } + } + + switch (cond->type) { + case EEQU: + if ( + copts.peephole && + IS_INT_CONST(right) && + pclastblock->pcodeCount > 0 && + pclastblock->lastPCode->op == PC_RLWINM && + pclastblock->lastPCode->args[0].data.reg.reg == op1.reg + ) + { + PCode *pc = pclastblock->lastPCode; + SInt32 a = pc->args[2].data.imm.value; + SInt32 b = pc->args[3].data.imm.value; + SInt32 value = right->data.intval.lo; + if (b == pc->args[4].data.imm.value) { + finalReg = outputReg ? outputReg : ALLOC_GPR(); + + if (value != (value & 1)) { + emitpcode(PC_LI, finalReg, 0); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + } + + if (value == 0) { + tmpReg = ALLOC_GPR(); + emitpcode( + PC_RLWINM, tmpReg, + pc->args[1].data.reg.reg, + (a + b + 1) & 31, 31, 31); + emitpcode(PC_ADDI, finalReg, tmpReg, 0, -1); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + } + + if (value == 1) { + tmpReg = ALLOC_GPR(); + emitpcode( + PC_RLWINM, + tmpReg, + pc->args[1].data.reg.reg, + (a + b + 1) & 31, + 31, + 31); + emitpcode(PC_NEG, finalReg, tmpReg); + output->optype = OpndType_GPR; + output->reg = tmpReg; // bug??? + return; + } + + CError_FATAL(5923); + } + } + + if (IS_INT_CONST_ZERO(right)) { + if (copts.optimize_for_size) { + tmpReg = ALLOC_GPR(); + emitpcode(PC_ADDIC, tmpReg, op1.reg, -1); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SUBFE, finalReg, tmpReg, tmpReg); + } else { + tmpReg = ALLOC_GPR(); + emitpcode(PC_CNTLZW, tmpReg, op1.reg); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_RLWINM, tmpReg2, tmpReg, 27, 31, 31); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_NEG, finalReg, tmpReg2); + } + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + } + + if (copts.optimize_for_size) { + tmpReg = ALLOC_GPR(); + emitpcode(PC_SUBF, tmpReg, op2.reg, op1.reg); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_ADDIC, tmpReg2, tmpReg, -1); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SUBFE, finalReg, tmpReg2, tmpReg2); + } else { + tmpReg = ALLOC_GPR(); + emitpcode(PC_SUBF, tmpReg, op2.reg, op1.reg); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_SUBF, tmpReg2, op1.reg, op2.reg); + tmpReg3 = ALLOC_GPR(); + emitpcode(PC_NOR, tmpReg3, tmpReg, tmpReg2); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SRAWI, finalReg, tmpReg3, 31); + } + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + + case ENOTEQU: + if ( + copts.peephole && + IS_INT_CONST(right) && + pclastblock->pcodeCount > 0 && + pclastblock->lastPCode->op == PC_RLWINM && + pclastblock->lastPCode->args[0].data.reg.reg == op1.reg + ) + { + PCode *pc = pclastblock->lastPCode; + SInt32 a = pc->args[2].data.imm.value; + SInt32 b = pc->args[3].data.imm.value; + SInt32 value = right->data.intval.lo; + if (b == pc->args[4].data.imm.value) { + finalReg = outputReg ? outputReg : ALLOC_GPR(); + + if (value != (value & 1)) { + emitpcode(PC_LI, finalReg, -1); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + } + + if (value == 0) { + tmpReg = ALLOC_GPR(); + emitpcode( + PC_RLWINM, tmpReg, + pc->args[1].data.reg.reg, + (a + b + 1) & 31, 31, 31); + emitpcode(PC_NEG, finalReg, tmpReg); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + } + + if (value == 1) { + tmpReg = ALLOC_GPR(); + emitpcode( + PC_RLWINM, tmpReg, + pc->args[1].data.reg.reg, + (a + b + 1) & 31, 31, 31); + emitpcode(PC_ADDI, finalReg, tmpReg, 0, -1); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + } + + CError_FATAL(6031); + } + } + + if (IS_INT_CONST_ZERO(right)) { + if (copts.optimize_for_size) { + tmpReg = ALLOC_GPR(); + emitpcode(PC_SUBFIC, tmpReg, op1.reg, 0); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SUBFE, finalReg, tmpReg, tmpReg); + } else { + tmpReg = ALLOC_GPR(); + emitpcode(PC_NEG, tmpReg, op1.reg); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_OR, tmpReg2, tmpReg, op1.reg); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SRAWI, finalReg, tmpReg2, 31); + } + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + } + + if (copts.optimize_for_size) { + tmpReg = ALLOC_GPR(); + emitpcode(PC_SUBF, tmpReg, op2.reg, op1.reg); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_SUBFIC, tmpReg2, tmpReg, 0); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SUBFE, finalReg, tmpReg2, tmpReg2); + } else { + tmpReg = ALLOC_GPR(); + emitpcode(PC_SUBF, tmpReg, op2.reg, op1.reg); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_SUBF, tmpReg2, op1.reg, op2.reg); + tmpReg3 = ALLOC_GPR(); + emitpcode(PC_OR, tmpReg3, tmpReg, tmpReg2); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SRAWI, finalReg, tmpReg3, 31); + } + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + + case EGREATEREQU: + if (!is_unsigned(left->rtype) && IS_INT_CONST_ZERO(right)) { + tmpReg = ALLOC_GPR(); + emitpcode(PC_RLWINM, tmpReg, op1.reg, 1, 31, 31); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_ADDI, finalReg, tmpReg, 0, -1); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + } + opTmp = op2; + op2 = op1; + op1 = opTmp; + + case ELESSEQU: + if (is_unsigned(left->rtype)) { + tmpReg = ALLOC_GPR(); + emitpcode(PC_SUBFC, tmpReg, op1.reg, op2.reg); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_ADDZE, tmpReg2, op1.reg); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SUBF, finalReg, tmpReg2, op1.reg); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + } + + if (IS_INT_CONST_ZERO(right)) { + tmpReg = ALLOC_GPR(); + emitpcode(PC_NEG, tmpReg, op1.reg); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_ORC, tmpReg2, op1.reg, tmpReg); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SRAWI, finalReg, tmpReg2, 31); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + } + + tmpReg = ALLOC_GPR(); + emitpcode(PC_XORIS, tmpReg, op1.reg, 0x8000); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_SUBF, tmpReg2, op1.reg, op2.reg); + tmpReg3 = ALLOC_GPR(); + emitpcode(PC_ADDC, tmpReg3, tmpReg2, tmpReg); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SUBFE, finalReg, tmpReg3, tmpReg3); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + + case EGREATER: + if (!is_unsigned(left->rtype) && IS_INT_CONST_ZERO(right)) { + tmpReg = ALLOC_GPR(); + emitpcode(PC_NEG, tmpReg, op1.reg); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_ANDC, tmpReg2, tmpReg, op1.reg); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SRAWI, finalReg, tmpReg2, 31); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + } + opTmp = op2; + op2 = op1; + op1 = opTmp; + + case ELESS: + if (is_unsigned(left->rtype)) { + tmpReg = ALLOC_GPR(); + emitpcode(PC_SUBFC, tmpReg, op2.reg, op1.reg); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SUBFE, finalReg, tmpReg, tmpReg); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + } + + if (IS_INT_CONST_ZERO(right)) { + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SRAWI, finalReg, op1.reg, 31); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + } + + tmpReg = ALLOC_GPR(); + emitpcode(PC_SUBFC, tmpReg, op2.reg, op1.reg); + tmpReg2 = ALLOC_GPR(); + emitpcode(PC_RLWINM, tmpReg2, op2.reg, 1, 31, 31); + tmpReg3 = ALLOC_GPR(); + emitpcode(PC_RLWINM, tmpReg3, op1.reg, 1, 31, 31); + finalReg = outputReg ? outputReg : ALLOC_GPR(); + emitpcode(PC_SUBFE, finalReg, tmpReg3, tmpReg2); + output->optype = OpndType_GPR; + output->reg = finalReg; + return; + + default: + CError_FATAL(6240); + } } void compare_floating(short nt, ENode *left, ENode *right, Operand *output) { @@ -3347,9 +3667,127 @@ void compare_integer(short nt, ENode *left, ENode *right, Operand *output) { } void compare_immediate(short nt, ENode *left, SInt32 value, Operand *output) { + int postIncFlag; + short postIncReg; + Operand op; + SInt32 postIncValue; + + memclrw(&op, sizeof(Operand)); + + postIncFlag = ispostincrementopportunity(left, &op, &postIncValue); + if (!postIncFlag) { + GEN_NODE(left, &op); + if (op.optype != OpndType_CRField) { + if (left->rtype->size < 4) + extend32(&op, left->rtype, 0); + else + ENSURE_GPR(&op, left->rtype, 0); + } + } else { + postIncReg = op.reg; + if (left->rtype->size < 4) + extend32(&op, left->rtype, 0); + ENSURE_GPR(&op, left->rtype, 0); + } + + if (op.optype == OpndType_CRField) { + if ( + (nt == EEQU && value == 1) || + (nt == ENOTEQU && value == 0) || + (nt == EGREATER && value == 0) || + (nt == EGREATEREQU && value == 1) + ) + { + *output = op; + return; + } + + if ( + (nt == EEQU && value == 0) || + (nt == ENOTEQU && value == 1) || + (nt == ELESS && value == 1) || + (nt == ELESSEQU && value == 0) + ) + { + *output = op; + switch (op.regOffset) { + case EEQU: + output->regOffset = ENOTEQU; + return; + case ENOTEQU: + output->regOffset = EEQU; + return; + case ELESS: + output->regOffset = EGREATEREQU; + return; + case EGREATER: + output->regOffset = ELESSEQU; + return; + case ELESSEQU: + output->regOffset = EGREATER; + return; + case EGREATEREQU: + output->regOffset = ELESS; + return; + } + } + + ENSURE_GPR(&op, left->rtype, 0); + } + + if ( + copts.peephole && + value == 0 && + pclastblock->pcodeCount > 0 && + pclastblock->lastPCode->op != PC_RLWINM && + (PCODE_FLAG_SET_F(pclastblock->lastPCode) & (fIsMove | fSideEffects | fCanSetRecordBit | fOpTypeGPR)) == (fCanSetRecordBit | fOpTypeGPR) && + pclastblock->lastPCode->args[0].data.reg.reg == op.reg && + (!is_unsigned(left->rtype) || nt == EEQU || nt == ENOTEQU) + ) + { + pcsetrecordbit(pclastblock->lastPCode); + } else { + emitpcode(is_unsigned(left->rtype) ? PC_CMPLI : PC_CMPI, 0, op.reg, value); + } + + if (postIncFlag) + add_register_immediate(postIncReg, postIncReg, postIncValue); + + output->optype = OpndType_CRField; + output->reg = 0; + output->regOffset = nt; } void compare_immediate_long(short nt, ENode *left, SInt32 value, Operand *output) { + int postIncFlag; + short postIncReg; + int outputReg; + Operand op; + SInt32 postIncValue; + + memclrw(&op, sizeof(Operand)); + + postIncFlag = ispostincrementopportunity(left, &op, &postIncValue); + if (!postIncFlag) { + GEN_NODE(left, &op); + } else { + postIncReg = op.reg; + } + + if (left->rtype->size < 4) + extend32(&op, left->rtype, 0); + ENSURE_GPR(&op, left->rtype, 0); + + outputReg = ALLOC_GPR(); + emitpcode(PC_ADDIS, outputReg, op.reg, 0, (SInt16) (~(value >> 16) + 1)); + emitpcode(PC_CMPLI, 0, outputReg, value & 0xFFFF); + + if (postIncFlag) + add_register_immediate(postIncReg, postIncReg, postIncValue); + + output->optype = OpndType_CRField; + output->reg = 0; + output->regOffset = nt; } static int ismask(SInt32 value, short *first, short *last) { @@ -3729,12 +4167,123 @@ void I8_gen_SUB(ENode *expr, short outputReg, short outputRegHi, Operand *output } void I8_gen_XOR(ENode *expr, short outputReg, short outputRegHi, Operand *output) { + ENode *left; + ENode *right; + short reg; + short regHi; + Operand opleft; + Operand opright; + + left = expr->data.diadic.left; + right = expr->data.diadic.right; + memclrw(&opleft, sizeof(Operand)); + memclrw(&opright, sizeof(Operand)); + + if (right->hascall) { + GEN_NODE(right, &opright); + coerce_to_register_pair(&opright, right->rtype, 0, 0); + + GEN_NODE(left, &opleft); + coerce_to_register_pair(&opleft, left->rtype, 0, 0); + } else { + GEN_NODE(left, &opleft); + coerce_to_register_pair(&opleft, left->rtype, 0, 0); + + GEN_NODE(right, &opright); + coerce_to_register_pair(&opright, right->rtype, 0, 0); + } + + CError_ASSERT(7254, opleft.optype == OpndType_GPRPair && opright.optype == OpndType_GPRPair); + + reg = outputReg ? outputReg : ALLOC_GPR(); + regHi = outputRegHi ? outputRegHi : ALLOC_GPR(); + + emitpcode(PC_XOR, reg, opleft.reg, opright.reg); + emitpcode(PC_XOR, regHi, opleft.regHi, opright.regHi); + + output->optype = OpndType_GPRPair; + output->reg = reg; + output->regHi = regHi; } void I8_gen_OR(ENode *expr, short outputReg, short outputRegHi, Operand *output) { + ENode *left; + ENode *right; + short reg; + short regHi; + Operand opleft; + Operand opright; + + left = expr->data.diadic.left; + right = expr->data.diadic.right; + memclrw(&opleft, sizeof(Operand)); + memclrw(&opright, sizeof(Operand)); + + if (right->hascall) { + GEN_NODE(right, &opright); + coerce_to_register_pair(&opright, right->rtype, 0, 0); + + GEN_NODE(left, &opleft); + coerce_to_register_pair(&opleft, left->rtype, 0, 0); + } else { + GEN_NODE(left, &opleft); + coerce_to_register_pair(&opleft, left->rtype, 0, 0); + + GEN_NODE(right, &opright); + coerce_to_register_pair(&opright, right->rtype, 0, 0); + } + + CError_ASSERT(7304, opleft.optype == OpndType_GPRPair && opright.optype == OpndType_GPRPair); + + reg = outputReg ? outputReg : ALLOC_GPR(); + regHi = outputRegHi ? outputRegHi : ALLOC_GPR(); + + emitpcode(PC_OR, reg, opleft.reg, opright.reg); + emitpcode(PC_OR, regHi, opleft.regHi, opright.regHi); + + output->optype = OpndType_GPRPair; + output->reg = reg; + output->regHi = regHi; } void I8_gen_AND(ENode *expr, short outputReg, short outputRegHi, Operand *output) { + ENode *left; + ENode *right; + short reg; + short regHi; + Operand opleft; + Operand opright; + + left = expr->data.diadic.left; + right = expr->data.diadic.right; + memclrw(&opleft, sizeof(Operand)); + memclrw(&opright, sizeof(Operand)); + + if (right->hascall) { + GEN_NODE(right, &opright); + coerce_to_register_pair(&opright, right->rtype, 0, 0); + + GEN_NODE(left, &opleft); + coerce_to_register_pair(&opleft, left->rtype, 0, 0); + } else { + GEN_NODE(left, &opleft); + coerce_to_register_pair(&opleft, left->rtype, 0, 0); + + GEN_NODE(right, &opright); + coerce_to_register_pair(&opright, right->rtype, 0, 0); + } + + CError_ASSERT(7354, opleft.optype == OpndType_GPRPair && opright.optype == OpndType_GPRPair); + + reg = outputReg ? outputReg : ALLOC_GPR(); + regHi = outputRegHi ? outputRegHi : ALLOC_GPR(); + + emitpcode(PC_AND, reg, opleft.reg, opright.reg); + emitpcode(PC_AND, regHi, opleft.regHi, opright.regHi); + + output->optype = OpndType_GPRPair; + output->reg = reg; + output->regHi = regHi; } int I8_getbit(UInt64 val) { @@ -4173,7 +4722,7 @@ void I8_gen_ASS(ENode *expr, short outputReg, short outputRegHi, Operand *output if (ENODE_IS(left, EINDIRECT)) left = left->data.monadic; else - CError_FATAL(8238); + CError_FATAL(8328); right = expr->data.cond.expr2; } else { left = expr->data.diadic.left; diff --git a/compiler_and_linker/unsorted/InterferenceGraph.c b/compiler_and_linker/unsorted/InterferenceGraph.c index f714b13..a849d1a 100644 --- a/compiler_and_linker/unsorted/InterferenceGraph.c +++ b/compiler_and_linker/unsorted/InterferenceGraph.c @@ -64,7 +64,7 @@ static void buildinterferencematrix(void) { for (j = 0; j < regs; j++) { if (bitvectorgetbit(j, vec)) { if ( - (instr->flags & fPCodeFlag10) && + (instr->flags & fIsMove) && PC_OP_IS_ANY_REGISTER(&instr->args[0], coloring_class) && instr->args[1].data.reg.reg == j ) @@ -89,10 +89,10 @@ static void buildinterferencematrix(void) { } if (coloring_class == RegClass_GPR) { - if (PCODE_FLAG_SET_F(instr) & (fPCodeFlag2 | fPCodeFlag4 | fPCodeFlag40000)) { + if (PCODE_FLAG_SET_F(instr) & (fIsRead | fIsWrite | fPCodeFlag40000)) { if (instr->args[1].data.reg.reg >= n_real_registers[coloring_class]) makeinterfere(0, instr->args[1].data.reg.reg); - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag2000000) + if (PCODE_FLAG_SET_F(instr) & fUpdatesPtr) makeinterfere(instr->args[0].data.reg.reg, instr->args[1].data.reg.reg); } else { switch (instr->op) { @@ -119,7 +119,7 @@ static void buildinterferencematrix(void) { } } - if (coloring_class == RegClass_GPR && (instr->flags & fPCodeFlag8)) { + if (coloring_class == RegClass_GPR && (instr->flags & fIsCall)) { i = branch_count_volatiles(); op = instr->args; CError_ASSERT(219, instr->argCount != 0); @@ -168,8 +168,8 @@ static void coalescenodes(void) { for (block = pcbasicblocks; block; block = block->nextBlock) { for (instr = block->firstPCode; instr; instr = instr->nextPCode) { - if ((instr->flags & fPCodeFlag10) && !(instr->flags & fSideEffects)) { - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) { + if ((instr->flags & fIsMove) && !(instr->flags & fSideEffects)) { + if (PCODE_FLAG_SET_F(instr) & fRecordBit) { CError_FATAL(309); continue; } diff --git a/compiler_and_linker/unsorted/IroDump.c b/compiler_and_linker/unsorted/IroDump.c index 9472a0f..22f5041 100644 --- a/compiler_and_linker/unsorted/IroDump.c +++ b/compiler_and_linker/unsorted/IroDump.c @@ -566,7 +566,7 @@ void IRO_SpellType(Type *type, char *buf) { strcat(buf, TYPE_ENUM(type)->enumname->name); break; case TYPESTRUCT: - if (IS_TYPESTRUCT_VECTOR(type)) { + if (IS_TYPESTRUCT_VECTOR(TYPE_STRUCT(type))) { switch (TYPE_STRUCT(type)->stype) { case STRUCT_TYPE_4: strcpy(buf, "vector unsigned char "); diff --git a/compiler_and_linker/unsorted/IroLinearForm.c b/compiler_and_linker/unsorted/IroLinearForm.c index c44a90c..2ac1d0a 100644 --- a/compiler_and_linker/unsorted/IroLinearForm.c +++ b/compiler_and_linker/unsorted/IroLinearForm.c @@ -79,10 +79,10 @@ static void MarkAssigned(IROLinear *linear, Boolean flag) { rec = IRO_InitAddrRecordPointer(inner); IRO_DecomposeAddressExpression(inner, rec); if (rec->numObjRefs == 1 && IS_LINEAR_ENODE(inner->u.diadic.left, EOBJREF)) { - rec->objRefs->element->flags |= IROLF_Assigned; + ((IROLinear *) rec->objRefs->element)->flags |= IROLF_Assigned; if (flag) { linear->flags |= IROLF_Used; - rec->objRefs->element->flags |= IROLF_Used; + ((IROLinear *) rec->objRefs->element)->flags |= IROLF_Used; } } } @@ -116,10 +116,10 @@ static void MarkAssigned(IROLinear *linear, Boolean flag) { rec = IRO_InitAddrRecordPointer(inner); IRO_DecomposeAddressExpression(inner, rec); if (rec->numObjRefs == 1 && IS_LINEAR_ENODE(inner->u.diadic.left, EOBJREF)) { - rec->objRefs->element->flags |= IROLF_Assigned; + ((IROLinear *) rec->objRefs->element)->flags |= IROLF_Assigned; if (flag) { linear->flags |= IROLF_Used; - rec->objRefs->element->flags |= IROLF_Used; + ((IROLinear *) rec->objRefs->element)->flags |= IROLF_Used; } } } @@ -248,7 +248,7 @@ static void MarkSubs1(IROLinear *linear) { rec = IRO_InitAddrRecordPointer(linear); IRO_DecomposeAddressExpression(linear, rec); if (rec->numObjRefs == 1 && IS_LINEAR_ENODE(linear->u.diadic.left, EOBJREF)) - rec->objRefs->element->flags |= IROLF_Ind; + ((IROLinear *) rec->objRefs->element)->flags |= IROLF_Ind; } } diff --git a/compiler_and_linker/unsorted/IroPointerAnalysisADTs.c b/compiler_and_linker/unsorted/IroPointerAnalysisADTs.c index cf54aca..fe5d4bb 100644 --- a/compiler_and_linker/unsorted/IroPointerAnalysisADTs.c +++ b/compiler_and_linker/unsorted/IroPointerAnalysisADTs.c @@ -1392,7 +1392,7 @@ inline LocationSet *LocationSet_bitfieldOf(LocationSet *ls) { return ls->u.unknown.bitfieldOf; } -inline LocationSetSet *LocationSetSet_New() { +inline LocationSetSet *LocationSetSet_New(void) { LocationSetSet *lss = IRO_malloc(sizeof(LocationSetSet)); IRO_ASSERT(2356, lss != NULL); @@ -2446,7 +2446,7 @@ inline Boolean PointsToFunctions_Match(PointsToFunction *pointsToFunc1, PointsTo return 1; } -inline PartialTransferFunction *PartialTransferFunction_New() { +inline PartialTransferFunction *PartialTransferFunction_New(void) { PartialTransferFunction *ptf = IRO_malloc(sizeof(PartialTransferFunction)); IRO_ASSERT(4110, ptf != NULL); diff --git a/compiler_and_linker/unsorted/LiveVariables.c b/compiler_and_linker/unsorted/LiveVariables.c new file mode 100644 index 0000000..210761e --- /dev/null +++ b/compiler_and_linker/unsorted/LiveVariables.c @@ -0,0 +1,157 @@ +#include "compiler/LiveInfo.h" +#include "compiler/BitVectors.h" +#include "compiler/Coloring.h" +#include "compiler/CompilerTools.h" +#include "compiler/PCode.h" +#include "compiler/Registers.h" +#include "compiler/objects.h" +#include "compiler/types.h" +#include "compiler/CParser.h" + +LiveInfo *liveinfo; + +static void allocateliveinfo(void) { + UInt32 regs; + LiveInfo *info; + int i; + + regs = used_virtual_registers[coloring_class]; + + liveinfo = oalloc(sizeof(LiveInfo) * pcblockcount); + for (i = 0, info = liveinfo; i < pcblockcount; i++, info++) { + bitvectorinitialize(info->use = oalloc(4 * ((regs + 31) >> 5)), regs, 0); + bitvectorinitialize(info->def = oalloc(4 * ((regs + 31) >> 5)), regs, 0); + bitvectorinitialize(info->in = oalloc(4 * ((regs + 31) >> 5)), regs, 0); + bitvectorinitialize(info->out = oalloc(4 * ((regs + 31) >> 5)), regs, 0); + } +} + +static void computelocalusedef(void) { + LiveInfo *info; + PCodeBlock *block; + PCode *instr; + UInt32 *use; + UInt32 *def; + PCodeArg *op; + int i; + + for (block = pcbasicblocks; block; block = block->nextBlock) { + info = &liveinfo[block->blockIndex]; + use = info->use; + def = info->def; + + for (instr = block->firstPCode; instr; instr = instr->nextPCode) { + op = instr->args; + i = instr->argCount; + while (i--) { + if (PC_OP_IS_READ_ANY_REGISTER(op, coloring_class) && !bitvectorgetbit(op->data.reg.reg, def)) + bitvectorsetbit(op->data.reg.reg, use); + op++; + } + + op = instr->args; + i = instr->argCount; + while (i--) { + if (PC_OP_IS_WRITE_ANY_REGISTER(op, coloring_class) && !bitvectorgetbit(op->data.reg.reg, use)) + bitvectorsetbit(op->data.reg.reg, def); + op++; + } + } + } +} + +static void computeglobalinout(void) { + UInt32 regs; + LiveInfo *info; + UInt32 *use; + UInt32 *def; + UInt32 *in; + UInt32 *out; + int bitvecsize; + int blockIndex; + int i; + int flag; + PCodeBlock *block; + PCLink *link; + UInt32 val; + + regs = used_virtual_registers[coloring_class]; + bitvecsize = (regs + 31) >> 5; + flag = 1; + while (flag) { + flag = 0; + blockIndex = pcblockcount; + while (blockIndex) { + if ((block = depthfirstordering[--blockIndex])) { + info = &liveinfo[block->blockIndex]; + if ((link = block->successors)) { + out = info->out; + bitvectorcopy(out, liveinfo[link->block->blockIndex].in, regs); + for (link = link->nextLink; link; link = link->nextLink) + bitvectorunion(out, liveinfo[link->block->blockIndex].in, regs); + } + + out = info->out; + in = info->in; + use = info->use; + def = info->def; + for (i = 0; i < bitvecsize; i++) { + val = *use | (*out & ~*def); + if (val != *in) { + *in = val; + flag = 1; + } + in++; + out++; + use++; + def++; + } + } + } + } +} + +void computelivevariables(Object *proc) { + Type *returnType; + + returnType = TYPE_FUNC(proc->type)->functype; + computedepthfirstordering(); + allocateliveinfo(); + computelocalusedef(); + + if (coloring_class == RegClass_GPR && TYPE_FITS_IN_REGISTER(returnType)) { + bitvectorsetbit(3, liveinfo[epilogue->blockIndex].use); + if (TYPE_IS_8BYTES(returnType)) + bitvectorsetbit(4, liveinfo[pclastblock->blockIndex].use); + } else if (coloring_class == RegClass_FPR && IS_TYPE_FLOAT(returnType)) { + bitvectorsetbit(1, liveinfo[epilogue->blockIndex].use); + } else if (coloring_class == RegClass_VR && IS_TYPE_VECTOR(returnType)) { + bitvectorsetbit(2, liveinfo[epilogue->blockIndex].use); + } + + computeglobalinout(); +} + +int dead(PCode *instr, RegClass rclass, UInt32 *vec) { + int i; + PCodeArg *op; + + if (instr->flags & (fIsBranch | fIsWrite | fIsCall | fIsVolatile | fSideEffects)) + return 0; + if (instr->block->flags & (fIsProlog | fIsEpilogue)) + return 0; + + op = instr->args; + i = instr->argCount; + while (i--) { + if ( + op->kind == PCOp_REGISTER && + (op->data.reg.effect & EffectWrite) && + (rclass != op->arg || bitvectorgetbit(op->data.reg.reg, vec)) + ) + return 0; + op++; + } + + return copts.optimizationlevel > 0; +} diff --git a/compiler_and_linker/unsorted/LoopDetection.c b/compiler_and_linker/unsorted/LoopDetection.c index 5df2524..1d8244a 100644 --- a/compiler_and_linker/unsorted/LoopDetection.c +++ b/compiler_and_linker/unsorted/LoopDetection.c @@ -15,7 +15,7 @@ static BlockList *loopheaders; static int nloopheaders; static PCodeBlock **loopstack; BitVector *LoopTemp; -void *LoopList_First; +struct LoopList *LoopList_First; static void computedominators(void) { int i; @@ -316,7 +316,7 @@ void insertpreheaderblock(Loop *loop) { if ( (!block28->nextBlock || !bitvectorgetbit(block28->nextBlock->blockIndex, loop->memberblocks)) && block28->lastPCode && - (block28->lastPCode->flags & fPCodeFlag1) && + (block28->lastPCode->flags & fIsBranch) && block28->lastPCode->op != PC_BDNZ ) { i = block28->lastPCode->argCount; @@ -851,10 +851,10 @@ void analyzeloop(Loop *loop) { if (pcode->op == PC_BCTRL || pcode->op == PC_BCTR || pcode->op == PC_BCCTR || pcode->op == PC_MTCTR || pcode->op == PC_MFCTR) { loop->x4E = 1; - } else if (pcode->flags & fPCodeFlag2) { + } else if (pcode->flags & fIsRead) { if (pcode->op == PC_LBZX || pcode->op == PC_LHZX || pcode->op == PC_LHAX || pcode->op == PC_LWZX || pcode->op == PC_LFSX || pcode->op == PC_LFDX) loop->x53 = 1; - } else if (pcode->flags & fPCodeFlag4) { + } else if (pcode->flags & fIsWrite) { if (pcode->op == PC_STBX || pcode->op == PC_STHX || pcode->op == PC_STWX || pcode->op == PC_STFSX || pcode->op == PC_STFDX) loop->x54 = 1; } else { @@ -883,4 +883,3 @@ void analyzeloopsinflowgraph(void) { if (loopsinflowgraph) analyzeloops(loopsinflowgraph); } - diff --git a/compiler_and_linker/unsorted/LoopOptimization.c b/compiler_and_linker/unsorted/LoopOptimization.c index c2a360f..9db7c53 100644 --- a/compiler_and_linker/unsorted/LoopOptimization.c +++ b/compiler_and_linker/unsorted/LoopOptimization.c @@ -175,7 +175,7 @@ static void skiplooptest(Loop *loop) { loop->bodySize--; } - for (instr = instr->nextPCode; instr && !(instr->flags & fPCodeFlag1); instr = instr->nextPCode) + for (instr = instr->nextPCode; instr && !(instr->flags & fIsBranch); instr = instr->nextPCode) insertpcodebefore(loop->preheader->lastPCode, copypcode(instr)); } @@ -206,7 +206,7 @@ static void unrollloop(Loop *loop) { if (firstInstr->op != PC_CMP && firstInstr->op != PC_CMPL && firstInstr->op != PC_CMPI && firstInstr->op != PC_CMPLI) CError_FATAL(450); - for (instr = firstInstr->nextPCode; instr && !(instr->flags & fPCodeFlag1); instr = instr->nextPCode) + for (instr = firstInstr->nextPCode; instr && !(instr->flags & fIsBranch); instr = instr->nextPCode) appendpcode(newBlock, copypcode(instr)); for (block = loop->preheader->successors->block; block != loop->body; block = block->successors->block) { @@ -384,7 +384,7 @@ static void unrollloopconditional(Loop *loop) { for (j = 0; j < inputBlockCount; j++) { for (instr = blocks[j]->firstPCode; instr; instr = instr->nextPCode) { - if (instr->flags & fPCodeFlag1) { + if (instr->flags & fIsBranch) { PCodeArg *op; int opID; instrCopy = copypcode(instr); @@ -425,7 +425,7 @@ static void unrollloopconditional(Loop *loop) { if (firstInstr->op != PC_CMP && firstInstr->op != PC_CMPL && firstInstr->op != PC_CMPI && firstInstr->op != PC_CMPLI) CError_FATAL(764); - for (instr = firstInstr->nextPCode; instr && !(instr->flags & fPCodeFlag1); instr = instr->nextPCode) + for (instr = firstInstr->nextPCode; instr && !(instr->flags & fIsBranch); instr = instr->nextPCode) appendpcode(blocks2[inputBlockCount - 1], copypcode(instr)); for (j = 0; j < inputBlockCount; j++) { @@ -465,7 +465,7 @@ static void unrollloopconditional(Loop *loop) { for (i = 0; i < inputBlockCount; i++) { for (instr = blocks[i]->firstPCode; instr; instr = instr->nextPCode) { - if (instr->flags & fPCodeFlag1) { + if (instr->flags & fIsBranch) { PCodeArg *op; int opID; op = NULL; @@ -1293,7 +1293,7 @@ void changearraytoregisters(void) { if ((arrays = scanforlocalarrays())) { for (block = pcbasicblocks; block; block = block->nextBlock) { for (instr = block->firstPCode; instr; instr = instr->nextPCode) { - if (!(instr->flags & fPCodeFlag1) && instr->argCount) { + if (!(instr->flags & fIsBranch) && instr->argCount) { op = instr->args; i = instr->argCount; while (i--) { @@ -1304,7 +1304,7 @@ void changearraytoregisters(void) { !array->invalid ) { if ( - (instr->flags & (fPCodeFlag2 | fPCodeFlag4)) && + (instr->flags & (fIsRead | fIsWrite)) && (op->data.mem.offset % array->elementSize) == 0 && op->data.mem.offset < array->arraySize ) { @@ -1460,9 +1460,9 @@ void changearraytoregisters(void) { for (block = pcbasicblocks; block; block = block->nextBlock) { for (instr = block->firstPCode; instr; instr = instr->nextPCode) { if ( - !(instr->flags & fPCodeFlag1) && + !(instr->flags & fIsBranch) && instr->argCount && - (instr->flags & (fPCodeFlag2 | fPCodeFlag4)) && + (instr->flags & (fIsRead | fIsWrite)) && instr->args[2].kind == PCOp_MEMORY && (PCOpMemoryArg) instr->args[2].arg == PCOpMemory1 && (array = lookup_array_object(arrays, instr->args[2].data.mem.obj)) && diff --git a/compiler_and_linker/unsorted/MachineSimulation601.c b/compiler_and_linker/unsorted/MachineSimulation601.c new file mode 100644 index 0000000..2d54678 --- /dev/null +++ b/compiler_and_linker/unsorted/MachineSimulation601.c @@ -0,0 +1,552 @@ +#include "compiler/Scheduler.h" +#include "compiler/PCode.h" +#include "compiler/PCodeInfo.h" + +// https://stuff.mit.edu/afs/sipb/contrib/doc/specs/ic/cpu/powerpc/mpc601.pdf +// https://www.nxp.com/docs/en/user-guide/MPC601UMAD.pdf + +typedef enum Stage { + IU, // Integer Unit + FD, // FP Decode + FPM, // FP Multiply + FPA, // FP Add + FWA, // FP Arithmetic Writeback + BPU, // Branch Processing Unit + NumStages, + Serialize, // special form for instructions that use IU but are serialised + Unsupported // instructions not supported by this processor +} Stage; + +static struct { + // the instruction currently in this pipeline stage + PCode *instr; + + // how many cycles are left for this instruction to finish + int remaining; +} pipeline[NumStages]; + +static struct { + // the initial stage for this instruction + Stage stage; + + // the total amount of cycles required by this instruction + char latency; + + // how long it takes to finish each stage + char cycles[4]; +} instruction_timing[OPCODE_MAX] = { + BPU, 0, 0, 0, 0, 1, // PC_B + BPU, 0, 0, 0, 0, 1, // PC_BL + BPU, 0, 0, 0, 0, 1, // PC_BC + BPU, 0, 0, 0, 0, 1, // PC_BCLR + BPU, 0, 0, 0, 0, 1, // PC_BCCTR + BPU, 0, 0, 0, 0, 1, // PC_BT + BPU, 0, 0, 0, 0, 1, // PC_BTLR + BPU, 0, 0, 0, 0, 1, // PC_BTCTR + BPU, 0, 0, 0, 0, 1, // PC_BF + BPU, 0, 0, 0, 0, 1, // PC_BFLR + BPU, 0, 0, 0, 0, 1, // PC_BFCTR + BPU, 0, 0, 0, 0, 1, // PC_BDNZ + BPU, 0, 0, 0, 0, 1, // PC_BDNZT + BPU, 0, 0, 0, 0, 1, // PC_BDNZF + BPU, 0, 0, 0, 0, 1, // PC_BDZ + BPU, 0, 0, 0, 0, 1, // PC_BDZT + BPU, 0, 0, 0, 0, 1, // PC_BDZF + BPU, 0, 0, 0, 0, 1, // PC_BLR + BPU, 0, 0, 0, 0, 1, // PC_BCTR + BPU, 0, 0, 0, 0, 1, // PC_BCTRL + BPU, 0, 0, 0, 0, 1, // PC_BLRL + IU, 2, 1, 0, 0, 0, // PC_LBZ + IU, 2, 1, 0, 0, 0, // PC_LBZU + IU, 2, 1, 0, 0, 0, // PC_LBZX + IU, 2, 1, 0, 0, 0, // PC_LBZUX + IU, 2, 1, 0, 0, 0, // PC_LHZ + IU, 2, 1, 0, 0, 0, // PC_LHZU + IU, 2, 1, 0, 0, 0, // PC_LHZX + IU, 2, 1, 0, 0, 0, // PC_LHZUX + IU, 2, 1, 0, 0, 0, // PC_LHA + IU, 2, 1, 0, 0, 0, // PC_LHAU + IU, 2, 1, 0, 0, 0, // PC_LHAX + IU, 2, 1, 0, 0, 0, // PC_LHAUX + IU, 2, 1, 0, 0, 0, // PC_LHBRX + IU, 2, 1, 0, 0, 0, // PC_LWZ + IU, 2, 1, 0, 0, 0, // PC_LWZU + IU, 2, 1, 0, 0, 0, // PC_LWZX + IU, 2, 1, 0, 0, 0, // PC_LWZUX + IU, 2, 1, 0, 0, 0, // PC_LWBRX + IU, 1, 1, 0, 0, 0, // PC_LMW + IU, 1, 1, 0, 0, 0, // PC_STB + IU, 1, 1, 0, 0, 0, // PC_STBU + IU, 1, 1, 0, 0, 0, // PC_STBX + IU, 1, 1, 0, 0, 0, // PC_STBUX + IU, 1, 1, 0, 0, 0, // PC_STH + IU, 1, 1, 0, 0, 0, // PC_STHU + IU, 1, 1, 0, 0, 0, // PC_STHX + IU, 1, 1, 0, 0, 0, // PC_STHUX + IU, 1, 1, 0, 0, 0, // PC_STHBRX + IU, 1, 1, 0, 0, 0, // PC_STW + IU, 1, 1, 0, 0, 0, // PC_STWU + IU, 1, 1, 0, 0, 0, // PC_STWX + IU, 1, 1, 0, 0, 0, // PC_STWUX + IU, 1, 1, 0, 0, 0, // PC_STWBRX + IU, 1, 1, 0, 0, 0, // PC_STMW + IU, 2, 1, 0, 0, 0, // PC_DCBF + IU, 2, 1, 0, 0, 0, // PC_DCBST + IU, 2, 1, 0, 0, 0, // PC_DCBT + IU, 2, 1, 0, 0, 0, // PC_DCBTST + IU, 2, 1, 0, 0, 0, // PC_DCBZ + IU, 1, 1, 0, 0, 0, // PC_ADD + IU, 1, 1, 0, 0, 0, // PC_ADDC + IU, 1, 1, 0, 0, 0, // PC_ADDE + IU, 1, 1, 0, 0, 0, // PC_ADDI + IU, 1, 1, 0, 0, 0, // PC_ADDIC + IU, 1, 1, 0, 0, 0, // PC_ADDICR + IU, 1, 1, 0, 0, 0, // PC_ADDIS + IU, 1, 1, 0, 0, 0, // PC_ADDME + IU, 1, 1, 0, 0, 0, // PC_ADDZE + IU, 36, 36, 0, 0, 0, // PC_DIVW + IU, 36, 36, 0, 0, 0, // PC_DIVWU + IU, 5, 5, 0, 0, 0, // PC_MULHW + IU, 5, 5, 0, 0, 0, // PC_MULHWU + IU, 5, 5, 0, 0, 0, // PC_MULLI + IU, 5, 5, 0, 0, 0, // PC_MULLW + IU, 1, 1, 0, 0, 0, // PC_NEG + IU, 1, 1, 0, 0, 0, // PC_SUBF + IU, 1, 1, 0, 0, 0, // PC_SUBFC + IU, 1, 1, 0, 0, 0, // PC_SUBFE + IU, 1, 1, 0, 0, 0, // PC_SUBFIC + IU, 1, 1, 0, 0, 0, // PC_SUBFME + IU, 1, 1, 0, 0, 0, // PC_SUBFZE + IU, 3, 1, 0, 0, 0, // PC_CMPI + IU, 3, 1, 0, 0, 0, // PC_CMP + IU, 3, 1, 0, 0, 0, // PC_CMPLI + IU, 3, 1, 0, 0, 0, // PC_CMPL + IU, 1, 1, 0, 0, 0, // PC_ANDI + IU, 1, 1, 0, 0, 0, // PC_ANDIS + IU, 1, 1, 0, 0, 0, // PC_ORI + IU, 1, 1, 0, 0, 0, // PC_ORIS + IU, 1, 1, 0, 0, 0, // PC_XORI + IU, 1, 1, 0, 0, 0, // PC_XORIS + IU, 1, 1, 0, 0, 0, // PC_AND + IU, 1, 1, 0, 0, 0, // PC_OR + IU, 1, 1, 0, 0, 0, // PC_XOR + IU, 1, 1, 0, 0, 0, // PC_NAND + IU, 1, 1, 0, 0, 0, // PC_NOR + IU, 1, 1, 0, 0, 0, // PC_EQV + IU, 1, 1, 0, 0, 0, // PC_ANDC + IU, 1, 1, 0, 0, 0, // PC_ORC + IU, 1, 1, 0, 0, 0, // PC_EXTSB + IU, 1, 1, 0, 0, 0, // PC_EXTSH + IU, 1, 1, 0, 0, 0, // PC_CNTLZW + IU, 1, 1, 0, 0, 0, // PC_RLWINM + IU, 1, 1, 0, 0, 0, // PC_RLWNM + IU, 1, 1, 0, 0, 0, // PC_RLWIMI + IU, 1, 1, 0, 0, 0, // PC_SLW + IU, 1, 1, 0, 0, 0, // PC_SRW + IU, 1, 1, 0, 0, 0, // PC_SRAWI + IU, 1, 1, 0, 0, 0, // PC_SRAW + IU, 1, 1, 0, 0, 0, // PC_CRAND + IU, 1, 1, 0, 0, 0, // PC_CRANDC + IU, 1, 1, 0, 0, 0, // PC_CREQV + IU, 1, 1, 0, 0, 0, // PC_CRNAND + IU, 1, 1, 0, 0, 0, // PC_CRNOR + IU, 1, 1, 0, 0, 0, // PC_CROR + IU, 1, 1, 0, 0, 0, // PC_CRORC + IU, 1, 1, 0, 0, 0, // PC_CRXOR + IU, 1, 1, 0, 0, 0, // PC_MCRF + IU, 4, 1, 0, 0, 0, // PC_MTXER + IU, 4, 1, 0, 0, 0, // PC_MTCTR + IU, 4, 1, 0, 0, 0, // PC_MTLR + IU, 2, 1, 0, 0, 0, // PC_MTCRF + IU, 1, 0, 0, 0, 0, // PC_MTMSR + IU, 1, 0, 0, 0, 0, // PC_MTSPR + IU, 1, 0, 0, 0, 0, // PC_MFMSR + IU, 1, 0, 0, 0, 0, // PC_MFSPR + IU, 1, 1, 0, 0, 0, // PC_MFXER + IU, 1, 1, 0, 0, 0, // PC_MFCTR + IU, 1, 1, 0, 0, 0, // PC_MFLR + IU, 1, 1, 0, 0, 0, // PC_MFCR + FD, 4, 1, 1, 1, 1, // PC_MFFS + FD, 4, 1, 1, 1, 1, // PC_MTFSF + Serialize, 1, 1, 0, 0, 1, // PC_EIEIO + Serialize, 1, 1, 0, 0, 1, // PC_ISYNC + Serialize, 1, 1, 0, 0, 1, // PC_SYNC + Serialize, 0, 0, 0, 0, 1, // PC_RFI + IU, 1, 1, 0, 0, 0, // PC_LI + IU, 1, 1, 0, 0, 0, // PC_LIS + IU, 1, 1, 0, 0, 0, // PC_MR + IU, 1, 1, 0, 0, 0, // PC_NOP + IU, 1, 1, 0, 0, 0, // PC_NOT + IU, 3, 1, 0, 0, 0, // PC_LFS + IU, 3, 1, 0, 0, 0, // PC_LFSU + IU, 3, 1, 0, 0, 0, // PC_LFSX + IU, 3, 1, 0, 0, 0, // PC_LFSUX + IU, 3, 1, 0, 0, 0, // PC_LFD + IU, 3, 1, 0, 0, 0, // PC_LFDU + IU, 3, 1, 0, 0, 0, // PC_LFDX + IU, 3, 1, 0, 0, 0, // PC_LFDUX + IU, 1, 1, 0, 0, 0, // PC_STFS + IU, 1, 1, 0, 0, 0, // PC_STFSU + IU, 1, 1, 0, 0, 0, // PC_STFSX + IU, 1, 1, 0, 0, 0, // PC_STFSUX + IU, 1, 1, 0, 0, 0, // PC_STFD + IU, 1, 1, 0, 0, 0, // PC_STFDU + IU, 1, 1, 0, 0, 0, // PC_STFDX + IU, 1, 1, 0, 0, 0, // PC_STFDUX + FD, 4, 1, 1, 1, 1, // PC_FMR + FD, 4, 1, 1, 1, 1, // PC_FABS + FD, 4, 1, 1, 1, 1, // PC_FNEG + FD, 4, 1, 1, 1, 1, // PC_FNABS + FD, 4, 1, 1, 1, 1, // PC_FADD + FD, 4, 1, 1, 1, 1, // PC_FADDS + FD, 4, 1, 1, 1, 1, // PC_FSUB + FD, 4, 1, 1, 1, 1, // PC_FSUBS + FD, 5, 1, 1, 2, 1, // PC_FMUL + FD, 4, 1, 1, 1, 1, // PC_FMULS + FD, 31, 1, 1, 28, 1, // PC_FDIV + FD, 17, 1, 1, 14, 1, // PC_FDIVS + FD, 5, 1, 1, 2, 1, // PC_FMADD + FD, 4, 1, 1, 1, 1, // PC_FMADDS + FD, 5, 1, 1, 2, 1, // PC_FMSUB + FD, 4, 1, 1, 1, 1, // PC_FMSUBS + FD, 5, 1, 1, 2, 1, // PC_FNMADD + FD, 4, 1, 1, 1, 1, // PC_FNMADDS + FD, 5, 1, 1, 2, 1, // PC_FNMSUB + FD, 4, 1, 1, 1, 1, // PC_FNMSUBS + FD, 4, 1, 1, 1, 1, // PC_FRES + FD, 4, 1, 1, 1, 1, // PC_FRSQRTE + FD, 4, 1, 1, 1, 1, // PC_FSEL + FD, 4, 1, 1, 1, 1, // PC_FRSP + FD, 4, 1, 1, 1, 1, // PC_FCTIW + FD, 4, 1, 1, 1, 1, // PC_FCTIWZ + FD, 6, 1, 1, 1, 1, // PC_FCMPU + FD, 6, 1, 1, 1, 1, // PC_FCMPO + IU, 0, 0, 0, 0, 0, // PC_LWARX + IU, 0, 0, 0, 0, 0, // PC_LSWI + IU, 0, 0, 0, 0, 0, // PC_LSWX + IU, 0, 0, 0, 0, 0, // PC_STFIWX + IU, 0, 0, 0, 0, 0, // PC_STSWI + IU, 0, 0, 0, 0, 0, // PC_STSWX + IU, 0, 0, 0, 0, 0, // PC_STWCX + IU, 0, 0, 0, 0, 0, // PC_ECIWX + IU, 0, 0, 0, 0, 0, // PC_ECOWX + IU, 0, 0, 0, 0, 0, // PC_DCBI + IU, 0, 0, 0, 0, 0, // PC_ICBI + IU, 0, 0, 0, 0, 0, // PC_MCRFS + IU, 0, 0, 0, 0, 0, // PC_MCRXR + IU, 0, 0, 0, 0, 0, // PC_MFTB + IU, 0, 0, 0, 0, 0, // PC_MFSR + IU, 0, 0, 0, 0, 0, // PC_MTSR + IU, 0, 0, 0, 0, 0, // PC_MFSRIN + IU, 0, 0, 0, 0, 0, // PC_MTSRIN + IU, 0, 0, 0, 0, 0, // PC_MTFSB0 + IU, 0, 0, 0, 0, 0, // PC_MTFSB1 + IU, 0, 0, 0, 0, 0, // PC_MTFSFI + Serialize, 0, 0, 0, 0, 0, // PC_SC + IU, 0, 0, 0, 0, 0, // PC_FSQRT + IU, 0, 0, 0, 0, 0, // PC_FSQRTS + IU, 0, 0, 0, 0, 0, // PC_TLBIA + IU, 0, 0, 0, 0, 0, // PC_TLBIE + IU, 0, 0, 0, 0, 0, // PC_TLBLD + IU, 0, 0, 0, 0, 0, // PC_TLBLI + IU, 0, 0, 0, 0, 0, // PC_TLBSYNC + Serialize, 0, 0, 0, 0, 0, // PC_TW + Serialize, 0, 0, 0, 0, 0, // PC_TRAP + Serialize, 0, 0, 0, 0, 0, // PC_TWI + Serialize, 0, 0, 0, 0, 0, // PC_OPWORD + IU, 0, 0, 0, 0, 0, // PC_MFROM + IU, 0, 0, 0, 0, 0, // PC_DSA + IU, 0, 0, 0, 0, 0, // PC_ESA + IU, 0, 0, 0, 0, 0, // PC_DCCCI + IU, 0, 0, 0, 0, 0, // PC_DCREAD + IU, 0, 0, 0, 0, 0, // PC_ICBT + IU, 0, 0, 0, 0, 0, // PC_ICCCI + IU, 0, 0, 0, 0, 0, // PC_ICREAD + IU, 0, 0, 0, 0, 0, // PC_RFCI + IU, 0, 0, 0, 0, 0, // PC_TLBRE + IU, 0, 0, 0, 0, 0, // PC_TLBSX + IU, 0, 0, 0, 0, 0, // PC_TLBWE + IU, 0, 0, 0, 0, 0, // PC_WRTEE + IU, 0, 0, 0, 0, 0, // PC_WRTEEI + IU, 0, 0, 0, 0, 0, // PC_MFDCR + IU, 0, 0, 0, 0, 0, // PC_MTDCR + Unsupported, 0, 0, 0, 0, 0, // PC_DCBA + Unsupported, 0, 0, 0, 0, 0, // PC_DSS + Unsupported, 0, 0, 0, 0, 0, // PC_DSSALL + Unsupported, 0, 0, 0, 0, 0, // PC_DST + Unsupported, 0, 0, 0, 0, 0, // PC_DSTT + Unsupported, 0, 0, 0, 0, 0, // PC_DSTST + Unsupported, 0, 0, 0, 0, 0, // PC_DSTSTT + Unsupported, 0, 0, 0, 0, 0, // PC_LVEBX + Unsupported, 0, 0, 0, 0, 0, // PC_LVEHX + Unsupported, 0, 0, 0, 0, 0, // PC_LVEWX + Unsupported, 0, 0, 0, 0, 0, // PC_LVSL + Unsupported, 0, 0, 0, 0, 0, // PC_LVSR + Unsupported, 0, 0, 0, 0, 0, // PC_LVX + Unsupported, 0, 0, 0, 0, 0, // PC_LVXL + Unsupported, 0, 0, 0, 0, 0, // PC_STVEBX + Unsupported, 0, 0, 0, 0, 0, // PC_STVEHX + Unsupported, 0, 0, 0, 0, 0, // PC_STVEWX + Unsupported, 0, 0, 0, 0, 0, // PC_STVX + Unsupported, 0, 0, 0, 0, 0, // PC_STVXL + Unsupported, 0, 0, 0, 0, 0, // PC_MFVSCR + Unsupported, 0, 0, 0, 0, 0, // PC_MTVSCR + Unsupported, 0, 0, 0, 0, 0, // PC_VADDCUW + Unsupported, 0, 0, 0, 0, 0, // PC_VADDFP + Unsupported, 0, 0, 0, 0, 0, // PC_VADDSBS + Unsupported, 0, 0, 0, 0, 0, // PC_VADDSHS + Unsupported, 0, 0, 0, 0, 0, // PC_VADDSWS + Unsupported, 0, 0, 0, 0, 0, // PC_VADDUBM + Unsupported, 0, 0, 0, 0, 0, // PC_VADDUBS + Unsupported, 0, 0, 0, 0, 0, // PC_VADDUHM + Unsupported, 0, 0, 0, 0, 0, // PC_VADDUHS + Unsupported, 0, 0, 0, 0, 0, // PC_VADDUWM + Unsupported, 0, 0, 0, 0, 0, // PC_VADDUWS + Unsupported, 0, 0, 0, 0, 0, // PC_VAND + Unsupported, 0, 0, 0, 0, 0, // PC_VANDC + Unsupported, 0, 0, 0, 0, 0, // PC_VAVGSB + Unsupported, 0, 0, 0, 0, 0, // PC_VAVGSH + Unsupported, 0, 0, 0, 0, 0, // PC_VAVGSW + Unsupported, 0, 0, 0, 0, 0, // PC_VAVGUB + Unsupported, 0, 0, 0, 0, 0, // PC_VAVGUH + Unsupported, 0, 0, 0, 0, 0, // PC_VAVGUW + Unsupported, 0, 0, 0, 0, 0, // PC_VCFSX + Unsupported, 0, 0, 0, 0, 0, // PC_VCFUX + Unsupported, 0, 0, 0, 0, 0, // PC_VCMPBFP + Unsupported, 0, 0, 0, 0, 0, // PC_VCMPEQFP + Unsupported, 0, 0, 0, 0, 0, // PC_VCMPEQUB + Unsupported, 0, 0, 0, 0, 0, // PC_VCMPEQUH + Unsupported, 0, 0, 0, 0, 0, // PC_VCMPEQUW + Unsupported, 0, 0, 0, 0, 0, // PC_VCMPGEFP + Unsupported, 0, 0, 0, 0, 0, // PC_VCMPGTFP + Unsupported, 0, 0, 0, 0, 0, // PC_VCMPGTSB + Unsupported, 0, 0, 0, 0, 0, // PC_VCMPGTSH + Unsupported, 0, 0, 0, 0, 0, // PC_VCMPGTSW + Unsupported, 0, 0, 0, 0, 0, // PC_VCMPGTUB + Unsupported, 0, 0, 0, 0, 0, // PC_VCMPGTUH + Unsupported, 0, 0, 0, 0, 0, // PC_VCMPGTUW + Unsupported, 0, 0, 0, 0, 0, // PC_VCTSXS + Unsupported, 0, 0, 0, 0, 0, // PC_VCTUXS + Unsupported, 0, 0, 0, 0, 0, // PC_VEXPTEFP + Unsupported, 0, 0, 0, 0, 0, // PC_VLOGEFP + Unsupported, 0, 0, 0, 0, 0, // PC_VMAXFP + Unsupported, 0, 0, 0, 0, 0, // PC_VMAXSB + Unsupported, 0, 0, 0, 0, 0, // PC_VMAXSH + Unsupported, 0, 0, 0, 0, 0, // PC_VMAXSW + Unsupported, 0, 0, 0, 0, 0, // PC_VMAXUB + Unsupported, 0, 0, 0, 0, 0, // PC_VMAXUH + Unsupported, 0, 0, 0, 0, 0, // PC_VMAXUW + Unsupported, 0, 0, 0, 0, 0, // PC_VMINFP + Unsupported, 0, 0, 0, 0, 0, // PC_VMINSB + Unsupported, 0, 0, 0, 0, 0, // PC_VMINSH + Unsupported, 0, 0, 0, 0, 0, // PC_VMINSW + Unsupported, 0, 0, 0, 0, 0, // PC_VMINUB + Unsupported, 0, 0, 0, 0, 0, // PC_VMINUH + Unsupported, 0, 0, 0, 0, 0, // PC_VMINUW + Unsupported, 0, 0, 0, 0, 0, // PC_VMRGHB + Unsupported, 0, 0, 0, 0, 0, // PC_VMRGHH + Unsupported, 0, 0, 0, 0, 0, // PC_VMRGHW + Unsupported, 0, 0, 0, 0, 0, // PC_VMRGLB + Unsupported, 0, 0, 0, 0, 0, // PC_VMRGLH + Unsupported, 0, 0, 0, 0, 0, // PC_VMRGLW + Unsupported, 0, 0, 0, 0, 0, // PC_VMULESB + Unsupported, 0, 0, 0, 0, 0, // PC_VMULESH + Unsupported, 0, 0, 0, 0, 0, // PC_VMULEUB + Unsupported, 0, 0, 0, 0, 0, // PC_VMULEUH + Unsupported, 0, 0, 0, 0, 0, // PC_VMULOSB + Unsupported, 0, 0, 0, 0, 0, // PC_VMULOSH + Unsupported, 0, 0, 0, 0, 0, // PC_VMULOUB + Unsupported, 0, 0, 0, 0, 0, // PC_VMULOUH + Unsupported, 0, 0, 0, 0, 0, // PC_VNOR + Unsupported, 0, 0, 0, 0, 0, // PC_VOR + Unsupported, 0, 0, 0, 0, 0, // PC_VPKPX + Unsupported, 0, 0, 0, 0, 0, // PC_VPKSHSS + Unsupported, 0, 0, 0, 0, 0, // PC_VPKSHUS + Unsupported, 0, 0, 0, 0, 0, // PC_VPKSWSS + Unsupported, 0, 0, 0, 0, 0, // PC_VPKSWUS + Unsupported, 0, 0, 0, 0, 0, // PC_VPKUHUM + Unsupported, 0, 0, 0, 0, 0, // PC_VPKUHUS + Unsupported, 0, 0, 0, 0, 0, // PC_VPKUWUM + Unsupported, 0, 0, 0, 0, 0, // PC_VPKUWUS + Unsupported, 0, 0, 0, 0, 0, // PC_VREFP + Unsupported, 0, 0, 0, 0, 0, // PC_VRFIM + Unsupported, 0, 0, 0, 0, 0, // PC_VRFIN + Unsupported, 0, 0, 0, 0, 0, // PC_VRFIP + Unsupported, 0, 0, 0, 0, 0, // PC_VRFIZ + Unsupported, 0, 0, 0, 0, 0, // PC_VRLB + Unsupported, 0, 0, 0, 0, 0, // PC_VRLH + Unsupported, 0, 0, 0, 0, 0, // PC_VRLW + Unsupported, 0, 0, 0, 0, 0, // PC_VRSQRTEFP + Unsupported, 0, 0, 0, 0, 0, // PC_VSL + Unsupported, 0, 0, 0, 0, 0, // PC_VSLB + Unsupported, 0, 0, 0, 0, 0, // PC_VSLH + Unsupported, 0, 0, 0, 0, 0, // PC_VSLO + Unsupported, 0, 0, 0, 0, 0, // PC_VSLW + Unsupported, 0, 0, 0, 0, 0, // PC_VSPLTB + Unsupported, 0, 0, 0, 0, 0, // PC_VSPLTH + Unsupported, 0, 0, 0, 0, 0, // PC_VSPLTW + Unsupported, 0, 0, 0, 0, 0, // PC_VSPLTISB + Unsupported, 0, 0, 0, 0, 0, // PC_VSPLTISH + Unsupported, 0, 0, 0, 0, 0, // PC_VSPLTISW + Unsupported, 0, 0, 0, 0, 0, // PC_VSR + Unsupported, 0, 0, 0, 0, 0, // PC_VSRAB + Unsupported, 0, 0, 0, 0, 0, // PC_VSRAH + Unsupported, 0, 0, 0, 0, 0, // PC_VSRAW + Unsupported, 0, 0, 0, 0, 0, // PC_VSRB + Unsupported, 0, 0, 0, 0, 0, // PC_VSRH + Unsupported, 0, 0, 0, 0, 0, // PC_VSRO + Unsupported, 0, 0, 0, 0, 0, // PC_VSRW + Unsupported, 0, 0, 0, 0, 0, // PC_VSUBCUW + Unsupported, 0, 0, 0, 0, 0, // PC_VSUBFP + Unsupported, 0, 0, 0, 0, 0, // PC_VSUBSBS + Unsupported, 0, 0, 0, 0, 0, // PC_VSUBSHS + Unsupported, 0, 0, 0, 0, 0, // PC_VSUBSWS + Unsupported, 0, 0, 0, 0, 0, // PC_VSUBUBM + Unsupported, 0, 0, 0, 0, 0, // PC_VSUBUBS + Unsupported, 0, 0, 0, 0, 0, // PC_VSUBUHM + Unsupported, 0, 0, 0, 0, 0, // PC_VSUBUHS + Unsupported, 0, 0, 0, 0, 0, // PC_VSUBUWM + Unsupported, 0, 0, 0, 0, 0, // PC_VSUBUWS + Unsupported, 0, 0, 0, 0, 0, // PC_VSUMSWS + Unsupported, 0, 0, 0, 0, 0, // PC_VSUFPMSWS + Unsupported, 0, 0, 0, 0, 0, // PC_VSUFWASBS + Unsupported, 0, 0, 0, 0, 0, // PC_VSUFWASHS + Unsupported, 0, 0, 0, 0, 0, // PC_VSUFWAUBS + Unsupported, 0, 0, 0, 0, 0, // PC_VUPKHPX + Unsupported, 0, 0, 0, 0, 0, // PC_VUPKHSB + Unsupported, 0, 0, 0, 0, 0, // PC_VUPKHSH + Unsupported, 0, 0, 0, 0, 0, // PC_VUPKLPX + Unsupported, 0, 0, 0, 0, 0, // PC_VUPKLSB + Unsupported, 0, 0, 0, 0, 0, // PC_VUPKLSH + Unsupported, 0, 0, 0, 0, 0, // PC_VXOR + Unsupported, 0, 0, 0, 0, 0, // PC_VMADDFP + Unsupported, 0, 0, 0, 0, 0, // PC_VMHADDSHS + Unsupported, 0, 0, 0, 0, 0, // PC_VMHRADDSHS + Unsupported, 0, 0, 0, 0, 0, // PC_VMLADDUHM + Unsupported, 0, 0, 0, 0, 0, // PC_VMSUMMBM + Unsupported, 0, 0, 0, 0, 0, // PC_VMSUMSHM + Unsupported, 0, 0, 0, 0, 0, // PC_VMSUMSHS + Unsupported, 0, 0, 0, 0, 0, // PC_VMSUMUBM + Unsupported, 0, 0, 0, 0, 0, // PC_VMSUMUHM + Unsupported, 0, 0, 0, 0, 0, // PC_VMSUMUHS + Unsupported, 0, 0, 0, 0, 0, // PC_VNMSUBFP + Unsupported, 0, 0, 0, 0, 0, // PC_VPERM + Unsupported, 0, 0, 0, 0, 0, // PC_VSEL + Unsupported, 0, 0, 0, 0, 0, // PC_VSLDOI + Unsupported, 0, 0, 0, 0, 0, // PC_VMR + Unsupported, 0, 0, 0, 0, 0, // PC_VMRP + IU, 0, 0, 0, 0, 0, // PC_SLE + IU, 0, 0, 0, 0, 0, // PC_SLEQ + IU, 0, 0, 0, 0, 0, // PC_SLIQ + IU, 0, 0, 0, 0, 0, // PC_SLLIQ + IU, 0, 0, 0, 0, 0, // PC_SLLQ + IU, 0, 0, 0, 0, 0, // PC_SLQ + IU, 0, 0, 0, 0, 0, // PC_SRAIQ + IU, 0, 0, 0, 0, 0, // PC_SRAQ + IU, 0, 0, 0, 0, 0, // PC_SRE + IU, 0, 0, 0, 0, 0, // PC_SREA + IU, 0, 0, 0, 0, 0, // PC_SREQ + IU, 0, 0, 0, 0, 0, // PC_SRIQ + IU, 0, 0, 0, 0, 0, // PC_SRLIQ + IU, 0, 0, 0, 0, 0, // PC_SRLQ + IU, 0, 0, 0, 0, 0, // PC_SRQ + IU, 0, 0, 0, 0, 0, // PC_MASKG + IU, 0, 0, 0, 0, 0, // PC_MASKIR + IU, 0, 0, 0, 0, 0, // PC_LSCBX + IU, 0, 0, 0, 0, 0, // PC_DIV + IU, 0, 0, 0, 0, 0, // PC_DIVS + IU, 0, 0, 0, 0, 0, // PC_DOZ + IU, 0, 0, 0, 0, 0, // PC_MUL + IU, 0, 0, 0, 0, 0, // PC_NABS + IU, 0, 0, 0, 0, 0, // PC_ABS + IU, 0, 0, 0, 0, 0, // PC_CLCS + IU, 0, 0, 0, 0, 0, // PC_DOZI + IU, 0, 0, 0, 0, 0, // PC_RLMI + IU, 0, 0, 0, 0, 0, // PC_RRIB +}; + +static void advance(int stageCount, int oldStage, int newStage) { + PCode *instr = pipeline[oldStage].instr; + int cycles = instruction_timing[instr->op].cycles[newStage - stageCount]; + pipeline[newStage].instr = instr; + pipeline[newStage].remaining = cycles; + pipeline[oldStage].instr = NULL; +} + +static void complete_instruction(int stage) { + pipeline[stage].instr = NULL; +} + +static int latency(PCode *instr) { + int cycles = instruction_timing[instr->op].latency; + if (PCODE_FLAG_SET_F(instr) & fRecordBit) + cycles += 2; + if (instr->op == PC_LMW || instr->op == PC_STMW) + cycles += instr->argCount - 2; + return cycles; +} + +static void initialize(void) { + int stage; + + for (stage = 0; stage < NumStages; stage++) + pipeline[stage].instr = NULL; +} + +static int can_issue(PCode *instr) { + int stage = instruction_timing[instr->op].stage; + if (stage == Serialize) + stage = IU; + if (pipeline[stage].instr) + return 0; + return 1; +} + +static void issue(PCode *instr) { + int stage = instruction_timing[instr->op].stage; + int cycles = instruction_timing[instr->op].cycles[IU]; + if (stage == Serialize) + stage = IU; + pipeline[stage].instr = instr; + pipeline[stage].remaining = cycles; +} + +static void advance_clock(void) { + int stage; + + for (stage = 0; stage < NumStages; stage++) { + if (pipeline[stage].instr && pipeline[stage].remaining) + --pipeline[stage].remaining; + } + + if (pipeline[IU].instr && pipeline[IU].remaining == 0) + complete_instruction(IU); + if (pipeline[FWA].instr && pipeline[FWA].remaining == 0) + complete_instruction(FWA); + if (pipeline[BPU].instr && pipeline[BPU].remaining == 0) + complete_instruction(BPU); + + if (pipeline[FPA].instr && pipeline[FPA].remaining == 0 && !pipeline[FWA].instr) + advance(1, FPA, FWA); + if (pipeline[FPM].instr && pipeline[FPM].remaining == 0 && !pipeline[FPA].instr) + advance(1, FPM, FPA); + if (pipeline[FD].instr && pipeline[FD].remaining == 0 && !pipeline[FPM].instr) + advance(1, FD, FPM); +} + +static int serializes(PCode *instr) { + return instruction_timing[instr->op].stage == Serialize; +} + +MachineInfo machine601 = { + 2, + 0, + 0, + &latency, + &initialize, + &can_issue, + &issue, + &advance_clock, + &serializes, + &default_uses_vpermute_unit +}; diff --git a/compiler_and_linker/unsorted/MachineSimulation603.c b/compiler_and_linker/unsorted/MachineSimulation603.c new file mode 100644 index 0000000..49d1ea0 --- /dev/null +++ b/compiler_and_linker/unsorted/MachineSimulation603.c @@ -0,0 +1,626 @@ +#include "compiler/Scheduler.h" +#include "compiler/PCode.h" +#include "compiler/PCodeInfo.h" + +// this is actually for 603e, but i couldn't find the 603 doc +// https://www.nxp.com/docs/en/reference-manual/MPC603EUM.pdf + +typedef enum Stage { + BPU, // Branch Prediction Unit + IU, // Integer Unit + LSU1, // Load/Store Unit + LSU2, + FPU1, // Floating Point Unit + FPU2, + FPU3, + SRU, // System Register Unit + NumStages +} Stage; + +static struct { + // the instruction currently in this pipeline stage + PCode *instr; + + // how many cycles are left for this instruction to finish + int remaining; +} pipeline[NumStages]; + +enum { + MaxEntries = 5 +}; + +static struct { + // how many entries remain unused in the queue + unsigned int free; + + // how many entries are currently used in the queue + unsigned int used; + + // the index of the next instruction that will be retired + unsigned int nextToRetire; + + // the index of the next free slot that will be used when an instruction is dispatched + unsigned int nextFreeSlot; + + // circular array of entries in the completion queue + struct { + PCode *instr; + int completed; + } entries[MaxEntries]; +} completionbuffers; + +static struct { + // the initial stage for this instruction + Stage stage; + + // the total amount of cycles required by this instruction + char latency; + + // how long it takes to finish each stage + char cycles[3]; + + // does this instruction serialise? + char serializes; +} instruction_timing[OPCODE_MAX] = { + BPU, 0, 0, 0, 0, 1, // PC_B + BPU, 0, 0, 0, 0, 1, // PC_BL + BPU, 0, 0, 0, 0, 1, // PC_BC + BPU, 0, 0, 0, 0, 1, // PC_BCLR + BPU, 0, 0, 0, 0, 1, // PC_BCCTR + BPU, 0, 0, 0, 0, 1, // PC_BT + BPU, 0, 0, 0, 0, 1, // PC_BTLR + BPU, 0, 0, 0, 0, 1, // PC_BTCTR + BPU, 0, 0, 0, 0, 1, // PC_BF + BPU, 0, 0, 0, 0, 1, // PC_BFLR + BPU, 0, 0, 0, 0, 1, // PC_BFCTR + BPU, 0, 0, 0, 0, 1, // PC_BDNZ + BPU, 0, 0, 0, 0, 1, // PC_BDNZT + BPU, 0, 0, 0, 0, 1, // PC_BDNZF + BPU, 0, 0, 0, 0, 1, // PC_BDZ + BPU, 0, 0, 0, 0, 1, // PC_BDZT + BPU, 0, 0, 0, 0, 1, // PC_BDZF + BPU, 0, 0, 0, 0, 1, // PC_BLR + BPU, 0, 0, 0, 0, 1, // PC_BCTR + BPU, 0, 0, 0, 0, 1, // PC_BCTRL + BPU, 0, 0, 0, 0, 1, // PC_BLRL + LSU1, 2, 1, 1, 0, 0, // PC_LBZ + LSU1, 2, 1, 1, 0, 0, // PC_LBZU + LSU1, 2, 1, 1, 0, 0, // PC_LBZX + LSU1, 2, 1, 1, 0, 0, // PC_LBZUX + LSU1, 2, 1, 1, 0, 0, // PC_LHZ + LSU1, 2, 1, 1, 0, 0, // PC_LHZU + LSU1, 2, 1, 1, 0, 0, // PC_LHZX + LSU1, 2, 1, 1, 0, 0, // PC_LHZUX + LSU1, 2, 1, 1, 0, 0, // PC_LHA + LSU1, 2, 1, 1, 0, 0, // PC_LHAU + LSU1, 2, 1, 1, 0, 0, // PC_LHAX + LSU1, 2, 1, 1, 0, 0, // PC_LHAUX + LSU1, 2, 1, 1, 0, 0, // PC_LHBRX + LSU1, 2, 1, 1, 0, 0, // PC_LWZ + LSU1, 2, 1, 1, 0, 0, // PC_LWZU + LSU1, 2, 1, 1, 0, 0, // PC_LWZX + LSU1, 2, 1, 1, 0, 0, // PC_LWZUX + LSU1, 2, 1, 1, 0, 0, // PC_LWBRX + LSU1, 2, 1, 1, 0, 0, // PC_LMW + LSU1, 2, 1, 1, 0, 0, // PC_STB + LSU1, 2, 1, 1, 0, 0, // PC_STBU + LSU1, 2, 1, 1, 0, 0, // PC_STBX + LSU1, 2, 1, 1, 0, 0, // PC_STBUX + LSU1, 2, 1, 1, 0, 0, // PC_STH + LSU1, 2, 1, 1, 0, 0, // PC_STHU + LSU1, 2, 1, 1, 0, 0, // PC_STHX + LSU1, 2, 1, 1, 0, 0, // PC_STHUX + LSU1, 2, 1, 1, 0, 0, // PC_STHBRX + LSU1, 2, 1, 1, 0, 0, // PC_STW + LSU1, 2, 1, 1, 0, 0, // PC_STWU + LSU1, 2, 1, 1, 0, 0, // PC_STWX + LSU1, 2, 1, 1, 0, 0, // PC_STWUX + LSU1, 2, 1, 1, 0, 0, // PC_STWBRX + LSU1, 2, 1, 1, 0, 0, // PC_STMW + LSU1, 2, 1, 1, 0, 0, // PC_DCBF + LSU1, 2, 1, 1, 0, 0, // PC_DCBST + LSU1, 2, 1, 1, 0, 0, // PC_DCBT + LSU1, 2, 1, 1, 0, 0, // PC_DCBTST + LSU1, 2, 1, 1, 0, 0, // PC_DCBZ + IU, 1, 1, 0, 0, 0, // PC_ADD + IU, 1, 1, 0, 0, 0, // PC_ADDC + IU, 1, 1, 0, 0, 0, // PC_ADDE + IU, 1, 1, 0, 0, 0, // PC_ADDI + IU, 1, 1, 0, 0, 0, // PC_ADDIC + IU, 1, 1, 0, 0, 0, // PC_ADDICR + IU, 1, 1, 0, 0, 0, // PC_ADDIS + IU, 1, 1, 0, 0, 0, // PC_ADDME + IU, 1, 1, 0, 0, 0, // PC_ADDZE + IU, 37, 37, 0, 0, 0, // PC_DIVW + IU, 37, 37, 0, 0, 0, // PC_DIVWU + IU, 5, 5, 0, 0, 0, // PC_MULHW + IU, 5, 5, 0, 0, 0, // PC_MULHWU + IU, 3, 3, 0, 0, 0, // PC_MULLI + IU, 5, 5, 0, 0, 0, // PC_MULLW + IU, 1, 1, 0, 0, 0, // PC_NEG + IU, 1, 1, 0, 0, 0, // PC_SUBF + IU, 1, 1, 0, 0, 0, // PC_SUBFC + IU, 1, 1, 0, 0, 0, // PC_SUBFE + IU, 1, 1, 0, 0, 0, // PC_SUBFIC + IU, 1, 1, 0, 0, 0, // PC_SUBFME + IU, 1, 1, 0, 0, 0, // PC_SUBFZE + IU, 3, 1, 0, 0, 0, // PC_CMPI + IU, 3, 1, 0, 0, 0, // PC_CMP + IU, 3, 1, 0, 0, 0, // PC_CMPLI + IU, 3, 1, 0, 0, 0, // PC_CMPL + IU, 1, 1, 0, 0, 0, // PC_ANDI + IU, 1, 1, 0, 0, 0, // PC_ANDIS + IU, 1, 1, 0, 0, 0, // PC_ORI + IU, 1, 1, 0, 0, 0, // PC_ORIS + IU, 1, 1, 0, 0, 0, // PC_XORI + IU, 1, 1, 0, 0, 0, // PC_XORIS + IU, 1, 1, 0, 0, 0, // PC_AND + IU, 1, 1, 0, 0, 0, // PC_OR + IU, 1, 1, 0, 0, 0, // PC_XOR + IU, 1, 1, 0, 0, 0, // PC_NAND + IU, 1, 1, 0, 0, 0, // PC_NOR + IU, 1, 1, 0, 0, 0, // PC_EQV + IU, 1, 1, 0, 0, 0, // PC_ANDC + IU, 1, 1, 0, 0, 0, // PC_ORC + IU, 1, 1, 0, 0, 0, // PC_EXTSB + IU, 1, 1, 0, 0, 0, // PC_EXTSH + IU, 1, 1, 0, 0, 0, // PC_CNTLZW + IU, 1, 1, 0, 0, 0, // PC_RLWINM + IU, 1, 1, 0, 0, 0, // PC_RLWNM + IU, 1, 1, 0, 0, 0, // PC_RLWIMI + IU, 1, 1, 0, 0, 0, // PC_SLW + IU, 1, 1, 0, 0, 0, // PC_SRW + IU, 1, 1, 0, 0, 0, // PC_SRAWI + IU, 1, 1, 0, 0, 0, // PC_SRAW + SRU, 1, 1, 0, 0, 0, // PC_CRAND + SRU, 1, 1, 0, 0, 0, // PC_CRANDC + SRU, 1, 1, 0, 0, 0, // PC_CREQV + SRU, 1, 1, 0, 0, 0, // PC_CRNAND + SRU, 1, 1, 0, 0, 0, // PC_CRNOR + SRU, 1, 1, 0, 0, 0, // PC_CROR + SRU, 1, 1, 0, 0, 0, // PC_CRORC + SRU, 1, 1, 0, 0, 0, // PC_CRXOR + SRU, 1, 1, 0, 0, 0, // PC_MCRF + SRU, 2, 2, 0, 0, 0, // PC_MTXER + SRU, 2, 2, 0, 0, 0, // PC_MTCTR + SRU, 2, 2, 0, 0, 0, // PC_MTLR + SRU, 1, 1, 0, 0, 0, // PC_MTCRF + SRU, 1, 1, 0, 0, 1, // PC_MTMSR + SRU, 1, 1, 0, 0, 1, // PC_MTSPR + SRU, 1, 1, 0, 0, 1, // PC_MFMSR + SRU, 1, 1, 0, 0, 1, // PC_MFSPR + SRU, 1, 1, 0, 0, 0, // PC_MFXER + SRU, 1, 1, 0, 0, 0, // PC_MFCTR + SRU, 1, 1, 0, 0, 0, // PC_MFLR + SRU, 1, 1, 0, 0, 0, // PC_MFCR + FPU1, 3, 1, 1, 1, 0, // PC_MFFS + FPU1, 3, 1, 1, 1, 0, // PC_MTFSF + SRU, 1, 1, 0, 0, 1, // PC_EIEIO + SRU, 1, 1, 0, 0, 1, // PC_ISYNC + SRU, 1, 1, 0, 0, 1, // PC_SYNC + SRU, 1, 1, 0, 0, 1, // PC_RFI + IU, 1, 1, 0, 0, 0, // PC_LI + IU, 1, 1, 0, 0, 0, // PC_LIS + IU, 1, 1, 0, 0, 0, // PC_MR + IU, 1, 1, 0, 0, 0, // PC_NOP + IU, 1, 1, 0, 0, 0, // PC_NOT + LSU1, 2, 1, 1, 0, 0, // PC_LFS + LSU1, 2, 1, 1, 0, 0, // PC_LFSU + LSU1, 2, 1, 1, 0, 0, // PC_LFSX + LSU1, 2, 1, 1, 0, 0, // PC_LFSUX + LSU1, 2, 1, 1, 0, 0, // PC_LFD + LSU1, 2, 1, 1, 0, 0, // PC_LFDU + LSU1, 2, 1, 1, 0, 0, // PC_LFDX + LSU1, 2, 1, 1, 0, 0, // PC_LFDUX + LSU1, 2, 1, 1, 0, 0, // PC_STFS + LSU1, 2, 1, 1, 0, 0, // PC_STFSU + LSU1, 2, 1, 1, 0, 0, // PC_STFSX + LSU1, 2, 1, 1, 0, 0, // PC_STFSUX + LSU1, 2, 1, 1, 0, 0, // PC_STFD + LSU1, 2, 1, 1, 0, 0, // PC_STFDU + LSU1, 2, 1, 1, 0, 0, // PC_STFDX + LSU1, 2, 1, 1, 0, 0, // PC_STFDUX + FPU1, 3, 1, 1, 1, 0, // PC_FMR + FPU1, 3, 1, 1, 1, 0, // PC_FABS + FPU1, 3, 1, 1, 1, 0, // PC_FNEG + FPU1, 3, 1, 1, 1, 0, // PC_FNABS + FPU1, 3, 1, 1, 1, 0, // PC_FADD + FPU1, 3, 1, 1, 1, 0, // PC_FADDS + FPU1, 3, 1, 1, 1, 0, // PC_FSUB + FPU1, 3, 1, 1, 1, 0, // PC_FSUBS + FPU1, 4, 2, 1, 1, 0, // PC_FMUL + FPU1, 3, 1, 1, 1, 0, // PC_FMULS + FPU1, 33, 33, 0, 0, 0, // PC_FDIV + FPU1, 18, 18, 0, 0, 0, // PC_FDIVS + FPU1, 4, 2, 1, 1, 0, // PC_FMADD + FPU1, 3, 1, 1, 1, 0, // PC_FMADDS + FPU1, 4, 2, 1, 1, 0, // PC_FMSUB + FPU1, 3, 1, 1, 1, 0, // PC_FMSUBS + FPU1, 4, 2, 1, 1, 0, // PC_FNMADD + FPU1, 3, 1, 1, 1, 0, // PC_FNMADDS + FPU1, 4, 2, 1, 1, 0, // PC_FNMSUB + FPU1, 3, 1, 1, 1, 0, // PC_FNMSUBS + FPU1, 18, 18, 0, 0, 0, // PC_FRES + FPU1, 3, 1, 1, 1, 0, // PC_FRSQRTE + FPU1, 3, 1, 1, 1, 0, // PC_FSEL + FPU1, 3, 1, 1, 1, 0, // PC_FRSP + FPU1, 3, 1, 1, 1, 0, // PC_FCTIW + FPU1, 3, 1, 1, 1, 0, // PC_FCTIWZ + FPU1, 5, 1, 1, 1, 0, // PC_FCMPU + FPU1, 5, 1, 1, 1, 0, // PC_FCMPO + LSU1, 1, 1, 0, 0, 0, // PC_LWARX + LSU1, 1, 1, 0, 0, 0, // PC_LSWI + LSU1, 1, 1, 0, 0, 0, // PC_LSWX + LSU1, 1, 1, 0, 0, 0, // PC_STFIWX + LSU1, 1, 1, 0, 0, 0, // PC_STSWI + LSU1, 1, 1, 0, 0, 0, // PC_STSWX + LSU1, 1, 1, 0, 0, 0, // PC_STWCX + IU, 1, 1, 0, 0, 1, // PC_ECIWX + IU, 1, 1, 0, 0, 1, // PC_ECOWX + IU, 1, 1, 0, 0, 0, // PC_DCBI + IU, 1, 1, 0, 0, 0, // PC_ICBI + IU, 1, 1, 0, 0, 0, // PC_MCRFS + IU, 1, 1, 0, 0, 0, // PC_MCRXR + IU, 1, 1, 0, 0, 0, // PC_MFTB + IU, 1, 1, 0, 0, 0, // PC_MFSR + IU, 1, 1, 0, 0, 0, // PC_MTSR + IU, 1, 1, 0, 0, 0, // PC_MFSRIN + IU, 1, 1, 0, 0, 0, // PC_MTSRIN + IU, 1, 1, 0, 0, 0, // PC_MTFSB0 + IU, 1, 1, 0, 0, 0, // PC_MTFSB1 + IU, 1, 1, 0, 0, 0, // PC_MTFSFI + IU, 1, 1, 0, 0, 1, // PC_SC + FPU1, 1, 1, 0, 0, 0, // PC_FSQRT + FPU1, 1, 1, 0, 0, 0, // PC_FSQRTS + IU, 1, 1, 0, 0, 0, // PC_TLBIA + IU, 1, 1, 0, 0, 0, // PC_TLBIE + IU, 1, 1, 0, 0, 0, // PC_TLBLD + IU, 1, 1, 0, 0, 0, // PC_TLBLI + IU, 1, 1, 0, 0, 0, // PC_TLBSYNC + IU, 1, 1, 0, 0, 1, // PC_TW + IU, 1, 1, 0, 0, 1, // PC_TRAP + IU, 1, 1, 0, 0, 1, // PC_TWI + IU, 1, 1, 0, 0, 1, // PC_OPWORD + IU, 1, 1, 0, 0, 0, // PC_MFROM + IU, 1, 1, 0, 0, 1, // PC_DSA + IU, 1, 1, 0, 0, 1, // PC_ESA + IU, 0, 0, 0, 0, 0, // PC_DCCCI + IU, 0, 0, 0, 0, 0, // PC_DCREAD + IU, 0, 0, 0, 0, 0, // PC_ICBT + IU, 0, 0, 0, 0, 0, // PC_ICCCI + IU, 0, 0, 0, 0, 0, // PC_ICREAD + IU, 0, 0, 0, 0, 0, // PC_RFCI + IU, 0, 0, 0, 0, 0, // PC_TLBRE + IU, 0, 0, 0, 0, 0, // PC_TLBSX + IU, 0, 0, 0, 0, 0, // PC_TLBWE + IU, 0, 0, 0, 0, 0, // PC_WRTEE + IU, 0, 0, 0, 0, 0, // PC_WRTEEI + IU, 0, 0, 0, 0, 0, // PC_MFDCR + IU, 0, 0, 0, 0, 0, // PC_MTDCR + IU, 0, 0, 0, 0, 0, // PC_DCBA + BPU, 0, 0, 0, 0, 0, // PC_DSS + BPU, 0, 0, 0, 0, 0, // PC_DSSALL + BPU, 0, 0, 0, 0, 0, // PC_DST + BPU, 0, 0, 0, 0, 0, // PC_DSTT + BPU, 0, 0, 0, 0, 0, // PC_DSTST + BPU, 0, 0, 0, 0, 0, // PC_DSTSTT + BPU, 0, 0, 0, 0, 0, // PC_LVEBX + BPU, 0, 0, 0, 0, 0, // PC_LVEHX + BPU, 0, 0, 0, 0, 0, // PC_LVEWX + BPU, 0, 0, 0, 0, 0, // PC_LVSL + BPU, 0, 0, 0, 0, 0, // PC_LVSR + BPU, 0, 0, 0, 0, 0, // PC_LVX + BPU, 0, 0, 0, 0, 0, // PC_LVXL + BPU, 0, 0, 0, 0, 0, // PC_STVEBX + BPU, 0, 0, 0, 0, 0, // PC_STVEHX + BPU, 0, 0, 0, 0, 0, // PC_STVEWX + BPU, 0, 0, 0, 0, 0, // PC_STVX + BPU, 0, 0, 0, 0, 0, // PC_STVXL + BPU, 0, 0, 0, 0, 0, // PC_MFVSCR + BPU, 0, 0, 0, 0, 0, // PC_MTVSCR + BPU, 0, 0, 0, 0, 0, // PC_VADDCUW + BPU, 0, 0, 0, 0, 0, // PC_VADDFP + BPU, 0, 0, 0, 0, 0, // PC_VADDSBS + BPU, 0, 0, 0, 0, 0, // PC_VADDSHS + BPU, 0, 0, 0, 0, 0, // PC_VADDSWS + BPU, 0, 0, 0, 0, 0, // PC_VADDUBM + BPU, 0, 0, 0, 0, 0, // PC_VADDUBS + BPU, 0, 0, 0, 0, 0, // PC_VADDUHM + BPU, 0, 0, 0, 0, 0, // PC_VADDUHS + BPU, 0, 0, 0, 0, 0, // PC_VADDUWM + BPU, 0, 0, 0, 0, 0, // PC_VADDUWS + BPU, 0, 0, 0, 0, 0, // PC_VAND + BPU, 0, 0, 0, 0, 0, // PC_VANDC + BPU, 0, 0, 0, 0, 0, // PC_VAVGSB + BPU, 0, 0, 0, 0, 0, // PC_VAVGSH + BPU, 0, 0, 0, 0, 0, // PC_VAVGSW + BPU, 0, 0, 0, 0, 0, // PC_VAVGUB + BPU, 0, 0, 0, 0, 0, // PC_VAVGUH + BPU, 0, 0, 0, 0, 0, // PC_VAVGUW + BPU, 0, 0, 0, 0, 0, // PC_VCFSX + BPU, 0, 0, 0, 0, 0, // PC_VCFUX + BPU, 0, 0, 0, 0, 0, // PC_VCMPBFP + BPU, 0, 0, 0, 0, 0, // PC_VCMPEQFP + BPU, 0, 0, 0, 0, 0, // PC_VCMPEQUB + BPU, 0, 0, 0, 0, 0, // PC_VCMPEQUH + BPU, 0, 0, 0, 0, 0, // PC_VCMPEQUW + BPU, 0, 0, 0, 0, 0, // PC_VCMPGEFP + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTFP + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTSB + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTSH + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTSW + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTUB + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTUH + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTUW + BPU, 0, 0, 0, 0, 0, // PC_VCTSXS + BPU, 0, 0, 0, 0, 0, // PC_VCTUXS + BPU, 0, 0, 0, 0, 0, // PC_VEXPTEFP + BPU, 0, 0, 0, 0, 0, // PC_VLOGEFP + BPU, 0, 0, 0, 0, 0, // PC_VMAXFP + BPU, 0, 0, 0, 0, 0, // PC_VMAXSB + BPU, 0, 0, 0, 0, 0, // PC_VMAXSH + BPU, 0, 0, 0, 0, 0, // PC_VMAXSW + BPU, 0, 0, 0, 0, 0, // PC_VMAXUB + BPU, 0, 0, 0, 0, 0, // PC_VMAXUH + BPU, 0, 0, 0, 0, 0, // PC_VMAXUW + BPU, 0, 0, 0, 0, 0, // PC_VMINFP + BPU, 0, 0, 0, 0, 0, // PC_VMINSB + BPU, 0, 0, 0, 0, 0, // PC_VMINSH + BPU, 0, 0, 0, 0, 0, // PC_VMINSW + BPU, 0, 0, 0, 0, 0, // PC_VMINUB + BPU, 0, 0, 0, 0, 0, // PC_VMINUH + BPU, 0, 0, 0, 0, 0, // PC_VMINUW + BPU, 0, 0, 0, 0, 0, // PC_VMRGHB + BPU, 0, 0, 0, 0, 0, // PC_VMRGHH + BPU, 0, 0, 0, 0, 0, // PC_VMRGHW + BPU, 0, 0, 0, 0, 0, // PC_VMRGLB + BPU, 0, 0, 0, 0, 0, // PC_VMRGLH + BPU, 0, 0, 0, 0, 0, // PC_VMRGLW + BPU, 0, 0, 0, 0, 0, // PC_VMULESB + BPU, 0, 0, 0, 0, 0, // PC_VMULESH + BPU, 0, 0, 0, 0, 0, // PC_VMULEUB + BPU, 0, 0, 0, 0, 0, // PC_VMULEUH + BPU, 0, 0, 0, 0, 0, // PC_VMULOSB + BPU, 0, 0, 0, 0, 0, // PC_VMULOSH + BPU, 0, 0, 0, 0, 0, // PC_VMULOUB + BPU, 0, 0, 0, 0, 0, // PC_VMULOUH + BPU, 0, 0, 0, 0, 0, // PC_VNOR + BPU, 0, 0, 0, 0, 0, // PC_VOR + BPU, 0, 0, 0, 0, 0, // PC_VPKPX + BPU, 0, 0, 0, 0, 0, // PC_VPKSHSS + BPU, 0, 0, 0, 0, 0, // PC_VPKSHUS + BPU, 0, 0, 0, 0, 0, // PC_VPKSWSS + BPU, 0, 0, 0, 0, 0, // PC_VPKSWUS + BPU, 0, 0, 0, 0, 0, // PC_VPKUHUM + BPU, 0, 0, 0, 0, 0, // PC_VPKUHUS + BPU, 0, 0, 0, 0, 0, // PC_VPKUWUM + BPU, 0, 0, 0, 0, 0, // PC_VPKUWUS + BPU, 0, 0, 0, 0, 0, // PC_VREFP + BPU, 0, 0, 0, 0, 0, // PC_VRFIM + BPU, 0, 0, 0, 0, 0, // PC_VRFIN + BPU, 0, 0, 0, 0, 0, // PC_VRFIP + BPU, 0, 0, 0, 0, 0, // PC_VRFIZ + BPU, 0, 0, 0, 0, 0, // PC_VRLB + BPU, 0, 0, 0, 0, 0, // PC_VRLH + BPU, 0, 0, 0, 0, 0, // PC_VRLW + BPU, 0, 0, 0, 0, 0, // PC_VRSQRTEFP + BPU, 0, 0, 0, 0, 0, // PC_VSL + BPU, 0, 0, 0, 0, 0, // PC_VSLB + BPU, 0, 0, 0, 0, 0, // PC_VSLH + BPU, 0, 0, 0, 0, 0, // PC_VSLO + BPU, 0, 0, 0, 0, 0, // PC_VSLW + BPU, 0, 0, 0, 0, 0, // PC_VSPLTB + BPU, 0, 0, 0, 0, 0, // PC_VSPLTH + BPU, 0, 0, 0, 0, 0, // PC_VSPLTW + BPU, 0, 0, 0, 0, 0, // PC_VSPLTISB + BPU, 0, 0, 0, 0, 0, // PC_VSPLTISH + BPU, 0, 0, 0, 0, 0, // PC_VSPLTISW + BPU, 0, 0, 0, 0, 0, // PC_VSR + BPU, 0, 0, 0, 0, 0, // PC_VSRAB + BPU, 0, 0, 0, 0, 0, // PC_VSRAH + BPU, 0, 0, 0, 0, 0, // PC_VSRAW + BPU, 0, 0, 0, 0, 0, // PC_VSRB + BPU, 0, 0, 0, 0, 0, // PC_VSRH + BPU, 0, 0, 0, 0, 0, // PC_VSRO + BPU, 0, 0, 0, 0, 0, // PC_VSRW + BPU, 0, 0, 0, 0, 0, // PC_VSUBCUW + BPU, 0, 0, 0, 0, 0, // PC_VSUBFP + BPU, 0, 0, 0, 0, 0, // PC_VSUBSBS + BPU, 0, 0, 0, 0, 0, // PC_VSUBSHS + BPU, 0, 0, 0, 0, 0, // PC_VSUBSWS + BPU, 0, 0, 0, 0, 0, // PC_VSUBUBM + BPU, 0, 0, 0, 0, 0, // PC_VSUBUBS + BPU, 0, 0, 0, 0, 0, // PC_VSUBUHM + BPU, 0, 0, 0, 0, 0, // PC_VSUBUHS + BPU, 0, 0, 0, 0, 0, // PC_VSUBUWM + BPU, 0, 0, 0, 0, 0, // PC_VSUBUWS + BPU, 0, 0, 0, 0, 0, // PC_VSUMSWS + BPU, 0, 0, 0, 0, 0, // PC_VSUM2SWS + BPU, 0, 0, 0, 0, 0, // PC_VSUM4SBS + BPU, 0, 0, 0, 0, 0, // PC_VSUM4SHS + BPU, 0, 0, 0, 0, 0, // PC_VSUM4UBS + BPU, 0, 0, 0, 0, 0, // PC_VUPKHPX + BPU, 0, 0, 0, 0, 0, // PC_VUPKHSB + BPU, 0, 0, 0, 0, 0, // PC_VUPKHSH + BPU, 0, 0, 0, 0, 0, // PC_VUPKLPX + BPU, 0, 0, 0, 0, 0, // PC_VUPKLSB + BPU, 0, 0, 0, 0, 0, // PC_VUPKLSH + BPU, 0, 0, 0, 0, 0, // PC_VXOR + BPU, 0, 0, 0, 0, 0, // PC_VMADDFP + BPU, 0, 0, 0, 0, 0, // PC_VMHADDSHS + BPU, 0, 0, 0, 0, 0, // PC_VMHRADDSHS + BPU, 0, 0, 0, 0, 0, // PC_VMLADDUHM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMMBM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMSHM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMSHS + BPU, 0, 0, 0, 0, 0, // PC_VMSUMUBM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMUHM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMUHS + BPU, 0, 0, 0, 0, 0, // PC_VNMSUBFP + BPU, 0, 0, 0, 0, 0, // PC_VPERM + BPU, 0, 0, 0, 0, 0, // PC_VSEL + BPU, 0, 0, 0, 0, 0, // PC_VSLDOI + BPU, 0, 0, 0, 0, 0, // PC_VMR + BPU, 0, 0, 0, 0, 0, // PC_VMRP + BPU, 0, 0, 0, 0, 0, // PC_SLE + BPU, 0, 0, 0, 0, 0, // PC_SLEQ + BPU, 0, 0, 0, 0, 0, // PC_SLIQ + BPU, 0, 0, 0, 0, 0, // PC_SLLIQ + BPU, 0, 0, 0, 0, 0, // PC_SLLQ + BPU, 0, 0, 0, 0, 0, // PC_SLQ + BPU, 0, 0, 0, 0, 0, // PC_SRAIQ + BPU, 0, 0, 0, 0, 0, // PC_SRAQ + BPU, 0, 0, 0, 0, 0, // PC_SRE + BPU, 0, 0, 0, 0, 0, // PC_SREA + BPU, 0, 0, 0, 0, 0, // PC_SREQ + BPU, 0, 0, 0, 0, 0, // PC_SRIQ + BPU, 0, 0, 0, 0, 0, // PC_SRLIQ + BPU, 0, 0, 0, 0, 0, // PC_SRLQ + BPU, 0, 0, 0, 0, 0, // PC_SRQ + BPU, 0, 0, 0, 0, 0, // PC_MASKG + BPU, 0, 0, 0, 0, 0, // PC_MASKIR + BPU, 0, 0, 0, 0, 0, // PC_LSCBX + BPU, 0, 0, 0, 0, 0, // PC_DIV + BPU, 0, 0, 0, 0, 0, // PC_DIVS + BPU, 0, 0, 0, 0, 0, // PC_DOZ + BPU, 0, 0, 0, 0, 0, // PC_MUL + BPU, 0, 0, 0, 0, 0, // PC_NABS + BPU, 0, 0, 0, 0, 0, // PC_ABS + BPU, 0, 0, 0, 0, 0, // PC_CLCS + BPU, 0, 0, 0, 0, 0, // PC_DOZI + BPU, 0, 0, 0, 0, 0, // PC_RLMI + BPU, 0, 0, 0, 0, 0, // PC_RRIB +}; + +static void advance(int firstStage, int oldStage, int newStage) { + PCode *instr = pipeline[oldStage].instr; + int cycles = instruction_timing[instr->op].cycles[newStage - firstStage]; + pipeline[newStage].instr = instr; + pipeline[newStage].remaining = cycles; + pipeline[oldStage].instr = NULL; +} + +static void assign_completion_buffer(PCode *instr) { + completionbuffers.used++; + completionbuffers.free--; + completionbuffers.entries[completionbuffers.nextFreeSlot].instr = instr; + completionbuffers.entries[completionbuffers.nextFreeSlot].completed = 0; + completionbuffers.nextFreeSlot = (completionbuffers.nextFreeSlot + 1) % MaxEntries; +} + +static void complete_instruction(int stage) { + PCode *instr = pipeline[stage].instr; + int buf = 0; + while (buf < MaxEntries && completionbuffers.entries[buf].instr != instr) + buf++; + + completionbuffers.entries[buf].completed = 1; + pipeline[stage].instr = NULL; +} + +static void retire_instruction(void) { + completionbuffers.entries[completionbuffers.nextToRetire].instr = NULL; + completionbuffers.used--; + completionbuffers.free++; + completionbuffers.nextToRetire = (completionbuffers.nextToRetire + 1) % MaxEntries; +} + +static int latency(PCode *instr) { + int cycles = instruction_timing[instr->op].latency; + if (PCODE_FLAG_SET_F(instr) & fRecordBit) + cycles += 2; + if (instr->op == PC_LMW || instr->op == PC_STMW) + cycles += instr->argCount - 2; + return cycles; +} + +static void initialize(void) { + int stage; + int i; + + for (stage = 0; stage < NumStages; stage++) + pipeline[stage].instr = NULL; + + completionbuffers.free = 5; + completionbuffers.used = 0; + completionbuffers.nextToRetire = 0; + completionbuffers.nextFreeSlot = 0; + for (i = 0; i < MaxEntries; i++) + completionbuffers.entries[i].instr = NULL; +} + +static int can_issue(PCode *instr) { + if (completionbuffers.free == 0) + return 0; + if (pipeline[instruction_timing[instr->op].stage].instr) + return 0; + if ((instr->flags & fIsWrite) && pipeline[LSU2].instr && (pipeline[LSU2].instr->flags & fIsWrite)) + return 0; + return 1; +} + +static void issue(PCode *instr) { + int stage = instruction_timing[instr->op].stage; + int cycles = instruction_timing[instr->op].cycles[0]; + assign_completion_buffer(instr); + pipeline[stage].instr = instr; + pipeline[stage].remaining = cycles; +} + +static void advance_clock(void) { + int stage; + + for (stage = 0; stage < NumStages; stage++) { + if (pipeline[stage].instr && pipeline[stage].remaining) + --pipeline[stage].remaining; + } + + if (completionbuffers.used && completionbuffers.entries[completionbuffers.nextToRetire].completed) { + retire_instruction(); + if (completionbuffers.used && completionbuffers.entries[completionbuffers.nextToRetire].completed) { + retire_instruction(); + } + } + + if (pipeline[IU].instr && pipeline[IU].remaining == 0) + complete_instruction(IU); + if (pipeline[LSU2].instr && pipeline[LSU2].remaining == 0) + complete_instruction(LSU2); + if (pipeline[FPU3].instr && pipeline[FPU3].remaining == 0) + complete_instruction(FPU3); + if (pipeline[SRU].instr && pipeline[SRU].remaining == 0) + complete_instruction(SRU); + if (pipeline[BPU].instr && pipeline[BPU].remaining == 0) + complete_instruction(BPU); + + if ( + pipeline[FPU1].instr && + pipeline[FPU1].remaining == 0 && + (pipeline[FPU1].instr->op == PC_FDIV || pipeline[FPU1].instr->op == PC_FDIVS) + ) + complete_instruction(FPU1); + + if (pipeline[FPU2].instr && pipeline[FPU2].remaining == 0 && !pipeline[FPU3].instr) + advance(FPU1, FPU2, FPU3); + if (pipeline[FPU1].instr && pipeline[FPU1].remaining == 0 && !pipeline[FPU2].instr) + advance(FPU1, FPU1, FPU2); + if (pipeline[LSU1].instr && pipeline[LSU1].remaining == 0 && !pipeline[LSU2].instr) + advance(LSU1, LSU1, LSU2); +} + +static int serializes(PCode *instr) { + return instruction_timing[instr->op].serializes; +} + +MachineInfo machine603 = { + 2, + 1, + 0, + &latency, + &initialize, + &can_issue, + &issue, + &advance_clock, + &serializes, + &default_uses_vpermute_unit +}; diff --git a/compiler_and_linker/unsorted/MachineSimulation603e.c b/compiler_and_linker/unsorted/MachineSimulation603e.c new file mode 100644 index 0000000..d3e1e47 --- /dev/null +++ b/compiler_and_linker/unsorted/MachineSimulation603e.c @@ -0,0 +1,650 @@ +#include "compiler/Scheduler.h" +#include "compiler/PCode.h" +#include "compiler/PCodeInfo.h" + +// https://www.nxp.com/docs/en/reference-manual/MPC603EUM.pdf + +typedef enum Stage { + BPU, // Branch Prediction Unit + IU, // Integer Unit + LSU1, // Load/Store Unit + LSU2, + FPU1, // Floating Point Unit + FPU2, + FPU3, + SRU, // System Register Unit + NumStages +} Stage; + +static struct { + // the instruction currently in this pipeline stage + PCode *instr; + + // how many cycles are left for this instruction to finish + int remaining; +} pipeline[NumStages]; + +enum { + MaxEntries = 5 +}; + +static struct { + // how many entries remain unused in the queue + unsigned int free; + + // how many entries are currently used in the queue + unsigned int used; + + // the index of the next instruction that will be retired + unsigned int nextToRetire; + + // the index of the next free slot that will be used when an instruction is dispatched + unsigned int nextFreeSlot; + + // circular array of entries in the completion queue + struct { + PCode *instr; + int completed; + } entries[MaxEntries]; +} completionbuffers; + +static struct { + // the initial stage for this instruction + Stage stage; + + // the total amount of cycles required by this instruction + char latency; + + // how long it takes to finish each stage + char cycles[3]; + + // does this instruction serialise? + char serializes; +} instruction_timing[OPCODE_MAX] = { + BPU, 0, 0, 0, 0, 1, // PC_B + BPU, 0, 0, 0, 0, 1, // PC_BL + BPU, 0, 0, 0, 0, 1, // PC_BC + BPU, 0, 0, 0, 0, 1, // PC_BCLR + BPU, 0, 0, 0, 0, 1, // PC_BCCTR + BPU, 0, 0, 0, 0, 1, // PC_BT + BPU, 0, 0, 0, 0, 1, // PC_BTLR + BPU, 0, 0, 0, 0, 1, // PC_BTCTR + BPU, 0, 0, 0, 0, 1, // PC_BF + BPU, 0, 0, 0, 0, 1, // PC_BFLR + BPU, 0, 0, 0, 0, 1, // PC_BFCTR + BPU, 0, 0, 0, 0, 1, // PC_BDNZ + BPU, 0, 0, 0, 0, 1, // PC_BDNZT + BPU, 0, 0, 0, 0, 1, // PC_BDNZF + BPU, 0, 0, 0, 0, 1, // PC_BDZ + BPU, 0, 0, 0, 0, 1, // PC_BDZT + BPU, 0, 0, 0, 0, 1, // PC_BDZF + BPU, 0, 0, 0, 0, 1, // PC_BLR + BPU, 0, 0, 0, 0, 1, // PC_BCTR + BPU, 0, 0, 0, 0, 1, // PC_BCTRL + BPU, 0, 0, 0, 0, 1, // PC_BLRL + LSU1, 2, 1, 1, 0, 0, // PC_LBZ + LSU1, 2, 1, 1, 0, 0, // PC_LBZU + LSU1, 2, 1, 1, 0, 0, // PC_LBZX + LSU1, 2, 1, 1, 0, 0, // PC_LBZUX + LSU1, 2, 1, 1, 0, 0, // PC_LHZ + LSU1, 2, 1, 1, 0, 0, // PC_LHZU + LSU1, 2, 1, 1, 0, 0, // PC_LHZX + LSU1, 2, 1, 1, 0, 0, // PC_LHZUX + LSU1, 2, 1, 1, 0, 0, // PC_LHA + LSU1, 2, 1, 1, 0, 0, // PC_LHAU + LSU1, 2, 1, 1, 0, 0, // PC_LHAX + LSU1, 2, 1, 1, 0, 0, // PC_LHAUX + LSU1, 2, 1, 1, 0, 0, // PC_LHBRX + LSU1, 2, 1, 1, 0, 0, // PC_LWZ + LSU1, 2, 1, 1, 0, 0, // PC_LWZU + LSU1, 2, 1, 1, 0, 0, // PC_LWZX + LSU1, 2, 1, 1, 0, 0, // PC_LWZUX + LSU1, 2, 1, 1, 0, 0, // PC_LWBRX + LSU1, 2, 1, 1, 0, 0, // PC_LMW + LSU1, 2, 1, 1, 0, 0, // PC_STB + LSU1, 2, 1, 1, 0, 0, // PC_STBU + LSU1, 2, 1, 1, 0, 0, // PC_STBX + LSU1, 2, 1, 1, 0, 0, // PC_STBUX + LSU1, 2, 1, 1, 0, 0, // PC_STH + LSU1, 2, 1, 1, 0, 0, // PC_STHU + LSU1, 2, 1, 1, 0, 0, // PC_STHX + LSU1, 2, 1, 1, 0, 0, // PC_STHUX + LSU1, 2, 1, 1, 0, 0, // PC_STHBRX + LSU1, 2, 1, 1, 0, 0, // PC_STW + LSU1, 2, 1, 1, 0, 0, // PC_STWU + LSU1, 2, 1, 1, 0, 0, // PC_STWX + LSU1, 2, 1, 1, 0, 0, // PC_STWUX + LSU1, 2, 1, 1, 0, 0, // PC_STWBRX + LSU1, 2, 1, 1, 0, 0, // PC_STMW + LSU1, 2, 1, 1, 0, 0, // PC_DCBF + LSU1, 2, 1, 1, 0, 0, // PC_DCBST + LSU1, 2, 1, 1, 0, 0, // PC_DCBT + LSU1, 2, 1, 1, 0, 0, // PC_DCBTST + LSU1, 2, 1, 1, 0, 0, // PC_DCBZ + IU, 1, 1, 0, 0, 0, // PC_ADD + IU, 1, 1, 0, 0, 0, // PC_ADDC + IU, 1, 1, 0, 0, 0, // PC_ADDE + IU, 1, 1, 0, 0, 0, // PC_ADDI + IU, 1, 1, 0, 0, 0, // PC_ADDIC + IU, 1, 1, 0, 0, 0, // PC_ADDICR + IU, 1, 1, 0, 0, 0, // PC_ADDIS + IU, 1, 1, 0, 0, 0, // PC_ADDME + IU, 1, 1, 0, 0, 0, // PC_ADDZE + IU, 37, 37, 0, 0, 0, // PC_DIVW + IU, 37, 37, 0, 0, 0, // PC_DIVWU + IU, 5, 5, 0, 0, 0, // PC_MULHW + IU, 5, 5, 0, 0, 0, // PC_MULHWU + IU, 3, 3, 0, 0, 0, // PC_MULLI + IU, 5, 5, 0, 0, 0, // PC_MULLW + IU, 1, 1, 0, 0, 0, // PC_NEG + IU, 1, 1, 0, 0, 0, // PC_SUBF + IU, 1, 1, 0, 0, 0, // PC_SUBFC + IU, 1, 1, 0, 0, 0, // PC_SUBFE + IU, 1, 1, 0, 0, 0, // PC_SUBFIC + IU, 1, 1, 0, 0, 0, // PC_SUBFME + IU, 1, 1, 0, 0, 0, // PC_SUBFZE + IU, 3, 1, 0, 0, 0, // PC_CMPI + IU, 3, 1, 0, 0, 0, // PC_CMP + IU, 3, 1, 0, 0, 0, // PC_CMPLI + IU, 3, 1, 0, 0, 0, // PC_CMPL + IU, 1, 1, 0, 0, 0, // PC_ANDI + IU, 1, 1, 0, 0, 0, // PC_ANDIS + IU, 1, 1, 0, 0, 0, // PC_ORI + IU, 1, 1, 0, 0, 0, // PC_ORIS + IU, 1, 1, 0, 0, 0, // PC_XORI + IU, 1, 1, 0, 0, 0, // PC_XORIS + IU, 1, 1, 0, 0, 0, // PC_AND + IU, 1, 1, 0, 0, 0, // PC_OR + IU, 1, 1, 0, 0, 0, // PC_XOR + IU, 1, 1, 0, 0, 0, // PC_NAND + IU, 1, 1, 0, 0, 0, // PC_NOR + IU, 1, 1, 0, 0, 0, // PC_EQV + IU, 1, 1, 0, 0, 0, // PC_ANDC + IU, 1, 1, 0, 0, 0, // PC_ORC + IU, 1, 1, 0, 0, 0, // PC_EXTSB + IU, 1, 1, 0, 0, 0, // PC_EXTSH + IU, 1, 1, 0, 0, 0, // PC_CNTLZW + IU, 1, 1, 0, 0, 0, // PC_RLWINM + IU, 1, 1, 0, 0, 0, // PC_RLWNM + IU, 1, 1, 0, 0, 0, // PC_RLWIMI + IU, 1, 1, 0, 0, 0, // PC_SLW + IU, 1, 1, 0, 0, 0, // PC_SRW + IU, 1, 1, 0, 0, 0, // PC_SRAWI + IU, 1, 1, 0, 0, 0, // PC_SRAW + SRU, 1, 1, 0, 0, 0, // PC_CRAND + SRU, 1, 1, 0, 0, 0, // PC_CRANDC + SRU, 1, 1, 0, 0, 0, // PC_CREQV + SRU, 1, 1, 0, 0, 0, // PC_CRNAND + SRU, 1, 1, 0, 0, 0, // PC_CRNOR + SRU, 1, 1, 0, 0, 0, // PC_CROR + SRU, 1, 1, 0, 0, 0, // PC_CRORC + SRU, 1, 1, 0, 0, 0, // PC_CRXOR + SRU, 1, 1, 0, 0, 0, // PC_MCRF + SRU, 2, 2, 0, 0, 0, // PC_MTXER + SRU, 2, 2, 0, 0, 0, // PC_MTCTR + SRU, 2, 2, 0, 0, 0, // PC_MTLR + SRU, 1, 1, 0, 0, 0, // PC_MTCRF + SRU, 1, 1, 0, 0, 1, // PC_MTMSR + SRU, 1, 1, 0, 0, 1, // PC_MTSPR + SRU, 1, 1, 0, 0, 1, // PC_MFMSR + SRU, 1, 1, 0, 0, 1, // PC_MFSPR + SRU, 1, 1, 0, 0, 0, // PC_MFXER + SRU, 1, 1, 0, 0, 0, // PC_MFCTR + SRU, 1, 1, 0, 0, 0, // PC_MFLR + SRU, 1, 1, 0, 0, 0, // PC_MFCR + FPU1, 3, 1, 1, 1, 0, // PC_MFFS + FPU1, 3, 1, 1, 1, 0, // PC_MTFSF + SRU, 1, 1, 0, 0, 1, // PC_EIEIO + SRU, 1, 1, 0, 0, 1, // PC_ISYNC + SRU, 1, 1, 0, 0, 1, // PC_SYNC + SRU, 1, 1, 0, 0, 1, // PC_RFI + IU, 1, 1, 0, 0, 0, // PC_LI + IU, 1, 1, 0, 0, 0, // PC_LIS + IU, 1, 1, 0, 0, 0, // PC_MR + IU, 1, 1, 0, 0, 0, // PC_NOP + IU, 1, 1, 0, 0, 0, // PC_NOT + LSU1, 2, 1, 1, 0, 0, // PC_LFS + LSU1, 2, 1, 1, 0, 0, // PC_LFSU + LSU1, 2, 1, 1, 0, 0, // PC_LFSX + LSU1, 2, 1, 1, 0, 0, // PC_LFSUX + LSU1, 2, 1, 1, 0, 0, // PC_LFD + LSU1, 2, 1, 1, 0, 0, // PC_LFDU + LSU1, 2, 1, 1, 0, 0, // PC_LFDX + LSU1, 2, 1, 1, 0, 0, // PC_LFDUX + LSU1, 2, 1, 1, 0, 0, // PC_STFS + LSU1, 2, 1, 1, 0, 0, // PC_STFSU + LSU1, 2, 1, 1, 0, 0, // PC_STFSX + LSU1, 2, 1, 1, 0, 0, // PC_STFSUX + LSU1, 2, 1, 1, 0, 0, // PC_STFD + LSU1, 2, 1, 1, 0, 0, // PC_STFDU + LSU1, 2, 1, 1, 0, 0, // PC_STFDX + LSU1, 2, 1, 1, 0, 0, // PC_STFDUX + FPU1, 3, 1, 1, 1, 0, // PC_FMR + FPU1, 3, 1, 1, 1, 0, // PC_FABS + FPU1, 3, 1, 1, 1, 0, // PC_FNEG + FPU1, 3, 1, 1, 1, 0, // PC_FNABS + FPU1, 3, 1, 1, 1, 0, // PC_FADD + FPU1, 3, 1, 1, 1, 0, // PC_FADDS + FPU1, 3, 1, 1, 1, 0, // PC_FSUB + FPU1, 3, 1, 1, 1, 0, // PC_FSUBS + FPU1, 4, 2, 1, 1, 0, // PC_FMUL + FPU1, 3, 1, 1, 1, 0, // PC_FMULS + FPU1, 33, 33, 0, 0, 0, // PC_FDIV + FPU1, 18, 18, 0, 0, 0, // PC_FDIVS + FPU1, 4, 2, 1, 1, 0, // PC_FMADD + FPU1, 3, 1, 1, 1, 0, // PC_FMADDS + FPU1, 4, 2, 1, 1, 0, // PC_FMSUB + FPU1, 3, 1, 1, 1, 0, // PC_FMSUBS + FPU1, 4, 2, 1, 1, 0, // PC_FNMADD + FPU1, 3, 1, 1, 1, 0, // PC_FNMADDS + FPU1, 4, 2, 1, 1, 0, // PC_FNMSUB + FPU1, 3, 1, 1, 1, 0, // PC_FNMSUBS + FPU1, 18, 18, 0, 0, 0, // PC_FRES + FPU1, 3, 1, 1, 1, 0, // PC_FRSQRTE + FPU1, 3, 1, 1, 1, 0, // PC_FSEL + FPU1, 3, 1, 1, 1, 0, // PC_FRSP + FPU1, 3, 1, 1, 1, 0, // PC_FCTIW + FPU1, 3, 1, 1, 1, 0, // PC_FCTIWZ + FPU1, 5, 1, 1, 1, 0, // PC_FCMPU + FPU1, 5, 1, 1, 1, 0, // PC_FCMPO + LSU1, 1, 1, 0, 0, 0, // PC_LWARX + LSU1, 1, 1, 0, 0, 0, // PC_LSWI + LSU1, 1, 1, 0, 0, 0, // PC_LSWX + LSU1, 1, 1, 0, 0, 0, // PC_STFIWX + LSU1, 1, 1, 0, 0, 0, // PC_STSWI + LSU1, 1, 1, 0, 0, 0, // PC_STSWX + LSU1, 1, 1, 0, 0, 0, // PC_STWCX + IU, 1, 1, 0, 0, 1, // PC_ECIWX + IU, 1, 1, 0, 0, 1, // PC_ECOWX + IU, 1, 1, 0, 0, 0, // PC_DCBI + IU, 1, 1, 0, 0, 0, // PC_ICBI + IU, 1, 1, 0, 0, 0, // PC_MCRFS + IU, 1, 1, 0, 0, 0, // PC_MCRXR + IU, 1, 1, 0, 0, 0, // PC_MFTB + IU, 1, 1, 0, 0, 0, // PC_MFSR + IU, 1, 1, 0, 0, 0, // PC_MTSR + IU, 1, 1, 0, 0, 0, // PC_MFSRIN + IU, 1, 1, 0, 0, 0, // PC_MTSRIN + IU, 1, 1, 0, 0, 0, // PC_MTFSB0 + IU, 1, 1, 0, 0, 0, // PC_MTFSB1 + IU, 1, 1, 0, 0, 0, // PC_MTFSFI + IU, 1, 1, 0, 0, 1, // PC_SC + FPU1, 1, 1, 0, 0, 0, // PC_FSQRT + FPU1, 1, 1, 0, 0, 0, // PC_FSQRTS + IU, 1, 1, 0, 0, 0, // PC_TLBIA + IU, 1, 1, 0, 0, 0, // PC_TLBIE + IU, 1, 1, 0, 0, 0, // PC_TLBLD + IU, 1, 1, 0, 0, 0, // PC_TLBLI + IU, 1, 1, 0, 0, 0, // PC_TLBSYNC + IU, 1, 1, 0, 0, 1, // PC_TW + IU, 1, 1, 0, 0, 1, // PC_TRAP + IU, 1, 1, 0, 0, 1, // PC_TWI + IU, 1, 1, 0, 0, 1, // PC_OPWORD + IU, 1, 1, 0, 0, 0, // PC_MFROM + IU, 1, 1, 0, 0, 1, // PC_DSA + IU, 1, 1, 0, 0, 1, // PC_ESA + IU, 0, 0, 0, 0, 0, // PC_DCCCI + IU, 0, 0, 0, 0, 0, // PC_DCREAD + IU, 0, 0, 0, 0, 0, // PC_ICBT + IU, 0, 0, 0, 0, 0, // PC_ICCCI + IU, 0, 0, 0, 0, 0, // PC_ICREAD + IU, 0, 0, 0, 0, 0, // PC_RFCI + IU, 0, 0, 0, 0, 0, // PC_TLBRE + IU, 0, 0, 0, 0, 0, // PC_TLBSX + IU, 0, 0, 0, 0, 0, // PC_TLBWE + IU, 0, 0, 0, 0, 0, // PC_WRTEE + IU, 0, 0, 0, 0, 0, // PC_WRTEEI + IU, 0, 0, 0, 0, 0, // PC_MFDCR + IU, 0, 0, 0, 0, 0, // PC_MTDCR + IU, 0, 0, 0, 0, 0, // PC_DCBA + BPU, 0, 0, 0, 0, 0, // PC_DSS + BPU, 0, 0, 0, 0, 0, // PC_DSSALL + BPU, 0, 0, 0, 0, 0, // PC_DST + BPU, 0, 0, 0, 0, 0, // PC_DSTT + BPU, 0, 0, 0, 0, 0, // PC_DSTST + BPU, 0, 0, 0, 0, 0, // PC_DSTSTT + BPU, 0, 0, 0, 0, 0, // PC_LVEBX + BPU, 0, 0, 0, 0, 0, // PC_LVEHX + BPU, 0, 0, 0, 0, 0, // PC_LVEWX + BPU, 0, 0, 0, 0, 0, // PC_LVSL + BPU, 0, 0, 0, 0, 0, // PC_LVSR + BPU, 0, 0, 0, 0, 0, // PC_LVX + BPU, 0, 0, 0, 0, 0, // PC_LVXL + BPU, 0, 0, 0, 0, 0, // PC_STVEBX + BPU, 0, 0, 0, 0, 0, // PC_STVEHX + BPU, 0, 0, 0, 0, 0, // PC_STVEWX + BPU, 0, 0, 0, 0, 0, // PC_STVX + BPU, 0, 0, 0, 0, 0, // PC_STVXL + BPU, 0, 0, 0, 0, 0, // PC_MFVSCR + BPU, 0, 0, 0, 0, 0, // PC_MTVSCR + BPU, 0, 0, 0, 0, 0, // PC_VADDCUW + BPU, 0, 0, 0, 0, 0, // PC_VADDFP + BPU, 0, 0, 0, 0, 0, // PC_VADDSBS + BPU, 0, 0, 0, 0, 0, // PC_VADDSHS + BPU, 0, 0, 0, 0, 0, // PC_VADDSWS + BPU, 0, 0, 0, 0, 0, // PC_VADDUBM + BPU, 0, 0, 0, 0, 0, // PC_VADDUBS + BPU, 0, 0, 0, 0, 0, // PC_VADDUHM + BPU, 0, 0, 0, 0, 0, // PC_VADDUHS + BPU, 0, 0, 0, 0, 0, // PC_VADDUWM + BPU, 0, 0, 0, 0, 0, // PC_VADDUWS + BPU, 0, 0, 0, 0, 0, // PC_VAND + BPU, 0, 0, 0, 0, 0, // PC_VANDC + BPU, 0, 0, 0, 0, 0, // PC_VAVGSB + BPU, 0, 0, 0, 0, 0, // PC_VAVGSH + BPU, 0, 0, 0, 0, 0, // PC_VAVGSW + BPU, 0, 0, 0, 0, 0, // PC_VAVGUB + BPU, 0, 0, 0, 0, 0, // PC_VAVGUH + BPU, 0, 0, 0, 0, 0, // PC_VAVGUW + BPU, 0, 0, 0, 0, 0, // PC_VCFSX + BPU, 0, 0, 0, 0, 0, // PC_VCFUX + BPU, 0, 0, 0, 0, 0, // PC_VCMPBFP + BPU, 0, 0, 0, 0, 0, // PC_VCMPEQFP + BPU, 0, 0, 0, 0, 0, // PC_VCMPEQUB + BPU, 0, 0, 0, 0, 0, // PC_VCMPEQUH + BPU, 0, 0, 0, 0, 0, // PC_VCMPEQUW + BPU, 0, 0, 0, 0, 0, // PC_VCMPGEFP + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTFP + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTSB + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTSH + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTSW + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTUB + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTUH + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTUW + BPU, 0, 0, 0, 0, 0, // PC_VCTSXS + BPU, 0, 0, 0, 0, 0, // PC_VCTUXS + BPU, 0, 0, 0, 0, 0, // PC_VEXPTEFP + BPU, 0, 0, 0, 0, 0, // PC_VLOGEFP + BPU, 0, 0, 0, 0, 0, // PC_VMAXFP + BPU, 0, 0, 0, 0, 0, // PC_VMAXSB + BPU, 0, 0, 0, 0, 0, // PC_VMAXSH + BPU, 0, 0, 0, 0, 0, // PC_VMAXSW + BPU, 0, 0, 0, 0, 0, // PC_VMAXUB + BPU, 0, 0, 0, 0, 0, // PC_VMAXUH + BPU, 0, 0, 0, 0, 0, // PC_VMAXUW + BPU, 0, 0, 0, 0, 0, // PC_VMINFP + BPU, 0, 0, 0, 0, 0, // PC_VMINSB + BPU, 0, 0, 0, 0, 0, // PC_VMINSH + BPU, 0, 0, 0, 0, 0, // PC_VMINSW + BPU, 0, 0, 0, 0, 0, // PC_VMINUB + BPU, 0, 0, 0, 0, 0, // PC_VMINUH + BPU, 0, 0, 0, 0, 0, // PC_VMINUW + BPU, 0, 0, 0, 0, 0, // PC_VMRGHB + BPU, 0, 0, 0, 0, 0, // PC_VMRGHH + BPU, 0, 0, 0, 0, 0, // PC_VMRGHW + BPU, 0, 0, 0, 0, 0, // PC_VMRGLB + BPU, 0, 0, 0, 0, 0, // PC_VMRGLH + BPU, 0, 0, 0, 0, 0, // PC_VMRGLW + BPU, 0, 0, 0, 0, 0, // PC_VMULESB + BPU, 0, 0, 0, 0, 0, // PC_VMULESH + BPU, 0, 0, 0, 0, 0, // PC_VMULEUB + BPU, 0, 0, 0, 0, 0, // PC_VMULEUH + BPU, 0, 0, 0, 0, 0, // PC_VMULOSB + BPU, 0, 0, 0, 0, 0, // PC_VMULOSH + BPU, 0, 0, 0, 0, 0, // PC_VMULOUB + BPU, 0, 0, 0, 0, 0, // PC_VMULOUH + BPU, 0, 0, 0, 0, 0, // PC_VNOR + BPU, 0, 0, 0, 0, 0, // PC_VOR + BPU, 0, 0, 0, 0, 0, // PC_VPKPX + BPU, 0, 0, 0, 0, 0, // PC_VPKSHSS + BPU, 0, 0, 0, 0, 0, // PC_VPKSHUS + BPU, 0, 0, 0, 0, 0, // PC_VPKSWSS + BPU, 0, 0, 0, 0, 0, // PC_VPKSWUS + BPU, 0, 0, 0, 0, 0, // PC_VPKUHUM + BPU, 0, 0, 0, 0, 0, // PC_VPKUHUS + BPU, 0, 0, 0, 0, 0, // PC_VPKUWUM + BPU, 0, 0, 0, 0, 0, // PC_VPKUWUS + BPU, 0, 0, 0, 0, 0, // PC_VREFP + BPU, 0, 0, 0, 0, 0, // PC_VRFIM + BPU, 0, 0, 0, 0, 0, // PC_VRFIN + BPU, 0, 0, 0, 0, 0, // PC_VRFIP + BPU, 0, 0, 0, 0, 0, // PC_VRFIZ + BPU, 0, 0, 0, 0, 0, // PC_VRLB + BPU, 0, 0, 0, 0, 0, // PC_VRLH + BPU, 0, 0, 0, 0, 0, // PC_VRLW + BPU, 0, 0, 0, 0, 0, // PC_VRSQRTEFP + BPU, 0, 0, 0, 0, 0, // PC_VSL + BPU, 0, 0, 0, 0, 0, // PC_VSLB + BPU, 0, 0, 0, 0, 0, // PC_VSLH + BPU, 0, 0, 0, 0, 0, // PC_VSLO + BPU, 0, 0, 0, 0, 0, // PC_VSLW + BPU, 0, 0, 0, 0, 0, // PC_VSPLTB + BPU, 0, 0, 0, 0, 0, // PC_VSPLTH + BPU, 0, 0, 0, 0, 0, // PC_VSPLTW + BPU, 0, 0, 0, 0, 0, // PC_VSPLTISB + BPU, 0, 0, 0, 0, 0, // PC_VSPLTISH + BPU, 0, 0, 0, 0, 0, // PC_VSPLTISW + BPU, 0, 0, 0, 0, 0, // PC_VSR + BPU, 0, 0, 0, 0, 0, // PC_VSRAB + BPU, 0, 0, 0, 0, 0, // PC_VSRAH + BPU, 0, 0, 0, 0, 0, // PC_VSRAW + BPU, 0, 0, 0, 0, 0, // PC_VSRB + BPU, 0, 0, 0, 0, 0, // PC_VSRH + BPU, 0, 0, 0, 0, 0, // PC_VSRO + BPU, 0, 0, 0, 0, 0, // PC_VSRW + BPU, 0, 0, 0, 0, 0, // PC_VSUBCUW + BPU, 0, 0, 0, 0, 0, // PC_VSUBFP + BPU, 0, 0, 0, 0, 0, // PC_VSUBSBS + BPU, 0, 0, 0, 0, 0, // PC_VSUBSHS + BPU, 0, 0, 0, 0, 0, // PC_VSUBSWS + BPU, 0, 0, 0, 0, 0, // PC_VSUBUBM + BPU, 0, 0, 0, 0, 0, // PC_VSUBUBS + BPU, 0, 0, 0, 0, 0, // PC_VSUBUHM + BPU, 0, 0, 0, 0, 0, // PC_VSUBUHS + BPU, 0, 0, 0, 0, 0, // PC_VSUBUWM + BPU, 0, 0, 0, 0, 0, // PC_VSUBUWS + BPU, 0, 0, 0, 0, 0, // PC_VSUMSWS + BPU, 0, 0, 0, 0, 0, // PC_VSUM2SWS + BPU, 0, 0, 0, 0, 0, // PC_VSUM4SBS + BPU, 0, 0, 0, 0, 0, // PC_VSUM4SHS + BPU, 0, 0, 0, 0, 0, // PC_VSUM4UBS + BPU, 0, 0, 0, 0, 0, // PC_VUPKHPX + BPU, 0, 0, 0, 0, 0, // PC_VUPKHSB + BPU, 0, 0, 0, 0, 0, // PC_VUPKHSH + BPU, 0, 0, 0, 0, 0, // PC_VUPKLPX + BPU, 0, 0, 0, 0, 0, // PC_VUPKLSB + BPU, 0, 0, 0, 0, 0, // PC_VUPKLSH + BPU, 0, 0, 0, 0, 0, // PC_VXOR + BPU, 0, 0, 0, 0, 0, // PC_VMADDFP + BPU, 0, 0, 0, 0, 0, // PC_VMHADDSHS + BPU, 0, 0, 0, 0, 0, // PC_VMHRADDSHS + BPU, 0, 0, 0, 0, 0, // PC_VMLADDUHM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMMBM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMSHM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMSHS + BPU, 0, 0, 0, 0, 0, // PC_VMSUMUBM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMUHM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMUHS + BPU, 0, 0, 0, 0, 0, // PC_VNMSUBFP + BPU, 0, 0, 0, 0, 0, // PC_VPERM + BPU, 0, 0, 0, 0, 0, // PC_VSEL + BPU, 0, 0, 0, 0, 0, // PC_VSLDOI + BPU, 0, 0, 0, 0, 0, // PC_VMR + BPU, 0, 0, 0, 0, 0, // PC_VMRP + BPU, 0, 0, 0, 0, 0, // PC_SLE + BPU, 0, 0, 0, 0, 0, // PC_SLEQ + BPU, 0, 0, 0, 0, 0, // PC_SLIQ + BPU, 0, 0, 0, 0, 0, // PC_SLLIQ + BPU, 0, 0, 0, 0, 0, // PC_SLLQ + BPU, 0, 0, 0, 0, 0, // PC_SLQ + BPU, 0, 0, 0, 0, 0, // PC_SRAIQ + BPU, 0, 0, 0, 0, 0, // PC_SRAQ + BPU, 0, 0, 0, 0, 0, // PC_SRE + BPU, 0, 0, 0, 0, 0, // PC_SREA + BPU, 0, 0, 0, 0, 0, // PC_SREQ + BPU, 0, 0, 0, 0, 0, // PC_SRIQ + BPU, 0, 0, 0, 0, 0, // PC_SRLIQ + BPU, 0, 0, 0, 0, 0, // PC_SRLQ + BPU, 0, 0, 0, 0, 0, // PC_SRQ + BPU, 0, 0, 0, 0, 0, // PC_MASKG + BPU, 0, 0, 0, 0, 0, // PC_MASKIR + BPU, 0, 0, 0, 0, 0, // PC_LSCBX + BPU, 0, 0, 0, 0, 0, // PC_DIV + BPU, 0, 0, 0, 0, 0, // PC_DIVS + BPU, 0, 0, 0, 0, 0, // PC_DOZ + BPU, 0, 0, 0, 0, 0, // PC_MUL + BPU, 0, 0, 0, 0, 0, // PC_NABS + BPU, 0, 0, 0, 0, 0, // PC_ABS + BPU, 0, 0, 0, 0, 0, // PC_CLCS + BPU, 0, 0, 0, 0, 0, // PC_DOZI + BPU, 0, 0, 0, 0, 0, // PC_RLMI + BPU, 0, 0, 0, 0, 0, // PC_RRIB +}; + +static void advance(int firstStage, int oldStage, int newStage) { + PCode *instr = pipeline[oldStage].instr; + int cycles = instruction_timing[instr->op].cycles[newStage - firstStage]; + pipeline[newStage].instr = instr; + pipeline[newStage].remaining = cycles; + pipeline[oldStage].instr = NULL; +} + +static void assign_completion_buffer(PCode *instr) { + completionbuffers.used++; + completionbuffers.free--; + completionbuffers.entries[completionbuffers.nextFreeSlot].instr = instr; + completionbuffers.entries[completionbuffers.nextFreeSlot].completed = 0; + completionbuffers.nextFreeSlot = (completionbuffers.nextFreeSlot + 1) % MaxEntries; +} + +static void complete_instruction(int stage) { + PCode *instr = pipeline[stage].instr; + int buf = 0; + while (buf < MaxEntries && completionbuffers.entries[buf].instr != instr) + buf++; + + completionbuffers.entries[buf].completed = 1; + pipeline[stage].instr = NULL; +} + +static void retire_instruction(void) { + completionbuffers.entries[completionbuffers.nextToRetire].instr = NULL; + completionbuffers.used--; + completionbuffers.free++; + completionbuffers.nextToRetire = (completionbuffers.nextToRetire + 1) % MaxEntries; +} + +static int latency(PCode *instr) { + int cycles = instruction_timing[instr->op].latency; + if (PCODE_FLAG_SET_F(instr) & fRecordBit) + cycles += 2; + if (instr->op == PC_LMW || instr->op == PC_STMW) + cycles += instr->argCount - 2; + return cycles; +} + +static void initialize(void) { + int stage; + int i; + + for (stage = 0; stage < NumStages; stage++) + pipeline[stage].instr = NULL; + + completionbuffers.free = MaxEntries; + completionbuffers.used = 0; + completionbuffers.nextToRetire = 0; + completionbuffers.nextFreeSlot = 0; + for (i = 0; i < MaxEntries; i++) + completionbuffers.entries[i].instr = NULL; +} + +static int can_issue(PCode *instr) { + int stage; + + if (completionbuffers.free == 0) + return 0; + + stage = instruction_timing[instr->op].stage; + if (pipeline[stage].instr) { + if (stage == IU) { + switch (instr->op) { + case PC_ADD: + case PC_ADDC: + case PC_ADDI: + case PC_ADDIS: + case PC_CMPI: + case PC_CMP: + case PC_CMPLI: + case PC_CMPL: + if (is_dependent(instr, pipeline[IU].instr, RegClass_GPR)) + return 0; + if (!pipeline[SRU].instr) + return 1; + } + } + return 0; + } + + if ((instr->flags & fIsWrite) && pipeline[LSU2].instr && (pipeline[LSU2].instr->flags & fIsWrite)) + return 0; + + return 1; +} + +static void issue(PCode *instr) { + int stage = instruction_timing[instr->op].stage; + int cycles = instruction_timing[instr->op].cycles[0]; + if (stage == IU && pipeline[IU].instr) + stage = SRU; + assign_completion_buffer(instr); + pipeline[stage].instr = instr; + pipeline[stage].remaining = cycles; +} + +static void advance_clock(void) { + int stage; + + for (stage = 0; stage < NumStages; stage++) { + if (pipeline[stage].instr && pipeline[stage].remaining) + --pipeline[stage].remaining; + } + + if (completionbuffers.used && completionbuffers.entries[completionbuffers.nextToRetire].completed) { + retire_instruction(); + if (completionbuffers.used && completionbuffers.entries[completionbuffers.nextToRetire].completed) { + retire_instruction(); + } + } + + if (pipeline[IU].instr && pipeline[IU].remaining == 0) + complete_instruction(IU); + if (pipeline[LSU2].instr && pipeline[LSU2].remaining == 0) + complete_instruction(LSU2); + if (pipeline[FPU3].instr && pipeline[FPU3].remaining == 0) + complete_instruction(FPU3); + if (pipeline[SRU].instr && pipeline[SRU].remaining == 0) + complete_instruction(SRU); + if (pipeline[BPU].instr && pipeline[BPU].remaining == 0) + complete_instruction(BPU); + + if ( + pipeline[FPU1].instr && + pipeline[FPU1].remaining == 0 && + (pipeline[FPU1].instr->op == PC_FDIV || pipeline[FPU1].instr->op == PC_FDIVS) + ) + complete_instruction(FPU1); + + if (pipeline[FPU2].instr && pipeline[FPU2].remaining == 0 && !pipeline[FPU3].instr) + advance(FPU1, FPU2, FPU3); + if (pipeline[FPU1].instr && pipeline[FPU1].remaining == 0 && !pipeline[FPU2].instr) + advance(FPU1, FPU1, FPU2); + if (pipeline[LSU1].instr && pipeline[LSU1].remaining == 0 && !pipeline[LSU2].instr) + advance(LSU1, LSU1, LSU2); +} + +static int serializes(PCode *instr) { + return instruction_timing[instr->op].serializes; +} + +MachineInfo machine603e = { + 2, + 1, + 0, + &latency, + &initialize, + &can_issue, + &issue, + &advance_clock, + &serializes, + &default_uses_vpermute_unit +}; diff --git a/compiler_and_linker/unsorted/MachineSimulation604.c b/compiler_and_linker/unsorted/MachineSimulation604.c new file mode 100644 index 0000000..9775c9e --- /dev/null +++ b/compiler_and_linker/unsorted/MachineSimulation604.c @@ -0,0 +1,670 @@ +#include "compiler/Scheduler.h" +#include "compiler/PCode.h" +#include "compiler/PCodeInfo.h" + +// https://archive.org/details/bitsavers_motorolaPosManualNov94_22719504 + +typedef enum Stage { + SCIU, // Single-Cycle Integer Unit 1 + SCIU2, // Single-Cycle Integer Unit 2 + MCIU, // Multiple-Cycle Integer Unit + FPU1, // Floating Point Unit + FPU2, + FPU3, + LSU1, // Load/Store Unit + LSU2, + BPU, // Branch Prediction Unit + NumStages +} Stage; + +static struct { + // the instruction currently in this pipeline stage + PCode *instr; + + // how many cycles are left for this instruction to finish + int remaining; +} pipeline[NumStages]; + +enum { + MaxEntries = 16 +}; + +static struct { + // how many entries remain unused in the queue + unsigned int free; + + // how many entries are currently used in the queue + unsigned int used; + + // the index of the next instruction that will be retired + unsigned int nextToRetire; + + // the index of the next free slot that will be used when an instruction is dispatched + unsigned int nextFreeSlot; + + // circular array of entries in the completion queue + struct { + PCode *instr; + int completed; + } entries[MaxEntries]; +} completionbuffers; + +static PCode *sciu_completed_instruction; +static PCode *sciu2_completed_instruction; + +static struct { + // the initial stage for this instruction + Stage stage; + + // the total amount of cycles required by this instruction + char latency; + + // how long it takes to finish each stage + char cycles[3]; + + // does this instruction serialise? + char serializes; +} instruction_timing[OPCODE_MAX] = { + BPU, 0, 0, 0, 0, 1, // PC_B + BPU, 0, 0, 0, 0, 1, // PC_BL + BPU, 0, 0, 0, 0, 1, // PC_BC + BPU, 0, 0, 0, 0, 1, // PC_BCLR + BPU, 0, 0, 0, 0, 1, // PC_BCCTR + BPU, 0, 0, 0, 0, 1, // PC_BT + BPU, 0, 0, 0, 0, 1, // PC_BTLR + BPU, 0, 0, 0, 0, 1, // PC_BTCTR + BPU, 0, 0, 0, 0, 1, // PC_BF + BPU, 0, 0, 0, 0, 1, // PC_BFLR + BPU, 0, 0, 0, 0, 1, // PC_BFCTR + BPU, 0, 0, 0, 0, 1, // PC_BDNZ + BPU, 0, 0, 0, 0, 1, // PC_BDNZT + BPU, 0, 0, 0, 0, 1, // PC_BDNZF + BPU, 0, 0, 0, 0, 1, // PC_BDZ + BPU, 0, 0, 0, 0, 1, // PC_BDZT + BPU, 0, 0, 0, 0, 1, // PC_BDZF + BPU, 0, 0, 0, 0, 1, // PC_BLR + BPU, 0, 0, 0, 0, 1, // PC_BCTR + BPU, 0, 0, 0, 0, 1, // PC_BCTRL + BPU, 0, 0, 0, 0, 1, // PC_BLRL + LSU1, 2, 1, 1, 0, 0, // PC_LBZ + LSU1, 2, 1, 1, 0, 0, // PC_LBZU + LSU1, 2, 1, 1, 0, 0, // PC_LBZX + LSU1, 2, 1, 1, 0, 0, // PC_LBZUX + LSU1, 2, 1, 1, 0, 0, // PC_LHZ + LSU1, 2, 1, 1, 0, 0, // PC_LHZU + LSU1, 2, 1, 1, 0, 0, // PC_LHZX + LSU1, 2, 1, 1, 0, 0, // PC_LHZUX + LSU1, 2, 1, 1, 0, 0, // PC_LHA + LSU1, 2, 1, 1, 0, 0, // PC_LHAU + LSU1, 2, 1, 1, 0, 0, // PC_LHAX + LSU1, 2, 1, 1, 0, 0, // PC_LHAUX + LSU1, 2, 1, 1, 0, 0, // PC_LHBRX + LSU1, 2, 1, 1, 0, 0, // PC_LWZ + LSU1, 2, 1, 1, 0, 0, // PC_LWZU + LSU1, 2, 1, 1, 0, 0, // PC_LWZX + LSU1, 2, 1, 1, 0, 0, // PC_LWZUX + LSU1, 2, 1, 1, 0, 0, // PC_LWBRX + LSU1, 2, 1, 1, 0, 0, // PC_LMW + LSU1, 3, 1, 1, 0, 0, // PC_STB + LSU1, 3, 1, 1, 0, 0, // PC_STBU + LSU1, 3, 1, 1, 0, 0, // PC_STBX + LSU1, 3, 1, 1, 0, 0, // PC_STBUX + LSU1, 3, 1, 1, 0, 0, // PC_STH + LSU1, 3, 1, 1, 0, 0, // PC_STHU + LSU1, 3, 1, 1, 0, 0, // PC_STHX + LSU1, 3, 1, 1, 0, 0, // PC_STHUX + LSU1, 3, 1, 1, 0, 0, // PC_STHBRX + LSU1, 3, 1, 1, 0, 0, // PC_STW + LSU1, 3, 1, 1, 0, 0, // PC_STWU + LSU1, 3, 1, 1, 0, 0, // PC_STWX + LSU1, 3, 1, 1, 0, 0, // PC_STWUX + LSU1, 3, 1, 1, 0, 0, // PC_STWBRX + LSU1, 2, 1, 1, 0, 0, // PC_STMW + LSU1, 2, 1, 1, 0, 0, // PC_DCBF + LSU1, 2, 1, 1, 0, 0, // PC_DCBST + LSU1, 2, 1, 1, 0, 0, // PC_DCBT + LSU1, 2, 1, 1, 0, 0, // PC_DCBTST + LSU1, 2, 1, 1, 0, 0, // PC_DCBZ + SCIU, 1, 1, 0, 0, 0, // PC_ADD + SCIU, 1, 1, 0, 0, 0, // PC_ADDC + SCIU, 1, 1, 0, 0, 0, // PC_ADDE + SCIU, 1, 1, 0, 0, 0, // PC_ADDI + SCIU, 1, 1, 0, 0, 0, // PC_ADDIC + SCIU, 1, 1, 0, 0, 0, // PC_ADDICR + SCIU, 1, 1, 0, 0, 0, // PC_ADDIS + SCIU, 1, 1, 0, 0, 0, // PC_ADDME + SCIU, 1, 1, 0, 0, 0, // PC_ADDZE + MCIU, 20, 20, 0, 0, 0, // PC_DIVW + MCIU, 20, 20, 0, 0, 0, // PC_DIVWU + MCIU, 4, 4, 0, 0, 0, // PC_MULHW + MCIU, 4, 4, 0, 0, 0, // PC_MULHWU + MCIU, 3, 3, 0, 0, 0, // PC_MULLI + MCIU, 4, 4, 0, 0, 0, // PC_MULLW + SCIU, 1, 1, 0, 0, 0, // PC_NEG + SCIU, 1, 1, 0, 0, 0, // PC_SUBF + SCIU, 1, 1, 0, 0, 0, // PC_SUBFC + SCIU, 1, 1, 0, 0, 0, // PC_SUBFE + SCIU, 1, 1, 0, 0, 0, // PC_SUBFIC + SCIU, 1, 1, 0, 0, 0, // PC_SUBFME + SCIU, 1, 1, 0, 0, 0, // PC_SUBFZE + SCIU, 3, 1, 0, 0, 0, // PC_CMPI + SCIU, 3, 1, 0, 0, 0, // PC_CMP + SCIU, 3, 1, 0, 0, 0, // PC_CMPLI + SCIU, 3, 1, 0, 0, 0, // PC_CMPL + SCIU, 1, 1, 0, 0, 0, // PC_ANDI + SCIU, 1, 1, 0, 0, 0, // PC_ANDIS + SCIU, 1, 1, 0, 0, 0, // PC_ORI + SCIU, 1, 1, 0, 0, 0, // PC_ORIS + SCIU, 1, 1, 0, 0, 0, // PC_XORI + SCIU, 1, 1, 0, 0, 0, // PC_XORIS + SCIU, 1, 1, 0, 0, 0, // PC_AND + SCIU, 1, 1, 0, 0, 0, // PC_OR + SCIU, 1, 1, 0, 0, 0, // PC_XOR + SCIU, 1, 1, 0, 0, 0, // PC_NAND + SCIU, 1, 1, 0, 0, 0, // PC_NOR + SCIU, 1, 1, 0, 0, 0, // PC_EQV + SCIU, 1, 1, 0, 0, 0, // PC_ANDC + SCIU, 1, 1, 0, 0, 0, // PC_ORC + SCIU, 1, 1, 0, 0, 0, // PC_EXTSB + SCIU, 1, 1, 0, 0, 0, // PC_EXTSH + SCIU, 1, 1, 0, 0, 0, // PC_CNTLZW + SCIU, 1, 1, 0, 0, 0, // PC_RLWINM + SCIU, 1, 1, 0, 0, 0, // PC_RLWNM + SCIU, 1, 1, 0, 0, 0, // PC_RLWIMI + SCIU, 1, 1, 0, 0, 0, // PC_SLW + SCIU, 1, 1, 0, 0, 0, // PC_SRW + SCIU, 1, 1, 0, 0, 0, // PC_SRAWI + SCIU, 1, 1, 0, 0, 0, // PC_SRAW + BPU, 1, 1, 0, 0, 0, // PC_CRAND + BPU, 1, 1, 0, 0, 0, // PC_CRANDC + BPU, 1, 1, 0, 0, 0, // PC_CREQV + BPU, 1, 1, 0, 0, 0, // PC_CRNAND + BPU, 1, 1, 0, 0, 0, // PC_CRNOR + BPU, 1, 1, 0, 0, 0, // PC_CROR + BPU, 1, 1, 0, 0, 0, // PC_CRORC + BPU, 1, 1, 0, 0, 0, // PC_CRXOR + BPU, 1, 1, 0, 0, 0, // PC_MCRF + MCIU, 1, 1, 0, 0, 0, // PC_MTXER + MCIU, 1, 1, 0, 0, 0, // PC_MTCTR + MCIU, 1, 1, 0, 0, 0, // PC_MTLR + MCIU, 1, 1, 0, 0, 0, // PC_MTCRF + MCIU, 1, 1, 0, 0, 0, // PC_MTMSR + MCIU, 1, 1, 0, 0, 0, // PC_MTSPR + MCIU, 1, 1, 0, 0, 0, // PC_MFMSR + MCIU, 1, 1, 0, 0, 0, // PC_MFSPR + MCIU, 3, 3, 0, 0, 0, // PC_MFXER + MCIU, 3, 3, 0, 0, 0, // PC_MFCTR + MCIU, 3, 3, 0, 0, 0, // PC_MFLR + MCIU, 3, 3, 0, 0, 0, // PC_MFCR + FPU1, 3, 1, 1, 1, 0, // PC_MFFS + FPU1, 3, 1, 1, 1, 0, // PC_MTFSF + LSU1, 1, 0, 0, 0, 1, // PC_EIEIO + LSU1, 1, 0, 0, 0, 1, // PC_ISYNC + LSU1, 1, 0, 0, 0, 1, // PC_SYNC + LSU1, 1, 1, 0, 0, 1, // PC_RFI + SCIU, 1, 1, 0, 0, 0, // PC_LI + SCIU, 1, 1, 0, 0, 0, // PC_LIS + SCIU, 1, 1, 0, 0, 0, // PC_MR + SCIU, 1, 1, 0, 0, 0, // PC_NOP + SCIU, 1, 1, 0, 0, 0, // PC_NOT + LSU1, 3, 1, 1, 0, 0, // PC_LFS + LSU1, 3, 1, 1, 0, 0, // PC_LFSU + LSU1, 3, 1, 1, 0, 0, // PC_LFSX + LSU1, 3, 1, 1, 0, 0, // PC_LFSUX + LSU1, 3, 1, 1, 0, 0, // PC_LFD + LSU1, 3, 1, 1, 0, 0, // PC_LFDU + LSU1, 3, 1, 1, 0, 0, // PC_LFDX + LSU1, 3, 1, 1, 0, 0, // PC_LFDUX + LSU1, 3, 1, 1, 0, 0, // PC_STFS + LSU1, 3, 1, 1, 0, 0, // PC_STFSU + LSU1, 3, 1, 1, 0, 0, // PC_STFSX + LSU1, 3, 1, 1, 0, 0, // PC_STFSUX + LSU1, 3, 1, 1, 0, 0, // PC_STFD + LSU1, 3, 1, 1, 0, 0, // PC_STFDU + LSU1, 3, 1, 1, 0, 0, // PC_STFDX + LSU1, 3, 1, 1, 0, 0, // PC_STFDUX + FPU1, 3, 1, 1, 1, 0, // PC_FMR + FPU1, 3, 1, 1, 1, 0, // PC_FABS + FPU1, 3, 1, 1, 1, 0, // PC_FNEG + FPU1, 3, 1, 1, 1, 0, // PC_FNABS + FPU1, 3, 1, 1, 1, 0, // PC_FADD + FPU1, 3, 1, 1, 1, 0, // PC_FADDS + FPU1, 3, 1, 1, 1, 0, // PC_FSUB + FPU1, 3, 1, 1, 1, 0, // PC_FSUBS + FPU1, 3, 1, 1, 1, 0, // PC_FMUL + FPU1, 3, 1, 1, 1, 0, // PC_FMULS + FPU1, 32, 32, 0, 0, 0, // PC_FDIV + FPU1, 18, 18, 0, 0, 0, // PC_FDIVS + FPU1, 3, 1, 1, 1, 0, // PC_FMADD + FPU1, 3, 1, 1, 1, 0, // PC_FMADDS + FPU1, 3, 1, 1, 1, 0, // PC_FMSUB + FPU1, 3, 1, 1, 1, 0, // PC_FMSUBS + FPU1, 3, 1, 1, 1, 0, // PC_FNMADD + FPU1, 3, 1, 1, 1, 0, // PC_FNMADDS + FPU1, 3, 1, 1, 1, 0, // PC_FNMSUB + FPU1, 3, 1, 1, 1, 0, // PC_FNMSUBS + FPU1, 18, 18, 0, 0, 0, // PC_FRES + FPU1, 3, 1, 1, 1, 0, // PC_FRSQRTE + FPU1, 3, 1, 1, 1, 0, // PC_FSEL + FPU1, 3, 1, 1, 1, 0, // PC_FRSP + FPU1, 3, 1, 1, 1, 0, // PC_FCTIW + FPU1, 3, 1, 1, 1, 0, // PC_FCTIWZ + FPU1, 5, 1, 1, 1, 0, // PC_FCMPU + FPU1, 5, 1, 1, 1, 0, // PC_FCMPO + LSU1, 1, 1, 0, 0, 0, // PC_LWARX + LSU1, 1, 1, 0, 0, 0, // PC_LSWI + LSU1, 1, 1, 0, 0, 0, // PC_LSWX + LSU1, 1, 1, 0, 0, 0, // PC_STFIWX + LSU1, 1, 1, 0, 0, 0, // PC_STSWI + LSU1, 1, 1, 0, 0, 0, // PC_STSWX + LSU1, 1, 1, 0, 0, 0, // PC_STWCX + MCIU, 1, 1, 0, 0, 1, // PC_ECIWX + MCIU, 1, 1, 0, 0, 1, // PC_ECOWX + MCIU, 1, 1, 0, 0, 0, // PC_DCBI + MCIU, 1, 1, 0, 0, 0, // PC_ICBI + MCIU, 1, 1, 0, 0, 0, // PC_MCRFS + MCIU, 1, 1, 0, 0, 0, // PC_MCRXR + MCIU, 1, 1, 0, 0, 0, // PC_MFTB + MCIU, 1, 1, 0, 0, 0, // PC_MFSR + MCIU, 1, 1, 0, 0, 0, // PC_MTSR + MCIU, 1, 1, 0, 0, 0, // PC_MFSRIN + MCIU, 1, 1, 0, 0, 0, // PC_MTSRIN + MCIU, 1, 1, 0, 0, 0, // PC_MTFSB0 + MCIU, 1, 1, 0, 0, 0, // PC_MTFSB1 + MCIU, 1, 1, 0, 0, 0, // PC_MTFSFI + MCIU, 1, 1, 0, 0, 1, // PC_SC + FPU1, 1, 1, 0, 0, 0, // PC_FSQRT + FPU1, 1, 1, 0, 0, 0, // PC_FSQRTS + MCIU, 1, 1, 0, 0, 0, // PC_TLBIA + MCIU, 1, 1, 0, 0, 0, // PC_TLBIE + MCIU, 1, 1, 0, 0, 0, // PC_TLBLD + MCIU, 1, 1, 0, 0, 0, // PC_TLBLI + MCIU, 1, 1, 0, 0, 0, // PC_TLBSYNC + MCIU, 1, 1, 0, 0, 1, // PC_TW + MCIU, 1, 1, 0, 0, 1, // PC_TRAP + MCIU, 1, 1, 0, 0, 1, // PC_TWI + MCIU, 1, 1, 0, 0, 1, // PC_OPWORD + MCIU, 1, 1, 0, 0, 0, // PC_MFROM + MCIU, 1, 1, 0, 0, 1, // PC_DSA + MCIU, 1, 1, 0, 0, 1, // PC_ESA + MCIU, 0, 0, 0, 0, 0, // PC_DCCCI + MCIU, 0, 0, 0, 0, 0, // PC_DCREAD + MCIU, 0, 0, 0, 0, 0, // PC_ICBT + MCIU, 0, 0, 0, 0, 0, // PC_ICCCI + MCIU, 0, 0, 0, 0, 0, // PC_ICREAD + MCIU, 0, 0, 0, 0, 0, // PC_RFCI + MCIU, 0, 0, 0, 0, 0, // PC_TLBRE + MCIU, 0, 0, 0, 0, 0, // PC_TLBSX + MCIU, 0, 0, 0, 0, 0, // PC_TLBWE + MCIU, 0, 0, 0, 0, 0, // PC_WRTEE + MCIU, 0, 0, 0, 0, 0, // PC_WRTEEI + MCIU, 0, 0, 0, 0, 0, // PC_MFDCR + MCIU, 0, 0, 0, 0, 0, // PC_MTDCR + MCIU, 0, 0, 0, 0, 0, // PC_DCBA + SCIU, 0, 0, 0, 0, 0, // PC_DSS + SCIU, 0, 0, 0, 0, 0, // PC_DSSALL + SCIU, 0, 0, 0, 0, 0, // PC_DST + SCIU, 0, 0, 0, 0, 0, // PC_DSTT + SCIU, 0, 0, 0, 0, 0, // PC_DSTST + SCIU, 0, 0, 0, 0, 0, // PC_DSTSTT + SCIU, 0, 0, 0, 0, 0, // PC_LVEBX + SCIU, 0, 0, 0, 0, 0, // PC_LVEHX + SCIU, 0, 0, 0, 0, 0, // PC_LVEWX + SCIU, 0, 0, 0, 0, 0, // PC_LVSL + SCIU, 0, 0, 0, 0, 0, // PC_LVSR + SCIU, 0, 0, 0, 0, 0, // PC_LVX + SCIU, 0, 0, 0, 0, 0, // PC_LVXL + SCIU, 0, 0, 0, 0, 0, // PC_STVEBX + SCIU, 0, 0, 0, 0, 0, // PC_STVEHX + SCIU, 0, 0, 0, 0, 0, // PC_STVEWX + SCIU, 0, 0, 0, 0, 0, // PC_STVX + SCIU, 0, 0, 0, 0, 0, // PC_STVXL + SCIU, 0, 0, 0, 0, 0, // PC_MFVSCR + SCIU, 0, 0, 0, 0, 0, // PC_MTVSCR + SCIU, 0, 0, 0, 0, 0, // PC_VADDCUW + SCIU, 0, 0, 0, 0, 0, // PC_VADDFP + SCIU, 0, 0, 0, 0, 0, // PC_VADDSBS + SCIU, 0, 0, 0, 0, 0, // PC_VADDSHS + SCIU, 0, 0, 0, 0, 0, // PC_VADDSWS + SCIU, 0, 0, 0, 0, 0, // PC_VADDUBM + SCIU, 0, 0, 0, 0, 0, // PC_VADDUBS + SCIU, 0, 0, 0, 0, 0, // PC_VADDUHM + SCIU, 0, 0, 0, 0, 0, // PC_VADDUHS + SCIU, 0, 0, 0, 0, 0, // PC_VADDUWM + SCIU, 0, 0, 0, 0, 0, // PC_VADDUWS + SCIU, 0, 0, 0, 0, 0, // PC_VAND + SCIU, 0, 0, 0, 0, 0, // PC_VANDC + SCIU, 0, 0, 0, 0, 0, // PC_VAVGSB + SCIU, 0, 0, 0, 0, 0, // PC_VAVGSH + SCIU, 0, 0, 0, 0, 0, // PC_VAVGSW + SCIU, 0, 0, 0, 0, 0, // PC_VAVGUB + SCIU, 0, 0, 0, 0, 0, // PC_VAVGUH + SCIU, 0, 0, 0, 0, 0, // PC_VAVGUW + SCIU, 0, 0, 0, 0, 0, // PC_VCFSX + SCIU, 0, 0, 0, 0, 0, // PC_VCFUX + SCIU, 0, 0, 0, 0, 0, // PC_VCMPBFP + SCIU, 0, 0, 0, 0, 0, // PC_VCMPEQFP + SCIU, 0, 0, 0, 0, 0, // PC_VCMPEQUB + SCIU, 0, 0, 0, 0, 0, // PC_VCMPEQUH + SCIU, 0, 0, 0, 0, 0, // PC_VCMPEQUW + SCIU, 0, 0, 0, 0, 0, // PC_VCMPGEFP + SCIU, 0, 0, 0, 0, 0, // PC_VCMPGTFP + SCIU, 0, 0, 0, 0, 0, // PC_VCMPGTSB + SCIU, 0, 0, 0, 0, 0, // PC_VCMPGTSH + SCIU, 0, 0, 0, 0, 0, // PC_VCMPGTSW + SCIU, 0, 0, 0, 0, 0, // PC_VCMPGTUB + SCIU, 0, 0, 0, 0, 0, // PC_VCMPGTUH + SCIU, 0, 0, 0, 0, 0, // PC_VCMPGTUW + SCIU, 0, 0, 0, 0, 0, // PC_VCTSXS + SCIU, 0, 0, 0, 0, 0, // PC_VCTUXS + SCIU, 0, 0, 0, 0, 0, // PC_VEXPTEFP + SCIU, 0, 0, 0, 0, 0, // PC_VLOGEFP + SCIU, 0, 0, 0, 0, 0, // PC_VMAXFP + SCIU, 0, 0, 0, 0, 0, // PC_VMAXSB + SCIU, 0, 0, 0, 0, 0, // PC_VMAXSH + SCIU, 0, 0, 0, 0, 0, // PC_VMAXSW + SCIU, 0, 0, 0, 0, 0, // PC_VMAXUB + SCIU, 0, 0, 0, 0, 0, // PC_VMAXUH + SCIU, 0, 0, 0, 0, 0, // PC_VMAXUW + SCIU, 0, 0, 0, 0, 0, // PC_VMINFP + SCIU, 0, 0, 0, 0, 0, // PC_VMINSB + SCIU, 0, 0, 0, 0, 0, // PC_VMINSH + SCIU, 0, 0, 0, 0, 0, // PC_VMINSW + SCIU, 0, 0, 0, 0, 0, // PC_VMINUB + SCIU, 0, 0, 0, 0, 0, // PC_VMINUH + SCIU, 0, 0, 0, 0, 0, // PC_VMINUW + SCIU, 0, 0, 0, 0, 0, // PC_VMRGHB + SCIU, 0, 0, 0, 0, 0, // PC_VMRGHH + SCIU, 0, 0, 0, 0, 0, // PC_VMRGHW + SCIU, 0, 0, 0, 0, 0, // PC_VMRGLB + SCIU, 0, 0, 0, 0, 0, // PC_VMRGLH + SCIU, 0, 0, 0, 0, 0, // PC_VMRGLW + SCIU, 0, 0, 0, 0, 0, // PC_VMULESB + SCIU, 0, 0, 0, 0, 0, // PC_VMULESH + SCIU, 0, 0, 0, 0, 0, // PC_VMULEUB + SCIU, 0, 0, 0, 0, 0, // PC_VMULEUH + SCIU, 0, 0, 0, 0, 0, // PC_VMULOSB + SCIU, 0, 0, 0, 0, 0, // PC_VMULOSH + SCIU, 0, 0, 0, 0, 0, // PC_VMULOUB + SCIU, 0, 0, 0, 0, 0, // PC_VMULOUH + SCIU, 0, 0, 0, 0, 0, // PC_VNOR + SCIU, 0, 0, 0, 0, 0, // PC_VOR + SCIU, 0, 0, 0, 0, 0, // PC_VPKPX + SCIU, 0, 0, 0, 0, 0, // PC_VPKSHSS + SCIU, 0, 0, 0, 0, 0, // PC_VPKSHUS + SCIU, 0, 0, 0, 0, 0, // PC_VPKSWSS + SCIU, 0, 0, 0, 0, 0, // PC_VPKSWUS + SCIU, 0, 0, 0, 0, 0, // PC_VPKUHUM + SCIU, 0, 0, 0, 0, 0, // PC_VPKUHUS + SCIU, 0, 0, 0, 0, 0, // PC_VPKUWUM + SCIU, 0, 0, 0, 0, 0, // PC_VPKUWUS + SCIU, 0, 0, 0, 0, 0, // PC_VREFP + SCIU, 0, 0, 0, 0, 0, // PC_VRFIM + SCIU, 0, 0, 0, 0, 0, // PC_VRFIN + SCIU, 0, 0, 0, 0, 0, // PC_VRFIP + SCIU, 0, 0, 0, 0, 0, // PC_VRFIZ + SCIU, 0, 0, 0, 0, 0, // PC_VRLB + SCIU, 0, 0, 0, 0, 0, // PC_VRLH + SCIU, 0, 0, 0, 0, 0, // PC_VRLW + SCIU, 0, 0, 0, 0, 0, // PC_VRSQRTEFP + SCIU, 0, 0, 0, 0, 0, // PC_VSL + SCIU, 0, 0, 0, 0, 0, // PC_VSLB + SCIU, 0, 0, 0, 0, 0, // PC_VSLH + SCIU, 0, 0, 0, 0, 0, // PC_VSLO + SCIU, 0, 0, 0, 0, 0, // PC_VSLW + SCIU, 0, 0, 0, 0, 0, // PC_VSPLTB + SCIU, 0, 0, 0, 0, 0, // PC_VSPLTH + SCIU, 0, 0, 0, 0, 0, // PC_VSPLTW + SCIU, 0, 0, 0, 0, 0, // PC_VSPLTISB + SCIU, 0, 0, 0, 0, 0, // PC_VSPLTISH + SCIU, 0, 0, 0, 0, 0, // PC_VSPLTISW + SCIU, 0, 0, 0, 0, 0, // PC_VSR + SCIU, 0, 0, 0, 0, 0, // PC_VSRAB + SCIU, 0, 0, 0, 0, 0, // PC_VSRAH + SCIU, 0, 0, 0, 0, 0, // PC_VSRAW + SCIU, 0, 0, 0, 0, 0, // PC_VSRB + SCIU, 0, 0, 0, 0, 0, // PC_VSRH + SCIU, 0, 0, 0, 0, 0, // PC_VSRO + SCIU, 0, 0, 0, 0, 0, // PC_VSRW + SCIU, 0, 0, 0, 0, 0, // PC_VSUBCUW + SCIU, 0, 0, 0, 0, 0, // PC_VSUBFP + SCIU, 0, 0, 0, 0, 0, // PC_VSUBSBS + SCIU, 0, 0, 0, 0, 0, // PC_VSUBSHS + SCIU, 0, 0, 0, 0, 0, // PC_VSUBSWS + SCIU, 0, 0, 0, 0, 0, // PC_VSUBUBM + SCIU, 0, 0, 0, 0, 0, // PC_VSUBUBS + SCIU, 0, 0, 0, 0, 0, // PC_VSUBUHM + SCIU, 0, 0, 0, 0, 0, // PC_VSUBUHS + SCIU, 0, 0, 0, 0, 0, // PC_VSUBUWM + SCIU, 0, 0, 0, 0, 0, // PC_VSUBUWS + SCIU, 0, 0, 0, 0, 0, // PC_VSUMSWS + SCIU, 0, 0, 0, 0, 0, // PC_VSUM2SWS + SCIU, 0, 0, 0, 0, 0, // PC_VSUM4SBS + SCIU, 0, 0, 0, 0, 0, // PC_VSUM4SHS + SCIU, 0, 0, 0, 0, 0, // PC_VSUM4UBS + SCIU, 0, 0, 0, 0, 0, // PC_VUPKHPX + SCIU, 0, 0, 0, 0, 0, // PC_VUPKHSB + SCIU, 0, 0, 0, 0, 0, // PC_VUPKHSH + SCIU, 0, 0, 0, 0, 0, // PC_VUPKLPX + SCIU, 0, 0, 0, 0, 0, // PC_VUPKLSB + SCIU, 0, 0, 0, 0, 0, // PC_VUPKLSH + SCIU, 0, 0, 0, 0, 0, // PC_VXOR + SCIU, 0, 0, 0, 0, 0, // PC_VMADDFP + SCIU, 0, 0, 0, 0, 0, // PC_VMHADDSHS + SCIU, 0, 0, 0, 0, 0, // PC_VMHRADDSHS + SCIU, 0, 0, 0, 0, 0, // PC_VMLADDUHM + SCIU, 0, 0, 0, 0, 0, // PC_VMSUMMBM + SCIU, 0, 0, 0, 0, 0, // PC_VMSUMSHM + SCIU, 0, 0, 0, 0, 0, // PC_VMSUMSHS + SCIU, 0, 0, 0, 0, 0, // PC_VMSUMUBM + SCIU, 0, 0, 0, 0, 0, // PC_VMSUMUHM + SCIU, 0, 0, 0, 0, 0, // PC_VMSUMUHS + SCIU, 0, 0, 0, 0, 0, // PC_VNMSUBFP + SCIU, 0, 0, 0, 0, 0, // PC_VPERM + SCIU, 0, 0, 0, 0, 0, // PC_VSEL + SCIU, 0, 0, 0, 0, 0, // PC_VSLDOI + SCIU, 0, 0, 0, 0, 0, // PC_VMR + SCIU, 0, 0, 0, 0, 0, // PC_VMRP + SCIU, 0, 0, 0, 0, 0, // PC_SLE + SCIU, 0, 0, 0, 0, 0, // PC_SLEQ + SCIU, 0, 0, 0, 0, 0, // PC_SLIQ + SCIU, 0, 0, 0, 0, 0, // PC_SLLIQ + SCIU, 0, 0, 0, 0, 0, // PC_SLLQ + SCIU, 0, 0, 0, 0, 0, // PC_SLQ + SCIU, 0, 0, 0, 0, 0, // PC_SRAIQ + SCIU, 0, 0, 0, 0, 0, // PC_SRAQ + SCIU, 0, 0, 0, 0, 0, // PC_SRE + SCIU, 0, 0, 0, 0, 0, // PC_SREA + SCIU, 0, 0, 0, 0, 0, // PC_SREQ + SCIU, 0, 0, 0, 0, 0, // PC_SRIQ + SCIU, 0, 0, 0, 0, 0, // PC_SRLIQ + SCIU, 0, 0, 0, 0, 0, // PC_SRLQ + SCIU, 0, 0, 0, 0, 0, // PC_SRQ + SCIU, 0, 0, 0, 0, 0, // PC_MASKG + SCIU, 0, 0, 0, 0, 0, // PC_MASKIR + SCIU, 0, 0, 0, 0, 0, // PC_LSCBX + SCIU, 0, 0, 0, 0, 0, // PC_DIV + SCIU, 0, 0, 0, 0, 0, // PC_DIVS + SCIU, 0, 0, 0, 0, 0, // PC_DOZ + SCIU, 0, 0, 0, 0, 0, // PC_MUL + SCIU, 0, 0, 0, 0, 0, // PC_NABS + SCIU, 0, 0, 0, 0, 0, // PC_ABS + SCIU, 0, 0, 0, 0, 0, // PC_CLCS + SCIU, 0, 0, 0, 0, 0, // PC_DOZI + SCIU, 0, 0, 0, 0, 0, // PC_RLMI + SCIU, 0, 0, 0, 0, 0, // PC_RRIB +}; + +static void advance(int firstStage, int oldStage, int newStage) { + PCode *instr = pipeline[oldStage].instr; + int cycles = instruction_timing[instr->op].cycles[newStage - firstStage]; + pipeline[newStage].instr = instr; + pipeline[newStage].remaining = cycles; + pipeline[oldStage].instr = NULL; +} + +static void assign_completion_buffer(PCode *instr) { + completionbuffers.used++; + completionbuffers.free--; + completionbuffers.entries[completionbuffers.nextFreeSlot].instr = instr; + completionbuffers.entries[completionbuffers.nextFreeSlot].completed = 0; + completionbuffers.nextFreeSlot = (completionbuffers.nextFreeSlot + 1) % MaxEntries; +} + +static void complete_instruction(int stage) { + PCode *instr = pipeline[stage].instr; + int buf = 0; + while (buf < MaxEntries && completionbuffers.entries[buf].instr != instr) + buf++; + + completionbuffers.entries[buf].completed = 1; + pipeline[stage].instr = NULL; + + if (stage == SCIU) + sciu_completed_instruction = instr; + else if (stage == SCIU2) + sciu2_completed_instruction = instr; +} + +static void retire_instruction(void) { + completionbuffers.entries[completionbuffers.nextToRetire].instr = NULL; + completionbuffers.used--; + completionbuffers.free++; + completionbuffers.nextToRetire = (completionbuffers.nextToRetire + 1) % MaxEntries; +} + +static int latency(PCode *instr) { + int cycles = instruction_timing[instr->op].latency; + if (PCODE_FLAG_SET_F(instr) & fRecordBit) + cycles += 2; + if (instr->op == PC_LMW || instr->op == PC_STMW) + cycles += instr->argCount - 2; + return cycles; +} + +static void initialize(void) { + int stage; + int i; + + for (stage = 0; stage < NumStages; stage++) + pipeline[stage].instr = NULL; + + completionbuffers.free = MaxEntries; + completionbuffers.used = 0; + completionbuffers.nextToRetire = 0; + completionbuffers.nextFreeSlot = 0; + for (i = 0; i < MaxEntries; i++) + completionbuffers.entries[i].instr = NULL; + + sciu_completed_instruction = NULL; + sciu2_completed_instruction = NULL; +} + +static int can_issue(PCode *instr) { + PCode *check; + int stage = instruction_timing[instr->op].stage; + + if (completionbuffers.free == 0) + return 0; + + if (stage == SCIU) { + int isClear1 = !pipeline[SCIU].instr; + int isClear2 = !pipeline[SCIU2].instr; + if (!isClear1 && !isClear2) + return 0; + if (isClear1 && isClear2) + return 1; + + if (isClear1) + check = pipeline[SCIU2].instr; + else + check = pipeline[SCIU].instr; + + if (is_dependent(instr, check, RegClass_GPR)) + return 0; + if (is_dependent(instr, sciu_completed_instruction, RegClass_GPR)) + return 0; + if (is_dependent(instr, sciu2_completed_instruction, RegClass_GPR)) + return 0; + } else { + if (pipeline[stage].instr) + return 0; + } + + return 1; +} + +static void issue(PCode *instr) { + int stage = instruction_timing[instr->op].stage; + int cycles = instruction_timing[instr->op].cycles[0]; + if (stage == SCIU && pipeline[SCIU].instr) + stage = SCIU2; + assign_completion_buffer(instr); + pipeline[stage].instr = instr; + pipeline[stage].remaining = cycles; +} + +static void advance_clock(void) { + int stage; + int i; + + sciu_completed_instruction = NULL; + sciu2_completed_instruction = NULL; + + for (stage = 0; stage < NumStages; stage++) { + if (pipeline[stage].instr && pipeline[stage].remaining) + --pipeline[stage].remaining; + } + + for (i = 0; i < 5; i++) { + if (completionbuffers.used == 0) + break; + if (completionbuffers.entries[completionbuffers.nextToRetire].completed == 0) + break; + retire_instruction(); + } + + if (pipeline[SCIU].instr && pipeline[SCIU].remaining == 0) + complete_instruction(SCIU); + if (pipeline[SCIU2].instr && pipeline[SCIU2].remaining == 0) + complete_instruction(SCIU2); + if (pipeline[MCIU].instr && pipeline[MCIU].remaining == 0) + complete_instruction(MCIU); + if (pipeline[LSU2].instr && pipeline[LSU2].remaining == 0) + complete_instruction(LSU2); + if (pipeline[FPU3].instr && pipeline[FPU3].remaining == 0) + complete_instruction(FPU3); + if (pipeline[BPU].instr && pipeline[BPU].remaining == 0) + complete_instruction(BPU); + + if ( + pipeline[FPU1].instr && + pipeline[FPU1].remaining == 0 && + (pipeline[FPU1].instr->op == PC_FDIV || pipeline[FPU1].instr->op == PC_FDIVS) + ) + complete_instruction(FPU1); + + if (pipeline[FPU2].instr && pipeline[FPU2].remaining == 0 && !pipeline[FPU3].instr) + advance(FPU1, FPU2, FPU3); + if (pipeline[FPU1].instr && pipeline[FPU1].remaining == 0 && !pipeline[FPU2].instr) + advance(FPU1, FPU1, FPU2); + if (pipeline[LSU1].instr && pipeline[LSU1].remaining == 0 && !pipeline[LSU2].instr) + advance(LSU1, LSU1, LSU2); +} + +static int serializes(PCode *instr) { + return instruction_timing[instr->op].serializes; +} + +MachineInfo machine604 = { + 4, + 1, + 0, + &latency, + &initialize, + &can_issue, + &issue, + &advance_clock, + &serializes, + &default_uses_vpermute_unit +}; diff --git a/compiler_and_linker/unsorted/MachineSimulation7400.c b/compiler_and_linker/unsorted/MachineSimulation7400.c new file mode 100644 index 0000000..56b375c --- /dev/null +++ b/compiler_and_linker/unsorted/MachineSimulation7400.c @@ -0,0 +1,744 @@ +#include "compiler/Scheduler.h" +#include "compiler/PCode.h" +#include "compiler/PCodeInfo.h" + +// https://www.nxp.com/docs/en/reference-manual/MPC7410UM.pdf + +typedef enum Stage { + BPU, // Branch Prediction Unit + IU1, // Integer Unit 1 + IU2, // Integer Unit 2 + + LSU1, // Load/Store Unit + LSU2, + + FPU1, // Floating Point Unit + FPU2, + FPU3, + + SRU, // System Register Unit + VSIU, // Vector Simple Integer Unit + VPU, // AltiVec Permute Unit + + VCIU1, // Vector Complex Integer Unit + VCIU2, + VCIU3, + + VFPU1, // Vector Floating-Point Unit + VFPU2, + VFPU3, + VFPU4, + + NumStages +} Stage; + +static struct { + // the instruction currently in this pipeline stage + PCode *instr; + + // how many cycles are left for this instruction to finish + int remaining; +} pipeline[NumStages]; + +static PCode *iu1_completed_instruction; +static PCode *iu2_completed_instruction; + +enum { + MaxEntries = 8 +}; + +static struct { + // how many entries remain unused in the queue + unsigned int free; + + // how many entries are currently used in the queue + unsigned int used; + + // the index of the next instruction that will be retired + unsigned int nextToRetire; + + // the index of the next free slot that will be used when an instruction is dispatched + unsigned int nextFreeSlot; + + // circular array of entries in the completion queue + struct { + PCode *instr; + int completed; + } entries[MaxEntries]; +} completionbuffers; + +static struct { + // the initial stage for this instruction + Stage stage; + + // the total amount of cycles required by this instruction + char latency; + + // how long it takes to finish each stage + char cycles[4]; + + // does this instruction serialise? + char serializes; + + char unused; +} instruction_timing[OPCODE_MAX] = { + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_B + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BL + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BC + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BCLR + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BCCTR + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BT + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BTLR + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BTCTR + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BF + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BFLR + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BFCTR + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BDNZ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BDNZT + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BDNZF + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BDZ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BDZT + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BDZF + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BLR + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BCTR + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BCTRL + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BLRL + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LBZ + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LBZU + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LBZX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LBZUX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LHZ + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LHZU + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LHZX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LHZUX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LHA + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LHAU + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LHAX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LHAUX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LHBRX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LWZ + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LWZU + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LWZX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LWZUX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LWBRX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LMW + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STB + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STBU + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STBX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STBUX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STH + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STHU + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STHX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STHUX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STHBRX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STW + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STWU + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STWX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STWUX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STWBRX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STMW + LSU1, 3, 1, 2, 0, 0, 0, 0, // PC_DCBF + LSU1, 3, 1, 2, 0, 0, 0, 0, // PC_DCBST + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_DCBT + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_DCBTST + LSU1, 3, 1, 2, 0, 0, 0, 0, // PC_DCBZ + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ADD + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ADDC + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ADDE + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ADDI + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ADDIC + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ADDICR + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ADDIS + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ADDME + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ADDZE + IU1, 19, 19, 0, 0, 0, 0, 0, // PC_DIVW + IU1, 19, 19, 0, 0, 0, 0, 0, // PC_DIVWU + IU1, 5, 5, 0, 0, 0, 0, 0, // PC_MULHW + IU1, 6, 5, 0, 0, 0, 0, 0, // PC_MULHWU + IU1, 3, 3, 0, 0, 0, 0, 0, // PC_MULLI + IU1, 5, 5, 0, 0, 0, 0, 0, // PC_MULLW + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_NEG + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_SUBF + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_SUBFC + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_SUBFE + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_SUBFIC + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_SUBFME + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_SUBFZE + IU2, 3, 1, 0, 0, 0, 0, 0, // PC_CMPI + IU2, 3, 1, 0, 0, 0, 0, 0, // PC_CMP + IU2, 3, 1, 0, 0, 0, 0, 0, // PC_CMPLI + IU2, 3, 1, 0, 0, 0, 0, 0, // PC_CMPL + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ANDI + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ANDIS + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ORI + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ORIS + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_XORI + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_XORIS + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_AND + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_OR + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_XOR + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_NAND + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_NOR + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_EQV + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ANDC + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ORC + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_EXTSB + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_EXTSH + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_CNTLZW + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_RLWINM + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_RLWNM + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_RLWIMI + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_SLW + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_SRW + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_SRAWI + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_SRAW + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_CRAND + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_CRANDC + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_CREQV + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_CRNAND + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_CRNOR + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_CROR + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_CRORC + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_CRXOR + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_MCRF + SRU, 2, 2, 0, 0, 0, 1, 0, // PC_MTXER + SRU, 2, 2, 0, 0, 0, 1, 0, // PC_MTCTR + SRU, 2, 2, 0, 0, 0, 1, 0, // PC_MTLR + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_MTCRF + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_MTMSR + SRU, 2, 2, 0, 0, 0, 1, 0, // PC_MTSPR + SRU, 1, 1, 0, 0, 0, 0, 0, // PC_MFMSR + SRU, 3, 3, 0, 0, 0, 1, 0, // PC_MFSPR + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_MFXER + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_MFCTR + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_MFLR + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_MFCR + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_MFFS + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_MTFSF + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_EIEIO + SRU, 2, 2, 0, 0, 0, 1, 0, // PC_ISYNC + SRU, 3, 3, 0, 0, 0, 1, 0, // PC_SYNC + SRU, 2, 2, 0, 0, 0, 1, 0, // PC_RFI + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_LI + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_LIS + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_MR + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_NOP + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_NOT + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LFS + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LFSU + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LFSX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LFSUX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LFD + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LFDU + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LFDX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LFDUX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STFS + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STFSU + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STFSX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STFSUX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STFD + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STFDU + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STFDX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STFDUX + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FMR + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FABS + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FNEG + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FNABS + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FADD + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FADDS + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FSUB + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FSUBS + FPU1, 4, 2, 1, 1, 0, 0, 0, // PC_FMUL + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FMULS + FPU1, 31, 31, 0, 0, 0, 0, 0, // PC_FDIV + FPU1, 17, 17, 0, 0, 0, 0, 0, // PC_FDIVS + FPU1, 4, 2, 1, 1, 0, 0, 0, // PC_FMADD + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FMADDS + FPU1, 4, 2, 1, 1, 0, 0, 0, // PC_FMSUB + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FMSUBS + FPU1, 4, 2, 1, 1, 0, 0, 0, // PC_FNMADD + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FNMADDS + FPU1, 4, 2, 1, 1, 0, 0, 0, // PC_FNMSUB + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FNMSUBS + FPU1, 10, 10, 0, 0, 0, 0, 0, // PC_FRES + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FRSQRTE + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FSEL + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FRSP + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FCTIW + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FCTIWZ + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FCMPU + FPU1, 3, 1, 1, 1, 0, 0, 0, // PC_FCMPO + LSU1, 2, 1, 1, 0, 0, 1, 0, // PC_LWARX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LSWI + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LSWX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STFIWX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STSWI + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STSWX + LSU1, 2, 1, 1, 0, 0, 1, 0, // PC_STWCX + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ECIWX + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ECOWX + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_DCBI + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ICBI + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_MCRFS + SRU, 1, 1, 0, 0, 0, 1, 0, // PC_MCRXR + SRU, 1, 1, 0, 0, 0, 0, 0, // PC_MFTB + SRU, 3, 3, 0, 0, 0, 0, 0, // PC_MFSR + SRU, 2, 2, 0, 0, 0, 1, 0, // PC_MTSR + SRU, 3, 3, 0, 0, 0, 0, 0, // PC_MFSRIN + SRU, 2, 2, 0, 0, 0, 1, 0, // PC_MTSRIN + FPU1, 1, 1, 0, 0, 0, 0, 0, // PC_MTFSB0 + FPU1, 1, 1, 0, 0, 0, 0, 0, // PC_MTFSB1 + FPU1, 1, 1, 0, 0, 0, 0, 0, // PC_MTFSFI + SRU, 2, 2, 0, 0, 0, 1, 0, // PC_SC + FPU1, 1, 1, 0, 0, 0, 0, 0, // PC_FSQRT + FPU1, 1, 1, 0, 0, 0, 0, 0, // PC_FSQRTS + LSU1, 1, 1, 0, 0, 0, 0, 0, // PC_TLBIA + LSU1, 1, 1, 0, 0, 0, 0, 0, // PC_TLBIE + LSU1, 1, 1, 0, 0, 0, 0, 0, // PC_TLBLD + LSU1, 1, 1, 0, 0, 0, 0, 0, // PC_TLBLI + LSU1, 1, 1, 0, 0, 0, 1, 0, // PC_TLBSYNC + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_TW + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_TRAP + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_TWI + IU2, 1, 1, 0, 0, 0, 1, 0, // PC_OPWORD + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_MFROM + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_DSA + IU2, 1, 1, 0, 0, 0, 0, 0, // PC_ESA + IU2, 1, 0, 0, 0, 0, 0, 0, // PC_DCCCI + IU2, 1, 0, 0, 0, 0, 0, 0, // PC_DCREAD + IU2, 1, 0, 0, 0, 0, 0, 0, // PC_ICBT + IU2, 1, 0, 0, 0, 0, 0, 0, // PC_ICCCI + IU2, 1, 0, 0, 0, 0, 0, 0, // PC_ICREAD + IU2, 1, 0, 0, 0, 0, 0, 0, // PC_RFCI + IU2, 1, 0, 0, 0, 0, 0, 0, // PC_TLBRE + IU2, 1, 0, 0, 0, 0, 0, 0, // PC_TLBSX + IU2, 1, 0, 0, 0, 0, 0, 0, // PC_TLBWE + IU2, 1, 0, 0, 0, 0, 0, 0, // PC_WRTEE + IU2, 1, 0, 0, 0, 0, 0, 0, // PC_WRTEEI + IU2, 1, 0, 0, 0, 0, 0, 0, // PC_MFDCR + IU2, 1, 0, 0, 0, 0, 0, 0, // PC_MTDCR + LSU1, 3, 1, 2, 0, 0, 0, 0, // PC_DCBA + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_DSS + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_DSSALL + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_DST + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_DSTT + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_DSTST + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_DSTSTT + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LVEBX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LVEHX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LVEWX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LVSL + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LVSR + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LVX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_LVXL + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STVEBX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STVEHX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STVEWX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STVX + LSU1, 2, 1, 1, 0, 0, 0, 0, // PC_STVXL + VSIU, 1, 1, 0, 0, 0, 1, 0, // PC_MFVSCR + VSIU, 1, 1, 0, 0, 0, 1, 0, // PC_MTVSCR + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VADDCUW + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VADDFP + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VADDSBS + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VADDSHS + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VADDSWS + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VADDUBM + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VADDUBS + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VADDUHM + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VADDUHS + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VADDUWM + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VADDUWS + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VAND + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VANDC + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VAVGSB + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VAVGSH + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VAVGSW + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VAVGUB + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VAVGUH + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VAVGUW + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VCFSX + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VCFUX + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VCMPBFP + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VCMPEQFP + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPEQUB + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPEQUH + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPEQUW + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VCMPGEFP + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VCMPGTFP + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPGTSB + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPGTSH + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPGTSW + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPGTUB + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPGTUH + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPGTUW + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VCTSXS + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VCTUXS + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VEXPTEFP + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VLOGEFP + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VMAXFP + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VMAXSB + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VMAXSH + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VMAXSW + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VMAXUB + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VMAXUH + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VMAXUW + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VMINFP + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VMINSB + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VMINSH + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VMINSW + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VMINUB + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VMINUH + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VMINUW + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VMRGHB + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VMRGHH + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VMRGHW + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VMRGLB + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VMRGLH + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VMRGLW + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMULESB + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMULESH + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMULEUB + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMULEUH + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMULOSB + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMULOSH + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMULOUB + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMULOUH + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VNOR + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VOR + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VPKPX + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VPKSHSS + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VPKSHUS + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VPKSWSS + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VPKSWUS + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VPKUHUM + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VPKUHUS + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VPKUWUM + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VPKUWUS + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VREFP + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VRFIM + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VRFIN + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VRFIP + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VRFIZ + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VRLB + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VRLH + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VRLW + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VRSQRTEFP + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSL + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSLB + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSLH + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VSLO + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSLW + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VSPLTB + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VSPLTH + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VSPLTW + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VSPLTISB + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VSPLTISH + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VSPLTISW + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSR + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSRAB + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSRAH + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSRAW + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSRB + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSRH + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VSRO + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSRW + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBCUW + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VSUBFP + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBSBS + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBSHS + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBSWS + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBUBM + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBUBS + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBUHM + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBUHS + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBUWM + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBUWS + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VSUMSWS + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VSUM2SWS + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VSUM4SBS + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VSUM4SHS + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VSUM4UBS + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VUPKHPX + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VUPKHSB + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VUPKHSH + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VUPKLPX + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VUPKLSB + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VUPKLSH + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VXOR + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VMADDFP + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMHADDSHS + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMHRADDSHS + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMLADDUHM + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMSUMMBM + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMSUMSHM + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMSUMSHS + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMSUMUBM + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMSUMUHM + VCIU1, 3, 1, 1, 1, 0, 0, 0, // PC_VMSUMUHS + VFPU1, 4, 1, 1, 1, 1, 0, 0, // PC_VNMSUBFP + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VPERM + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VSEL + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VSLDOI + VSIU, 1, 1, 0, 0, 0, 0, 0, // PC_VMR + VPU, 1, 1, 0, 0, 0, 0, 0, // PC_VMRP + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SLE + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SLEQ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SLIQ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SLLIQ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SLLQ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SLQ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SRAIQ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SRAQ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SRE + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SREA + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SREQ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SRIQ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SRLIQ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SRLQ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_SRQ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_MASKG + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_MASKIR + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_LSCBX + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_DIV + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_DIVS + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_DOZ + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_MUL + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_NABS + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_ABS + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_CLCS + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_DOZI + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_RLMI + BPU, 0, 0, 0, 0, 0, 0, 0, // PC_RRIB +}; + +static void advance(int firstStage, int oldStage, int newStage) { + PCode *instr = pipeline[oldStage].instr; + int cycles = instruction_timing[instr->op].cycles[newStage - firstStage]; + pipeline[newStage].instr = instr; + pipeline[newStage].remaining = cycles; + pipeline[oldStage].instr = NULL; +} + +static void assign_completion_buffer(PCode *instr) { + completionbuffers.used++; + completionbuffers.free--; + completionbuffers.entries[completionbuffers.nextFreeSlot].instr = instr; + completionbuffers.entries[completionbuffers.nextFreeSlot].completed = 0; + completionbuffers.nextFreeSlot = (completionbuffers.nextFreeSlot + 1) % MaxEntries; +} + +static void complete_instruction(int stage) { + PCode *instr = pipeline[stage].instr; + int buf = 0; + while (buf < MaxEntries && completionbuffers.entries[buf].instr != instr) + buf++; + + completionbuffers.entries[buf].completed = 1; + pipeline[stage].instr = NULL; + + if (stage == IU1) + iu1_completed_instruction = instr; + else if (stage == IU2) + iu2_completed_instruction = instr; +} + +static void retire_instruction(void) { + completionbuffers.entries[completionbuffers.nextToRetire].instr = NULL; + completionbuffers.used--; + completionbuffers.free++; + completionbuffers.nextToRetire = (completionbuffers.nextToRetire + 1) % MaxEntries; +} + +static int latency(PCode *instr) { + int cycles = instruction_timing[instr->op].latency; + if (PCODE_FLAG_SET_F(instr) & fRecordBit) + cycles += 2; + if (instr->op == PC_LMW || instr->op == PC_STMW) + cycles += instr->argCount - 2; + return cycles; +} + +static void initialize(void) { + int stage; + int i; + + for (stage = 0; stage < NumStages; stage++) + pipeline[stage].instr = NULL; + + completionbuffers.free = MaxEntries; + completionbuffers.used = 0; + completionbuffers.nextToRetire = 0; + completionbuffers.nextFreeSlot = 0; + for (i = 0; i < MaxEntries; i++) + completionbuffers.entries[i].instr = NULL; + + iu1_completed_instruction = NULL; + iu2_completed_instruction = NULL; +} + +static int can_issue(PCode *instr) { + int stage; + + if (completionbuffers.free == 0) + return 0; + + stage = instruction_timing[instr->op].stage; + + if (stage == IU2) { + PCode *check; + int isClear1 = !pipeline[IU1].instr; + int isClear2 = !pipeline[IU2].instr; + if (!isClear1 && !isClear2) + return 0; + if (isClear1 && isClear2) + return 1; + + if (isClear1) + check = pipeline[IU2].instr; + else + check = pipeline[IU1].instr; + + if (is_dependent(instr, check, RegClass_GPR)) + return 0; + if (is_dependent(instr, iu1_completed_instruction, RegClass_GPR)) + return 0; + if (is_dependent(instr, iu2_completed_instruction, RegClass_GPR)) + return 0; + } else if (stage == VFPU1 || stage == VCIU1 || stage == VSIU || stage == VPU) { + PCode *check; + int isVpuClear = !pipeline[VPU].instr; + int isVFpuClear = !pipeline[VFPU1].instr; + int isVCiuClear = !pipeline[VCIU1].instr; + int isVSiuClear = !pipeline[VSIU].instr; + + if (stage == VPU) { + if (!isVpuClear) + return 0; + + if (!isVFpuClear) + check = pipeline[VFPU1].instr; + else if (!isVCiuClear) + check = pipeline[VCIU1].instr; + else if (!isVSiuClear) + check = pipeline[VSIU].instr; + else + check = NULL; + + if (is_dependent(instr, check, RegClass_VR)) + return 0; + } else { + if (!isVFpuClear || !isVCiuClear || !isVSiuClear) + return 0; + + if (!isVpuClear && is_dependent(instr, pipeline[VPU].instr, RegClass_VR)) + return 0; + } + } else { + if (pipeline[stage].instr) + return 0; + } + + if ((instr->flags & fIsWrite) && pipeline[LSU2].instr && (pipeline[LSU2].instr->flags & fIsWrite)) + return 0; + + return 1; +} + +static void issue(PCode *instr) { + int stage = instruction_timing[instr->op].stage; + int cycles = instruction_timing[instr->op].cycles[0]; + assign_completion_buffer(instr); + if (stage == IU2 && !pipeline[IU1].instr) + stage = IU1; + pipeline[stage].instr = instr; + pipeline[stage].remaining = cycles; +} + +static void advance_clock(void) { + int stage; + + iu1_completed_instruction = NULL; + iu2_completed_instruction = NULL; + + for (stage = 0; stage < NumStages; stage++) { + if (pipeline[stage].instr && pipeline[stage].remaining) + --pipeline[stage].remaining; + } + + if (completionbuffers.used && completionbuffers.entries[completionbuffers.nextToRetire].completed) { + retire_instruction(); + if (completionbuffers.used && completionbuffers.entries[completionbuffers.nextToRetire].completed) { + retire_instruction(); + } + } + + if (pipeline[IU1].instr && pipeline[IU1].remaining == 0) + complete_instruction(IU1); + if (pipeline[VPU].instr && pipeline[VPU].remaining == 0) + complete_instruction(VPU); + if (pipeline[LSU2].instr && pipeline[LSU2].remaining == 0) + complete_instruction(LSU2); + if (pipeline[FPU3].instr && pipeline[FPU3].remaining == 0) + complete_instruction(FPU3); + if (pipeline[SRU].instr && pipeline[SRU].remaining == 0) + complete_instruction(SRU); + if (pipeline[BPU].instr && pipeline[BPU].remaining == 0) + complete_instruction(BPU); + if (pipeline[VSIU].instr && pipeline[VSIU].remaining == 0) + complete_instruction(VSIU); + if (pipeline[VCIU3].instr && pipeline[VCIU3].remaining == 0) + complete_instruction(VCIU3); + if (pipeline[VFPU4].instr && pipeline[VFPU4].remaining == 0) + complete_instruction(VFPU4); + if (pipeline[IU2].instr && pipeline[IU2].remaining == 0) + complete_instruction(IU2); + + if ( + pipeline[FPU1].instr && + pipeline[FPU1].remaining == 0 && + (pipeline[FPU1].instr->op == PC_FDIV || pipeline[FPU1].instr->op == PC_FDIVS) + ) + complete_instruction(FPU1); + + if (pipeline[FPU2].instr && pipeline[FPU2].remaining == 0 && !pipeline[FPU3].instr) + advance(FPU1, FPU2, FPU3); + if (pipeline[FPU1].instr && pipeline[FPU1].remaining == 0 && !pipeline[FPU2].instr) + advance(FPU1, FPU1, FPU2); + + if (pipeline[LSU1].instr && pipeline[LSU1].remaining == 0 && !pipeline[LSU2].instr) + advance(LSU1, LSU1, LSU2); + + if (pipeline[VCIU2].instr && pipeline[VCIU2].remaining == 0 && !pipeline[VCIU3].instr) + advance(VCIU1, VCIU2, VCIU3); + if (pipeline[VCIU1].instr && pipeline[VCIU1].remaining == 0 && !pipeline[VCIU2].instr) + advance(VCIU1, VCIU1, VCIU2); + + if (pipeline[VFPU3].instr && pipeline[VFPU3].remaining == 0 && !pipeline[VFPU4].instr) + advance(VFPU1, VFPU3, VFPU4); + if (pipeline[VFPU2].instr && pipeline[VFPU2].remaining == 0 && !pipeline[VFPU3].instr) + advance(VFPU1, VFPU2, VFPU3); + if (pipeline[VFPU1].instr && pipeline[VFPU1].remaining == 0 && !pipeline[VFPU2].instr) + advance(VFPU1, VFPU1, VFPU2); +} + +static int serializes(PCode *instr) { + return instruction_timing[instr->op].serializes; +} + +static int uses_vpermute_unit_7400(PCode *instr) { + return instruction_timing[instr->op].stage == VPU; +} + +MachineInfo machine7400 = { + 2, + 1, + 0, + &latency, + &initialize, + &can_issue, + &issue, + &advance_clock, + &serializes, + &uses_vpermute_unit_7400 +}; diff --git a/compiler_and_linker/unsorted/MachineSimulation750.c b/compiler_and_linker/unsorted/MachineSimulation750.c new file mode 100644 index 0000000..d412df3 --- /dev/null +++ b/compiler_and_linker/unsorted/MachineSimulation750.c @@ -0,0 +1,678 @@ +#include "compiler/Scheduler.h" +#include "compiler/PCode.h" +#include "compiler/PCodeInfo.h" + +// https://www.nxp.com/docs/en/reference-manual/MPC750UM.pdf + +typedef enum Stage { + BPU, // Branch Prediction Unit + IU1, // Integer Unit 1 + IU2, // Integer Unit 2 + + LSU1, // Load/Store Unit + LSU2, + + FPU1, // Floating Point Unit + FPU2, + FPU3, + + SRU, // System Register Unit + + NumStages +} Stage; + +static struct { + // the instruction currently in this pipeline stage + PCode *instr; + + // how many cycles are left for this instruction to finish + int remaining; +} pipeline[NumStages]; + +static PCode *iu1_completed_instruction; +static PCode *iu2_completed_instruction; + +enum { + MaxEntries = 6 +}; + +static struct { + // how many entries remain unused in the queue + unsigned int free; + + // how many entries are currently used in the queue + unsigned int used; + + // the index of the next instruction that will be retired + unsigned int nextToRetire; + + // the index of the next free slot that will be used when an instruction is dispatched + unsigned int nextFreeSlot; + + // circular array of entries in the completion queue + struct { + PCode *instr; + int completed; + } entries[MaxEntries]; +} completionbuffers; + +static struct { + // the initial stage for this instruction + Stage stage; + + // the total amount of cycles required by this instruction + char latency; + + // how long it takes to finish each stage + char cycles[3]; + + // does this instruction serialise? + char serializes; +} instruction_timing[OPCODE_MAX] = { + BPU, 0, 0, 0, 0, 1, // PC_B + BPU, 0, 0, 0, 0, 1, // PC_BL + BPU, 0, 0, 0, 0, 1, // PC_BC + BPU, 0, 0, 0, 0, 1, // PC_BCLR + BPU, 0, 0, 0, 0, 1, // PC_BCCTR + BPU, 0, 0, 0, 0, 1, // PC_BT + BPU, 0, 0, 0, 0, 1, // PC_BTLR + BPU, 0, 0, 0, 0, 1, // PC_BTCTR + BPU, 0, 0, 0, 0, 1, // PC_BF + BPU, 0, 0, 0, 0, 1, // PC_BFLR + BPU, 0, 0, 0, 0, 1, // PC_BFCTR + BPU, 0, 0, 0, 0, 1, // PC_BDNZ + BPU, 0, 0, 0, 0, 1, // PC_BDNZT + BPU, 0, 0, 0, 0, 1, // PC_BDNZF + BPU, 0, 0, 0, 0, 1, // PC_BDZ + BPU, 0, 0, 0, 0, 1, // PC_BDZT + BPU, 0, 0, 0, 0, 1, // PC_BDZF + BPU, 0, 0, 0, 0, 1, // PC_BLR + BPU, 0, 0, 0, 0, 1, // PC_BCTR + BPU, 0, 0, 0, 0, 1, // PC_BCTRL + BPU, 0, 0, 0, 0, 1, // PC_BLRL + LSU1, 2, 1, 1, 0, 0, // PC_LBZ + LSU1, 2, 1, 1, 0, 0, // PC_LBZU + LSU1, 2, 1, 1, 0, 0, // PC_LBZX + LSU1, 2, 1, 1, 0, 0, // PC_LBZUX + LSU1, 2, 1, 1, 0, 0, // PC_LHZ + LSU1, 2, 1, 1, 0, 0, // PC_LHZU + LSU1, 2, 1, 1, 0, 0, // PC_LHZX + LSU1, 2, 1, 1, 0, 0, // PC_LHZUX + LSU1, 2, 1, 1, 0, 0, // PC_LHA + LSU1, 2, 1, 1, 0, 0, // PC_LHAU + LSU1, 2, 1, 1, 0, 0, // PC_LHAX + LSU1, 2, 1, 1, 0, 0, // PC_LHAUX + LSU1, 2, 1, 1, 0, 0, // PC_LHBRX + LSU1, 2, 1, 1, 0, 0, // PC_LWZ + LSU1, 2, 1, 1, 0, 0, // PC_LWZU + LSU1, 2, 1, 1, 0, 0, // PC_LWZX + LSU1, 2, 1, 1, 0, 0, // PC_LWZUX + LSU1, 2, 1, 1, 0, 0, // PC_LWBRX + LSU1, 2, 1, 1, 0, 0, // PC_LMW + LSU1, 2, 1, 1, 0, 0, // PC_STB + LSU1, 2, 1, 1, 0, 0, // PC_STBU + LSU1, 2, 1, 1, 0, 0, // PC_STBX + LSU1, 2, 1, 1, 0, 0, // PC_STBUX + LSU1, 2, 1, 1, 0, 0, // PC_STH + LSU1, 2, 1, 1, 0, 0, // PC_STHU + LSU1, 2, 1, 1, 0, 0, // PC_STHX + LSU1, 2, 1, 1, 0, 0, // PC_STHUX + LSU1, 2, 1, 1, 0, 0, // PC_STHBRX + LSU1, 2, 1, 1, 0, 0, // PC_STW + LSU1, 2, 1, 1, 0, 0, // PC_STWU + LSU1, 2, 1, 1, 0, 0, // PC_STWX + LSU1, 2, 1, 1, 0, 0, // PC_STWUX + LSU1, 2, 1, 1, 0, 0, // PC_STWBRX + LSU1, 2, 1, 1, 0, 0, // PC_STMW + LSU1, 3, 1, 2, 0, 0, // PC_DCBF + LSU1, 3, 1, 2, 0, 0, // PC_DCBST + LSU1, 2, 1, 1, 0, 0, // PC_DCBT + LSU1, 2, 1, 1, 0, 0, // PC_DCBTST + LSU1, 3, 1, 2, 0, 0, // PC_DCBZ + IU2, 1, 1, 0, 0, 0, // PC_ADD + IU2, 1, 1, 0, 0, 0, // PC_ADDC + IU2, 1, 1, 0, 0, 0, // PC_ADDE + IU2, 1, 1, 0, 0, 0, // PC_ADDI + IU2, 1, 1, 0, 0, 0, // PC_ADDIC + IU2, 1, 1, 0, 0, 0, // PC_ADDICR + IU2, 1, 1, 0, 0, 0, // PC_ADDIS + IU2, 1, 1, 0, 0, 0, // PC_ADDME + IU2, 1, 1, 0, 0, 0, // PC_ADDZE + IU1, 19, 19, 0, 0, 0, // PC_DIVW + IU1, 19, 19, 0, 0, 0, // PC_DIVWU + IU1, 5, 5, 0, 0, 0, // PC_MULHW + IU1, 6, 5, 0, 0, 0, // PC_MULHWU + IU1, 3, 3, 0, 0, 0, // PC_MULLI + IU1, 5, 5, 0, 0, 0, // PC_MULLW + IU2, 1, 1, 0, 0, 0, // PC_NEG + IU2, 1, 1, 0, 0, 0, // PC_SUBF + IU2, 1, 1, 0, 0, 0, // PC_SUBFC + IU2, 1, 1, 0, 0, 0, // PC_SUBFE + IU2, 1, 1, 0, 0, 0, // PC_SUBFIC + IU2, 1, 1, 0, 0, 0, // PC_SUBFME + IU2, 1, 1, 0, 0, 0, // PC_SUBFZE + IU2, 3, 1, 0, 0, 0, // PC_CMPI + IU2, 3, 1, 0, 0, 0, // PC_CMP + IU2, 3, 1, 0, 0, 0, // PC_CMPLI + IU2, 3, 1, 0, 0, 0, // PC_CMPL + IU2, 1, 1, 0, 0, 0, // PC_ANDI + IU2, 1, 1, 0, 0, 0, // PC_ANDIS + IU2, 1, 1, 0, 0, 0, // PC_ORI + IU2, 1, 1, 0, 0, 0, // PC_ORIS + IU2, 1, 1, 0, 0, 0, // PC_XORI + IU2, 1, 1, 0, 0, 0, // PC_XORIS + IU2, 1, 1, 0, 0, 0, // PC_AND + IU2, 1, 1, 0, 0, 0, // PC_OR + IU2, 1, 1, 0, 0, 0, // PC_XOR + IU2, 1, 1, 0, 0, 0, // PC_NAND + IU2, 1, 1, 0, 0, 0, // PC_NOR + IU2, 1, 1, 0, 0, 0, // PC_EQV + IU2, 1, 1, 0, 0, 0, // PC_ANDC + IU2, 1, 1, 0, 0, 0, // PC_ORC + IU2, 1, 1, 0, 0, 0, // PC_EXTSB + IU2, 1, 1, 0, 0, 0, // PC_EXTSH + IU2, 1, 1, 0, 0, 0, // PC_CNTLZW + IU2, 1, 1, 0, 0, 0, // PC_RLWINM + IU2, 1, 1, 0, 0, 0, // PC_RLWNM + IU2, 1, 1, 0, 0, 0, // PC_RLWIMI + IU2, 1, 1, 0, 0, 0, // PC_SLW + IU2, 1, 1, 0, 0, 0, // PC_SRW + IU2, 1, 1, 0, 0, 0, // PC_SRAWI + IU2, 1, 1, 0, 0, 0, // PC_SRAW + SRU, 1, 1, 0, 0, 1, // PC_CRAND + SRU, 1, 1, 0, 0, 1, // PC_CRANDC + SRU, 1, 1, 0, 0, 1, // PC_CREQV + SRU, 1, 1, 0, 0, 1, // PC_CRNAND + SRU, 1, 1, 0, 0, 1, // PC_CRNOR + SRU, 1, 1, 0, 0, 1, // PC_CROR + SRU, 1, 1, 0, 0, 1, // PC_CRORC + SRU, 1, 1, 0, 0, 1, // PC_CRXOR + SRU, 1, 1, 0, 0, 1, // PC_MCRF + SRU, 2, 2, 0, 0, 1, // PC_MTXER + SRU, 2, 2, 0, 0, 1, // PC_MTCTR + SRU, 2, 2, 0, 0, 1, // PC_MTLR + SRU, 1, 1, 0, 0, 1, // PC_MTCRF + SRU, 1, 1, 0, 0, 0, // PC_MTMSR + SRU, 1, 1, 0, 0, 1, // PC_MTSPR + SRU, 1, 1, 0, 0, 1, // PC_MFMSR + SRU, 1, 1, 0, 0, 1, // PC_MFSPR + SRU, 1, 1, 0, 0, 1, // PC_MFXER + SRU, 1, 1, 0, 0, 1, // PC_MFCTR + SRU, 1, 1, 0, 0, 1, // PC_MFLR + SRU, 1, 1, 0, 0, 1, // PC_MFCR + FPU1, 3, 1, 1, 1, 0, // PC_MFFS + FPU1, 3, 1, 1, 1, 0, // PC_MTFSF + SRU, 1, 1, 0, 0, 1, // PC_EIEIO + SRU, 2, 2, 0, 0, 1, // PC_ISYNC + SRU, 3, 3, 0, 0, 1, // PC_SYNC + SRU, 1, 1, 0, 0, 1, // PC_RFI + IU2, 1, 1, 0, 0, 0, // PC_LI + IU2, 1, 1, 0, 0, 0, // PC_LIS + IU2, 1, 1, 0, 0, 0, // PC_MR + IU2, 1, 1, 0, 0, 0, // PC_NOP + IU2, 1, 1, 0, 0, 0, // PC_NOT + LSU1, 2, 1, 1, 0, 0, // PC_LFS + LSU1, 2, 1, 1, 0, 0, // PC_LFSU + LSU1, 2, 1, 1, 0, 0, // PC_LFSX + LSU1, 2, 1, 1, 0, 0, // PC_LFSUX + LSU1, 2, 1, 1, 0, 0, // PC_LFD + LSU1, 2, 1, 1, 0, 0, // PC_LFDU + LSU1, 2, 1, 1, 0, 0, // PC_LFDX + LSU1, 2, 1, 1, 0, 0, // PC_LFDUX + LSU1, 2, 1, 1, 0, 0, // PC_STFS + LSU1, 2, 1, 1, 0, 0, // PC_STFSU + LSU1, 2, 1, 1, 0, 0, // PC_STFSX + LSU1, 2, 1, 1, 0, 0, // PC_STFSUX + LSU1, 2, 1, 1, 0, 0, // PC_STFD + LSU1, 2, 1, 1, 0, 0, // PC_STFDU + LSU1, 2, 1, 1, 0, 0, // PC_STFDX + LSU1, 2, 1, 1, 0, 0, // PC_STFDUX + FPU1, 3, 1, 1, 1, 0, // PC_FMR + FPU1, 3, 1, 1, 1, 0, // PC_FABS + FPU1, 3, 1, 1, 1, 0, // PC_FNEG + FPU1, 3, 1, 1, 1, 0, // PC_FNABS + FPU1, 3, 1, 1, 1, 0, // PC_FADD + FPU1, 3, 1, 1, 1, 0, // PC_FADDS + FPU1, 3, 1, 1, 1, 0, // PC_FSUB + FPU1, 3, 1, 1, 1, 0, // PC_FSUBS + FPU1, 4, 2, 1, 1, 0, // PC_FMUL + FPU1, 3, 1, 1, 1, 0, // PC_FMULS + FPU1, 31, 31, 0, 0, 0, // PC_FDIV + FPU1, 17, 17, 0, 0, 0, // PC_FDIVS + FPU1, 4, 2, 1, 1, 0, // PC_FMADD + FPU1, 3, 1, 1, 1, 0, // PC_FMADDS + FPU1, 4, 2, 1, 1, 0, // PC_FMSUB + FPU1, 3, 1, 1, 1, 0, // PC_FMSUBS + FPU1, 4, 2, 1, 1, 0, // PC_FNMADD + FPU1, 3, 1, 1, 1, 0, // PC_FNMADDS + FPU1, 4, 2, 1, 1, 0, // PC_FNMSUB + FPU1, 3, 1, 1, 1, 0, // PC_FNMSUBS + FPU1, 10, 10, 0, 0, 0, // PC_FRES + FPU1, 3, 1, 1, 1, 0, // PC_FRSQRTE + FPU1, 3, 1, 1, 1, 0, // PC_FSEL + FPU1, 3, 1, 1, 1, 0, // PC_FRSP + FPU1, 3, 1, 1, 1, 0, // PC_FCTIW + FPU1, 3, 1, 1, 1, 0, // PC_FCTIWZ + FPU1, 3, 1, 1, 1, 0, // PC_FCMPU + FPU1, 3, 1, 1, 1, 0, // PC_FCMPO + LSU1, 1, 1, 0, 0, 0, // PC_LWARX + LSU1, 1, 1, 0, 0, 0, // PC_LSWI + LSU1, 1, 1, 0, 0, 0, // PC_LSWX + LSU1, 1, 1, 0, 0, 0, // PC_STFIWX + LSU1, 1, 1, 0, 0, 0, // PC_STSWI + LSU1, 1, 1, 0, 0, 0, // PC_STSWX + LSU1, 1, 1, 0, 0, 0, // PC_STWCX + IU1, 1, 1, 0, 0, 1, // PC_ECIWX + IU1, 1, 1, 0, 0, 1, // PC_ECOWX + IU1, 1, 1, 0, 0, 0, // PC_DCBI + IU1, 1, 1, 0, 0, 0, // PC_ICBI + IU1, 1, 1, 0, 0, 0, // PC_MCRFS + IU1, 1, 1, 0, 0, 0, // PC_MCRXR + IU1, 1, 1, 0, 0, 0, // PC_MFTB + IU1, 1, 1, 0, 0, 0, // PC_MFSR + IU1, 1, 1, 0, 0, 0, // PC_MTSR + IU1, 1, 1, 0, 0, 0, // PC_MFSRIN + IU1, 1, 1, 0, 0, 0, // PC_MTSRIN + IU1, 1, 1, 0, 0, 0, // PC_MTFSB0 + IU1, 1, 1, 0, 0, 0, // PC_MTFSB1 + IU1, 1, 1, 0, 0, 0, // PC_MTFSFI + IU1, 1, 1, 0, 0, 1, // PC_SC + FPU1, 1, 1, 0, 0, 0, // PC_FSQRT + FPU1, 1, 1, 0, 0, 0, // PC_FSQRTS + IU1, 1, 1, 0, 0, 0, // PC_TLBIA + IU1, 1, 1, 0, 0, 0, // PC_TLBIE + IU1, 1, 1, 0, 0, 0, // PC_TLBLD + IU1, 1, 1, 0, 0, 0, // PC_TLBLI + IU1, 1, 1, 0, 0, 0, // PC_TLBSYNC + IU1, 1, 1, 0, 0, 1, // PC_TW + IU1, 1, 1, 0, 0, 1, // PC_TRAP + IU1, 1, 1, 0, 0, 1, // PC_TWI + IU1, 1, 1, 0, 0, 1, // PC_OPWORD + IU1, 1, 1, 0, 0, 0, // PC_MFROM + IU1, 1, 1, 0, 0, 1, // PC_DSA + IU1, 1, 1, 0, 0, 1, // PC_ESA + IU1, 0, 0, 0, 0, 0, // PC_DCCCI + IU1, 0, 0, 0, 0, 0, // PC_DCREAD + IU1, 0, 0, 0, 0, 0, // PC_ICBT + IU1, 0, 0, 0, 0, 0, // PC_ICCCI + IU1, 0, 0, 0, 0, 0, // PC_ICREAD + IU1, 0, 0, 0, 0, 0, // PC_RFCI + IU1, 0, 0, 0, 0, 0, // PC_TLBRE + IU1, 0, 0, 0, 0, 0, // PC_TLBSX + IU1, 0, 0, 0, 0, 0, // PC_TLBWE + IU1, 0, 0, 0, 0, 0, // PC_WRTEE + IU1, 0, 0, 0, 0, 0, // PC_WRTEEI + IU1, 0, 0, 0, 0, 0, // PC_MFDCR + IU1, 0, 0, 0, 0, 0, // PC_MTDCR + IU1, 0, 0, 0, 0, 0, // PC_DCBA + BPU, 0, 0, 0, 0, 0, // PC_DSS + BPU, 0, 0, 0, 0, 0, // PC_DSSALL + BPU, 0, 0, 0, 0, 0, // PC_DST + BPU, 0, 0, 0, 0, 0, // PC_DSTT + BPU, 0, 0, 0, 0, 0, // PC_DSTST + BPU, 0, 0, 0, 0, 0, // PC_DSTSTT + BPU, 0, 0, 0, 0, 0, // PC_LVEBX + BPU, 0, 0, 0, 0, 0, // PC_LVEHX + BPU, 0, 0, 0, 0, 0, // PC_LVEWX + BPU, 0, 0, 0, 0, 0, // PC_LVSL + BPU, 0, 0, 0, 0, 0, // PC_LVSR + BPU, 0, 0, 0, 0, 0, // PC_LVX + BPU, 0, 0, 0, 0, 0, // PC_LVXL + BPU, 0, 0, 0, 0, 0, // PC_STVEBX + BPU, 0, 0, 0, 0, 0, // PC_STVEHX + BPU, 0, 0, 0, 0, 0, // PC_STVEWX + BPU, 0, 0, 0, 0, 0, // PC_STVX + BPU, 0, 0, 0, 0, 0, // PC_STVXL + BPU, 0, 0, 0, 0, 0, // PC_MFVSCR + BPU, 0, 0, 0, 0, 0, // PC_MTVSCR + BPU, 0, 0, 0, 0, 0, // PC_VADDCUW + BPU, 0, 0, 0, 0, 0, // PC_VADDFP + BPU, 0, 0, 0, 0, 0, // PC_VADDSBS + BPU, 0, 0, 0, 0, 0, // PC_VADDSHS + BPU, 0, 0, 0, 0, 0, // PC_VADDSWS + BPU, 0, 0, 0, 0, 0, // PC_VADDUBM + BPU, 0, 0, 0, 0, 0, // PC_VADDUBS + BPU, 0, 0, 0, 0, 0, // PC_VADDUHM + BPU, 0, 0, 0, 0, 0, // PC_VADDUHS + BPU, 0, 0, 0, 0, 0, // PC_VADDUWM + BPU, 0, 0, 0, 0, 0, // PC_VADDUWS + BPU, 0, 0, 0, 0, 0, // PC_VAND + BPU, 0, 0, 0, 0, 0, // PC_VANDC + BPU, 0, 0, 0, 0, 0, // PC_VAVGSB + BPU, 0, 0, 0, 0, 0, // PC_VAVGSH + BPU, 0, 0, 0, 0, 0, // PC_VAVGSW + BPU, 0, 0, 0, 0, 0, // PC_VAVGUB + BPU, 0, 0, 0, 0, 0, // PC_VAVGUH + BPU, 0, 0, 0, 0, 0, // PC_VAVGUW + BPU, 0, 0, 0, 0, 0, // PC_VCFSX + BPU, 0, 0, 0, 0, 0, // PC_VCFUX + BPU, 0, 0, 0, 0, 0, // PC_VCMPBFP + BPU, 0, 0, 0, 0, 0, // PC_VCMPEQFP + BPU, 0, 0, 0, 0, 0, // PC_VCMPEQUB + BPU, 0, 0, 0, 0, 0, // PC_VCMPEQUH + BPU, 0, 0, 0, 0, 0, // PC_VCMPEQUW + BPU, 0, 0, 0, 0, 0, // PC_VCMPGEFP + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTFP + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTSB + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTSH + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTSW + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTUB + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTUH + BPU, 0, 0, 0, 0, 0, // PC_VCMPGTUW + BPU, 0, 0, 0, 0, 0, // PC_VCTSXS + BPU, 0, 0, 0, 0, 0, // PC_VCTUXS + BPU, 0, 0, 0, 0, 0, // PC_VEXPTEFP + BPU, 0, 0, 0, 0, 0, // PC_VLOGEFP + BPU, 0, 0, 0, 0, 0, // PC_VMAXFP + BPU, 0, 0, 0, 0, 0, // PC_VMAXSB + BPU, 0, 0, 0, 0, 0, // PC_VMAXSH + BPU, 0, 0, 0, 0, 0, // PC_VMAXSW + BPU, 0, 0, 0, 0, 0, // PC_VMAXUB + BPU, 0, 0, 0, 0, 0, // PC_VMAXUH + BPU, 0, 0, 0, 0, 0, // PC_VMAXUW + BPU, 0, 0, 0, 0, 0, // PC_VMINFP + BPU, 0, 0, 0, 0, 0, // PC_VMINSB + BPU, 0, 0, 0, 0, 0, // PC_VMINSH + BPU, 0, 0, 0, 0, 0, // PC_VMINSW + BPU, 0, 0, 0, 0, 0, // PC_VMINUB + BPU, 0, 0, 0, 0, 0, // PC_VMINUH + BPU, 0, 0, 0, 0, 0, // PC_VMINUW + BPU, 0, 0, 0, 0, 0, // PC_VMRGHB + BPU, 0, 0, 0, 0, 0, // PC_VMRGHH + BPU, 0, 0, 0, 0, 0, // PC_VMRGHW + BPU, 0, 0, 0, 0, 0, // PC_VMRGLB + BPU, 0, 0, 0, 0, 0, // PC_VMRGLH + BPU, 0, 0, 0, 0, 0, // PC_VMRGLW + BPU, 0, 0, 0, 0, 0, // PC_VMULESB + BPU, 0, 0, 0, 0, 0, // PC_VMULESH + BPU, 0, 0, 0, 0, 0, // PC_VMULEUB + BPU, 0, 0, 0, 0, 0, // PC_VMULEUH + BPU, 0, 0, 0, 0, 0, // PC_VMULOSB + BPU, 0, 0, 0, 0, 0, // PC_VMULOSH + BPU, 0, 0, 0, 0, 0, // PC_VMULOUB + BPU, 0, 0, 0, 0, 0, // PC_VMULOUH + BPU, 0, 0, 0, 0, 0, // PC_VNOR + BPU, 0, 0, 0, 0, 0, // PC_VOR + BPU, 0, 0, 0, 0, 0, // PC_VPKPX + BPU, 0, 0, 0, 0, 0, // PC_VPKSHSS + BPU, 0, 0, 0, 0, 0, // PC_VPKSHUS + BPU, 0, 0, 0, 0, 0, // PC_VPKSWSS + BPU, 0, 0, 0, 0, 0, // PC_VPKSWUS + BPU, 0, 0, 0, 0, 0, // PC_VPKUHUM + BPU, 0, 0, 0, 0, 0, // PC_VPKUHUS + BPU, 0, 0, 0, 0, 0, // PC_VPKUWUM + BPU, 0, 0, 0, 0, 0, // PC_VPKUWUS + BPU, 0, 0, 0, 0, 0, // PC_VREFP + BPU, 0, 0, 0, 0, 0, // PC_VRFIM + BPU, 0, 0, 0, 0, 0, // PC_VRFIN + BPU, 0, 0, 0, 0, 0, // PC_VRFIP + BPU, 0, 0, 0, 0, 0, // PC_VRFIZ + BPU, 0, 0, 0, 0, 0, // PC_VRLB + BPU, 0, 0, 0, 0, 0, // PC_VRLH + BPU, 0, 0, 0, 0, 0, // PC_VRLW + BPU, 0, 0, 0, 0, 0, // PC_VRSQRTEFP + BPU, 0, 0, 0, 0, 0, // PC_VSL + BPU, 0, 0, 0, 0, 0, // PC_VSLB + BPU, 0, 0, 0, 0, 0, // PC_VSLH + BPU, 0, 0, 0, 0, 0, // PC_VSLO + BPU, 0, 0, 0, 0, 0, // PC_VSLW + BPU, 0, 0, 0, 0, 0, // PC_VSPLTB + BPU, 0, 0, 0, 0, 0, // PC_VSPLTH + BPU, 0, 0, 0, 0, 0, // PC_VSPLTW + BPU, 0, 0, 0, 0, 0, // PC_VSPLTISB + BPU, 0, 0, 0, 0, 0, // PC_VSPLTISH + BPU, 0, 0, 0, 0, 0, // PC_VSPLTISW + BPU, 0, 0, 0, 0, 0, // PC_VSR + BPU, 0, 0, 0, 0, 0, // PC_VSRAB + BPU, 0, 0, 0, 0, 0, // PC_VSRAH + BPU, 0, 0, 0, 0, 0, // PC_VSRAW + BPU, 0, 0, 0, 0, 0, // PC_VSRB + BPU, 0, 0, 0, 0, 0, // PC_VSRH + BPU, 0, 0, 0, 0, 0, // PC_VSRO + BPU, 0, 0, 0, 0, 0, // PC_VSRW + BPU, 0, 0, 0, 0, 0, // PC_VSUBCUW + BPU, 0, 0, 0, 0, 0, // PC_VSUBFP + BPU, 0, 0, 0, 0, 0, // PC_VSUBSBS + BPU, 0, 0, 0, 0, 0, // PC_VSUBSHS + BPU, 0, 0, 0, 0, 0, // PC_VSUBSWS + BPU, 0, 0, 0, 0, 0, // PC_VSUBUBM + BPU, 0, 0, 0, 0, 0, // PC_VSUBUBS + BPU, 0, 0, 0, 0, 0, // PC_VSUBUHM + BPU, 0, 0, 0, 0, 0, // PC_VSUBUHS + BPU, 0, 0, 0, 0, 0, // PC_VSUBUWM + BPU, 0, 0, 0, 0, 0, // PC_VSUBUWS + BPU, 0, 0, 0, 0, 0, // PC_VSUMSWS + BPU, 0, 0, 0, 0, 0, // PC_VSUM2SWS + BPU, 0, 0, 0, 0, 0, // PC_VSUM4SBS + BPU, 0, 0, 0, 0, 0, // PC_VSUM4SHS + BPU, 0, 0, 0, 0, 0, // PC_VSUM4UBS + BPU, 0, 0, 0, 0, 0, // PC_VUPKHPX + BPU, 0, 0, 0, 0, 0, // PC_VUPKHSB + BPU, 0, 0, 0, 0, 0, // PC_VUPKHSH + BPU, 0, 0, 0, 0, 0, // PC_VUPKLPX + BPU, 0, 0, 0, 0, 0, // PC_VUPKLSB + BPU, 0, 0, 0, 0, 0, // PC_VUPKLSH + BPU, 0, 0, 0, 0, 0, // PC_VXOR + BPU, 0, 0, 0, 0, 0, // PC_VMADDFP + BPU, 0, 0, 0, 0, 0, // PC_VMHADDSHS + BPU, 0, 0, 0, 0, 0, // PC_VMHRADDSHS + BPU, 0, 0, 0, 0, 0, // PC_VMLADDUHM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMMBM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMSHM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMSHS + BPU, 0, 0, 0, 0, 0, // PC_VMSUMUBM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMUHM + BPU, 0, 0, 0, 0, 0, // PC_VMSUMUHS + BPU, 0, 0, 0, 0, 0, // PC_VNMSUBFP + BPU, 0, 0, 0, 0, 0, // PC_VPERM + BPU, 0, 0, 0, 0, 0, // PC_VSEL + BPU, 0, 0, 0, 0, 0, // PC_VSLDOI + BPU, 0, 0, 0, 0, 0, // PC_VMR + BPU, 0, 0, 0, 0, 0, // PC_VMRP + BPU, 0, 0, 0, 0, 0, // PC_SLE + BPU, 0, 0, 0, 0, 0, // PC_SLEQ + BPU, 0, 0, 0, 0, 0, // PC_SLIQ + BPU, 0, 0, 0, 0, 0, // PC_SLLIQ + BPU, 0, 0, 0, 0, 0, // PC_SLLQ + BPU, 0, 0, 0, 0, 0, // PC_SLQ + BPU, 0, 0, 0, 0, 0, // PC_SRAIQ + BPU, 0, 0, 0, 0, 0, // PC_SRAQ + BPU, 0, 0, 0, 0, 0, // PC_SRE + BPU, 0, 0, 0, 0, 0, // PC_SREA + BPU, 0, 0, 0, 0, 0, // PC_SREQ + BPU, 0, 0, 0, 0, 0, // PC_SRIQ + BPU, 0, 0, 0, 0, 0, // PC_SRLIQ + BPU, 0, 0, 0, 0, 0, // PC_SRLQ + BPU, 0, 0, 0, 0, 0, // PC_SRQ + BPU, 0, 0, 0, 0, 0, // PC_MASKG + BPU, 0, 0, 0, 0, 0, // PC_MASKIR + BPU, 0, 0, 0, 0, 0, // PC_LSCBX + BPU, 0, 0, 0, 0, 0, // PC_DIV + BPU, 0, 0, 0, 0, 0, // PC_DIVS + BPU, 0, 0, 0, 0, 0, // PC_DOZ + BPU, 0, 0, 0, 0, 0, // PC_MUL + BPU, 0, 0, 0, 0, 0, // PC_NABS + BPU, 0, 0, 0, 0, 0, // PC_ABS + BPU, 0, 0, 0, 0, 0, // PC_CLCS + BPU, 0, 0, 0, 0, 0, // PC_DOZI + BPU, 0, 0, 0, 0, 0, // PC_RLMI + BPU, 0, 0, 0, 0, 0, // PC_RRIB +}; + +static void advance(int firstStage, int oldStage, int newStage) { + PCode *instr = pipeline[oldStage].instr; + int cycles = instruction_timing[instr->op].cycles[newStage - firstStage]; + pipeline[newStage].instr = instr; + pipeline[newStage].remaining = cycles; + pipeline[oldStage].instr = NULL; +} + +static void assign_completion_buffer(PCode *instr) { + completionbuffers.used++; + completionbuffers.free--; + completionbuffers.entries[completionbuffers.nextFreeSlot].instr = instr; + completionbuffers.entries[completionbuffers.nextFreeSlot].completed = 0; + completionbuffers.nextFreeSlot = (completionbuffers.nextFreeSlot + 1) % MaxEntries; +} + +static void complete_instruction(int stage) { + PCode *instr = pipeline[stage].instr; + int buf = 0; + while (buf < MaxEntries && completionbuffers.entries[buf].instr != instr) + buf++; + + completionbuffers.entries[buf].completed = 1; + pipeline[stage].instr = NULL; + + if (stage == IU1) + iu1_completed_instruction = instr; + else if (stage == IU2) + iu2_completed_instruction = instr; +} + +static void retire_instruction(void) { + completionbuffers.entries[completionbuffers.nextToRetire].instr = NULL; + completionbuffers.used--; + completionbuffers.free++; + completionbuffers.nextToRetire = (completionbuffers.nextToRetire + 1) % MaxEntries; +} + +static int latency(PCode *instr) { + int cycles = instruction_timing[instr->op].latency; + if (PCODE_FLAG_SET_F(instr) & fRecordBit) + cycles += 2; + if (instr->op == PC_LMW || instr->op == PC_STMW) + cycles += instr->argCount - 2; + return cycles; +} + +static void initialize(void) { + int stage; + int i; + + for (stage = 0; stage < NumStages; stage++) + pipeline[stage].instr = NULL; + + completionbuffers.free = MaxEntries; + completionbuffers.used = 0; + completionbuffers.nextToRetire = 0; + completionbuffers.nextFreeSlot = 0; + for (i = 0; i < MaxEntries; i++) + completionbuffers.entries[i].instr = NULL; + + iu1_completed_instruction = NULL; + iu2_completed_instruction = NULL; +} + +static int can_issue(PCode *instr) { + int stage; + + if (completionbuffers.free == 0) + return 0; + + stage = instruction_timing[instr->op].stage; + + if (stage == IU2) { + PCode *check; + int isClear1 = !pipeline[IU1].instr; + int isClear2 = !pipeline[IU2].instr; + if (!isClear1 && !isClear2) + return 0; + if (isClear1 && isClear2) + return 1; + + if (isClear1) + check = pipeline[IU2].instr; + else + check = pipeline[IU1].instr; + + if (is_dependent(instr, check, RegClass_GPR)) + return 0; + if (is_dependent(instr, iu1_completed_instruction, RegClass_GPR)) + return 0; + if (is_dependent(instr, iu2_completed_instruction, RegClass_GPR)) + return 0; + } else { + if (pipeline[stage].instr) + return 0; + } + + if ((instr->flags & fIsWrite) && pipeline[LSU2].instr && (pipeline[LSU2].instr->flags & fIsWrite)) + return 0; + + return 1; +} + +static void issue(PCode *instr) { + int stage = instruction_timing[instr->op].stage; + int cycles = instruction_timing[instr->op].cycles[0]; + assign_completion_buffer(instr); + if (stage == IU2 && !pipeline[IU1].instr) + stage = IU1; + pipeline[stage].instr = instr; + pipeline[stage].remaining = cycles; +} + +static void advance_clock(void) { + int stage; + + iu1_completed_instruction = NULL; + iu2_completed_instruction = NULL; + + for (stage = 0; stage < NumStages; stage++) { + if (pipeline[stage].instr && pipeline[stage].remaining) + --pipeline[stage].remaining; + } + + if (completionbuffers.used && completionbuffers.entries[completionbuffers.nextToRetire].completed) { + retire_instruction(); + if (completionbuffers.used && completionbuffers.entries[completionbuffers.nextToRetire].completed) { + retire_instruction(); + } + } + + if (pipeline[IU1].instr && pipeline[IU1].remaining == 0) + complete_instruction(IU1); + if (pipeline[LSU2].instr && pipeline[LSU2].remaining == 0) + complete_instruction(LSU2); + if (pipeline[FPU3].instr && pipeline[FPU3].remaining == 0) + complete_instruction(FPU3); + if (pipeline[SRU].instr && pipeline[SRU].remaining == 0) + complete_instruction(SRU); + if (pipeline[BPU].instr && pipeline[BPU].remaining == 0) + complete_instruction(BPU); + if (pipeline[IU2].instr && pipeline[IU2].remaining == 0) + complete_instruction(IU2); + + if ( + pipeline[FPU1].instr && + pipeline[FPU1].remaining == 0 && + (pipeline[FPU1].instr->op == PC_FDIV || pipeline[FPU1].instr->op == PC_FDIVS) + ) + complete_instruction(FPU1); + + if (pipeline[FPU2].instr && pipeline[FPU2].remaining == 0 && !pipeline[FPU3].instr) + advance(FPU1, FPU2, FPU3); + if (pipeline[FPU1].instr && pipeline[FPU1].remaining == 0 && !pipeline[FPU2].instr) + advance(FPU1, FPU1, FPU2); + + if (pipeline[LSU1].instr && pipeline[LSU1].remaining == 0 && !pipeline[LSU2].instr) + advance(LSU1, LSU1, LSU2); +} + +static int serializes(PCode *instr) { + return instruction_timing[instr->op].serializes; +} + +MachineInfo machine750 = { + 2, + 1, + 0, + &latency, + &initialize, + &can_issue, + &issue, + &advance_clock, + &serializes, + &default_uses_vpermute_unit +}; diff --git a/compiler_and_linker/unsorted/MachineSimulation821.c b/compiler_and_linker/unsorted/MachineSimulation821.c new file mode 100644 index 0000000..bbf0509 --- /dev/null +++ b/compiler_and_linker/unsorted/MachineSimulation821.c @@ -0,0 +1,615 @@ +#include "compiler/Scheduler.h" +#include "compiler/PCode.h" +#include "compiler/PCodeInfo.h" + +// https://www.nxp.com/docs/en/user-guide/MPC821UM.pdf + +typedef enum Stage { + BranchUnit, + Stage1, + Stage2, + LSU1, + LSU2, + CRUnit, + NumStages, + Stage7 +} Stage; + +static struct { + // the instruction currently in this pipeline stage + PCode *instr; + + // how many cycles are left for this instruction to finish + int remaining; +} pipeline[NumStages]; + +enum { + MaxEntries = 6 +}; + +static struct { + // how many entries remain unused in the queue + unsigned int free; + + // how many entries are currently used in the queue + unsigned int used; + + // the index of the next instruction that will be retired + unsigned int nextToRetire; + + // the index of the next free slot that will be used when an instruction is dispatched + unsigned int nextFreeSlot; + + // circular array of entries in the completion queue + struct { + PCode *instr; + int completed; + } entries[MaxEntries]; +} completionbuffers; + +static struct { + // the initial stage for this instruction + Stage stage; + + // the total amount of cycles required by this instruction + char latency; + + // how long it takes to finish each stage + char cycles[3]; + + // does this instruction serialise? + char serializes; +} instruction_timing[OPCODE_MAX] = { + BranchUnit, 0, 0, 0, 0, 0, // PC_B + BranchUnit, 0, 0, 0, 0, 0, // PC_BL + BranchUnit, 0, 0, 0, 0, 0, // PC_BC + BranchUnit, 0, 0, 0, 0, 0, // PC_BCLR + BranchUnit, 0, 0, 0, 0, 0, // PC_BCCTR + BranchUnit, 0, 0, 0, 0, 0, // PC_BT + BranchUnit, 0, 0, 0, 0, 0, // PC_BTLR + BranchUnit, 0, 0, 0, 0, 0, // PC_BTCTR + BranchUnit, 0, 0, 0, 0, 0, // PC_BF + BranchUnit, 0, 0, 0, 0, 0, // PC_BFLR + BranchUnit, 0, 0, 0, 0, 0, // PC_BFCTR + BranchUnit, 0, 0, 0, 0, 0, // PC_BDNZ + BranchUnit, 0, 0, 0, 0, 0, // PC_BDNZT + BranchUnit, 0, 0, 0, 0, 0, // PC_BDNZF + BranchUnit, 0, 0, 0, 0, 0, // PC_BDZ + BranchUnit, 0, 0, 0, 0, 0, // PC_BDZT + BranchUnit, 0, 0, 0, 0, 0, // PC_BDZF + BranchUnit, 0, 0, 0, 0, 0, // PC_BLR + BranchUnit, 0, 0, 0, 0, 0, // PC_BCTR + BranchUnit, 0, 0, 0, 0, 0, // PC_BCTRL + BranchUnit, 0, 0, 0, 0, 0, // PC_BLRL + BranchUnit, 0, 0, 0, 0, 0, // PC_LBZ + LSU1, 2, 1, 1, 0, 0, // PC_LBZU + LSU1, 2, 1, 1, 0, 0, // PC_LBZX + LSU1, 2, 1, 1, 0, 0, // PC_LBZUX + LSU1, 2, 1, 1, 0, 0, // PC_LHZ + LSU1, 2, 1, 1, 0, 0, // PC_LHZU + LSU1, 2, 1, 1, 0, 0, // PC_LHZX + LSU1, 2, 1, 1, 0, 0, // PC_LHZUX + LSU1, 2, 1, 1, 0, 0, // PC_LHA + LSU1, 2, 1, 1, 0, 0, // PC_LHAU + LSU1, 2, 1, 1, 0, 0, // PC_LHAX + LSU1, 2, 1, 1, 0, 0, // PC_LHAUX + LSU1, 2, 1, 1, 0, 0, // PC_LHBRX + LSU1, 2, 1, 1, 0, 0, // PC_LWZ + LSU1, 2, 1, 1, 0, 0, // PC_LWZU + LSU1, 2, 1, 1, 0, 0, // PC_LWZX + LSU1, 2, 1, 1, 0, 0, // PC_LWZUX + LSU1, 2, 1, 1, 0, 0, // PC_LWBRX + LSU1, 2, 1, 1, 0, 0, // PC_LMW + LSU1, 2, 1, 1, 0, 0, // PC_STB + LSU1, 2, 1, 1, 0, 0, // PC_STBU + LSU1, 2, 1, 1, 0, 0, // PC_STBX + LSU1, 2, 1, 1, 0, 0, // PC_STBUX + LSU1, 2, 1, 1, 0, 0, // PC_STH + LSU1, 2, 1, 1, 0, 0, // PC_STHU + LSU1, 2, 1, 1, 0, 0, // PC_STHX + LSU1, 2, 1, 1, 0, 0, // PC_STHUX + LSU1, 2, 1, 1, 0, 0, // PC_STHBRX + LSU1, 2, 1, 1, 0, 0, // PC_STW + LSU1, 2, 1, 1, 0, 0, // PC_STWU + LSU1, 2, 1, 1, 0, 0, // PC_STWX + LSU1, 2, 1, 1, 0, 0, // PC_STWUX + LSU1, 2, 1, 1, 0, 0, // PC_STWBRX + LSU1, 2, 1, 1, 0, 0, // PC_STMW + LSU1, 2, 1, 1, 0, 0, // PC_DCBF + LSU1, 2, 1, 1, 0, 0, // PC_DCBST + LSU1, 2, 1, 1, 0, 0, // PC_DCBT + LSU1, 2, 1, 1, 0, 0, // PC_DCBTST + LSU1, 2, 1, 1, 0, 0, // PC_DCBZ + LSU1, 2, 1, 1, 0, 0, // PC_ADD + Stage1, 1, 1, 0, 0, 0, // PC_ADDC + Stage1, 1, 1, 0, 0, 0, // PC_ADDE + Stage1, 1, 1, 0, 0, 0, // PC_ADDI + Stage1, 1, 1, 0, 0, 0, // PC_ADDIC + Stage1, 1, 1, 0, 0, 0, // PC_ADDICR + Stage1, 1, 1, 0, 0, 0, // PC_ADDIS + Stage1, 1, 1, 0, 0, 0, // PC_ADDME + Stage1, 1, 1, 0, 0, 0, // PC_ADDZE + Stage1, 1, 1, 0, 0, 0, // PC_DIVW + Stage1, 37, 37, 0, 0, 0, // PC_DIVWU + Stage1, 37, 37, 0, 0, 0, // PC_MULHW + Stage1, 5, 5, 0, 0, 0, // PC_MULHWU + Stage1, 5, 5, 0, 0, 0, // PC_MULLI + Stage1, 3, 3, 0, 0, 0, // PC_MULLW + Stage1, 5, 5, 0, 0, 0, // PC_NEG + Stage1, 1, 1, 0, 0, 0, // PC_SUBF + Stage1, 1, 1, 0, 0, 0, // PC_SUBFC + Stage1, 1, 1, 0, 0, 0, // PC_SUBFE + Stage1, 1, 1, 0, 0, 0, // PC_SUBFIC + Stage1, 1, 1, 0, 0, 0, // PC_SUBFME + Stage1, 1, 1, 0, 0, 0, // PC_SUBFZE + Stage1, 1, 1, 0, 0, 0, // PC_CMPI + Stage1, 3, 1, 0, 0, 0, // PC_CMP + Stage1, 3, 1, 0, 0, 0, // PC_CMPLI + Stage1, 3, 1, 0, 0, 0, // PC_CMPL + Stage1, 3, 1, 0, 0, 0, // PC_ANDI + Stage1, 1, 1, 0, 0, 0, // PC_ANDIS + Stage1, 1, 1, 0, 0, 0, // PC_ORI + Stage1, 1, 1, 0, 0, 0, // PC_ORIS + Stage1, 1, 1, 0, 0, 0, // PC_XORI + Stage1, 1, 1, 0, 0, 0, // PC_XORIS + Stage1, 1, 1, 0, 0, 0, // PC_AND + Stage1, 1, 1, 0, 0, 0, // PC_OR + Stage1, 1, 1, 0, 0, 0, // PC_XOR + Stage1, 1, 1, 0, 0, 0, // PC_NAND + Stage1, 1, 1, 0, 0, 0, // PC_NOR + Stage1, 1, 1, 0, 0, 0, // PC_EQV + Stage1, 1, 1, 0, 0, 0, // PC_ANDC + Stage1, 1, 1, 0, 0, 0, // PC_ORC + Stage1, 1, 1, 0, 0, 0, // PC_EXTSB + Stage1, 1, 1, 0, 0, 0, // PC_EXTSH + Stage1, 1, 1, 0, 0, 0, // PC_CNTLZW + Stage1, 1, 1, 0, 0, 0, // PC_RLWINM + Stage1, 1, 1, 0, 0, 0, // PC_RLWNM + Stage1, 1, 1, 0, 0, 0, // PC_RLWIMI + Stage1, 1, 1, 0, 0, 0, // PC_SLW + Stage1, 1, 1, 0, 0, 0, // PC_SRW + Stage1, 1, 1, 0, 0, 0, // PC_SRAWI + Stage1, 1, 1, 0, 0, 0, // PC_SRAW + Stage1, 1, 1, 0, 0, 0, // PC_CRAND + CRUnit, 1, 1, 0, 0, 0, // PC_CRANDC + CRUnit, 1, 1, 0, 0, 0, // PC_CREQV + CRUnit, 1, 1, 0, 0, 0, // PC_CRNAND + CRUnit, 1, 1, 0, 0, 0, // PC_CRNOR + CRUnit, 1, 1, 0, 0, 0, // PC_CROR + CRUnit, 1, 1, 0, 0, 0, // PC_CRORC + CRUnit, 1, 1, 0, 0, 0, // PC_CRXOR + CRUnit, 1, 1, 0, 0, 0, // PC_MCRF + CRUnit, 1, 1, 0, 0, 0, // PC_MTXER + Stage1, 1, 1, 0, 0, 0, // PC_MTCTR + BranchUnit, 2, 2, 0, 0, 0, // PC_MTLR + BranchUnit, 2, 2, 0, 0, 0, // PC_MTCRF + Stage1, 1, 1, 0, 0, 0, // PC_MTMSR + Stage1, 1, 1, 0, 0, 0, // PC_MTSPR + Stage1, 1, 1, 0, 0, 0, // PC_MFMSR + Stage1, 1, 1, 0, 0, 0, // PC_MFSPR + Stage1, 1, 1, 0, 0, 0, // PC_MFXER + Stage7, 3, 1, 1, 1, 0, // PC_MFCTR + Stage7, 3, 1, 1, 1, 0, // PC_MFLR + Stage1, 1, 1, 0, 0, 0, // PC_MFCR + Stage1, 1, 1, 0, 0, 0, // PC_MFFS + Stage1, 1, 1, 0, 0, 0, // PC_MTFSF + Stage1, 1, 1, 0, 0, 0, // PC_EIEIO + Stage1, 1, 1, 0, 0, 0, // PC_ISYNC + Stage1, 1, 1, 0, 0, 0, // PC_SYNC + Stage1, 1, 1, 0, 0, 0, // PC_RFI + Stage1, 1, 1, 0, 0, 0, // PC_LI + LSU1, 2, 1, 1, 0, 0, // PC_LIS + LSU1, 2, 1, 1, 0, 0, // PC_MR + LSU1, 2, 1, 1, 0, 0, // PC_NOP + LSU1, 2, 1, 1, 0, 0, // PC_NOT + LSU1, 2, 1, 1, 0, 0, // PC_LFS + LSU1, 2, 1, 1, 0, 0, // PC_LFSU + LSU1, 2, 1, 1, 0, 0, // PC_LFSX + LSU1, 2, 1, 1, 0, 0, // PC_LFSUX + LSU1, 2, 1, 1, 0, 0, // PC_LFD + LSU1, 2, 1, 1, 0, 0, // PC_LFDU + LSU1, 2, 1, 1, 0, 0, // PC_LFDX + LSU1, 2, 1, 1, 0, 0, // PC_LFDUX + LSU1, 2, 1, 1, 0, 0, // PC_STFS + LSU1, 2, 1, 1, 0, 0, // PC_STFSU + LSU1, 2, 1, 1, 0, 0, // PC_STFSX + LSU1, 2, 1, 1, 0, 0, // PC_STFSUX + Stage7, 3, 1, 1, 1, 0, // PC_STFD + Stage7, 3, 1, 1, 1, 0, // PC_STFDU + Stage7, 3, 1, 1, 1, 0, // PC_STFDX + Stage7, 3, 1, 1, 1, 0, // PC_STFDUX + Stage7, 3, 1, 1, 1, 0, // PC_FMR + Stage7, 3, 1, 1, 1, 0, // PC_FABS + Stage7, 3, 1, 1, 1, 0, // PC_FNEG + Stage7, 3, 1, 1, 1, 0, // PC_FNABS + Stage7, 4, 2, 1, 1, 0, // PC_FADD + Stage7, 3, 1, 1, 1, 0, // PC_FADDS + Stage7, 33, 33, 0, 0, 0, // PC_FSUB + Stage7, 18, 18, 0, 0, 0, // PC_FSUBS + Stage7, 4, 2, 1, 1, 0, // PC_FMUL + Stage7, 3, 1, 1, 1, 0, // PC_FMULS + Stage7, 4, 2, 1, 1, 0, // PC_FDIV + Stage7, 3, 1, 1, 1, 0, // PC_FDIVS + Stage7, 4, 2, 1, 1, 0, // PC_FMADD + Stage7, 3, 1, 1, 1, 0, // PC_FMADDS + Stage7, 4, 2, 1, 1, 0, // PC_FMSUB + Stage7, 3, 1, 1, 1, 0, // PC_FMSUBS + Stage7, 18, 18, 0, 0, 0, // PC_FNMADD + Stage7, 3, 1, 1, 1, 0, // PC_FNMADDS + Stage7, 3, 1, 1, 1, 0, // PC_FNMSUB + Stage7, 3, 1, 1, 1, 0, // PC_FNMSUBS + Stage7, 3, 1, 1, 1, 0, // PC_FRES + Stage7, 3, 1, 1, 1, 0, // PC_FRSQRTE + Stage7, 5, 1, 1, 1, 0, // PC_FSEL + Stage7, 5, 1, 1, 1, 0, // PC_FRSP + LSU1, 1, 0, 0, 0, 0, // PC_FCTIW + LSU1, 1, 0, 0, 0, 0, // PC_FCTIWZ + LSU1, 1, 0, 0, 0, 0, // PC_FCMPU + LSU1, 1, 0, 0, 0, 0, // PC_FCMPO + LSU1, 1, 0, 0, 0, 0, // PC_LWARX + LSU1, 1, 0, 0, 0, 0, // PC_LSWI + LSU1, 1, 0, 0, 0, 0, // PC_LSWX + Stage1, 1, 0, 0, 0, 0, // PC_STFIWX + Stage1, 1, 0, 0, 0, 0, // PC_STSWI + Stage1, 1, 0, 0, 0, 0, // PC_STSWX + Stage1, 1, 0, 0, 0, 0, // PC_STWCX + Stage1, 1, 0, 0, 0, 0, // PC_ECIWX + Stage1, 1, 0, 0, 0, 0, // PC_ECOWX + Stage1, 1, 0, 0, 0, 0, // PC_DCBI + Stage1, 1, 0, 0, 0, 0, // PC_ICBI + Stage1, 1, 0, 0, 0, 0, // PC_MCRFS + Stage1, 1, 0, 0, 0, 0, // PC_MCRXR + Stage1, 1, 0, 0, 0, 0, // PC_MFTB + Stage1, 1, 0, 0, 0, 0, // PC_MFSR + Stage1, 1, 0, 0, 0, 0, // PC_MTSR + Stage1, 1, 0, 0, 0, 0, // PC_MFSRIN + Stage1, 1, 0, 0, 0, 0, // PC_MTSRIN + Stage1, 1, 0, 0, 0, 0, // PC_MTFSB0 + Stage1, 1, 0, 0, 0, 0, // PC_MTFSB1 + Stage1, 1, 0, 0, 0, 0, // PC_MTFSFI + Stage1, 1, 0, 0, 0, 1, // PC_SC + Stage1, 1, 0, 0, 0, 1, // PC_FSQRT + Stage1, 1, 0, 0, 0, 0, // PC_FSQRTS + Stage1, 1, 0, 0, 0, 0, // PC_TLBIA + Stage1, 1, 0, 0, 0, 0, // PC_TLBIE + Stage1, 1, 0, 0, 0, 0, // PC_TLBLD + Stage1, 1, 0, 0, 0, 0, // PC_TLBLI + Stage1, 1, 0, 0, 0, 0, // PC_TLBSYNC + Stage1, 1, 0, 0, 0, 0, // PC_TW + Stage1, 1, 0, 0, 0, 1, // PC_TRAP + Stage1, 1, 0, 0, 0, 1, // PC_TWI + Stage1, 1, 0, 0, 0, 1, // PC_OPWORD + Stage1, 1, 0, 0, 0, 1, // PC_MFROM + Stage1, 1, 0, 0, 0, 0, // PC_DSA + Stage1, 1, 0, 0, 0, 0, // PC_ESA + Stage1, 1, 0, 0, 0, 0, // PC_DCCCI + Stage1, 0, 0, 0, 0, 0, // PC_DCREAD + Stage1, 0, 0, 0, 0, 0, // PC_ICBT + Stage1, 0, 0, 0, 0, 0, // PC_ICCCI + Stage1, 0, 0, 0, 0, 0, // PC_ICREAD + Stage1, 0, 0, 0, 0, 0, // PC_RFCI + Stage1, 0, 0, 0, 0, 0, // PC_TLBRE + Stage1, 0, 0, 0, 0, 0, // PC_TLBSX + Stage1, 0, 0, 0, 0, 0, // PC_TLBWE + Stage1, 0, 0, 0, 0, 0, // PC_WRTEE + Stage1, 0, 0, 0, 0, 0, // PC_WRTEEI + Stage1, 0, 0, 0, 0, 0, // PC_MFDCR + Stage1, 0, 0, 0, 0, 0, // PC_MTDCR + Stage1, 0, 0, 0, 0, 0, // PC_DCBA + Stage1, 0, 0, 0, 0, 0, // PC_DSS + BranchUnit, 0, 0, 0, 0, 0, // PC_DSSALL + BranchUnit, 0, 0, 0, 0, 0, // PC_DST + BranchUnit, 0, 0, 0, 0, 0, // PC_DSTT + BranchUnit, 0, 0, 0, 0, 0, // PC_DSTST + BranchUnit, 0, 0, 0, 0, 0, // PC_DSTSTT + BranchUnit, 0, 0, 0, 0, 0, // PC_LVEBX + BranchUnit, 0, 0, 0, 0, 0, // PC_LVEHX + BranchUnit, 0, 0, 0, 0, 0, // PC_LVEWX + BranchUnit, 0, 0, 0, 0, 0, // PC_LVSL + BranchUnit, 0, 0, 0, 0, 0, // PC_LVSR + BranchUnit, 0, 0, 0, 0, 0, // PC_LVX + BranchUnit, 0, 0, 0, 0, 0, // PC_LVXL + BranchUnit, 0, 0, 0, 0, 0, // PC_STVEBX + BranchUnit, 0, 0, 0, 0, 0, // PC_STVEHX + BranchUnit, 0, 0, 0, 0, 0, // PC_STVEWX + BranchUnit, 0, 0, 0, 0, 0, // PC_STVX + BranchUnit, 0, 0, 0, 0, 0, // PC_STVXL + BranchUnit, 0, 0, 0, 0, 0, // PC_MFVSCR + BranchUnit, 0, 0, 0, 0, 0, // PC_MTVSCR + BranchUnit, 0, 0, 0, 0, 0, // PC_VADDCUW + BranchUnit, 0, 0, 0, 0, 0, // PC_VADDFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VADDSBS + BranchUnit, 0, 0, 0, 0, 0, // PC_VADDSHS + BranchUnit, 0, 0, 0, 0, 0, // PC_VADDSWS + BranchUnit, 0, 0, 0, 0, 0, // PC_VADDUBM + BranchUnit, 0, 0, 0, 0, 0, // PC_VADDUBS + BranchUnit, 0, 0, 0, 0, 0, // PC_VADDUHM + BranchUnit, 0, 0, 0, 0, 0, // PC_VADDUHS + BranchUnit, 0, 0, 0, 0, 0, // PC_VADDUWM + BranchUnit, 0, 0, 0, 0, 0, // PC_VADDUWS + BranchUnit, 0, 0, 0, 0, 0, // PC_VAND + BranchUnit, 0, 0, 0, 0, 0, // PC_VANDC + BranchUnit, 0, 0, 0, 0, 0, // PC_VAVGSB + BranchUnit, 0, 0, 0, 0, 0, // PC_VAVGSH + BranchUnit, 0, 0, 0, 0, 0, // PC_VAVGSW + BranchUnit, 0, 0, 0, 0, 0, // PC_VAVGUB + BranchUnit, 0, 0, 0, 0, 0, // PC_VAVGUH + BranchUnit, 0, 0, 0, 0, 0, // PC_VAVGUW + BranchUnit, 0, 0, 0, 0, 0, // PC_VCFSX + BranchUnit, 0, 0, 0, 0, 0, // PC_VCFUX + BranchUnit, 0, 0, 0, 0, 0, // PC_VCMPBFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VCMPEQFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VCMPEQUB + BranchUnit, 0, 0, 0, 0, 0, // PC_VCMPEQUH + BranchUnit, 0, 0, 0, 0, 0, // PC_VCMPEQUW + BranchUnit, 0, 0, 0, 0, 0, // PC_VCMPGEFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VCMPGTFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VCMPGTSB + BranchUnit, 0, 0, 0, 0, 0, // PC_VCMPGTSH + BranchUnit, 0, 0, 0, 0, 0, // PC_VCMPGTSW + BranchUnit, 0, 0, 0, 0, 0, // PC_VCMPGTUB + BranchUnit, 0, 0, 0, 0, 0, // PC_VCMPGTUH + BranchUnit, 0, 0, 0, 0, 0, // PC_VCMPGTUW + BranchUnit, 0, 0, 0, 0, 0, // PC_VCTSXS + BranchUnit, 0, 0, 0, 0, 0, // PC_VCTUXS + BranchUnit, 0, 0, 0, 0, 0, // PC_VEXPTEFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VLOGEFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VMAXFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VMAXSB + BranchUnit, 0, 0, 0, 0, 0, // PC_VMAXSH + BranchUnit, 0, 0, 0, 0, 0, // PC_VMAXSW + BranchUnit, 0, 0, 0, 0, 0, // PC_VMAXUB + BranchUnit, 0, 0, 0, 0, 0, // PC_VMAXUH + BranchUnit, 0, 0, 0, 0, 0, // PC_VMAXUW + BranchUnit, 0, 0, 0, 0, 0, // PC_VMINFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VMINSB + BranchUnit, 0, 0, 0, 0, 0, // PC_VMINSH + BranchUnit, 0, 0, 0, 0, 0, // PC_VMINSW + BranchUnit, 0, 0, 0, 0, 0, // PC_VMINUB + BranchUnit, 0, 0, 0, 0, 0, // PC_VMINUH + BranchUnit, 0, 0, 0, 0, 0, // PC_VMINUW + BranchUnit, 0, 0, 0, 0, 0, // PC_VMRGHB + BranchUnit, 0, 0, 0, 0, 0, // PC_VMRGHH + BranchUnit, 0, 0, 0, 0, 0, // PC_VMRGHW + BranchUnit, 0, 0, 0, 0, 0, // PC_VMRGLB + BranchUnit, 0, 0, 0, 0, 0, // PC_VMRGLH + BranchUnit, 0, 0, 0, 0, 0, // PC_VMRGLW + BranchUnit, 0, 0, 0, 0, 0, // PC_VMULESB + BranchUnit, 0, 0, 0, 0, 0, // PC_VMULESH + BranchUnit, 0, 0, 0, 0, 0, // PC_VMULEUB + BranchUnit, 0, 0, 0, 0, 0, // PC_VMULEUH + BranchUnit, 0, 0, 0, 0, 0, // PC_VMULOSB + BranchUnit, 0, 0, 0, 0, 0, // PC_VMULOSH + BranchUnit, 0, 0, 0, 0, 0, // PC_VMULOUB + BranchUnit, 0, 0, 0, 0, 0, // PC_VMULOUH + BranchUnit, 0, 0, 0, 0, 0, // PC_VNOR + BranchUnit, 0, 0, 0, 0, 0, // PC_VOR + BranchUnit, 0, 0, 0, 0, 0, // PC_VPKPX + BranchUnit, 0, 0, 0, 0, 0, // PC_VPKSHSS + BranchUnit, 0, 0, 0, 0, 0, // PC_VPKSHUS + BranchUnit, 0, 0, 0, 0, 0, // PC_VPKSWSS + BranchUnit, 0, 0, 0, 0, 0, // PC_VPKSWUS + BranchUnit, 0, 0, 0, 0, 0, // PC_VPKUHUM + BranchUnit, 0, 0, 0, 0, 0, // PC_VPKUHUS + BranchUnit, 0, 0, 0, 0, 0, // PC_VPKUWUM + BranchUnit, 0, 0, 0, 0, 0, // PC_VPKUWUS + BranchUnit, 0, 0, 0, 0, 0, // PC_VREFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VRFIM + BranchUnit, 0, 0, 0, 0, 0, // PC_VRFIN + BranchUnit, 0, 0, 0, 0, 0, // PC_VRFIP + BranchUnit, 0, 0, 0, 0, 0, // PC_VRFIZ + BranchUnit, 0, 0, 0, 0, 0, // PC_VRLB + BranchUnit, 0, 0, 0, 0, 0, // PC_VRLH + BranchUnit, 0, 0, 0, 0, 0, // PC_VRLW + BranchUnit, 0, 0, 0, 0, 0, // PC_VRSQRTEFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VSL + BranchUnit, 0, 0, 0, 0, 0, // PC_VSLB + BranchUnit, 0, 0, 0, 0, 0, // PC_VSLH + BranchUnit, 0, 0, 0, 0, 0, // PC_VSLO + BranchUnit, 0, 0, 0, 0, 0, // PC_VSLW + BranchUnit, 0, 0, 0, 0, 0, // PC_VSPLTB + BranchUnit, 0, 0, 0, 0, 0, // PC_VSPLTH + BranchUnit, 0, 0, 0, 0, 0, // PC_VSPLTW + BranchUnit, 0, 0, 0, 0, 0, // PC_VSPLTISB + BranchUnit, 0, 0, 0, 0, 0, // PC_VSPLTISH + BranchUnit, 0, 0, 0, 0, 0, // PC_VSPLTISW + BranchUnit, 0, 0, 0, 0, 0, // PC_VSR + BranchUnit, 0, 0, 0, 0, 0, // PC_VSRAB + BranchUnit, 0, 0, 0, 0, 0, // PC_VSRAH + BranchUnit, 0, 0, 0, 0, 0, // PC_VSRAW + BranchUnit, 0, 0, 0, 0, 0, // PC_VSRB + BranchUnit, 0, 0, 0, 0, 0, // PC_VSRH + BranchUnit, 0, 0, 0, 0, 0, // PC_VSRO + BranchUnit, 0, 0, 0, 0, 0, // PC_VSRW + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUBCUW + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUBFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUBSBS + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUBSHS + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUBSWS + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUBUBM + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUBUBS + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUBUHM + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUBUHS + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUBUWM + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUBUWS + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUMSWS + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUM2SWS + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUM4SBS + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUM4SHS + BranchUnit, 0, 0, 0, 0, 0, // PC_VSUM4UBS + BranchUnit, 0, 0, 0, 0, 0, // PC_VUPKHPX + BranchUnit, 0, 0, 0, 0, 0, // PC_VUPKHSB + BranchUnit, 0, 0, 0, 0, 0, // PC_VUPKHSH + BranchUnit, 0, 0, 0, 0, 0, // PC_VUPKLPX + BranchUnit, 0, 0, 0, 0, 0, // PC_VUPKLSB + BranchUnit, 0, 0, 0, 0, 0, // PC_VUPKLSH + BranchUnit, 0, 0, 0, 0, 0, // PC_VXOR + BranchUnit, 0, 0, 0, 0, 0, // PC_VMADDFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VMHADDSHS + BranchUnit, 0, 0, 0, 0, 0, // PC_VMHRADDSHS + BranchUnit, 0, 0, 0, 0, 0, // PC_VMLADDUHM + BranchUnit, 0, 0, 0, 0, 0, // PC_VMSUMMBM + BranchUnit, 0, 0, 0, 0, 0, // PC_VMSUMSHM + BranchUnit, 0, 0, 0, 0, 0, // PC_VMSUMSHS + BranchUnit, 0, 0, 0, 0, 0, // PC_VMSUMUBM + BranchUnit, 0, 0, 0, 0, 0, // PC_VMSUMUHM + BranchUnit, 0, 0, 0, 0, 0, // PC_VMSUMUHS + BranchUnit, 0, 0, 0, 0, 0, // PC_VNMSUBFP + BranchUnit, 0, 0, 0, 0, 0, // PC_VPERM + BranchUnit, 0, 0, 0, 0, 0, // PC_VSEL + BranchUnit, 0, 0, 0, 0, 0, // PC_VSLDOI + BranchUnit, 0, 0, 0, 0, 0, // PC_VMR + BranchUnit, 0, 0, 0, 0, 0, // PC_VMRP + BranchUnit, 0, 0, 0, 0, 0, // PC_SLE + BranchUnit, 0, 0, 0, 0, 0, // PC_SLEQ + BranchUnit, 0, 0, 0, 0, 0, // PC_SLIQ + BranchUnit, 0, 0, 0, 0, 0, // PC_SLLIQ + BranchUnit, 0, 0, 0, 0, 0, // PC_SLLQ + BranchUnit, 0, 0, 0, 0, 0, // PC_SLQ + BranchUnit, 0, 0, 0, 0, 0, // PC_SRAIQ + BranchUnit, 0, 0, 0, 0, 0, // PC_SRAQ + BranchUnit, 0, 0, 0, 0, 0, // PC_SRE + BranchUnit, 0, 0, 0, 0, 0, // PC_SREA + BranchUnit, 0, 0, 0, 0, 0, // PC_SREQ + BranchUnit, 0, 0, 0, 0, 0, // PC_SRIQ + BranchUnit, 0, 0, 0, 0, 0, // PC_SRLIQ + BranchUnit, 0, 0, 0, 0, 0, // PC_SRLQ + BranchUnit, 0, 0, 0, 0, 0, // PC_SRQ + BranchUnit, 0, 0, 0, 0, 0, // PC_MASKG + BranchUnit, 0, 0, 0, 0, 0, // PC_MASKIR + BranchUnit, 0, 0, 0, 0, 0, // PC_LSCBX + BranchUnit, 0, 0, 0, 0, 0, // PC_DIV + BranchUnit, 0, 0, 0, 0, 0, // PC_DIVS + BranchUnit, 0, 0, 0, 0, 0, // PC_DOZ + BranchUnit, 0, 0, 0, 0, 0, // PC_MUL + BranchUnit, 0, 0, 0, 0, 0, // PC_NABS + BranchUnit, 0, 0, 0, 0, 0, // PC_ABS + BranchUnit, 0, 0, 0, 0, 0, // PC_CLCS + BranchUnit, 0, 0, 0, 0, 0, // PC_DOZI + BranchUnit, 0, 0, 0, 0, 0, // PC_RLMI + BranchUnit, 0, 0, 0, 0, 0, // PC_RRIB +}; + +static void advance(int firstStage, int oldStage, int newStage) { + PCode *instr = pipeline[oldStage].instr; + int cycles = instruction_timing[instr->op].cycles[newStage - firstStage]; + pipeline[newStage].instr = instr; + pipeline[newStage].remaining = cycles; + pipeline[oldStage].instr = NULL; +} + +static void assign_completion_buffer(PCode *instr) { + completionbuffers.used++; + completionbuffers.free--; + completionbuffers.entries[completionbuffers.nextFreeSlot].instr = instr; + completionbuffers.entries[completionbuffers.nextFreeSlot].completed = 0; + completionbuffers.nextFreeSlot = (completionbuffers.nextFreeSlot + 1) % MaxEntries; +} + +static void complete_instruction(int stage) { + PCode *instr = pipeline[stage].instr; + int buf = 0; + while (buf < MaxEntries && completionbuffers.entries[buf].instr != instr) + buf++; + + completionbuffers.entries[buf].completed = 1; + pipeline[stage].instr = NULL; +} + +static void retire_instruction(void) { + completionbuffers.entries[completionbuffers.nextToRetire].instr = NULL; + completionbuffers.used--; + completionbuffers.free++; + completionbuffers.nextToRetire = (completionbuffers.nextToRetire + 1) % MaxEntries; +} + +static int latency(PCode *instr) { + int cycles = instruction_timing[instr->op].latency; + if (PCODE_FLAG_SET_F(instr) & fRecordBit) + cycles += 2; + if (instr->op == PC_LMW || instr->op == PC_STMW) + cycles += instr->argCount - 2; + return cycles; +} + +static void initialize(void) { + int stage; + int i; + + for (stage = 0; stage < NumStages; stage++) + pipeline[stage].instr = NULL; + + completionbuffers.free = MaxEntries; + completionbuffers.used = 0; + completionbuffers.nextToRetire = 0; + completionbuffers.nextFreeSlot = 0; + for (i = 0; i < MaxEntries; i++) + completionbuffers.entries[i].instr = NULL; +} + +static int can_issue(PCode *instr) { + int stage; + + if (completionbuffers.free == 0) + return 0; + + stage = instruction_timing[instr->op].stage; + if (pipeline[stage].instr) + return 0; + + if ((instr->flags & fIsWrite) && pipeline[LSU2].instr && (pipeline[LSU2].instr->flags & fIsWrite)) + return 0; + + return 1; +} + +static void issue(PCode *instr) { + int stage = instruction_timing[instr->op].stage; + int cycles = instruction_timing[instr->op].cycles[0]; + assign_completion_buffer(instr); + pipeline[stage].instr = instr; + pipeline[stage].remaining = cycles; +} + +static void advance_clock(void) { + int stage; + + for (stage = 0; stage < NumStages; stage++) { + if (pipeline[stage].instr && pipeline[stage].remaining) + --pipeline[stage].remaining; + } + + if (completionbuffers.used && completionbuffers.entries[completionbuffers.nextToRetire].completed) { + retire_instruction(); + if (completionbuffers.used && completionbuffers.entries[completionbuffers.nextToRetire].completed) { + retire_instruction(); + } + } + + if (pipeline[Stage1].instr && pipeline[Stage1].remaining == 0) + complete_instruction(Stage1); + if (pipeline[LSU2].instr && pipeline[LSU2].remaining == 0) + complete_instruction(LSU2); + if (pipeline[BranchUnit].instr && pipeline[BranchUnit].remaining == 0) + complete_instruction(BranchUnit); + + if (pipeline[LSU1].instr && pipeline[LSU1].remaining == 0 && !pipeline[LSU2].instr) + advance(LSU1, LSU1, LSU2); +} + +static int serializes(PCode *instr) { + return instruction_timing[instr->op].serializes; +} + +MachineInfo machine821 = { + 1, + 0, + 0, + &latency, + &initialize, + &can_issue, + &issue, + &advance_clock, + &serializes, + &default_uses_vpermute_unit +}; diff --git a/compiler_and_linker/unsorted/MachineSimulationAltiVec.c b/compiler_and_linker/unsorted/MachineSimulationAltiVec.c new file mode 100644 index 0000000..d261ee9 --- /dev/null +++ b/compiler_and_linker/unsorted/MachineSimulationAltiVec.c @@ -0,0 +1,752 @@ +#include "compiler/Scheduler.h" +#include "compiler/CError.h" +#include "compiler/PCode.h" +#include "compiler/PCodeInfo.h" + +// https://www.nxp.com/docs/en/reference-manual/MPC7450UM.pdf + +typedef enum Stage { + BPU, // Branch Prediction Unit + + IU2_1, // Multiple-Cycle Integer Unit + IU2_2, + IU2_3, + + IU1a, // Single-Cycle Integer Unit + IU1b, // Single-Cycle Integer Unit + IU1c, // Single-Cycle Integer Unit + + LSU_1, // Load/Store Unit + LSU_2, + LSU_3, + LSU_4, + + FPU_1, // Floating-Point Unit + FPU_2, + FPU_3, + FPU_4, + + VIU1, // Vector Simple Integer Unit + + VPU_1, // Vector Permute Unit + VPU_2, + + VIU2_1, // Vector Complex Integer Unit + VIU2_2, + VIU2_3, + VIU2_4, + + VFPU_1, // Vector Floating-Point Unit + VFPU_2, + VFPU_3, + VFPU_4, + + NumStages +} Stage; + +static struct { + // the instruction currently in this pipeline stage + PCode *instr; + + // how many cycles are left for this instruction to finish + int remaining; +} pipeline_altivec[NumStages]; + +enum { + Queue0, + Queue1, + Queue2, + Queue3, + Queue4, + Queue5, + Queue6, + Queue7, + NumQueues +}; + +static int fetchqueues[NumQueues]; + +enum { + MaxEntries = 16 +}; + +static struct { + // how many entries remain unused in the queue + unsigned int free; + + // how many entries are currently used in the queue + unsigned int used; + + // the index of the next instruction that will be retired + unsigned int nextToRetire; + + // the index of the next free slot that will be used when an instruction is dispatched + unsigned int nextFreeSlot; + + // circular array of entries in the completion queue + struct { + PCode *instr; + int completed; + } entries[MaxEntries]; +} completionbuffers; + +static struct { + short index; + + // the initial stage for this instruction + Stage stage; + + // the total amount of cycles required by this instruction + char latency; + + // how long it takes to finish each stage + char cycles[4]; + + // does this instruction serialise? + char serializes; + + char unused; +} instruction_timing[] = { + 0, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_B + 1, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BL + 2, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BC + 3, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BCLR + 4, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BCCTR + 5, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BT + 6, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BTLR + 7, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BTCTR + 8, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BF + 9, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BFLR + 10, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BFCTR + 11, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BDNZ + 12, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BDNZT + 13, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BDNZF + 14, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BDZ + 15, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BDZT + 16, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BDZF + 17, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BLR + 18, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BCTR + 19, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BCTRL + 20, BPU, 0, 0, 0, 0, 0, 0, 0, // PC_BLRL + 21, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LBZ + 22, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LBZU + 23, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LBZX + 24, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LBZUX + 25, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LHZ + 26, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LHZU + 27, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LHZX + 28, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LHZUX + 29, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LHA + 30, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LHAU + 31, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LHAX + 32, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LHAUX + 33, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LHBRX + 34, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LWZ + 35, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LWZU + 36, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LWZX + 37, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LWZUX + 38, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LWBRX + 39, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_LMW + 40, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STB + 41, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STBU + 42, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STBX + 43, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STBUX + 44, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STH + 45, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STHU + 46, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STHX + 47, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STHUX + 48, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STHBRX + 49, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STW + 50, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STWU + 51, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STWX + 52, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STWUX + 53, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STWBRX + 54, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_STMW + 55, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_DCBF + 56, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_DCBST + 57, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_DCBT + 58, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_DCBTST + 59, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_DCBZ + 60, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ADD + 61, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ADDC + 62, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ADDE + 63, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ADDI + 64, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ADDIC + 65, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ADDICR + 66, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ADDIS + 67, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ADDME + 68, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ADDZE + 69, IU2_1, 23, 23, 0, 0, 0, 0, 0, // PC_DIVW + 70, IU2_1, 23, 23, 0, 0, 0, 0, 0, // PC_DIVWU + 71, IU2_1, 4, 2, 2, 0, 0, 0, 0, // PC_MULHW + 72, IU2_1, 4, 2, 2, 0, 0, 0, 0, // PC_MULHWU + 73, IU2_1, 3, 1, 1, 1, 0, 0, 0, // PC_MULLI + 74, IU2_1, 4, 2, 2, 0, 0, 0, 0, // PC_MULLW + 75, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_NEG + 76, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_SUBF + 77, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_SUBFC + 78, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_SUBFE + 79, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_SUBFIC + 80, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_SUBFME + 81, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_SUBFZE + 82, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_CMPI + 83, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_CMP + 84, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_CMPLI + 85, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_CMPL + 86, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ANDI + 87, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ANDIS + 88, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ORI + 89, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ORIS + 90, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_XORI + 91, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_XORIS + 92, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_AND + 93, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_OR + 94, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_XOR + 95, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_NAND + 96, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_NOR + 97, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_EQV + 98, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ANDC + 99, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ORC + 100, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_EXTSB + 101, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_EXTSH + 102, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_CNTLZW + 103, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_RLWINM + 104, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_RLWNM + 105, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_RLWIMI + 106, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_SLW + 107, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_SRW + 108, IU1a, 2, 2, 0, 0, 0, 0, 0, // PC_SRAWI + 109, IU1a, 2, 2, 0, 0, 0, 0, 0, // PC_SRAW + 110, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_CRAND + 111, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_CRANDC + 112, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_CREQV + 113, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_CRNAND + 114, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_CRNOR + 115, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_CROR + 116, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_CRORC + 117, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_CRXOR + 118, IU2_1, 1, 1, 0, 0, 0, 1, 0, // PC_MCRF + 119, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_MTXER + 120, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_MTCTR + 121, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_MTLR + 122, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_MTCRF + 123, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_MTMSR + 124, IU2_1, 3, 3, 0, 0, 0, 1, 0, // PC_MTSPR + 125, IU2_1, 3, 2, 1, 0, 0, 0, 0, // PC_MFMSR + 126, IU2_1, 3, 3, 0, 0, 0, 1, 0, // PC_MFSPR + 127, IU2_1, 1, 1, 0, 0, 0, 1, 0, // PC_MFXER + 128, IU2_1, 1, 1, 0, 0, 0, 1, 0, // PC_MFCTR + 129, IU2_1, 1, 1, 0, 0, 0, 1, 0, // PC_MFLR + 130, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_MFCR + 131, FPU_1, 5, 5, 0, 0, 0, 1, 0, // PC_MFFS + 132, FPU_1, 5, 5, 0, 0, 0, 1, 0, // PC_MTFSF + 133, LSU_1, 3, 3, 0, 0, 0, 1, 0, // PC_EIEIO + 134, IU2_1, 1, 1, 0, 0, 0, 1, 0, // PC_ISYNC + 135, LSU_1, 35, 35, 0, 0, 0, 1, 0, // PC_SYNC + 136, IU2_1, 1, 1, 0, 0, 0, 1, 0, // PC_RFI + 137, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_LI + 138, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_LIS + 139, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_MR + 140, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_NOP + 141, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_NOT + 142, LSU_1, 4, 1, 1, 1, 1, 0, 0, // PC_LFS + 143, LSU_1, 4, 1, 1, 1, 1, 0, 0, // PC_LFSU + 144, LSU_1, 4, 1, 1, 1, 1, 0, 0, // PC_LFSX + 145, LSU_1, 4, 1, 1, 1, 1, 0, 0, // PC_LFSUX + 146, LSU_1, 4, 1, 1, 1, 1, 0, 0, // PC_LFD + 147, LSU_1, 4, 1, 1, 1, 1, 0, 0, // PC_LFDU + 148, LSU_1, 4, 1, 1, 1, 1, 0, 0, // PC_LFDX + 149, LSU_1, 4, 1, 1, 1, 1, 0, 0, // PC_LFDUX + 150, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_STFS + 151, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_STFSU + 152, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_STFSX + 153, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_STFSUX + 154, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_STFD + 155, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_STFDU + 156, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_STFDX + 157, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_STFDUX + 158, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FMR + 159, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FABS + 160, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FNEG + 161, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FNABS + 162, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FADD + 163, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FADDS + 164, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FSUB + 165, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FSUBS + 166, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FMUL + 167, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FMULS + 168, FPU_1, 35, 35, 0, 0, 0, 0, 0, // PC_FDIV + 169, FPU_1, 21, 21, 0, 0, 0, 0, 0, // PC_FDIVS + 170, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FMADD + 171, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FMADDS + 172, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FMSUB + 173, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FMSUBS + 174, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FNMADD + 175, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FNMADDS + 176, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FNMSUB + 177, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FNMSUBS + 178, FPU_1, 14, 14, 0, 0, 0, 0, 0, // PC_FRES + 179, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FRSQRTE + 180, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FSEL + 181, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FRSP + 182, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FCTIW + 183, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FCTIWZ + 184, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FCMPU + 185, FPU_1, 5, 1, 1, 1, 2, 0, 0, // PC_FCMPO + 186, LSU_1, 3, 3, 0, 0, 0, 1, 0, // PC_LWARX + 187, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LSWI + 188, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_LSWX + 189, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STFIWX + 190, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_STSWI + 191, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_STSWX + 192, LSU_1, 3, 1, 1, 1, 0, 1, 0, // PC_STWCX + 193, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_ECIWX + 194, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_ECOWX + 195, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_DCBI + 196, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_ICBI + 197, IU2_1, 5, 5, 0, 0, 0, 1, 0, // PC_MCRFS + 198, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_MCRXR + 199, IU2_1, 5, 5, 0, 0, 0, 0, 0, // PC_MFTB + 200, IU2_1, 4, 1, 3, 0, 0, 0, 0, // PC_MFSR + 201, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_MTSR + 202, IU2_1, 4, 1, 3, 0, 0, 0, 0, // PC_MFSRIN + 203, IU2_1, 2, 2, 0, 0, 0, 1, 0, // PC_MTSRIN + 204, FPU_1, 5, 5, 0, 0, 0, 1, 0, // PC_MTFSB0 + 205, FPU_1, 5, 5, 0, 0, 0, 1, 0, // PC_MTFSB1 + 206, FPU_1, 5, 5, 0, 0, 0, 0, 0, // PC_MTFSFI + 207, IU2_1, 1, 1, 0, 0, 0, 1, 0, // PC_SC + 208, FPU_1, 1, 1, 0, 0, 0, 0, 0, // PC_FSQRT + 209, FPU_1, 1, 1, 0, 0, 0, 0, 0, // PC_FSQRTS + 210, LSU_1, 1, 1, 0, 0, 0, 0, 0, // PC_TLBIA + 211, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_TLBIE + 212, LSU_1, 3, 3, 0, 0, 0, 0, 0, // PC_TLBLD + 213, LSU_1, 3, 3, 0, 0, 0, 1, 0, // PC_TLBLI + 214, LSU_1, 3, 3, 0, 0, 0, 1, 0, // PC_TLBSYNC + 215, IU1a, 2, 2, 0, 0, 0, 0, 0, // PC_TW + 216, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_TRAP + 217, IU1a, 2, 2, 0, 0, 0, 0, 0, // PC_TWI + 218, IU1a, 1, 1, 0, 0, 0, 1, 0, // PC_OPWORD + 219, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_MFROM + 220, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_DSA + 221, IU1a, 1, 1, 0, 0, 0, 0, 0, // PC_ESA + 222, IU1a, 1, 0, 0, 0, 0, 0, 0, // PC_DCCCI + 223, IU1a, 1, 0, 0, 0, 0, 0, 0, // PC_DCREAD + 224, IU1a, 1, 0, 0, 0, 0, 0, 0, // PC_ICBT + 225, IU1a, 1, 0, 0, 0, 0, 0, 0, // PC_ICCCI + 226, IU1a, 1, 0, 0, 0, 0, 0, 0, // PC_ICREAD + 227, IU1a, 1, 0, 0, 0, 0, 0, 0, // PC_RFCI + 228, IU1a, 1, 0, 0, 0, 0, 0, 0, // PC_TLBRE + 229, IU1a, 1, 0, 0, 0, 0, 0, 0, // PC_TLBSX + 230, IU1a, 1, 0, 0, 0, 0, 0, 0, // PC_TLBWE + 231, IU1a, 1, 0, 0, 0, 0, 0, 0, // PC_WRTEE + 232, IU1a, 1, 0, 0, 0, 0, 0, 0, // PC_WRTEEI + 233, IU1a, 1, 0, 0, 0, 0, 0, 0, // PC_MFDCR + 234, IU1a, 1, 0, 0, 0, 0, 0, 0, // PC_MTDCR + 235, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_DCBA + 236, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_DSS + 237, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_DSSALL + 238, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_DST + 239, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_DSTT + 240, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_DSTST + 241, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_DSTSTT + 242, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LVEBX + 243, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LVEHX + 244, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LVEWX + 245, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LVSL + 246, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LVSR + 247, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LVX + 248, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_LVXL + 249, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STVEBX + 250, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STVEHX + 251, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STVEWX + 252, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STVX + 253, LSU_1, 3, 1, 1, 1, 0, 0, 0, // PC_STVXL + 254, VFPU_1, 2, 2, 0, 0, 0, 1, 0, // PC_MFVSCR + 255, VFPU_1, 2, 2, 0, 0, 0, 1, 0, // PC_MTVSCR + 256, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VADDCUW + 257, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VADDFP + 258, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VADDSBS + 259, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VADDSHS + 260, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VADDSWS + 261, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VADDUBM + 262, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VADDUBS + 263, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VADDUHM + 264, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VADDUHS + 265, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VADDUWM + 266, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VADDUWS + 267, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VAND + 268, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VANDC + 269, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VAVGSB + 270, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VAVGSH + 271, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VAVGSW + 272, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VAVGUB + 273, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VAVGUH + 274, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VAVGUW + 275, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VCFSX + 276, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VCFUX + 277, VFPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VCMPBFP + 278, VFPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VCMPEQFP + 279, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPEQUB + 280, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPEQUH + 281, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPEQUW + 282, VFPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VCMPGEFP + 283, VFPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VCMPGTFP + 284, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPGTSB + 285, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPGTSH + 286, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPGTSW + 287, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPGTUB + 288, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPGTUH + 289, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VCMPGTUW + 290, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VCTSXS + 291, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VCTUXS + 292, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VEXPTEFP + 293, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VLOGEFP + 294, VFPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VMAXFP + 295, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VMAXSB + 296, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VMAXSH + 297, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VMAXSW + 298, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VMAXUB + 299, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VMAXUH + 300, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VMAXUW + 301, VFPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VMINFP + 302, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VMINSB + 303, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VMINSH + 304, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VMINSW + 305, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VMINUB + 306, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VMINUH + 307, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VMINUW + 308, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VMRGHB + 309, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VMRGHH + 310, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VMRGHW + 311, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VMRGLB + 312, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VMRGLH + 313, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VMRGLW + 314, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMULESB + 315, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMULESH + 316, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMULEUB + 317, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMULEUH + 318, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMULOSB + 319, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMULOSH + 320, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMULOUB + 321, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMULOUH + 322, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VNOR + 323, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VOR + 324, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VPKPX + 325, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VPKSHSS + 326, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VPKSHUS + 327, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VPKSWSS + 328, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VPKSWUS + 329, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VPKUHUM + 330, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VPKUHUS + 331, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VPKUWUM + 332, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VPKUWUS + 333, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VREFP + 334, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VRFIM + 335, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VRFIN + 336, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VRFIP + 337, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VRFIZ + 338, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VRLB + 339, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VRLH + 340, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VRLW + 341, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VRSQRTEFP + 342, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VSL + 343, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSLB + 344, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSLH + 345, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VSLO + 346, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSLW + 347, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VSPLTB + 348, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VSPLTH + 349, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VSPLTW + 350, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VSPLTISB + 351, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VSPLTISH + 352, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VSPLTISW + 353, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VSR + 354, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSRAB + 355, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSRAH + 356, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSRAW + 357, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSRB + 358, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSRH + 359, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VSRO + 360, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSRW + 361, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBCUW + 362, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VSUBFP + 363, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBSBS + 364, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBSHS + 365, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBSWS + 366, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBUBM + 367, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBUBS + 368, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBUHM + 369, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBUHS + 370, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBUWM + 371, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSUBUWS + 372, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VSUMSWS + 373, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VSUM2SWS + 374, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VSUM4SBS + 375, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VSUM4SHS + 376, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VSUM4UBS + 377, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VUPKHPX + 378, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VUPKHSB + 379, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VUPKHSH + 380, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VUPKLPX + 381, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VUPKLSB + 382, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VUPKLSH + 383, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VXOR + 384, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMADDFP + 385, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMHADDSHS + 386, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMHRADDSHS + 387, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMLADDUHM + 388, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMSUMMBM + 389, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMSUMSHM + 390, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMSUMSHS + 391, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMSUMUBM + 392, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMSUMUHM + 393, VIU2_1, 4, 1, 1, 1, 1, 0, 0, // PC_VMSUMUHS + 394, VFPU_1, 4, 1, 1, 1, 1, 0, 0, // PC_VNMSUBFP + 395, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VPERM + 396, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VSEL + 397, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VSLDOI + 398, VIU1, 1, 1, 0, 0, 0, 0, 0, // PC_VMR + 399, VPU_1, 2, 1, 1, 0, 0, 0, 0, // PC_VMRP + -1, IU2_1, 1, 1, 0, 0, 0, 1, 0 +}; + +enum { NumPipelineUnits = 6 }; +static struct { + Stage start, end; +} pipeline_units[8] = { + IU2_1, IU2_3, + LSU_1, LSU_4, + FPU_1, FPU_4, + VPU_1, VPU_2, + VIU2_1, VIU2_4, + VFPU_1, VFPU_4 +}; + +enum { NumFinalStages = 11 }; +static Stage finalstages[16] = { + BPU, IU2_3, IU1a, IU1b, + IU1c, LSU_4, FPU_4, VIU1, + VPU_2, VIU2_4, VFPU_4 +}; + +// forward decl +static void complete_instruction(int stage); + +static void advance(int firstStage, int oldStage, int newStage) { + PCode *instr = pipeline_altivec[oldStage].instr; + int cycles = instruction_timing[instr->op].cycles[newStage - firstStage]; + pipeline_altivec[newStage].instr = instr; + pipeline_altivec[newStage].remaining = cycles; + pipeline_altivec[oldStage].instr = NULL; + pipeline_altivec[oldStage].remaining = 0; + if (cycles == 0) + complete_instruction(newStage); +} + +static void assign_completion_buffer(PCode *instr) { + completionbuffers.used++; + completionbuffers.free--; + completionbuffers.entries[completionbuffers.nextFreeSlot].instr = instr; + completionbuffers.entries[completionbuffers.nextFreeSlot].completed = 0; + completionbuffers.nextFreeSlot = (completionbuffers.nextFreeSlot + 1) % MaxEntries; +} + +static void complete_instruction(int stage) { + PCode *instr = pipeline_altivec[stage].instr; + int buf = 0; + while (buf < MaxEntries && completionbuffers.entries[buf].instr != instr) + buf++; + + completionbuffers.entries[buf].completed = 1; + pipeline_altivec[stage].instr = NULL; +} + +static void retire_instruction(void) { + completionbuffers.entries[completionbuffers.nextToRetire].instr = NULL; + completionbuffers.entries[completionbuffers.nextToRetire].completed = 0; + completionbuffers.used--; + completionbuffers.free++; + completionbuffers.nextToRetire = (completionbuffers.nextToRetire + 1) % MaxEntries; +} + +static int latency(PCode *instr) { + int cycles = instruction_timing[instr->op].latency; + if (PCODE_FLAG_SET_F(instr) & fRecordBit) + cycles += 1; + if (instr->op == PC_LMW || instr->op == PC_STMW) + cycles += instr->argCount - 2; + return cycles; +} + +static void initialize(void) { + int stage; + int i; + + fetchqueues[Queue0] = 1; + for (i = 1; i < NumQueues; i++) + fetchqueues[i] = 0; + + for (stage = 0; stage < NumStages; stage++) + pipeline_altivec[stage].instr = NULL; + + completionbuffers.free = MaxEntries; + completionbuffers.used = 0; + completionbuffers.nextToRetire = 0; + completionbuffers.nextFreeSlot = 0; + for (i = 0; i < MaxEntries; i++) { + completionbuffers.entries[i].instr = NULL; + completionbuffers.entries[i].completed = 0; + } +} + +static int can_issue(PCode *instr) { + int stage; + + if (completionbuffers.free == 0) + return 0; + + stage = instruction_timing[instr->op].stage; + + if (stage == IU1a) { + int isClear1 = !pipeline_altivec[IU1a].instr; + int isClear2 = !pipeline_altivec[IU1b].instr; + if (!isClear1 && !isClear2) + return 0; + } else { + if (pipeline_altivec[stage].instr) + return 0; + } + + if (fetchqueues[Queue1] <= 0) + return 0; + + if (stage == FPU_1) { + if (fetchqueues[Queue2] < 1 || fetchqueues[Queue5] >= 1) + return 0; + } else if (stage >= VIU1 && stage <= VFPU_1) { + if (fetchqueues[Queue4] < 1 || fetchqueues[Queue7] >= 2) + return 0; + } else if (stage != BPU) { + if (fetchqueues[Queue3] < 1 || fetchqueues[Queue6] >= 3) + return 0; + } + + return 1; +} + +static void issue(PCode *instr) { + int stage = instruction_timing[instr->op].stage; + int cycles = instruction_timing[instr->op].cycles[0]; + assign_completion_buffer(instr); + + CError_ASSERT(879, --fetchqueues[Queue1] >= 0); + + if (stage == FPU_1) { + fetchqueues[Queue2]--; + fetchqueues[Queue5]++; + } else if (stage >= VIU1 && stage <= VFPU_1) { + fetchqueues[Queue4]--; + fetchqueues[Queue7]++; + } else if (stage != BPU) { + fetchqueues[Queue3]--; + fetchqueues[Queue6]++; + } + + fetchqueues[Queue2] = (fetchqueues[Queue1] < fetchqueues[Queue2]) ? fetchqueues[Queue1] : fetchqueues[Queue2]; + fetchqueues[Queue3] = (fetchqueues[Queue1] < fetchqueues[Queue3]) ? fetchqueues[Queue1] : fetchqueues[Queue3]; + fetchqueues[Queue4] = (fetchqueues[Queue1] < fetchqueues[Queue4]) ? fetchqueues[Queue1] : fetchqueues[Queue4]; + + if (stage == IU1a) { + if (!pipeline_altivec[IU1a].instr) + stage = IU1a; + else if (!pipeline_altivec[IU1b].instr) + stage = IU1b; + else if (!pipeline_altivec[IU1c].instr) + stage = IU1c; + } + + pipeline_altivec[stage].instr = instr; + pipeline_altivec[stage].remaining = cycles; +} + +static void advance_clock(void) { + int num; + int i; + unsigned int unit; + + for (i = 0; i < NumStages; i++) { + if (pipeline_altivec[i].instr && pipeline_altivec[i].remaining) + --pipeline_altivec[i].remaining; + } + + for (i = 0; i < 3; i++) { + if (completionbuffers.used == 0) + break; + if (completionbuffers.entries[completionbuffers.nextToRetire].completed == 0) + break; + retire_instruction(); + } + + unit = 0; + do { + if (pipeline_altivec[finalstages[unit]].instr && pipeline_altivec[finalstages[unit]].remaining == 0) + complete_instruction(finalstages[unit]); + } while (++unit < NumFinalStages); + + unit = 0; + do { + Stage first; + Stage current; + first = pipeline_units[unit].start; + for (current = first; current < pipeline_units[unit].end; current++) { + if (pipeline_altivec[current].instr && pipeline_altivec[current].remaining == 0 && !pipeline_altivec[current + 1].instr) + advance(first, current, current + 1); + } + } while (++unit < NumPipelineUnits); + + fetchqueues[Queue5] = 0; + fetchqueues[Queue6] = 0; + fetchqueues[Queue7] = 0; + +#define CHEAP_MIN(a, b) ( ((a) < (b)) ? (a) : (b) ) + num = 2 - fetchqueues[Queue2]; + num += 6 - fetchqueues[Queue3]; + num += 4 - fetchqueues[Queue4]; + num = (num > 3) ? 3 : num; + num = (completionbuffers.free < num) ? completionbuffers.free : num; + if (fetchqueues[Queue0] < num) + num = fetchqueues[Queue0]; + + fetchqueues[Queue1] += num; + fetchqueues[Queue0] -= num; + + fetchqueues[Queue2] = CHEAP_MIN(fetchqueues[Queue1], CHEAP_MIN(2, fetchqueues[Queue2] + num)); + fetchqueues[Queue3] = CHEAP_MIN(fetchqueues[Queue1], CHEAP_MIN(6, fetchqueues[Queue3] + num)); + fetchqueues[Queue4] = CHEAP_MIN(fetchqueues[Queue1], CHEAP_MIN(4, fetchqueues[Queue4] + num)); + + CError_ASSERT(991, fetchqueues[Queue1] <= (fetchqueues[Queue2] + fetchqueues[Queue3] + fetchqueues[Queue4])); + + if (fetchqueues[Queue0] <= 8) + fetchqueues[Queue0] += 4; +} + +static int serializes(PCode *instr) { + return instruction_timing[instr->op].serializes; +} + +static int uses_vpermute_unit_altivec(PCode *instr) { + return instruction_timing[instr->op].stage == VPU_1; +} + +MachineInfo machine7450 = { + 6, + 1, + 4, + &latency, + &initialize, + &can_issue, + &issue, + &advance_clock, + &serializes, + &uses_vpermute_unit_altivec +}; diff --git a/compiler_and_linker/unsorted/ObjGenMachO.c b/compiler_and_linker/unsorted/ObjGenMachO.c index 890c06e..0a2c843 100644 --- a/compiler_and_linker/unsorted/ObjGenMachO.c +++ b/compiler_and_linker/unsorted/ObjGenMachO.c @@ -186,7 +186,7 @@ static char ObjGen_ComputePrivFlag(UInt8 objectFlags) { case 0: case 1: if ( - (objectFlags & OBJECT_FLAGS_UNUSED) && + (objectFlags & OBJECT_FLAGS_1) && (objectFlags & OBJECT_FLAGS_2) && !(objectFlags & OBJECT_FLAGS_4) ) @@ -199,7 +199,7 @@ static char ObjGen_ComputePrivFlag(UInt8 objectFlags) { if ((objectFlags & OBJECT_FLAGS_40) == OBJECT_FLAGS_40) return 0; if ( - (objectFlags & OBJECT_FLAGS_UNUSED) && + (objectFlags & OBJECT_FLAGS_1) && (objectFlags & OBJECT_FLAGS_2) && !(objectFlags & OBJECT_FLAGS_4) ) diff --git a/compiler_and_linker/unsorted/OpcodeInfo.c b/compiler_and_linker/unsorted/OpcodeInfo.c new file mode 100644 index 0000000..14d9032 --- /dev/null +++ b/compiler_and_linker/unsorted/OpcodeInfo.c @@ -0,0 +1,435 @@ +#include "compiler/PCodeInfo.h" +#include "compiler/PCode.h" + +OpcodeInfo opcodeinfo[] = { + "B", "l;p", 2, 0, fIsBranch | fCanLink | fCanBeAbsolute, 0x48000000, + "BL", "#,m;p", 2, 0, fIsCall | fLink | fCanLink | fCanBeAbsolute, 0x48000001, + "BC", "B,Q,l;p", 5, 0, fIsBranch | fCanLink | fCanBeAbsolute, 0x40000000, + "BCLR", "B,Q;L", 4, 0, fIsBranch | fCanLink, 0x4C000020, + "BCCTR", "B,Q;Cp", 5, 0, fIsBranch | fCanLink, 0x4C000420, + "BT", "Q,l;p", 4, 0, fIsBranch | fCanLink | fCanBeAbsolute, 0x41800000, + "BTLR", "Q;L", 3, 0, fIsBranch | fCanLink, 0x4D800020, + "BTCTR", "Q;Cp", 4, 0, fIsBranch | fCanLink, 0x4D800420, + "BF", "Q,l;p", 4, 0, fIsBranch | fCanLink | fCanBeAbsolute, 0x40800000, + "BFLR", "Q;L", 3, 0, fIsBranch | fCanLink, 0x4C800020, + "BFCTR", "Q;Cp", 4, 0, fIsBranch | fCanLink, 0x4C800420, + "BDNZ", "l;Cp", 3, 0, fIsBranch | fCanLink | fCanBeAbsolute, 0x42000000, + "BDNZT", "Q,l;Cp", 4, 0, fIsBranch | fCanLink | fCanBeAbsolute, 0x41000000, + "BDNZF", "Q,l;Cp", 4, 0, fIsBranch | fCanLink | fCanBeAbsolute, 0x40000000, + "BDZ", "l;Cp", 2, 0, fIsBranch | fCanLink | fCanBeAbsolute, 0x42400000, + "BDZT", "Q,l;Cp", 4, 0, fIsBranch | fCanLink | fCanBeAbsolute, 0x41400000, + "BDZF", "Q,l;Cp", 4, 0, fIsBranch | fCanLink | fCanBeAbsolute, 0x40400000, + "BLR", ";L", 1, 0, fIsBranch | fCanLink, 0x4E800020, + "BCTR", ";Cmp", 3, 0, fIsBranch | fCanLink, 0x4E800420, + "BCTRL", "#;C=L", 2, 0, fIsCall | fLink | fCanLink, 0x4E800421, + "BLRL", "#;+L", 1, 0, fIsCall | fLink | fCanLink, 0x4E800021, + "LBZ", "=r,d(b)", 3, 3, fIsRead, 0x88000000, + "LBZU", "=r,d(+b)", 3, 3, fIsRead | fUpdatesPtr, 0x8C000000, + "LBZX", "=r,(b,r)", 3, 3, fIsRead | fIsPtrOp, 0x7C0000AE, + "LBZUX", "=r,(+b,r)", 3, 3, fIsRead | fIsPtrOp | fUpdatesPtr, 0x7C0000EE, + "LHZ", "=r,d(b)", 3, 3, fIsRead, 0xA0000000, + "LHZU", "=r,d(+b)", 3, 3, fIsRead | fUpdatesPtr, 0xA4000000, + "LHZX", "=r,(b,r)", 3, 3, fIsRead | fIsPtrOp, 0x7C00022E, + "LHZUX", "=r,(+b,r)", 3, 3, fIsRead | fIsPtrOp | fUpdatesPtr, 0x7C00026E, + "LHA", "=r,d(b)", 3, 3, fIsRead, 0xA8000000, + "LHAU", "=r,d(+b)", 3, 3, fIsRead | fUpdatesPtr, 0xAC000000, + "LHAX", "=r,(b,r)", 3, 3, fIsRead | fIsPtrOp, 0x7C0002AE, + "LHAUX", "=r,(+b,r)", 3, 3, fIsRead | fIsPtrOp | fUpdatesPtr, 0x7C0002EE, + "LHBRX", "=r,(b,r)", 3, 3, fIsRead | fIsPtrOp, 0x7C00062C, + "LWZ", "=r,d(b)", 3, 3, fIsRead, 0x80000000, + "LWZU", "=r,d(+b)", 3, 3, fIsRead | fUpdatesPtr, 0x84000000, + "LWZX", "=r,(b,r)", 3, 3, fIsRead | fIsPtrOp, 0x7C00002E, + "LWZUX", "=r,(+b,r)", 3, 3, fIsRead | fIsPtrOp | fUpdatesPtr, 0x7C00006E, + "LWBRX", "=r,(b,r)", 3, 3, fIsRead | fIsPtrOp, 0x7C00042C, + "LMW", "#,=r,d(b);=V", 3, 3, fIsRead, 0xB8000000, + "STB", "r,d(b)", 3, 1, fIsWrite, 0x98000000, + "STBU", "r,d(+b)", 3, 2, fIsWrite | fUpdatesPtr, 0x9C000000, + "STBX", "r,(b,r)", 3, 1, fIsWrite | fIsPtrOp, 0x7C0001AE, + "STBUX", "r,(+b,r)", 3, 2, fIsWrite | fIsPtrOp | fUpdatesPtr, 0x7C0001EE, + "STH", "r,d(b)", 3, 1, fIsWrite, 0xB0000000, + "STHU", "r,d(+b)", 3, 2, fIsWrite | fUpdatesPtr, 0xB4000000, + "STHX", "r,(b,r)", 3, 1, fIsWrite | fIsPtrOp, 0x7C00032E, + "STHUX", "r,(+b,r)", 3, 2, fIsWrite | fIsPtrOp | fUpdatesPtr, 0x7C00036E, + "STHBRX", "r,(b,r)", 3, 1, fIsWrite | fIsPtrOp, 0x7C00072C, + "STW", "r,d(b)", 3, 1, fIsWrite, 0x90000000, + "STWU", "r,d(+b)", 3, 2, fIsWrite | fUpdatesPtr, 0x94000000, + "STWX", "r,(b,r)", 3, 1, fIsWrite | fIsPtrOp, 0x7C00012E, + "STWUX", "r,(+b,r)", 3, 2, fIsWrite | fIsPtrOp | fUpdatesPtr, 0x7C00016E, + "STWBRX", "r,(b,r)", 3, 1, fIsWrite | fIsPtrOp, 0x7C00052C, + "STMW", "#,r,d(b);V", 3, 1, fIsWrite, 0xBC000000, + "DCBF", "b,r", 2, 1, fSideEffects | fOpTypeGPR, 0x7C0000AC, + "DCBST", "b,r", 2, 1, fSideEffects | fOpTypeGPR, 0x7C00006C, + "DCBT", "b,r", 2, 1, fSideEffects | fOpTypeGPR, 0x7C00022C, + "DCBTST", "b,r", 2, 1, fSideEffects | fOpTypeGPR, 0x7C0001EC, + "DCBZ", "b,r", 2, 1, fSideEffects | fOpTypeGPR, 0x7C0007EC, + "ADD", "=r,r,r", 3, 2, fCommutative | fIsCSE | fCanSetCarry | fCanSetRecordBit | fOpTypeGPR, 0x7C000214, + "ADDC", "=r,r,r;+X", 4, 2, fCanSetCarry | fCanSetRecordBit | fSetsCarry | fOpTypeGPR, 0x7C000014, + "ADDE", "=r,r,r;+X", 4, 2, fCanSetCarry | fCanSetRecordBit | fSetsCarry | fOpTypeGPR, 0x7C000114, + "ADDI", "=r,b,m;p", 4, 2, fIsCSE | fPCodeFlag400000 | fCanSetRecordBit | fOpTypeGPR, 0x38000000, + "ADDIC", "=r,r,i;+X", 4, 2, fCanSetRecordBit | fSetsCarry | fOpTypeGPR, 0x30000000, + "ADDICR", "=r,r,n;+X=Z", 5, 2, fCanSetRecordBit | fSetsCarry | fRecordBit | fOpTypeGPR, 0x34000000, + "ADDIS", "=r,b,M", 3, 2, fIsCSE | fPCodeFlag400000 | fOpTypeGPR, 0x3C000000, + "ADDME", "=r,r;+X", 3, 2, fCanSetCarry | fCanSetRecordBit | fSetsCarry | fOpTypeGPR, 0x7C0001D4, + "ADDZE", "=r,r;+X", 3, 2, fCanSetCarry | fCanSetRecordBit | fSetsCarry | fOpTypeGPR, 0x7C000194, + "DIVW", "=r,r,r", 3, 2, fIsCSE | fCanSetCarry | fCanSetRecordBit | fOpTypeGPR, 0x7C0003D6, + "DIVWU", "=r,r,r", 3, 2, fIsCSE | fCanSetCarry | fCanSetRecordBit | fOpTypeGPR, 0x7C000396, + "MULHW", "=r,r,r", 3, 2, fCommutative | fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C000096, + "MULHWU", "=r,r,r", 3, 2, fCommutative | fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C000016, + "MULLI", "=r,r,i", 3, 2, fIsCSE | fOpTypeGPR, 0x1C000000, + "MULLW", "=r,r,r", 3, 2, fCommutative | fIsCSE | fCanSetCarry | fCanSetRecordBit | fOpTypeGPR, 0x7C0001D6, + "NEG", "=r,r", 2, 2, fIsCSE | fCanSetCarry | fCanSetRecordBit | fOpTypeGPR, 0x7C0000D0, + "SUBF", "=r,r,r", 3, 2, fIsCSE | fCanSetCarry | fCanSetRecordBit | fOpTypeGPR, 0x7C000050, + "SUBFC", "=r,r,r;+X", 4, 2, fCanSetCarry | fCanSetRecordBit | fSetsCarry | fOpTypeGPR, 0x7C000010, + "SUBFE", "=r,r,r;+X", 4, 2, fCanSetCarry | fCanSetRecordBit | fSetsCarry | fOpTypeGPR, 0x7C000110, + "SUBFIC", "=r,r,i;+X", 4, 2, fSetsCarry | fOpTypeGPR, 0x20000000, + "SUBFME", "=r,r;+X", 3, 2, fCanSetCarry | fCanSetRecordBit | fSetsCarry | fOpTypeGPR, 0x7C0001D0, + "SUBFZE", "=r,r;+X", 3, 2, fCanSetCarry | fCanSetRecordBit | fSetsCarry | fOpTypeGPR, 0x7C000190, + "CMPI", "=?c,Or,i", 3, 1, fIsCSE | fOpTypeGPR, 0x2C000000, + "CMP", "=?c,Or,r", 3, 1, fIsCSE | fOpTypeGPR, 0x7C000000, + "CMPLI", "=?c,Or,u", 3, 1, fIsCSE | fOpTypeGPR, 0x28000000, + "CMPL", "=?c,Or,r", 3, 1, fIsCSE | fOpTypeGPR, 0x7C000040, + "ANDI", "=r,r,x;=Z", 4, 2, fCanSetRecordBit | fRecordBit | fOpTypeGPR, 0x70000000, + "ANDIS", "=r,r,x;=Z", 4, 2, fCanSetRecordBit | fRecordBit | fOpTypeGPR, 0x74000000, + "ORI", "=r,r,x", 3, 2, fIsCSE | fOpTypeGPR, 0x60000000, + "ORIS", "=r,r,x", 3, 2, fIsCSE | fOpTypeGPR, 0x64000000, + "XORI", "=r,r,x", 3, 2, fIsCSE | fOpTypeGPR, 0x68000000, + "XORIS", "=r,r,x", 3, 2, fIsCSE | fOpTypeGPR, 0x6C000000, + "AND", "=r,r,r", 3, 2, fCommutative | fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C000038, + "OR", "=r,r,r;pp", 5, 2, fCommutative | fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C000378, + "XOR", "=r,r,r", 3, 2, fCommutative | fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C000278, + "NAND", "=r,r,r", 3, 2, fCommutative | fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C0003B8, + "NOR", "=r,r,r", 3, 2, fCommutative | fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C0000F8, + "EQV", "=r,r,r", 3, 2, fCommutative | fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C000238, + "ANDC", "=r,r,r", 3, 2, fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C000078, + "ORC", "=r,r,r", 3, 2, fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C000338, + "EXTSB", "=r,r", 2, 2, fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C000774, + "EXTSH", "=r,r", 2, 2, fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C000734, + "CNTLZW", "=r,r", 2, 2, fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C000034, + "RLWINM", "=r,r,u5,u5,u5", 5, 2, fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x54000000, + "RLWNM", "=r,r,r,u5,u5", 5, 2, fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x5C000000, + "RLWIMI", "+r,r,u5,u5,u5", 5, 2, fCanSetRecordBit | fOpTypeGPR, 0x50000000, + "SLW", "=r,r,r", 3, 2, fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C000030, + "SRW", "=r,r,r", 3, 2, fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C000430, + "SRAWI", "=r,r,u5;+X", 4, 2, fCanSetRecordBit | fSetsCarry | fOpTypeGPR, 0x7C000670, + "SRAW", "=r,r,r;+X", 4, 2, fCanSetRecordBit | fSetsCarry | fOpTypeGPR, 0x7C000630, + "CRAND", "=Q,Q,Q", 6, 2, fCommutative | fIsCSE | fOpTypeGPR, 0x4C000202, + "CRANDC", "=Q,Q,Q", 6, 2, fIsCSE | fOpTypeGPR, 0x4C000102, + "CREQV", "=Q,Q,Q", 6, 2, fCommutative | fIsCSE | fOpTypeGPR, 0x4C000242, + "CRNAND", "=Q,Q,Q", 6, 2, fCommutative | fIsCSE | fOpTypeGPR, 0x4C0001C2, + "CRNOR", "=Q,Q,Q", 6, 2, fCommutative | fIsCSE | fOpTypeGPR, 0x4C000042, + "CROR", "=Q,Q,Q", 6, 2, fCommutative | fIsCSE | fOpTypeGPR, 0x4C000382, + "CRORC", "=Q,Q,Q", 6, 2, fIsCSE | fOpTypeGPR, 0x4C000342, + "CRXOR", "=Q,Q,Q", 6, 2, fCommutative | fIsCSE | fOpTypeGPR, 0x4C000182, + "MCRF", "=c,c", 2, 1, fIsMove | fOpTypeGPR, 0x4C000000, + "MTXER", "r;=X", 2, 1, fSetsCarry | fOpTypeGPR, 0x7C0103A6, + "MTCTR", "r;=C", 2, 1, fOpTypeGPR, 0x7C0903A6, + "MTLR", "r;=L", 2, 1, fOpTypeGPR, 0x7C0803A6, + "MTCRF", "x8,r;=Y", 10, 1, fOpTypeGPR, 0x7C000120, + "MTMSR", "r", 1, 4, fSideEffects | fOpTypeGPR, 0x7C000124, + "MTSPR", "=s,r", 2, 4, fOpTypeGPR, 0x7C0003A6, + "MFMSR", "=r", 1, 4, fOpTypeGPR, 0x7C0000A6, + "MFSPR", "=r,s", 2, 4, fOpTypeGPR, 0x7C0002A6, + "MFXER", "=r;X", 2, 4, fOpTypeGPR, 0x7C0102A6, + "MFCTR", "=r;C", 2, 4, fOpTypeGPR, 0x7C0902A6, + "MFLR", "=r;L", 2, 4, fOpTypeGPR, 0x7C0802A6, + "MFCR", "=r;Y", 9, 4, fOpTypeGPR, 0x7C000026, + "MFFS", "=f", 1, 4, fCanSetRecordBit | fOpTypeFPR, 0xFC00048E, + "MTFSF", "x8,f", 2, 1, fSideEffects | fCanSetRecordBit | fOpTypeFPR, 0xFC00058E, + "EIEIO", "", 0, 0, fSideEffects | fOpTypeGPR, 0x7C0006AC, + "ISYNC", "", 0, 0, fSideEffects | fOpTypeGPR, 0x4C00012C, + "SYNC", "", 0, 0, fSideEffects | fOpTypeGPR, 0x7C0004AC, + "RFI", "", 0, 0, fSideEffects, 0x4C000064, + "LI", "=r,n", 2, 4, fIsCSE | fOpTypeGPR, 0x38000000, + "LIS", "=r,M", 2, 4, fIsCSE | fOpTypeGPR, 0x3C000000, + "MR", "=r,r;p", 3, 0, fIsMove | fCanSetRecordBit | fOpTypeGPR, 0x7C000378, + "NOP", "", 0, 0, fSideEffects | fOpTypeGPR, 0x60000000, + "NOT", "=r,r", 2, 2, fIsCSE | fCanSetRecordBit | fOpTypeGPR, 0x7C0000F8, + "LFS", "=f,d(b)", 3, 3, fIsRead, 0xC0000000, + "LFSU", "=f,d(+b)", 3, 3, fIsRead | fUpdatesPtr, 0xC4000000, + "LFSX", "=f,(b,r)", 3, 3, fIsRead | fIsPtrOp, 0x7C00042E, + "LFSUX", "=f,(+b,r)", 3, 3, fIsRead | fIsPtrOp | fUpdatesPtr, 0x7C00046E, + "LFD", "=f,d(b)", 3, 3, fIsRead, 0xC8000000, + "LFDU", "=f,d(+b)", 3, 3, fIsRead | fUpdatesPtr, 0xCC000000, + "LFDX", "=f,(b,r)", 3, 3, fIsRead | fIsPtrOp, 0x7C0004AE, + "LFDUX", "=f,(+b,r)", 3, 3, fIsRead | fIsPtrOp | fUpdatesPtr, 0x7C0004EE, + "STFS", "f,d(b)", 3, 1, fIsWrite, 0xD0000000, + "STFSU", "f,d(+b)", 3, 2, fIsWrite | fUpdatesPtr, 0xD4000000, + "STFSX", "f,(b,r)", 3, 1, fIsWrite | fIsPtrOp, 0x7C00052E, + "STFSUX", "f,(+b,r)", 3, 2, fIsWrite | fIsPtrOp | fUpdatesPtr, 0x7C00056E, + "STFD", "f,d(b)", 3, 1, fIsWrite, 0xD8000000, + "STFDU", "f,d(+b)", 3, 2, fIsWrite | fUpdatesPtr, 0xDC000000, + "STFDX", "f,(b,r)", 3, 1, fIsWrite | fIsPtrOp, 0x7C0005AE, + "STFDUX", "f,(+b,r)", 3, 2, fIsWrite | fIsPtrOp | fUpdatesPtr, 0x7C0005EE, + "FMR", "=f,f", 2, 0, fIsMove | fCanSetRecordBit | fOpTypeFPR, 0xFC000090, + "FABS", "=f,f", 2, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC000210, + "FNEG", "=f,f", 2, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC000050, + "FNABS", "=f,f", 2, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC000110, + "FADD", "=f,f,f", 3, 2, fCommutative | fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC00002A, + "FADDS", "=f,f,f", 3, 2, fCommutative | fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xEC00002A, + "FSUB", "=f,f,f", 3, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC000028, + "FSUBS", "=f,f,f", 3, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xEC000028, + "FMUL", "=f,f,f", 3, 2, fCommutative | fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC000032, + "FMULS", "=f,f,f", 3, 2, fCommutative | fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xEC000032, + "FDIV", "=f,f,f", 3, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC000024, + "FDIVS", "=f,f,f", 3, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xEC000024, + "FMADD", "=f,f,f,f", 4, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC00003A, + "FMADDS", "=f,f,f,f", 4, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xEC00003A, + "FMSUB", "=f,f,f,f", 4, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC000038, + "FMSUBS", "=f,f,f,f", 4, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xEC000038, + "FNMADD", "=f,f,f,f", 4, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC00003E, + "FNMADDS", "=f,f,f,f", 4, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xEC00003E, + "FNMSUB", "=f,f,f,f", 4, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC00003C, + "FNMSUBS", "=f,f,f,f", 4, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xEC00003C, + "FRES", "=f,f", 2, 2, fCanSetRecordBit | fOpTypeFPR, 0xEC000030, + "FRSQRTE", "=f,f", 2, 2, fCanSetRecordBit | fOpTypeFPR, 0xFC000034, + "FSEL", "=f,f,f,f", 4, 2, fCanSetRecordBit | fOpTypeFPR, 0xFC00002E, + "FRSP", "=f,f", 2, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC000018, + "FCTIW", "=f,f", 2, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC00001C, + "FCTIWZ", "=f,f", 2, 2, fIsCSE | fCanSetRecordBit | fOpTypeFPR, 0xFC00001E, + "FCMPU", "=?c,f,f", 3, 1, fIsCSE | fOpTypeFPR, 0xFC000000, + "FCMPO", "=?c,f,f", 3, 1, fIsCSE | fOpTypeFPR, 0xFC000040, + "LWARX", "=r,(b,r)", 3, 3, fIsRead | fIsPtrOp, 0x7C000028, + "LSWI", "=r,b,N", 3, 3, fIsRead | fIsPtrOp | fSideEffects, 0x7C0004AA, + "LSWX", "=r,(b,r)", 3, 3, fIsRead | fIsPtrOp | fSideEffects, 0x7C00042A, + "STFIWX", "f,(b,r)", 3, 3, fIsWrite | fIsPtrOp, 0x7C0007AE, + "STSWI", "r,b,N", 3, 3, fIsWrite | fIsPtrOp, 0x7C0005AA, + "STSWX", "r,(b,r)", 3, 3, fIsWrite | fIsPtrOp, 0x7C00052A, + "STWCX", "r,(b,r);=Z", 4, 3, fIsWrite | fIsPtrOp | fCanSetRecordBit | fRecordBit, 0x7C00012D, + "ECIWX", "=r,(b,r)", 3, 3, fIsRead | fIsPtrOp, 0x7C00026C, + "ECOWX", "r,(b,r)", 3, 1, fIsWrite | fIsPtrOp | fSideEffects, 0x7C00036C, + "DCBI", "b,r", 2, 1, fSideEffects | fOpTypeGPR, 0x7C0003AC, + "ICBI", "b,r", 2, 1, fSideEffects | fOpTypeGPR, 0x7C0007AC, + "MCRFS", "=c,x3", 2, 1, fSideEffects | fOpTypeGPR, 0xFC000080, + "MCRXR", "=c;+X", 2, 1, fOpTypeGPR, 0x7C000400, + "MFTB", "=r?T", 2, 4, fOpTypeGPR, 0x7C0002E6, + "MFSR", "=r,u4", 2, 4, fOpTypeGPR, 0x7C0004A6, + "MTSR", "u4,r", 2, 4, fSideEffects | fOpTypeGPR, 0x7C0001A4, + "MFSRIN", "=r,r", 2, 4, fOpTypeGPR, 0x7C000526, + "MTSRIN", "r,r", 2, 4, fSideEffects | fOpTypeGPR, 0x7C0001E4, + "MTFSB0", "u5", 1, 4, fSideEffects | fCanSetRecordBit | fOpTypeGPR, 0xFC00008C, + "MTFSB1", "u5", 1, 4, fSideEffects | fCanSetRecordBit | fOpTypeGPR, 0xFC00004C, + "MTFSFI", "c,x4", 2, 1, fSideEffects | fCanSetRecordBit | fOpTypeGPR, 0xFC00010C, + "SC", "", 0, 0, fIsCall | fSideEffects, 0x44000002, + "FSQRT", "=f,f", 2, 2, fCanSetRecordBit | fOpTypeFPR, 0xFC00002C, + "FSQRTS", "=f,f", 2, 2, fCanSetRecordBit | fOpTypeFPR, 0xEC00002C, + "TLBIA", "", 0, 1, fSideEffects, 0x7C0002E4, + "TLBIE", "r", 1, 1, fSideEffects, 0x7C000264, + "TLBLD", "r", 1, 1, fSideEffects, 0x7C0007A4, + "TLBLI", "r", 1, 1, fSideEffects, 0x7C0007E4, + "TLBSYNC", "", 0, 1, fSideEffects, 0x7C00046C, + "TW", "t,r,r", 3, 1, fIsCall | fSideEffects, 0x7C000008, + "TRAP", "", 0, 1, fIsCall | fSideEffects, 0x7FE00008, + "TWI", "t,r,x", 3, 1, fIsCall | fSideEffects, 0x0C000000, + "OPWORD", "w", 1, 0, fSideEffects, 0x00000000, + "MFROM", "=r,r", 2, 4, fIsRead, 0x7C000212, + "DSA", "", 0, 0, fSideEffects | fOpTypeGPR, 0x7C0004E8, + "ESA", "", 0, 0, fSideEffects | fOpTypeGPR, 0x7C0004A8, + "DCCCI", "b,r", 2, 0, fSideEffects | fOpTypeGPR, 0x7C00038C, + "DCREAD", "=r,(b,r)", 3, 0, fSideEffects | fPCodeFlag400000 | fOpTypeGPR, 0x7C0003CC, + "ICBT", "b,r", 2, 0, fSideEffects | fOpTypeGPR, 0x7C00020C, + "ICCCI", "b,r", 2, 0, fSideEffects | fOpTypeGPR, 0x7C00078C, + "ICREAD", "b,r", 2, 0, fSideEffects | fOpTypeGPR, 0x7C0007CC, + "RFCI", "", 0, 0, fSideEffects | fOpTypeGPR, 0x4C000066, + "TLBRE", "=r,r,u1", 3, 0, fSideEffects | fOpTypeGPR, 0x7C000764, + "TLBSX", "=r,(b,r)", 3, 0, fSideEffects | fPCodeFlag400000 | fCanSetRecordBit | fOpTypeGPR, 0x7C000724, + "TLBWE", "=r,r,i", 3, 0, fSideEffects | fOpTypeGPR, 0x7C0007A4, + "WRTEE", "r", 1, 0, fSideEffects | fOpTypeGPR, 0x7C000106, + "WRTEEI", "u1", 1, 0, fSideEffects | fOpTypeGPR, 0x7C000146, + "MFDCR", "=r,D", 2, 4, fSideEffects | fOpTypeGPR, 0x7C000286, + "MTDCR", "D,r", 2, 4, fSideEffects | fOpTypeGPR, 0x7C000386, + "DCBA", "b,r", 2, 1, fSideEffects | fOpTypeGPR, 0x7C0005EC, + "DSS", "u2?u2", 2, 1, fSideEffects | fOpTypeGPR, 0x7C00066C, + "DSSALL", "", 0, 1, fSideEffects | fOpTypeGPR, 0x7E00066C, + "DST", "b,r,u2?u2", 4, 1, fSideEffects | fOpTypeGPR, 0x7C0002AC, + "DSTT", "b,r,u2", 3, 1, fSideEffects | fOpTypeGPR, 0x7E0002AC, + "DSTST", "b,r,u2?u2", 4, 1, fSideEffects | fOpTypeGPR, 0x7C0002EC, + "DSTSTT", "b,r,u2", 3, 1, fSideEffects | fOpTypeGPR, 0x7E0002EC, + "LVEBX", "=v,(b,r)", 3, 3, fIsRead | fIsPtrOp | fOpTypeVR, 0x7C00000E, + "LVEHX", "=v,(b,r)", 3, 3, fIsRead | fIsPtrOp | fOpTypeVR, 0x7C00004E, + "LVEWX", "=v,(b,r)", 3, 3, fIsRead | fIsPtrOp | fOpTypeVR, 0x7C00008E, + "LVSL", "=v,(b,r)", 3, 3, fPCodeFlag400000 | fOpTypeVR, 0x7C00000C, + "LVSR", "=v,(b,r)", 3, 3, fPCodeFlag400000 | fOpTypeVR, 0x7C00004C, + "LVX", "=v,(b,r)", 3, 3, fIsRead | fIsPtrOp | fOpTypeVR, 0x7C0000CE, + "LVXL", "=v,(b,r)", 3, 3, fIsRead | fIsPtrOp | fOpTypeVR, 0x7C0002CE, + "STVEBX", "v,(b,r)", 3, 1, fIsWrite | fIsPtrOp | fOpTypeVR, 0x7C00010E, + "STVEHX", "v,(b,r)", 3, 1, fIsWrite | fIsPtrOp | fOpTypeVR, 0x7C00014E, + "STVEWX", "v,(b,r)", 3, 1, fIsWrite | fIsPtrOp | fOpTypeVR, 0x7C00018E, + "STVX", "v,(b,r)", 3, 1, fIsWrite | fIsPtrOp | fOpTypeVR, 0x7C0001CE, + "STVXL", "v,(b,r)", 3, 1, fIsWrite | fIsPtrOp | fOpTypeVR, 0x7C0003CE, + "MFVSCR", "=v", 1, 3, fSideEffects | fOpTypeVR, 0x10000604, + "MTVSCR", "v", 1, 3, fSideEffects | fOpTypeVR, 0x10000644, + "VADDCUW", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000180, + "VADDFP", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x1000000A, + "VADDSBS", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000300, + "VADDSHS", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000340, + "VADDSWS", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000380, + "VADDUBM", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000000, + "VADDUBS", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000200, + "VADDUHM", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000040, + "VADDUHS", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000240, + "VADDUWM", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000080, + "VADDUWS", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000280, + "VAND", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000404, + "VANDC", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000444, + "VAVGSB", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000502, + "VAVGSH", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000542, + "VAVGSW", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000582, + "VAVGUB", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000402, + "VAVGUH", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000442, + "VAVGUW", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000482, + "VCFSX", "=v,v,u5", 3, 2, fIsCSE | fOpTypeVR, 0x1000034A, + "VCFUX", "=v,v,u5", 3, 2, fIsCSE | fOpTypeVR, 0x1000030A, + "VCMPBFP", "=v,v,v", 3, 2, fCanSetRecordBit | fOpTypeVR, 0x100003C6, + "VCMPEQFP", "=v,v,v", 3, 2, fCanSetRecordBit | fOpTypeVR, 0x100000C6, + "VCMPEQUB", "=v,v,v", 3, 2, fCanSetRecordBit | fOpTypeVR, 0x10000006, + "VCMPEQUH", "=v,v,v", 3, 2, fCanSetRecordBit | fOpTypeVR, 0x10000046, + "VCMPEQUW", "=v,v,v", 3, 2, fCanSetRecordBit | fOpTypeVR, 0x10000086, + "VCMPGEFP", "=v,v,v", 3, 2, fCanSetRecordBit | fOpTypeVR, 0x100001C6, + "VCMPGTFP", "=v,v,v", 3, 2, fCanSetRecordBit | fOpTypeVR, 0x100002C6, + "VCMPGTSB", "=v,v,v", 3, 2, fCanSetRecordBit | fOpTypeVR, 0x10000306, + "VCMPGTSH", "=v,v,v", 3, 2, fCanSetRecordBit | fOpTypeVR, 0x10000346, + "VCMPGTSW", "=v,v,v", 3, 2, fCanSetRecordBit | fOpTypeVR, 0x10000386, + "VCMPGTUB", "=v,v,v", 3, 2, fCanSetRecordBit | fOpTypeVR, 0x10000206, + "VCMPGTUH", "=v,v,v", 3, 2, fCanSetRecordBit | fOpTypeVR, 0x10000246, + "VCMPGTUW", "=v,v,v", 3, 2, fCanSetRecordBit | fOpTypeVR, 0x10000286, + "VCTSXS", "=v,v,u5", 3, 2, fIsCSE | fOpTypeVR, 0x100003CA, + "VCTUXS", "=v,v,u5", 3, 2, fIsCSE | fOpTypeVR, 0x1000038A, + "VEXPTEFP", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x1000018A, + "VLOGEFP", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x100001CA, + "VMAXFP", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x1000040A, + "VMAXSB", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000102, + "VMAXSH", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000142, + "VMAXSW", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000182, + "VMAXUB", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000002, + "VMAXUH", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000042, + "VMAXUW", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000082, + "VMINFP", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x1000044A, + "VMINSB", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000302, + "VMINSH", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000342, + "VMINSW", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000382, + "VMINUB", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000202, + "VMINUH", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000242, + "VMINUW", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000282, + "VMRGHB", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000000C, + "VMRGHH", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000004C, + "VMRGHW", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000008C, + "VMRGLB", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000010C, + "VMRGLH", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000014C, + "VMRGLW", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000018C, + "VMULESB", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000308, + "VMULESH", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000348, + "VMULEUB", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000208, + "VMULEUH", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000248, + "VMULOSB", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000108, + "VMULOSH", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000148, + "VMULOUB", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000008, + "VMULOUH", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000048, + "VNOR", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000504, + "VOR", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x10000484, + "VPKPX", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000030E, + "VPKSHSS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000018E, + "VPKSHUS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000010E, + "VPKSWSS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x100001CE, + "VPKSWUS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000014E, + "VPKUHUM", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000000E, + "VPKUHUS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000008E, + "VPKUWUM", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000004E, + "VPKUWUS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x100000CE, + "VREFP", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x1000010A, + "VRFIM", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x100002CA, + "VRFIN", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x1000020A, + "VRFIP", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x1000028A, + "VRFIZ", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x1000024A, + "VRLB", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000004, + "VRLH", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000044, + "VRLW", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000084, + "VRSQRTEFP", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x1000014A, + "VSL", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x100001C4, + "VSLB", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000104, + "VSLH", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000144, + "VSLO", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000040C, + "VSLW", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000184, + "VSPLTB", "=v,v,u5", 3, 2, fIsCSE | fOpTypeVR, 0x1000020C, + "VSPLTH", "=v,v,u5", 3, 2, fIsCSE | fOpTypeVR, 0x1000024C, + "VSPLTW", "=v,v,u5", 3, 2, fIsCSE | fOpTypeVR, 0x1000028C, + "VSPLTISB", "=v,i5", 2, 2, fIsCSE | fOpTypeVR, 0x1000030C, + "VSPLTISH", "=v,i5", 2, 2, fIsCSE | fOpTypeVR, 0x1000034C, + "VSPLTISW", "=v,i5", 2, 2, fIsCSE | fOpTypeVR, 0x1000038C, + "VSR", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x100002C4, + "VSRAB", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000304, + "VSRAH", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000344, + "VSRAW", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000384, + "VSRB", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000204, + "VSRH", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000244, + "VSRO", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000044C, + "VSRW", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000284, + "VSUBCUW", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000580, + "VSUBFP", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x1000004A, + "VSUBSBS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000700, + "VSUBSHS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000740, + "VSUBSWS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000780, + "VSUBUBM", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000400, + "VSUBUBS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000600, + "VSUBUHM", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000440, + "VSUBUHS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000640, + "VSUBUWM", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000480, + "VSUBUWS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000680, + "VSUMSWS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000788, + "VSUM2SWS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000688, + "VSUM4SBS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000708, + "VSUM4SHS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000648, + "VSUM4UBS", "=v,v,v", 3, 2, fIsCSE | fOpTypeVR, 0x10000608, + "VUPKHPX", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x1000034E, + "VUPKHSB", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x1000020E, + "VUPKHSH", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x1000024E, + "VUPKLPX", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x100003CE, + "VUPKLSB", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x1000028E, + "VUPKLSH", "=v,v", 2, 2, fIsCSE | fOpTypeVR, 0x100002CE, + "VXOR", "=v,v,v", 3, 2, fCommutative | fIsCSE | fOpTypeVR, 0x100004C4, + "VMADDFP", "=v,v,v,v", 4, 2, fIsCSE | fOpTypeVR, 0x1000002E, + "VMHADDSHS", "=v,v,v,v", 4, 2, fIsCSE | fOpTypeVR, 0x10000020, + "VMHRADDSHS", "=v,v,v,v", 4, 2, fIsCSE | fOpTypeVR, 0x10000021, + "VMLADDUHM", "=v,v,v,v", 4, 2, fIsCSE | fOpTypeVR, 0x10000022, + "VMSUMMBM", "=v,v,v,v", 4, 2, fIsCSE | fOpTypeVR, 0x10000025, + "VMSUMSHM", "=v,v,v,v", 4, 2, fIsCSE | fOpTypeVR, 0x10000028, + "VMSUMSHS", "=v,v,v,v", 4, 2, fIsCSE | fOpTypeVR, 0x10000029, + "VMSUMUBM", "=v,v,v,v", 4, 2, fIsCSE | fOpTypeVR, 0x10000024, + "VMSUMUHM", "=v,v,v,v", 4, 2, fIsCSE | fOpTypeVR, 0x10000026, + "VMSUMUHS", "=v,v,v,v", 4, 2, fIsCSE | fOpTypeVR, 0x10000027, + "VNMSUBFP", "=v,v,v,v", 4, 2, fIsCSE | fOpTypeVR, 0x1000002F, + "VPERM", "=v,v,v,v", 4, 2, fIsCSE | fOpTypeVR, 0x1000002B, + "VSEL", "=v,v,v,v", 4, 2, fIsCSE | fOpTypeVR, 0x1000002A, + "VSLDOI", "=v,v,v,u4", 4, 2, fIsCSE | fOpTypeVR, 0x1000002C, + "VMR", "=v,v", 2, 2, fIsMove | fOpTypeVR, 0x10000484, + "VMRP", "=v,v", 2, 2, fIsMove | fOpTypeVR, 0x1000002C, + "SLE", "=r,r,r", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C000132, + "SLEQ", "=r,r,r", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C0001B2, + "SLIQ", "=r,r,u5", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C000170, + "SLLIQ", "=r,r,u5", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C0001F0, + "SLLQ", "=r,r,r", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C0001B0, + "SLQ", "=r,r,r", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C000130, + "SRAIQ", "=r,r,u5", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C000770, + "SRAQ", "=r,r,r", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C000730, + "SRE", "=r,r,r", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C000532, + "SREA", "=r,r,r", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C000732, + "SREQ", "=r,r,r", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C0005B2, + "SRIQ", "=r,r,u5", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C000570, + "SRLIQ", "=r,r,u5", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C0005F0, + "SRLQ", "=r,r,r", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C0005B0, + "SRQ", "=r,r,r", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C000530, + "MASKG", "=r,r,r", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C00003A, + "MASKIR", "=r,r,r", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C00043A, + "LSCBX", "=r,(b,r)", 3, 3, fIsRead | fIsPtrOp | fSideEffects | fCanSetRecordBit, 0x7C00022A, + "DIV", "=r,r,r", 3, 2, fCanSetCarry | fCanSetRecordBit | fOpTypeGPR, 0x7C000296, + "DIVS", "=r,r,r", 3, 2, fCanSetCarry | fCanSetRecordBit | fOpTypeGPR, 0x7C0002D6, + "DOZ", "=r,r,r", 3, 2, fCanSetCarry | fCanSetRecordBit | fOpTypeGPR, 0x7C000210, + "MUL", "=r,r,r", 3, 2, fCanSetCarry | fCanSetRecordBit | fOpTypeGPR, 0x7C0000D6, + "NABS", "=r,r", 2, 2, fCanSetCarry | fCanSetRecordBit | fOpTypeGPR, 0x7C0003D0, + "ABS", "=r,r", 2, 2, fCanSetCarry | fCanSetRecordBit | fOpTypeGPR, 0x7C0002D0, + "CLCS", "=r,r", 2, 2, fOpTypeGPR, 0x7C000426, + "DOZI", "=r,r,u5", 3, 2, fOpTypeGPR, 0x24000000, + "RLMI", "+r,r,r,u5,u5", 5, 2, fCanSetRecordBit | fOpTypeGPR, 0x58000000, + "RRIB", "=r,r,r", 3, 2, fCanSetRecordBit | fOpTypeGPR, 0x7C000432, + "PENTRY", "", 0, 0, 0, 0x00000000, + "PEXIT", "", 0, 0, 0, 0x00000000 +}; diff --git a/compiler_and_linker/unsorted/Operands.c b/compiler_and_linker/unsorted/Operands.c index bdf75f9..d1e96ef 100644 --- a/compiler_and_linker/unsorted/Operands.c +++ b/compiler_and_linker/unsorted/Operands.c @@ -2,15 +2,17 @@ #include "compiler/CError.h" #include "compiler/CMachine.h" #include "compiler/CParser.h" +#include "compiler/CodeGen.h" +#include "compiler/CompilerTools.h" #include "compiler/PCode.h" #include "compiler/PCodeInfo.h" #include "compiler/PCodeUtilities.h" +#include "compiler/RegisterInfo.h" #include "compiler/Registers.h" #include "compiler/StackFrame.h" +#include "compiler/TOC.h" #include "compiler/enode.h" #include "compiler/objects.h" -#include "compiler/CodeGen.h" -#include "compiler/RegisterInfo.h" unsigned long long uns_to_float_cc = 0x4330000000000000; unsigned long long int_to_float_cc = 0x4330000080000000; @@ -65,7 +67,7 @@ void indirect(Operand *op, ENode *expr) { case OpndType_IndirectGPR_Indexed: case OpndType_IndirectSymbol: if (op->optype) - Coerce_to_register(op, (Type *) &void_ptr, 0); + Coerce_to_register(op, TYPE(&void_ptr), 0); case OpndType_GPR: op->immOffset = 0; op->object = NULL; @@ -345,7 +347,7 @@ void coerce_to_addressable(Operand *op) { void Coerce_to_register(Operand *op, Type *type, short output_reg) { SInt32 offset; - short opcode; + Opcode opcode; short reg; short tmp; short cond_neg; @@ -581,7 +583,7 @@ void coerce_to_register_pair(Operand *op, Type *type, short output_reg, short ou } } -void Coerce_to_fp_register(Operand *op, TypeIntegral *tint, short output_reg) { +void Coerce_to_fp_register(Operand *op, Type *type, short output_reg) { short reg; coerce_to_addressable(op); @@ -592,12 +594,12 @@ void Coerce_to_fp_register(Operand *op, TypeIntegral *tint, short output_reg) { break; case OpndType_IndirectGPR_ImmOffset: reg = output_reg ? output_reg : used_virtual_registers[RegClass_FPR]++; - load_store_register((tint->size == 4) ? PC_LFS : PC_LFD, reg, op->reg, op->object, op->immOffset); + load_store_register((type->size == 4) ? PC_LFS : PC_LFD, reg, op->reg, op->object, op->immOffset); setpcodeflags(op->flags); break; case OpndType_IndirectGPR_Indexed: reg = output_reg ? output_reg : used_virtual_registers[RegClass_FPR]++; - emitpcode((tint->size == 4) ? PC_LFSX : PC_LFDX, reg, op->reg, op->regOffset, 0, 0x390); + emitpcode((type->size == 4) ? PC_LFSX : PC_LFDX, reg, op->reg, op->regOffset, 0, 0x390); setpcodeflags(op->flags); break; default: @@ -608,7 +610,7 @@ void Coerce_to_fp_register(Operand *op, TypeIntegral *tint, short output_reg) { op->reg = reg; } -void Coerce_to_v_register(Operand *op, TypeStruct *tstruct, short output_reg) { +void Coerce_to_v_register(Operand *op, Type *type, short output_reg) { short reg; coerce_to_addressable(op); @@ -629,7 +631,7 @@ void Coerce_to_v_register(Operand *op, TypeStruct *tstruct, short output_reg) { break; case OpndType_Absolute: reg = output_reg ? output_reg : used_virtual_registers[RegClass_VR]++; - switch (tstruct->stype) { + switch (TYPE_STRUCT(type)->stype) { case STRUCT_TYPE_4: case STRUCT_TYPE_5: case STRUCT_TYPE_6: @@ -663,7 +665,7 @@ void Coerce_to_v_register(Operand *op, TypeStruct *tstruct, short output_reg) { } void store(short reg, Operand *op, Type *type) { - short opcode; + Opcode opcode; coerce_to_addressable(op); switch (op->optype) { @@ -732,15 +734,15 @@ void store_pair(short reg, short regHi, Operand *op, Type *type) { } } -void store_fp(short reg, Operand *op, Type *tint) { +void store_fp(short reg, Operand *op, Type *type) { coerce_to_addressable(op); switch (op->optype) { case OpndType_IndirectGPR_ImmOffset: - load_store_register((tint->size == 4) ? PC_STFS : PC_STFD, reg, op->reg, op->object, op->immOffset); + load_store_register((type->size == 4) ? PC_STFS : PC_STFD, reg, op->reg, op->object, op->immOffset); setpcodeflags(op->flags); break; case OpndType_IndirectGPR_Indexed: - emitpcode((tint->size == 4) ? PC_STFSX : PC_STFDX, reg, op->reg, op->regOffset); + emitpcode((type->size == 4) ? PC_STFSX : PC_STFDX, reg, op->reg, op->regOffset); setpcodeflags(op->flags); break; default: @@ -855,26 +857,56 @@ void extend64(Operand *op, Type *type, short output_reg, short output_regHi) { op->regHi = regHi; } -void load_floating_constant(short reg, Type *type, double *data) { - // do me AFTER +void load_floating_constant(short reg, Type *type, Float *data) { + Object *object; + Object *indObject; + Operand op1; + Operand op2; + Operand op3; + SInt32 offset = 0; + + memclrw(&op1, sizeof(Operand)); + + object = CreateFloatConst(type, data, &offset); + indObject = createIndirect(object, 0, 1); + + if (indObject) { + symbol_operand(&op1, indObject); + indirect(&op1, NULL); + } else { + symbol_operand(&op1, object); + } + + if (offset) { + op2 = op1; + memclrw(&op3, sizeof(Operand)); + op3.optype = OpndType_Absolute; + op3.immediate = offset; + if (op2.optype != OpndType_GPR) + Coerce_to_register(&op2, TYPE(&void_ptr), 0); + combine(&op2, &op3, 0, &op1); + } + + indirect(&op1, NULL); + if (op1.optype != OpndType_FPR) + Coerce_to_fp_register(&op1, type, reg); } void convert_integer_to_floating(Operand *op, Boolean is_single, short output_reg) { - // issue with matching the PC_FSUB/PC_FSUBS ternary Operand temp_op; - double d; + Float d; int const_reg; int tmp_reg; int work_reg; int result_reg; - short opcode; + Opcode opcode; - symbol_operand(&temp_op, maketemporary((Type *) &stdouble)); + symbol_operand(&temp_op, maketemporary(TYPE(&stdouble))); coerce_to_addressable(&temp_op); - d = *((double *) &int_to_float_cc); + d.value = *((double *) &int_to_float_cc); const_reg = used_virtual_registers[RegClass_FPR]++; - load_floating_constant(const_reg, &stdouble, &d); + load_floating_constant(const_reg, TYPE(&stdouble), &d); tmp_reg = used_virtual_registers[RegClass_GPR]++; emitpcode(PC_XORIS, tmp_reg, op->reg, 0x8000); @@ -886,10 +918,6 @@ void convert_integer_to_floating(Operand *op, Boolean is_single, short output_re load_store_register(PC_LFD, work_reg = used_virtual_registers[RegClass_FPR]++, temp_op.reg, temp_op.object, 0); result_reg = output_reg ? output_reg : used_virtual_registers[RegClass_FPR]++; - //opcode = PC_FSUB; - //if (is_single) - // opcode = PC_FSUBS; - //opcode = (is_single != 0) ? PC_FSUBS : PC_FSUB; if (is_single != 0) opcode = PC_FSUBS; else @@ -901,21 +929,20 @@ void convert_integer_to_floating(Operand *op, Boolean is_single, short output_re } void convert_unsigned_to_floating(Operand *op, Boolean is_single, short output_reg) { - // issue with matching the PC_FSUB/PC_FSUBS ternary Operand temp_op; - double d; + Float d; int const_reg; int tmp_reg; int work_reg; int result_reg; - short opcode; + Opcode opcode; - symbol_operand(&temp_op, maketemporary((Type *) &stdouble)); + symbol_operand(&temp_op, maketemporary(TYPE(&stdouble))); coerce_to_addressable(&temp_op); - d = *((double *) &uns_to_float_cc); + d.value = *((double *) &uns_to_float_cc); const_reg = used_virtual_registers[RegClass_FPR]++; - load_floating_constant(const_reg, &stdouble, &d); + load_floating_constant(const_reg, TYPE(&stdouble), &d); load_store_register(PC_STW, op->reg, temp_op.reg, temp_op.object, low_offset); @@ -925,10 +952,6 @@ void convert_unsigned_to_floating(Operand *op, Boolean is_single, short output_r load_store_register(PC_LFD, work_reg = used_virtual_registers[RegClass_FPR]++, temp_op.reg, temp_op.object, 0); result_reg = output_reg ? output_reg : used_virtual_registers[RegClass_FPR]++; - //opcode = PC_FSUB; - //if (is_single) - // opcode = PC_FSUBS; - //opcode = (is_single != 0) ? PC_FSUBS : PC_FSUB; if (is_single != 0) opcode = PC_FSUBS; else @@ -944,7 +967,7 @@ void convert_floating_to_integer(Operand *op, short output_reg) { int tmp_reg; int result_reg; - symbol_operand(&temp_op, maketemporary((Type *) &stdouble)); + symbol_operand(&temp_op, maketemporary(TYPE(&stdouble))); coerce_to_addressable(&temp_op); tmp_reg = used_virtual_registers[RegClass_FPR]++; @@ -1004,11 +1027,10 @@ void load_address(short dest_reg, Operand *op) { coerce_to_addressable(op); if (op->optype == OpndType_IndirectGPR_ImmOffset) { if (!op->immOffset && !op->object) { - if (op->reg != dest_reg) { + if (op->reg != dest_reg) emitpcode(PC_MR, dest_reg, op->reg); - } } else { - add_immediate(dest_reg, op->reg, op->object, op->immOffset); + add_immediate(dest_reg, op->reg, op->object, (SInt16) op->immOffset); } } else if (op->optype == OpndType_IndirectGPR_Indexed) { emitpcode(PC_ADD, dest_reg, op->reg, op->regOffset); diff --git a/compiler_and_linker/unsorted/PCode.c b/compiler_and_linker/unsorted/PCode.c index c35cac4..ee5b8e0 100644 --- a/compiler_and_linker/unsorted/PCode.c +++ b/compiler_and_linker/unsorted/PCode.c @@ -51,7 +51,7 @@ PCode *copypcode(PCode *pcode) { int i; extra_arg = 0; - if ((PCODE_FLAG_SET_F(pcode) & fPCodeFlag8000000) && !(PCODE_FLAG_SET_F(pcode) & fPCodeFlag20000000)) + if ((PCODE_FLAG_SET_F(pcode) & fCanSetRecordBit) && !(PCODE_FLAG_SET_F(pcode) & fRecordBit)) extra_arg = 1; newpc = lalloc(sizeof(PCode) + sizeof(PCodeArg) * (pcode->argCount + extra_arg)); @@ -148,7 +148,7 @@ void deleteblock(PCodeBlock *block) { block->prevBlock->nextBlock = block->nextBlock; if (block->nextBlock) block->nextBlock->prevBlock = block->prevBlock; - block->flags |= fPCBlockFlag20; + block->flags |= fDeleted; } void deleteunreachableblocks(void) { @@ -157,7 +157,7 @@ void deleteunreachableblocks(void) { computedepthfirstordering(); for (block = pcbasicblocks->nextBlock; block; block = block->nextBlock) { - if (!(block->flags & fPCBlockFlag4)) + if (!(block->flags & fVisited)) deleteblock(block); } } @@ -193,7 +193,7 @@ void deletepcode(PCode *pcode) { pcode->block = 0; block->pcodeCount--; - block->flags &= ~fPCBlockFlag8; + block->flags &= ~fScheduled; } void insertpcodebefore(PCode *anchor, PCode *newpcode) { @@ -211,7 +211,7 @@ void insertpcodebefore(PCode *anchor, PCode *newpcode) { newpcode->block = block; block->pcodeCount++; - block->flags &= ~fPCBlockFlag8; + block->flags &= ~fScheduled; } void insertpcodeafter(PCode *anchor, PCode *newpcode) { @@ -229,13 +229,13 @@ void insertpcodeafter(PCode *anchor, PCode *newpcode) { newpcode->block = block; block->pcodeCount++; - block->flags &= ~fPCBlockFlag8; + block->flags &= ~fScheduled; } void setpcodeflags(int flags) { pclastblock->lastPCode->flags |= flags; if (flags & fSideEffects) - pclastblock->lastPCode->flags &= ~(fIsCSE | fCommutative | fPCodeFlag10); + pclastblock->lastPCode->flags &= ~(fIsCSE | fCommutative | fIsMove); } void clearpcodeflags(int flags) { @@ -273,11 +273,11 @@ void computedepthfirstordering(void) { depthfirstorder = pcblockcount; for (block = pcbasicblocks; block; block = block->nextBlock) { - block->flags &= ~fPCBlockFlag4; + block->flags &= ~fVisited; } dfo = (DFO *) oalloc(sizeof(DFO) * pcblockcount); - pcbasicblocks->flags |= fPCBlockFlag4; + pcbasicblocks->flags |= fVisited; dfo->block = pcbasicblocks; dfo->link = pcbasicblocks->successors; @@ -286,8 +286,8 @@ void computedepthfirstordering(void) { if ((link = dfo[index - 1].link)) { dfo[index - 1].link = link->nextLink; block = link->block; - if (!(block->flags & fPCBlockFlag4)) { - block->flags |= fPCBlockFlag4; + if (!(block->flags & fVisited)) { + block->flags |= fVisited; dfo[index].block = block; dfo[index].link = block->successors; index++; diff --git a/compiler_and_linker/unsorted/PCodeAssembly.c b/compiler_and_linker/unsorted/PCodeAssembly.c index 922e9cf..2c87ce3 100644 --- a/compiler_and_linker/unsorted/PCodeAssembly.c +++ b/compiler_and_linker/unsorted/PCodeAssembly.c @@ -361,7 +361,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[0].data.reg.reg << 21; bits |= instr->args[1].data.reg.reg << 16; bits |= instr->args[2].data.reg.reg << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -403,7 +403,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[1].data.reg.reg << 16; if (PCODE_FLAG_SET_F(instr) & fOverflow) bits |= 0x400; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -459,7 +459,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[0].data.reg.reg << 16; bits |= instr->args[1].data.reg.reg << 21; bits |= instr->args[2].data.reg.reg << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -468,7 +468,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { case PC_CNTLZW: bits |= instr->args[0].data.reg.reg << 16; bits |= instr->args[1].data.reg.reg << 21; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -476,7 +476,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[0].data.reg.reg << 16; bits |= instr->args[1].data.reg.reg << 21; bits |= instr->args[1].data.reg.reg << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -484,7 +484,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[0].data.reg.reg << 16; bits |= instr->args[1].data.reg.reg << 21; bits |= instr->args[1].data.reg.reg << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -492,7 +492,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[0].data.reg.reg << 16; bits |= instr->args[1].data.reg.reg << 21; bits |= (instr->args[2].data.imm.value & 31) << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -503,7 +503,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= (instr->args[2].data.imm.value & 31) << 11; bits |= (instr->args[3].data.imm.value & 31) << 6; bits |= (instr->args[4].data.imm.value & 31) << 1; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -513,7 +513,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[2].data.reg.reg << 11; bits |= (instr->args[3].data.imm.value & 31) << 6; bits |= (instr->args[4].data.imm.value & 31) << 1; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -545,7 +545,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { case PC_MFFS: bits |= instr->args[0].data.reg.reg << 21; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -557,7 +557,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { case PC_MTFSF: bits |= (instr->args[0].data.imm.value & 0xFF) << 17; bits |= instr->args[1].data.reg.reg << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -572,7 +572,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { case PC_FCTIWZ: bits |= instr->args[0].data.reg.reg << 21; bits |= instr->args[1].data.reg.reg << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -585,7 +585,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[0].data.reg.reg << 21; bits |= instr->args[1].data.reg.reg << 16; bits |= instr->args[2].data.reg.reg << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -604,7 +604,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[0].data.reg.reg << 21; bits |= instr->args[1].data.reg.reg << 16; bits |= instr->args[2].data.reg.reg << 6; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -714,14 +714,14 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { case PC_MTFSB0: case PC_MTFSB1: bits |= (instr->args[0].data.imm.value & 31) << 21; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; case PC_MTFSFI: bits |= instr->args[0].data.reg.reg << 23; bits |= (instr->args[1].data.imm.value & 15) << 12; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -729,7 +729,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { case PC_FSQRTS: bits |= instr->args[0].data.reg.reg << 21; bits |= instr->args[1].data.reg.reg << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -761,7 +761,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[1].data.reg.reg << 21; bits |= instr->args[0].data.reg.reg << 16; bits |= instr->args[2].data.reg.reg << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -769,7 +769,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[0].data.reg.reg << 21; bits |= instr->args[1].data.reg.reg << 16; bits |= instr->args[2].data.reg.reg << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -782,7 +782,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[2].data.reg.reg << 11; if (PCODE_FLAG_SET_F(instr) & fOverflow) bits |= 0x400; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -792,14 +792,14 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[1].data.reg.reg << 16; if (PCODE_FLAG_SET_F(instr) & fOverflow) bits |= 0x400; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; case PC_CLCS: bits |= instr->args[0].data.reg.reg << 21; bits |= instr->args[1].data.reg.reg << 16; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -815,7 +815,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[2].data.reg.reg << 11; bits |= (instr->args[3].data.imm.value & 31) << 6; bits |= (instr->args[4].data.imm.value & 31) << 1; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -833,7 +833,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[1].data.reg.reg << 21; bits |= instr->args[0].data.reg.reg << 16; bits |= instr->args[2].data.reg.reg << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -845,7 +845,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[1].data.reg.reg << 21; bits |= instr->args[0].data.reg.reg << 16; bits |= (instr->args[2].data.imm.value & 31) << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 1; break; @@ -1048,7 +1048,7 @@ UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop) { bits |= instr->args[0].data.reg.reg << 21; bits |= instr->args[1].data.reg.reg << 16; bits |= instr->args[2].data.reg.reg << 11; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) bits |= 0x400; break; @@ -1172,13 +1172,13 @@ static void insertlongbranches(SInt32 mask) { block->codeOffset = i; if (block->pcodeCount) { i += block->pcodeCount * 4; - if (block->pcodeCount && (block->lastPCode->flags & fPCodeFlag1)) + if (block->pcodeCount && (block->lastPCode->flags & fIsBranch)) i += 4; } } for (block = pcbasicblocks; block; block = block->nextBlock) { - if (block->pcodeCount && (block->lastPCode->flags & fPCodeFlag1)) { + if (block->pcodeCount && (block->lastPCode->flags & fIsBranch)) { switch (block->lastPCode->op) { case PC_BT: case PC_BF: @@ -1313,7 +1313,7 @@ SInt32 optimizefinalbranches(SInt32 codesize) { continue; instr = block->lastPCode; - if (!(instr->flags & fPCodeFlag1)) + if (!(instr->flags & fIsBranch)) continue; offset = block->codeOffset + (block->pcodeCount - 1) * 4; diff --git a/compiler_and_linker/unsorted/PCodeInfo.c b/compiler_and_linker/unsorted/PCodeInfo.c index c93176c..b11288b 100644 --- a/compiler_and_linker/unsorted/PCodeInfo.c +++ b/compiler_and_linker/unsorted/PCodeInfo.c @@ -126,10 +126,10 @@ PCode *vformatpcode(short opcode, va_list argList) { int tmp; int tmp2; // r19 int i; - int thing; - int thing2; - int thing3; - int thing4; + SInt32 thing; + SInt32 thing2; + SInt32 thing3; + SInt32 thing4; Object *obj; PCodeLabel *label; char c; @@ -146,7 +146,7 @@ PCode *vformatpcode(short opcode, va_list argList) { format++; } - if (info->flags & fPCodeFlag8000000) + if (info->flags & fCanSetRecordBit) unkreg_r22 = 1; if ((argcount + unkreg_r22) < 5) @@ -474,7 +474,7 @@ PCode *vformatpcode(short opcode, va_list argList) { arg->data.mem.obj = obj; arg->data.mem.offset = va_arg(argList, SInt32); - if (pcode->flags & (fPCodeFlag2 | fPCodeFlag4 | fPCodeFlag20000 | fPCodeFlag40000)) { + if (pcode->flags & (fIsRead | fIsWrite | fPCodeFlag20000 | fPCodeFlag40000)) { pcode->alias = make_alias(obj, arg->data.mem.offset, nbytes_loaded_or_stored_by(pcode)); if (is_volatile_object(obj)) pcode->flags |= fIsVolatile; @@ -486,7 +486,7 @@ PCode *vformatpcode(short opcode, va_list argList) { pcode->alias = make_alias(obj, arg->data.mem.offset, 1); } CError_ASSERT(536, obj->datatype == DLOCAL || arg->data.mem.offset == 0); - if (pcode->flags & (fPCodeFlag2 | fPCodeFlag4)) { + if (pcode->flags & (fIsRead | fIsWrite)) { //if ((obj->type->type == TYPEPOINTER || obj->type->type == TYPEARRAY) ? (TYPE_POINTER(obj->type)->qual & Q_VOLATILE) : (obj->qual & Q_VOLATILE)) if (OBJ_GET_TARGET_VOLATILE(obj)) pcode->flags |= fIsVolatile; @@ -495,7 +495,7 @@ PCode *vformatpcode(short opcode, va_list argList) { pcode->flags |= fIsConst; } - if (pcode->flags & (fPCodeFlag1 | fPCodeFlag8)) { + if (pcode->flags & (fIsBranch | fIsCall)) { arg->arg = RefType_4; } else if (obj->datatype == DLOCAL) { if (!local_is_16bit_offset(obj)) @@ -510,8 +510,8 @@ PCode *vformatpcode(short opcode, va_list argList) { arg->kind = PCOp_IMMEDIATE; arg->data.imm.value = va_arg(argList, SInt32); arg->data.imm.obj = NULL; - if (pcode->flags & (fPCodeFlag2 | fPCodeFlag4)) - pcode->flags |= fPCodeFlag20; + if (pcode->flags & (fIsRead | fIsWrite)) + pcode->flags |= fIsPtrOp; } break; @@ -530,7 +530,7 @@ PCode *vformatpcode(short opcode, va_list argList) { arg->data.mem.offset = va_arg(argList, SInt32); CError_ASSERT(590, obj->datatype == DLOCAL || arg->data.mem.offset == 0); - if (pcode->flags & (fPCodeFlag2 | fPCodeFlag4)) { + if (pcode->flags & (fIsRead | fIsWrite)) { //if ((obj->type->type == TYPEPOINTER || obj->type->type == TYPEARRAY) ? (TYPE_POINTER(obj->type)->qual & Q_VOLATILE) : (obj->qual & Q_VOLATILE)) if (OBJ_GET_TARGET_VOLATILE(obj)) pcode->flags |= fIsVolatile; @@ -549,8 +549,8 @@ PCode *vformatpcode(short opcode, va_list argList) { arg->kind = PCOp_IMMEDIATE; arg->data.imm.value = va_arg(argList, SInt32); arg->data.imm.obj = NULL; - if (pcode->flags & (fPCodeFlag2 | fPCodeFlag4)) - pcode->flags |= fPCodeFlag20; + if (pcode->flags & (fIsRead | fIsWrite)) + pcode->flags |= fIsPtrOp; } break; @@ -800,9 +800,9 @@ void formatoperands(PCode *pcode, char *buf, int showBasicBlocks) { int i; int tmp; int tmp2; - int thing; - int thing2; - int thing4; + SInt32 thing; + SInt32 thing2; + SInt32 thing4; char c; int flagSetT; int flagSetF; @@ -1048,7 +1048,7 @@ void formatoperands(PCode *pcode, char *buf, int showBasicBlocks) { buf += expectandformatoperand(pa, PCOp_MEMORY, 0, -1, buf); else if (pa->kind == PCOp_LABELDIFF) buf += expectandformatoperand(pa, PCOp_LABELDIFF, 0, -1, buf); - else if ((pcode->flags & (fPCodeFlag1 | fPCodeFlag8)) && (pa->kind == PCOp_LABEL)) + else if ((pcode->flags & (fIsBranch | fIsCall)) && (pa->kind == PCOp_LABEL)) buf += expectandformatoperand(pa, PCOp_LABEL, 0, -1, buf); else buf += expectandformatoperand(pa, PCOp_IMMEDIATE, 0, -1, buf); @@ -1122,6 +1122,7 @@ void formatoperands(PCode *pcode, char *buf, int showBasicBlocks) { if (pcode->flags & fCommutative) buf += sprintf(buf, "; fCommutative"); + // i think these are the wrong way round lol if (flagSetT & fIsPtrOp) buf += sprintf(buf, "; fIsPtrOp"); @@ -1158,7 +1159,7 @@ int can_reuse_stored_value(PCode *a, PCode *b) { int nbytes_loaded_or_stored_by(PCode *pcode) { OpcodeInfo *oinfo = opcodeinfo + pcode->op; - if (oinfo->flags & (fPCodeFlag2 | fPCodeFlag4)) { + if (oinfo->flags & (fIsRead | fIsWrite)) { switch (pcode->op) { case PC_LBZ: case PC_LBZU: @@ -1265,7 +1266,7 @@ void change_num_operands(PCode *pcode, int newNum) { void change_opcode(PCode *pcode, short opcode) { pcode->flags = (pcode->flags & ~(opcodeinfo[pcode->op].flags & ~fIsPtrOp)) | opcodeinfo[opcode].flags; - if ((pcode->flags & fPCodeFlag10) && (PCODE_FLAG_SET_F(pcode) & fPCodeFlag20000000)) - pcode->flags &= ~fPCodeFlag10; + if ((pcode->flags & fIsMove) && (PCODE_FLAG_SET_F(pcode) & fRecordBit)) + pcode->flags &= ~fIsMove; pcode->op = opcode; } diff --git a/compiler_and_linker/unsorted/PCodeListing.c b/compiler_and_linker/unsorted/PCodeListing.c index c95400d..ffaec79 100644 --- a/compiler_and_linker/unsorted/PCodeListing.c +++ b/compiler_and_linker/unsorted/PCodeListing.c @@ -55,7 +55,7 @@ static void pclistblock(PCodeBlock *block, char *format, UInt32 vecSize) { UInt32 opcode; MachineInfo *mi; char buf[500]; - PCodeArg dummyArg; + WeirdOperand dummyArg; fprintf(pcfile, ":{%4.4x}::::::::::::::::::::::::::::::::::::::::LOOPWEIGHT=%ld\n", block->flags, block->loopWeight); fprintf(pcfile, "B%ld: ", block->blockIndex); @@ -107,7 +107,7 @@ static void pclistblock(PCodeBlock *block, char *format, UInt32 vecSize) { for (offset = block->codeOffset, instr = block->firstPCode; instr; instr = instr->nextPCode, offset += 4) { latency = mi->latency(instr); formatoperands(instr, buf, 1); - chr = (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) ? '.' : ' '; + chr = (PCODE_FLAG_SET_F(instr) & fRecordBit) ? '.' : ' '; if (coloring) opcode = 0; else @@ -145,7 +145,7 @@ static void pclistonoff(int flag) { fprintf(pcfile, "Off\n"); } -void pcinitlisting(void) { +void pcinitlisting() { // unknown args, etc } @@ -155,58 +155,58 @@ void pccleanuplisting(void) { void pclistblocks(char *name1, char *name2) { } -void pclistdataflow(void) { +void pclistdataflow() { // unknown args } void pclistinterferences(char *class_format, int regcount) { } -void pclistspill(void) { +void pclistspill() { // unknown args } -void pclistcopypropitem(void) { +void pclistcopypropitem() { // unknown args } -void pclistcoalesce(void) { +void pclistcoalesce() { // unknown args } -void pclistusedefs(void) { +void pclistusedefs() { // unknown args } -void pclistpropinfo(void) { +void pclistpropinfo() { // unknown args } -static void listloop(void) { +static void listloop() { // unknown args } -static void listloops(void) { +static void listloops() { // unknown args } -void pclistloops(void) { +void pclistloops() { // unknown args } -static void listswitchtables(void) { +static void listswitchtables() { // unknown args } -void pclistswitchtables(void) { +void pclistswitchtables() { // unknown args } -void pclistdominators(void) { +void pclistdominators() { // unknown args } -void pclistbackedge(void) { +void pclistbackedge() { // unknown args } @@ -264,15 +264,15 @@ static char *GetInterferenceFlags(IGNode *node) { return buf; } -void pclistinterferencegraphnode(void) { +void pclistinterferencegraphnode() { // unknown args } -void pclistinterferencegraph(void) { +void pclistinterferencegraph() { // unknown args } -void pclistblock_scheduler(void) { +void pclistblock_scheduler() { // unknown args } @@ -284,15 +284,15 @@ void pclistblocks_end_scheduler(void) { CError_FATAL(1318); } -static void printheapsize(void) { +static void printheapsize() { // unknown args } -void pctotalheap(void) { +void pctotalheap() { // unknown args } -void pctotalmemory(void) { +void pctotalmemory() { // unknown args } @@ -468,7 +468,7 @@ int dumpalias(Alias *alias, int len, Boolean flag1, Boolean flag2) { } } -void pcformatset(void) { +void pcformatset() { // unknown args } @@ -506,11 +506,11 @@ int GetLineOffset(char *str, int lineNum, int len) { return 0; } -void DumpSourceCode(void) { +void DumpSourceCode() { // unknown args } -int DumpIR_SrcBreak(void) { +int DumpIR_SrcBreak() { // unknown args return 0; } diff --git a/compiler_and_linker/unsorted/PCodeUtilities.c b/compiler_and_linker/unsorted/PCodeUtilities.c index 89c4c1f..b1f8ffb 100644 --- a/compiler_and_linker/unsorted/PCodeUtilities.c +++ b/compiler_and_linker/unsorted/PCodeUtilities.c @@ -1,6 +1,9 @@ #include "compiler/PCodeUtilities.h" #include "compiler/CError.h" +#include "compiler/CFunc.h" #include "compiler/CParser.h" +#include "compiler/CodeGen.h" +#include "compiler/Exceptions.h" #include "compiler/PCode.h" #include "compiler/PCodeInfo.h" #include "compiler/Registers.h" @@ -13,20 +16,20 @@ void pcsetrecordbit(PCode *pc) { short argCount; int argIdx; - pc->flags &= ~(fPCodeFlag10 | fCommutative | fIsCSE); - if ((pc->flags & (fPCodeFlag80000000 | fPCodeFlag40000000)) == fPCodeFlag40000000) { + pc->flags &= ~(fIsMove | fCommutative | fIsCSE); + if ((pc->flags & fOpTypeMask) == fOpTypeFPR) { reg = 1; - } else if ((pc->flags & (fPCodeFlag80000000 | fPCodeFlag40000000)) == (fPCodeFlag80000000 | fPCodeFlag40000000)) { + } else if ((pc->flags & fOpTypeMask) == fOpTypeVR) { reg = 6; } else { reg = 0; } if (pc->op == PC_ANDI || pc->op == PC_ANDIS) { - pc->flags |= fPCodeFlag20000000; + pc->flags |= fRecordBit; } else if (pc->op == PC_ADDI || pc->op == PC_ADDIC) { - pc->flags |= fPCodeFlag10000000; - pc->flags |= fPCodeFlag20000000; + pc->flags |= fSetsCarry; + pc->flags |= fRecordBit; change_num_operands(pc, 5); pc->op = PC_ADDICR; @@ -46,7 +49,7 @@ void pcsetrecordbit(PCode *pc) { while (arg->kind != PCOp_PLACEHOLDEROPERAND && argIdx) { if (arg->kind == PCOp_REGISTER && arg->arg == RegClass_CRFIELD && arg->data.reg.reg == reg) { arg->data.reg.effect |= EffectWrite; - pc->flags |= fPCodeFlag20000000; + pc->flags |= fRecordBit; return; } arg++; @@ -64,12 +67,12 @@ void pcsetrecordbit(PCode *pc) { arg->data.reg.reg = reg; arg->data.reg.effect = EffectWrite; if (pc->op != PC_ADDICR) - pc->flags |= fPCodeFlag20000000; + pc->flags |= fRecordBit; } } void pcsetsideeffects(PCode *pc) { - pc->flags &= ~(fPCodeFlag10 | fCommutative | fIsCSE); + pc->flags &= ~(fIsMove | fCommutative | fIsCSE); pc->flags |= fSideEffects; } @@ -107,9 +110,9 @@ void pcsetlinkbit(PCode *pc) { arg->data.reg.reg = 1; arg->data.reg.effect = EffectWrite; - if (opcodeinfo[pc->op].flags & fPCodeFlag8) { - pc->flags &= ~fPCodeFlag1; - pc->flags |= fPCodeFlag8; + if (opcodeinfo[pc->op].flags & fIsCall) { + pc->flags &= ~fIsBranch; + pc->flags |= fIsCall; } pc->flags |= fLink; } diff --git a/compiler_and_linker/unsorted/Peephole.c b/compiler_and_linker/unsorted/Peephole.c index 3779d39..0480c80 100644 --- a/compiler_and_linker/unsorted/Peephole.c +++ b/compiler_and_linker/unsorted/Peephole.c @@ -188,9 +188,9 @@ static int dead(PCode *instr, UInt32 *masks) { int i; PCodeArg *op; - if (instr->block->flags & (fPCBlockFlag1 | fPCBlockFlag2)) + if (instr->block->flags & (fIsProlog | fIsEpilogue)) return 0; - if (instr->flags & (fPCodeFlag1 | fPCodeFlag4 | fPCodeFlag8 | fIsVolatile | fSideEffects)) + if (instr->flags & (fIsBranch | fIsWrite | fIsCall | fIsVolatile | fSideEffects)) return 0; if (!instr->block->predecessors) return 1; @@ -354,10 +354,10 @@ static int canuseupdatetest(PCodeBlock *block, PCode *instr, int count1, int cou return 1; } - if (instr->flags & (fPCodeFlag2 | fPCodeFlag4)) { + if (instr->flags & (fIsRead | fIsWrite)) { if (++count4 > 1) return 1; - } else if (instr->flags & fPCodeFlag1) { + } else if (instr->flags & fIsBranch) { if (++count2 > 2) return 1; @@ -389,7 +389,7 @@ static int canuseupdate(PCode *instr) { static int MR_Rx_Rx(PCode *instr, UInt32 *masks) { if ( instr->args[0].data.reg.reg == instr->args[1].data.reg.reg && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + !(PCODE_FLAG_SET_F(instr) & fRecordBit) ) { deletepcode(instr); @@ -402,7 +402,7 @@ static int MR_Rx_Rx(PCode *instr, UInt32 *masks) { static int FMR_Fx_Fx(PCode *instr, UInt32 *masks) { if ( instr->args[0].data.reg.reg == instr->args[1].data.reg.reg && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + !(PCODE_FLAG_SET_F(instr) & fRecordBit) ) { deletepcode(instr); @@ -415,7 +415,7 @@ static int FMR_Fx_Fx(PCode *instr, UInt32 *masks) { static int VMR_Vx_Vx(PCode *instr, UInt32 *masks) { if ( instr->args[0].data.reg.reg == instr->args[1].data.reg.reg && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + !(PCODE_FLAG_SET_F(instr) & fRecordBit) ) { deletepcode(instr); @@ -432,7 +432,7 @@ static int MR_MR(PCode *instr, UInt32 *masks) { defInstr->op == PC_MR && instr->args[0].data.reg.reg == defInstr->args[1].data.reg.reg && !definedbetween(instr, defInstr, &instr->args[0]) && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + !(PCODE_FLAG_SET_F(instr) & fRecordBit) ) { deletepcode(instr); @@ -448,7 +448,7 @@ static int FMR_FMR(PCode *instr, UInt32 *masks) { if ( defInstr->op == PC_FMR && instr->args[0].data.reg.reg == defInstr->args[1].data.reg.reg && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(instr) & fRecordBit) && !definedbetween(instr, defInstr, &instr->args[0]) ) { @@ -465,7 +465,7 @@ static int VMR_VMR(PCode *instr, UInt32 *masks) { if ( defInstr->op == PC_VMR && instr->args[0].data.reg.reg == defInstr->args[1].data.reg.reg && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(instr) & fRecordBit) && !definedbetween(instr, defInstr, &instr->args[0]) ) { @@ -485,11 +485,11 @@ static int VMR_VMRP(PCode *instr, UInt32 *masks) { int nextPermute = 0; if (prev) { - prevFlag = (prev->flags & fPCodeFlagC0000000) == fPCodeFlagC0000000; + prevFlag = (prev->flags & fOpTypeMask) == fOpTypeVR; prevPermute = uses_vpermute_unit(prev); } if (next) { - nextFlag = (next->flags & fPCodeFlagC0000000) == fPCodeFlagC0000000; + nextFlag = (next->flags & fOpTypeMask) == fOpTypeVR; nextPermute = uses_vpermute_unit(next); } @@ -529,7 +529,7 @@ static int MR_CMPI(PCode *instr, UInt32 *masks) { if ( instr->args[0].data.reg.reg == 0 && instr->args[2].data.imm.value == 0 && - (PCODE_FLAG_SET_F(defInstr) & (fSideEffects | fPCodeFlag8000000 | fPCodeFlag80000000)) == (fPCodeFlag8000000 | fPCodeFlag80000000) && + (PCODE_FLAG_SET_F(defInstr) & (fSideEffects | fCanSetRecordBit | fOpTypeGPR)) == (fCanSetRecordBit | fOpTypeGPR) && !usedbetween(instr, defInstr, &instr->args[0]) && !definedbetween(instr, defInstr, &instr->args[0]) ) @@ -557,7 +557,7 @@ static int EXTSB_RLWINM(PCode *instr, UInt32 *masks) { if ( defInstr->op == PC_EXTSB && (defInstr->args[0].data.reg.reg == instr->args[0].data.reg.reg || !(masks[RegClass_GPR] & (1 << defInstr->args[0].data.reg.reg))) && - !(PCODE_FLAG_SET_F(defInstr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(defInstr) & fRecordBit) && !definedbetween(instr, defInstr, &defInstr->args[1]) && !usedbetween(instr, defInstr, &defInstr->args[0]) && (extractedbits(instr) & 0xFFFFFF00) == 0 @@ -578,7 +578,7 @@ static int EXTSH_RLWINM(PCode *instr, UInt32 *masks) { if ( defInstr->op == PC_EXTSH && (defInstr->args[0].data.reg.reg == instr->args[0].data.reg.reg || !(masks[RegClass_GPR] & (1 << defInstr->args[0].data.reg.reg))) && - !(PCODE_FLAG_SET_F(defInstr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(defInstr) & fRecordBit) && !definedbetween(instr, defInstr, &defInstr->args[1]) && !usedbetween(instr, defInstr, &defInstr->args[0]) && (extractedbits(instr) & 0xFFFF0000) == 0 @@ -601,7 +601,7 @@ static int LBZ_RLWINM(PCode *instr, UInt32 *masks) { instr->args[2].data.imm.value == 0 && instr->args[3].data.imm.value <= 24 && instr->args[4].data.imm.value == 31 && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(instr) & fRecordBit) && (defInstr->args[0].data.reg.reg == instr->args[0].data.reg.reg || !(masks[RegClass_GPR] & (1 << defInstr->args[0].data.reg.reg))) && !usedbetween(instr, defInstr, &defInstr->args[0]) && !definedbetween(instr, defInstr, &instr->args[0]) && @@ -624,7 +624,7 @@ static int LHZ_RLWINM(PCode *instr, UInt32 *masks) { instr->args[2].data.imm.value == 0 && instr->args[3].data.imm.value <= 16 && instr->args[4].data.imm.value == 31 && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(instr) & fRecordBit) && (defInstr->args[0].data.reg.reg == instr->args[0].data.reg.reg || !(masks[RegClass_GPR] & (1 << defInstr->args[0].data.reg.reg))) && !usedbetween(instr, defInstr, &defInstr->args[0]) && !definedbetween(instr, defInstr, &instr->args[0]) && @@ -644,7 +644,7 @@ static int LHA_EXTSH(PCode *instr, UInt32 *masks) { if ( defInstr->op == PC_LHA && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(instr) & fRecordBit) && (defInstr->args[0].data.reg.reg == instr->args[0].data.reg.reg || !(masks[RegClass_GPR] & (1 << defInstr->args[0].data.reg.reg))) && !usedbetween(instr, defInstr, &defInstr->args[0]) && !definedbetween(instr, defInstr, &instr->args[0]) && @@ -658,7 +658,7 @@ static int LHA_EXTSH(PCode *instr, UInt32 *masks) { if ( defInstr->op == PC_EXTSB && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + !(PCODE_FLAG_SET_F(instr) & fRecordBit) ) { if (defInstr->args[0].data.reg.reg == defInstr->args[1].data.reg.reg) { @@ -739,7 +739,7 @@ static int ADDI_L_S(PCode *instr, UInt32 *masks) { if (defInstr->args[2].kind == PCOp_MEMORY) { instr->args[2] = defInstr->args[2]; instr->args[2].data.mem.offset += addright; - if (instr->flags & (fPCodeFlag2 | fPCodeFlag4 | fPCodeFlag20000 | fPCodeFlag40000)) { + if (instr->flags & (fIsRead | fIsWrite | fPCodeFlag20000 | fPCodeFlag40000)) { instr->alias = make_alias( instr->args[2].data.mem.obj, instr->args[2].data.mem.offset, @@ -768,7 +768,7 @@ static int ADDI_L_S(PCode *instr, UInt32 *masks) { if (defInstr->args[2].kind == PCOp_MEMORY) { instr->args[2] = defInstr->args[2]; instr->args[2].data.mem.offset += addright; - if (instr->flags & (fPCodeFlag2 | fPCodeFlag4 | fPCodeFlag20000 | fPCodeFlag40000)) { + if (instr->flags & (fIsRead | fIsWrite | fPCodeFlag20000 | fPCodeFlag40000)) { instr->alias = make_alias( instr->args[2].data.mem.obj, instr->args[2].data.mem.offset, @@ -930,7 +930,7 @@ static int RLWINM_CMPLI_BC(PCode *instr, UInt32 *masks) { if (defInstr->op == PC_CMPLI && defInstr->args[0].data.reg.reg == 0 && defInstr->args[2].data.imm.value == 0) { defInstr2 = defininginstruction[defInstr->defID + 1]; if ( - (PCODE_FLAG_SET_F(defInstr2) & (fSideEffects | fPCodeFlag8000000 | fPCodeFlag80000000)) == (fPCodeFlag8000000 | fPCodeFlag80000000) && + (PCODE_FLAG_SET_F(defInstr2) & (fSideEffects | fCanSetRecordBit | fOpTypeGPR)) == (fCanSetRecordBit | fOpTypeGPR) && !usedbetween(defInstr, defInstr2, &defInstr->args[0]) && !definedbetween(defInstr, defInstr2, &defInstr->args[0]) ) @@ -961,7 +961,7 @@ static int LBZ_EXTSB_CMPI_BC(PCode *instr, UInt32 *masks) { || ( (defInstr->op == PC_EXTSB || defInstr->op == PC_EXTSH) && - (PCODE_FLAG_SET_F(defInstr) & fPCodeFlag20000000) + (PCODE_FLAG_SET_F(defInstr) & fRecordBit) ) ) { @@ -992,7 +992,7 @@ static int FRSP_STFS(PCode *instr, UInt32 *masks) { if ( defInstr->op == PC_FRSP && !(masks[RegClass_FPR] & (1 << defInstr->args[0].data.reg.reg)) && - !(PCODE_FLAG_SET_F(defInstr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(defInstr) & fRecordBit) && !definedbetween(instr, defInstr, &defInstr->args[1]) && !usedbetween(instr, defInstr, &defInstr->args[0]) ) @@ -1012,7 +1012,7 @@ static int NOT_AND(PCode *instr, UInt32 *masks) { if ( defInstr->op == PC_NOT && (defInstr->args[0].data.reg.reg == instr->args[0].data.reg.reg || !(masks[RegClass_GPR] & (1 << defInstr->args[0].data.reg.reg))) && - !(PCODE_FLAG_SET_F(defInstr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(defInstr) & fRecordBit) && !definedbetween(instr, defInstr, &defInstr->args[1]) && !usedbetween(instr, defInstr, &defInstr->args[0]) ) @@ -1033,7 +1033,7 @@ static int LI_MR(PCode *instr, UInt32 *masks) { if ( defInstr->op == PC_LI && (defInstr->args[0].data.reg.reg == instr->args[0].data.reg.reg || !(masks[RegClass_GPR] & (1 << defInstr->args[0].data.reg.reg))) && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(instr) & fRecordBit) && !usedbetween(instr, defInstr, &defInstr->args[0]) ) { @@ -1054,7 +1054,7 @@ static int VSPLTIS_VMR(PCode *instr, UInt32 *masks) { if ( (opcode == PC_VSPLTISB || opcode == PC_VSPLTISH || opcode == PC_VSPLTISW) && (defInstr->args[0].data.reg.reg == instr->args[0].data.reg.reg || !(masks[RegClass_VR] & (1 << defInstr->args[0].data.reg.reg))) && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(instr) & fRecordBit) && !usedbetween(instr, defInstr, &defInstr->args[0]) ) { @@ -1072,9 +1072,9 @@ static int L_MR(PCode *instr, UInt32 *masks) { PCode *defInstr = defininginstruction[instr->defID + 1]; if ( - (defInstr->flags & fPCodeFlag2) && + (defInstr->flags & fIsRead) && !(masks[RegClass_GPR] & (1 << defInstr->args[0].data.reg.reg)) && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(instr) & fRecordBit) && !usedbetween(instr, defInstr, &defInstr->args[0]) && !usedbetween(instr, defInstr, &instr->args[0]) && !definedbetween(instr, defInstr, &instr->args[0]) @@ -1092,9 +1092,9 @@ static int L_FMR(PCode *instr, UInt32 *masks) { PCode *defInstr = defininginstruction[instr->defID + 1]; if ( - (defInstr->flags & fPCodeFlag2) && + (defInstr->flags & fIsRead) && !(masks[RegClass_FPR] & (1 << defInstr->args[0].data.reg.reg)) && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(instr) & fRecordBit) && !usedbetween(instr, defInstr, &defInstr->args[0]) && !usedbetween(instr, defInstr, &instr->args[0]) && !definedbetween(instr, defInstr, &instr->args[0]) @@ -1119,13 +1119,13 @@ static int L_S(PCode *instr, UInt32 *masks) { SInt32 scanOffset; SInt32 storeSize; - if (PCODE_FLAG_SET_F(instr) & (fIsVolatile | fSideEffects | fPCodeFlag2000000)) + if (PCODE_FLAG_SET_F(instr) & (fIsVolatile | fSideEffects | fUpdatesPtr)) return 0; - if (PCODE_FLAG_SET_F(defInstr) & (fIsVolatile | fSideEffects | fPCodeFlag2000000)) + if (PCODE_FLAG_SET_F(defInstr) & (fIsVolatile | fSideEffects | fUpdatesPtr)) return 0; if ( - (defInstr->flags & fPCodeFlag2) && + (defInstr->flags & fIsRead) && PC_OP_IS_REGISTER(&defInstr->args[1], RegClass_GPR, instr->args[1].data.reg.reg) && defInstr->args[2].kind == instr->args[2].kind && !definedbetween(instr, defInstr, &instr->args[1]) @@ -1231,7 +1231,7 @@ static int L_S(PCode *instr, UInt32 *masks) { } for (scan = instr->prevPCode; scan && scan != defInstr; scan = scan->prevPCode) { - if (scan->flags & fPCodeFlag4) { + if (scan->flags & fIsWrite) { if (scan->args[1].data.reg.reg != instr->args[1].data.reg.reg) return 0; if (scan->args[2].kind != defInstr->args[2].kind) @@ -1306,7 +1306,7 @@ static int RLWINM_RLWINM(PCode *instr, UInt32 *masks) { if ( defInstr->op == PC_RLWINM && - !(PCODE_FLAG_SET_F(defInstr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(defInstr) & fRecordBit) && !definedbetween(instr, defInstr, &defInstr->args[1]) && !( defInstr->args[0].data.reg.reg == defInstr->args[1].data.reg.reg && @@ -1358,7 +1358,7 @@ static int RLWINM_RLWINM(PCode *instr, UInt32 *masks) { if ( (defInstr->args[0].data.reg.reg == instr->args[0].data.reg.reg || !(masks[RegClass_GPR] & (1 << defInstr->args[0].data.reg.reg))) && - !(PCODE_FLAG_SET_F(defInstr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(defInstr) & fRecordBit) && !usedbetween(instr, defInstr, &defInstr->args[0]) ) deletepcode(defInstr); @@ -1375,7 +1375,7 @@ static int MULLI_MULLI(PCode *instr, UInt32 *masks) { if ( defInstr->op == PC_MULLI && (defInstr->args[0].data.reg.reg == instr->args[0].data.reg.reg || !(masks[RegClass_GPR] & (1 << defInstr->args[0].data.reg.reg))) && - !(PCODE_FLAG_SET_F(defInstr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(defInstr) & fRecordBit) && !definedbetween(instr, defInstr, &defInstr->args[1]) && !usedbetween(instr, defInstr, &defInstr->args[0]) && FITS_IN_SHORT(instr->args[2].data.imm.value * defInstr->args[2].data.imm.value) @@ -1398,7 +1398,7 @@ static int ADDI_ADDI(PCode *instr, UInt32 *masks) { if ( defInstr->op == PC_ADDI && (defInstr->args[0].data.reg.reg == instr->args[0].data.reg.reg || !(masks[RegClass_GPR] & (1 << defInstr->args[0].data.reg.reg))) && - !(PCODE_FLAG_SET_F(defInstr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(defInstr) & fRecordBit) && !definedbetween(instr, defInstr, &defInstr->args[1]) && !usedbetween(instr, defInstr, &defInstr->args[0]) && instr->args[2].kind == PCOp_IMMEDIATE && @@ -1423,7 +1423,7 @@ static int SRAWI_SRAWI(PCode *instr, UInt32 *masks) { if ( defInstr->op == PC_SRAWI && (defInstr->args[0].data.reg.reg == instr->args[0].data.reg.reg || !(masks[RegClass_GPR] & (1 << defInstr->args[0].data.reg.reg))) && - !(PCODE_FLAG_SET_F(defInstr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(defInstr) & fRecordBit) && !definedbetween(instr, defInstr, &defInstr->args[1]) && !usedbetween(instr, defInstr, &defInstr->args[0]) && instr->args[2].kind == PCOp_IMMEDIATE && @@ -1451,12 +1451,12 @@ static int MR_ADDI(PCode *instr, UInt32 *masks) { if (copts.cpu == CPU_PPC603e) { if (prev) - prevFlag = (prev->flags & fPCodeFlagC0000000) == fPCodeFlag80000000; + prevFlag = (prev->flags & fOpTypeMask) == fOpTypeGPR; if (next) - nextFlag = (next->flags & fPCodeFlagC0000000) == fPCodeFlag80000000; + nextFlag = (next->flags & fOpTypeMask) == fOpTypeGPR; if ( - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(instr) & fRecordBit) && instr->argCount >= 2 && instr->args[1].data.reg.reg != 0 && (prevFlag || nextFlag) @@ -1528,7 +1528,7 @@ static int SRW_SUBFIC_RLW_OR(PCode *instr, UInt32 *masks) { PCode *defInstr1 = defininginstruction[instr->defID + 1]; PCode *defInstr2 = defininginstruction[instr->defID + 2]; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) return 0; if ( @@ -2151,12 +2151,12 @@ static void adjustforward(PCodeBlock *block) { scan->args[2].data.imm.value == 0 ) { - if (PCODE_FLAG_SET_F(scan) & fPCodeFlag20000000) { + if (PCODE_FLAG_SET_F(scan) & fRecordBit) { if (!flag1) { pcsetrecordbit(instr); change_opcode(scan, PC_MR); - scan->flags &= ~fPCodeFlag20000000; - scan->flags |= fPCodeFlag10; + scan->flags &= ~fRecordBit; + scan->flags |= fIsMove; change_num_operands(scan, 2); } else { change_opcode(scan, PC_MR); @@ -2201,7 +2201,7 @@ static void adjustforward(PCodeBlock *block) { PC_RLWINM, scan->args[0].data.reg.reg, reg1, 32 - scan->args[2].data.imm.value, start, end )); - if (PCODE_FLAG_SET_F(scan) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(scan) & fRecordBit) pcsetrecordbit(scan->nextPCode); deletepcode(scan); } @@ -2209,8 +2209,8 @@ static void adjustforward(PCodeBlock *block) { opcode == PC_OR && !flag2 && reg0 != reg1 && - !(PCODE_FLAG_SET_F(scan) & fPCodeFlag20000000) && - !(PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) && + !(PCODE_FLAG_SET_F(scan) & fRecordBit) && + !(PCODE_FLAG_SET_F(instr) & fRecordBit) && scan->args[0].data.reg.reg != instr->args[1].data.reg.reg ) { @@ -2313,10 +2313,10 @@ static void adjustforward(PCodeBlock *block) { ) { change_opcode(scan, PC_MR); - if ((PCODE_FLAG_SET_F(scan) & fPCodeFlag20000000) && !flag1) { + if ((PCODE_FLAG_SET_F(scan) & fRecordBit) && !flag1) { pcsetrecordbit(instr); - scan->flags &= ~fPCodeFlag20000000; - scan->flags |= fPCodeFlag10; + scan->flags &= ~fRecordBit; + scan->flags |= fIsMove; change_num_operands(scan, 2); } } @@ -2329,10 +2329,10 @@ static void adjustforward(PCodeBlock *block) { ) { change_opcode(scan, PC_MR); - if ((PCODE_FLAG_SET_F(scan) & fPCodeFlag20000000) && !flag1) { + if ((PCODE_FLAG_SET_F(scan) & fRecordBit) && !flag1) { pcsetrecordbit(instr); - scan->flags &= ~fPCodeFlag20000000; - scan->flags |= fPCodeFlag10; + scan->flags &= ~fRecordBit; + scan->flags |= fIsMove; change_num_operands(scan, 2); } } @@ -2371,10 +2371,10 @@ static void adjustforward(PCodeBlock *block) { ) { change_opcode(scan, PC_MR); - if ((PCODE_FLAG_SET_F(scan) & fPCodeFlag20000000) && !flag) { + if ((PCODE_FLAG_SET_F(scan) & fRecordBit) && !flag) { pcsetrecordbit(instr); - scan->flags &= ~fPCodeFlag20000000; - scan->flags |= fPCodeFlag10; + scan->flags &= ~fRecordBit; + scan->flags |= fIsMove; change_num_operands(scan, 2); } } @@ -2410,10 +2410,10 @@ static void adjustforward(PCodeBlock *block) { else if (scan->op == PC_EXTSH && scan->args[1].data.reg.reg == reg0) { change_opcode(scan, PC_MR); - if ((PCODE_FLAG_SET_F(scan) & fPCodeFlag20000000) && !flag) { + if ((PCODE_FLAG_SET_F(scan) & fRecordBit) && !flag) { pcsetrecordbit(instr); - scan->flags &= ~fPCodeFlag20000000; - scan->flags |= fPCodeFlag10; + scan->flags &= ~fRecordBit; + scan->flags |= fIsMove; change_num_operands(scan, 2); } } @@ -2443,11 +2443,11 @@ static void adjustforward(PCodeBlock *block) { SInt32 val2 = instr->args[2].data.imm.value; for (scan = instr->nextPCode; scan; scan = scan->nextPCode) { - if ((scan->flags & fPCodeFlag4) && scan->args[0].data.reg.reg == reg0) + if ((scan->flags & fIsWrite) && scan->args[0].data.reg.reg == reg0) break; if ( - (scan->flags & (fPCodeFlag2 | fPCodeFlag4)) && + (scan->flags & (fIsRead | fIsWrite)) && scan->args[1].data.reg.reg == reg0 && scan->args[2].kind == PCOp_IMMEDIATE && FITS_IN_SHORT(val2 + scan->args[2].data.imm.value) @@ -2456,7 +2456,7 @@ static void adjustforward(PCodeBlock *block) { scan->args[2].data.imm.value += val2; tmp = instr->prevPCode; if ( - (scan->flags & fPCodeFlag2) && + (scan->flags & fIsRead) && scan->args[0].data.reg.reg == reg0 && scan->args[0].kind == PCOp_REGISTER && scan->args[0].arg == RegClass_GPR @@ -2490,7 +2490,7 @@ static void adjustforward(PCodeBlock *block) { break; } - if (scan->flags & (fPCodeFlag1 | fPCodeFlag8)) { + if (scan->flags & (fIsBranch | fIsCall)) { if (flag1 && scan->prevPCode != instr) { tmp = instr->prevPCode; deletepcode(instr); @@ -2653,14 +2653,14 @@ void peepholemergeblocks(Object *func, Boolean flag) { next = block->nextBlock; if (!flag) { - flag2 = next && (next->flags & fPCBlockFlag2); - if (block->flags & fPCBlockFlag1) + flag2 = next && (next->flags & fIsEpilogue); + if (block->flags & fIsProlog) continue; } if (block->pcodeCount > 0) { for (instr = block->firstPCode; instr; instr = instr->nextPCode) { - if (instr->flags & (fPCodeFlag8 | fSideEffects)) + if (instr->flags & (fIsCall | fSideEffects)) break; } @@ -2676,7 +2676,7 @@ void peepholemergeblocks(Object *func, Boolean flag) { } instr = block->lastPCode; - if (instr && (instr->flags & fPCodeFlag1) && instr->op != PC_B) + if (instr && (instr->flags & fIsBranch) && instr->op != PC_B) continue; while ( @@ -2692,7 +2692,7 @@ void peepholemergeblocks(Object *func, Boolean flag) { if (next->pcodeCount > 0) { for (instr = next->firstPCode; instr; instr = nextinstr) { nextinstr = instr->nextPCode; - if (instr->flags & (fPCodeFlag8 | fSideEffects)) + if (instr->flags & (fIsCall | fSideEffects)) break; deletepcode(instr); @@ -2727,11 +2727,11 @@ void peepholemergeblocks(Object *func, Boolean flag) { if (block->nextBlock) block->nextBlock->prevBlock = block; - next->flags |= fPCBlockFlag20; + next->flags |= fDeleted; next = block->nextBlock; if (!flag) - flag2 = next && (next->flags & fPCBlockFlag2); + flag2 = next && (next->flags & fIsEpilogue); } } } diff --git a/compiler_and_linker/unsorted/RegisterInfo.c b/compiler_and_linker/unsorted/RegisterInfo.c index 91d775f..13c519d 100644 --- a/compiler_and_linker/unsorted/RegisterInfo.c +++ b/compiler_and_linker/unsorted/RegisterInfo.c @@ -311,7 +311,7 @@ UInt32 colored_vrs_as_vrsave(PCodeBlock *block) { while (block) { for (pc = block->firstPCode; pc; pc = pc->nextPCode) { - if (pc->flags & (fPCodeFlag40000000 | fPCodeFlag80000000)) { + if (pc->flags & fOpTypeVR) { for (i = 0; i < pc->argCount; i++) { if (pc->args[i].kind == PCOp_REGISTER && pc->args[i].arg == RegClass_VR) mask |= 1 << (31 - pc->args[i].data.reg.reg); diff --git a/compiler_and_linker/unsorted/Scheduler.c b/compiler_and_linker/unsorted/Scheduler.c index e3c8ac7..791ba28 100644 --- a/compiler_and_linker/unsorted/Scheduler.c +++ b/compiler_and_linker/unsorted/Scheduler.c @@ -170,7 +170,7 @@ static void addsuccessor(DGNode *a, DGNode *b, Boolean flag) { a->successors = succ; succ->x8 = r29; - if (flag && (succ->node->instr->flags & fPCodeFlag1)) + if (flag && (succ->node->instr->flags & fIsBranch)) succ->x8 += MI->x8; b->predCount++; @@ -290,9 +290,9 @@ static void findsuccessors(DGNode *nodes, DGNode *node) { } } - if (instr->flags & (fPCodeFlag2 | fPCodeFlag20000)) + if (instr->flags & (fIsRead | fPCodeFlag20000)) serialize_load(node); - else if (instr->flags & (fPCodeFlag4 | fPCodeFlag40000)) + else if (instr->flags & (fIsWrite | fPCodeFlag40000)) serialize_store(node); if (instr->flags & fIsVolatile) { @@ -301,7 +301,7 @@ static void findsuccessors(DGNode *nodes, DGNode *node) { } if ( - ((instr->flags & fPCodeFlag8 | fPCodeFlag1) && (instr->flags & fLink)) || + ((instr->flags & fIsCall | fIsBranch) && (instr->flags & fLink)) || (instr->flags & fSideEffects) || MI->serializes(instr) ) @@ -424,7 +424,7 @@ static void scheduleblock(PCodeBlock *block) { for (instr = block->lastPCode; instr; instr = instr->prevPCode) { DGNode *n = makedgnode(instr); findsuccessors(head, n); - if (instr->flags & fPCodeFlag1) + if (instr->flags & fIsBranch) defaultsuccessor = n; head = adddgnode(head, n); } @@ -492,12 +492,12 @@ void scheduleinstructions(Boolean flag) { for (block = pcbasicblocks; block; block = block->nextBlock) { if ( block->pcodeCount > 2 && - (flag || !(block->flags & (fPCBlockFlag1 | fPCBlockFlag2))) && - !(block->flags & fPCBlockFlag8) + (flag || !(block->flags & (fIsProlog | fIsEpilogue))) && + !(block->flags & fScheduled) ) { scheduleblock(block); - block->flags |= fPCBlockFlag8; + block->flags |= fScheduled; } } } diff --git a/compiler_and_linker/unsorted/SpillCode.c b/compiler_and_linker/unsorted/SpillCode.c index bfafbac..477d391 100644 --- a/compiler_and_linker/unsorted/SpillCode.c +++ b/compiler_and_linker/unsorted/SpillCode.c @@ -50,7 +50,7 @@ void estimatespillcosts(void) { while (i--) { if (PC_OP_IS_WRITE_ANY_REGISTER(op, coloring_class)) { node = interferencegraph[op->data.reg.reg]; - if (node->instr8 || (instr->flags & fPCodeFlag8000)) + if (node->instr8 || (instr->flags & fIsArgInit)) node->spillCost -= weight; else node->spillCost += weight; @@ -291,7 +291,7 @@ static void spillinstruction(PCodeBlock *block, PCode *instr) { } if (writeCounter) { - if (node->instr8 || (instr->flags & fPCodeFlag8000)) + if (node->instr8 || (instr->flags & fIsArgInit)) flag = 1; else insert_store_spilled_register(instr, 0, reg2, node); @@ -440,9 +440,9 @@ void insertspillcode(void) { if (coloring_class == RegClass_VR && rTEMP_for_VR_spill == 0) rTEMP_for_VR_spill = used_virtual_registers[RegClass_GPR]++; - if (instr->flags & fPCodeFlag10) + if (instr->flags & fIsMove) spillcopy(block, instr); - else if (instr->flags & fPCodeFlag8) + else if (instr->flags & fIsCall) spillcall(block, instr); else spillinstruction(block, instr); diff --git a/compiler_and_linker/unsorted/StackFrame.c b/compiler_and_linker/unsorted/StackFrame.c index 91b15da..e9feb2e 100644 --- a/compiler_and_linker/unsorted/StackFrame.c +++ b/compiler_and_linker/unsorted/StackFrame.c @@ -293,7 +293,7 @@ void compute_frame_sizes(void) { genuine_frame_size = frame_size; } if (!large_stack && frame_size > 0x7FFF) - CError_ErrorTerm(210); + CError_ErrorTerm(CErrorStr210); } static void allocate_new_frame(int reg1, int reg2) { @@ -427,7 +427,7 @@ void generate_prologue(PCodeBlock *block, Boolean has_varargs) { if (large_stack) do_allocate_dynamic_stack_space(1, 11, 0, large_data_near_size); - block->flags |= fPCBlockFlag1; + block->flags |= fIsProlog; pclastblock = save_block; current_statement = save_statement; } @@ -498,7 +498,7 @@ void generate_epilogue(PCodeBlock *block, Boolean add_blr) { setpcodeflags(fIsVolatile); } - block->flags |= fPCBlockFlag2; + block->flags |= fIsEpilogue; pclastblock = save_block; current_statement = save_statement; } @@ -832,7 +832,7 @@ void move_varargs_to_memory(void) { dummyvaparam = galloc(sizeof(Object)); memclrw(dummyvaparam, sizeof(Object)); - dummyvaparam->type = (Type *) &stvoid; + dummyvaparam->type = TYPE(&stvoid); dummyvaparam->otype = OT_OBJECT; dummyvaparam->name = GetHashNameNode("<vaparam>"); dummyvaparam->datatype = DLOCAL; @@ -843,7 +843,7 @@ void move_varargs_to_memory(void) { for (reg = last_argument_register[RegClass_GPR] + 1; (int)reg <= 10; reg++) { emitpcode(PC_STW, reg, local_base_register(dummyvaparam), dummyvaparam, (reg - 3) * 4); - setpcodeflags(fPCodeFlag20 | fPCodeFlag8000); + setpcodeflags(fIsPtrOp | fIsArgInit); } } diff --git a/compiler_and_linker/unsorted/StrengthReduction.c b/compiler_and_linker/unsorted/StrengthReduction.c index 462653a..2b68dca 100644 --- a/compiler_and_linker/unsorted/StrengthReduction.c +++ b/compiler_and_linker/unsorted/StrengthReduction.c @@ -143,7 +143,7 @@ static int isinductionvariable(BasicInductionVar *biv, int useID, SInt32 *result return 0; if (instr->args[4].data.imm.value != (31 - instr->args[2].data.imm.value)) return 0; - if (PCODE_FLAG_SET_F(instr) & fPCodeFlag20000000) + if (PCODE_FLAG_SET_F(instr) & fRecordBit) return 0; *result1 = 1 << instr->args[2].data.imm.value; break; @@ -222,7 +222,7 @@ static void addinductionvariable(BasicInductionVar *biv, PCode *instr, SInt32 va iv->x18 = val2; iv->x1A = val3; iv->someloop = val4; - if (instr->flags & (fPCodeFlag2 | fPCodeFlag4)) + if (instr->flags & (fIsRead | fIsWrite)) iv->x1C = -1; else iv->x1C = instr->args[0].data.reg.reg; @@ -343,7 +343,7 @@ static void incrementinductionvariable(InductionVar *iv) { } static void copyinductionvariable(InductionVar *iv) { - if (iv->instr->flags & (fPCodeFlag2 | fPCodeFlag4)) { + if (iv->instr->flags & (fIsRead | fIsWrite)) { iv->instr->op -= 2; iv->instr->args[1].data.reg.reg = iv->x1E; iv->instr->args[2].kind = PCOp_IMMEDIATE; @@ -658,7 +658,7 @@ static void combineinductionvariables(Loop *loop, BasicInductionVar *biv1, Basic } } - if (loop->body->lastPCode->flags & fPCodeFlag1) { + if (loop->body->lastPCode->flags & fIsBranch) { nextBlock = NULL; for (i = 0; i < loop->body->lastPCode->argCount; i++) { diff --git a/compiler_and_linker/unsorted/UseDefChains.c b/compiler_and_linker/unsorted/UseDefChains.c index 1525005..7d87fa9 100644 --- a/compiler_and_linker/unsorted/UseDefChains.c +++ b/compiler_and_linker/unsorted/UseDefChains.c @@ -82,13 +82,13 @@ static void precomputememoryusedefs(void) { for (block = pcbasicblocks; block; block = block->nextBlock) { for (pcode = block->firstPCode; pcode; pcode = pcode->nextPCode) { - if (pcode->flags & (fPCodeFlag2 | fPCodeFlag4)) { + if (pcode->flags & (fIsRead | fIsWrite)) { if (pcode->alias) { if (pcode->alias->type == AliasType2 || pcode->alias->size != nbytes_loaded_or_stored_by(pcode)) - pcode->flags |= fPCodeFlag20; + pcode->flags |= fIsPtrOp; addaliasusedef(pcode->alias); } else { - pcode->flags |= fPCodeFlag20; + pcode->flags |= fIsPtrOp; } } } @@ -109,7 +109,7 @@ static void precomputeusedefcounts(int flag) { for (block = pcbasicblocks; block; block = block->nextBlock) { for (pcode = block->firstPCode; pcode; pcode = pcode->nextPCode) { - if (!(pcode->flags & fPCodeFlag1) && pcode->argCount) { + if (!(pcode->flags & fIsBranch) && pcode->argCount) { pcode->useID = number_of_Uses; pcode->defID = number_of_Defs; op = pcode->args; @@ -125,8 +125,8 @@ static void precomputeusedefcounts(int flag) { } if (flag) { - if (pcode->flags & fPCodeFlag2) { - if (pcode->flags & fPCodeFlag20) { + if (pcode->flags & fIsRead) { + if (pcode->flags & fIsPtrOp) { for (oud = objectusedeflist; oud; oud = oud->next) { if (may_alias_object(pcode, oud->object)) number_of_Uses++; @@ -134,8 +134,8 @@ static void precomputeusedefcounts(int flag) { } else { number_of_Uses++; } - } else if (pcode->flags & fPCodeFlag4) { - if (pcode->flags & fPCodeFlag20) { + } else if (pcode->flags & fIsWrite) { + if (pcode->flags & fIsPtrOp) { for (oud = objectusedeflist; oud; oud = oud->next) { if (may_alias_object(pcode, oud->object)) number_of_Defs++; @@ -143,7 +143,7 @@ static void precomputeusedefcounts(int flag) { } else { number_of_Defs++; } - } else if (pcode->flags & fPCodeFlag8) { + } else if (pcode->flags & fIsCall) { for (oud = objectusedeflist; oud; oud = oud->next) { if ( oud->object->datatype == DDATA || @@ -207,7 +207,7 @@ static void computeusedeflists(int flag) { for (block = pcbasicblocks; block; block = block->nextBlock) { for (pcode = block->firstPCode; pcode; pcode = pcode->nextPCode) { - if (!(pcode->flags & fPCodeFlag1) && pcode->argCount) { + if (!(pcode->flags & fIsBranch) && pcode->argCount) { use = &Uses[useID = pcode->useID]; def = &Defs[defID = pcode->defID]; @@ -244,8 +244,8 @@ static void computeusedeflists(int flag) { } if (flag) { - if (pcode->flags & fPCodeFlag2) { - if (pcode->flags & fPCodeFlag20) { + if (pcode->flags & fIsRead) { + if (pcode->flags & fIsPtrOp) { for (oud = objectusedeflist; oud; oud = oud->next) { if (may_alias_object(pcode, object = oud->object)) { use->pcode = pcode; @@ -272,8 +272,8 @@ static void computeusedeflists(int flag) { list->next = tmp->uses; tmp->uses = list; } - } else if (pcode->flags & fPCodeFlag4) { - if (pcode->flags & fPCodeFlag20) { + } else if (pcode->flags & fIsWrite) { + if (pcode->flags & fIsPtrOp) { for (oud = objectusedeflist; oud; oud = oud->next) { if (may_alias_object(pcode, object = oud->object)) { def->pcode = pcode; @@ -300,7 +300,7 @@ static void computeusedeflists(int flag) { list->next = tmp->defs; tmp->defs = list; } - } else if (pcode->flags & fPCodeFlag8) { + } else if (pcode->flags & fIsCall) { for (oud = objectusedeflist; oud; oud = oud->next) { object = oud->object; if ( @@ -396,7 +396,7 @@ static void computelocalusedefinfo(void) { bitvectorinitialize(info->usevec1C, number_of_Uses, 0); for (pcode = block->firstPCode; pcode; pcode = pcode->nextPCode) { - if (!(pcode->flags & fPCodeFlag1) && pcode->argCount) { + if (!(pcode->flags & fIsBranch) && pcode->argCount) { for (use = &Uses[useID = pcode->useID]; useID < number_of_Uses && use->pcode == pcode; use++, useID++) { bitvectorsetbit(useID, usevec10); if (use->v.kind == PCOp_REGISTER) { diff --git a/compiler_and_linker/unsorted/ValueNumbering.c b/compiler_and_linker/unsorted/ValueNumbering.c index 670471d..0907fa1 100644 --- a/compiler_and_linker/unsorted/ValueNumbering.c +++ b/compiler_and_linker/unsorted/ValueNumbering.c @@ -265,7 +265,7 @@ static int matchvalues(AvailableValue *av, PCode *match) { } } - if ((match->flags & (fPCodeFlag2 | fPCodeFlag20000)) && match->alias->valuenumber != av->aliasnumber) + if ((match->flags & (fIsRead | fPCodeFlag20000)) && match->alias->valuenumber != av->aliasnumber) return 0; return 1; @@ -331,7 +331,7 @@ static void addavailablevalue(PCode *pcode) { av->opnumbers[i] = regvalue[op->arg][op->data.reg.reg].number; } - if (pcode->flags & (fPCodeFlag2 | fPCodeFlag20000)) + if (pcode->flags & (fIsRead | fPCodeFlag20000)) av->aliasnumber = pcode->alias->valuenumber; op = &pcode->args[0]; @@ -368,7 +368,7 @@ static int isCSEop(PCode *pcode) { break; } - if (PCODE_FLAG_SET_F(pcode) & (fIsVolatile | fSideEffects | fOverflow | fPCodeFlag10000000 | fPCodeFlag20000000)) + if (PCODE_FLAG_SET_F(pcode) & (fIsVolatile | fSideEffects | fOverflow | fSetsCarry | fRecordBit)) return 0; for (i = 0, op = &pcode->args[0]; i < pcode->argCount; i++, op++) { @@ -542,17 +542,17 @@ static void removecsesfrombasicblock(PCodeBlock *block) { for (pcode = block->firstPCode; pcode; pcode = next) { next = pcode->nextPCode; propagatecopiesto(pcode); - if (pcode->flags & fPCodeFlag10) { + if (pcode->flags & fIsMove) { registercopy(pcode); - } else if ((pcode->flags & fPCodeFlag8) && (pcode->flags & (fLink | fSideEffects))) { + } else if ((pcode->flags & fIsCall) && (pcode->flags & (fLink | fSideEffects))) { functioncall(pcode); - } else if (pcode->flags & fPCodeFlag2) { - if (pcode->flags & fPCodeFlag20) + } else if (pcode->flags & fIsRead) { + if (pcode->flags & fIsPtrOp) pointerload(pcode); else simpleload(pcode); - } else if (pcode->flags & fPCodeFlag4) { - if (pcode->flags & fPCodeFlag20) + } else if (pcode->flags & fIsWrite) { + if (pcode->flags & fIsPtrOp) pointerstore(pcode); else simplestore(pcode); @@ -567,7 +567,7 @@ static void removecsesfrombasicblock(PCodeBlock *block) { } } - block->flags |= fPCBlockFlag4; + block->flags |= fVisited; } static void getvaluestate(State *state) { @@ -621,7 +621,7 @@ static void removecsesfromextendedbasicblock(PCodeBlock *block) { counter = 0; for (succ = block->successors; succ; succ = succ->nextLink) { - if (!(succ->block->flags & fPCBlockFlag4) && succ->block->predecessors && !succ->block->predecessors->nextLink) + if (!(succ->block->flags & fVisited) && succ->block->predecessors && !succ->block->predecessors->nextLink) counter++; } @@ -629,7 +629,7 @@ static void removecsesfromextendedbasicblock(PCodeBlock *block) { getvaluestate(&state); forkvaluestate(nextvaluenumber); for (succ = block->successors; succ; succ = succ->nextLink) { - if (!(succ->block->flags & fPCBlockFlag4) && succ->block->predecessors && !succ->block->predecessors->nextLink) { + if (!(succ->block->flags & fVisited) && succ->block->predecessors && !succ->block->predecessors->nextLink) { removecsesfromextendedbasicblock(succ->block); regressvaluestate(); } @@ -647,10 +647,10 @@ void removecommonsubexpressions(Object *proc, int flag) { allocatecsedatastructures(); for (block = pcbasicblocks; block; block = block->nextBlock) - block->flags &= ~fPCBlockFlag4; + block->flags &= ~fVisited; for (block = pcbasicblocks; block; block = block->nextBlock) { - if (!(block->flags & fPCBlockFlag4)) { + if (!(block->flags & fVisited)) { initializecsedatastructures(); removecsesfromextendedbasicblock(block); } diff --git a/compiler_and_linker/unsorted/VectorArraysToRegs.c b/compiler_and_linker/unsorted/VectorArraysToRegs.c index c6c4735..fde27f1 100644 --- a/compiler_and_linker/unsorted/VectorArraysToRegs.c +++ b/compiler_and_linker/unsorted/VectorArraysToRegs.c @@ -110,7 +110,7 @@ static void scaninstructions(LocalVectorArray *arrays) { firstaddinblock[block->blockIndex] = number_of_ADDIs; counter = 0; for (instr = block->firstPCode; instr; instr = instr->nextPCode) { - if (!(instr->flags & fPCodeFlag1) && instr->argCount) { + if (!(instr->flags & fIsBranch) && instr->argCount) { op = instr->args; i = instr->argCount; while (i--) { @@ -168,7 +168,7 @@ static void computeaddilist(LocalVectorArray *arrays) { bitvectorcopy(vec, usedefinfo[block->blockIndex].usevec1C, number_of_Uses); addi = &ADDIs[firstaddinblock[block->blockIndex] + naddsinblock[block->blockIndex] - 1]; for (instr = block->lastPCode; instr; instr = instr->prevPCode) { - if (!(instr->flags & fPCodeFlag1) && instr->argCount) { + if (!(instr->flags & fIsBranch) && instr->argCount) { int reg; // r18 if ( instr->op == PC_ADDI && @@ -245,7 +245,7 @@ static void computelocalvectorpropinfo(LocalVectorArray *arrays) { index = firstaddinblock[block->blockIndex]; for (instr = block->firstPCode; instr; instr = instr->nextPCode) { - if (!(instr->flags & fPCodeFlag1) && instr->argCount) { + if (!(instr->flags & fIsBranch) && instr->argCount) { i = instr->argCount; op = instr->args; while (i--) { diff --git a/compiler_and_linker/unsorted/uDump.c b/compiler_and_linker/unsorted/uDump.c index 52ab09f..86a6e68 100644 --- a/compiler_and_linker/unsorted/uDump.c +++ b/compiler_and_linker/unsorted/uDump.c @@ -429,7 +429,7 @@ static void spell(Type *type, char *buf) { strcat(buf, TYPE_ENUM(type)->enumname->name); break; case TYPESTRUCT: - if (IS_TYPESTRUCT_VECTOR(type)) { + if (IS_TYPESTRUCT_VECTOR(TYPE_STRUCT(type))) { switch (TYPE_STRUCT(type)->stype) { case STRUCT_TYPE_4: strcpy(buf, "vector unsigned char "); |