summaryrefslogtreecommitdiff
path: root/compiler_and_linker/FrontEnd/Optimizer/IroLoop.h
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-01-26 11:30:47 +0000
committerAsh Wolf <ninji@wuffs.org>2023-01-26 11:30:47 +0000
commit094b96ca1df4a035b5f93c351f773306c0241f3f (patch)
tree95ce05e3ebe816c7ee7996206bb37ea17d8ca33c /compiler_and_linker/FrontEnd/Optimizer/IroLoop.h
parentfc0c4c0df7b583b55a08317cf1ef6a71d27c0440 (diff)
downloadMWCC-094b96ca1df4a035b5f93c351f773306c0241f3f.tar.gz
MWCC-094b96ca1df4a035b5f93c351f773306c0241f3f.zip
move lots of source files around to match their actual placement in the original treemain
Diffstat (limited to 'compiler_and_linker/FrontEnd/Optimizer/IroLoop.h')
-rw-r--r--compiler_and_linker/FrontEnd/Optimizer/IroLoop.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/compiler_and_linker/FrontEnd/Optimizer/IroLoop.h b/compiler_and_linker/FrontEnd/Optimizer/IroLoop.h
new file mode 100644
index 0000000..2d968ad
--- /dev/null
+++ b/compiler_and_linker/FrontEnd/Optimizer/IroLoop.h
@@ -0,0 +1,111 @@
+#ifndef COMPILER_IROLOOP_H
+#define COMPILER_IROLOOP_H
+
+#include "IrOptimizer.h"
+#include "BitVector.h"
+
+typedef enum IROLoopIndFlags {
+ LoopInd_HasMod = 1,
+ LoopInd_HasDiv = 2,
+ LoopInd_4 = 4,
+ LoopInd_8 = 8
+} IROLoopIndFlags;
+
+typedef enum IROLoopFlags {
+ LoopFlags_1 = 1, // LP_INDUCTION_AT_LEFT
+ LP_LOOP_HAS_CALLS = 2,
+ LP_LOOP_HAS_CNTRLFLOW = 4,
+ LoopFlags_8 = 8, // LP_HAS_NONASSIGN
+ LP_INDUCTION_NOT_FOUND = 0x10,
+ LP_IFEXPR_NON_CANONICAL = 0x20,
+ LP_HAS_MULTIPLE_INDUCTIONS = 0x40,
+ LP_LOOP_HDR_HAS_SIDEEFFECTS = 0x80,
+ LP_LOOP_STEP_ISADD = 0x100,
+ LoopFlags_200 = 0x200, // LP_HEADER_FOLLOWS_UPDATE?
+ LP_LOOP_STEP_ISPOS = 0x400,
+ LoopFlags_800 = 0x800, // LP_IND_USED_IN_LOOP
+ LoopFlags_1000 = 0x1000, // LP_HAS_MULTIPLE_EXITS
+ LoopFlags_2000 = 0x2000, // inverse of LP_LOOP_STEP_ISADD?
+ LP_LOOP_STEP_ISNEG = 0x4000,
+ LP_LOOP_HAS_ASM = 0x8000,
+ LoopFlags_10000 = 0x10000, // LP_WHILE_LOOP
+ LoopFlags_20000 = 0x20000, // maybe LP_RECURSIVE_LOOP?
+ LoopFlags_40000 = 0x40000 // LP_IS_REDUCTION_CAND
+} IROLoopFlags;
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+typedef struct IROLoopInd {
+ IROLoopIndFlags flags;
+ VarRecord *var;
+ IRONode *fnode;
+ IROLinear *nd;
+ SInt32 addConst;
+ IROLinear *addNode;
+ struct IROLoopInd *next;
+} IROLoopInd;
+
+struct IROLoop {
+ SInt32 flags;
+ IRONode *fnode;
+ int x8;
+ IRONode *xC;
+ IRONode *x10;
+ IROLinear *nd14; // assignment expression that sets the initial value of induction
+ IROLinear *nd18; // ifexpr?
+ IROLoopInd *induction;
+ int index20;
+ int index24;
+ CInt64 x28;
+ CInt64 x30;
+ int sizeBySomeMeasurement;
+};
+
+typedef enum IROLoopMemRefFlags {
+ LoopMemRef_1 = 1,
+ LoopMemRef_2 = 2,
+ LoopMemRef_4 = 4,
+ LoopMemRef_8 = 8,
+ LoopMemRef_10 = 0x10
+} IROLoopMemRefFlags;
+
+typedef struct IROLoopMemRef {
+ IROLoopMemRefFlags flags;
+ IROLinear *nd;
+ IROElmList *list;
+ IROAddrRecord *rec;
+ struct IROLoopMemRef *next;
+} IROLoopMemRef;
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+extern IRONode *LoopNode;
+extern Boolean ConditionalHeaderAtBottom;
+extern IROLoopInd *FirstInd;
+extern BitVector *InLoop;
+extern IROList IRO_InitLList;
+extern BitVector *InLoop_Exits;
+extern BitVector *InLoop_Tails;
+extern UInt32 LoopExitNumber;
+extern UInt32 LoopTailNum;
+extern IRONode *LoopExitSuccessor;
+extern IRONode *LoopTail;
+extern IROLoopMemRef *IRO_LoopMemRefFirst;
+extern IROLoopMemRef *IRO_LoopMemRefCurrent;
+
+extern void FindMustReach(void);
+extern void FindMustReach1(IRONode *checkfnode);
+extern void AddPreds(IRONode *fnode);
+extern void IncLoopDepth(void);
+extern void IRO_SetLoopDepth(void);
+extern void IRO_FindLoops(void);
+extern void ComputeLoopKills(void);
+extern void ComputeLoopInvariance(void);
+extern void ComputeLoopInduction(void);
+extern void FindAssignmenttoInductionVar(IROLoop *loop, IRONode *fnode);
+extern IROLoop *ExtractLoopInfo(IRONode *fnode);
+extern CLabel *BuildLabel(IROList *list);
+
+#endif