summaryrefslogtreecommitdiff
path: root/compiler_and_linker/FrontEnd/Optimizer/IroLinearForm.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/IroLinearForm.h
parentfc0c4c0df7b583b55a08317cf1ef6a71d27c0440 (diff)
downloadMWCC-main.tar.gz
MWCC-main.zip
move lots of source files around to match their actual placement in the original treemain
Diffstat (limited to 'compiler_and_linker/FrontEnd/Optimizer/IroLinearForm.h')
-rw-r--r--compiler_and_linker/FrontEnd/Optimizer/IroLinearForm.h165
1 files changed, 165 insertions, 0 deletions
diff --git a/compiler_and_linker/FrontEnd/Optimizer/IroLinearForm.h b/compiler_and_linker/FrontEnd/Optimizer/IroLinearForm.h
new file mode 100644
index 0000000..c0b2d17
--- /dev/null
+++ b/compiler_and_linker/FrontEnd/Optimizer/IroLinearForm.h
@@ -0,0 +1,165 @@
+#ifndef COMPILER_IROLINEARFORM_H
+#define COMPILER_IROLINEARFORM_H
+
+#include "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