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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
#ifndef COMPILER_IROLINEARFORM_H
#define COMPILER_IROLINEARFORM_H
#include "compiler/IrOptimizer.h"
#include "compiler/Switch.h"
#include "compiler/enode.h"
#ifdef __MWERKS__
#pragma options align=mac68k
#endif
typedef struct IROLinearIRSave {
IROLinear *firstLinear;
IROLinear *lastLinear;
UInt32 numLinear;
Statement *curStat;
Boolean disableDueToAsm;
Boolean isLeafFunction;
Boolean functionHasReturn;
void *nullCheckList;
Statement *currStmt;
Statement *prevStmt;
} IROLinearIRSave;
typedef enum IROLinearType {
IROLinearNop,
IROLinearOperand,
IROLinearOp1Arg,
IROLinearOp2Arg,
IROLinearGoto,
IROLinearIf,
IROLinearIfNot,
IROLinearReturn,
IROLinearLabel,
IROLinearSwitch,
IROLinearOp3Arg,
IROLinearFunccall,
IROLinearEntry,
IROLinearExit,
IROLinearBeginCatch,
IROLinearEndCatch,
IROLinearEndCatchDtor,
IROLinearAsm,
IROLinear18,
IROLinear19,
IROLinearEnd
} IROLinearType;
enum {
IROLF_1 = 0x1,
IROLF_Reffed = 0x2,
IROLF_Assigned = 0x4,
IROLF_8 = 0x8,
IROLF_Used = 0x10,
IROLF_Ind = 0x20,
IROLF_Subs = 0x40,
IROLF_80 = 0x80,
IROLF_LoopInvariant = 0x100,
IROLF_BeginLoop = 0x200,
IROLF_EndLoop = 0x400,
IROLF_Ris = 0x800,
IROLF_Immind = 0x1000,
IROLF_VecOp = 0x2000,
IROLF_4000 = 0x4000,
IROLF_8000 = 0x8000,
IROLF_VecOpBase = 0x10000,
IROLF_20000 = 0x20000,
IROLF_CounterLoop = 0x40000,
IROLF_BitfieldIndirect = 0x80000,
IROLF_CouldError = 0x100000
};
// actual name is LinearNode as per mwccppc v8
struct IROLinear {
IROLinearType type;
ENodeType nodetype;
SInt32 flags;
UInt16 nodeflags;
unsigned short index;
Statement *stmt;
Type *rtype;
IROExpr *expr;
struct ERange *x16;
PointsToFunction *pointsToFunction;
Boolean x1E;
union {
struct {
void *data1;
void *data2;
void *data3;
void *data4;
void *data5;
} idk;
// Operand
ENode *node;
// Op1Arg
IROLinear *monadic;
// Op2Arg
struct {
IROLinear *left;
IROLinear *right;
} diadic;
// Op3Arg
struct {
IROLinear *a;
IROLinear *b;
IROLinear *c;
} args3;
// Funccall
struct {
char ispascal;
short argCount;
IROLinear **args;
IROLinear *linear8; // funcref
TypeFunc *functype;
struct LocationSetSet *returnedLocs;
} funccall;
// Asm
Statement *asm_stmt;
// If, IfNot, Goto, Label
struct {
CLabel *label;
IROLinear *x4; // if,ifnot only??
} label;
struct {
SwitchInfo *info;
IROLinear *x4;
} swtch;
// BeginCatch, EndCatch, EndCatchDtor
struct {
IROLinear *linear;
int x4;
int x8;
} ctch;
} u;
IROLinear *next;
};
#ifdef __MWERKS__
#pragma options align=reset
#endif
extern IROLinear *IRO_FirstLinear;
extern IROLinear *IRO_LastLinear;
extern UInt32 IRO_NumLinear;
extern Statement *CurStat;
extern IROLinear *IRO_NewLinear(IROLinearType type);
extern void IRO_PreLinearize(Statement *stmt);
extern void IRO_Linearize(Statement *stmt);
extern ENode *IRO_NewENode(ENodeType nodetype);
extern Statement *IRO_Delinearize(IRONode *node, IROLinear *linear);
extern void IRO_RenumberInts(void);
extern void IRO_UpdateFlagsOnInts(void);
extern void IRO_SaveLinearIR(IROLinearIRSave *save);
extern void IRO_RestoreLinearIR(IROLinearIRSave *save);
#define IS_LINEAR_ENODE(_linear, _nodetype) ( ((_linear)->type == IROLinearOperand) && ((_linear)->u.node->type) == (_nodetype) )
#define IS_LINEAR_MONADIC(_linear, _nodetype) ( ((_linear)->type == IROLinearOp1Arg) && ((_linear)->nodetype) == (_nodetype) )
#define IS_LINEAR_MONADIC_2(_linear, _nodetype1, _nodetype2) ( ((_linear)->type == IROLinearOp1Arg) && (((_linear)->nodetype) == (_nodetype1) || ((_linear)->nodetype) == (_nodetype2)) )
#define IS_LINEAR_DIADIC(_linear, _nodetype) ( ((_linear)->type == IROLinearOp2Arg) && ((_linear)->nodetype) == (_nodetype) )
#define IS_LINEAR_DIADIC_2(_linear, _nodetype1, _nodetype2) ( ((_linear)->type == IROLinearOp2Arg) && (((_linear)->nodetype) == (_nodetype1) || ((_linear)->nodetype) == (_nodetype2)) )
#define IS_LINEAR_DIADIC_3(_linear, _nodetype1, _nodetype2, _nodetype3) ( ((_linear)->type == IROLinearOp2Arg) && (((_linear)->nodetype) == (_nodetype1) || ((_linear)->nodetype) == (_nodetype2) || ((_linear)->nodetype) == (_nodetype3)) )
#endif
|