diff options
author | Ash Wolf <ninji@wuffs.org> | 2022-12-14 00:16:59 +0000 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2022-12-14 00:16:59 +0000 |
commit | 25bab8b1fb2fc851ea3f1f630b3de65ca6afdc22 (patch) | |
tree | c0ee632aa3752884b996c562622e2ece88216ea4 /includes/compiler/LoopDetection.h | |
parent | 9d2728a5605f651934fe67a6fe6986b3e4a2c011 (diff) | |
download | MWCC-25bab8b1fb2fc851ea3f1f630b3de65ca6afdc22.tar.gz MWCC-25bab8b1fb2fc851ea3f1f630b3de65ca6afdc22.zip |
haha it's been a while since i last committed, hasn't it
Diffstat (limited to '')
-rw-r--r-- | includes/compiler/LoopDetection.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/includes/compiler/LoopDetection.h b/includes/compiler/LoopDetection.h index 7f27467..28dbb7a 100644 --- a/includes/compiler/LoopDetection.h +++ b/includes/compiler/LoopDetection.h @@ -2,5 +2,97 @@ #define COMPILER_LOOPDETECTION_H #include "compiler/common.h" +#include "compiler/BitVector.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif +typedef struct BlockList { + struct BlockList *next; + PCodeBlock *block; +} BlockList; + +typedef struct InstrList { + struct InstrList *next; + PCode *instr; +} InstrList; + +typedef enum LoopBound { + LOOP_BOUND_INDETERMINATE, + LOOP_BOUND_CONSTANT, + LOOP_BOUND_VARIABLE +} LoopBound; + +typedef struct Loop { + struct Loop *parent; + struct Loop *nextSibling; + struct Loop *children; + PCodeBlock *body; // repeated block + PCodeBlock *preheader; // block at the start of the loop + PCodeBlock *footer; // block at the end of the loop + PCode *pc18; + BlockList *blocks; + UInt32 *memberblocks; + UInt32 *vec24; + UInt32 *vec28; + UInt32 *vec2C; + struct BasicInductionVar *basicInductionVars; + int loopWeight; + int bodySize; // amount of instructions in the body + SInt32 iterationCount; + SInt32 lower; + SInt32 upper; + SInt32 step; // value added in each iteration + unsigned char unknownCondition; + Boolean x4D; + Boolean x4E; + Boolean x4F; + Boolean isUnknownCountingLoop; // is a counting loop with non-constant iteration count + Boolean isKnownCountingLoop; + Boolean x52; + Boolean x53; + Boolean x54; + LoopBound lowerType; + LoopBound upperType; + Boolean x57; +} Loop; + +typedef struct BasicInductionVar { + struct BasicInductionVar *next; + Loop *loop; + struct InductionVar *inductionVars; + InstrList *instrsC; + PCode *initializer; + SInt32 step; + short reg; +} BasicInductionVar; + +typedef struct InductionVar { + struct InductionVar *next; + BasicInductionVar *basicVar; + PCode *instr; + PCode *instrC; + Loop *someloop; + SInt32 step; + short x18; // arg index within instr + short x1A; // arg index within instr + short x1C; // reg + short x1E; // reg +} InductionVar; +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +extern Loop *loopsinflowgraph; +extern int loopdetection_nblocks; +extern BitVector *LoopTemp; +extern void *LoopList_First; + +extern void addblocktoloop(Loop *loop, PCodeBlock *block); +extern void insertpreheaderblock(Loop *loop); +extern void findloopsinflowgraph(void); +extern void analyzeForCountableLoops(Loop *loop); +extern void analyzeloop(Loop *loop); +extern void analyzeloopsinflowgraph(void); #endif |