2022-11-20 05:07:22 +00:00
|
|
|
#ifndef COMPILER_IROFLOWGRAPH_H
|
|
|
|
#define COMPILER_IROFLOWGRAPH_H
|
|
|
|
|
2022-12-14 00:16:59 +00:00
|
|
|
#include "compiler/IrOptimizer.h"
|
|
|
|
#include "compiler/BitVector.h"
|
|
|
|
#include "compiler/CError.h"
|
|
|
|
#include "compiler/CompilerTools.h"
|
|
|
|
|
|
|
|
#ifdef __MWERKS__
|
|
|
|
#pragma options align=mac68k
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct IRONode {
|
|
|
|
UInt16 index;
|
|
|
|
UInt16 numsucc;
|
|
|
|
UInt16 *succ;
|
|
|
|
UInt16 numpred;
|
|
|
|
UInt16 *pred;
|
|
|
|
IROLinear *first;
|
|
|
|
IROLinear *last;
|
|
|
|
BitVector *x16; // In
|
|
|
|
BitVector *x1A; // Out
|
|
|
|
BitVector *x1E; // Gen
|
|
|
|
BitVector *x22; // Kill
|
|
|
|
UInt32 x26;
|
|
|
|
BitVector *x2A; // AA
|
|
|
|
BitVector *dom;
|
|
|
|
IRONode *nextnode;
|
|
|
|
Boolean x36;
|
|
|
|
Boolean x37;
|
|
|
|
Boolean mustreach;
|
|
|
|
Boolean x39;
|
|
|
|
UInt16 loopdepth;
|
|
|
|
Boolean x3C;
|
|
|
|
struct ObjectSet *addressed;
|
|
|
|
Boolean mustreach1;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct IRONodes {
|
|
|
|
UInt16 *indices;
|
|
|
|
UInt16 num;
|
|
|
|
UInt16 base;
|
|
|
|
} IRONodes;
|
|
|
|
|
|
|
|
#ifdef __MWERKS__
|
|
|
|
#pragma options align=reset
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern UInt16 IRO_NumNodes;
|
|
|
|
extern IRONode *IRO_FirstNode;
|
|
|
|
extern IRONode *IRO_LastNode;
|
|
|
|
extern IRONode *IRO_EndNode;
|
|
|
|
extern IRONode **IRO_NodeTable;
|
|
|
|
extern BitVector *IRO_VarKills;
|
|
|
|
extern BitVector *IRO_Avail;
|
|
|
|
extern BitVector *IRO_FuncKills;
|
|
|
|
extern BitVector *IRO_ExprKills;
|
|
|
|
|
|
|
|
extern void IRO_ComputeSuccPred(void);
|
|
|
|
extern void IRO_ComputeDom(void);
|
|
|
|
extern void IRO_BuildFlowgraph(IROLinear *linear);
|
|
|
|
extern IRONode *IRO_NewFlowGraphNode(void);
|
|
|
|
extern IRONode *IRO_MergeFlowGraphNodes(IRONode *a, IRONode *b);
|
|
|
|
|
2023-01-11 23:26:04 +00:00
|
|
|
CW_INLINE void IROFlowgraph_sub_4C2140(IRONodes *nodes) {
|
2022-12-14 00:16:59 +00:00
|
|
|
nodes->indices = oalloc(sizeof(UInt16) * IRO_NumNodes);
|
|
|
|
nodes->num = 0;
|
|
|
|
nodes->base = 0;
|
|
|
|
}
|
|
|
|
|
2023-01-11 23:26:04 +00:00
|
|
|
CW_INLINE void IROFlowgraph_sub_4C20E0(IRONodes *nodes) {
|
2022-12-14 00:16:59 +00:00
|
|
|
}
|
|
|
|
|
2023-01-11 23:26:04 +00:00
|
|
|
CW_INLINE UInt16 IROFlowgraph_sub_4C2040(IRONodes *nodes) {
|
2022-12-14 00:16:59 +00:00
|
|
|
return nodes->num;
|
|
|
|
}
|
|
|
|
|
2023-01-11 23:26:04 +00:00
|
|
|
CW_INLINE UInt16 IROFlowgraph_sub_4C2100(IRONodes *nodes) {
|
2022-12-14 00:16:59 +00:00
|
|
|
UInt16 result = -1;
|
|
|
|
if (nodes->num) {
|
|
|
|
result = nodes->indices[nodes->base];
|
|
|
|
nodes->base = (nodes->base + 1) % IRO_NumNodes;
|
|
|
|
nodes->num--;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-01-11 23:26:04 +00:00
|
|
|
CW_INLINE void IROFlowgraph_sub_4C3880(IRONodes *nodes, UInt16 index) {
|
2022-12-14 00:16:59 +00:00
|
|
|
if (nodes->num < IRO_NumNodes) {
|
|
|
|
nodes->indices[(nodes->base + nodes->num) % IRO_NumNodes] = index;
|
|
|
|
nodes->num++;
|
|
|
|
} else {
|
2022-12-29 12:32:55 +00:00
|
|
|
CError_FATAL(93);
|
2022-12-14 00:16:59 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-20 05:07:22 +00:00
|
|
|
|
|
|
|
#endif
|