blob: 5d9a7292743cde746ec0ff31364f7d6789917229 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#ifndef COMPILER_LOOPDETECTION_H
#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 struct LoopList *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
|