@@ -32,14 +32,19 @@ typedef int BOOL;
3232
3333// Removes any functions that cannot possibly be called by any codepath
3434#define CSCRIPTCOMPILER_OPTIMIZE_DEAD_FUNCTIONS 0x00000001
35- // Merges constant expressions into a single constant where possible.
36- // Note: Only affects runtime expressions, assignments to const variables are always folded.
37- #define CSCRIPTCOMPILER_OPTIMIZE_FOLD_CONSTANTS 0x00000002
3835// Post processes generated instructions to merge sequences into shorter equivalents
39- #define CSCRIPTCOMPILER_OPTIMIZE_MELD_INSTRUCTIONS 0x00000004
36+ #define CSCRIPTCOMPILER_OPTIMIZE_MELD_INSTRUCTIONS 0x00000002
37+ // Removes the jump and the dead branches in if (CONST) constructs
38+ #define CSCRIPTCOMPILER_OPTIMIZE_DEAD_BRANCHES 0x00000004
4039
40+ // Optimization groups - roughly corresponding to -O0, -O1, -O2, -O3. Each group includes the previous one.
41+ // Safe - Known good, used by the game and toolset
42+ // Aggressive - Probably good, used by the external compiler
43+ // Experimental - Untested or known to break something
4144#define CSCRIPTCOMPILER_OPTIMIZE_NOTHING 0x00000000
42- #define CSCRIPTCOMPILER_OPTIMIZE_EVERYTHING 0xFFFFFFFF
45+ #define CSCRIPTCOMPILER_OPTIMIZE_SAFE (CSCRIPTCOMPILER_OPTIMIZE_DEAD_FUNCTIONS)
46+ #define CSCRIPTCOMPILER_OPTIMIZE_AGGRESSIVE (CSCRIPTCOMPILER_OPTIMIZE_SAFE | CSCRIPTCOMPILER_OPTIMIZE_DEAD_BRANCHES)
47+ #define CSCRIPTCOMPILER_OPTIMIZE_EXPERIMENTAL (CSCRIPTCOMPILER_OPTIMIZE_AGGRESSIVE | CSCRIPTCOMPILER_OPTIMIZE_MELD_INSTRUCTIONS)
4348
4449struct CScriptCompilerAPI
4550{
@@ -297,7 +302,7 @@ struct CScriptCompiler
297302 int32_t GetStructureSize (const CExoString & sStructureName );
298303 int32_t GetIdentifierByName (const CExoString & sIdentifierName );
299304 int32_t AddToGlobalVariableList (CScriptParseTreeNode * pGlobalVariableNode);
300- BOOL ConstantFoldNode (CScriptParseTreeNode *pNode, BOOL bForce = false );
305+ BOOL ConstantFoldNode (CScriptParseTreeNode *pNode);
301306 CScriptParseTreeNode *TrimParseTree (CScriptParseTreeNode *pNode);
302307 void InitializeSwitchLabelList ();
303308 int32_t TraverseTreeForSwitchLabels (CScriptParseTreeNode * pNode);
0 commit comments