From 0bec4f557a96e1a40437cf5af20cc78a5eec8a63 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 11 Jan 2023 22:29:53 +0000 Subject: getting closer --- CMakeLists.txt | 12 +- .../C++_Parser/Src/Library/WarningHelpers.c | 2 +- command_line/CmdLine/Src/CLDependencies.c | 4 +- command_line/CmdLine/Src/CLFileOps.c | 8 +- command_line/CmdLine/Src/CLIncludeFileCache.c | 6 +- command_line/CmdLine/Src/CLLicenses.c | 13 +- command_line/CmdLine/Src/CLMain.c | 16 +- command_line/CmdLine/Src/CLPrefs.c | 4 +- command_line/CmdLine/Src/CLToolExec.c | 4 +- command_line/CmdLine/Src/Clients/ClientGlue.c | 2 +- command_line/CmdLine/Src/Envir/CLIO.c | 18 +- command_line/CmdLine/Src/MacEmul/LowMem.c | 6 +- command_line/CmdLine/Src/MacEmul/Memory.c | 10 +- command_line/CmdLine/Src/MacEmul/ResourceStrings.c | 4 +- command_line/CmdLine/Src/MacEmul/Resources.c | 12 +- command_line/CmdLine/Src/MacEmul/TextUtils.c | 2 +- command_line/CmdLine/Src/OSLib/Posix.c | 4 +- command_line/CmdLine/Src/Plugins/CLPlugins.c | 8 +- command_line/CmdLine/Src/Project/CLAccessPaths.c | 4 +- command_line/CmdLine/Src/Project/CLFiles.c | 2 +- .../Src/Options/Glue/TargetWarningHelpers-ppc-cc.c | 22 +- .../MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c | 36 +- .../Tools_PPC/Src/Plugin/libimp-mach-ppc.c | 4 +- compiler_and_linker/FrontEnd/C/CPrep.c | 1362 +++++++++++++++----- compiler_and_linker/FrontEnd/C/CPrepTokenizer.c | 106 +- compiler_and_linker/FrontEnd/C/CScope.c | 413 +++--- .../FrontEnd/Common/CompilerTools.c | 29 +- compiler_and_linker/unsorted/AddPropagation.c | 18 +- compiler_and_linker/unsorted/Alias.c | 26 +- compiler_and_linker/unsorted/CABI.c | 2 +- compiler_and_linker/unsorted/CClass.c | 4 +- compiler_and_linker/unsorted/CCompiler.c | 8 +- compiler_and_linker/unsorted/CDecl.c | 472 +++---- compiler_and_linker/unsorted/CError.c | 22 +- compiler_and_linker/unsorted/CExpr.c | 280 ++-- compiler_and_linker/unsorted/CExpr2.c | 42 +- compiler_and_linker/unsorted/CExprConvMatch.c | 4 +- compiler_and_linker/unsorted/CFunc.c | 10 +- compiler_and_linker/unsorted/CInit.c | 210 +-- compiler_and_linker/unsorted/CInline.c | 2 +- compiler_and_linker/unsorted/CInt64.c | 2 +- compiler_and_linker/unsorted/CMachine.c | 172 ++- compiler_and_linker/unsorted/CParser.c | 202 +-- compiler_and_linker/unsorted/CPrec.c | 4 +- compiler_and_linker/unsorted/CTemplateClass.c | 2 +- compiler_and_linker/unsorted/CTemplateNew.c | 2 +- compiler_and_linker/unsorted/CTemplateTools.c | 2 +- compiler_and_linker/unsorted/CodeGen.c | 92 +- compiler_and_linker/unsorted/CodeMotion.c | 26 +- compiler_and_linker/unsorted/Coloring.c | 2 +- compiler_and_linker/unsorted/ConstantPropagation.c | 22 +- compiler_and_linker/unsorted/CopyPropagation.c | 14 +- compiler_and_linker/unsorted/Exceptions.c | 2 +- compiler_and_linker/unsorted/FuncLevelAsmPPC.c | 8 +- compiler_and_linker/unsorted/GCCInlineAsm.c | 6 +- compiler_and_linker/unsorted/GenStabs.c | 2 +- compiler_and_linker/unsorted/InlineAsm.c | 14 +- compiler_and_linker/unsorted/InlineAsmPPC.c | 80 +- compiler_and_linker/unsorted/InlineAsmRegisters.c | 2 +- compiler_and_linker/unsorted/InstrSelection.c | 991 ++++++++++---- compiler_and_linker/unsorted/InterferenceGraph.c | 12 +- compiler_and_linker/unsorted/IroDump.c | 2 +- compiler_and_linker/unsorted/IroLinearForm.c | 10 +- .../unsorted/IroPointerAnalysisADTs.c | 4 +- compiler_and_linker/unsorted/LiveVariables.c | 157 +++ compiler_and_linker/unsorted/LoopDetection.c | 9 +- compiler_and_linker/unsorted/LoopOptimization.c | 18 +- .../unsorted/MachineSimulation601.c | 552 ++++++++ .../unsorted/MachineSimulation603.c | 626 +++++++++ .../unsorted/MachineSimulation603e.c | 650 ++++++++++ .../unsorted/MachineSimulation604.c | 670 ++++++++++ .../unsorted/MachineSimulation7400.c | 744 +++++++++++ .../unsorted/MachineSimulation750.c | 678 ++++++++++ .../unsorted/MachineSimulation821.c | 615 +++++++++ .../unsorted/MachineSimulationAltiVec.c | 752 +++++++++++ compiler_and_linker/unsorted/ObjGenMachO.c | 4 +- compiler_and_linker/unsorted/OpcodeInfo.c | 435 +++++++ compiler_and_linker/unsorted/Operands.c | 100 +- compiler_and_linker/unsorted/PCode.c | 22 +- compiler_and_linker/unsorted/PCodeAssembly.c | 58 +- compiler_and_linker/unsorted/PCodeInfo.c | 41 +- compiler_and_linker/unsorted/PCodeListing.c | 50 +- compiler_and_linker/unsorted/PCodeUtilities.c | 27 +- compiler_and_linker/unsorted/Peephole.c | 146 +-- compiler_and_linker/unsorted/RegisterInfo.c | 2 +- compiler_and_linker/unsorted/Scheduler.c | 16 +- compiler_and_linker/unsorted/SpillCode.c | 8 +- compiler_and_linker/unsorted/StackFrame.c | 10 +- compiler_and_linker/unsorted/StrengthReduction.c | 8 +- compiler_and_linker/unsorted/UseDefChains.c | 32 +- compiler_and_linker/unsorted/ValueNumbering.c | 28 +- compiler_and_linker/unsorted/VectorArraysToRegs.c | 6 +- compiler_and_linker/unsorted/uDump.c | 2 +- includes/cmdline.h | 62 +- includes/compiler/CError.h | 307 ++++- includes/compiler/CInline.h | 4 +- includes/compiler/CInt64.h | 2 +- includes/compiler/CMachine.h | 2 +- includes/compiler/CObjC.h | 2 +- includes/compiler/CPrec.h | 4 +- includes/compiler/CPrep.h | 14 +- includes/compiler/CScope.h | 2 +- includes/compiler/CTemplateClass.h | 2 +- includes/compiler/CompilerTools.h | 30 +- includes/compiler/ObjGenMachO.h | 4 +- includes/compiler/Operands.h | 6 +- includes/compiler/PCode.h | 62 +- includes/compiler/PCodeInfo.h | 865 +------------ includes/compiler/PCodeListing.h | 38 +- includes/compiler/common.h | 2 +- includes/compiler/objects.h | 2 +- includes/compiler/templates.h | 6 +- includes/compiler/tokens.h | 18 +- includes/compiler/types.h | 34 +- includes/cos.h | 6 +- includes/macemul.h | 32 +- includes/mwcc_decomp.h | 26 +- includes/option_system.h | 36 +- includes/oslib.h | 4 +- includes/parser.h | 20 +- includes/pref_structs.h | 21 +- osx_build.sh | 328 ++++- unsorted/Arguments.c | 24 +- unsorted/Help.c | 20 +- unsorted/OptimizerHelpers.c | 2 +- unsorted/Option.c | 18 +- unsorted/Parameter.c | 2 +- unsorted/Projects.c | 4 +- unsorted/StaticParserGlue.c | 4 +- unsorted/TargetOptimizer-ppc-mach.c | 36 +- unsorted/Targets.c | 2 +- unsorted/ToolHelpers-cc.c | 2 +- unsorted/uCOS.c | 6 +- 133 files changed, 10138 insertions(+), 3277 deletions(-) create mode 100644 compiler_and_linker/unsorted/LiveVariables.c create mode 100644 compiler_and_linker/unsorted/MachineSimulation601.c create mode 100644 compiler_and_linker/unsorted/MachineSimulation603.c create mode 100644 compiler_and_linker/unsorted/MachineSimulation603e.c create mode 100644 compiler_and_linker/unsorted/MachineSimulation604.c create mode 100644 compiler_and_linker/unsorted/MachineSimulation7400.c create mode 100644 compiler_and_linker/unsorted/MachineSimulation750.c create mode 100644 compiler_and_linker/unsorted/MachineSimulation821.c create mode 100644 compiler_and_linker/unsorted/MachineSimulationAltiVec.c create mode 100644 compiler_and_linker/unsorted/OpcodeInfo.c diff --git a/CMakeLists.txt b/CMakeLists.txt index d433c1d..903082b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,6 +145,7 @@ add_executable(mwcc compiler_and_linker/unsorted/StructMoves.c compiler_and_linker/unsorted/FunctionCalls.c compiler_and_linker/unsorted/IroBitVect.c + compiler_and_linker/unsorted/OpcodeInfo.c compiler_and_linker/unsorted/InlineAsmRegistersPPC.c compiler_and_linker/unsorted/InlineAsmMnemonicsPPC.c compiler_and_linker/unsorted/InlineAsmRegisters.c @@ -159,8 +160,15 @@ add_executable(mwcc compiler_and_linker/unsorted/UseDefChains.c compiler_and_linker/unsorted/LoadDeletion.c compiler_and_linker/unsorted/VectorArraysToRegs.c - compiler_and_linker/unsorted/LiveInfo.c - + compiler_and_linker/unsorted/LiveVariables.c + compiler_and_linker/unsorted/MachineSimulation604.c + compiler_and_linker/unsorted/MachineSimulation603.c + compiler_and_linker/unsorted/MachineSimulationAltiVec.c + compiler_and_linker/unsorted/MachineSimulation7400.c + compiler_and_linker/unsorted/MachineSimulation603e.c + compiler_and_linker/unsorted/MachineSimulation750.c + compiler_and_linker/unsorted/MachineSimulation601.c + compiler_and_linker/unsorted/MachineSimulation821.c compiler_and_linker/unsorted/InterferenceGraph.c compiler_and_linker/unsorted/SpillCode.c compiler_and_linker/unsorted/GCCInlineAsm.c diff --git a/command_line/C++_Parser/Src/Library/WarningHelpers.c b/command_line/C++_Parser/Src/Library/WarningHelpers.c index 35a6fa8..95a0657 100644 --- a/command_line/C++_Parser/Src/Library/WarningHelpers.c +++ b/command_line/C++_Parser/Src/Library/WarningHelpers.c @@ -55,7 +55,7 @@ int SetWarningFlags(const char *opt, void *str, const char *, int flags) { return 1; } -int DisplayWarningOptions() { +int DisplayWarningOptions(const char *, void *, const char *, int) { Handle h; h = NewHandle(0); diff --git a/command_line/CmdLine/Src/CLDependencies.c b/command_line/CmdLine/Src/CLDependencies.c index 8c4c13b..6590257 100644 --- a/command_line/CmdLine/Src/CLDependencies.c +++ b/command_line/CmdLine/Src/CLDependencies.c @@ -273,11 +273,11 @@ int Deps_ChangeSpecialAccessPath(OSSpec *srcfss, Boolean initialize) { return 1; } -Path *Deps_GetSpecialAccessPath() { +Path *Deps_GetSpecialAccessPath(void) { return specialAccessPath; } -static void SetSpecialAccessPathFromIncludeStackTOS() { +static void SetSpecialAccessPathFromIncludeStackTOS(void) { // does not match, some registers are in the wrong order OSSpec spec; SInt16 index; diff --git a/command_line/CmdLine/Src/CLFileOps.c b/command_line/CmdLine/Src/CLFileOps.c index 14c9dc6..be3c00c 100644 --- a/command_line/CmdLine/Src/CLFileOps.c +++ b/command_line/CmdLine/Src/CLFileOps.c @@ -460,7 +460,7 @@ static int CompileEntry(File *file, Boolean *compiled) { return 1; } -static void DumpFileAndPathInfo() { +static void DumpFileAndPathInfo(void) { int i; int n; @@ -583,7 +583,7 @@ static void DumpFileAndPathInfo() { } } -int CompileFilesInProject() { +int CompileFilesInProject(void) { struct BuildInfo *tinfo; SInt32 index; SInt32 startTime; @@ -679,7 +679,7 @@ int CompileFilesInProject() { return CheckForUserBreak() ? Result_Cancelled : Result_Success; } -static int PostLinkFilesInProject() { +static int PostLinkFilesInProject(void) { SInt32 index; SInt32 startTime; SInt32 endTime; @@ -709,7 +709,7 @@ static int PostLinkFilesInProject() { return CheckForUserBreak() ? Result_Cancelled : Result_Success; } -int LinkProject() { +int LinkProject(void) { SInt32 startTime; SInt32 endTime; diff --git a/command_line/CmdLine/Src/CLIncludeFileCache.c b/command_line/CmdLine/Src/CLIncludeFileCache.c index d479f36..b7c78ea 100644 --- a/command_line/CmdLine/Src/CLIncludeFileCache.c +++ b/command_line/CmdLine/Src/CLIncludeFileCache.c @@ -19,7 +19,7 @@ static CacheEntry *cachelist; static CacheEntry *freelist; static UInt32 availablecache; -static CacheEntry *makecacheentry() { +static CacheEntry *makecacheentry(void) { CacheEntry *c = freelist; if (c) { freelist = c->next; @@ -46,13 +46,13 @@ static void deletecacheentry(CacheEntry *c) { cachelist = c->next; } -void InitializeIncludeCache() { +void InitializeIncludeCache(void) { freelist = NULL; cachelist = NULL; availablecache = CACHE_SIZE; } -void CleanupIncludeCache() { +void CleanupIncludeCache(void) { CacheEntry *c; CacheEntry *c1; diff --git a/command_line/CmdLine/Src/CLLicenses.c b/command_line/CmdLine/Src/CLLicenses.c index f264e6c..a58d58d 100644 --- a/command_line/CmdLine/Src/CLLicenses.c +++ b/command_line/CmdLine/Src/CLLicenses.c @@ -1,23 +1,22 @@ #include "cmdline.h" -void License_Initialize() { +void License_Initialize(void) { } -void License_Terminate() { +void License_Terminate(void) { } -SInt32 License_Checkout() { +SInt32 License_Checkout(void) { return 0xD0AD0A; } void License_Refresh() { - + // unknown args } void License_Checkin() { - + // unknown args } -void License_AutoCheckin() { - +void License_AutoCheckin(void) { } diff --git a/command_line/CmdLine/Src/CLMain.c b/command_line/CmdLine/Src/CLMain.c index 6e041ad..ae678fa 100644 --- a/command_line/CmdLine/Src/CLMain.c +++ b/command_line/CmdLine/Src/CLMain.c @@ -117,13 +117,13 @@ static BasePluginCallbacks clcb = { CLT_GetFileTypeMappings }; -static int RegisterStaticCmdLinePlugin() { +static int RegisterStaticCmdLinePlugin(void) { return RegisterStaticPlugin(&clcb); } #include "command_line/CmdLine/Project/Resources/CLErrors.r" -static int RegisterCmdLineResources() { +static int RegisterCmdLineResources(void) { return RegisterResource("Command-line strings", 12000, STR12000); } @@ -278,7 +278,7 @@ int Main_Terminate(int exitcode) { return exitcode; } -static int Main_ParseCommandLine() { +static int Main_ParseCommandLine(void) { Plugin *parser; CWCommandLineArgs myargs; int x, y; @@ -337,7 +337,7 @@ static int Main_ParseCommandLine() { return Result_Success; } -static int Main_SetupParamBlock() { +static int Main_SetupParamBlock(void) { PrefPanelsChangedCallback(0); if (optsCompiler.outMakefile[0]) { @@ -362,7 +362,7 @@ static int Main_SetupParamBlock() { return 0; } -static int Main_ResolveProject() { +static int Main_ResolveProject(void) { SInt32 startTime; SInt32 endTime; int err; @@ -562,7 +562,7 @@ static int UpdatePrefPanels(const char *name) { return 1; } -static int SetupCmdLinePrefPanels() { +static int SetupCmdLinePrefPanels(void) { int ret; PrefPanelsChangedCallback = UpdatePrefPanels; @@ -578,7 +578,7 @@ static int SetupCmdLinePrefPanels() { return ret; } -static int Main_SetupContext() { +static int Main_SetupContext(void) { gTarg = Target_New("default", clState.cpu, clState.os, clState.language); Target_Add(&gProj->targets, gTarg); @@ -622,7 +622,7 @@ static int Main_SetupContext() { return 1; } -int Main_Driver() { +int Main_Driver(void) { volatile int result; result = setjmp(exit_program); diff --git a/command_line/CmdLine/Src/CLPrefs.c b/command_line/CmdLine/Src/CLPrefs.c index 7aaa28a..dba6dd8 100644 --- a/command_line/CmdLine/Src/CLPrefs.c +++ b/command_line/CmdLine/Src/CLPrefs.c @@ -78,11 +78,11 @@ int PrefPanel_PutHandle(PrefPanel *panel, Handle data) { return 1; } -void Prefs_Initialize() { +void Prefs_Initialize(void) { panellist = NULL; } -void Prefs_Terminate() { +void Prefs_Terminate(void) { PrefPanel *scan; PrefPanel *next; diff --git a/command_line/CmdLine/Src/CLToolExec.c b/command_line/CmdLine/Src/CLToolExec.c index 80e3a7c..9bc4213 100644 --- a/command_line/CmdLine/Src/CLToolExec.c +++ b/command_line/CmdLine/Src/CLToolExec.c @@ -100,7 +100,7 @@ static int SetupLinkerCommandLine(SInt32 dropinflags, File *file, CWCommandLineA return 1; } -int SetupTemporaries() { +int SetupTemporaries(void) { SInt32 idx; File *file; @@ -117,7 +117,7 @@ int SetupTemporaries() { return 1; } -int DeleteTemporaries() { +int DeleteTemporaries(void) { SInt32 idx; File *file; diff --git a/command_line/CmdLine/Src/Clients/ClientGlue.c b/command_line/CmdLine/Src/Clients/ClientGlue.c index 6bc0508..f6b4a74 100644 --- a/command_line/CmdLine/Src/Clients/ClientGlue.c +++ b/command_line/CmdLine/Src/Clients/ClientGlue.c @@ -48,7 +48,7 @@ int CmdLine_Initialize(int argc, char **argv, const char *builddate, const char return Main_Initialize(argc, argv); } -int CmdLine_Driver() { +int CmdLine_Driver(void) { return Main_Driver(); } diff --git a/command_line/CmdLine/Src/Envir/CLIO.c b/command_line/CmdLine/Src/Envir/CLIO.c index 70ba9ae..0c07eaf 100644 --- a/command_line/CmdLine/Src/Envir/CLIO.c +++ b/command_line/CmdLine/Src/Envir/CLIO.c @@ -24,7 +24,7 @@ static void catchinterrupt() { clState.userBreak = 1; } -static void SetupConsoleInfo() { +static void SetupConsoleInfo(void) { struct winsize ws; struct stat st; @@ -57,11 +57,11 @@ static void Crash() { *((unsigned char *) NULL) = 0; } -void SetupDebuggingTraps() { +void SetupDebuggingTraps(void) { signal(SIGABRT, Crash); } -Boolean IO_Initialize() { +Boolean IO_Initialize(void) { ioPiping = 0; ioInHelp = 0; ioLineNum = 0; @@ -79,19 +79,19 @@ Boolean IO_Initialize() { return 1; } -Boolean IO_Terminate() { +Boolean IO_Terminate(void) { if (ioInHelp) IO_HelpTerminate(); TermWorking(); return 1; } -Boolean IO_HelpInitialize() { +Boolean IO_HelpInitialize(void) { ioInHelp = 1; return 1; } -Boolean IO_HelpTerminate() { +Boolean IO_HelpTerminate(void) { ioInHelp = 0; return 1; } @@ -229,13 +229,13 @@ Boolean AppendHandleToFile(OSSpec *spec, Handle text, UInt32 size, CWDataType ma return 1; } -void InitWorking() { +void InitWorking(void) { } void ShowWorking(int x) { } -void TermWorking() { +void TermWorking(void) { } static void ProgressFunction(const char *functionname) { @@ -243,7 +243,7 @@ static void ProgressFunction(const char *functionname) { CLReport(7, functionname); } -Boolean CheckForUserBreak() { +Boolean CheckForUserBreak(void) { ShowWorking(4); return clState.userBreak; } diff --git a/command_line/CmdLine/Src/MacEmul/LowMem.c b/command_line/CmdLine/Src/MacEmul/LowMem.c index cd31194..6b32e2c 100644 --- a/command_line/CmdLine/Src/MacEmul/LowMem.c +++ b/command_line/CmdLine/Src/MacEmul/LowMem.c @@ -2,15 +2,15 @@ static OSErr memErr; -UInt32 LMGetTicks() { +UInt32 LMGetTicks(void) { return (OS_GetMilliseconds() * 60) / 1000; } -UInt32 LMGetTime() { +UInt32 LMGetTime(void) { return OS_GetMilliseconds() / 1000; } -OSErr LMGetMemErr() { +OSErr LMGetMemErr(void) { return memErr; } diff --git a/command_line/CmdLine/Src/MacEmul/Memory.c b/command_line/CmdLine/Src/MacEmul/Memory.c index e201343..e6c42c3 100644 --- a/command_line/CmdLine/Src/MacEmul/Memory.c +++ b/command_line/CmdLine/Src/MacEmul/Memory.c @@ -49,7 +49,7 @@ void OS_DestroyMacHandle(Handle h, OSHandle *ret) { free(h); } -OSErr MemError() { +OSErr MemError(void) { return memError; } @@ -257,10 +257,10 @@ void DebugStr(ConstStringPtr str) { fprintf(stderr, "%*.*s", str[0], str[0], &str[1]); } -struct Zone *HandleZone() { - return 0; +struct Zone *HandleZone(void) { + return NULL; } -struct Zone *ApplicationZone() { - return 0; +struct Zone *ApplicationZone(void) { + return NULL; } diff --git a/command_line/CmdLine/Src/MacEmul/ResourceStrings.c b/command_line/CmdLine/Src/MacEmul/ResourceStrings.c index 4b6bc22..2cc960c 100644 --- a/command_line/CmdLine/Src/MacEmul/ResourceStrings.c +++ b/command_line/CmdLine/Src/MacEmul/ResourceStrings.c @@ -8,7 +8,7 @@ typedef struct { static Res rlist[16]; -void Res_Initialize() { +void Res_Initialize(void) { memset(rlist, 0, sizeof(rlist)); } @@ -64,5 +64,5 @@ const char *Res_GetResource(SInt16 rsrcid, SInt16 index) { return 0; } -void Res_Cleanup() { +void Res_Cleanup(void) { } diff --git a/command_line/CmdLine/Src/MacEmul/Resources.c b/command_line/CmdLine/Src/MacEmul/Resources.c index ef2aab0..821df0b 100644 --- a/command_line/CmdLine/Src/MacEmul/Resources.c +++ b/command_line/CmdLine/Src/MacEmul/Resources.c @@ -105,7 +105,7 @@ static Boolean UseResourceForkInfo; // Forward declarations static void ReadResourceFork(SInt16 ref, SInt8 permission, void *file_data, SInt32 file_size); -Boolean OS_UsingMacResourceForkInfo() { +Boolean OS_UsingMacResourceForkInfo(void) { return UseResourceForkInfo; } @@ -1186,7 +1186,7 @@ OSErr HOpenRF(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName, SInt8 permi } } -OSErr InitResources() { +OSErr InitResources(void) { MemRsrcMap *map; map = maplist; @@ -1201,7 +1201,7 @@ OSErr InitResources() { return 0; } -OSErr ResError() { +OSErr ResError(void) { return resError; } @@ -1289,7 +1289,7 @@ OSErr HOpenResFile(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName, SInt8 return FSpOpenResFile(&fss, permission); } -SInt16 CurResFile() { +SInt16 CurResFile(void) { return cur_res_file; } @@ -1570,7 +1570,7 @@ Handle Get1IndResource(OSType theType, SInt16 index) { } } -SInt16 Count1Types() { +SInt16 Count1Types(void) { MemRsrcMap *rm; MemRsrcTypeList *rtl; SInt16 count; @@ -1667,6 +1667,6 @@ SInt16 GetResFileAttrs(SInt16) { } } -Boolean LMGetResLoad() { +Boolean LMGetResLoad(void) { return 1; } diff --git a/command_line/CmdLine/Src/MacEmul/TextUtils.c b/command_line/CmdLine/Src/MacEmul/TextUtils.c index 7971074..f9f606d 100644 --- a/command_line/CmdLine/Src/MacEmul/TextUtils.c +++ b/command_line/CmdLine/Src/MacEmul/TextUtils.c @@ -22,7 +22,7 @@ SInt16 CharacterByteType(Ptr textBuf, SInt16 textOffset, ScriptCode script) { return 0; } -SInt16 CharByte() { +SInt16 CharByte(void) { return 0; } diff --git a/command_line/CmdLine/Src/OSLib/Posix.c b/command_line/CmdLine/Src/OSLib/Posix.c index 1f13dff..f42c0be 100644 --- a/command_line/CmdLine/Src/OSLib/Posix.c +++ b/command_line/CmdLine/Src/OSLib/Posix.c @@ -48,7 +48,7 @@ int OS_InitProgram(int *pArgc, char ***pArgv) { return 0; } -int OS_TermProgram() { +int OS_TermProgram(void) { return 0; } @@ -767,7 +767,7 @@ int OS_CloseDir(OSOpenedDir *ref) { return 0; } -UInt32 OS_GetMilliseconds() { +UInt32 OS_GetMilliseconds(void) { struct tms tms; return times(&tms) * 1000 / CLOCKS_PER_SEC; } diff --git a/command_line/CmdLine/Src/Plugins/CLPlugins.c b/command_line/CmdLine/Src/Plugins/CLPlugins.c index 5f31f45..38af6fe 100644 --- a/command_line/CmdLine/Src/Plugins/CLPlugins.c +++ b/command_line/CmdLine/Src/Plugins/CLPlugins.c @@ -5,11 +5,11 @@ static ToolVersionInfo toolVersionInfo; static VersionInfo toolVersion; static Boolean useToolVersion; -static void GetToolVersionInfo() { +static void GetToolVersionInfo(void) { useToolVersion = 0; } -const ToolVersionInfo *Plugin_GetToolVersionInfo() { +const ToolVersionInfo *Plugin_GetToolVersionInfo(void) { return useToolVersion ? &toolVersionInfo : 0; } @@ -480,12 +480,12 @@ Boolean Plugin_VerifyPanels(Plugin *pl) { } } -void Plugins_Init() { +void Plugins_Init(void) { pluginlist = NULL; GetToolVersionInfo(); } -void Plugins_Term() { +void Plugins_Term(void) { Plugin *scan; Plugin *next; diff --git a/command_line/CmdLine/Src/Project/CLAccessPaths.c b/command_line/CmdLine/Src/Project/CLAccessPaths.c index 1ffcd1d..d20b16b 100644 --- a/command_line/CmdLine/Src/Project/CLAccessPaths.c +++ b/command_line/CmdLine/Src/Project/CLAccessPaths.c @@ -451,7 +451,7 @@ int Frameworks_AddFramework(const char *name, const char *version, Boolean hidde return 0; } -void Framework_GetEnvInfo() { +void Framework_GetEnvInfo(void) { char path[256]; char *env; char *ptr; @@ -513,7 +513,7 @@ void Framework_GetEnvInfo() { } } -int Frameworks_GetCount() { +int Frameworks_GetCount(void) { return FrameworkInfo.fwsCount; } diff --git a/command_line/CmdLine/Src/Project/CLFiles.c b/command_line/CmdLine/Src/Project/CLFiles.c index a13deaf..6953df1 100644 --- a/command_line/CmdLine/Src/Project/CLFiles.c +++ b/command_line/CmdLine/Src/Project/CLFiles.c @@ -1,6 +1,6 @@ #include "cmdline.h" -File *File_New() { +File *File_New(void) { File *file; file = xmalloc(NULL, sizeof(File)); if (!file) { 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(""); 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 "); diff --git a/includes/cmdline.h b/includes/cmdline.h index 2c40cb1..6c39423 100644 --- a/includes/cmdline.h +++ b/includes/cmdline.h @@ -461,7 +461,7 @@ extern void SetBuildTarget(OSType cpu, OSType os); extern void SetParserType(OSType plang); extern void SetPluginType(OSType lang, OSType type); extern int CmdLine_Initialize(int argc, char **argv, const char *builddate, const char *buildtime); -extern int CmdLine_Driver(); +extern int CmdLine_Driver(void); extern int CmdLine_Terminate(int exitcode); /********************************/ @@ -476,20 +476,20 @@ extern void CLFatalError(const char *format, ...); /********************************/ /* Envir/CLIO.c */ -extern void SetupDebuggingTraps(); -extern Boolean IO_Initialize(); -extern Boolean IO_Terminate(); -extern Boolean IO_HelpInitialize(); -extern Boolean IO_HelpTerminate(); +extern void SetupDebuggingTraps(void); +extern Boolean IO_Initialize(void); +extern Boolean IO_Terminate(void); +extern Boolean IO_HelpInitialize(void); +extern Boolean IO_HelpTerminate(void); extern void FixHandleForIDE(Handle text, UInt32 size); extern Boolean ShowHandle(Handle text, UInt32 size, Boolean decorate); extern Boolean WriteHandleToFile(OSSpec *spec, Handle text, UInt32 size, OSType creator, OSType type); extern Boolean WriteBinaryHandleToFile(OSSpec *spec, OSType maccreator, OSType mactype, OSHandle *text); extern Boolean AppendHandleToFile(OSSpec *spec, Handle text, UInt32 size, OSType maccreator, OSType mactype); -extern void InitWorking(); +extern void InitWorking(void); extern void ShowWorking(int x); -extern void TermWorking(); -extern Boolean CheckForUserBreak(); +extern void TermWorking(void); +extern Boolean CheckForUserBreak(void); extern char *IO_FormatText(char *buffer, SInt32 size, char *newline, const char *format, ...); extern void CLPrintDispatch(int unk, SInt16 msgtype, const char *message); extern void CLPrintType(SInt16 msgtype, const char *format, ...); @@ -500,7 +500,7 @@ extern SInt16 CLStyledMessageDispatch(Plugin *plugin, MessageRef *ref, SInt32 er /********************************/ /* Plugins/CLPlugins.c */ -extern const ToolVersionInfo *Plugin_GetToolVersionInfo(); +extern const ToolVersionInfo *Plugin_GetToolVersionInfo(void); extern const char *Plugin_GetDropInName(Plugin *pl); extern const VersionInfo *Plugin_GetVersionInfo(Plugin *pl); extern char *Plugin_GetVersionInfoASCII(Plugin *pl); @@ -523,8 +523,8 @@ extern Boolean Plugin_CL_GetCompilerMapping(Plugin *pl, OSType type, const char extern Plugin *Plugin_New(const BasePluginCallbacks *cb, const CompilerLinkerPluginCallbacks *cl_cb, const ParserPluginCallbacks *pr_cb); extern void Plugin_Free(Plugin *pl); extern Boolean Plugin_VerifyPanels(Plugin *pl); -extern void Plugins_Init(); -extern void Plugins_Term(); +extern void Plugins_Init(void); +extern void Plugins_Term(void); extern int Plugins_Add(Plugin *pl); extern Plugin *Plugins_MatchName(Plugin *list, const char *name); extern Plugin *Plugins_CL_MatchTarget(Plugin *list, OSType cpu, OSType os, OSType type, OSType lang); @@ -562,8 +562,8 @@ extern void Paths_CopyRecurseFSS(FSSpec *list, Paths *paths, UInt16 count); extern Boolean MakeFrameworkPath(char *out, const char *filename, Path *globalpath); extern void Frameworks_AddPath(const OSPathSpec *oss); extern int Frameworks_AddFramework(const char *name, const char *version, Boolean hidden); -extern void Framework_GetEnvInfo(); -extern int Frameworks_GetCount(); +extern void Framework_GetEnvInfo(void); +extern int Frameworks_GetCount(void); extern Paths_FWInfo *Frameworks_GetInfo(int which); // Not sure if this is the right TU for this @@ -571,7 +571,7 @@ extern Paths FrameworkPaths; /********************************/ /* Project/CLFiles.c */ -extern File *File_New(); +extern File *File_New(void); extern void File_Free(File *file); extern Boolean Files_Initialize(Files *); extern Boolean Files_Terminate(Files *); @@ -643,7 +643,7 @@ extern Boolean Incls_FindFileInPaths(Incls *incls, char *filename, Boolean fulls extern Boolean Deps_Initialize(Deps *deps, Incls *incls); extern void Deps_Terminate(Deps *deps); extern int Deps_ChangeSpecialAccessPath(OSSpec *srcfss, Boolean initialize); -extern Path *Deps_GetSpecialAccessPath(); +extern Path *Deps_GetSpecialAccessPath(void); extern void Deps_AddDependency(Deps *deps, SInt32 incl, OSSpec *spec, Boolean unk, SInt16 dependencyType, Boolean *alreadyincluded); extern void Deps_ListDependencies(Incls *incls, File *file, OSHandle *h); @@ -651,25 +651,25 @@ extern void Deps_ListDependencies(Incls *incls, File *file, OSHandle *h); /* CLFileOps.c */ extern int GetOutputFile(File *file, SInt16 stage); extern int StoreObjectFile(File *file); -extern int CompileFilesInProject(); -extern int LinkProject(); +extern int CompileFilesInProject(void); +extern int LinkProject(void); /********************************/ /* CLIncludeFileCache.c */ -extern void InitializeIncludeCache(); -extern void CleanupIncludeCache(); +extern void InitializeIncludeCache(void); +extern void CleanupIncludeCache(void); extern void CacheIncludeFile(OSSpec *spec, Handle text, Boolean precompiled); extern Handle CachedIncludeFile(OSSpec *spec, Boolean *precompiled); extern void FreeIncludeFile(Handle text); /********************************/ /* CLLicenses.c */ -extern void License_Initialize(); -extern void License_Terminate(); -extern SInt32 License_Checkout(); -extern void License_Refresh(); -extern void License_Checkin(); -extern void License_AutoCheckin(); +extern void License_Initialize(void); +extern void License_Terminate(void); +extern SInt32 License_Checkout(/* unknown args */); +extern void License_Refresh(/* unknown args */); +extern void License_Checkin(/* unknown args */); +extern void License_AutoCheckin(void); /********************************/ /* CLLoadAndCache.c */ @@ -683,7 +683,7 @@ extern void Main_PreParse(int *argc, char ***argv); extern void Main_PassSpecialArgs(int *argc, char ***argv); extern int Main_Initialize(int argc, char **argv); extern int Main_Terminate(int code); -extern int Main_Driver(); +extern int Main_Driver(void); /********************************/ /* CLPluginRequests.cpp */ @@ -714,8 +714,8 @@ extern Boolean SendInitOrTermRequest(Plugin *plugin, Boolean reqIsInitialize); extern PrefPanel *PrefPanel_New(const char *name, void *initdata, SInt32 initdatasize); extern Handle PrefPanel_GetHandle(PrefPanel *panel); extern int PrefPanel_PutHandle(PrefPanel *panel, Handle data); -extern void Prefs_Initialize(); -extern void Prefs_Terminate(); +extern void Prefs_Initialize(void); +extern void Prefs_Terminate(void); extern Boolean Prefs_AddPanel(PrefPanel *panel); extern PrefPanel *Prefs_FindPanel(const char *name); @@ -729,8 +729,8 @@ extern void Target_Add(Target **list, Target *targ); /********************************/ /* CLToolExec.c */ extern void AppendArgumentList(int *argc, char ***argv, const char *str); -extern int SetupTemporaries(); -extern int DeleteTemporaries(); +extern int SetupTemporaries(void); +extern int DeleteTemporaries(void); extern int ExecuteLinker(Plugin *plugin, SInt32 dropinflags, File *file, char *stdoutfile, char *stderrfile); /********************************/ diff --git a/includes/compiler/CError.h b/includes/compiler/CError.h index a0f1217..754bdef 100644 --- a/includes/compiler/CError.h +++ b/includes/compiler/CError.h @@ -8,298 +8,591 @@ #define CError_FATAL(line) do { CError_Internal(__FILE__, line); } while (0) enum { + // "illegal character constant" CErrorStr100 = 100, + // "illegal string constant" CErrorStr101 = 101, + // "unexpected end of file" CErrorStr102 = 102, + // "unterminated comment" CErrorStr103 = 103, + // "undefined preprocessor directive" CErrorStr104 = 104, + // "illegal token" CErrorStr105 = 105, + // "string too long" CErrorStr106 = 106, + // "identifier expected" CErrorStr107 = 107, + // "macro '%u' redefined" CErrorStr108 = 108, + // "illegal argument list" CErrorStr109 = 109, + // "too many macro arguments" CErrorStr110 = 110, + // "macro(s) too complex" CErrorStr111 = 111, + // "unexpected end of line" CErrorStr112 = 112, + // "end of line expected" CErrorStr113 = 113, + // "'(' expected" CErrorStr114 = 114, + // "')' expected" CErrorStr115 = 115, + // "',' expected" CErrorStr116 = 116, + // "preprocessor syntax error" CErrorStr117 = 117, + // "preceding #if is missing" CErrorStr118 = 118, + // "unterminated #if / macro" CErrorStr119 = 119, + // "unexpected token" CErrorStr120 = 120, + // "declaration syntax error" CErrorStr121 = 121, + // "identifier '%u' redeclared" CErrorStr122 = 122, + // "';' expected" CErrorStr123 = 123, + // "illegal constant expression" CErrorStr124 = 124, + // "']' expected" CErrorStr125 = 125, + // "illegal use of 'void'" CErrorStr126 = 126, + // "illegal function definition" CErrorStr127 = 127, + // "illegal function return type" CErrorStr128 = 128, + // "illegal array definition" CErrorStr129 = 129, + // "'}' expected" CErrorStr130 = 130, + // "illegal struct/union/enum/class definition" CErrorStr131 = 131, + // "struct/union/enum/class tag '%u' redefined" CErrorStr132 = 132, + // "struct/union/class member '%u' redefined" CErrorStr133 = 133, + // "declarator expected" CErrorStr134 = 134, + // "'{' expected" CErrorStr135 = 135, + // "illegal use of incomplete struct/union/class '%t'" CErrorStr136 = 136, + // "struct/union/class size exceeds 32K" CErrorStr137 = 137, + // "illegal bitfield declaration" CErrorStr138 = 138, + // "division by 0" CErrorStr139 = 139, + // "undefined identifier '%u'" CErrorStr140 = 140, + // "expression syntax error" CErrorStr141 = 141, + // "not an lvalue" CErrorStr142 = 142, + // "illegal operation" CErrorStr143 = 143, + // "illegal operand" CErrorStr144 = 144, + // "data type is incomplete" CErrorStr145 = 145, + // "illegal type" CErrorStr146 = 146, + // "too many initializers" CErrorStr147 = 147, + // "pointer/array required" CErrorStr148 = 148, + // "not a struct/union/class" CErrorStr149 = 149, + // "'%u' is not a struct/union/class member" CErrorStr150 = 150, + // "the file '%u' cannot be opened" CErrorStr151 = 151, + // "illegal instruction for this processor" CErrorStr152 = 152, + // "illegal operands for this processor" CErrorStr153 = 153, + // "number is out of range" CErrorStr154 = 154, + // "illegal addressing mode" CErrorStr155 = 155, + // "illegal data size" CErrorStr156 = 156, + // "illegal register list" CErrorStr157 = 157, + // "branch out of range" CErrorStr158 = 158, + // "undefined label '%u'" CErrorStr159 = 159, + // "reference to label '%u' is out of range" CErrorStr160 = 160, + // "call of non-function" CErrorStr161 = 161, + // "function call does not match prototype" CErrorStr162 = 162, + // "illegal use of register variable" CErrorStr163 = 163, + // "illegal type cast" CErrorStr164 = 164, + // "function already has a stackframe" CErrorStr165 = 165, + // "function has no initialized stackframe" CErrorStr166 = 166, + // "value is not stored in register" CErrorStr167 = 167, + // "function nesting too complex" CErrorStr168 = 168, + // "illegal use of keyword" CErrorStr169 = 169, + // "':' expected" CErrorStr170 = 170, + // "label '%u' redefined" CErrorStr171 = 171, + // "case constant defined more than once" CErrorStr172 = 172, + // "default label defined more than once" CErrorStr173 = 173, + // "illegal initialization" CErrorStr174 = 174, + // "illegal use of inline function" CErrorStr175 = 175, + // "illegal type qualifier(s)" CErrorStr176 = 176, + // "illegal storage class" CErrorStr177 = 177, + // "function has no prototype" CErrorStr178 = 178, + // "illegal assignment to constant" CErrorStr179 = 179, + // "illegal use of precompiled header" CErrorStr180 = 180, + // "illegal data in precompiled header" CErrorStr181 = 181, + // "variable / argument '%u' is not used in function" CErrorStr182 = 182, + // "illegal use of direct parameters" CErrorStr183 = 183, + // "return value expected" CErrorStr184 = 184, + // "variable '%u' is not initialized before being used" CErrorStr185 = 185, + // "illegal #pragma" CErrorStr186 = 186, + // "illegal access to protected/private member" CErrorStr187 = 187, + // "ambiguous access to class/struct/union member" CErrorStr188 = 188, + // "illegal use of 'this'" CErrorStr189 = 189, + // "unimplemented C++ feature" CErrorStr190 = 190, + // "illegal use of 'HandleObject'" CErrorStr191 = 191, + // "illegal access qualifier" CErrorStr192 = 192, + // "illegal 'operator' declaration" CErrorStr193 = 193, + // "illegal use of abstract class ('%o')" CErrorStr194 = 194, + // "illegal use of pure function" CErrorStr195 = 195, + // "illegal '&' reference" CErrorStr196 = 196, + // "illegal function overloading" CErrorStr197 = 197, + // "illegal operator overloading" CErrorStr198 = 198, + // "ambiguous access to overloaded function " CErrorStr199 = 199, + // "illegal access/using declaration" CErrorStr200 = 200, + // "illegal 'friend' declaration" CErrorStr201 = 201, + // "illegal 'inline' function definition" CErrorStr202 = 202, + // "class has no default constructor" CErrorStr203 = 203, + // "illegal operator" CErrorStr204 = 204, + // "illegal default argument(s)" CErrorStr205 = 205, + // "possible unwanted ';'" CErrorStr206 = 206, + // "possible unwanted assignment" CErrorStr207 = 207, + // "possible unwanted compare" CErrorStr208 = 208, + // "illegal implicit conversion from '%t' to\n'%t'" CErrorStr209 = 209, + // "local data >32k" CErrorStr210 = 210, + // "illegal jump past initializer" CErrorStr211 = 211, + // "illegal ctor initializer" CErrorStr212 = 212, + // "cannot construct %t's base class '%t'" CErrorStr213 = 213, + // "cannot construct %t's direct member '%u'" CErrorStr214 = 214, + // "#if nesting overflow" CErrorStr215 = 215, + // "illegal empty declaration" CErrorStr216 = 216, + // "illegal implicit enum conversion from '%t' to\n'%t'" CErrorStr217 = 217, + // "illegal use of #pragma parameter" CErrorStr218 = 218, + // "virtual functions cannot be pascal functions" CErrorStr219 = 219, + // "illegal implicit const/volatile pointer conversion from '%t' to\n'%t'" CErrorStr220 = 220, + // "illegal use of non-static member" CErrorStr221 = 221, + // "illegal precompiled header version" CErrorStr222 = 222, + // "illegal precompiled header compiler flags or target" CErrorStr223 = 223, + // "'const' or '&' variable needs initializer" CErrorStr224 = 224, + // "'%o' hides inherited virtual function '%o'" CErrorStr225 = 225, + // "pascal function cannot be overloaded" CErrorStr226 = 226, + // "derived function differs from virtual base function in return type only" CErrorStr227 = 227, + // "non-const '&' reference initialized to temporary" CErrorStr228 = 228, + // "illegal template declaration" CErrorStr229 = 229, + // "'<' expected" CErrorStr230 = 230, + // "'>' expected" CErrorStr231 = 231, + // "illegal template argument(s)" CErrorStr232 = 232, + // "cannot instantiate '%o'" CErrorStr233 = 233, + // "template redefined" CErrorStr234 = 234, + // "template parameter mismatch" CErrorStr235 = 235, + // "cannot pass const/volatile data object to non-const/volatile member function" CErrorStr236 = 236, + // "preceding '#pragma push' is missing" CErrorStr237 = 237, + // "illegal explicit template instantiation" CErrorStr238 = 238, + // "illegal X::X(X) copy constructor" CErrorStr239 = 239, + // "function defined 'inline' after being called" CErrorStr240 = 240, + // "illegal constructor/destructor declaration" CErrorStr241 = 241, + // "'catch' expected" CErrorStr242 = 242, + // "#include nesting overflow" CErrorStr243 = 243, + // "cannot convert\n'%t' to\n'%t'" CErrorStr244 = 244, + // "type mismatch\n'%t' and\n'%t'" CErrorStr245 = 245, + // "class type expected" CErrorStr246 = 246, + // "illegal explicit conversion from '%t' to\n'%t'" CErrorStr247 = 247, + // "function call '*' does not match" CErrorStr248 = 248, + // "identifier '%u' redeclared\nwas declared as: '%t'\nnow declared as: '%t'" CErrorStr249 = 249, + // "cannot throw class with ambiguous base class ('%u')" CErrorStr250 = 250, + // "class '%t': '%o' has more than one final overrider:\n'%o'\nand '%o'" CErrorStr251 = 251, + // "exception handling option is disabled" CErrorStr252 = 252, + // "cannot delete pointer to const" CErrorStr253 = 253, + // "cannot destroy const object" CErrorStr254 = 254, + // "const member '%u' is not initialized" CErrorStr255 = 255, + // "'&' reference member '%u' is not initialized" CErrorStr256 = 256, + // "RTTI option is disabled" CErrorStr257 = 257, + // "constness casted away" CErrorStr258 = 258, + // "illegal const/volatile '&' reference initialization" CErrorStr259 = 259, + // "inconsistent linkage: 'extern' object redeclared as 'static'" CErrorStr260 = 260, + // "unknown assembler instruction mnemonic" CErrorStr261 = 261, + // "local data > 224 bytes" CErrorStr262 = 262, + // "'%u' could not be assigned to a register" CErrorStr263 = 263, + // "illegal exception specification" CErrorStr264 = 264, + // "exception specification list mismatch" CErrorStr265 = 265, + // "the parameter(s) of the '%n' function must be immediate value(s)" CErrorStr266 = 266, + // "SOM classes can only inherit from other SOM based classes" CErrorStr267 = 267, + // "SOM classes inhertiance must be virtual" CErrorStr268 = 268, + // "SOM class data members must be private" CErrorStr269 = 269, + // "illegal SOM function overload '%o'" CErrorStr270 = 270, + // "no static members allowed in SOM classes" CErrorStr271 = 271, + // "no parameters allowed in SOM class constructors" CErrorStr272 = 272, + // "illegal SOM function parameters or return type" CErrorStr273 = 273, + // "SOM runtime function '%u' not defined (should be defined in somobj.hh)" CErrorStr274 = 274, + // "SOM runtime function '%u' has unexpected type" CErrorStr275 = 275, + // "'%u' is not a SOM class" CErrorStr276 = 276, + // "illegal use of #pragma outside of SOM class definition" CErrorStr277 = 277, + // "introduced method '%o' is not specified in release order list" CErrorStr278 = 278, + // "SOM class access qualification only allowed to direct parent or own class" CErrorStr279 = 279, + // "SOM class must have one non-inline member function" CErrorStr280 = 280, + // "SOM type '%u' undefined" CErrorStr281 = 281, + // "new SOM callstyle method '%o' must have explicit 'Environment *' parameter" CErrorStr282 = 282, + // "functions cannot return SOM classes" CErrorStr283 = 283, + // "functions cannot have SOM class arguments" CErrorStr284 = 284, + // "assignment is not supported for SOM classes" CErrorStr285 = 285, + // "sizeof() is not supported for SOM classes" CErrorStr286 = 286, + // "SOM classes cannot be class members" CErrorStr287 = 287, + // "global SOM class objects are not supported" CErrorStr288 = 288, + // "SOM class arrays are not supported" CErrorStr289 = 289, + // "'pointer to member' is not supported for SOM classes" CErrorStr290 = 290, + // "SOM class has no release order list" CErrorStr291 = 291, + // "'%u' is not an Objective-C class" CErrorStr292 = 292, + // "method '%m' redeclared" CErrorStr293 = 293, + // "undefined method '%m'" CErrorStr294 = 294, + // "class '%u' redeclared" CErrorStr295 = 295, + // "class '%u' redefined" CErrorStr296 = 296, + // "Objective-C type '%u' is undefined (should be defined in objc.h)" CErrorStr297 = 297, + // "Objective-C type '%u' has unexpected type" CErrorStr298 = 298, + // "method '%m' not defined" CErrorStr299 = 299, + // "method '%m' redefined" CErrorStr300 = 300, + // "illegal use of 'self'" CErrorStr301 = 301, + // "illegal use of 'super'" CErrorStr302 = 302, + // "illegal message receiver" CErrorStr303 = 303, + // "receiver cannot handle this message" CErrorStr304 = 304, + // "ambiguous message selector\nused: '%m'\nalso had: '%m'" CErrorStr305 = 305, + // "unknown message selector" CErrorStr306 = 306, + // "illegal use of Objective-C object" CErrorStr307 = 307, + // "protocol '%u' redefined" CErrorStr308 = 308, + // "protocol '%u' is undefined" CErrorStr309 = 309, + // "protocol '%u' is already in protocol list" CErrorStr310 = 310, + // "category '%u' redefined" CErrorStr311 = 311, + // "category '%u' is undefined" CErrorStr312 = 312, + // "illegal use of '%u'" CErrorStr313 = 313, + // "template too complex or recursive" CErrorStr314 = 314, + // "illegal return value in void/constructor/destructor function" CErrorStr315 = 315, + // "assigning a non-int numeric value to an unprototyped function" CErrorStr316 = 316, + // "implicit arithmetic conversion from '%t' to '%t'" CErrorStr317 = 317, + // "preprocessor #error directive" CErrorStr318 = 318, + // "ambiguous access to name found '%u' and '%u'" CErrorStr319 = 319, + // "illegal namespace" CErrorStr320 = 320, + // "illegal use of namespace name" CErrorStr321 = 321, + // "illegal name overloading" CErrorStr322 = 322, + // "instance variable list does not match @interface" CErrorStr323 = 323, + // "protocol list does not match @interface" CErrorStr324 = 324, + // "super class does not match @interface" CErrorStr325 = 325, + // "function result is a pointer/reference to an automatic variable" CErrorStr326 = 326, + // "cannot allocate initialized objects in the scratchpad" CErrorStr327 = 327, + // "illegal class member access" CErrorStr328 = 328, + // "data object '%o' redefined" CErrorStr329 = 329, + // "illegal access to local variable from other function" CErrorStr330 = 330, + // "illegal implicit member pointer conversion" CErrorStr331 = 331, + // "typename redefined" CErrorStr332 = 332, + // "object '%o' redefined" CErrorStr333 = 333, + // "'main' not defined as external 'int main()' function" CErrorStr334 = 334, + // "illegal explicit template specialization" CErrorStr335 = 335, + // "name has not been declared in namespace/class" CErrorStr336 = 336, + // "preprocessor #warning directive" CErrorStr337 = 337, + // "illegal use of asm inline function" CErrorStr338 = 338, + // "illegal use of C++ feature in EC++" CErrorStr339 = 339, + // "illegal use template argument dependent type 'T::%u'" CErrorStr340 = 340, + // "illegal use of alloca() in function argument" CErrorStr341 = 341, + // "inline function call '%o' not inlined" CErrorStr342 = 342, + // "inconsistent use of 'class' and 'struct' keywords" CErrorStr343 = 343, + // "illegal partial specialization" CErrorStr344 = 344, + // "illegal partial specialization argument list" CErrorStr345 = 345, + // "ambiguous use of partial specialization" CErrorStr346 = 346, + // "local classes shall not have member templates" CErrorStr347 = 347, + // "illegal template argument dependent expression" CErrorStr348 = 348, + // "implicit 'int' is no longer supported in C++" CErrorStr349 = 349, + // "%i pad byte(s) inserted after data member '%u'" CErrorStr350 = 350, + // "pure function '%o' is not virtual" CErrorStr351 = 351, + // "illegal virtual function '%o' in 'union'" CErrorStr352 = 352, + // "cannot pass 'void' or 'function' parameter" CErrorStr353 = 353, + // "illegal static const member '%u' initialization" CErrorStr354 = 354, + // "'typename' is missing in template argument dependent qualified type" CErrorStr355 = 355, + // "more than one expression in non-class type conversion" CErrorStr356 = 356, + // "template non-type argument objects shall have external linkage" CErrorStr357 = 357, + // "illegal inline assembly operand: %u" CErrorStr358 = 358, + // "illegal or unsupported __attribute__" CErrorStr359 = 359, + // "cannot create object file '%f'" CErrorStr360 = 360, + // "error writing to object file '%f'" CErrorStr361 = 361, + // "printf-family format string doesn't match arguments" CErrorStr362 = 362, + // "scanf-family format string doesn't match arguments" CErrorStr363 = 363, + // "__alignof__() is not supported for SOM classes" CErrorStr364 = 364, + // "illegal macro argument name '%u'" CErrorStr365 = 365, + // "case has an empty range of values" CErrorStr366 = 366, + // "'long long' switch() is not supported" CErrorStr367 = 367, + // "'long long' case range is not supported" CErrorStr368 = 368, + // "expression has no side effect" CErrorStr369 = 369, + // "result of function call is not used" CErrorStr370 = 370, + // "illegal non-type template argument" CErrorStr371 = 371, + // "illegal use of abstract class ('%t')" CErrorStr372 = 372, + // "illegal use of 'template' prefix" CErrorStr373 = 373, + // "template parameter/argument list mismatch" CErrorStr374 = 374, + // "cannot find matching deallocation function for '%t'" CErrorStr375 = 375, + // "illegal operand '%t'" CErrorStr376 = 376, + // "illegal operands '%t' %u '%t'" CErrorStr377 = 377, + // "illegal use of default template-argument" CErrorStr378 = 378, + // "illegal UUID syntax" CErrorStr379 = 379, + // "__uuidof() is not supported for SOM classes" CErrorStr380 = 380, + // "illegal access from '%t' to protected/private member '%o'" CErrorStr381 = 381, + // "integral type is not large enough to hold pointer" CErrorStr382 = 382, + // "unknown x86 assembler instruction mnemonic" CErrorStr383 = 383, + // "illegal use of const/volatile function qualifier sequence" CErrorStr384 = 384, + // "illegal optimization level for this limited version of CodeWarrior" CErrorStr385 = 385, + // "no UUID defined for type '%t'" CErrorStr386 = 386, + // "using implicit copy assigment for class with const or reference member ('%t')" CErrorStr387 = 387, + // "unimplemented assembler instruction/directive" CErrorStr388 = 388, + // "override of dllimport function '%u' only has application scope" CErrorStr389 = 389, + // "illegal combination of operands in inline statement at line %i" CErrorStr390 = 390, + // "illegal operand in inline statement at line %i" CErrorStr391 = 391, + // "function call '*' is ambiguous" CErrorStr392 = 392, CErrorStrMAX = 393 }; @@ -316,12 +609,12 @@ extern char cerror_synchdata[32]; extern short cerror_synchoffset; extern int CError_BreakPointcount; -extern void CError_Init(); +extern void CError_Init(void); extern void CError_SetErrorToken(TStreamElement *token); -extern void CError_SetNullErrorToken(); +extern void CError_SetNullErrorToken(void); extern void CError_LockErrorPos(TStreamElement *token, TStreamElement **saved); extern void CError_UnlockErrorPos(TStreamElement **saved); -extern void CError_ResetErrorSkip(); +extern void CError_ResetErrorSkip(void); extern void CError_GetErrorString(char *buf, short code); extern void CError_BufferInit(CErrorBuffer *eb, char *buf, SInt32 bufSize); extern void CError_BufferGrow(CErrorBuffer *eb, SInt32 amount); @@ -360,10 +653,10 @@ extern void CError_AbstractClassError(TypeClass *tclass); extern void CError_Warning(int code, ...); extern void CError_BreakPoint(const char *a, const char *b); extern void CError_Internal(char *filename, int line); -extern void CError_ExpressionTooComplex(); -extern void CError_NoMem(); -extern void CError_UserBreak(); -extern void CError_CannotOpen(); +extern void CError_ExpressionTooComplex(void); +extern void CError_NoMem(void); +extern void CError_UserBreak(void); +extern void CError_CannotOpen(void); extern void CError_QualifierCheck(UInt32 qual); #endif diff --git a/includes/compiler/CInline.h b/includes/compiler/CInline.h index 4fae90a..51abd45 100644 --- a/includes/compiler/CInline.h +++ b/includes/compiler/CInline.h @@ -115,7 +115,7 @@ typedef struct CI_Action { union { struct { FileOffsetInfo fileoffset; - TStream stream; + TokenStream stream; TypeClass *tclass; } inlinefunc; struct { @@ -151,7 +151,7 @@ extern SInt16 CInline_GetStatementNumber(Statement *first, Statement *stmt); extern void CInline_PackIFunctionData(CI_FuncData *packed, Statement *stmt, Object *object); extern void CInline_UnpackIFunctionData(Object *object, CI_FuncData *packed, Statement *firstStmt); extern void CInline_AddDefaultFunctionAction(Object *object); -extern void CInline_AddInlineFunctionAction(Object *object, TypeClass *tclass, FileOffsetInfo *fileoffset, TStream *stream, Boolean flag); +extern void CInline_AddInlineFunctionAction(Object *object, TypeClass *tclass, FileOffsetInfo *fileoffset, TokenStream *stream, Boolean flag); extern void CInline_AddMemberFunctionAction(Object *object, TemplClass *templ, TemplClassInst *inst, TemplateMember *tmemb); extern void CInline_AddTemplateFunctionAction(Object *object, TemplateFunction *func, TemplFuncInstance *inst); extern void CInline_ObjectAddrRef(Object *object); diff --git a/includes/compiler/CInt64.h b/includes/compiler/CInt64.h index dc8b51d..a0938e2 100644 --- a/includes/compiler/CInt64.h +++ b/includes/compiler/CInt64.h @@ -40,7 +40,7 @@ inline void CInt64_Extend32(CInt64 *n) { // assumed name n->hi = (n->lo >> 31) ? 0xFFFFFFFF : 0; } -extern void CInt64_Init(); +extern void CInt64_Init(void); extern CInt64 CInt64_Not(CInt64 input); extern CInt64 CInt64_Inv(CInt64 input); extern CInt64 CInt64_Add(CInt64 lhs, CInt64 rhs); diff --git a/includes/compiler/CMachine.h b/includes/compiler/CMachine.h index be763d5..72efcea 100644 --- a/includes/compiler/CMachine.h +++ b/includes/compiler/CMachine.h @@ -60,7 +60,7 @@ extern Boolean CMach_FloatIsNegOne(Float fval); extern void CMach_InitFloatMem(Type *type, Float val, void *mem); extern void CMach_PrintFloat(char *buf, Float val); extern void CMach_PragmaParams(void); -extern void CMach_AdjustFuntionArgs(void); +extern void CMach_AdjustFuntionArgs(/* unknown args */); extern SInt16 CMach_GetStructAlign(TypeStruct *tstruct); extern SInt16 CMach_GetClassAlign(TypeClass *tclass); extern SInt16 CMach_GetTypeAlign(Type *type); diff --git a/includes/compiler/CObjC.h b/includes/compiler/CObjC.h index cd7686d..30a16bb 100644 --- a/includes/compiler/CObjC.h +++ b/includes/compiler/CObjC.h @@ -30,7 +30,7 @@ extern void CObjC_ParseInterface(void); extern void CObjC_ParseImplementation(void); extern void CObjC_ParseProtocol(void); extern void CObjC_ParseClassDeclaration(void); -extern void *CObjC_ParseIdentifier(); +extern void *CObjC_ParseIdentifier(/* unknown args */); extern ENode *CObjC_MakeSendMsgExpr(ENode *objexpr, TypeClass *tclass, ObjCNamedArg *namedArgs, ENodeList *unnamedArgs, UInt8 calltype, Boolean isSuper); extern ENode *CObjC_ParseMessageExpression(void); extern ENode *CObjC_ParseEncodeExpression(void); diff --git a/includes/compiler/CPrec.h b/includes/compiler/CPrec.h index a2ac87c..38078ca 100644 --- a/includes/compiler/CPrec.h +++ b/includes/compiler/CPrec.h @@ -3,7 +3,9 @@ #include "compiler/common.h" -extern void SetupPrecompiler(void); +extern char *precomp_target_str; + +extern void SetupPrecompiler(Boolean isPrecompiling); extern void CleanupPrecompiler(void); extern void PreComp_StaticData(Object *obj, const void *data, OLinkList *links, SInt32 size); extern void PrecompilerWrite(void); diff --git a/includes/compiler/CPrep.h b/includes/compiler/CPrep.h index aeb341b..02d5a76 100644 --- a/includes/compiler/CPrep.h +++ b/includes/compiler/CPrep.h @@ -15,7 +15,7 @@ struct Macro { unsigned short xC; Boolean is_special; Boolean xF; - HashNameNode *names[1]; + HashNameNode *names[0]; }; typedef struct TokenStack { char *pos; @@ -25,7 +25,7 @@ typedef struct TokenStack { } TokenStack; //#define OPT_OFFSET(optname) ((short) (((char *) (&copts.optname)) - ((char *) &copts))) -#define OPT_OFFSET(optname) ((short) ( &((COpts *)0)->optname )) +#define OPT_OFFSET(optname) ((UInt16) ( &((COpts *)0)->optname )) enum { OPT_OFFSET_MASK = 0x1FFF, OPT_FLAG_2000 = 0x2000, @@ -89,11 +89,11 @@ extern void CPrep_UnLex(void); // this is actually an arg of `const PrepState *` extern void CPrep_TokenStreamSetCurState(SInt32 *state); typedef void (*CPrepStreamFuncPtr)(TStreamElement *); -extern void CPrep_StreamGetBlock(TStream *stream, CPrepStreamFuncPtr func, int arg); -extern void CPrep_StreamGetSemicolon(TStream *stream, CPrepStreamFuncPtr func); -extern void CPrep_StreamGetTemplate(TStream *stream, CPrepStreamFuncPtr func); -extern void CPrep_StreamInsert(TStream *stream, SInt32 *state); -extern void CPrep_StreamRemove(TStream *stream, SInt32 *state); +extern void CPrep_StreamGetBlock(TokenStream *stream, CPrepStreamFuncPtr func, int arg); +extern void CPrep_StreamGetSemicolon(TokenStream *stream, CPrepStreamFuncPtr func); +extern void CPrep_StreamGetTemplate(TokenStream *stream, CPrepStreamFuncPtr func); +extern void CPrep_StreamInsert(TokenStream *stream, SInt32 *state); +extern void CPrep_StreamRemove(TokenStream *stream, SInt32 *state); extern void CPrep_RemoveTokens(SInt32 amount); extern void CPrep_TokenStreamFlush(void); extern TStreamElement *CPrep_CurStreamElement(void); diff --git a/includes/compiler/CScope.h b/includes/compiler/CScope.h index f9ba72c..7a4c3de 100644 --- a/includes/compiler/CScope.h +++ b/includes/compiler/CScope.h @@ -97,7 +97,7 @@ extern NameSpaceObjectList *CScope_GetLocalObject(NameSpace *nspace, HashNameNod extern BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass); extern Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boolean flag); extern void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, HashNameNode *name, AccessType access); -extern void CScope_ParseUsingDeclaration(NameSpace *nspace, short access, Boolean flag); +extern void CScope_ParseUsingDeclaration(NameSpace *nspace, AccessType access, Boolean flag); extern void CScope_ParseNameSpaceAlias(HashNameNode *name); extern void CScope_ParseUsingDirective(NameSpace *nspace); diff --git a/includes/compiler/CTemplateClass.h b/includes/compiler/CTemplateClass.h index 4400480..12cd088 100644 --- a/includes/compiler/CTemplateClass.h +++ b/includes/compiler/CTemplateClass.h @@ -13,7 +13,7 @@ extern void CTemplClass_RegisterObjectInit(TemplClass *tmclass, Object *object, extern void CTemplClass_RegisterObjectDef(TemplClass *tmclass, ObjBase *refobj); extern void CTemplClass_CompleteClass(TemplClass *templ, DeclE *de); extern TemplClassInst *CTemplClass_GetInstance(TemplClass *tmclass, TemplArg *args1, TemplArg *args2); -extern TemplateMember *CTemplClass_DefineMember(TemplClass *tmclass, Object *object, FileOffsetInfo *foi, TStream *stream); +extern TemplateMember *CTemplClass_DefineMember(TemplClass *tmclass, Object *object, FileOffsetInfo *foi, TokenStream *stream); extern void CTemplClass_ParsePartialSpecialization(DeclFucker *what_is_this, TemplParam *params, short mode, SInt32 *offset); extern void CTemplClass_ParseClass(DeclFucker *what_is_this, TemplParam *params, short mode, SInt32 *offset); extern Boolean CTemplClass_FindPartialTemplate(TemplArg *args, TemplClass **resultTempl, TemplArg **resultArgs); diff --git a/includes/compiler/CompilerTools.h b/includes/compiler/CompilerTools.h index 82ef228..b218925 100644 --- a/includes/compiler/CompilerTools.h +++ b/includes/compiler/CompilerTools.h @@ -49,7 +49,7 @@ struct GList { extern long hash_name_id; extern HashNameNode **name_hash_nodes; -extern void (*GListErrorProc)(); +extern void (*GListErrorProc)(void); extern short InitGList(GList *gl, SInt32 size); extern void FreeGList(GList *gl); @@ -79,34 +79,34 @@ extern HashNameNode *GetHashNameNodeHash2(const char *name, SInt16 hashval); extern HashNameNode *GetHashNameNodeExport(const char *name); extern SInt32 GetHashNameNodeExportID(HashNameNode *node); extern HashNameNode *GetHashNameNodeByID(SInt32 id); -extern void NameHashExportReset(); +extern void NameHashExportReset(void); extern void NameHashWriteNameTable(GList *glist); extern void NameHashWriteTargetEndianNameTable(GList *glist); -extern void InitNameHash(); +extern void InitNameHash(void); -typedef void (*heaperror_t)(); +typedef void (*heaperror_t)(void); -extern SInt32 CTool_TotalHeapSize(); +extern SInt32 CTool_TotalHeapSize(void); extern void CTool_GetHeapInfo(HeapInfo *result, unsigned char heapID); extern short initheaps(heaperror_t heaperrorproc); extern short initgheap(heaperror_t heaperrorproc); -extern heaperror_t getheaperror(); +extern heaperror_t getheaperror(void); extern void setheaperror(heaperror_t heaperrorproc); -extern void releaseheaps(); -extern void releasegheap(); -extern void releaseoheap(); +extern void releaseheaps(void); +extern void releasegheap(void); +extern void releaseoheap(void); extern void *galloc(SInt32 s); extern void *lalloc(SInt32 s); extern void *aalloc(SInt32 s); extern void *oalloc(SInt32 s); extern void *balloc(SInt32 s); -extern void locklheap(); -extern void unlocklheap(); -extern void freelheap(); -extern void freeaheap(); -extern void freeoheap(); -extern void freebheap(); +extern void locklheap(void); +extern void unlocklheap(void); +extern void freelheap(void); +extern void freeaheap(void); +extern void freeoheap(void); +extern void freebheap(void); extern char *ScanHex(char *string, UInt32 *result, Boolean *overflow); extern char *ScanOct(char *string, UInt32 *result, Boolean *overflow); diff --git a/includes/compiler/ObjGenMachO.h b/includes/compiler/ObjGenMachO.h index 82c8650..edc4944 100644 --- a/includes/compiler/ObjGenMachO.h +++ b/includes/compiler/ObjGenMachO.h @@ -47,7 +47,7 @@ extern void ObjGen_SrcBreakName(HashNameNode *name, SInt32 fileModDate, Boolean extern GList *ObjGen_GetSectionGList(MachOSection *section); extern MachOSection *ObjGen_DeclareFunction(Object *object); extern MachOSection *ObjGen_DeclareCode(Object *object); -extern MachOSection *ObjGen_DeclareMachSection(); +extern MachOSection *ObjGen_DeclareMachSection(/* unknown args */); extern void ObjGen_Relocate(MachOSection *section, SInt32 offset, SInt32 relocID, RelocType relocType, MWReloc mwRelType); extern void ObjGen_RelocateObj(MachOSection *section, SInt32 offset, Object *object, MWReloc mwRelType); extern SInt32 ObjGen_DeclareLiteralString(UInt32 len, char *data, SInt32 align); @@ -68,7 +68,7 @@ extern void ObjGen_DeclareSymInfo(void); extern void ObjGen_Line(UInt32 line, UInt32 offset); extern void ObjGen_OutputDebugInfo(Object *funcobj); extern SInt32 ObjGen_OutputStab(SymbolData *symbol, SInt32 strIdx); -extern void ObjGen_SetSectName(); +extern void ObjGen_SetSectName(/* unknown args */); extern void ObjGen_DeclareInitFunction(Object *funcobj); extern Boolean ObjGen_IsExported(Object *object); diff --git a/includes/compiler/Operands.h b/includes/compiler/Operands.h index cd9c035..8808e60 100644 --- a/includes/compiler/Operands.h +++ b/includes/compiler/Operands.h @@ -61,15 +61,15 @@ extern void combine(Operand *opA, Operand *opB, short output_reg, Operand *opOut extern void coerce_to_addressable(Operand *op); extern void Coerce_to_register(Operand *op, Type *type, short output_reg); extern void coerce_to_register_pair(Operand *op, Type *type, short output_reg, short output_regHi); -extern void Coerce_to_fp_register(Operand *op, Type *tint, short output_reg); -extern void Coerce_to_v_register(Operand *op, Type *tstruct, short output_reg); +extern void Coerce_to_fp_register(Operand *op, Type *type, short output_reg); +extern void Coerce_to_v_register(Operand *op, Type *type, short output_reg); extern void store(short reg, Operand *op, Type *type); extern void store_pair(short reg, short regHi, Operand *op, Type *type); extern void store_fp(short reg, Operand *op, Type *tint); extern void store_v(short reg, Operand *op, Type *tstruct); extern void extend32(Operand *op, Type *type, short output_reg); extern void extend64(Operand *op, Type *type, short output_reg, short output_regHi); -extern void load_floating_constant(short reg, Type *type, double *data); +extern void load_floating_constant(short reg, Type *type, Float *data); extern void convert_integer_to_floating(Operand *op, Boolean is_single, short output_reg); extern void convert_unsigned_to_floating(Operand *op, Boolean is_single, short output_reg); extern void convert_floating_to_integer(Operand *op, short output_reg); diff --git a/includes/compiler/PCode.h b/includes/compiler/PCode.h index 9b6103b..97f652d 100644 --- a/includes/compiler/PCode.h +++ b/includes/compiler/PCode.h @@ -8,11 +8,11 @@ #pragma options align=mac68k #endif -#define FLAG_SET_T(flags) (((flags) & (fPCodeFlag1 | fPCodeFlag8)) ? (flags) : 0) -#define FLAG_SET_F(flags) (((flags) & (fPCodeFlag1 | fPCodeFlag8)) ? 0 : (flags)) +#define FLAG_SET_T(flags) (((flags) & (fIsBranch | fIsCall)) ? (flags) : 0) +#define FLAG_SET_F(flags) (((flags) & (fIsBranch | fIsCall)) ? 0 : (flags)) -#define PCODE_FLAG_SET_T(pcode) (((pcode)->flags & (fPCodeFlag1 | fPCodeFlag8)) ? (pcode)->flags : 0) -#define PCODE_FLAG_SET_F(pcode) (((pcode)->flags & (fPCodeFlag1 | fPCodeFlag8)) ? 0 : (pcode)->flags) +#define PCODE_FLAG_SET_T(pcode) (((pcode)->flags & (fIsBranch | fIsCall)) ? (pcode)->flags : 0) +#define PCODE_FLAG_SET_F(pcode) (((pcode)->flags & (fIsBranch | fIsCall)) ? 0 : (pcode)->flags) enum { EffectRead = 1, @@ -22,16 +22,6 @@ enum { Effect40 = 0x40 // spilled register? }; -/*typedef enum { - PCOp_REGISTER, - PCOp_SYSREG, - PCOp_IMMEDIATE, - PCOp_MEMORY, - PCOp_LABEL, - PCOp_LABELDIFF, - PCOp_PLACEHOLDEROPERAND -} PCOpKind;*/ - typedef enum { RefType_0, RefType_1, // like D, but 32-bit? @@ -158,12 +148,11 @@ struct PCodeBlock { /* PCode Flags */ enum { - fPCodeFlag1 = 1, // some kinds of branches - fPCodeFlag2 = 2, // read from memory - fPCodeFlag4 = 4, // write to memory - fPCodeFlag8 = 8, // other kinds of branches - fPCodeFlag10 = 0x10, // moves - fPCodeFlag20 = 0x20, // indexed operations + fIsBranch = 1, + fIsRead = 2, // read from memory + fIsWrite = 4, // write to memory + fIsCall = 8, + fIsMove = 0x10, // moves register (mcrf, mr, fmr, vmr, vmrp) // Always valid fIsConst = 0x40, fIsVolatile = 0x80, @@ -174,36 +163,39 @@ enum { fPCodeFlag1000 = 0x1000, // ? fCommutative = 0x2000, fIsCSE = 0x4000, - fPCodeFlag8000 = 0x8000, + fIsArgInit = 0x8000, // instruction that stores varargs from GPRs to the stack fPCodeFlag20000 = 0x20000, // some kinda load? fPCodeFlag40000 = 0x40000, // some kinda store? // Set 1 (branches) only fLink = 0x1000000, + fCanLink = 0x2000000, // is capable of being a link branch fBranchNotTaken = 0x4000000, fBranchTaken = 0x8000000, fAbsolute = 0x10000000, + fCanBeAbsolute = 0x20000000, // is capable of having fAbsolute set // Set 2 (non-branches) only fIsPtrOp = 0x20, + fPCodeFlag200000 = 0x200000, + fPCodeFlag400000 = 0x400000, fOverflow = 0x800000, + fUpdatesPtr = 0x2000000, // lbzu, lbzux, lwzu, stbu, stbux, etc + fCanSetCarry = 0x4000000, // is capable of having fSetsCarry set + fCanSetRecordBit = 0x8000000, // is capable of having fRecordBit set fSetsCarry = 0x10000000, - fPCodeFlag20000000 = 0x20000000, // record bit? - // ?? - fPCodeFlag2000000 = 0x2000000, - fPCodeFlag4000000 = 0x4000000, - fPCodeFlag8000000 = 0x8000000, - fPCodeFlag10000000 = 0x10000000, - fPCodeFlag40000000 = 0x40000000, - fPCodeFlag80000000 = 0x80000000, - fPCodeFlagC0000000 = 0xC0000000 + fRecordBit = 0x20000000, + fOpTypeFPR = 0x40000000, + fOpTypeGPR = 0x80000000, + fOpTypeVR = 0xC0000000, + fOpTypeMask = 0xC0000000 }; enum { - fPCBlockFlag1 = 1, // fIsProlog - fPCBlockFlag2 = 2, // fIsEpilogue - fPCBlockFlag4 = 4, // fVisited - fPCBlockFlag8 = 8, // fScheduled + fIsProlog = 1, // fIsProlog + fIsEpilogue = 2, // fIsEpilogue + fVisited = 4, // fVisited + fScheduled = 8, // fScheduled fPCBlockFlag10 = 0x10, // maybe fIsSwitch based off v3? - fPCBlockFlag20 = 0x20, // fDeleted + fDeleted = 0x20, fPCBlockFlag2000 = 0x2000, fPCBlockFlag4000 = 0x4000, fPCBlockFlag6000 = 0x6000, diff --git a/includes/compiler/PCodeInfo.h b/includes/compiler/PCodeInfo.h index b70211a..330a422 100644 --- a/includes/compiler/PCodeInfo.h +++ b/includes/compiler/PCodeInfo.h @@ -463,870 +463,9 @@ typedef enum Opcode { PC_RRIB = 0x1AB, OPCODE_MAX = 0x1AC } Opcode; -//#define PC_B 0x0 -//#define PC_BL 0x1 -//#define PC_BC 0x2 -//#define PC_BCLR 0x3 -//#define PC_BCCTR 0x4 -//#define PC_BT 0x5 -//#define PC_BTLR 0x6 -//#define PC_BTCTR 0x7 -//#define PC_BF 0x8 -//#define PC_BFLR 0x9 -//#define PC_BFCTR 0xA -//#define PC_BDNZ 0xB -//#define PC_BDNZT 0xC -//#define PC_BDNZF 0xD -//#define PC_BDZ 0xE -//#define PC_BDZT 0xF -//#define PC_BDZF 0x10 -//#define PC_BLR 0x11 -//#define PC_BCTR 0x12 -//#define PC_BCTRL 0x13 -//#define PC_BLRL 0x14 -//#define PC_LBZ 0x15 -//#define PC_LBZU 0x16 -//#define PC_LBZX 0x17 -//#define PC_LBZUX 0x18 -//#define PC_LHZ 0x19 -//#define PC_LHZU 0x1A -//#define PC_LHZX 0x1B -//#define PC_LHZUX 0x1C -//#define PC_LHA 0x1D -//#define PC_LHAU 0x1E -//#define PC_LHAX 0x1F -//#define PC_LHAUX 0x20 -//#define PC_LHBRX 0x21 -//#define PC_LWZ 0x22 -//#define PC_LWZU 0x23 -//#define PC_LWZX 0x24 -//#define PC_LWZUX 0x25 -//#define PC_LWBRX 0x26 -//#define PC_LMW 0x27 -//#define PC_STB 0x28 -//#define PC_STBU 0x29 -//#define PC_STBX 0x2A -//#define PC_STBUX 0x2B -//#define PC_STH 0x2C -//#define PC_STHU 0x2D -//#define PC_STHX 0x2E -//#define PC_STHUX 0x2F -//#define PC_STHBRX 0x30 -//#define PC_STW 0x31 -//#define PC_STWU 0x32 -//#define PC_STWX 0x33 -//#define PC_STWUX 0x34 -//#define PC_STWBRX 0x35 -//#define PC_STMW 0x36 -//#define PC_DCBF 0x37 -//#define PC_DCBST 0x38 -//#define PC_DCBT 0x39 -//#define PC_DCBTST 0x3A -//#define PC_DCBZ 0x3B -//#define PC_ADD 0x3C -//#define PC_ADDC 0x3D -//#define PC_ADDE 0x3E -//#define PC_ADDI 0x3F -//#define PC_ADDIC 0x40 -//#define PC_ADDICR 0x41 -//#define PC_ADDIS 0x42 -//#define PC_ADDME 0x43 -//#define PC_ADDZE 0x44 -//#define PC_DIVW 0x45 -//#define PC_DIVWU 0x46 -//#define PC_MULHW 0x47 -//#define PC_MULHWU 0x48 -//#define PC_MULLI 0x49 -//#define PC_MULLW 0x4A -//#define PC_NEG 0x4B -//#define PC_SUBF 0x4C -//#define PC_SUBFC 0x4D -//#define PC_SUBFE 0x4E -//#define PC_SUBFIC 0x4F -//#define PC_SUBFME 0x50 -//#define PC_SUBFZE 0x51 -//#define PC_CMPI 0x52 -//#define PC_CMP 0x53 -//#define PC_CMPLI 0x54 -//#define PC_CMPL 0x55 -//#define PC_ANDI 0x56 -//#define PC_ANDIS 0x57 -//#define PC_ORI 0x58 -//#define PC_ORIS 0x59 -//#define PC_XORI 0x5A -//#define PC_XORIS 0x5B -//#define PC_AND 0x5C -//#define PC_OR 0x5D -//#define PC_XOR 0x5E -//#define PC_NAND 0x5F -//#define PC_NOR 0x60 -//#define PC_EQV 0x61 -//#define PC_ANDC 0x62 -//#define PC_ORC 0x63 -//#define PC_EXTSB 0x64 -//#define PC_EXTSH 0x65 -//#define PC_CNTLZW 0x66 -//#define PC_RLWINM 0x67 -//#define PC_RLWNM 0x68 -//#define PC_RLWIMI 0x69 -//#define PC_SLW 0x6A -//#define PC_SRW 0x6B -//#define PC_SRAWI 0x6C -//#define PC_SRAW 0x6D -//#define PC_CRAND 0x6E -//#define PC_CRANDC 0x6F -//#define PC_CREQV 0x70 -//#define PC_CRNAND 0x71 -//#define PC_CRNOR 0x72 -//#define PC_CROR 0x73 -//#define PC_CRORC 0x74 -//#define PC_CRXOR 0x75 -//#define PC_MCRF 0x76 -//#define PC_MTXER 0x77 -//#define PC_MTCTR 0x78 -//#define PC_MTLR 0x79 -//#define PC_MTCRF 0x7A -//#define PC_MTMSR 0x7B -//#define PC_MTSPR 0x7C -//#define PC_MFMSR 0x7D -//#define PC_MFSPR 0x7E -//#define PC_MFXER 0x7F -//#define PC_MFCTR 0x80 -//#define PC_MFLR 0x81 -//#define PC_MFCR 0x82 -//#define PC_MFFS 0x83 -//#define PC_MTFSF 0x84 -//#define PC_EIEIO 0x85 -//#define PC_ISYNC 0x86 -//#define PC_SYNC 0x87 -//#define PC_RFI 0x88 -//#define PC_LI 0x89 -//#define PC_LIS 0x8A -//#define PC_MR 0x8B -//#define PC_NOP 0x8C -//#define PC_NOT 0x8D -//#define PC_LFS 0x8E -//#define PC_LFSU 0x8F -//#define PC_LFSX 0x90 -//#define PC_LFSUX 0x91 -//#define PC_LFD 0x92 -//#define PC_LFDU 0x93 -//#define PC_LFDX 0x94 -//#define PC_LFDUX 0x95 -//#define PC_STFS 0x96 -//#define PC_STFSU 0x97 -//#define PC_STFSX 0x98 -//#define PC_STFSUX 0x99 -//#define PC_STFD 0x9A -//#define PC_STFDU 0x9B -//#define PC_STFDX 0x9C -//#define PC_STFDUX 0x9D -//#define PC_FMR 0x9E -//#define PC_FABS 0x9F -//#define PC_FNEG 0xA0 -//#define PC_FNABS 0xA1 -//#define PC_FADD 0xA2 -//#define PC_FADDS 0xA3 -//#define PC_FSUB 0xA4 -//#define PC_FSUBS 0xA5 -//#define PC_FMUL 0xA6 -//#define PC_FMULS 0xA7 -//#define PC_FDIV 0xA8 -//#define PC_FDIVS 0xA9 -//#define PC_FMADD 0xAA -//#define PC_FMADDS 0xAB -//#define PC_FMSUB 0xAC -//#define PC_FMSUBS 0xAD -//#define PC_FNMADD 0xAE -//#define PC_FNMADDS 0xAF -//#define PC_FNMSUB 0xB0 -//#define PC_FNMSUBS 0xB1 -//#define PC_FRES 0xB2 -//#define PC_FRSQRTE 0xB3 -//#define PC_FSEL 0xB4 -//#define PC_FRSP 0xB5 -//#define PC_FCTIW 0xB6 -//#define PC_FCTIWZ 0xB7 -//#define PC_FCMPU 0xB8 -//#define PC_FCMPO 0xB9 -//#define PC_LWARX 0xBA -//#define PC_LSWI 0xBB -//#define PC_LSWX 0xBC -//#define PC_STFIWX 0xBD -//#define PC_STSWI 0xBE -//#define PC_STSWX 0xBF -//#define PC_STWCX 0xC0 -//#define PC_ECIWX 0xC1 -//#define PC_ECOWX 0xC2 -//#define PC_DCBI 0xC3 -//#define PC_ICBI 0xC4 -//#define PC_MCRFS 0xC5 -//#define PC_MCRXR 0xC6 -//#define PC_MFTB 0xC7 -//#define PC_MFSR 0xC8 -//#define PC_MTSR 0xC9 -//#define PC_MFSRIN 0xCA -//#define PC_MTSRIN 0xCB -//#define PC_MTFSB0 0xCC -//#define PC_MTFSB1 0xCD -//#define PC_MTFSFI 0xCE -//#define PC_SC 0xCF -//#define PC_FSQRT 0xD0 -//#define PC_FSQRTS 0xD1 -//#define PC_TLBIA 0xD2 -//#define PC_TLBIE 0xD3 -//#define PC_TLBLD 0xD4 -//#define PC_TLBLI 0xD5 -//#define PC_TLBSYNC 0xD6 -//#define PC_TW 0xD7 -//#define PC_TRAP 0xD8 -//#define PC_TWI 0xD9 -//#define PC_OPWORD 0xDA -//#define PC_MFROM 0xDB -//#define PC_DSA 0xDC -//#define PC_ESA 0xDD -//#define PC_DCCCI 0xDE -//#define PC_DCREAD 0xDF -//#define PC_ICBT 0xE0 -//#define PC_ICCCI 0xE1 -//#define PC_ICREAD 0xE2 -//#define PC_RFCI 0xE3 -//#define PC_TLBRE 0xE4 -//#define PC_TLBSX 0xE5 -//#define PC_TLBWE 0xE6 -//#define PC_WRTEE 0xE7 -//#define PC_WRTEEI 0xE8 -//#define PC_MFDCR 0xE9 -//#define PC_MTDCR 0xEA -//#define PC_DCBA 0xEB -//#define PC_DSS 0xEC -//#define PC_DSSALL 0xED -//#define PC_DST 0xEE -//#define PC_DSTT 0xEF -//#define PC_DSTST 0xF0 -//#define PC_DSTSTT 0xF1 -//#define PC_LVEBX 0xF2 -//#define PC_LVEHX 0xF3 -//#define PC_LVEWX 0xF4 -//#define PC_LVSL 0xF5 -//#define PC_LVSR 0xF6 -//#define PC_LVX 0xF7 -//#define PC_LVXL 0xF8 -//#define PC_STVEBX 0xF9 -//#define PC_STVEHX 0xFA -//#define PC_STVEWX 0xFB -//#define PC_STVX 0xFC -//#define PC_STVXL 0xFD -//#define PC_MFVSCR 0xFE -//#define PC_MTVSCR 0xFF -//#define PC_VADDCUW 0x100 -//#define PC_VADDFP 0x101 -//#define PC_VADDSBS 0x102 -//#define PC_VADDSHS 0x103 -//#define PC_VADDSWS 0x104 -//#define PC_VADDUBM 0x105 -//#define PC_VADDUBS 0x106 -//#define PC_VADDUHM 0x107 -//#define PC_VADDUHS 0x108 -//#define PC_VADDUWM 0x109 -//#define PC_VADDUWS 0x10A -//#define PC_VAND 0x10B -//#define PC_VANDC 0x10C -//#define PC_VAVGSB 0x10D -//#define PC_VAVGSH 0x10E -//#define PC_VAVGSW 0x10F -//#define PC_VAVGUB 0x110 -//#define PC_VAVGUH 0x111 -//#define PC_VAVGUW 0x112 -//#define PC_VCFSX 0x113 -//#define PC_VCFUX 0x114 -//#define PC_VCMPBFP 0x115 -//#define PC_VCMPEQFP 0x116 -//#define PC_VCMPEQUB 0x117 -//#define PC_VCMPEQUH 0x118 -//#define PC_VCMPEQUW 0x119 -//#define PC_VCMPGEFP 0x11A -//#define PC_VCMPGTFP 0x11B -//#define PC_VCMPGTSB 0x11C -//#define PC_VCMPGTSH 0x11D -//#define PC_VCMPGTSW 0x11E -//#define PC_VCMPGTUB 0x11F -//#define PC_VCMPGTUH 0x120 -//#define PC_VCMPGTUW 0x121 -//#define PC_VCTSXS 0x122 -//#define PC_VCTUXS 0x123 -//#define PC_VEXPTEFP 0x124 -//#define PC_VLOGEFP 0x125 -//#define PC_VMAXFP 0x126 -//#define PC_VMAXSB 0x127 -//#define PC_VMAXSH 0x128 -//#define PC_VMAXSW 0x129 -//#define PC_VMAXUB 0x12A -//#define PC_VMAXUH 0x12B -//#define PC_VMAXUW 0x12C -//#define PC_VMINFP 0x12D -//#define PC_VMINSB 0x12E -//#define PC_VMINSH 0x12F -//#define PC_VMINSW 0x130 -//#define PC_VMINUB 0x131 -//#define PC_VMINUH 0x132 -//#define PC_VMINUW 0x133 -//#define PC_VMRGHB 0x134 -//#define PC_VMRGHH 0x135 -//#define PC_VMRGHW 0x136 -//#define PC_VMRGLB 0x137 -//#define PC_VMRGLH 0x138 -//#define PC_VMRGLW 0x139 -//#define PC_VMULESB 0x13A -//#define PC_VMULESH 0x13B -//#define PC_VMULEUB 0x13C -//#define PC_VMULEUH 0x13D -//#define PC_VMULOSB 0x13E -//#define PC_VMULOSH 0x13F -//#define PC_VMULOUB 0x140 -//#define PC_VMULOUH 0x141 -//#define PC_VNOR 0x142 -//#define PC_VOR 0x143 -//#define PC_VPKPX 0x144 -//#define PC_VPKSHSS 0x145 -//#define PC_VPKSHUS 0x146 -//#define PC_VPKSWSS 0x147 -//#define PC_VPKSWUS 0x148 -//#define PC_VPKUHUM 0x149 -//#define PC_VPKUHUS 0x14A -//#define PC_VPKUWUM 0x14B -//#define PC_VPKUWUS 0x14C -//#define PC_VREFP 0x14D -//#define PC_VRFIM 0x14E -//#define PC_VRFIN 0x14F -//#define PC_VRFIP 0x150 -//#define PC_VRFIZ 0x151 -//#define PC_VRLB 0x152 -//#define PC_VRLH 0x153 -//#define PC_VRLW 0x154 -//#define PC_VRSQRTEFP 0x155 -//#define PC_VSL 0x156 -//#define PC_VSLB 0x157 -//#define PC_VSLH 0x158 -//#define PC_VSLO 0x159 -//#define PC_VSLW 0x15A -//#define PC_VSPLTB 0x15B -//#define PC_VSPLTH 0x15C -//#define PC_VSPLTW 0x15D -//#define PC_VSPLTISB 0x15E -//#define PC_VSPLTISH 0x15F -//#define PC_VSPLTISW 0x160 -//#define PC_VSR 0x161 -//#define PC_VSRAB 0x162 -//#define PC_VSRAH 0x163 -//#define PC_VSRAW 0x164 -//#define PC_VSRB 0x165 -//#define PC_VSRH 0x166 -//#define PC_VSRO 0x167 -//#define PC_VSRW 0x168 -//#define PC_VSUBCUW 0x169 -//#define PC_VSUBFP 0x16A -//#define PC_VSUBSBS 0x16B -//#define PC_VSUBSHS 0x16C -//#define PC_VSUBSWS 0x16D -//#define PC_VSUBUBM 0x16E -//#define PC_VSUBUBS 0x16F -//#define PC_VSUBUHM 0x170 -//#define PC_VSUBUHS 0x171 -//#define PC_VSUBUWM 0x172 -//#define PC_VSUBUWS 0x173 -//#define PC_VSUMSWS 0x174 -//#define PC_VSUM2SWS 0x175 -//#define PC_VSUM4SBS 0x176 -//#define PC_VSUM4SHS 0x177 -//#define PC_VSUM4UBS 0x178 -//#define PC_VUPKHPX 0x179 -//#define PC_VUPKHSB 0x17A -//#define PC_VUPKHSH 0x17B -//#define PC_VUPKLPX 0x17C -//#define PC_VUPKLSB 0x17D -//#define PC_VUPKLSH 0x17E -//#define PC_VXOR 0x17F -//#define PC_VMADDFP 0x180 -//#define PC_VMHADDSHS 0x181 -//#define PC_VMHRADDSHS 0x182 -//#define PC_VMLADDUHM 0x183 -//#define PC_VMSUMMBM 0x184 -//#define PC_VMSUMSHM 0x185 -//#define PC_VMSUMSHS 0x186 -//#define PC_VMSUMUBM 0x187 -//#define PC_VMSUMUHM 0x188 -//#define PC_VMSUMUHS 0x189 -//#define PC_VNMSUBFP 0x18A -//#define PC_VPERM 0x18B -//#define PC_VSEL 0x18C -//#define PC_VSLDOI 0x18D -//#define PC_VMR 0x18E -//#define PC_VMRP 0x18F -//#define PC_SLE 0x190 -//#define PC_SLEQ 0x191 -//#define PC_SLIQ 0x192 -//#define PC_SLLIQ 0x193 -//#define PC_SLLQ 0x194 -//#define PC_SLQ 0x195 -//#define PC_SRAIQ 0x196 -//#define PC_SRAQ 0x197 -//#define PC_SRE 0x198 -//#define PC_SREA 0x199 -//#define PC_SREQ 0x19A -//#define PC_SRIQ 0x19B -//#define PC_SRLIQ 0x19C -//#define PC_SRLQ 0x19D -//#define PC_SRQ 0x19E -//#define PC_MASKG 0x19F -//#define PC_MASKIR 0x1A0 -//#define PC_LSCBX 0x1A1 -//#define PC_DIV 0x1A2 -//#define PC_DIVS 0x1A3 -//#define PC_DOZ 0x1A4 -//#define PC_MUL 0x1A5 -//#define PC_NABS 0x1A6 -//#define PC_ABS 0x1A7 -//#define PC_CLCS 0x1A8 -//#define PC_DOZI 0x1A9 -//#define PC_RLMI 0x1AA -//#define PC_RRIB 0x1AB -//#define PC_PENTRY 0x1AC -//#define PC_PEXIT 0x1AD -//#define OPCODE_MAX 0x1AE -//const short PC_B = 0x0; -//const short PC_BL = 0x1; -//const short PC_BC = 0x2; -//const short PC_BCLR = 0x3; -//const short PC_BCCTR = 0x4; -//const short PC_BT = 0x5; -//const short PC_BTLR = 0x6; -//const short PC_BTCTR = 0x7; -//const short PC_BF = 0x8; -//const short PC_BFLR = 0x9; -//const short PC_BFCTR = 0xA; -//const short PC_BDNZ = 0xB; -//const short PC_BDNZT = 0xC; -//const short PC_BDNZF = 0xD; -//const short PC_BDZ = 0xE; -//const short PC_BDZT = 0xF; -//const short PC_BDZF = 0x10; -//const short PC_BLR = 0x11; -//const short PC_BCTR = 0x12; -//const short PC_BCTRL = 0x13; -//const short PC_BLRL = 0x14; -//const short PC_LBZ = 0x15; -//const short PC_LBZU = 0x16; -//const short PC_LBZX = 0x17; -//const short PC_LBZUX = 0x18; -//const short PC_LHZ = 0x19; -//const short PC_LHZU = 0x1A; -//const short PC_LHZX = 0x1B; -//const short PC_LHZUX = 0x1C; -//const short PC_LHA = 0x1D; -//const short PC_LHAU = 0x1E; -//const short PC_LHAX = 0x1F; -//const short PC_LHAUX = 0x20; -//const short PC_LHBRX = 0x21; -//const short PC_LWZ = 0x22; -//const short PC_LWZU = 0x23; -//const short PC_LWZX = 0x24; -//const short PC_LWZUX = 0x25; -//const short PC_LWBRX = 0x26; -//const short PC_LMW = 0x27; -//const short PC_STB = 0x28; -//const short PC_STBU = 0x29; -//const short PC_STBX = 0x2A; -//const short PC_STBUX = 0x2B; -//const short PC_STH = 0x2C; -//const short PC_STHU = 0x2D; -//const short PC_STHX = 0x2E; -//const short PC_STHUX = 0x2F; -//const short PC_STHBRX = 0x30; -//const short PC_STW = 0x31; -//const short PC_STWU = 0x32; -//const short PC_STWX = 0x33; -//const short PC_STWUX = 0x34; -//const short PC_STWBRX = 0x35; -//const short PC_STMW = 0x36; -//const short PC_DCBF = 0x37; -//const short PC_DCBST = 0x38; -//const short PC_DCBT = 0x39; -//const short PC_DCBTST = 0x3A; -//const short PC_DCBZ = 0x3B; -//const short PC_ADD = 0x3C; -//const short PC_ADDC = 0x3D; -//const short PC_ADDE = 0x3E; -//const short PC_ADDI = 0x3F; -//const short PC_ADDIC = 0x40; -//const short PC_ADDICR = 0x41; -//const short PC_ADDIS = 0x42; -//const short PC_ADDME = 0x43; -//const short PC_ADDZE = 0x44; -//const short PC_DIVW = 0x45; -//const short PC_DIVWU = 0x46; -//const short PC_MULHW = 0x47; -//const short PC_MULHWU = 0x48; -//const short PC_MULLI = 0x49; -//const short PC_MULLW = 0x4A; -//const short PC_NEG = 0x4B; -//const short PC_SUBF = 0x4C; -//const short PC_SUBFC = 0x4D; -//const short PC_SUBFE = 0x4E; -//const short PC_SUBFIC = 0x4F; -//const short PC_SUBFME = 0x50; -//const short PC_SUBFZE = 0x51; -//const short PC_CMPI = 0x52; -//const short PC_CMP = 0x53; -//const short PC_CMPLI = 0x54; -//const short PC_CMPL = 0x55; -//const short PC_ANDI = 0x56; -//const short PC_ANDIS = 0x57; -//const short PC_ORI = 0x58; -//const short PC_ORIS = 0x59; -//const short PC_XORI = 0x5A; -//const short PC_XORIS = 0x5B; -//const short PC_AND = 0x5C; -//const short PC_OR = 0x5D; -//const short PC_XOR = 0x5E; -//const short PC_NAND = 0x5F; -//const short PC_NOR = 0x60; -//const short PC_EQV = 0x61; -//const short PC_ANDC = 0x62; -//const short PC_ORC = 0x63; -//const short PC_EXTSB = 0x64; -//const short PC_EXTSH = 0x65; -//const short PC_CNTLZW = 0x66; -//const short PC_RLWINM = 0x67; -//const short PC_RLWNM = 0x68; -//const short PC_RLWIMI = 0x69; -//const short PC_SLW = 0x6A; -//const short PC_SRW = 0x6B; -//const short PC_SRAWI = 0x6C; -//const short PC_SRAW = 0x6D; -//const short PC_CRAND = 0x6E; -//const short PC_CRANDC = 0x6F; -//const short PC_CREQV = 0x70; -//const short PC_CRNAND = 0x71; -//const short PC_CRNOR = 0x72; -//const short PC_CROR = 0x73; -//const short PC_CRORC = 0x74; -//const short PC_CRXOR = 0x75; -//const short PC_MCRF = 0x76; -//const short PC_MTXER = 0x77; -//const short PC_MTCTR = 0x78; -//const short PC_MTLR = 0x79; -//const short PC_MTCRF = 0x7A; -//const short PC_MTMSR = 0x7B; -//const short PC_MTSPR = 0x7C; -//const short PC_MFMSR = 0x7D; -//const short PC_MFSPR = 0x7E; -//const short PC_MFXER = 0x7F; -//const short PC_MFCTR = 0x80; -//const short PC_MFLR = 0x81; -//const short PC_MFCR = 0x82; -//const short PC_MFFS = 0x83; -//const short PC_MTFSF = 0x84; -//const short PC_EIEIO = 0x85; -//const short PC_ISYNC = 0x86; -//const short PC_SYNC = 0x87; -//const short PC_RFI = 0x88; -//const short PC_LI = 0x89; -//const short PC_LIS = 0x8A; -//const short PC_MR = 0x8B; -//const short PC_NOP = 0x8C; -//const short PC_NOT = 0x8D; -//const short PC_LFS = 0x8E; -//const short PC_LFSU = 0x8F; -//const short PC_LFSX = 0x90; -//const short PC_LFSUX = 0x91; -//const short PC_LFD = 0x92; -//const short PC_LFDU = 0x93; -//const short PC_LFDX = 0x94; -//const short PC_LFDUX = 0x95; -//const short PC_STFS = 0x96; -//const short PC_STFSU = 0x97; -//const short PC_STFSX = 0x98; -//const short PC_STFSUX = 0x99; -//const short PC_STFD = 0x9A; -//const short PC_STFDU = 0x9B; -//const short PC_STFDX = 0x9C; -//const short PC_STFDUX = 0x9D; -//const short PC_FMR = 0x9E; -//const short PC_FABS = 0x9F; -//const short PC_FNEG = 0xA0; -//const short PC_FNABS = 0xA1; -//const short PC_FADD = 0xA2; -//const short PC_FADDS = 0xA3; -//const short PC_FSUB = 0xA4; -//const short PC_FSUBS = 0xA5; -//const short PC_FMUL = 0xA6; -//const short PC_FMULS = 0xA7; -//const short PC_FDIV = 0xA8; -//const short PC_FDIVS = 0xA9; -//const short PC_FMADD = 0xAA; -//const short PC_FMADDS = 0xAB; -//const short PC_FMSUB = 0xAC; -//const short PC_FMSUBS = 0xAD; -//const short PC_FNMADD = 0xAE; -//const short PC_FNMADDS = 0xAF; -//const short PC_FNMSUB = 0xB0; -//const short PC_FNMSUBS = 0xB1; -//const short PC_FRES = 0xB2; -//const short PC_FRSQRTE = 0xB3; -//const short PC_FSEL = 0xB4; -//const short PC_FRSP = 0xB5; -//const short PC_FCTIW = 0xB6; -//const short PC_FCTIWZ = 0xB7; -//const short PC_FCMPU = 0xB8; -//const short PC_FCMPO = 0xB9; -//const short PC_LWARX = 0xBA; -//const short PC_LSWI = 0xBB; -//const short PC_LSWX = 0xBC; -//const short PC_STFIWX = 0xBD; -//const short PC_STSWI = 0xBE; -//const short PC_STSWX = 0xBF; -//const short PC_STWCX = 0xC0; -//const short PC_ECIWX = 0xC1; -//const short PC_ECOWX = 0xC2; -//const short PC_DCBI = 0xC3; -//const short PC_ICBI = 0xC4; -//const short PC_MCRFS = 0xC5; -//const short PC_MCRXR = 0xC6; -//const short PC_MFTB = 0xC7; -//const short PC_MFSR = 0xC8; -//const short PC_MTSR = 0xC9; -//const short PC_MFSRIN = 0xCA; -//const short PC_MTSRIN = 0xCB; -//const short PC_MTFSB0 = 0xCC; -//const short PC_MTFSB1 = 0xCD; -//const short PC_MTFSFI = 0xCE; -//const short PC_SC = 0xCF; -//const short PC_FSQRT = 0xD0; -//const short PC_FSQRTS = 0xD1; -//const short PC_TLBIA = 0xD2; -//const short PC_TLBIE = 0xD3; -//const short PC_TLBLD = 0xD4; -//const short PC_TLBLI = 0xD5; -//const short PC_TLBSYNC = 0xD6; -//const short PC_TW = 0xD7; -//const short PC_TRAP = 0xD8; -//const short PC_TWI = 0xD9; -//const short PC_OPWORD = 0xDA; -//const short PC_MFROM = 0xDB; -//const short PC_DSA = 0xDC; -//const short PC_ESA = 0xDD; -//const short PC_DCCCI = 0xDE; -//const short PC_DCREAD = 0xDF; -//const short PC_ICBT = 0xE0; -//const short PC_ICCCI = 0xE1; -//const short PC_ICREAD = 0xE2; -//const short PC_RFCI = 0xE3; -//const short PC_TLBRE = 0xE4; -//const short PC_TLBSX = 0xE5; -//const short PC_TLBWE = 0xE6; -//const short PC_WRTEE = 0xE7; -//const short PC_WRTEEI = 0xE8; -//const short PC_MFDCR = 0xE9; -//const short PC_MTDCR = 0xEA; -//const short PC_DCBA = 0xEB; -//const short PC_DSS = 0xEC; -//const short PC_DSSALL = 0xED; -//const short PC_DST = 0xEE; -//const short PC_DSTT = 0xEF; -//const short PC_DSTST = 0xF0; -//const short PC_DSTSTT = 0xF1; -//const short PC_LVEBX = 0xF2; -//const short PC_LVEHX = 0xF3; -//const short PC_LVEWX = 0xF4; -//const short PC_LVSL = 0xF5; -//const short PC_LVSR = 0xF6; -//const short PC_LVX = 0xF7; -//const short PC_LVXL = 0xF8; -//const short PC_STVEBX = 0xF9; -//const short PC_STVEHX = 0xFA; -//const short PC_STVEWX = 0xFB; -//const short PC_STVX = 0xFC; -//const short PC_STVXL = 0xFD; -//const short PC_MFVSCR = 0xFE; -//const short PC_MTVSCR = 0xFF; -//const short PC_VADDCUW = 0x100; -//const short PC_VADDFP = 0x101; -//const short PC_VADDSBS = 0x102; -//const short PC_VADDSHS = 0x103; -//const short PC_VADDSWS = 0x104; -//const short PC_VADDUBM = 0x105; -//const short PC_VADDUBS = 0x106; -//const short PC_VADDUHM = 0x107; -//const short PC_VADDUHS = 0x108; -//const short PC_VADDUWM = 0x109; -//const short PC_VADDUWS = 0x10A; -//const short PC_VAND = 0x10B; -//const short PC_VANDC = 0x10C; -//const short PC_VAVGSB = 0x10D; -//const short PC_VAVGSH = 0x10E; -//const short PC_VAVGSW = 0x10F; -//const short PC_VAVGUB = 0x110; -//const short PC_VAVGUH = 0x111; -//const short PC_VAVGUW = 0x112; -//const short PC_VCFSX = 0x113; -//const short PC_VCFUX = 0x114; -//const short PC_VCMPBFP = 0x115; -//const short PC_VCMPEQFP = 0x116; -//const short PC_VCMPEQUB = 0x117; -//const short PC_VCMPEQUH = 0x118; -//const short PC_VCMPEQUW = 0x119; -//const short PC_VCMPGEFP = 0x11A; -//const short PC_VCMPGTFP = 0x11B; -//const short PC_VCMPGTSB = 0x11C; -//const short PC_VCMPGTSH = 0x11D; -//const short PC_VCMPGTSW = 0x11E; -//const short PC_VCMPGTUB = 0x11F; -//const short PC_VCMPGTUH = 0x120; -//const short PC_VCMPGTUW = 0x121; -//const short PC_VCTSXS = 0x122; -//const short PC_VCTUXS = 0x123; -//const short PC_VEXPTEFP = 0x124; -//const short PC_VLOGEFP = 0x125; -//const short PC_VMAXFP = 0x126; -//const short PC_VMAXSB = 0x127; -//const short PC_VMAXSH = 0x128; -//const short PC_VMAXSW = 0x129; -//const short PC_VMAXUB = 0x12A; -//const short PC_VMAXUH = 0x12B; -//const short PC_VMAXUW = 0x12C; -//const short PC_VMINFP = 0x12D; -//const short PC_VMINSB = 0x12E; -//const short PC_VMINSH = 0x12F; -//const short PC_VMINSW = 0x130; -//const short PC_VMINUB = 0x131; -//const short PC_VMINUH = 0x132; -//const short PC_VMINUW = 0x133; -//const short PC_VMRGHB = 0x134; -//const short PC_VMRGHH = 0x135; -//const short PC_VMRGHW = 0x136; -//const short PC_VMRGLB = 0x137; -//const short PC_VMRGLH = 0x138; -//const short PC_VMRGLW = 0x139; -//const short PC_VMULESB = 0x13A; -//const short PC_VMULESH = 0x13B; -//const short PC_VMULEUB = 0x13C; -//const short PC_VMULEUH = 0x13D; -//const short PC_VMULOSB = 0x13E; -//const short PC_VMULOSH = 0x13F; -//const short PC_VMULOUB = 0x140; -//const short PC_VMULOUH = 0x141; -//const short PC_VNOR = 0x142; -//const short PC_VOR = 0x143; -//const short PC_VPKPX = 0x144; -//const short PC_VPKSHSS = 0x145; -//const short PC_VPKSHUS = 0x146; -//const short PC_VPKSWSS = 0x147; -//const short PC_VPKSWUS = 0x148; -//const short PC_VPKUHUM = 0x149; -//const short PC_VPKUHUS = 0x14A; -//const short PC_VPKUWUM = 0x14B; -//const short PC_VPKUWUS = 0x14C; -//const short PC_VREFP = 0x14D; -//const short PC_VRFIM = 0x14E; -//const short PC_VRFIN = 0x14F; -//const short PC_VRFIP = 0x150; -//const short PC_VRFIZ = 0x151; -//const short PC_VRLB = 0x152; -//const short PC_VRLH = 0x153; -//const short PC_VRLW = 0x154; -//const short PC_VRSQRTEFP = 0x155; -//const short PC_VSL = 0x156; -//const short PC_VSLB = 0x157; -//const short PC_VSLH = 0x158; -//const short PC_VSLO = 0x159; -//const short PC_VSLW = 0x15A; -//const short PC_VSPLTB = 0x15B; -//const short PC_VSPLTH = 0x15C; -//const short PC_VSPLTW = 0x15D; -//const short PC_VSPLTISB = 0x15E; -//const short PC_VSPLTISH = 0x15F; -//const short PC_VSPLTISW = 0x160; -//const short PC_VSR = 0x161; -//const short PC_VSRAB = 0x162; -//const short PC_VSRAH = 0x163; -//const short PC_VSRAW = 0x164; -//const short PC_VSRB = 0x165; -//const short PC_VSRH = 0x166; -//const short PC_VSRO = 0x167; -//const short PC_VSRW = 0x168; -//const short PC_VSUBCUW = 0x169; -//const short PC_VSUBFP = 0x16A; -//const short PC_VSUBSBS = 0x16B; -//const short PC_VSUBSHS = 0x16C; -//const short PC_VSUBSWS = 0x16D; -//const short PC_VSUBUBM = 0x16E; -//const short PC_VSUBUBS = 0x16F; -//const short PC_VSUBUHM = 0x170; -//const short PC_VSUBUHS = 0x171; -//const short PC_VSUBUWM = 0x172; -//const short PC_VSUBUWS = 0x173; -//const short PC_VSUMSWS = 0x174; -//const short PC_VSUM2SWS = 0x175; -//const short PC_VSUM4SBS = 0x176; -//const short PC_VSUM4SHS = 0x177; -//const short PC_VSUM4UBS = 0x178; -//const short PC_VUPKHPX = 0x179; -//const short PC_VUPKHSB = 0x17A; -//const short PC_VUPKHSH = 0x17B; -//const short PC_VUPKLPX = 0x17C; -//const short PC_VUPKLSB = 0x17D; -//const short PC_VUPKLSH = 0x17E; -//const short PC_VXOR = 0x17F; -//const short PC_VMADDFP = 0x180; -//const short PC_VMHADDSHS = 0x181; -//const short PC_VMHRADDSHS = 0x182; -//const short PC_VMLADDUHM = 0x183; -//const short PC_VMSUMMBM = 0x184; -//const short PC_VMSUMSHM = 0x185; -//const short PC_VMSUMSHS = 0x186; -//const short PC_VMSUMUBM = 0x187; -//const short PC_VMSUMUHM = 0x188; -//const short PC_VMSUMUHS = 0x189; -//const short PC_VNMSUBFP = 0x18A; -//const short PC_VPERM = 0x18B; -//const short PC_VSEL = 0x18C; -//const short PC_VSLDOI = 0x18D; -//const short PC_VMR = 0x18E; -//const short PC_VMRP = 0x18F; -//const short PC_SLE = 0x190; -//const short PC_SLEQ = 0x191; -//const short PC_SLIQ = 0x192; -//const short PC_SLLIQ = 0x193; -//const short PC_SLLQ = 0x194; -//const short PC_SLQ = 0x195; -//const short PC_SRAIQ = 0x196; -//const short PC_SRAQ = 0x197; -//const short PC_SRE = 0x198; -//const short PC_SREA = 0x199; -//const short PC_SREQ = 0x19A; -//const short PC_SRIQ = 0x19B; -//const short PC_SRLIQ = 0x19C; -//const short PC_SRLQ = 0x19D; -//const short PC_SRQ = 0x19E; -//const short PC_MASKG = 0x19F; -//const short PC_MASKIR = 0x1A0; -//const short PC_LSCBX = 0x1A1; -//const short PC_DIV = 0x1A2; -//const short PC_DIVS = 0x1A3; -//const short PC_DOZ = 0x1A4; -//const short PC_MUL = 0x1A5; -//const short PC_NABS = 0x1A6; -//const short PC_ABS = 0x1A7; -//const short PC_CLCS = 0x1A8; -//const short PC_DOZI = 0x1A9; -//const short PC_RLMI = 0x1AA; -//const short PC_RRIB = 0x1AB; -//const short PC_PENTRY = 0x1AC; -//const short PC_PEXIT = 0x1AD; -//const short OPCODE_MAX = 0x1AE; -extern OpcodeInfo opcodeinfo[OPCODE_MAX]; +// this is actually in OpcodeInfo.c +extern OpcodeInfo opcodeinfo[]; extern void pcode_get_hi_lo(int bits, char typechar, SInt32 *hi, SInt32 *lo); extern int pcode_check_imm_bits(SInt32 value, int bits, char typechar); diff --git a/includes/compiler/PCodeListing.h b/includes/compiler/PCodeListing.h index 994fd83..d01222e 100644 --- a/includes/compiler/PCodeListing.h +++ b/includes/compiler/PCodeListing.h @@ -5,34 +5,34 @@ extern int pclist_bad_operand; -extern void pcinitlisting(void); +extern void pcinitlisting(/* unknown args */); extern void pccleanuplisting(void); extern void pclistblocks(char *name1, char *name2); -extern void pclistdataflow(void); +extern void pclistdataflow(/* unknown args */); extern void pclistinterferences(char *class_format, int regcount); -extern void pclistspill(void); -extern void pclistcopypropitem(void); -extern void pclistcoalesce(void); -extern void pclistusedefs(void); -extern void pclistpropinfo(void); -extern void pclistloops(void); -extern void pclistswitchtables(void); -extern void pclistdominators(void); -extern void pclistbackedge(void); -extern void pclistinterferencegraphnode(void); -extern void pclistinterferencegraph(void); -extern void pclistblock_scheduler(void); +extern void pclistspill(/* unknown args */); +extern void pclistcopypropitem(/* unknown args */); +extern void pclistcoalesce(/* unknown args */); +extern void pclistusedefs(/* unknown args */); +extern void pclistpropinfo(/* unknown args */); +extern void pclistloops(/* unknown args */); +extern void pclistswitchtables(/* unknown args */); +extern void pclistdominators(/* unknown args */); +extern void pclistbackedge(/* unknown args */); +extern void pclistinterferencegraphnode(/* unknown args */); +extern void pclistinterferencegraph(/* unknown args */); +extern void pclistblock_scheduler(/* unknown args */); extern void pclistblocks_start_scheduler(char *str1, char *str2); extern void pclistblocks_end_scheduler(void); -extern void pctotalheap(void); -extern void pctotalmemory(void); +extern void pctotalheap(/* unknown args */); +extern void pctotalmemory(/* unknown args */); extern void pcmessage(char *probably_a_string, ...); extern int formatalias(Alias *alias, char *buf, int bufSize); extern int dumpalias(Alias *alias, int len, Boolean flag1, Boolean flag2); -extern void pcformatset(void); +extern void pcformatset(/* unknown args */); extern int GetLineEndOffset(char *str, int lineNum, int len); extern int GetLineOffset(char *str, int lineNum, int len); -extern void DumpSourceCode(void); -extern int DumpIR_SrcBreak(void); +extern void DumpSourceCode(/* unknown args */); +extern int DumpIR_SrcBreak(/* unknown args */); #endif diff --git a/includes/compiler/common.h b/includes/compiler/common.h index 5eefd2c..0b8aaa7 100644 --- a/includes/compiler/common.h +++ b/includes/compiler/common.h @@ -187,7 +187,7 @@ typedef struct TemplInstance TemplInstance; typedef struct TemplParam TemplParam; typedef struct TemplPartialSpec TemplPartialSpec; typedef struct TemplStack TemplStack; -typedef struct TStream TStream; +typedef struct TokenStream TokenStream; typedef struct TStreamElement TStreamElement; typedef struct Type Type; typedef struct TypeBitfield TypeBitfield; diff --git a/includes/compiler/objects.h b/includes/compiler/objects.h index 52bbf36..2209dee 100644 --- a/includes/compiler/objects.h +++ b/includes/compiler/objects.h @@ -188,7 +188,7 @@ struct ObjectTemplated { }; enum { - OBJECT_FLAGS_UNUSED = 1, + OBJECT_FLAGS_1 = 1, OBJECT_FLAGS_2 = 2, OBJECT_FLAGS_4 = 4, OBJECT_FLAGS_8 = 8, diff --git a/includes/compiler/templates.h b/includes/compiler/templates.h index 8fe5c46..14f60b6 100644 --- a/includes/compiler/templates.h +++ b/includes/compiler/templates.h @@ -31,7 +31,7 @@ struct Template { struct TemplateFriend { // verified via CPrec PackedDeclInfo decl; FileOffsetInfo fileoffset; - TStream stream; + TokenStream stream; }; struct TemplateMember { // verified via CPrec @@ -39,7 +39,7 @@ struct TemplateMember { // verified via CPrec TemplParam *params; Object *object; FileOffsetInfo fileoffset; - TStream stream; + TokenStream stream; CPrepFileInfo *srcfile; SInt32 startoffset; SInt32 endoffset; @@ -191,7 +191,7 @@ struct TemplateFunction { // verified via CPrec TemplateFunction *unk4; // parent? HashNameNode *name; TemplParam *params; - TStream stream; + TokenStream stream; TStreamElement deftoken; Object *tfunc; TemplFuncInstance *instances; diff --git a/includes/compiler/tokens.h b/includes/compiler/tokens.h index 43c2e85..4230194 100644 --- a/includes/compiler/tokens.h +++ b/includes/compiler/tokens.h @@ -7,19 +7,20 @@ #pragma options align=mac68k #endif -#define TKD_OPERATOR 328 -#define TKD_TEMPLATE 332 -#define TKD_IDENTIFIER -3 -#define TKD_COLON_COLON 372 - typedef enum EToken { TK_INTCONST = -1, TK_FLOATCONST = -2, TK_IDENTIFIER = -3, TK_STRING = -4, TK_STRING_WIDE = -5, - TK_NEG6 = -6, - TK_NEG7 = -7, + TK_ILLEGAL = -6, + TK_EOL = -7, + TK_END = 0, + TK_MACRO_ARG_1 = 1, + TK_MACRO_ARG_2 = 2, + TK_MACRO_ARG_HASH = 3, // #something, followed by the arg index + TK_4 = 4, + TK_5 = 5, TK_AUTO = 256, TK_REGISTER, TK_STATIC, @@ -180,8 +181,7 @@ struct TStreamElement { TData data; }; -// this is actually called TokenStream -struct TStream { +struct TokenStream { SInt32 tokens; TStreamElement *firsttoken; }; diff --git a/includes/compiler/types.h b/includes/compiler/types.h index 4d6e16e..b1d6c73 100644 --- a/includes/compiler/types.h +++ b/includes/compiler/types.h @@ -96,7 +96,7 @@ struct StructMember { UInt32 qual; }; -/*enum { +enum { STRUCT_TYPE_STRUCT = 0, STRUCT_TYPE_UNION = 1, STRUCT_TYPE_CLASS = 2, @@ -112,22 +112,22 @@ struct StructMember { STRUCT_TYPE_C = 12, STRUCT_TYPE_D = 13, STRUCT_TYPE_E = 14 -};*/ -const char STRUCT_TYPE_STRUCT = 0; -const char STRUCT_TYPE_UNION = 1; -const char STRUCT_TYPE_CLASS = 2; -const char STRUCT_TYPE_3 = 3; -const char STRUCT_TYPE_4 = 4; -const char STRUCT_TYPE_5 = 5; -const char STRUCT_TYPE_6 = 6; -const char STRUCT_TYPE_7 = 7; -const char STRUCT_TYPE_8 = 8; -const char STRUCT_TYPE_9 = 9; -const char STRUCT_TYPE_A = 10; -const char STRUCT_TYPE_B = 11; -const char STRUCT_TYPE_C = 12; -const char STRUCT_TYPE_D = 13; -const char STRUCT_TYPE_E = 14; +}; +//const char STRUCT_TYPE_STRUCT = 0; +//const char STRUCT_TYPE_UNION = 1; +//const char STRUCT_TYPE_CLASS = 2; +//const char STRUCT_TYPE_3 = 3; +//const char STRUCT_TYPE_4 = 4; +//const char STRUCT_TYPE_5 = 5; +//const char STRUCT_TYPE_6 = 6; +//const char STRUCT_TYPE_7 = 7; +//const char STRUCT_TYPE_8 = 8; +//const char STRUCT_TYPE_9 = 9; +//const char STRUCT_TYPE_A = 10; +//const char STRUCT_TYPE_B = 11; +//const char STRUCT_TYPE_C = 12; +//const char STRUCT_TYPE_D = 13; +//const char STRUCT_TYPE_E = 14; struct ClassList { // checked via CPrec diff --git a/includes/cos.h b/includes/cos.h index f49ed63..f9818c3 100644 --- a/includes/cos.h +++ b/includes/cos.h @@ -17,9 +17,9 @@ extern char *COS_NewPtr(SInt32 byteCount); extern char *COS_NewPtrClear(SInt32 byteCount); extern void COS_FreePtr(char *ptr); extern void COS_AppendPtrToHandle(char *ptr1, Handle hand2, SInt32 size); -extern OSErr COS_GetMemErr(); -extern SInt32 COS_GetTicks(); -extern SInt32 COS_GetTime(); +extern OSErr COS_GetMemErr(void); +extern SInt32 COS_GetTicks(void); +extern SInt32 COS_GetTime(void); extern void COS_GetString(char *buffer, SInt16 strListID, SInt16 index); extern void COS_GetPString(StringPtr buffer, SInt16 strListID, SInt16 index); extern Boolean COS_IsMultiByte(const void *str1, const void *str2); diff --git a/includes/macemul.h b/includes/macemul.h index dbc4765..ac52e0a 100644 --- a/includes/macemul.h +++ b/includes/macemul.h @@ -51,9 +51,9 @@ extern OSErr Allocate(SInt16 refNum, SInt32 *byteCount); /********************************/ /* LowMem */ -extern UInt32 LMGetTicks(); -extern UInt32 LMGetTime(); -extern OSErr LMGetMemErr(); +extern UInt32 LMGetTicks(void); +extern UInt32 LMGetTime(void); +extern OSErr LMGetMemErr(void); extern void LMSetMemErr(OSErr value); /********************************/ @@ -63,7 +63,7 @@ extern Handle OS_CreateMacHandle(OSHandle *h); extern Handle OS_CreateMacHandleDup(OSHandle *h); extern void OS_DestroyMacHandle(Handle h, OSHandle *ret); -extern OSErr MemError(); +extern OSErr MemError(void); extern Handle NewHandle(SInt32 dataSize); extern Handle NewHandleClear(UInt32 dataSize); extern Handle TempNewHandle(UInt32 dataSize, OSErr *resultCode); @@ -88,12 +88,12 @@ extern Ptr NewPtr(SInt32 dataSize); extern void DisposePtr(Ptr p); extern Ptr NewPtrClear(SInt32 dataSize); extern void DebugStr(ConstStringPtr str); -extern struct Zone *HandleZone(); -extern struct Zone *ApplicationZone(); +extern struct Zone *HandleZone(void); +extern struct Zone *ApplicationZone(void); /********************************/ /* Resources */ -extern Boolean OS_UsingMacResourceForkInfo(); +extern Boolean OS_UsingMacResourceForkInfo(void); extern void OS_UseMacResourceForkInfo(Boolean which); extern OSErr SystemInitResources(OSSpec *spec); extern void OS_AddMacResourceForkRef(int ref, const OSSpec *spec); @@ -106,13 +106,13 @@ extern void OS_CleanupMacResourceForkDir(const OSPathSpec *dir); extern OSErr OS_MacDumpResourceFork(SInt16 ref, Boolean dumpContents); extern OSErr FSpOpenRF(const FSSpec *fss, SInt8 permission, SInt16 *refNum); extern OSErr HOpenRF(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName, SInt8 permission, SInt16 *refNum); -extern OSErr InitResources(); -extern OSErr ResError(); +extern OSErr InitResources(void); +extern OSErr ResError(void); extern void FSpCreateResFile(const FSSpec *fss, OSType creator, OSType fileType, ScriptCode scriptTag); extern void HCreateResFile(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName); extern OSErr FSpOpenResFile(const FSSpec *spec, SInt8 permission); extern SInt16 HOpenResFile(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName, SInt8 permission); -extern SInt16 CurResFile(); +extern SInt16 CurResFile(void); extern void UseResFile(SInt16 refNum); extern SInt16 HomeResFile(Handle theResource); extern Handle GetResource(OSType theType, SInt16 theID); @@ -134,28 +134,28 @@ extern SInt16 CountResources(OSType theType); extern SInt16 Count1Resources(OSType theType); extern Handle GetIndResource(OSType theType, SInt16 index); extern Handle Get1IndResource(OSType theType, SInt16 index); -extern SInt16 Count1Types(); +extern SInt16 Count1Types(void); extern void Get1IndType(OSType *theType, SInt16 index); -extern void ReleaseResource(); +extern void ReleaseResource(Handle theResource); extern void DetachResource(Handle theResource); extern void RemoveResource(Handle theResource); extern void CloseResFile(SInt16 refNum); extern SInt16 GetResFileAttrs(SInt16); -extern Boolean LMGetResLoad(); +extern Boolean LMGetResLoad(void); /********************************/ /* ResourceStrings */ -extern void Res_Initialize(); +extern void Res_Initialize(void); extern int Res_AddResource(const char *name, SInt16 rsrcid, const char **strings); extern const char *Res_GetResource(SInt16 rsrcid, SInt16 index); -extern void Res_Cleanup(); +extern void Res_Cleanup(void); /********************************/ /* TextUtils */ extern StringPtr c2pstr(char *s); extern char *p2cstr(StringPtr s); extern SInt16 CharacterByteType(Ptr textBuf, SInt16 textOffset, ScriptCode script); -extern SInt16 CharByte(); +extern SInt16 CharByte(void); extern void GetDateTime(UInt32 *secs); extern Boolean EqualString(ConstStr255Param strA, ConstStr255Param strB, Boolean caseSens, Boolean diacSens); extern void GetIndString(Str255 theString, SInt16 strListID, SInt16 index); diff --git a/includes/mwcc_decomp.h b/includes/mwcc_decomp.h index a898422..312c858 100644 --- a/includes/mwcc_decomp.h +++ b/includes/mwcc_decomp.h @@ -26,35 +26,35 @@ extern OSErr GetMacFileType(const FSSpec *fss, void *a); // TODO sig extern void GetStaticTarget(OSType *cpu, OSType *os); extern void GetStaticPluginType(OSType *language, OSType *plugintype); extern void GetStaticParserPluginType(OSType *style); -extern int RegisterStaticTargetResources(); -extern int RegisterStaticTargetPlugins(); +extern int RegisterStaticTargetResources(void); +extern int RegisterStaticTargetPlugins(void); /********************************/ /* Might be ParserGlue-mach-ppc-cc.c? */ -extern int RegisterStaticParserToolInfo(); +extern int RegisterStaticParserToolInfo(void); /********************************/ /* Might be cc-mach-ppc.c? */ -extern int RegisterStaticCompilerPlugin(); -extern int RegisterCompilerResources(); +extern int RegisterStaticCompilerPlugin(void); +extern int RegisterCompilerResources(void); /********************************/ /* libimp-mach-ppc.c */ // some statics here -extern int RegisterStaticLibImporterPlugin(); -extern int RegisterLibImporterResources(); +extern int RegisterStaticLibImporterPlugin(void); +extern int RegisterLibImporterResources(void); /********************************/ /* TargetOptimizer-ppc-mach.c */ extern int TargetSetOptFlags(SInt16 val, Boolean set); extern void TargetDisplayOptimizationOptions(Handle txt); -extern void TargetSetPragmaOptimizationsToUnspecified(); +extern void TargetSetPragmaOptimizationsToUnspecified(void); /********************************/ /* OptimizerHelpers.c */ -extern int SetPragmaOptimizationsToUnspecified(); +extern int SetPragmaOptimizationsToUnspecified(void); extern int SetOptFlags(char *opt, void *str, ...); // two unknown args -extern int DisplayOptimizationOptions(); +extern int DisplayOptimizationOptions(void); /********************************/ /* Unk name lol */ @@ -64,7 +64,7 @@ extern int TargetDisplayWarningOptions(Handle txt); /********************************/ /* WarningHelpers.c */ extern int SetWarningFlags(char *opt, void *str, ...); // two unknown args -extern int DisplayWarningOptions(); +extern int DisplayWarningOptions(void); /********************************/ /* CCompiler.c */ @@ -74,8 +74,8 @@ extern CWPLUGIN_ENTRY(MWC_main)(CWPluginContext context); /********************************/ /* StaticParserGlue.c */ -extern int RegisterStaticParserPlugins(); -extern int RegisterStaticParserResources(); +extern int RegisterStaticParserPlugins(void); +extern int RegisterStaticParserResources(void); /********************************/ /* CmdLineBuildDate.c */ diff --git a/includes/option_system.h b/includes/option_system.h index aa519e2..f95f5a9 100644 --- a/includes/option_system.h +++ b/includes/option_system.h @@ -326,14 +326,14 @@ extern anon0_50 prelinkargs; extern anon0_50 postlinkargs; extern void Arg_Init(int theargc, char **theargv); -extern void Arg_Terminate(); -extern void Arg_Reset(); +extern void Arg_Terminate(void); +extern void Arg_Reset(void); extern void Arg_Stop(ArgToken *where); -extern ArgToken *Arg_PeekToken(); -extern ArgToken *Arg_UsedToken(); -extern int Arg_IsEmpty(); -extern ArgToken *Arg_GetToken(); -extern ArgToken *Arg_UndoToken(); +extern ArgToken *Arg_PeekToken(void); +extern ArgToken *Arg_UsedToken(void); +extern int Arg_IsEmpty(void); +extern ArgToken *Arg_GetToken(void); +extern ArgToken *Arg_UndoToken(void); extern const char *Arg_GetTokenName(ArgToken *tok); extern const char *Arg_GetTokenText(ArgToken *tok, char *buffer, int maxlen, unsigned char warn); extern void Arg_InitToolArgs(anon0_50 *ta); @@ -364,19 +364,19 @@ typedef struct { extern char curopt[1024]; -extern void Args_InitStack(); -extern int Args_StackSize(); +extern void Args_InitStack(void); +extern int Args_StackSize(void); extern void Args_Push(SInt16 flags, void *first, void *second); extern Opt48 *Args_Pop(SInt16 flags); extern void Args_SpellStack(char *buffer, SInt16 flags); extern void Args_AddToToolArgs(anon0_50 *ta); -extern void Options_Init(); -extern OptionList *Options_GetOptions(); -extern void Options_SortOptions(); +extern void Options_Init(void); +extern OptionList *Options_GetOptions(void); +extern void Options_SortOptions(void); extern int Options_AddList(OptionList *optlst); extern int Options_AddLists(OptionList **optlst); extern int Option_ForTool(Option *opt, int which); -extern int Option_ThisTool(); +extern int Option_ThisTool(void); extern int Option_ForThisTool(Option *opt); extern int Option_AlsoPassedToTool(Option *opt, int which); extern int Option_AlsoPassedFromThisTool(Option *opt); @@ -391,7 +391,7 @@ extern void Option_Error(SInt16 id, ...); extern void Option_Warning(SInt16 id, ...); extern int Options_Help(const char *keyword); extern int Option_Help(const char *opt); -extern int Options_DisplayHelp(); +extern int Options_DisplayHelp(void); /********************************/ /* Parameter.c */ @@ -407,11 +407,11 @@ extern void Param_Warning(SInt16 id, ...); /* Help.c */ extern int Help_Option(OptionList *lst, Option *opt, int subprint, const char *keyword); extern void Help_Options(OptionList *lst, int subprint, const char *keyword); -extern void Help_Usage(); -extern void Help_Null(); -extern void Help_Init(); +extern void Help_Usage(void); +extern void Help_Null(void); +extern void Help_Init(void); extern void Help_Line(char ch); -extern void Help_Term(); +extern void Help_Term(void); #ifdef __cplusplus } diff --git a/includes/oslib.h b/includes/oslib.h index 4de46e9..d5be38e 100644 --- a/includes/oslib.h +++ b/includes/oslib.h @@ -110,7 +110,7 @@ extern int OS_AppendHandle(OSHandle *hand, const void *data, UInt32 len); extern uOSTypePair OS_TEXTTYPE; extern const char *OS_GetErrText(int err); extern int OS_InitProgram(int *pArgc, char ***pArgv); -extern int OS_TermProgram(); +extern int OS_TermProgram(void); extern int OS_Create(const OSSpec *spec, const uOSTypePair *type); extern int OS_Status(const OSSpec *spec); extern int OS_GetFileType(const OSSpec *spec, uOSTypePair *type); @@ -157,7 +157,7 @@ extern int OS_ResolveLink(const OSSpec *link, OSSpec *target); extern int OS_OpenDir(const OSPathSpec *spec, OSOpenedDir *ref); extern int OS_ReadDir(OSOpenedDir *ref, OSSpec *spec, char *filename, Boolean *isfile); extern int OS_CloseDir(OSOpenedDir *ref); -extern UInt32 OS_GetMilliseconds(); +extern UInt32 OS_GetMilliseconds(void); extern void OS_GetTime(time_t *p); extern int OS_NewHandle(UInt32 size, OSHandle *hand); extern int OS_ResizeHandle(OSHandle *hand, UInt32 size); diff --git a/includes/parser.h b/includes/parser.h index ae28fee..92e4504 100644 --- a/includes/parser.h +++ b/includes/parser.h @@ -125,9 +125,9 @@ typedef struct { OptionList **optionLists; int numPrefDataPanels; PrefDataPanel *prefDataPanels; - int (*PreParse)(); - int (*MidParse)(); - int (*PostParse)(); + int (*PreParse)(void); + int (*MidParse)(void); + int (*PostParse)(void); } ParserTool; // assumed name typedef struct { @@ -184,7 +184,7 @@ extern Pragma irPragmas[]; extern int SetPragmaOptimizationsToUnspecified(const char *opt, void *, const char *, int); extern int SetOptFlags(const char *opt, void *str, const char *, int flags); -extern int DisplayOptimizationOptions(); +extern int DisplayOptimizationOptions(const char *, void *, const char *, int); /********************************/ /* ParserErrors.c */ @@ -281,12 +281,12 @@ extern int SetupPragmas(const Pragma *pragmas); /********************************/ /* Projects.c */ -extern int GetFileCount(); +extern int GetFileCount(void); extern void SetFileOutputName(SInt32 position, SInt16 which, char *outfilename); extern int AddFileToProject(OSSpec *oss, SInt16 which, char *outfilename, Boolean exists, SInt32 position); extern Boolean GetFileInfo(SInt32 position, OSSpec *spec, char *plugin); extern int AddAccessPath(OSPathSpec *oss, SInt16 type, SInt32 position, Boolean recursive); -extern int MoveSystemPathsIntoUserList(); +extern int MoveSystemPathsIntoUserList(void); extern void AddVirtualFile(const char *filename, Handle *text); extern void GetOutputFileDirectory(OSPathSpec *dir); extern void SetOutputFileDirectory(OSPathSpec *dir); @@ -302,7 +302,7 @@ extern char schedule_ppc_default; extern int TargetSetOptFlags(short val, Boolean set); extern void TargetDisplayOptimizationOptions(Handle txt); -extern void TargetSetPragmaOptimizationsToUnspecified(); +extern void TargetSetPragmaOptimizationsToUnspecified(void); /********************************/ /* TargetWarningHelpers-ppc-cc.c */ @@ -318,7 +318,7 @@ extern ParserTool *pTool; extern int SetParserToolInfo(ParserTool *tool); extern Boolean ParserToolMatchesPlugin(OSType type, OSType lang, OSType cpu, OSType os); extern Boolean ParserToolHandlesPanels(int numPanels, const char **panelNames); -extern Boolean SetupParserToolOptions(); +extern Boolean SetupParserToolOptions(void); /********************************/ /* ToolHelpers.c */ @@ -348,7 +348,7 @@ extern int Opt_RedirectStream(const char *opt, void *file, const char *filename) /* ToolHelpers-cc.c */ extern int Opt_DummyLinkerRoutine(const char *opt, void *, const char *, int); extern int Opt_DummyLinkerSettingRoutine(const char *var, const char *val); -extern void FinishCompilerTool(); +extern void FinishCompilerTool(void); /********************************/ /* Utils.c */ @@ -363,7 +363,7 @@ extern int Utils_CompareOptionString(const char *a, const char *b, int cased, in /********************************/ /* WarningHelpers.c */ extern int SetWarningFlags(const char *opt, void *str, const char *, int flags); -extern int DisplayWarningOptions(); +extern int DisplayWarningOptions(const char *, void *, const char *, int); #ifdef __cplusplus extern "C" } diff --git a/includes/pref_structs.h b/includes/pref_structs.h index ee016b6..3b34b7e 100644 --- a/includes/pref_structs.h +++ b/includes/pref_structs.h @@ -70,6 +70,17 @@ typedef struct PCmdLineLinker { Boolean callLinker; } PCmdLineLinker; +typedef enum { + PrefCPU_Generic, + PrefCPU_601, + PrefCPU_603, + PrefCPU_603e, + PrefCPU_604, + PrefCPU_604e, + PrefCPU_750, + PrefCPU_Altivec +} PrefCPU; + typedef struct PBackEnd { SInt16 version; UInt8 structalignment; @@ -241,11 +252,11 @@ typedef struct PGlobalOptimizer { // assumed name/symbols for this one typedef struct PExtraWarningC { - Boolean warn_largeargs; - Boolean warn_padding; - Boolean warn_resultnotused; - Boolean warn_ptr_int_conv; - Boolean warn_no_side_effect; + UInt8 warn_largeargs; + UInt8 warn_padding; + UInt8 warn_resultnotused; + UInt8 warn_ptr_int_conv; + UInt8 warn_no_side_effect; } PExtraWarningC; #ifdef __MWERKS__ diff --git a/osx_build.sh b/osx_build.sh index add410f..17523c1 100755 --- a/osx_build.sh +++ b/osx_build.sh @@ -3,10 +3,8 @@ export MWCIncludes=/usr/include #rm objs/* -MWC_FLAGS="-c -g -opt l=4,noschedule,speed -enum min -Iincludes -Isdk_hdrs -w all,nounused -wchar_t on -bool off -Cpp_exceptions off" +MWC_FLAGS="-c -g -opt l=4,noschedule,speed -enum min -Iincludes -Isdk_hdrs -w all,nounused,nonotinlined -wchar_t on -bool off -Cpp_exceptions off -maxwarnings 10" -#~/bin/mwccppc $MWC_FLAGS -o objs/WarningHelpers.o command_line/C++_Parser/Src/Library/WarningHelpers.c -# #~/bin/mwccppc $MWC_FLAGS -o objs/CLCompilerLinkerDropin_V10.o command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp #~/bin/mwccppc $MWC_FLAGS -o objs/CLDropinCallbacks_V10.o command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp #~/bin/mwccppc $MWC_FLAGS -o objs/CLParserCallbacks_V1.o command_line/CmdLine/Src/Callbacks/CLParserCallbacks_V1.cpp @@ -57,21 +55,137 @@ MWC_FLAGS="-c -g -opt l=4,noschedule,speed -enum min -Iincludes -Isdk_hdrs -w al #~/bin/mwccppc $MWC_FLAGS -o objs/uFileTypeMappings.o command_line/CmdLine/Src/uFileTypeMappings.c # #~/bin/mwccppc $MWC_FLAGS -o objs/ParserGlue-mach-ppc-cc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c -#~/bin/mwccppc $MWC_FLAGS -o objs/TargetWarningHelpers-ppc-cc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c +~/bin/mwccppc $MWC_FLAGS -o objs/TargetWarningHelpers-ppc-cc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c # -#~/bin/mwccppc $MWC_FLAGS -o objs/cc-mach-ppc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c -#~/bin/mwccppc $MWC_FLAGS -o objs/libimp-mach-ppc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c +~/bin/mwccppc $MWC_FLAGS -o objs/cc-mach-ppc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c +~/bin/mwccppc $MWC_FLAGS -o objs/libimp-mach-ppc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c # #~/bin/mwccppc $MWC_FLAGS -o objs/cc-mach-ppc-mw.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c # -~/bin/mwccppc $MWC_FLAGS -o objs/CCompiler.o compiler_and_linker/unsorted/CCompiler.c +~/bin/mwccppc $MWC_FLAGS -o objs/CPrep.o compiler_and_linker/FrontEnd/C/CPrep.c +~/bin/mwccppc $MWC_FLAGS -o objs/CPrepTokenizer.o compiler_and_linker/FrontEnd/C/CPrepTokenizer.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CScope.o compiler_and_linker/FrontEnd/C/CScope.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/CompilerTools.o compiler_and_linker/FrontEnd/Common/CompilerTools.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/AddPropagation.o compiler_and_linker/unsorted/AddPropagation.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Alias.o compiler_and_linker/unsorted/Alias.c +#~/bin/mwccppc $MWC_FLAGS -o objs/BitVectors.o compiler_and_linker/unsorted/BitVectors.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CABI.o compiler_and_linker/unsorted/CABI.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CBrowse.o compiler_and_linker/unsorted/CBrowse.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CClass.o compiler_and_linker/unsorted/CClass.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CCompiler.o compiler_and_linker/unsorted/CCompiler.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CDecl.o compiler_and_linker/unsorted/CDecl.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CError.o compiler_and_linker/unsorted/CError.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CException.o compiler_and_linker/unsorted/CException.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CExpr.o compiler_and_linker/unsorted/CExpr.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CExpr2.o compiler_and_linker/unsorted/CExpr2.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CExprConvMatch.o compiler_and_linker/unsorted/CExprConvMatch.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CFunc.o compiler_and_linker/unsorted/CFunc.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CInit.o compiler_and_linker/unsorted/CInit.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CInline.o compiler_and_linker/unsorted/CInline.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CInt64.o compiler_and_linker/unsorted/CInt64.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CIRTransform.o compiler_and_linker/unsorted/CIRTransform.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CMachine.o compiler_and_linker/unsorted/CMachine.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CMangler.o compiler_and_linker/unsorted/CMangler.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CObjC.o compiler_and_linker/unsorted/CObjC.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CObjCModern.o compiler_and_linker/unsorted/CObjCModern.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CodeGen.o compiler_and_linker/unsorted/CodeGen.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CodeGenOptPPC.o compiler_and_linker/unsorted/CodeGenOptPPC.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CodeMotion.o compiler_and_linker/unsorted/CodeMotion.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Coloring.o compiler_and_linker/unsorted/Coloring.c +#~/bin/mwccppc $MWC_FLAGS -o objs/ConstantPropagation.o compiler_and_linker/unsorted/ConstantPropagation.c +#~/bin/mwccppc $MWC_FLAGS -o objs/COptimizer.o compiler_and_linker/unsorted/COptimizer.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CopyPropagation.o compiler_and_linker/unsorted/CopyPropagation.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CParser.o compiler_and_linker/unsorted/CParser.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CPrec.o compiler_and_linker/unsorted/CPrec.c +~/bin/mwccppc $MWC_FLAGS -o objs/CPreprocess.o compiler_and_linker/unsorted/CPreprocess.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CRTTI.o compiler_and_linker/unsorted/CRTTI.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CSOM.o compiler_and_linker/unsorted/CSOM.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CTemplateClass.o compiler_and_linker/unsorted/CTemplateClass.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CTemplateFunc.o compiler_and_linker/unsorted/CTemplateFunc.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CTemplateNew.o compiler_and_linker/unsorted/CTemplateNew.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CTemplateTools.o compiler_and_linker/unsorted/CTemplateTools.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Exceptions.o compiler_and_linker/unsorted/Exceptions.c +#~/bin/mwccppc $MWC_FLAGS -o objs/FuncLevelAsmPPC.o compiler_and_linker/unsorted/FuncLevelAsmPPC.c +#~/bin/mwccppc $MWC_FLAGS -o objs/FunctionCalls.o compiler_and_linker/unsorted/FunctionCalls.c +#~/bin/mwccppc $MWC_FLAGS -o objs/GCCInlineAsm.o compiler_and_linker/unsorted/GCCInlineAsm.c +#~/bin/mwccppc $MWC_FLAGS -o objs/GenStabs.o compiler_and_linker/unsorted/GenStabs.c +#~/bin/mwccppc $MWC_FLAGS -o objs/GlobalOptimizer.o compiler_and_linker/unsorted/GlobalOptimizer.c +#~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsm.o compiler_and_linker/unsorted/InlineAsm.c +#~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsmMnemonicsPPC.o compiler_and_linker/unsorted/InlineAsmMnemonicsPPC.c +#~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsmPPC.o compiler_and_linker/unsorted/InlineAsmPPC.c +#~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsmRegisters.o compiler_and_linker/unsorted/InlineAsmRegisters.c +#~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsmRegistersPPC.o compiler_and_linker/unsorted/InlineAsmRegistersPPC.c +#~/bin/mwccppc $MWC_FLAGS -o objs/InstrSelection.o compiler_and_linker/unsorted/InstrSelection.c +#~/bin/mwccppc $MWC_FLAGS -o objs/InterferenceGraph.o compiler_and_linker/unsorted/InterferenceGraph.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Intrinsics.o compiler_and_linker/unsorted/Intrinsics.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroBitVect.o compiler_and_linker/unsorted/IroBitVect.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroCSE.o compiler_and_linker/unsorted/IroCSE.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroDump.o compiler_and_linker/unsorted/IroDump.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroEmptyLoop.o compiler_and_linker/unsorted/IroEmptyLoop.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroEval.o compiler_and_linker/unsorted/IroEval.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroExprRegeneration.o compiler_and_linker/unsorted/IroExprRegeneration.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroFlowgraph.o compiler_and_linker/unsorted/IroFlowgraph.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroJump.o compiler_and_linker/unsorted/IroJump.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroLinearForm.o compiler_and_linker/unsorted/IroLinearForm.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroLoop.o compiler_and_linker/unsorted/IroLoop.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroMalloc.o compiler_and_linker/unsorted/IroMalloc.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroPointerAnalysis.o compiler_and_linker/unsorted/IroPointerAnalysis.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroPropagate.o compiler_and_linker/unsorted/IroPropagate.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IrOptimizer.o compiler_and_linker/unsorted/IrOptimizer.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroRangePropagation.o compiler_and_linker/unsorted/IroRangePropagation.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroSubable.o compiler_and_linker/unsorted/IroSubable.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroTransform.o compiler_and_linker/unsorted/IroTransform.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroUnrollLoop.o compiler_and_linker/unsorted/IroUnrollLoop.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IROUseDef.o compiler_and_linker/unsorted/IROUseDef.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroUtil.o compiler_and_linker/unsorted/IroUtil.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IroVars.o compiler_and_linker/unsorted/IroVars.c +#~/bin/mwccppc $MWC_FLAGS -o objs/LiveVariables.o compiler_and_linker/unsorted/LiveVariables.c +#~/bin/mwccppc $MWC_FLAGS -o objs/LoadDeletion.o compiler_and_linker/unsorted/LoadDeletion.c +#~/bin/mwccppc $MWC_FLAGS -o objs/LoopDetection.o compiler_and_linker/unsorted/LoopDetection.c +#~/bin/mwccppc $MWC_FLAGS -o objs/LoopOptimization.o compiler_and_linker/unsorted/LoopOptimization.c +#~/bin/mwccppc $MWC_FLAGS -o objs/MachO.o compiler_and_linker/unsorted/MachO.c +#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation601.o compiler_and_linker/unsorted/MachineSimulation601.c +#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation603.o compiler_and_linker/unsorted/MachineSimulation603.c +#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation603e.o compiler_and_linker/unsorted/MachineSimulation603e.c +#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation604.o compiler_and_linker/unsorted/MachineSimulation604.c +#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation7400.o compiler_and_linker/unsorted/MachineSimulation7400.c +#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation750.o compiler_and_linker/unsorted/MachineSimulation750.c +#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation821.o compiler_and_linker/unsorted/MachineSimulation821.c +#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulationAltiVec.o compiler_and_linker/unsorted/MachineSimulationAltiVec.c +#~/bin/mwccppc $MWC_FLAGS -o objs/ObjGenMachO.o compiler_and_linker/unsorted/ObjGenMachO.c +#~/bin/mwccppc $MWC_FLAGS -o objs/OpcodeInfo.o compiler_and_linker/unsorted/OpcodeInfo.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Operands.o compiler_and_linker/unsorted/Operands.c +#~/bin/mwccppc $MWC_FLAGS -o objs/PCode.o compiler_and_linker/unsorted/PCode.c +#~/bin/mwccppc $MWC_FLAGS -o objs/PCodeAssembly.o compiler_and_linker/unsorted/PCodeAssembly.c +#~/bin/mwccppc $MWC_FLAGS -o objs/PCodeInfo.o compiler_and_linker/unsorted/PCodeInfo.c +#~/bin/mwccppc $MWC_FLAGS -o objs/PCodeListing.o compiler_and_linker/unsorted/PCodeListing.c +#~/bin/mwccppc $MWC_FLAGS -o objs/PCodeUtilities.o compiler_and_linker/unsorted/PCodeUtilities.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Peephole.o compiler_and_linker/unsorted/Peephole.c +#~/bin/mwccppc $MWC_FLAGS -o objs/PPCError.o compiler_and_linker/unsorted/PPCError.c +#~/bin/mwccppc $MWC_FLAGS -o objs/RegisterInfo.o compiler_and_linker/unsorted/RegisterInfo.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Registers.o compiler_and_linker/unsorted/Registers.c +#~/bin/mwccppc $MWC_FLAGS -o objs/ScanFloat.o compiler_and_linker/unsorted/ScanFloat.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Scheduler.o compiler_and_linker/unsorted/Scheduler.c +#~/bin/mwccppc $MWC_FLAGS -o objs/SpillCode.o compiler_and_linker/unsorted/SpillCode.c +#~/bin/mwccppc $MWC_FLAGS -o objs/StackFrame.o compiler_and_linker/unsorted/StackFrame.c +#~/bin/mwccppc $MWC_FLAGS -o objs/StrengthReduction.o compiler_and_linker/unsorted/StrengthReduction.c +#~/bin/mwccppc $MWC_FLAGS -o objs/StructMoves.o compiler_and_linker/unsorted/StructMoves.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Switch.o compiler_and_linker/unsorted/Switch.c +#~/bin/mwccppc $MWC_FLAGS -o objs/TOC.o compiler_and_linker/unsorted/TOC.c +#~/bin/mwccppc $MWC_FLAGS -o objs/uDump.o compiler_and_linker/unsorted/uDump.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Unmangle.o compiler_and_linker/unsorted/Unmangle.c +#~/bin/mwccppc $MWC_FLAGS -o objs/UseDefChains.o compiler_and_linker/unsorted/UseDefChains.c +#~/bin/mwccppc $MWC_FLAGS -o objs/ValueNumbering.o compiler_and_linker/unsorted/ValueNumbering.c +#~/bin/mwccppc $MWC_FLAGS -o objs/VectorArraysToRegs.o compiler_and_linker/unsorted/VectorArraysToRegs.c # #~/bin/mwccppc $MWC_FLAGS -o objs/Arguments.o unsorted/Arguments.c -~/bin/mwccppc $MWC_FLAGS -o objs/CmdLineBuildDate.o unsorted/CmdLineBuildDate.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CmdLineBuildDate.o unsorted/CmdLineBuildDate.c #~/bin/mwccppc $MWC_FLAGS -o objs/Help.o unsorted/Help.c #~/bin/mwccppc $MWC_FLAGS -o objs/IO.o unsorted/IO.c #~/bin/mwccppc $MWC_FLAGS -o objs/OptimizerHelpers.o unsorted/OptimizerHelpers.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Option.o unsorted/Option.c +~/bin/mwccppc $MWC_FLAGS -o objs/Option.o unsorted/Option.c #~/bin/mwccppc $MWC_FLAGS -o objs/Parameter.o unsorted/Parameter.c #~/bin/mwccppc $MWC_FLAGS -o objs/ParserErrors.o unsorted/ParserErrors.c #~/bin/mwccppc $MWC_FLAGS -o objs/ParserFace.o unsorted/ParserFace.c @@ -80,7 +194,7 @@ MWC_FLAGS="-c -g -opt l=4,noschedule,speed -enum min -Iincludes -Isdk_hdrs -w al #~/bin/mwccppc $MWC_FLAGS -o objs/Projects.o unsorted/Projects.c #~/bin/mwccppc $MWC_FLAGS -o objs/StaticParserGlue.o unsorted/StaticParserGlue.c #~/bin/mwccppc $MWC_FLAGS -o objs/Targets.o unsorted/Targets.c -#~/bin/mwccppc $MWC_FLAGS -o objs/TargetOptimizer-ppc-mach.o unsorted/TargetOptimizer-ppc-mach.c +~/bin/mwccppc $MWC_FLAGS -o objs/TargetOptimizer-ppc-mach.o unsorted/TargetOptimizer-ppc-mach.c #~/bin/mwccppc $MWC_FLAGS -o objs/ToolHelpers.o unsorted/ToolHelpers.c #~/bin/mwccppc $MWC_FLAGS -o objs/ToolHelpers-cc.o unsorted/ToolHelpers-cc.c #~/bin/mwccppc $MWC_FLAGS -o objs/uContext1.o unsorted/uContext1.cpp @@ -90,5 +204,197 @@ MWC_FLAGS="-c -g -opt l=4,noschedule,speed -enum min -Iincludes -Isdk_hdrs -w al #~/bin/mwccppc $MWC_FLAGS -o objs/uCOS.o unsorted/uCOS.c #~/bin/mwccppc $MWC_FLAGS -o objs/uLibImporter.o unsorted/uLibImporter.c #~/bin/mwccppc $MWC_FLAGS -o objs/Utils.o unsorted/Utils.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/WarningHelpers.o command_line/C++_Parser/Src/Library/WarningHelpers.c -ld /usr/lib/crt1.o objs/*.o -framework System /Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MacOS\ X\ Support/Libraries/Runtime/Libs/MSL_Runtime_Mach-O.a +ld /usr/lib/crt1.o \ + objs/CLStaticMain.o \ + objs/ClientGlue.o \ + objs/CLMain.o \ + objs/Resources.o \ + objs/CLErrors.o \ + objs/ResourceStrings.o \ + objs/CLPlugins.o \ + objs/CLParserCallbacks_V1.o \ + objs/CLIO.o \ + objs/CLToolExec.o \ + objs/Posix.o \ + objs/StringExtras.o \ + objs/Generic.o \ + objs/CLProj.o \ + objs/CLLicenses.o \ + objs/MemUtils.o \ + objs/CLPluginRequests.o \ + objs/LowMem.o \ + objs/CLFileOps.o \ + objs/CLPrefs.o \ + objs/CLTarg.o \ + objs/CLAccessPaths.o \ + objs/MacSpecs.o \ + objs/StringUtils.o \ + objs/Memory.o \ + objs/Files.o \ + objs/TextUtils.o \ + objs/uFileTypeMappings.o \ + objs/CLFiles.o \ + objs/CLOverlays.o \ + objs/CLSegs.o \ + objs/CLDropinCallbacks_V10.o \ + objs/MacFileTypes.o \ + objs/FileHandles.o \ + objs/CLCompilerLinkerDropin_V10.o \ + objs/CLDependencies.o \ + objs/CLWriteObjectFile.o \ + objs/CLBrowser.o \ + objs/CLIncludeFileCache.o \ + objs/CLLoadAndCache.o \ + objs/ErrMgr.o \ + objs/cc-mach-ppc-mw.o \ + objs/ParserGlue-mach-ppc-cc.o \ + objs/cc-mach-ppc.o \ + objs/libimp-mach-ppc.o \ + objs/TargetOptimizer-ppc-mach.o \ + objs/OptimizerHelpers.o \ + objs/TargetWarningHelpers-ppc-cc.o \ + objs/WarningHelpers.o \ + \ + objs/CCompiler.o \ + objs/CParser.o \ + objs/CompilerTools.o \ + objs/CodeGenOptPPC.o \ + objs/IrOptimizer.o \ + objs/CodeGen.o \ + objs/CPrep.o \ + objs/CScope.o \ + objs/CMachine.o \ + objs/CExpr.o \ + objs/CFunc.o \ + objs/CTemplateNew.o \ + objs/CError.o \ + objs/ObjGenMachO.o \ + objs/CDecl.o \ + objs/CMangler.o \ + objs/CSOM.o \ + objs/CABI.o \ + objs/CInit.o \ + objs/CClass.o \ + objs/CIRTransform.o \ + objs/CObjC.o \ + objs/CInline.o \ + objs/CPrepTokenizer.o \ + objs/CTemplateTools.o \ + objs/IroPointerAnalysis.o \ + objs/InstrSelection.o \ + objs/IroFlowgraph.o \ + objs/IroLinearForm.o \ + objs/IroUtil.o \ + objs/IroCSE.o \ + objs/IroPropagate.o \ + objs/IROUseDef.o \ + objs/InlineAsmPPC.o \ + objs/IroDump.o \ + objs/IroTransform.o \ + objs/IroVars.o \ + objs/IroEval.o \ + objs/IroJump.o \ + objs/IroRangePropagation.o \ + objs/IroEmptyLoop.o \ + objs/IroUnrollLoop.o \ + objs/IroLoop.o \ + objs/IroExprRegeneration.o \ + objs/IroSubable.o \ + objs/RegisterInfo.o \ + objs/TOC.o \ + objs/StackFrame.o \ + objs/Registers.o \ + objs/PCode.o \ + objs/Switch.o \ + objs/ValueNumbering.o \ + objs/PCodeUtilities.o \ + objs/Operands.o \ + objs/Exceptions.o \ + objs/uDump.o \ + objs/COptimizer.o \ + objs/GlobalOptimizer.o \ + objs/PCodeListing.o \ + objs/Peephole.o \ + objs/Scheduler.o \ + objs/Coloring.o \ + objs/PCodeAssembly.o \ + objs/Intrinsics.o \ + objs/PPCError.o \ + objs/CExpr2.o \ + objs/CInt64.o \ + objs/CPrec.o \ + objs/CBrowse.o \ + objs/CPreprocess.o \ + objs/FuncLevelAsmPPC.o \ + objs/CException.o \ + objs/CTemplateClass.o \ + objs/ScanFloat.o \ + objs/CExprConvMatch.o \ + objs/CRTTI.o \ + objs/CObjCModern.o \ + objs/InlineAsm.o \ + objs/Unmangle.o \ + objs/MachO.o \ + objs/GenStabs.o \ + objs/CTemplateFunc.o \ + objs/IroMalloc.o \ + objs/PCodeInfo.o \ + objs/StructMoves.o \ + objs/FunctionCalls.o \ + objs/IroBitVect.o \ + objs/OpcodeInfo.o \ + objs/InlineAsmRegistersPPC.o \ + objs/InlineAsmMnemonicsPPC.o \ + objs/InlineAsmRegisters.o \ + objs/Alias.o \ + objs/LoopDetection.o \ + objs/CopyPropagation.o \ + objs/CodeMotion.o \ + objs/StrengthReduction.o \ + objs/LoopOptimization.o \ + objs/ConstantPropagation.o \ + objs/AddPropagation.o \ + objs/UseDefChains.o \ + objs/LoadDeletion.o \ + objs/VectorArraysToRegs.o \ + objs/LiveVariables.o \ + objs/MachineSimulation604.o \ + objs/MachineSimulation603.o \ + objs/MachineSimulationAltiVec.o \ + objs/MachineSimulation7400.o \ + objs/MachineSimulation603e.o \ + objs/MachineSimulation750.o \ + objs/MachineSimulation601.o \ + objs/MachineSimulation821.o \ + objs/InterferenceGraph.o \ + objs/SpillCode.o \ + objs/GCCInlineAsm.o \ + objs/BitVectors.o \ + \ + objs/StaticParserGlue.o \ + objs/ParserFace.o \ + objs/ParserHelpers.o \ + objs/ToolHelpers.o \ + objs/ParserHelpers-cc.o \ + objs/Arguments.o \ + objs/ToolHelpers-cc.o \ + objs/IO.o \ + objs/Projects.o \ + objs/Targets.o \ + objs/Option.o \ + objs/ParserErrors.o \ + objs/Utils.o \ + objs/Parameter.o \ + objs/Help.o \ + objs/uContext1.o \ + objs/uContextCL.o \ + objs/uContextSecret.o \ + objs/uCOS.o \ + objs/uContextParser.o \ + objs/uLibImporter.o \ + objs/CmdLineBuildDate.o \ + \ + -framework System /Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MacOS\ X\ Support/Libraries/Runtime/Libs/MSL_Runtime_Mach-O.a diff --git a/unsorted/Arguments.c b/unsorted/Arguments.c index c427a5a..663d211 100644 --- a/unsorted/Arguments.c +++ b/unsorted/Arguments.c @@ -96,7 +96,7 @@ static void Arg_Setup(int argc, char **argv) { margind = 1; } -static void Arg_SkipRespFileWS() { +static void Arg_SkipRespFileWS(void) { restart: while (respfile[0] && isspace(respfile[0])) ++respfile; @@ -139,12 +139,12 @@ static unsigned char Arg_OpenRespFile(const char *name) { } } -static void Arg_CloseRespFile() { +static void Arg_CloseRespFile(void) { in_response_file = 0; OS_FreeFileHandle(&respfilehandle); } -static char *Arg_GetRespFileToken() { +static char *Arg_GetRespFileToken(void) { char *start; char *ptr; int quoting; @@ -211,7 +211,7 @@ restart: return ret; } -static unsigned char Arg_GotMore() { +static unsigned char Arg_GotMore(void) { if (!in_response_file) return margind < margc; else if (respfile[0]) @@ -220,7 +220,7 @@ static unsigned char Arg_GotMore() { return margind < margc; } -static void Arg_Parse() { +static void Arg_Parse(void) { unsigned char isOpt; unsigned char isList; char *arg; @@ -385,7 +385,7 @@ void Arg_Init(int theargc, char **theargv) { } } -void Arg_Terminate() { +void Arg_Terminate(void) { ArgToken *cur; while (numargtoks > 0) { @@ -399,7 +399,7 @@ void Arg_Terminate() { maxargtoks = 0; } -void Arg_Reset() { +void Arg_Reset(void) { scantok = 0; } @@ -419,27 +419,27 @@ void Arg_Stop(ArgToken *where) { scantok = numargtoks - 2; } -ArgToken *Arg_PeekToken() { +ArgToken *Arg_PeekToken(void) { if (scantok >= numargtoks) return 0; else return &argtoks[scantok]; } -ArgToken *Arg_UsedToken() { +ArgToken *Arg_UsedToken(void) { if (scantok < numargtoks) scantok++; return Arg_PeekToken(); } -int Arg_IsEmpty() { +int Arg_IsEmpty(void) { ArgToken *tok; tok = Arg_PeekToken(); return (tok == 0 || tok->val == ATK_END); } -ArgToken *Arg_GetToken() { +ArgToken *Arg_GetToken(void) { ArgToken *ret; ret = Arg_PeekToken(); @@ -448,7 +448,7 @@ ArgToken *Arg_GetToken() { return ret; } -ArgToken *Arg_UndoToken() { +ArgToken *Arg_UndoToken(void) { if (scantok > 0) { scantok--; return Arg_PeekToken(); diff --git a/unsorted/Help.c b/unsorted/Help.c index ceeb278..74849a1 100644 --- a/unsorted/Help.c +++ b/unsorted/Help.c @@ -23,7 +23,7 @@ static char outLine[256]; static void Help_Output(Side *left, Side *right); static void Help_OutputSingle(Side *all); -static void Help_Flush(); +static void Help_Flush(void); static void Side_Init(Side *s, short offset, short width) { memset(s, 0, sizeof(Side)); @@ -147,7 +147,7 @@ static void Side_DumpLine(Side *s) { } } -static void Help_PrintLine() { +static void Help_PrintLine(void) { HPrintF(helptext, "%.*s\n", parseopts.ioCols - 1, outLine); } @@ -176,11 +176,11 @@ static void Help_OutputSingle(Side *all) { } } -static void Help_Flush() { +static void Help_Flush(void) { Help_Output(&left, &right); } -static void Help_NewLine() { +static void Help_NewLine(void) { Side_NewLine(&left); Side_NewLine(&right); } @@ -369,7 +369,7 @@ int Help_Option(struct OptionList *lst, struct Option *opt, int subprint, const Side_Print( &left, "%s", - (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) ? ((lastparam->flags & PARAMFLAGS_8) ? "[=" : "[,") : ((lastparam->flags & PARAMFLAGS_8) ? "," : "=") + (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) ? ((lastparam->flags & PARAMFLAGS_8) ? "[=" : "[,") : ((lastparam->flags & PARAMFLAGS_8) ? "=" : ",") ); } else if (!(opt->avail & OTF_STICKY)) { if (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) { @@ -397,8 +397,8 @@ int Help_Option(struct OptionList *lst, struct Option *opt, int subprint, const Side_Print(&left, "\t"); Side_Print(&right, "\t"); Help_Options(opt->sub, 1, ""); - Side_Print(&left, "\b"); Side_Print(&right, "\b"); + Side_Print(&left, "\b"); } else { Side_Print(&left, "\n"); Side_Print(&right, "\n"); @@ -465,7 +465,7 @@ void Help_Options(struct OptionList *lst, int subprint, const char *keyword) { HPrintF(helptext, "\n"); } -void Help_Usage() { +void Help_Usage(void) { Side_Print( &all, "\tGuide to help:\b" @@ -518,7 +518,7 @@ void Help_Usage() { Help_OutputSingle(&all); } -void Help_Null() { +void Help_Null(void) { Side_Print(&all, "%s [options, filenames...]\n\nExecute '%s %shelp' for more information.", OS_GetFileNamePtr(parseopts.args->argv[0]), @@ -528,7 +528,7 @@ void Help_Null() { Help_OutputSingle(&all); } -void Help_Init() { +void Help_Init(void) { short lb; short le; short rb; @@ -555,7 +555,7 @@ void Help_Line(char ch) { HPrintF(helptext, "%.*s\n", parseopts.ioCols - 1, line); } -void Help_Term() { +void Help_Term(void) { ShowTextHandle(0, helptext); DisposeHandle(helptext); } diff --git a/unsorted/OptimizerHelpers.c b/unsorted/OptimizerHelpers.c index 8b4bf36..4085363 100644 --- a/unsorted/OptimizerHelpers.c +++ b/unsorted/OptimizerHelpers.c @@ -123,7 +123,7 @@ int SetOptFlags(const char *opt, void *str, const char *, int flags) { return 1; } -int DisplayOptimizationOptions() { +int DisplayOptimizationOptions(const char *, void *, const char *, int) { SInt32 oldsize; Handle h; diff --git a/unsorted/Option.c b/unsorted/Option.c index 410c807..c1c8e91 100644 --- a/unsorted/Option.c +++ b/unsorted/Option.c @@ -69,14 +69,14 @@ static void Option_PopOpt(char *optname) { free(os->e.o.curopt); } -static void Option_PopList() { +static void Option_PopList(void) { Args_Pop(ARGFLAG_1); } -void Args_InitStack() { +void Args_InitStack(void) { oStackPtr = 0; } -int Args_StackSize() { +int Args_StackSize(void) { return oStackPtr; } @@ -187,7 +187,7 @@ void Args_AddToToolArgs(anon0_50 *ta) { Arg_AddToToolArgs(ta, 2, nptr); } -void Options_Init() { +void Options_Init(void) { numoptionlists = 0; maxlegalset = 0; numlegalset = 0; @@ -212,11 +212,11 @@ void Options_Init() { Args_InitStack(); } -OptionList *Options_GetOptions() { +OptionList *Options_GetOptions(void) { return &legalset; } -void Options_SortOptions() { +void Options_SortOptions(void) { int r; if (numinternalset > 0) { @@ -341,7 +341,7 @@ int Option_ForTool(Option *opt, int which) { return !which || (opt->avail & which); } -int Option_ThisTool() { +int Option_ThisTool(void) { return (pTool->TYPE == CWDROPINCOMPILERTYPE) ? OTF_TOOL_COMPILER : OTF_TOOL_LINKER; } @@ -817,7 +817,7 @@ static int Options_DoParse(OptionList *search, int flags) { parseopts.possibleFiles++; haderrors = 0; } - parsedany = 1; + parsedany++; if (haderrors) failed = 1; else @@ -1126,7 +1126,7 @@ int Option_Help(const char *opt) { return ret; } -int Options_DisplayHelp() { +int Options_DisplayHelp(void) { if (parseopts.helpFlags & HELPFLAGS_1) return Option_Help(parseopts.helpKey); else diff --git a/unsorted/Parameter.c b/unsorted/Parameter.c index b3c7367..03e4a75 100644 --- a/unsorted/Parameter.c +++ b/unsorted/Parameter.c @@ -973,7 +973,7 @@ static void Param_PushParam(const char *param) { Args_Push(4, (void *) param, 0); } -static void Param_PopParam() { +static void Param_PopParam(void) { Args_Pop(4); } diff --git a/unsorted/Projects.c b/unsorted/Projects.c index fda92df..dca9df2 100644 --- a/unsorted/Projects.c +++ b/unsorted/Projects.c @@ -2,7 +2,7 @@ extern char STSbuf[256]; -int GetFileCount() { +int GetFileCount(void) { SInt32 num; CWGetProjectFileCount(parseopts.context, &num); return num; @@ -115,7 +115,7 @@ int AddAccessPath(OSPathSpec *oss, SInt16 type, SInt32 position, Boolean recursi return 1; } -int MoveSystemPathsIntoUserList() { +int MoveSystemPathsIntoUserList(void) { CWResult result = CWParserSwapAccessPaths(parseopts.context); return result == cwNoErr; } diff --git a/unsorted/StaticParserGlue.c b/unsorted/StaticParserGlue.c index c2e130d..7a44487 100644 --- a/unsorted/StaticParserGlue.c +++ b/unsorted/StaticParserGlue.c @@ -18,12 +18,12 @@ static ParserPluginCallbacks pr_cb = { Parser_SupportsPanels }; -int RegisterStaticParserPlugins() { +int RegisterStaticParserPlugins(void) { return RegisterStaticParserPlugin(&cb, &pr_cb); } #include "ParserErrors.r" -int RegisterStaticParserResources() { +int RegisterStaticParserResources(void) { return RegisterResource("Parser Strings", 12010, STR12010); } diff --git a/unsorted/TargetOptimizer-ppc-mach.c b/unsorted/TargetOptimizer-ppc-mach.c index 10fe33e..6c86356 100644 --- a/unsorted/TargetOptimizer-ppc-mach.c +++ b/unsorted/TargetOptimizer-ppc-mach.c @@ -17,28 +17,28 @@ int TargetSetOptFlags(short val, Boolean set) { pBackEnd.processor = schedule_ppc_default; break; case 'SG': - pBackEnd.processor = schedule_ppc_default = 0; + pBackEnd.processor = schedule_ppc_default = PrefCPU_Generic; break; case 'S1': - pBackEnd.processor = schedule_ppc_default = 1; + pBackEnd.processor = schedule_ppc_default = PrefCPU_601; break; case 'S3': - pBackEnd.processor = schedule_ppc_default = 2; + pBackEnd.processor = schedule_ppc_default = PrefCPU_603; break; case 'S#': - pBackEnd.processor = schedule_ppc_default = 3; + pBackEnd.processor = schedule_ppc_default = PrefCPU_603e; break; case 'S4': - pBackEnd.processor = schedule_ppc_default = 4; + pBackEnd.processor = schedule_ppc_default = PrefCPU_604; break; case 'S%': - pBackEnd.processor = schedule_ppc_default = 5; + pBackEnd.processor = schedule_ppc_default = PrefCPU_604e; break; case 'S7': - pBackEnd.processor = schedule_ppc_default = 6; + pBackEnd.processor = schedule_ppc_default = PrefCPU_750; break; case 'SA': - pBackEnd.processor = schedule_ppc_default = 7; + pBackEnd.processor = schedule_ppc_default = PrefCPU_Altivec; break; default: return 0; @@ -48,22 +48,24 @@ int TargetSetOptFlags(short val, Boolean set) { } void TargetDisplayOptimizationOptions(Handle txt) { + PrefCPU p; + if (!pBackEnd.schedule) { HPrintF(txt, "\t- no instruction scheduling\n"); } else { HPrintF(txt, "\t- schedule for %s\n", - (pBackEnd.processor == 0) ? "generic PPC" : - (pBackEnd.processor == 1) ? "601" : - (pBackEnd.processor == 2) ? "603" : - (pBackEnd.processor == 3) ? "603e" : - (pBackEnd.processor == 4) ? "604" : - (pBackEnd.processor == 5) ? "604e" : - (pBackEnd.processor == 6) ? "750" : - (pBackEnd.processor == 7) ? "Altivec" : + !(p = (PrefCPU) pBackEnd.processor) ? "generic PPC" : + (p == PrefCPU_601) ? "601" : + (p == PrefCPU_603) ? "603" : + (p == PrefCPU_603e) ? "603e" : + (p == PrefCPU_604) ? "604" : + (p == PrefCPU_604e) ? "604e" : + (p == PrefCPU_750) ? "750" : + (p == PrefCPU_Altivec) ? "Altivec" : "???" ); } } -void TargetSetPragmaOptimizationsToUnspecified() { +void TargetSetPragmaOptimizationsToUnspecified(void) { } diff --git a/unsorted/Targets.c b/unsorted/Targets.c index accad8b..1c00170 100644 --- a/unsorted/Targets.c +++ b/unsorted/Targets.c @@ -53,7 +53,7 @@ Boolean ParserToolHandlesPanels(int numPanels, const char **panelNames) { return 0; } -Boolean SetupParserToolOptions() { +Boolean SetupParserToolOptions(void) { int idx; Options_Init(); diff --git a/unsorted/ToolHelpers-cc.c b/unsorted/ToolHelpers-cc.c index fee7517..b58f188 100644 --- a/unsorted/ToolHelpers-cc.c +++ b/unsorted/ToolHelpers-cc.c @@ -11,7 +11,7 @@ int Opt_DummyLinkerSettingRoutine(const char *var, const char *val) { return 0; } -void FinishCompilerTool() { +void FinishCompilerTool(void) { SInt32 numfiles; if (parseopts.lastoutputname[0]) { diff --git a/unsorted/uCOS.c b/unsorted/uCOS.c index 2a7f643..11f1668 100644 --- a/unsorted/uCOS.c +++ b/unsorted/uCOS.c @@ -119,15 +119,15 @@ void COS_AppendPtrToHandle(char *ptr1, Handle hand2, SInt32 size) { PtrAndHand(ptr1, hand2, size); } -OSErr COS_GetMemErr() { +OSErr COS_GetMemErr(void) { return LMGetMemErr(); } -SInt32 COS_GetTicks() { +SInt32 COS_GetTicks(void) { return LMGetTicks(); } -SInt32 COS_GetTime() { +SInt32 COS_GetTime(void) { return LMGetTime(); } -- cgit v1.2.3