MWCC/includes/compiler/CInline.h

168 lines
4.1 KiB
C
Raw Normal View History

2022-11-07 03:06:21 +00:00
#ifndef COMPILER_CINLINE_H
#define COMPILER_CINLINE_H
#include "compiler/common.h"
#include "compiler/tokens.h"
#include "compiler/CFunc.h"
#ifdef __MWERKS__
#pragma options align=mac68k
#endif
2023-01-10 11:05:21 +00:00
// Not sure if these two are actually in CInline or not
typedef struct XRefOffset {
UInt32 xrefoffset;
SInt32 offset;
} XRefOffset;
struct InlineXRef {
InlineXRef *next;
Object *object;
UInt16 xrefmode;
UInt16 numxrefs;
XRefOffset xref[1];
};
2022-11-07 03:06:21 +00:00
typedef struct CI_Var {
HashNameNode *name;
Type *type;
UInt32 qual;
UInt8 sflags;
2022-12-29 12:32:55 +00:00
SInt8 xD;
SInt8 xE;
2022-11-07 03:06:21 +00:00
} CI_Var;
2022-12-29 12:32:55 +00:00
enum {
CI_SFLAGS_NoClass = 0,
CI_SFLAGS_Register = 1,
CI_SFLAGS_Auto = 2,
CI_SFLAGS_HasObjectFlag2 = 0x80
};
typedef struct CI_SwitchCase {
short labelID;
CInt64 min;
CInt64 max;
} CI_SwitchCase;
2022-11-07 03:06:21 +00:00
typedef struct CI_Switch {
2022-12-29 12:32:55 +00:00
ENode *expr;
2023-01-10 11:05:21 +00:00
Type *unkSwitch8;
2022-12-29 12:32:55 +00:00
short defaultlabelID;
short numcases;
2023-01-10 11:05:21 +00:00
CI_SwitchCase cases[1];
2022-11-07 03:06:21 +00:00
} CI_Switch;
typedef struct CI_Statement {
StatementType type;
UInt8 flags;
UInt16 value;
SInt32 sourceoffset;
HashNameNode *sourcefilepath;
ExceptionAction *dobjstack;
union {
SInt16 statementnum;
ENode *expr;
struct {
ENode *expr;
SInt16 statementnum;
} ifgoto;
CI_Switch *switchdata;
2022-12-29 12:32:55 +00:00
struct {
void *data;
SInt32 size;
} asmdata;
2022-11-07 03:06:21 +00:00
} u;
} CI_Statement;
2022-12-29 12:32:55 +00:00
typedef enum {
CI_CanInline0,
CI_CanInline1,
CI_CanInline2,
CI_CanInline3,
CI_CanInline4,
CI_CanInline5,
CI_CanInline6
} CI_CanInline;
2022-11-07 03:06:21 +00:00
struct CI_FuncData {
short numarguments;
CI_Var *arguments;
short numlocals;
CI_Var *locals;
short numstatements;
CI_Statement *statements;
FileOffsetInfo fileoffset;
SInt32 symdecloffset;
SInt32 functionbodyoffset;
HashNameNode *functionbodypath;
SInt32 symdeclend;
2022-12-29 12:32:55 +00:00
UInt8 can_inline;
2022-11-07 03:06:21 +00:00
};
typedef enum {
CI_ActionInlineFunc = 0,
CI_ActionMemberFunc = 1,
CI_ActionTemplateFunc = 2,
CI_ActionDefaultFunc = 3
} CI_ActionType;
typedef struct CI_Action {
struct CI_Action *next;
Object *obj;
union {
struct {
FileOffsetInfo fileoffset;
TStream stream;
TypeClass *tclass;
} inlinefunc;
struct {
2022-12-29 12:32:55 +00:00
TemplClass *templ;
TemplClassInst *inst;
2022-11-07 03:06:21 +00:00
TemplateMember *tmemb;
} memberfunc;
struct {
TemplateFunction *func;
TemplFuncInstance *inst;
} templatefunc;
} u;
2022-12-29 12:32:55 +00:00
CI_ActionType actiontype;
2022-11-07 03:06:21 +00:00
} CI_Action;
typedef enum {
CopyMode0,
CopyMode1,
CopyMode2,
CopyMode3,
CopyMode4
} CInlineCopyMode;
extern CI_Action *cinline_tactionlist;
extern void CInline_Init(void);
2022-12-29 12:32:55 +00:00
extern SInt32 CInline_GetLocalID(Object *object);
2022-11-07 03:06:21 +00:00
extern Boolean CInline_ExpressionHasSideEffect(ENode *expr);
extern ENode *CInline_CopyExpression(ENode *expr, CInlineCopyMode mode);
extern void CInline_SerializeStatement(Statement *stmt);
extern Object *CInline_GetLocalObj(SInt32 id, Boolean flag);
extern SInt16 CInline_GetStatementNumber(Statement *first, Statement *stmt);
2022-12-29 12:32:55 +00:00
extern void CInline_PackIFunctionData(CI_FuncData *packed, Statement *stmt, Object *object);
extern void CInline_UnpackIFunctionData(Object *object, CI_FuncData *packed, Statement *firstStmt);
extern void CInline_AddDefaultFunctionAction(Object *object);
extern void CInline_AddInlineFunctionAction(Object *object, TypeClass *tclass, FileOffsetInfo *fileoffset, TStream *stream, Boolean flag);
extern void CInline_AddMemberFunctionAction(Object *object, TemplClass *templ, TemplClassInst *inst, TemplateMember *tmemb);
extern void CInline_AddTemplateFunctionAction(Object *object, TemplateFunction *func, TemplFuncInstance *inst);
extern void CInline_ObjectAddrRef(Object *object);
extern void CInline_GenFunc(Statement *stmt, Object *object, UInt8 unk);
2022-11-07 03:06:21 +00:00
extern Boolean CInline_CanFreeLHeap(void);
extern Boolean CInline_GenerateDeferredFuncs(void);
extern void CInline_Finish(void);
#ifdef __MWERKS__
#pragma options align=reset
#endif
#endif