2022-11-20 05:07:22 +00:00
|
|
|
#ifndef COMPILER_IROUTIL_H
|
|
|
|
#define COMPILER_IROUTIL_H
|
|
|
|
|
2022-12-14 00:16:59 +00:00
|
|
|
#include "compiler/IrOptimizer.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);
|
|
|
|
extern void 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);
|
|
|
|
extern IROLinear *IRO_NewFloatConst(Float val, Type *type);
|
|
|
|
extern Boolean IRO_IsAddressMultiply(IROLinear *linear);
|
|
|
|
extern void IRO_SetupForUserBreakChecking(void);
|
|
|
|
extern void IRO_CheckForUserBreak(void);
|
|
|
|
|
|
|
|
// TODO is this elsewhere?
|
|
|
|
inline Boolean IRO_IsUnsignedType(Type *type) {
|
|
|
|
return is_unsigned(type);
|
|
|
|
}
|
2022-11-20 05:07:22 +00:00
|
|
|
|
|
|
|
#endif
|