MWCC/includes/compiler/IroUtil.h

128 lines
4.7 KiB
C
Raw Normal View History

#ifndef COMPILER_IROUTIL_H
#define COMPILER_IROUTIL_H
#include "compiler/IrOptimizer.h"
2023-01-10 11:05:21 +00:00
#include "compiler/CInt64.h"
#include "compiler/CParser.h"
#ifdef __MWERKS__
#pragma options align=mac68k
#endif
struct IROList {
IROLinear *head;
IROLinear *tail;
};
struct IROListNode {
IROList list;
IROListNode *nextList;
};
struct IROElmList {
void *element;
IROElmList *next;
};
struct IROAddrRecord {
IROLinear *linear;
unsigned short numObjRefs;
IROElmList *objRefs;
unsigned short numMisc;
IROElmList *misc;
unsigned short numInts;
IROElmList *ints;
int x16;
};
#ifdef __MWERKS__
#pragma options align=reset
#endif
extern Object *FunctionName;
extern Boolean IRO_IsLeafFunction;
extern Boolean IRO_FunctionHasReturn;
extern Boolean DisableDueToAsm;
extern Boolean LoopOptimizerRun;
extern Object *IRO_IsVariable(IROLinear *linear);
extern Boolean IRO_IsConstant(IROLinear *linear);
extern Boolean IRO_IsPow2(IROLinear *linear, SInt32 *powvalue);
extern Boolean IRO_IsIntConstant(IROLinear *linear);
extern Boolean IRO_IsFloatConstant(IROLinear *linear);
extern Boolean IRO_IsVector128Constant(IROLinear *linear);
extern Boolean IRO_IsAssignment(IROLinear *linear);
extern Boolean IRO_TypesEqual(Type *a, Type *b);
extern Type *IRO_UnsignedType(Type *type);
extern Type *IRO_SignedType(Type *type);
extern Boolean IRO_is_CPtypeequal(Type *a, Type *b);
extern Boolean IRO_ExprsSame(IROLinear *a, IROLinear *b);
extern CLabel *IRO_NewLabel(void);
extern Boolean IRO_ExprsSameSemantically(IROLinear *a, IROLinear *b);
extern IROLinear *IRO_FindPrecedAfter(IROLinear *a, IROLinear *iter);
extern IROLinear *IRO_FindPreced(IROLinear *a);
extern IROLinear *IRO_FindFirst(IROLinear *linear);
extern void IRO_CutAndPasteAfter(IROLinear *a, IROLinear *b, IROLinear *c);
extern Boolean IRO_IsConstantZero(IROLinear *linear);
extern Boolean IRO_IsConstantOne(IROLinear *linear);
extern Boolean IRO_IsConstantNegativeOne(IROLinear *linear);
extern void IRO_NopOut(IROLinear *linear);
extern void IRO_NopNonSideEffects(IROLinear *linear, SInt32 level);
extern void IRO_BuildList(IROLinear *linear, Boolean isEntry);
typedef void (*IROWalkTreeFunc)(IROLinear *linear, Boolean isEntry);
extern void IRO_WalkTree(IROLinear *linear, IROWalkTreeFunc func);
extern void IRO_WalkTreeToPropagateFlags(IROLinear *linear, IROWalkTreeFunc func);
extern void IRO_WalkInts(IROLinear *a, IROLinear *b, IROWalkTreeFunc func);
extern void IRO_Cut(IROLinear *a, IROLinear *b);
extern void IRO_Paste(IROLinear *a, IROLinear *b, IROLinear *c);
extern void IRO_PasteAfter(IROLinear *a, IROLinear *b, IROLinear *c);
extern void IRO_ClipExpr(IROExpr *expr);
extern void IRO_ClipExprTree(IROLinear *linear);
extern void IRO_MoveExpression(IROExpr *expr, IROLinear *linear);
extern void IRO_InitList(IROList *list);
extern void IRO_AddToList(IROLinear *linear, IROList *list);
extern IROLinear *IRO_FindLabelNode(CLabel *label, IROLinear *linear);
extern void IRO_DuplicateExprRange(IROLinear *start, IROLinear *end, IROList *list);
extern IROLinear *IRO_DuplicateExpr(IROLinear *linear, IROList *list);
extern IROLinear *IRO_TempReference(Object *obj, IROList *list);
extern IROLinear *IRO_LocateFather(IROLinear *linear);
extern IROLinear *IRO_LocateFather_Cut_And_Paste(IROLinear *a, IROLinear *b);
extern IROLinear *IRO_LocateFather_Cut_And_Paste_Without_Nopping(IROLinear *a, IROLinear *b);
extern void IRO_ReplaceReference(IROLinear *a, Object *obj, IROLinear *b);
extern void IRO_ReplaceReferenceWithNode(IROLinear *a, IROLinear *b);
2023-01-10 11:05:21 +00:00
extern VarRecord *IRO_GetTemp(IROExpr *expr);
extern IROLinear *IRO_AssignToTemp(IROExpr *expr);
extern IROLinear *IRO_FindStart(IROLinear *linear);
extern void IRO_DeleteCommaNode(IROLinear *linear, IROExpr *expr);
extern void IRO_RemoveCommaNodeFromIR(void);
extern IROAddrRecord *IRO_InitAddrRecordPointer(IROLinear *linear);
extern IROLinear *IRO_HasSideEffect(IROLinear *linear);
extern IROLinear *IRO_CheckSideEffect(IROLinear *linear);
typedef void (*WalkObjFunc)(Object *obj);
extern void IRO_WalkExcActions(ExceptionAction *action, WalkObjFunc func);
extern Boolean IRO_FunctionCallMightThrowException(IROLinear *linear);
extern IROLinear *IRO_NewIntConst(CInt64 val, Type *type);
2023-01-10 11:05:21 +00:00
extern IROLinear *IRO_NewFloatConst(const Float val, Type *type);
extern Boolean IRO_IsAddressMultiply(IROLinear *linear);
extern void IRO_SetupForUserBreakChecking(void);
extern void IRO_CheckForUserBreak(void);
// TODO is this elsewhere?
2023-01-11 23:26:04 +00:00
CW_INLINE Boolean IRO_IsUnsignedType(Type *type) {
return is_unsigned(type);
}
2023-01-10 11:05:21 +00:00
// 4B4D40
2023-01-11 23:26:04 +00:00
CW_INLINE CInt64 IRO_MakeULong(UInt32 i) {
2023-01-10 11:05:21 +00:00
CInt64 val;
CInt64_SetULong(&val, i);
return val;
}
// 4BAAA0
2023-01-11 23:26:04 +00:00
CW_INLINE CInt64 IRO_MakeLong(SInt32 i) {
2023-01-10 11:05:21 +00:00
CInt64 val;
CInt64_SetLong(&val, i);
return val;
}
#endif