mirror of https://git.wuffs.org/MWCC
getting close to done
This commit is contained in:
parent
fcfbafff31
commit
aec1b8dddc
|
@ -281,7 +281,7 @@ static Boolean dofreeaheap;
|
|||
static GList mlist;
|
||||
static Handle ts_buffer;
|
||||
static TStreamElement *ts_first;
|
||||
static TStreamElement *ts_last;
|
||||
TStreamElement *ts_last;
|
||||
TStreamElement *ts_current;
|
||||
static SInt32 ts_elements;
|
||||
SInt32 ts_preread_elements;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -93,7 +93,7 @@ void CScope_SetFunctionScope(Object *function, CScopeSave *save) {
|
|||
}
|
||||
}
|
||||
|
||||
void CScope_SetMethodScope(Object *function, TypeClass *cls, Boolean unknownFlag, CScopeSave *save) {
|
||||
void CScope_SetMethodScope(Object *function, TypeClass *cls, Boolean is_static, CScopeSave *save) {
|
||||
save->current = cscope_current;
|
||||
save->currentclass = cscope_currentclass;
|
||||
save->currentfunc = cscope_currentfunc;
|
||||
|
@ -102,7 +102,7 @@ void CScope_SetMethodScope(Object *function, TypeClass *cls, Boolean unknownFlag
|
|||
cscope_currentfunc = function;
|
||||
cscope_currentclass = cls;
|
||||
cscope_current = cls->nspace;
|
||||
cscope_is_member_func = !unknownFlag;
|
||||
cscope_is_member_func = !is_static;
|
||||
}
|
||||
|
||||
void CScope_RestoreScope(CScopeSave *saved) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,68 +1,30 @@
|
|||
#include "compiler/CDecl.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/CABI.h"
|
||||
#include "compiler/CBrowse.h"
|
||||
#include "compiler/CClass.h"
|
||||
#include "compiler/CError.h"
|
||||
#include "compiler/CException.h"
|
||||
#include "compiler/CExpr.h"
|
||||
#include "compiler/CFunc.h"
|
||||
#include "compiler/CInit.h"
|
||||
#include "compiler/CInline.h"
|
||||
#include "compiler/CInt64.h"
|
||||
#include "compiler/CMachine.h"
|
||||
#include "compiler/CMangler.h"
|
||||
#include "compiler/CObjC.h"
|
||||
#include "compiler/CParser.h"
|
||||
#include "compiler/CPrep.h"
|
||||
#include "compiler/CPrepTokenizer.h"
|
||||
#include "compiler/CSOM.h"
|
||||
#include "compiler/CTemplateClass.h"
|
||||
#include "compiler/CTemplateFunc.h"
|
||||
#include "compiler/CTemplateNew.h"
|
||||
#include "compiler/CTemplateTools.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/objects.h"
|
||||
#include "compiler/scopes.h"
|
||||
#include "compiler/templates.h"
|
||||
#include "compiler/tokens.h"
|
||||
#include "compiler/CPrep.h"
|
||||
#include "compiler/CPrepTokenizer.h"
|
||||
#include "compiler/CMangler.h"
|
||||
#include "compiler/CClass.h"
|
||||
#include "compiler/CParser.h"
|
||||
#include "compiler/CFunc.h"
|
||||
#include "compiler/CInit.h"
|
||||
#include "compiler/CInt64.h"
|
||||
#include "compiler/CExpr.h"
|
||||
#include "compiler/CMachine.h"
|
||||
#include "compiler/CInline.h"
|
||||
#include "compiler/CABI.h"
|
||||
|
||||
// TODO MOVE ME
|
||||
extern void CExcept_ScanExceptionSpecification(TypeFunc *tfunc);
|
||||
extern void CExcept_CompareSpecifications(ExceptSpecList *a, ExceptSpecList *b);
|
||||
extern void CObjC_ParseDefs(TypeStruct *tstruct);
|
||||
extern void CTempl_Parse(TypeClass *tclass, short access);
|
||||
extern Boolean CTempl_InstantiateTemplateClass(TemplClass *cls);
|
||||
extern Boolean CTemplTool_IsTemplateArgumentDependentType(Type *type);
|
||||
extern TemplClass *CTemplTool_GetSelfRefTemplate(Type *type);
|
||||
extern Type *CTemplTool_ResolveMemberSelfRefs(TypeClass *tclass, Type *type, UInt32 *qual);
|
||||
extern Boolean CTempl_IsQualifiedMember(DeclInfo *declinfo, Type *type, NameSpace **nspace);
|
||||
extern Object *CTempl_TemplateFunctionCheck(DeclInfo *declinfo, NameSpaceObjectList *list);
|
||||
extern TemplArg *CTempl_ParseUncheckTemplArgs(void *a, Boolean flag);
|
||||
extern TemplArg *CTemplTool_MakeGlobalTemplArgCopy(TemplArg *args);
|
||||
extern void CTemplClass_RegisterFriend(TemplClass *tmclass, DeclInfo *declinfo);
|
||||
extern void CTemplClass_RegisterBaseClass(TemplClass *tmclass, Type *baseclass, short access, Boolean is_virtual);
|
||||
extern void CTemplClass_RegisterObjectDef(TemplClass *tmclass, ObjBase *obj);
|
||||
extern void CTemplClass_RegisterObjectInit(TemplClass *tmclass, ObjBase *obj, ENode *expr);
|
||||
extern void CTemplClass_DefineMember(TemplClass *tmclass, Object *obj, FileOffsetInfo *fileoffset, TStream *stream);
|
||||
extern void CTemplClass_CompleteClass(TemplClass *templ, DeclE *decle);
|
||||
extern void CTemplClass_RegisterEnumType(TemplClass *tmclass, TypeEnum *tenum);
|
||||
extern void CTemplClass_RegisterEnumerator(TemplClass *tmclass, ObjEnumConst *oec, ENode *expr);
|
||||
extern TypeClass *CTemplClass_DefineNestedClass(TemplClass *tmclass, HashNameNode *name, short mode);
|
||||
extern void CSOM_FixNewDeleteFunctype(TypeFunc *tfunc);
|
||||
extern void CSOM_CheckFuncType(TypeFunc *tfunc);
|
||||
extern void CSOM_ClassComplete(TypeClass *tclass);
|
||||
extern void CSOM_MakeSOMClass(TypeClass *tclass);
|
||||
typedef struct BrowseStruct {
|
||||
void *x0;
|
||||
void *x4;
|
||||
void *x8;
|
||||
void *xC;
|
||||
} BrowseStruct;
|
||||
extern void CBrowse_BeginStruct(DeclInfo *declinfo, TypeStruct *type, BrowseStruct *bs);
|
||||
extern void CBrowse_EndStruct(SInt32 offset, BrowseStruct *bs);
|
||||
extern void CBrowse_AddStructMember(StructMember *member, SInt32 tokenoffset, SInt32 fileoffset);
|
||||
extern void CBrowse_BeginClass(DeclInfo *declinfo, BrowseStruct *bs);
|
||||
extern void CBrowse_EndClass(SInt32 offset, BrowseStruct *bs);
|
||||
extern void CBrowse_NewTypedef(NameSpace *nspace, HashNameNode *name, CPrepFileInfo *file, SInt32 tokenline, SInt32 tokenoffset, SInt32 fileoffset);
|
||||
extern void CBrowse_NewData(Object *obj, CPrepFileInfo *file, SInt32 tokenline, SInt32 tokenoffset, SInt32 fileoffset);
|
||||
extern void CBrowse_NewFunction(Object *obj, CPrepFileInfo *file, CPrepFileInfo *file2, SInt32 tokenoffset, SInt32 fileoffset);
|
||||
extern void CBrowse_NewEnum(NameSpace *nspace, HashNameNode *name, CPrepFileInfo *file, CPrepFileInfo *file2, SInt32 tokenoffset, SInt32 fileoffset);
|
||||
extern void CBrowse_NewEnumConstant(NameSpace *nspace, HashNameNode *name, CPrepFileInfo *file, CPrepFileInfo *file2, SInt32 tokenoffset, SInt32 fileoffset);
|
||||
extern void CBrowse_AddClassMemberData(Object *obj, SInt32 tokenoffset, SInt32 fileoffset);
|
||||
extern void CBrowse_AddClassMemberFunction(Object *obj, SInt32 tokenoffset, SInt32 fileoffset);
|
||||
extern void CBrowse_AddClassMemberVar(ObjMemberVar *obj, SInt32 tokenoffset, SInt32 fileoffset);
|
||||
|
||||
AccessType global_access;
|
||||
FileOffsetInfo member_fileoffset;
|
||||
|
@ -213,7 +175,7 @@ void CDecl_CompleteType(Type *type) {
|
|||
}
|
||||
|
||||
if ((TYPE_CLASS(type)->flags & (CLASS_FLAGS_2 | CLASS_FLAGS_800)) == CLASS_FLAGS_800)
|
||||
CTempl_InstantiateTemplateClass(TEMPL_CLASS(type));
|
||||
CTempl_InstantiateTemplateClass(TYPE_CLASS(type));
|
||||
}
|
||||
|
||||
Boolean IsCompleteType(Type *type) {
|
||||
|
@ -231,8 +193,14 @@ Boolean IsCompleteType(Type *type) {
|
|||
}
|
||||
return 1;
|
||||
case TYPECLASS:
|
||||
if (!(TYPE_CLASS(type)->flags & CLASS_FLAGS_2) && (!(TYPE_CLASS(type)->flags & CLASS_FLAGS_800) || !CTempl_InstantiateTemplateClass(
|
||||
TEMPL_CLASS(type)))) {
|
||||
if (
|
||||
!(TYPE_CLASS(type)->flags & CLASS_FLAGS_2) &&
|
||||
(
|
||||
!(TYPE_CLASS(type)->flags & CLASS_FLAGS_800) ||
|
||||
!CTempl_InstantiateTemplateClass(TYPE_CLASS(type))
|
||||
)
|
||||
)
|
||||
{
|
||||
CError_Error(136, type, 0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -418,7 +386,7 @@ void CDecl_ParseDirectFuncDecl(DeclInfo *declinfo) {
|
|||
|
||||
if (copts.cplusplus) {
|
||||
CDecl_ParseCPPFuncDecl(tfunc);
|
||||
if (declinfo->storageclass == OBJECT_SCLASS_104 && tfunc->exspecs)
|
||||
if (declinfo->storageclass == TK_TYPEDEF && tfunc->exspecs)
|
||||
CError_Error(264);
|
||||
}
|
||||
|
||||
|
@ -638,11 +606,13 @@ static Boolean CDecl_IsEnumClassTypeOrRef(Type *type) {
|
|||
return IS_TYPE_CLASS(type) || IS_TYPE_ENUM(type);
|
||||
}
|
||||
|
||||
#define OpMysteryValue0 0
|
||||
#define OpMysteryValue1 1
|
||||
#define OpMysteryValue2 2
|
||||
#define OpMysteryValue3 3
|
||||
#define OpMysteryValue4 4
|
||||
typedef enum OpMysteryValue {
|
||||
OpMysteryValue0 = 0,
|
||||
OpMysteryValue1 = 1,
|
||||
OpMysteryValue2 = 2,
|
||||
OpMysteryValue3 = 3,
|
||||
OpMysteryValue4 = 4
|
||||
} OpMysteryValue;
|
||||
|
||||
static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) {
|
||||
FuncArg *args;
|
||||
|
@ -675,7 +645,11 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) {
|
|||
|
||||
secondarg = args->next;
|
||||
if (secondarg) {
|
||||
r27 = ((secondarg != &elipsis && !secondarg->next) != 0) ? OpMysteryValue4 : OpMysteryValue3;
|
||||
//r27 = ((secondarg != &elipsis && !secondarg->next) != 0) ? OpMysteryValue2 : OpMysteryValue3;
|
||||
if ((secondarg != &elipsis && !secondarg->next) != 0)
|
||||
r27 = OpMysteryValue2;
|
||||
else
|
||||
r27 = OpMysteryValue3;
|
||||
if (secondarg->dexpr) {
|
||||
switch (declinfo->x3E) {
|
||||
case '(':
|
||||
|
@ -1416,11 +1390,11 @@ void CheckDefaultArgs(FuncArg *args) {
|
|||
}
|
||||
|
||||
static void CDecl_FuncRedeclCheck(Object *obj, DeclInfo *declinfo, Boolean flag) {
|
||||
if (declinfo->storageclass == OBJECT_SCLASS_102 && obj->sclass != OBJECT_SCLASS_102) {
|
||||
if (declinfo->storageclass == TK_STATIC && obj->sclass != TK_STATIC) {
|
||||
if (copts.cplusplus)
|
||||
CError_Error(260);
|
||||
else
|
||||
obj->sclass = OBJECT_SCLASS_102;
|
||||
obj->sclass = TK_STATIC;
|
||||
}
|
||||
|
||||
obj->qual |= declinfo->qual;
|
||||
|
@ -1460,8 +1434,7 @@ Object *CDecl_GetFunctionObject(DeclInfo *declinfo, NameSpace *nspace, Boolean *
|
|||
}
|
||||
|
||||
if (nspace2->theclass) {
|
||||
#line 1969
|
||||
CError_ASSERT(declinfo->name);
|
||||
CError_ASSERT(1969, declinfo->name);
|
||||
if (!nspace2->theclass->size)
|
||||
CDecl_CompleteType((Type *) nspace2->theclass);
|
||||
if (!(list = CScope_GetLocalObject(nspace2, declinfo->name))) {
|
||||
|
@ -1614,8 +1587,7 @@ void CDecl_TypedefDeclarator(DeclInfo *declinfo) {
|
|||
CError_Error(322);
|
||||
return;
|
||||
default:
|
||||
#line 2156
|
||||
CError_FATAL();
|
||||
CError_FATAL(2156);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1654,8 +1626,8 @@ void CDecl_TypedefDeclarator(DeclInfo *declinfo) {
|
|||
}
|
||||
}
|
||||
|
||||
if (cparamblkptr->browseOptions.recordTypedefs && declinfo->fileoffsetinfo.file->recordbrowseinfo)
|
||||
CBrowse_NewTypedef(nspace, declinfo->name, declinfo->fileoffsetinfo.file, declinfo->fileoffsetinfo.tokenline, declinfo->fileoffsetinfo.tokenoffset, CPrep_BrowserFileOffset());
|
||||
if (cparamblkptr->browseOptions.recordTypedefs && declinfo->file->recordbrowseinfo)
|
||||
CBrowse_NewTypedef(nspace, declinfo->name, declinfo->file, declinfo->file2, declinfo->x60, CPrep_BrowserFileOffset());
|
||||
}
|
||||
|
||||
static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag) {
|
||||
|
@ -1697,8 +1669,7 @@ static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag)
|
|||
CError_Error(221);
|
||||
break;
|
||||
default:
|
||||
#line 2281
|
||||
CError_FATAL();
|
||||
CError_FATAL(2281);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1706,24 +1677,24 @@ static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag)
|
|||
if (!flag)
|
||||
CDecl_CompleteType(declinfo->thetype);
|
||||
switch (declinfo->storageclass) {
|
||||
case OBJECT_SCLASS_103:
|
||||
case TK_EXTERN:
|
||||
if (tk == '=' || tk == '(')
|
||||
declinfo->storageclass = 0;
|
||||
break;
|
||||
case 0:
|
||||
if (CParser_IsConst(declinfo->thetype, declinfo->qual)) {
|
||||
if ((!obj && !nspace->theclass) || (obj && obj->sclass != OBJECT_SCLASS_103 && !obj->nspace->theclass))
|
||||
declinfo->storageclass = OBJECT_SCLASS_102;
|
||||
if ((!obj && !nspace->theclass) || (obj && obj->sclass != TK_EXTERN && !obj->nspace->theclass))
|
||||
declinfo->storageclass = TK_STATIC;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (declinfo->storageclass == OBJECT_SCLASS_103 && tk == '=')
|
||||
if (declinfo->storageclass == TK_EXTERN && tk == '=')
|
||||
declinfo->storageclass = 0;
|
||||
}
|
||||
|
||||
if (IS_TYPE_ARRAY(declinfo->thetype) && !declinfo->thetype->size && !declinfo->storageclass && tk != '=')
|
||||
declinfo->storageclass = OBJECT_SCLASS_103;
|
||||
declinfo->storageclass = TK_EXTERN;
|
||||
|
||||
if (obj) {
|
||||
if ((!obj->type->size || !declinfo->thetype->size) && IS_TYPE_ARRAY(declinfo->thetype) && IS_TYPE_ARRAY(obj->type))
|
||||
|
@ -1740,8 +1711,8 @@ static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag)
|
|||
CError_Error(333, obj);
|
||||
}
|
||||
|
||||
if (declinfo->storageclass != OBJECT_SCLASS_103) {
|
||||
if (obj->sclass != OBJECT_SCLASS_103 && declinfo->storageclass && obj->sclass != declinfo->storageclass)
|
||||
if (declinfo->storageclass != TK_EXTERN) {
|
||||
if (obj->sclass != TK_EXTERN && declinfo->storageclass && obj->sclass != declinfo->storageclass)
|
||||
CError_Error(333, obj);
|
||||
|
||||
if (tmpflag) {
|
||||
|
@ -1788,15 +1759,14 @@ static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag)
|
|||
CInit_InitializeData(obj);
|
||||
}
|
||||
|
||||
if (declinfo->fileoffsetinfo.file->recordbrowseinfo && obj->sclass != OBJECT_SCLASS_103)
|
||||
CBrowse_NewData(obj, declinfo->fileoffsetinfo.file, declinfo->fileoffsetinfo.tokenline, declinfo->fileoffsetinfo.tokenoffset, CPrep_BrowserFileOffset());
|
||||
if (declinfo->file->recordbrowseinfo && obj->sclass != TK_EXTERN)
|
||||
CBrowse_NewData(obj, declinfo->file, declinfo->file2, declinfo->x60, CPrep_BrowserFileOffset());
|
||||
} else if (tk == '=') {
|
||||
tk = lex();
|
||||
expr = CExpr_IntegralConstOrDepExpr();
|
||||
if (IS_TYPE_TEMPLATE(obj->type) || !ENODE_IS(expr, EINTCONST)) {
|
||||
#line 2426
|
||||
CError_ASSERT(nspace->theclass && (nspace->theclass->flags & CLASS_FLAGS_100));
|
||||
CTemplClass_RegisterObjectInit(TEMPL_CLASS(nspace->theclass), OBJ_BASE(obj), expr);
|
||||
CError_ASSERT(2426, nspace->theclass && (nspace->theclass->flags & CLASS_FLAGS_100));
|
||||
CTemplClass_RegisterObjectInit(TEMPL_CLASS(nspace->theclass), obj, expr);
|
||||
} else if ((obj->qual & Q_CONST) && IS_TYPE_INT_OR_ENUM(obj->type)) {
|
||||
obj->u.data.u.intconst = expr->data.intval;
|
||||
obj->qual |= Q_10000 | Q_20000;
|
||||
|
@ -1820,21 +1790,20 @@ Boolean CDecl_FunctionDeclarator(DeclInfo *declinfo, NameSpace *nspace, Boolean
|
|||
}
|
||||
|
||||
if (obj->nspace == cscope_root && !strcmp(obj->name->name, "main")) {
|
||||
if (obj->sclass == OBJECT_SCLASS_102 || (copts.ANSI_strict && TYPE_FUNC(obj->type)->functype != (Type *) &stsignedint))
|
||||
if (obj->sclass == TK_STATIC || (copts.ANSI_strict && TYPE_FUNC(obj->type)->functype != (Type *) &stsignedint))
|
||||
CError_Error(334);
|
||||
} else if (copts.require_prototypes && (pflag || declinfo->fileoffsetinfo.is_inline)) {
|
||||
if (obj->sclass != OBJECT_SCLASS_102 && !(obj->qual & Q_INLINE) && !obj->nspace->is_unnamed)
|
||||
} else if (copts.require_prototypes && (pflag || declinfo->x64)) {
|
||||
if (obj->sclass != TK_STATIC && !(obj->qual & Q_INLINE) && !obj->nspace->is_unnamed)
|
||||
CError_Warning(178);
|
||||
}
|
||||
|
||||
CFunc_ParseFuncDef(obj, declinfo, NULL, 0, 0, NULL);
|
||||
// WARNING: WEIRD FileOffsetInfo ALERT
|
||||
if (declinfo->fileoffsetinfo.file->recordbrowseinfo)
|
||||
if (declinfo->file->recordbrowseinfo)
|
||||
CBrowse_NewFunction(
|
||||
obj,
|
||||
declinfo->fileoffsetinfo.file,
|
||||
(CPrepFileInfo *) declinfo->fileoffsetinfo.tokenline,
|
||||
declinfo->fileoffsetinfo.tokenoffset,
|
||||
declinfo->file,
|
||||
declinfo->file2,
|
||||
declinfo->x60,
|
||||
CPrep_BrowserFileOffset());
|
||||
|
||||
if (copts.cplusplus && lookahead() == ';')
|
||||
|
@ -1851,11 +1820,9 @@ static void CDecl_ParseSpecialMember(DeclInfo *declinfo, Boolean flag) {
|
|||
NameSpace *r25;
|
||||
|
||||
if (!(r28 = declinfo->x10)) {
|
||||
#line 2544
|
||||
CError_ASSERT(declinfo->x14);
|
||||
r28 = declinfo->x14->object;
|
||||
#line 2546
|
||||
CError_ASSERT(r28->otype == OT_OBJECT);
|
||||
CError_ASSERT(2544, declinfo->x14);
|
||||
r28 = OBJECT(declinfo->x14->object);
|
||||
CError_ASSERT(2546, r28->otype == OT_OBJECT);
|
||||
}
|
||||
|
||||
if (!r28->nspace->theclass) {
|
||||
|
@ -1900,8 +1867,7 @@ static void CDecl_ParseSpecialMember(DeclInfo *declinfo, Boolean flag) {
|
|||
}
|
||||
return;
|
||||
} else if (TYPE_FUNC(r28->type)->flags & FUNC_FLAGS_40) {
|
||||
#line 2603
|
||||
CError_FATAL();
|
||||
CError_FATAL(2603);
|
||||
|
||||
declinfo->thetype = TYPE_FUNC(r28->type)->functype;
|
||||
declinfo->qual |= TYPE_FUNC(r28->type)->qual;
|
||||
|
@ -1967,7 +1933,7 @@ void CDecl_ScanDeclarator(DeclInfo *declinfo) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (declinfo->storageclass && declinfo->storageclass != OBJECT_SCLASS_103)
|
||||
if (declinfo->storageclass && declinfo->storageclass != TK_EXTERN)
|
||||
CError_Error(177);
|
||||
|
||||
if (IS_TYPE_FUNC(declinfo->thetype)) {
|
||||
|
@ -1983,7 +1949,7 @@ void CDecl_ScanDeclarator(DeclInfo *declinfo) {
|
|||
|
||||
if (
|
||||
(declinfo->qual & ~(Q_ALIGNED_MASK | Q_OVERLOAD | Q_20000 | Q_PASCAL | Q_VOLATILE | Q_CONST)) ||
|
||||
(declinfo->storageclass == OBJECT_SCLASS_104 && (declinfo->qual & ~(Q_ALIGNED_MASK | Q_REFERENCE | Q_PASCAL | Q_VOLATILE | Q_CONST)))
|
||||
(declinfo->storageclass == TK_TYPEDEF && (declinfo->qual & ~(Q_ALIGNED_MASK | Q_REFERENCE | Q_PASCAL | Q_VOLATILE | Q_CONST)))
|
||||
)
|
||||
CError_Error(176);
|
||||
}
|
||||
|
@ -2000,8 +1966,7 @@ void scandeclaratorlist(DeclInfo *declinfo) {
|
|||
}
|
||||
|
||||
CScope_GetScope(&savescope);
|
||||
#line 2707
|
||||
CError_ASSERT(declinfo->thetype);
|
||||
CError_ASSERT(2707, declinfo->thetype);
|
||||
|
||||
r28 = 1;
|
||||
while (1) {
|
||||
|
@ -2020,7 +1985,7 @@ void scandeclaratorlist(DeclInfo *declinfo) {
|
|||
break;
|
||||
}
|
||||
|
||||
if (declinfo->storageclass != OBJECT_SCLASS_104) {
|
||||
if (declinfo->storageclass != TK_TYPEDEF) {
|
||||
if (IS_TYPE_FUNC(declinfo->thetype)) {
|
||||
if (!CDecl_FunctionDeclarator(declinfo, NULL, r28, 1))
|
||||
return;
|
||||
|
@ -2282,8 +2247,7 @@ static TypeEnum *CDecl_OldParseEnumList(TypeEnum *tenum, HashNameNode *name) {
|
|||
CError_Error(154);
|
||||
break;
|
||||
default:
|
||||
#line 3071
|
||||
CError_FATAL();
|
||||
CError_FATAL(3071);
|
||||
}
|
||||
} else {
|
||||
switch (basetype->size) {
|
||||
|
@ -2307,8 +2271,7 @@ static TypeEnum *CDecl_OldParseEnumList(TypeEnum *tenum, HashNameNode *name) {
|
|||
case 8:
|
||||
break;
|
||||
default:
|
||||
#line 3099
|
||||
CError_FATAL();
|
||||
CError_FATAL(3099);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2378,9 +2341,6 @@ void CDecl_ComputeUnderlyingEnumType(TypeEnum *tenum) {
|
|||
ObjEnumConst *oec2;
|
||||
Type *r26;
|
||||
int t;
|
||||
CInt64 maximumU;
|
||||
CInt64 unused;
|
||||
CInt64 minimum, maximum;
|
||||
|
||||
if (!copts.enumsalwaysint) {
|
||||
for (oec2 = tenum->enumlist; oec2; oec2 = oec2->next) {
|
||||
|
@ -2389,9 +2349,9 @@ void CDecl_ComputeUnderlyingEnumType(TypeEnum *tenum) {
|
|||
}
|
||||
|
||||
if (oec2) {
|
||||
unused = cint64_zero;
|
||||
minimum = cint64_zero;
|
||||
maximum = cint64_zero;
|
||||
CInt64 unused = cint64_zero;
|
||||
CInt64 minimum = cint64_zero;
|
||||
CInt64 maximum = cint64_zero;
|
||||
for (oec = tenum->enumlist; oec; oec = oec->next) {
|
||||
if (CInt64_IsNegative(&oec->val) && !is_unsigned(oec->type)) {
|
||||
if (CInt64_Less(oec->val, minimum))
|
||||
|
@ -2420,11 +2380,11 @@ void CDecl_ComputeUnderlyingEnumType(TypeEnum *tenum) {
|
|||
break;
|
||||
} while (1);
|
||||
} else {
|
||||
maximumU = cint64_zero;
|
||||
CInt64 val = cint64_zero;
|
||||
|
||||
for (oec = tenum->enumlist; oec; oec = oec->next) {
|
||||
if (CInt64_GreaterU(oec->val, maximumU))
|
||||
maximumU = oec->val;
|
||||
if (CInt64_GreaterU(oec->val, val))
|
||||
val = oec->val;
|
||||
}
|
||||
|
||||
t = 0;
|
||||
|
@ -2435,7 +2395,7 @@ void CDecl_ComputeUnderlyingEnumType(TypeEnum *tenum) {
|
|||
CError_Error(154);
|
||||
break;
|
||||
}
|
||||
if (CInt64_IsInURange(maximumU, r26->size))
|
||||
if (CInt64_IsInURange(val, r26->size))
|
||||
break;
|
||||
} while (1);
|
||||
}
|
||||
|
@ -2691,18 +2651,17 @@ void scanenum(DeclInfo *declinfo) {
|
|||
declinfo->thetype = TYPE(CDecl_ParseEnumList(NULL, name));
|
||||
}
|
||||
|
||||
if (cparamblkptr->browseOptions.recordEnums && declinfo->fileoffsetinfo.file->recordbrowseinfo)
|
||||
if (cparamblkptr->browseOptions.recordEnums && declinfo->file->recordbrowseinfo)
|
||||
CBrowse_NewEnum(
|
||||
cscope_current,
|
||||
TYPE_ENUM(declinfo->thetype)->enumname,
|
||||
declinfo->fileoffsetinfo.file,
|
||||
(CPrepFileInfo *) declinfo->fileoffsetinfo.tokenline,
|
||||
declinfo->fileoffsetinfo.tokenoffset,
|
||||
declinfo->file,
|
||||
declinfo->file2,
|
||||
declinfo->x60,
|
||||
CPrep_BrowserFileOffset());
|
||||
return;
|
||||
} else {
|
||||
#line 3851
|
||||
CError_ASSERT(!copts.cplusplus || tk != ';');
|
||||
CError_ASSERT(3851, !copts.cplusplus || tk != ';');
|
||||
tkidentifier = name;
|
||||
}
|
||||
}
|
||||
|
@ -2716,8 +2675,7 @@ void scanenum(DeclInfo *declinfo) {
|
|||
declinfo->thetype = type;
|
||||
return;
|
||||
} else {
|
||||
#line 3865
|
||||
CError_ASSERT(pr.name_4);
|
||||
CError_ASSERT(3865, pr.name_4);
|
||||
if ((tk = lex()) == '{') {
|
||||
declinfo->thetype = TYPE(CDecl_ParseEnumList(NULL, pr.name_4));
|
||||
return;
|
||||
|
@ -2759,7 +2717,7 @@ void CDecl_ScanStructDeclarator(BigDeclInfo *bde) {
|
|||
}
|
||||
|
||||
if ((!copts.ANSI_strict || copts.c9x) && !bde->declinfo2.thetype->size && IS_TYPE_ARRAY(bde->declinfo2.thetype)) {
|
||||
if (bde->declinfo2.storageclass != OBJECT_SCLASS_102 && bde->declinfo2.storageclass != OBJECT_SCLASS_104) {
|
||||
if (bde->declinfo2.storageclass != TK_STATIC && bde->declinfo2.storageclass != TK_TYPEDEF) {
|
||||
type = TYPE_POINTER(bde->declinfo2.thetype)->target;
|
||||
while (IS_TYPE_ARRAY(type))
|
||||
type = TYPE_POINTER(type)->target;
|
||||
|
@ -2771,7 +2729,7 @@ void CDecl_ScanStructDeclarator(BigDeclInfo *bde) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (bde->declinfo2.storageclass != OBJECT_SCLASS_102 && bde->declinfo2.storageclass != OBJECT_SCLASS_104) {
|
||||
if (bde->declinfo2.storageclass != TK_STATIC && bde->declinfo2.storageclass != TK_TYPEDEF) {
|
||||
if (!IS_TYPE_FUNC(bde->declinfo2.thetype) && !IsCompleteType(bde->declinfo2.thetype))
|
||||
return;
|
||||
}
|
||||
|
@ -2885,8 +2843,7 @@ static void CDecl_LayoutStruct(TypeStruct *tstruct) {
|
|||
r23 = 1;
|
||||
|
||||
if (!member->name) {
|
||||
#line 4064
|
||||
CError_ASSERT(IS_TYPE_STRUCT(member->type));
|
||||
CError_ASSERT(4064, IS_TYPE_STRUCT(member->type));
|
||||
innerbase = member->offset;
|
||||
innermember = TYPE_STRUCT(member->type)->members;
|
||||
r23 = 1;
|
||||
|
@ -3076,7 +3033,7 @@ void scanstruct(DeclInfo *declinfo, short structtype) {
|
|||
HashNameNode *name;
|
||||
TypeStruct typecopy;
|
||||
Boolean add_to_browse;
|
||||
BrowseStruct bs;
|
||||
GList gl;
|
||||
SInt32 offset;
|
||||
|
||||
if (copts.cplusplus) {
|
||||
|
@ -3127,8 +3084,8 @@ void scanstruct(DeclInfo *declinfo, short structtype) {
|
|||
type = (Type *) CDecl_DefineStruct(NULL, structtype);
|
||||
}
|
||||
|
||||
if ((add_to_browse = cparamblkptr->browseOptions.recordClasses && declinfo->fileoffsetinfo.file->recordbrowseinfo))
|
||||
CBrowse_BeginStruct(declinfo, TYPE_STRUCT(type), &bs);
|
||||
if ((add_to_browse = cparamblkptr->browseOptions.recordClasses && declinfo->file->recordbrowseinfo))
|
||||
CBrowse_BeginStruct(declinfo, TYPE_STRUCT(type), &gl);
|
||||
|
||||
typecopy = *TYPE_STRUCT(type);
|
||||
tk = lex();
|
||||
|
@ -3137,7 +3094,7 @@ void scanstruct(DeclInfo *declinfo, short structtype) {
|
|||
declinfo->thetype = type;
|
||||
|
||||
if (add_to_browse)
|
||||
CBrowse_EndStruct(offset, &bs);
|
||||
CBrowse_EndStruct(offset, &gl);
|
||||
}
|
||||
|
||||
static void InlineFunctionObject(Object *obj, TypeClass *tclass) {
|
||||
|
@ -3243,14 +3200,12 @@ static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *d
|
|||
declinfo->thetype = (Type *) tfunc;
|
||||
} else {
|
||||
tfunc = TYPE_METHOD(declinfo->thetype);
|
||||
#line 4579
|
||||
CError_ASSERT(!tclass->sominfo);
|
||||
CError_ASSERT(4579, !tclass->sominfo);
|
||||
}
|
||||
|
||||
CDecl_ExtractClassExportFlags(declinfo, tclass->eflags);
|
||||
|
||||
#line 4597
|
||||
CError_ASSERT(cscope_current == tclass->nspace);
|
||||
CError_ASSERT(4597, cscope_current == tclass->nspace);
|
||||
|
||||
if (list) {
|
||||
obj = CDecl_OverloadFunctionObject(list, declinfo, &outflag, flag4 ? OverloadMode1 : OverloadMode2, 0);
|
||||
|
@ -3491,7 +3446,7 @@ static void CDecl_ParseFriendDecl(TypeClass *tclass) {
|
|||
InlineFunctionObject(obj, tclass);
|
||||
} else {
|
||||
if (!obj->sclass)
|
||||
obj->sclass = OBJECT_SCLASS_103;
|
||||
obj->sclass = TK_EXTERN;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -3535,8 +3490,7 @@ static ObjMemberVar *CDecl_InstanceDataDeclarator(DeclE *decle, TypeClass *tclas
|
|||
case OT_TYPETAG:
|
||||
break;
|
||||
default:
|
||||
#line 4989
|
||||
CError_FATAL();
|
||||
CError_FATAL(4989);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3628,7 +3582,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode)
|
|||
}
|
||||
}
|
||||
|
||||
CTempl_Parse(tclass, access);
|
||||
CTempl_Parse(TEMPL_CLASS(tclass), access);
|
||||
tk = lex();
|
||||
continue;
|
||||
}
|
||||
|
@ -3716,7 +3670,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode)
|
|||
scandeclarator(&bde.declinfo2);
|
||||
if (IS_TYPE_FUNC(bde.declinfo2.thetype)) {
|
||||
if (r17)
|
||||
bde.declinfo2.thetype = CTemplTool_ResolveMemberSelfRefs(tclass, bde.declinfo2.thetype, &bde.declinfo2.qual);
|
||||
bde.declinfo2.thetype = CTemplTool_ResolveMemberSelfRefs(TEMPL_CLASS(tclass), bde.declinfo2.thetype, &bde.declinfo2.qual);
|
||||
if (tclass->sominfo) {
|
||||
if (TYPE_FUNC(bde.declinfo2.thetype)->args)
|
||||
CError_Error(272);
|
||||
|
@ -3856,9 +3810,9 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode)
|
|||
after_various_things:
|
||||
switch (bde.declinfo.storageclass) {
|
||||
case 0:
|
||||
case OBJECT_SCLASS_102:
|
||||
case OBJECT_SCLASS_104:
|
||||
case OBJECT_SCLASS_12B:
|
||||
case TK_STATIC:
|
||||
case TK_TYPEDEF:
|
||||
case TK_MUTABLE:
|
||||
break;
|
||||
default:
|
||||
CError_Error(177);
|
||||
|
@ -3869,11 +3823,11 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode)
|
|||
while (1) {
|
||||
CDecl_ScanStructDeclarator(&bde);
|
||||
if (r17)
|
||||
bde.declinfo2.thetype = CTemplTool_ResolveMemberSelfRefs(tclass, bde.declinfo2.thetype, &bde.declinfo2.qual);
|
||||
bde.declinfo2.thetype = CTemplTool_ResolveMemberSelfRefs(TEMPL_CLASS(tclass), bde.declinfo2.thetype, &bde.declinfo2.qual);
|
||||
if (bde.declinfo2.nspace)
|
||||
CError_Error(200);
|
||||
if (bde.declinfo2.x3E) {
|
||||
if (bde.declinfo.storageclass == OBJECT_SCLASS_12B)
|
||||
if (bde.declinfo.storageclass == TK_MUTABLE)
|
||||
CError_QualifierCheck(Q_MUTABLE);
|
||||
r19 = 0;
|
||||
switch (bde.declinfo2.x3E) {
|
||||
|
@ -3888,7 +3842,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode)
|
|||
r19 = 1;
|
||||
break;
|
||||
default:
|
||||
if (bde.declinfo2.storageclass == OBJECT_SCLASS_102)
|
||||
if (bde.declinfo2.storageclass == TK_STATIC)
|
||||
CError_Error(193);
|
||||
if (tclass->sominfo)
|
||||
CError_Error(193);
|
||||
|
@ -3908,11 +3862,11 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode)
|
|||
if (bde.declinfo2.name == constructor_name_node || bde.declinfo2.name == destructor_name_node)
|
||||
CError_Error(241);
|
||||
switch (bde.declinfo2.storageclass) {
|
||||
case OBJECT_SCLASS_104:
|
||||
case TK_TYPEDEF:
|
||||
CError_QualifierCheck(bde.declinfo2.qual & Q_VIRTUAL);
|
||||
CDecl_TypedefDeclarator(&bde.declinfo2);
|
||||
break;
|
||||
case OBJECT_SCLASS_102:
|
||||
case TK_STATIC:
|
||||
CError_QualifierCheck(bde.declinfo2.qual & Q_VIRTUAL);
|
||||
if (tclass->sominfo)
|
||||
CError_Error(271);
|
||||
|
@ -3929,11 +3883,11 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode)
|
|||
}
|
||||
break;
|
||||
case 0:
|
||||
case OBJECT_SCLASS_12B:
|
||||
case TK_MUTABLE:
|
||||
if (IS_TYPE_FUNC(bde.declinfo2.thetype)) {
|
||||
if (bde.declinfo2.name == tclass->classname)
|
||||
CError_Error(241);
|
||||
if (bde.declinfo.storageclass == OBJECT_SCLASS_12B)
|
||||
if (bde.declinfo.storageclass == TK_MUTABLE)
|
||||
CError_QualifierCheck(Q_MUTABLE);
|
||||
bde.declinfo2.qual |= r21;
|
||||
CDecl_AddFunctionMember(decle, tclass, &bde.declinfo2, access, 1, 0, 1, 0);
|
||||
|
@ -3941,7 +3895,7 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode)
|
|||
CDecl_CompleteType(bde.declinfo2.thetype);
|
||||
CanCreateObject(bde.declinfo2.thetype);
|
||||
CError_QualifierCheck(bde.declinfo2.qual & (Q_VIRTUAL | Q_INLINE));
|
||||
if (bde.declinfo2.storageclass == OBJECT_SCLASS_12B)
|
||||
if (bde.declinfo2.storageclass == TK_MUTABLE)
|
||||
bde.declinfo2.qual |= Q_MUTABLE;
|
||||
CDecl_InstanceDataDeclarator(decle, tclass, bde.declinfo2.thetype, bde.declinfo2.qual, bde.declinfo2.name, access);
|
||||
}
|
||||
|
@ -4236,17 +4190,14 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t
|
|||
}
|
||||
}
|
||||
|
||||
static short getaccesstype(short a, short b, short c) {
|
||||
AccessType a1 = (AccessType) a;
|
||||
AccessType b1 = (AccessType) b;
|
||||
AccessType c1 = (AccessType) c;
|
||||
static short getaccesstype(AccessType a, AccessType b, AccessType c) {
|
||||
if (a == ACCESSNONE || b == ACCESSNONE || b == ACCESSPRIVATE)
|
||||
return ACCESSNONE;
|
||||
|
||||
if (a1 == ACCESSNONE || b1 == ACCESSNONE || b1 == ACCESSPRIVATE)
|
||||
if (c == ACCESSPUBLIC && b != ACCESSPUBLIC)
|
||||
return ACCESSNONE;
|
||||
else if (c1 == ACCESSPUBLIC && a1 != ACCESSPUBLIC)
|
||||
return ACCESSNONE;
|
||||
else
|
||||
return ACCESSPUBLIC;
|
||||
|
||||
return ACCESSPUBLIC;
|
||||
}
|
||||
|
||||
static TypeMethod *CDecl_MakeDefaultCtorType(TypeClass *tclass) {
|
||||
|
@ -4566,8 +4517,7 @@ static void CDecl_SetupClassLayout(DeclE *decle, TypeClass *tclass, ObjBase **ob
|
|||
|
||||
i = TYPE_METHOD(obj->type)->x1E;
|
||||
if (i > 0) {
|
||||
#line 6363
|
||||
CError_ASSERT((i - 1) < decle->x8 && !objbuf[(int) (i - 1)]);
|
||||
CError_ASSERT(6363, (i - 1) < decle->x8 && !objbuf[(int) (i - 1)]);
|
||||
objbuf[(int) (i - 1)] = OBJ_BASE(obj);
|
||||
index++;
|
||||
if (obj->datatype != DVFUNC && !TYPE_METHOD(obj->type)->x26 && CClass_OverridesBaseMember(tclass, obj->name, obj))
|
||||
|
@ -4587,8 +4537,7 @@ static void CDecl_SetupClassLayout(DeclE *decle, TypeClass *tclass, ObjBase **ob
|
|||
TYPE_FUNC(obj->type)->flags &= ~FUNC_FLAGS_8;
|
||||
}
|
||||
} else {
|
||||
#line 6412
|
||||
CError_ASSERT(i == 0);
|
||||
CError_ASSERT(6412, i == 0);
|
||||
}
|
||||
|
||||
if (!tclass->sominfo)
|
||||
|
@ -4609,19 +4558,16 @@ static void CDecl_SetupClassLayout(DeclE *decle, TypeClass *tclass, ObjBase **ob
|
|||
if (!tclass->sominfo) {
|
||||
for (i = 0, ivar = tclass->ivars; i < decle->x8; i++) {
|
||||
if (!objbuf[i]) {
|
||||
#line 6449
|
||||
CError_ASSERT(ivar);
|
||||
CError_ASSERT(6449, ivar);
|
||||
objbuf[i] = OBJ_BASE(ivar);
|
||||
ivar = ivar->next;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
#line 6455
|
||||
CError_ASSERT(ivar == NULL);
|
||||
CError_ASSERT(6455, ivar == NULL);
|
||||
}
|
||||
|
||||
#line 6458
|
||||
CError_ASSERT(index == decle->x8);
|
||||
CError_ASSERT(6458, index == decle->x8);
|
||||
}
|
||||
|
||||
void CDecl_CompleteClass(DeclE *decle, TypeClass *tclass) {
|
||||
|
@ -4660,9 +4606,8 @@ TypeClass *CDecl_DefineClass(NameSpace *nspace, HashNameNode *name, TypeClass *t
|
|||
ObjType *objtype;
|
||||
|
||||
if (!tclass && nspace->theclass && (nspace->theclass->flags & CLASS_FLAGS_100)) {
|
||||
#line 6556
|
||||
CError_ASSERT(!flag2);
|
||||
return CTemplClass_DefineNestedClass(TEMPL_CLASS(nspace->theclass), name, mode);
|
||||
CError_ASSERT(6556, !flag2);
|
||||
return TYPE_CLASS(CTemplClass_DefineNestedClass(TEMPL_CLASS(nspace->theclass), name, mode));
|
||||
}
|
||||
|
||||
mynspace = CScope_NewListNameSpace(name, 1);
|
||||
|
@ -4759,7 +4704,7 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class
|
|||
NameSpace *nspace;
|
||||
CScopeParseResult pr;
|
||||
CScopeSave scopesave;
|
||||
BrowseStruct bs;
|
||||
GList gl;
|
||||
FileOffsetInfo offsetsave;
|
||||
SInt32 offset;
|
||||
Boolean is_templ;
|
||||
|
@ -4828,8 +4773,7 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class
|
|||
goto tagtype_search;
|
||||
}
|
||||
|
||||
#line 6786
|
||||
CError_ASSERT(pr.name_4);
|
||||
CError_ASSERT(6786, pr.name_4);
|
||||
|
||||
tclass = CDecl_DefineClass(CScope_FindNonClassNonFunctionNS(cscope_current), pr.name_4, NULL, mode, 0, 1);
|
||||
tclass->eflags |= class_declspec;
|
||||
|
@ -4865,8 +4809,7 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class
|
|||
TEMPL_CLASS_INST(tclass)->is_specialized = 1;
|
||||
}
|
||||
|
||||
#line 6853
|
||||
CError_ASSERT(copts.align_mode >= 0 && copts.align_mode <= 14);
|
||||
CError_ASSERT(6853, copts.align_mode >= 0 && copts.align_mode <= 14);
|
||||
|
||||
tclass->eflags |= (UInt8) ((copts.align_mode + 1) << 4);
|
||||
if (tk == ':')
|
||||
|
@ -4875,9 +4818,9 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class
|
|||
CScope_SetClassDefScope(tclass, &scopesave);
|
||||
if (tk == '{') {
|
||||
tk = lex();
|
||||
if ((add_to_browse = cparamblkptr->browseOptions.recordClasses && declinfo->fileoffsetinfo.file->recordbrowseinfo)) {
|
||||
if ((add_to_browse = cparamblkptr->browseOptions.recordClasses && declinfo->file->recordbrowseinfo)) {
|
||||
offsetsave = member_fileoffset;
|
||||
CBrowse_BeginClass(declinfo, &bs);
|
||||
CBrowse_BeginClass(declinfo, &gl);
|
||||
}
|
||||
CDecl_ParseClassMembers(&decle, tclass, mode);
|
||||
offset = CPrep_BrowserFileOffset();
|
||||
|
@ -4887,7 +4830,7 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class
|
|||
member_fileoffset = offsetsave;
|
||||
if (flag1 && tk == ';')
|
||||
CPrep_BrowserFileOffset();
|
||||
CBrowse_EndClass(offset, &bs);
|
||||
CBrowse_EndClass(offset, &gl);
|
||||
}
|
||||
} else {
|
||||
CError_Error(135);
|
||||
|
|
|
@ -249,7 +249,6 @@ void CError_BufferAppendTemplDepType(CErrorBuffer *eb, TypeTemplDep *type) {
|
|||
}
|
||||
|
||||
void CError_BufferAppendFuncArgs(CErrorBuffer *eb, TypeFunc *tfunc, Boolean isMethod) {
|
||||
// not matching - weirdness with referencing string constants
|
||||
FuncArg *arg;
|
||||
UInt32 qual;
|
||||
|
||||
|
@ -274,14 +273,14 @@ void CError_BufferAppendFuncArgs(CErrorBuffer *eb, TypeFunc *tfunc, Boolean isMe
|
|||
if (arg == &elipsis || arg == &oldstyle) {
|
||||
CError_BufferAppendString(eb, "...");
|
||||
break;
|
||||
} else {
|
||||
CError_BufferAppendType(eb, arg->type, arg->qual);
|
||||
}
|
||||
|
||||
if (!arg->next) {
|
||||
CError_BufferAppendType(eb, arg->type, arg->qual);
|
||||
|
||||
if ((arg = arg->next))
|
||||
CError_BufferAppendString(eb, ", ");
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
CError_BufferAppendChar(eb, ')');
|
||||
|
@ -291,73 +290,73 @@ void CError_BufferAppendFuncArgs(CErrorBuffer *eb, TypeFunc *tfunc, Boolean isMe
|
|||
|
||||
void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
|
||||
// not matching - register issues
|
||||
Type *scan;
|
||||
Type *scan2;
|
||||
char buf[16];
|
||||
Type *scan, *scan2;
|
||||
|
||||
switch (ty->type) {
|
||||
case TYPEVOID:
|
||||
CError_BufferAppendQualifier(eb, qual);
|
||||
CError_BufferAppendString(eb, "void");
|
||||
break;
|
||||
return;
|
||||
case TYPEINT:
|
||||
case TYPEFLOAT:
|
||||
CError_BufferAppendQualifier(eb, qual);
|
||||
switch (TYPE_INTEGRAL(ty)->integral) {
|
||||
case IT_BOOL:
|
||||
CError_BufferAppendString(eb, "bool");
|
||||
break;
|
||||
return;
|
||||
case IT_CHAR:
|
||||
CError_BufferAppendString(eb, "char");
|
||||
break;
|
||||
return;
|
||||
case IT_UCHAR:
|
||||
CError_BufferAppendString(eb, "unsigned char");
|
||||
break;
|
||||
return;
|
||||
case IT_SCHAR:
|
||||
CError_BufferAppendString(eb, "signed char");
|
||||
break;
|
||||
return;
|
||||
case IT_WCHAR_T:
|
||||
CError_BufferAppendString(eb, "wchar_t");
|
||||
break;
|
||||
return;
|
||||
case IT_SHORT:
|
||||
CError_BufferAppendString(eb, "short");
|
||||
break;
|
||||
return;
|
||||
case IT_USHORT:
|
||||
CError_BufferAppendString(eb, "unsigned short");
|
||||
break;
|
||||
return;
|
||||
case IT_INT:
|
||||
CError_BufferAppendString(eb, "int");
|
||||
break;
|
||||
return;
|
||||
case IT_UINT:
|
||||
CError_BufferAppendString(eb, "unsigned int");
|
||||
break;
|
||||
return;
|
||||
case IT_LONG:
|
||||
CError_BufferAppendString(eb, "long");
|
||||
break;
|
||||
return;
|
||||
case IT_ULONG:
|
||||
CError_BufferAppendString(eb, "unsigned long");
|
||||
break;
|
||||
return;
|
||||
case IT_LONGLONG:
|
||||
CError_BufferAppendString(eb, "long long");
|
||||
break;
|
||||
return;
|
||||
case IT_ULONGLONG:
|
||||
CError_BufferAppendString(eb, "unsigned long long");
|
||||
break;
|
||||
return;
|
||||
case IT_FLOAT:
|
||||
CError_BufferAppendString(eb, "float");
|
||||
break;
|
||||
return;
|
||||
case IT_SHORTDOUBLE:
|
||||
CError_BufferAppendString(eb, "short double");
|
||||
break;
|
||||
return;
|
||||
case IT_DOUBLE:
|
||||
CError_BufferAppendString(eb, "double");
|
||||
break;
|
||||
return;
|
||||
case IT_LONGDOUBLE:
|
||||
CError_BufferAppendString(eb, "long double");
|
||||
break;
|
||||
return;
|
||||
default:
|
||||
CError_FATAL(584);
|
||||
}
|
||||
break;
|
||||
case TYPEENUM:
|
||||
CError_BufferAppendQualifier(eb, qual);
|
||||
CError_BufferAppendNameSpace(eb, TYPE_ENUM(ty)->nspace);
|
||||
|
@ -365,7 +364,7 @@ void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
|
|||
CError_BufferAppendString(eb, TYPE_ENUM(ty)->enumname->name);
|
||||
else
|
||||
CError_BufferAppendString(eb, "{unnamed-enum}");
|
||||
break;
|
||||
return;
|
||||
case TYPESTRUCT:
|
||||
CError_BufferAppendQualifier(eb, qual);
|
||||
switch (TYPE_STRUCT(ty)->stype) {
|
||||
|
@ -373,7 +372,7 @@ void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
|
|||
CError_BufferAppendString(eb, "struct ");
|
||||
break;
|
||||
case STRUCT_TYPE_UNION:
|
||||
CError_BufferAppendString(eb, "struct ");
|
||||
CError_BufferAppendString(eb, "union ");
|
||||
break;
|
||||
case STRUCT_TYPE_4:
|
||||
case STRUCT_TYPE_5:
|
||||
|
@ -392,7 +391,7 @@ void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
|
|||
}
|
||||
if (TYPE_STRUCT(ty)->name)
|
||||
CError_BufferAppendString(eb, TYPE_STRUCT(ty)->name->name);
|
||||
break;
|
||||
return;
|
||||
case TYPECLASS:
|
||||
CError_BufferAppendQualifier(eb, qual);
|
||||
CError_BufferAppendNameSpace(eb, TYPE_CLASS(ty)->nspace->parent);
|
||||
|
@ -406,7 +405,7 @@ void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
|
|||
} else {
|
||||
CError_BufferAppendString(eb, "{unnamed-class}");
|
||||
}
|
||||
break;
|
||||
return;
|
||||
case TYPEPOINTER:
|
||||
case TYPEMEMBERPOINTER:
|
||||
scan = ty;
|
||||
|
@ -430,7 +429,7 @@ void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
|
|||
CError_BufferAppendPType(eb, ty);
|
||||
CError_BufferAppendChar(eb, ')');
|
||||
CError_BufferAppendFuncArgs(eb, TYPE_FUNC(scan), ty->type == TYPEMEMBERPOINTER);
|
||||
break;
|
||||
return;
|
||||
case TYPEARRAY:
|
||||
scan2 = scan;
|
||||
while (scan->type == TYPEARRAY)
|
||||
|
@ -445,7 +444,7 @@ void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
|
|||
CError_BufferAppendType(eb, scan, 0);
|
||||
CError_BufferAppendChar(eb, ' ');
|
||||
CError_BufferAppendPType(eb, ty);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case TYPEFUNC:
|
||||
|
@ -455,7 +454,7 @@ void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
|
|||
CError_BufferAppendType(eb, TYPE_FUNC(ty)->functype, 0);
|
||||
CError_BufferAppendChar(eb, ' ');
|
||||
CError_BufferAppendFuncArgs(eb, TYPE_FUNC(ty), 0);
|
||||
break;
|
||||
return;
|
||||
case TYPEARRAY:
|
||||
CError_BufferAppendQualifier(eb, qual);
|
||||
scan = ty;
|
||||
|
@ -472,18 +471,18 @@ void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) {
|
|||
CError_BufferAppendChar(eb, ']');
|
||||
ty = TYPE_POINTER(ty)->target;
|
||||
}
|
||||
break;
|
||||
return;
|
||||
case TYPETEMPLATE:
|
||||
CError_BufferAppendQualifier(eb, qual);
|
||||
CError_BufferAppendTemplDepType(eb, TYPE_TEMPLATE(ty));
|
||||
break;
|
||||
return;
|
||||
case TYPETEMPLDEPEXPR:
|
||||
CError_BufferAppendString(eb, "T");
|
||||
break;
|
||||
return;
|
||||
case TYPEBITFIELD:
|
||||
sprintf(buf, "bitfield:%ld", TYPE_BITFIELD(ty)->unkB);
|
||||
CError_BufferAppendString(eb, buf);
|
||||
break;
|
||||
return;
|
||||
default:
|
||||
CError_FATAL(752);
|
||||
}
|
||||
|
@ -740,56 +739,58 @@ void CError_ErrorMessageVA(int code, const char *format, va_list list, Boolean f
|
|||
SInt32 moddate;
|
||||
Type *type;
|
||||
UInt32 qual;
|
||||
const char *p;
|
||||
CError_BufferInit(&eb, buf, sizeof(buf));
|
||||
|
||||
p = format;
|
||||
do {
|
||||
switch (format[0]) {
|
||||
switch (p[0]) {
|
||||
case 0:
|
||||
break;
|
||||
case '%':
|
||||
switch (format[1]) {
|
||||
switch (p[1]) {
|
||||
case 'n':
|
||||
MWUnmangle(va_arg(list, const char *), unmangleBuf, sizeof(unmangleBuf));
|
||||
CError_BufferAppendString(&eb, unmangleBuf);
|
||||
format += 2;
|
||||
p += 2;
|
||||
continue;
|
||||
case 'u':
|
||||
CError_BufferAppendString(&eb, va_arg(list, const char *));
|
||||
format += 2;
|
||||
p += 2;
|
||||
continue;
|
||||
case 'o':
|
||||
CError_AppendObjectName(&eb, va_arg(list, Object *));
|
||||
format += 2;
|
||||
p += 2;
|
||||
continue;
|
||||
case 'm':
|
||||
CError_AppendMethodName(&eb, va_arg(list, ObjCMethod *));
|
||||
format += 2;
|
||||
p += 2;
|
||||
continue;
|
||||
case 't':
|
||||
type = va_arg(list, Type *);
|
||||
qual = va_arg(list, UInt32);
|
||||
CError_BufferAppendType(&eb, type, qual);
|
||||
format += 2;
|
||||
p += 2;
|
||||
continue;
|
||||
case '%':
|
||||
CError_BufferAppendChar(&eb, '%');
|
||||
format += 2;
|
||||
p += 2;
|
||||
continue;
|
||||
case 'i':
|
||||
sprintf(unmangleBuf, "%ld", va_arg(list, SInt32));
|
||||
CError_BufferAppendString(&eb, unmangleBuf);
|
||||
format += 2;
|
||||
p += 2;
|
||||
continue;
|
||||
case 'f':
|
||||
CError_BufferAppendString(&eb, CTool_GetPathName(va_arg(list, FSSpec *), &moddate)->name);
|
||||
format += 2;
|
||||
p += 2;
|
||||
continue;
|
||||
default:
|
||||
CError_FATAL(1174);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
CError_BufferAppendChar(&eb, *(format++));
|
||||
CError_BufferAppendChar(&eb, *(p++));
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
@ -883,6 +884,8 @@ void CError_ErrorFuncCall(short code, NameSpaceObjectList *args, ENodeList *argN
|
|||
CError_BufferAppendType(&eb, argscan->node->rtype, argscan->node->flags & ENODE_FLAG_QUALS);
|
||||
if ((argscan = argscan->next))
|
||||
CError_BufferAppendString(&eb, ", ");
|
||||
else
|
||||
break;
|
||||
}
|
||||
CError_BufferAppendChar(&eb, ')');
|
||||
break;
|
||||
|
@ -964,15 +967,11 @@ void CError_AbstractClassError(TypeClass *tclass) {
|
|||
|
||||
void CError_Warning(int code, ...) {
|
||||
va_list va;
|
||||
if (trychain)
|
||||
if (trychain || copts.supress_warnings)
|
||||
return;
|
||||
|
||||
if (copts.supress_warnings) {
|
||||
va_start(va, code);
|
||||
} else {
|
||||
va_start(va, code);
|
||||
CError_VAErrorMessage(code, va, 0, 1);
|
||||
}
|
||||
va_start(va, code);
|
||||
CError_VAErrorMessage(code, va, 0, 1);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,13 +25,6 @@ typedef struct UniqueObj {
|
|||
SInt32 uniqueid;
|
||||
} UniqueObj;
|
||||
|
||||
typedef struct DtorTemp {
|
||||
struct DtorTemp *next;
|
||||
Object *object;
|
||||
Object *dtor;
|
||||
Object *temp;
|
||||
} DtorTemp;
|
||||
|
||||
ExceptionAction *cexcept_dobjstack;
|
||||
Boolean cexcept_hasdobjects;
|
||||
Boolean cexcept_magic;
|
||||
|
@ -311,7 +304,7 @@ ENode *CExcept_RegisterDestructorObject(Object *local, SInt32 offset, Object *dt
|
|||
cexcept_dobjstack = action;
|
||||
|
||||
expr = create_objectrefnode(local);
|
||||
dtorObject = CABI_GetDestructorObject(dtor, 1);
|
||||
dtorObject = CABI_GetDestructorObject(dtor, CABIDestroy1);
|
||||
|
||||
if (offset == 0) {
|
||||
action->type = EAT_DESTROYLOCAL;
|
||||
|
@ -339,7 +332,7 @@ void CExcept_RegisterLocalArray(Statement *stmt, Object *localarray, Object *dto
|
|||
action->prev = cexcept_dobjstack;
|
||||
cexcept_dobjstack = action;
|
||||
|
||||
dtorObject = CABI_GetDestructorObject(dtor, 1);
|
||||
dtorObject = CABI_GetDestructorObject(dtor, CABIDestroy1);
|
||||
|
||||
action->type = EAT_DESTROYLOCALARRAY;
|
||||
action->data.destroy_local_array.localarray = localarray;
|
||||
|
@ -493,10 +486,10 @@ void CExcept_RegisterMember(Statement *stmt, Object *objectptr, SInt32 offset, O
|
|||
if (cond == NULL) {
|
||||
if (isMember) {
|
||||
action->type = EAT_DESTROYMEMBER;
|
||||
action->data.destroy_member.dtor = CABI_GetDestructorObject(dtor, 1);
|
||||
action->data.destroy_member.dtor = CABI_GetDestructorObject(dtor, CABIDestroy1);
|
||||
} else {
|
||||
action->type = EAT_DESTROYBASE;
|
||||
action->data.destroy_member.dtor = CABI_GetDestructorObject(dtor, 0);
|
||||
action->data.destroy_member.dtor = CABI_GetDestructorObject(dtor, CABIDestroy0);
|
||||
}
|
||||
action->data.destroy_member.objectptr = objectptr;
|
||||
action->data.destroy_member.offset = offset;
|
||||
|
@ -505,7 +498,7 @@ void CExcept_RegisterMember(Statement *stmt, Object *objectptr, SInt32 offset, O
|
|||
action->type = EAT_DESTROYMEMBERCOND;
|
||||
action->data.destroy_member_cond.objectptr = objectptr;
|
||||
action->data.destroy_member_cond.cond = cond;
|
||||
action->data.destroy_member_cond.dtor = CABI_GetDestructorObject(dtor, 1);
|
||||
action->data.destroy_member_cond.dtor = CABI_GetDestructorObject(dtor, CABIDestroy1);
|
||||
action->data.destroy_member_cond.offset = offset;
|
||||
}
|
||||
|
||||
|
@ -521,7 +514,7 @@ void CExcept_RegisterMemberArray(Statement *stmt, Object *objectptr, SInt32 offs
|
|||
|
||||
action->type = EAT_DESTROYMEMBERARRAY;
|
||||
action->data.destroy_member_array.objectptr = objectptr;
|
||||
action->data.destroy_member_array.dtor = CABI_GetDestructorObject(dtor, 1);
|
||||
action->data.destroy_member_array.dtor = CABI_GetDestructorObject(dtor, CABIDestroy1);
|
||||
action->data.destroy_member_array.offset = offset;
|
||||
action->data.destroy_member_array.elements = elements;
|
||||
action->data.destroy_member_array.element_size = element_size;
|
||||
|
@ -537,7 +530,7 @@ static Statement *CExcept_DestroyLocal(ExceptionAction *ea, Statement *stmt, Obj
|
|||
if (offset)
|
||||
expr = makediadicnode(expr, intconstnode(TYPE(&stunsignedlong), offset), EADD);
|
||||
|
||||
expr = CABI_DestroyObject(dtor, expr, 1, 1, 0);
|
||||
expr = CABI_DestroyObject(dtor, expr, CABIDestroy1, 1, 0);
|
||||
|
||||
CError_ASSERT(687, expr->type == EFUNCCALL && expr->data.funccall.funcref->type == EOBJREF);
|
||||
if (expr->data.funccall.funcref->data.objref->datatype == DVFUNC)
|
||||
|
@ -565,7 +558,7 @@ static Statement *CExcept_DestroyLocalArray(ExceptionAction *ea, Statement *stmt
|
|||
newStmt = CFunc_InsertStatement(ST_EXPRESSION, stmt);
|
||||
|
||||
if (dtor)
|
||||
dtorExpr = create_objectrefnode(CABI_GetDestructorObject(dtor, 1));
|
||||
dtorExpr = create_objectrefnode(CABI_GetDestructorObject(dtor, CABIDestroy1));
|
||||
else
|
||||
dtorExpr = nullnode();
|
||||
|
||||
|
@ -956,7 +949,7 @@ ENode *CExcept_ScanThrowExpression(void) {
|
|||
Xthrw_func,
|
||||
expr,
|
||||
resultExpr,
|
||||
create_objectrefnode(CABI_GetDestructorObject(func, 1)),
|
||||
create_objectrefnode(CABI_GetDestructorObject(func, CABIDestroy1)),
|
||||
NULL);
|
||||
} else {
|
||||
expr = funccallexpr(
|
||||
|
@ -1318,7 +1311,7 @@ static ENode *CExcept_TempTrans_ETEMP(ENode *expr) {
|
|||
cexcept_eabefore = ea;
|
||||
ea->type = EAT_DESTROYLOCAL;
|
||||
ea->data.destroy_local.local = dtorTemp->object;
|
||||
ea->data.destroy_local.dtor = CABI_GetDestructorObject(dtorTemp->dtor, 1);
|
||||
ea->data.destroy_local.dtor = CABI_GetDestructorObject(dtorTemp->dtor, CABIDestroy1);
|
||||
|
||||
ea = lalloc(sizeof(ExceptionAction));
|
||||
*ea = *cexcept_eabefore;
|
||||
|
@ -1635,7 +1628,7 @@ static ENode *CExcept_TempTransFuncCall(ENode *expr, Boolean isCond) {
|
|||
|
||||
ea->type = EAT_DESTROYLOCALCOND;
|
||||
ea->data.destroy_local_cond.local = dtorTemp->object;
|
||||
ea->data.destroy_local_cond.dtor = CABI_GetDestructorObject(dtorTemp->dtor, 1);
|
||||
ea->data.destroy_local_cond.dtor = CABI_GetDestructorObject(dtorTemp->dtor, CABIDestroy1);
|
||||
ea->data.destroy_local_cond.cond = dtorTemp->temp;
|
||||
|
||||
ea = lalloc(sizeof(ExceptionAction));
|
||||
|
@ -1653,7 +1646,7 @@ static ENode *CExcept_TempTransFuncCall(ENode *expr, Boolean isCond) {
|
|||
|
||||
ea->type = EAT_DESTROYLOCAL;
|
||||
ea->data.destroy_local.local = dtorTemp->object;
|
||||
ea->data.destroy_local.dtor = CABI_GetDestructorObject(dtorTemp->dtor, 1);
|
||||
ea->data.destroy_local.dtor = CABI_GetDestructorObject(dtorTemp->dtor, CABIDestroy1);
|
||||
|
||||
ea = lalloc(sizeof(ExceptionAction));
|
||||
*ea = *cexcept_eabefore;
|
||||
|
@ -1896,7 +1889,7 @@ static Statement *CExcept_DtorTransform(Statement *stmt) {
|
|||
}
|
||||
|
||||
curStmt = CFunc_InsertStatement(ST_EXPRESSION, curStmt);
|
||||
curStmt->expr = CABI_DestroyObject(dtorTemp->dtor, create_objectrefnode(dtorTemp->object), 1, 1, 0);
|
||||
curStmt->expr = CABI_DestroyObject(dtorTemp->dtor, create_objectrefnode(dtorTemp->object), CABIDestroy1, 1, 0);
|
||||
curStmt->dobjstack = cexcept_eaafter;
|
||||
|
||||
if (dtorTemp->temp) {
|
||||
|
|
|
@ -3,16 +3,25 @@
|
|||
#include "compiler/CClass.h"
|
||||
#include "compiler/CDecl.h"
|
||||
#include "compiler/CError.h"
|
||||
#include "compiler/CException.h"
|
||||
#include "compiler/CInit.h"
|
||||
#include "compiler/CInline.h"
|
||||
#include "compiler/CIRTransform.h"
|
||||
#include "compiler/CMachine.h"
|
||||
#include "compiler/CMangler.h"
|
||||
#include "compiler/CInt64.h"
|
||||
#include "compiler/CObjC.h"
|
||||
#include "compiler/CObjCModern.h"
|
||||
#include "compiler/CParser.h"
|
||||
#include "compiler/CPrep.h"
|
||||
#include "compiler/CPrepTokenizer.h"
|
||||
#include "compiler/CRTTI.h"
|
||||
#include "compiler/CSOM.h"
|
||||
#include "compiler/CTemplateNew.h"
|
||||
#include "compiler/CTemplateTools.h"
|
||||
#include "compiler/CodeGen.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/PPCError.h"
|
||||
#include "compiler/objects.h"
|
||||
#include "compiler/scopes.h"
|
||||
#include "compiler/templates.h"
|
||||
|
@ -20,30 +29,6 @@
|
|||
Boolean (*name_obj_check)(HashNameNode *, Object *);
|
||||
Boolean disallowgreaterthan;
|
||||
|
||||
// MOVE ME
|
||||
extern ENode *CIRTrans_TransformOpAss(ENode *);
|
||||
extern ENode *CTempl_MakeTemplDepExpr(ENode *, ENodeType, ENode *);
|
||||
extern Boolean CTemplTool_IsTemplateArgumentDependentType(Type *type);
|
||||
extern Boolean CTemplTool_IsTemplateArgumentDependentExpression(ENode *expr);
|
||||
extern ENode *CSOM_MemberVarAccess(BClassList *path, ObjMemberVar *var, ENode *expr);
|
||||
extern TemplArg *CTempl_ParseUncheckTemplArgs(void *a, Boolean flag);
|
||||
extern Boolean CObjC_IsCompatibleType(Type *a, Type *b);
|
||||
extern Type *CObjC_GetObjCType_id(Boolean flag);
|
||||
extern ENode *CExcept_ScanThrowExpression(void);
|
||||
extern void PPCError_Error(int code, ...);
|
||||
extern ENode *CObjC_ParseSelectorExpression(void);
|
||||
extern ENode *CObjC_ParseEncodeExpression(void);
|
||||
extern ENode *CObjC_ParseProtocolExpression(void);
|
||||
extern ENode *CObjC_ParseAtExpression(void);
|
||||
extern ENode *CObjC_ParseMessageExpression(void);
|
||||
extern ENode *CRTTI_Parse_const_cast(void);
|
||||
extern ENode *CRTTI_Parse_dynamic_cast(void);
|
||||
extern ENode *CRTTI_Parse_reinterpret_cast(void);
|
||||
extern ENode *CRTTI_Parse_static_cast(void);
|
||||
extern ENode *CRTTI_ParseTypeID(void);
|
||||
extern Boolean CObjC_IsType_id(Type *type);
|
||||
extern ENode *CObjC_CheckModernSendMessage(Type *type, ENode *expr);
|
||||
|
||||
// forward declarations
|
||||
static ENode *makeaddnode(ENode *left, ENode *right);
|
||||
static ENode *makesubnode(ENode *left, ENode *right);
|
||||
|
@ -81,8 +66,7 @@ restart:
|
|||
expr->data.floatval = CMach_CalcFloatConvertFromInt(TYPE(&stsignedlong), cint64_zero);
|
||||
break;
|
||||
default:
|
||||
#line 105
|
||||
CError_FATAL();
|
||||
CError_FATAL(105);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -383,8 +367,7 @@ static ENode *integralpointerpromote(ENode *expr) {
|
|||
} else if (stunsignedint.size == 4) {
|
||||
type = TYPE(&stunsignedint);
|
||||
} else {
|
||||
#line 480
|
||||
CError_FATAL();
|
||||
CError_FATAL(480);
|
||||
}
|
||||
} else {
|
||||
if (stsignedlong.size == 4) {
|
||||
|
@ -392,8 +375,7 @@ static ENode *integralpointerpromote(ENode *expr) {
|
|||
} else if (stsignedint.size == 4) {
|
||||
type = TYPE(&stsignedint);
|
||||
} else {
|
||||
#line 486
|
||||
CError_FATAL();
|
||||
CError_FATAL(486);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -865,8 +847,7 @@ static ENode *CExpr_MemberVarAccess(BClassList *path, ObjMemberVar *var, ENode *
|
|||
ENode *accessnode;
|
||||
BClassList *varpath;
|
||||
|
||||
#line 1152
|
||||
CError_ASSERT(path);
|
||||
CError_ASSERT(1152, path);
|
||||
|
||||
if (TYPE_CLASS(path->type)->sominfo)
|
||||
return CSOM_MemberVarAccess(path, var, expr);
|
||||
|
@ -952,8 +933,7 @@ ENode *CExpr_MakeNameLookupResultExpr(CScopeParseResult *pr) {
|
|||
CError_Error(0xDD);
|
||||
return nullnode();
|
||||
default:
|
||||
#line 1268
|
||||
CError_FATAL();
|
||||
CError_FATAL(1268);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -964,8 +944,7 @@ ENode *CExpr_MakeNameLookupResultExpr(CScopeParseResult *pr) {
|
|||
return expr;
|
||||
}
|
||||
|
||||
#line 1278
|
||||
CError_FATAL();
|
||||
CError_FATAL(1278);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -987,19 +966,16 @@ static Type *CExpr_NewPTMType(EMemberInfo *member, Object *obj) {
|
|||
ptm->ty1 = OBJ_MEMBER_VAR(member->list->object)->type;
|
||||
} else {
|
||||
if (!obj) {
|
||||
#line 1306
|
||||
CError_ASSERT(member->list->object->otype == OT_OBJECT);
|
||||
CError_ASSERT(1306, member->list->object->otype == OT_OBJECT);
|
||||
obj = OBJECT(member->list->object);
|
||||
#line 1308
|
||||
CError_ASSERT(IS_TYPE_FUNC(obj->type));
|
||||
CError_ASSERT(1308, IS_TYPE_FUNC(obj->type));
|
||||
}
|
||||
|
||||
tmethod = galloc(sizeof(TypeMethod));
|
||||
memclrw(tmethod, sizeof(TypeMethod));
|
||||
*tmethod = *TYPE_METHOD(obj->type);
|
||||
|
||||
#line 1312
|
||||
CError_ASSERT(tmethod->args);
|
||||
CError_ASSERT(1312, tmethod->args);
|
||||
|
||||
tmethod->args = tmethod->args->next;
|
||||
CDecl_MakePTMFuncType(TYPE_FUNC(tmethod));
|
||||
|
@ -1139,8 +1115,7 @@ static ENode *CExpr_ParseNameResultExpr(CScopeParseResult *pr, ENode *expr, Bool
|
|||
val++;
|
||||
}
|
||||
if (act->u.enumerator.objenumconst == oec) {
|
||||
#line 1521
|
||||
CError_ASSERT(expr);
|
||||
CError_ASSERT(1521, expr);
|
||||
expr = CInline_CopyExpression(expr, CopyMode0);
|
||||
if (val)
|
||||
expr = makediadicnode(expr, intconstnode(TYPE(&stsignedlong), val), EADD);
|
||||
|
@ -1168,8 +1143,7 @@ static ENode *CExpr_ParseNameResultExpr(CScopeParseResult *pr, ENode *expr, Bool
|
|||
}
|
||||
break;
|
||||
default:
|
||||
#line 1552
|
||||
CError_FATAL();
|
||||
CError_FATAL(1552);
|
||||
}
|
||||
|
||||
member = lalloc(sizeof(EMemberInfo));
|
||||
|
@ -1179,8 +1153,7 @@ static ENode *CExpr_ParseNameResultExpr(CScopeParseResult *pr, ENode *expr, Bool
|
|||
member->pr_1D = pr->x1D;
|
||||
member->isambig = pr->isambig;
|
||||
if ((tk = lex()) == '<' && (ta_expr = CExpr_ExplicitTemplateArgCheck(pr))) {
|
||||
#line 1564
|
||||
CError_ASSERT(ENODE_IS(ta_expr, EOBJLIST));
|
||||
CError_ASSERT(1564, ENODE_IS(ta_expr, EOBJLIST));
|
||||
member->list = ta_expr->data.objlist.list;
|
||||
member->templargs = ta_expr->data.objlist.templargs;
|
||||
} else {
|
||||
|
@ -1197,8 +1170,7 @@ static ENode *CExpr_ParseNameResultExpr(CScopeParseResult *pr, ENode *expr, Bool
|
|||
|
||||
if (pr->nsol_14) {
|
||||
if ((tk = lex()) == '<' && (ta_expr = CExpr_ExplicitTemplateArgCheck(pr))) {
|
||||
#line 1591
|
||||
CError_ASSERT(ENODE_IS(ta_expr, EOBJLIST));
|
||||
CError_ASSERT(1591, ENODE_IS(ta_expr, EOBJLIST));
|
||||
for (list = ta_expr->data.objlist.list; list; list = list->next) {
|
||||
if (list->object->otype == OT_OBJECT && IS_TYPE_NONSTATIC_METHOD(OBJECT(list->object)->type)) {
|
||||
member = lalloc(sizeof(EMemberInfo));
|
||||
|
@ -1290,8 +1262,7 @@ static ENode *CExpr_ParseNameResultExpr(CScopeParseResult *pr, ENode *expr, Bool
|
|||
return create_objectrefnode(obj);
|
||||
}
|
||||
|
||||
#line 1711
|
||||
CError_FATAL();
|
||||
CError_FATAL(1711);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1462,8 +1433,7 @@ static SInt32 CExpr_AtomTypeID(IntegralType what) {
|
|||
case IT_23: return 38;
|
||||
case IT_24: return 39;
|
||||
default:
|
||||
#line 1976
|
||||
CError_FATAL();
|
||||
CError_FATAL(1976);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1734,8 +1704,7 @@ static ENode *CExpr_NewPTMFCall(void) {
|
|||
CError_Error(115);
|
||||
return nullnode();
|
||||
} else {
|
||||
#line 2465
|
||||
CError_FATAL();
|
||||
CError_FATAL(2465);
|
||||
return nullnode();
|
||||
}
|
||||
}
|
||||
|
@ -1770,8 +1739,7 @@ static ENode *call_ptmf(ENode *expr) {
|
|||
list2->node = expr->data.mfpointer.mfpointer->data.monadic;
|
||||
|
||||
if (!copts.old_argmatch) {
|
||||
#line 2568
|
||||
CError_ASSERT(IS_TYPE_POINTER_ONLY(list2->node->rtype));
|
||||
CError_ASSERT(2568, IS_TYPE_POINTER_ONLY(list2->node->rtype));
|
||||
list2->node->rtype = TYPE(&void_ptr);
|
||||
}
|
||||
|
||||
|
@ -1938,9 +1906,8 @@ loop:
|
|||
goto loop;
|
||||
}
|
||||
|
||||
#line 2753
|
||||
CError_ASSERT((expr = conv.left));
|
||||
CError_ASSERT((subexpr = conv.right));
|
||||
CError_ASSERT(2753, expr = conv.left);
|
||||
CError_ASSERT(2754, subexpr = conv.right);
|
||||
}
|
||||
|
||||
if (IS_TYPE_POINTER(expr->rtype)) {
|
||||
|
@ -1964,8 +1931,7 @@ loop:
|
|||
funcexpr = CExpr_PointerGeneration(expr);
|
||||
if (copts.cplusplus) {
|
||||
if (CExpr_CheckOperator('(', funcexpr, NULL, &conv)) {
|
||||
#line 2775
|
||||
CError_ASSERT((expr = conv.x0));
|
||||
CError_ASSERT(2775, expr = conv.x0);
|
||||
goto loop;
|
||||
}
|
||||
if (ENODE_IS(funcexpr, EMFPOINTER)) {
|
||||
|
@ -1996,8 +1962,7 @@ loop:
|
|||
expr = pointer_generation(expr);
|
||||
if (copts.cplusplus) {
|
||||
while (IS_TYPE_CLASS(expr->rtype) && CExpr_CheckOperator(TK_ARROW, expr, NULL, &conv)) {
|
||||
#line 2810
|
||||
CError_ASSERT((subexpr = conv.x0));
|
||||
CError_ASSERT(2810, subexpr = conv.x0);
|
||||
expr = pointer_generation(subexpr);
|
||||
}
|
||||
}
|
||||
|
@ -2020,7 +1985,7 @@ loop:
|
|||
expr = pointer_generation(expr);
|
||||
if (IS_TYPE_CLASS(expr->rtype)) {
|
||||
CDecl_CompleteType(expr->rtype);
|
||||
if (TYPE_CLASS(expr->rtype)->objcinfo && copts.cplusplus && (subexpr = CObjC_CheckModernSendMessage(expr->rtype, expr)))
|
||||
if (TYPE_CLASS(expr->rtype)->objcinfo && copts.cplusplus && (subexpr = CObjC_CheckModernSendMessage(TYPE_CLASS(expr->rtype), expr)))
|
||||
return subexpr;
|
||||
|
||||
if (!(TYPE_CLASS(expr->rtype)->flags & CLASS_FLAGS_2))
|
||||
|
@ -2100,8 +2065,7 @@ loop:
|
|||
tk = lex();
|
||||
goto loop;
|
||||
}
|
||||
#line 2952
|
||||
CError_ASSERT((tmp = conv.left));
|
||||
CError_ASSERT(2952, tmp = conv.left);
|
||||
}
|
||||
tmp = CExpr_LValue(tmp, 1, 1);
|
||||
if (tmp->rtype == TYPE(&stbool)) {
|
||||
|
@ -2121,8 +2085,7 @@ loop:
|
|||
tk = lex();
|
||||
goto loop;
|
||||
}
|
||||
#line 2976
|
||||
CError_ASSERT((tmp = conv.left));
|
||||
CError_ASSERT(2976, tmp = conv.left);
|
||||
}
|
||||
tmp = CExpr_LValue(tmp, 1, 1);
|
||||
checkadditive(tmp);
|
||||
|
@ -2320,8 +2283,7 @@ static ENode *CExpr_MakeStaticMemberList(NameSpaceObjectList *list) {
|
|||
static ENode *CExpr_MakePTDM(ENode *expr) {
|
||||
ENode *result;
|
||||
|
||||
#line 3414
|
||||
CError_ASSERT(ENODE_IS(expr, EMEMBER) && expr->data.emember->list->object->otype == OT_MEMBERVAR);
|
||||
CError_ASSERT(3414, ENODE_IS(expr, EMEMBER) && expr->data.emember->list->object->otype == OT_MEMBERVAR);
|
||||
|
||||
result = nullnode();
|
||||
result->rtype = CExpr_NewPTMType(expr->data.emember, NULL);
|
||||
|
@ -2338,8 +2300,7 @@ ENode *getpointertomemberfunc(ENode *expr, Type *type, Boolean flag) {
|
|||
OLinkList *olist;
|
||||
SInt32 data[3];
|
||||
|
||||
#line 3442
|
||||
CError_ASSERT(ENODE_IS(expr, EMEMBER));
|
||||
CError_ASSERT(3442, ENODE_IS(expr, EMEMBER));
|
||||
|
||||
if (expr->data.emember->expr && !copts.cpp_extensions)
|
||||
CError_Error(141);
|
||||
|
@ -2378,8 +2339,7 @@ ENode *getpointertomemberfunc(ENode *expr, Type *type, Boolean flag) {
|
|||
while (obj->datatype == DALIAS)
|
||||
obj = obj->u.alias.object;
|
||||
|
||||
#line 3503
|
||||
CError_ASSERT(obj->otype == OT_OBJECT && IS_TYPE_NONSTATIC_METHOD(obj->type));
|
||||
CError_ASSERT(3503, obj->otype == OT_OBJECT && IS_TYPE_NONSTATIC_METHOD(obj->type));
|
||||
|
||||
if (TYPE_FUNC(obj->type)->flags & FUNC_FLAGS_100000)
|
||||
CError_Error(190);
|
||||
|
@ -2414,8 +2374,7 @@ ENode *getpointertomemberfunc(ENode *expr, Type *type, Boolean flag) {
|
|||
}
|
||||
|
||||
static ENode *getpointertomember(ENode *expr) {
|
||||
#line 3554
|
||||
CError_ASSERT(ENODE_IS(expr, EMEMBER));
|
||||
CError_ASSERT(3554, ENODE_IS(expr, EMEMBER));
|
||||
|
||||
if (expr->data.emember->expr)
|
||||
CError_Error(141);
|
||||
|
@ -2442,8 +2401,7 @@ ENode *CExpr_New_ELOGNOT_Node(ENode *input) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('!', expr, NULL, &conv)) {
|
||||
if ((input = conv.x0))
|
||||
return input;
|
||||
#line 3593
|
||||
CError_ASSERT((expr = conv.left));
|
||||
CError_ASSERT(3593, expr = conv.left);
|
||||
}
|
||||
|
||||
switch (expr->rtype->type) {
|
||||
|
@ -2489,8 +2447,7 @@ ENode *CExpr_New_EMONMIN_Node(ENode *input) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('-', expr, NULL, &conv)) {
|
||||
if ((input = conv.x0))
|
||||
return input;
|
||||
#line 3652
|
||||
CError_ASSERT((expr = conv.left));
|
||||
CError_ASSERT(3652, expr = conv.left);
|
||||
}
|
||||
|
||||
switch (expr->rtype->type) {
|
||||
|
@ -2525,8 +2482,7 @@ ENode *CExpr_New_EBINNOT_Node(ENode *input) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('~', expr, NULL, &conv)) {
|
||||
if ((input = conv.x0))
|
||||
return input;
|
||||
#line 3702
|
||||
CError_ASSERT((expr = conv.left));
|
||||
CError_ASSERT(3702, expr = conv.left);
|
||||
}
|
||||
|
||||
expr = integralpromote(expr);
|
||||
|
@ -2566,8 +2522,7 @@ ENode *unary_expression(void) {
|
|||
if (CExpr_CheckOperator(TK_INCREMENT, expr, NULL, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 3748
|
||||
CError_ASSERT((expr = conv.left));
|
||||
CError_ASSERT(3748, expr = conv.left);
|
||||
}
|
||||
} else {
|
||||
expr = pointer_generation(unary_expression());
|
||||
|
@ -2589,8 +2544,7 @@ ENode *unary_expression(void) {
|
|||
if (CExpr_CheckOperator(TK_DECREMENT, expr, NULL, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 3776
|
||||
CError_ASSERT((expr = conv.left));
|
||||
CError_ASSERT(3776, expr = conv.left);
|
||||
}
|
||||
} else {
|
||||
expr = pointer_generation(unary_expression());
|
||||
|
@ -2614,8 +2568,7 @@ ENode *unary_expression(void) {
|
|||
}
|
||||
|
||||
if (CExpr_CheckOperator('&', expr, NULL, &conv)) {
|
||||
#line 3809
|
||||
CError_ASSERT(conv.x0);
|
||||
CError_ASSERT(3809, conv.x0);
|
||||
return conv.x0;
|
||||
}
|
||||
} else {
|
||||
|
@ -2642,8 +2595,7 @@ ENode *unary_expression(void) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('*', expr, NULL, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 3840
|
||||
CError_ASSERT((expr = conv.left));
|
||||
CError_ASSERT(3840, expr = conv.left);
|
||||
}
|
||||
|
||||
if (!IS_TYPE_POINTER(expr->rtype)) {
|
||||
|
@ -2661,8 +2613,7 @@ ENode *unary_expression(void) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('+', expr, NULL, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 3852
|
||||
CError_ASSERT((expr = conv.left));
|
||||
CError_ASSERT(3852, expr = conv.left);
|
||||
}
|
||||
|
||||
switch (expr->rtype->type) {
|
||||
|
@ -2761,10 +2712,8 @@ ENode *PointerToMemberCast(ENode *expr, TypeMemberPointer *tm1, TypeMemberPointe
|
|||
CInt64 pathoffset64;
|
||||
ENode *tmp;
|
||||
|
||||
#line 3984
|
||||
CError_ASSERT(IS_TYPE_CLASS(tm1->ty2));
|
||||
#line 3985
|
||||
CError_ASSERT(IS_TYPE_CLASS(tm2->ty2));
|
||||
CError_ASSERT(3984, IS_TYPE_CLASS(tm1->ty2));
|
||||
CError_ASSERT(3985, IS_TYPE_CLASS(tm2->ty2));
|
||||
|
||||
if (tm1->ty2 == tm2->ty2) {
|
||||
expr->rtype = TYPE(tm2);
|
||||
|
@ -3113,8 +3062,7 @@ restart:
|
|||
right = pointer_generation(cast_expression());
|
||||
|
||||
if (CExpr_CheckOperator(TK_ARROW_STAR, left, right, &conv)) {
|
||||
#line 4457
|
||||
CError_ASSERT((left = conv.x0));
|
||||
CError_ASSERT(4457, left = conv.x0);
|
||||
goto restart;
|
||||
}
|
||||
|
||||
|
@ -3192,8 +3140,7 @@ restart:
|
|||
left = checkreference(left);
|
||||
goto restart;
|
||||
} else {
|
||||
#line 4535
|
||||
CError_ASSERT(ENODE_IS(right, EINDIRECT));
|
||||
CError_ASSERT(4535, ENODE_IS(right, EINDIRECT));
|
||||
tmp = lalloc(sizeof(ENode));
|
||||
tmp->type = EMFPOINTER;
|
||||
tmp->cost = 4;
|
||||
|
@ -3219,9 +3166,8 @@ ENode *CExpr_New_EMUL_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('*', left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 4566
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(4566, left = conv.left);
|
||||
CError_ASSERT(4567, right = conv.right);
|
||||
}
|
||||
|
||||
return makemultnode(left, right);
|
||||
|
@ -3238,9 +3184,8 @@ ENode *CExpr_New_EDIV_Node(ENode *left, ENode *right, Boolean no_warning) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('/', left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 4592
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(4592, left = conv.left);
|
||||
CError_ASSERT(4593, right = conv.right);
|
||||
}
|
||||
|
||||
return makedivnode(left, right, no_warning);
|
||||
|
@ -3257,9 +3202,8 @@ ENode *CExpr_New_EMODULO_Node(ENode *left, ENode *right, Boolean no_warning) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('%', left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 4618
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(4618, left = conv.left);
|
||||
CError_ASSERT(4619, right = conv.right);
|
||||
}
|
||||
|
||||
left = integralpromote(left);
|
||||
|
@ -3300,9 +3244,8 @@ ENode *CExpr_New_EADD_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('+', left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 4665
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(4665, left = conv.left);
|
||||
CError_ASSERT(4666, right = conv.right);
|
||||
}
|
||||
|
||||
return makeaddnode(left, right);
|
||||
|
@ -3319,9 +3262,8 @@ ENode *CExpr_New_ESUB_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('-', left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 4690
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(4690, left = conv.left);
|
||||
CError_ASSERT(4691, right = conv.right);
|
||||
}
|
||||
|
||||
return makesubnode(left, right);
|
||||
|
@ -3338,9 +3280,8 @@ ENode *CExpr_New_ESHL_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator(TK_SHL, left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 4715
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(4715, left = conv.left);
|
||||
CError_ASSERT(4716, right = conv.right);
|
||||
}
|
||||
|
||||
left = integralpromote(left);
|
||||
|
@ -3369,9 +3310,8 @@ ENode *CExpr_New_ESHR_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator(TK_SHR, left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 4752
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(4752, left = conv.left);
|
||||
CError_ASSERT(4753, right = conv.right);
|
||||
}
|
||||
|
||||
left = integralpromote(left);
|
||||
|
@ -3421,14 +3361,12 @@ static ENode *pointercompare(ENodeType nt, ENode *left, ENode *right) {
|
|||
if (IS_TYPE_INT(ltype)) {
|
||||
if (!(ENODE_IS(left, EINTCONST) && CInt64_IsZero(&left->data.intval)))
|
||||
CError_Error(144);
|
||||
#line 4847
|
||||
CError_ASSERT(IS_TYPE_POINTER_ONLY(rtype));
|
||||
CError_ASSERT(4847, IS_TYPE_POINTER_ONLY(rtype));
|
||||
left->rtype = TYPE(&stunsignedlong);
|
||||
} else if (IS_TYPE_INT(rtype)) {
|
||||
if (!(ENODE_IS(right, EINTCONST) && CInt64_IsZero(&right->data.intval)))
|
||||
CError_Error(144);
|
||||
#line 4855
|
||||
CError_ASSERT(IS_TYPE_POINTER_ONLY(ltype));
|
||||
CError_ASSERT(4855, IS_TYPE_POINTER_ONLY(ltype));
|
||||
right->rtype = TYPE(&stunsignedlong);
|
||||
} else if (!is_typeequal(ltype, rtype)) {
|
||||
CError_Error(245, left->rtype, ENODE_QUALS(left), right->rtype, ENODE_QUALS(right));
|
||||
|
@ -3473,9 +3411,8 @@ ENode *CExpr_New_ELESS_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('<', left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 4929
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(4929, left = conv.left);
|
||||
CError_ASSERT(4930, right = conv.right);
|
||||
}
|
||||
|
||||
if (IS_TYPE_POINTER(left->rtype) || IS_TYPE_POINTER(right->rtype))
|
||||
|
@ -3507,9 +3444,8 @@ ENode *CExpr_New_ELESSEQU_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator(TK_LESS_EQUAL, left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 4976
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(4976, left = conv.left);
|
||||
CError_ASSERT(4977, right = conv.right);
|
||||
}
|
||||
|
||||
if (IS_TYPE_POINTER(left->rtype) || IS_TYPE_POINTER(right->rtype))
|
||||
|
@ -3541,9 +3477,8 @@ ENode *CExpr_New_EGREATER_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('>', left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 5023
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(5023, left = conv.left);
|
||||
CError_ASSERT(5024, right = conv.right);
|
||||
}
|
||||
|
||||
if (IS_TYPE_POINTER(left->rtype) || IS_TYPE_POINTER(right->rtype))
|
||||
|
@ -3575,9 +3510,8 @@ ENode *CExpr_New_EGREATEREQU_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator(TK_GREATER_EQUAL, left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 5070
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(5070, left = conv.left);
|
||||
CError_ASSERT(5071, right = conv.right);
|
||||
}
|
||||
|
||||
if (IS_TYPE_POINTER(left->rtype) || IS_TYPE_POINTER(right->rtype))
|
||||
|
@ -3664,9 +3598,8 @@ ENode *CExpr_New_EEQU_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator(TK_LOGICAL_EQ, left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 5201
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(5201, left = conv.left);
|
||||
CError_ASSERT(5202, right = conv.right);
|
||||
}
|
||||
|
||||
if (IS_TYPE_POINTER(left->rtype) || IS_TYPE_POINTER(right->rtype))
|
||||
|
@ -3702,9 +3635,8 @@ ENode *CExpr_New_ENOTEQU_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator(TK_LOGICAL_NE, left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 5261
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(5261, left = conv.left);
|
||||
CError_ASSERT(5262, right = conv.right);
|
||||
}
|
||||
|
||||
if (IS_TYPE_POINTER(left->rtype) || IS_TYPE_POINTER(right->rtype))
|
||||
|
@ -3739,9 +3671,8 @@ ENode *CExpr_New_EAND_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('&', left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 5321
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(5321, left = conv.left);
|
||||
CError_ASSERT(5322, right = conv.right);
|
||||
}
|
||||
|
||||
left = integralpromote(left);
|
||||
|
@ -3774,9 +3705,8 @@ ENode *CExpr_New_EXOR_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('^', left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 5360
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(5360, left = conv.left);
|
||||
CError_ASSERT(5361, right = conv.right);
|
||||
}
|
||||
|
||||
left = integralpromote(left);
|
||||
|
@ -3809,9 +3739,8 @@ ENode *CExpr_New_EOR_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator('|', left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 5399
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(5399, left = conv.left);
|
||||
CError_ASSERT(5400, right = conv.right);
|
||||
}
|
||||
|
||||
left = integralpromote(left);
|
||||
|
@ -3844,9 +3773,8 @@ ENode *CExpr_New_ELAND_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator(TK_LOGICAL_AND, left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 5438
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(5438, left = conv.left);
|
||||
CError_ASSERT(5439, right = conv.right);
|
||||
}
|
||||
|
||||
switch (left->rtype->type) {
|
||||
|
@ -3930,9 +3858,8 @@ ENode *CExpr_New_ELOR_Node(ENode *left, ENode *right) {
|
|||
if (copts.cplusplus && CExpr_CheckOperator(TK_LOGICAL_OR, left, right, &conv)) {
|
||||
if (conv.x0)
|
||||
return conv.x0;
|
||||
#line 5543
|
||||
CError_ASSERT((left = conv.left));
|
||||
CError_ASSERT((right = conv.right));
|
||||
CError_ASSERT(5543, left = conv.left);
|
||||
CError_ASSERT(5544, right = conv.right);
|
||||
}
|
||||
|
||||
switch (left->rtype->type) {
|
||||
|
@ -4006,8 +3933,7 @@ ENode *CExpr_New_ELOR_Node(ENode *left, ENode *right) {
|
|||
ENode *CExpr_NewDyadicNode(ENode *left, ENodeType nt, ENode *right) {
|
||||
switch (nt) {
|
||||
default:
|
||||
#line 5642
|
||||
CError_FATAL();
|
||||
CError_FATAL(5642);
|
||||
case EADD: return CExpr_New_EADD_Node(left, right);
|
||||
case ESUB: return CExpr_New_ESUB_Node(left, right);
|
||||
case EMUL: return CExpr_New_EMUL_Node(left, right);
|
||||
|
@ -4266,8 +4192,7 @@ ENode *CExpr_New_ECOND_Node(ENode *cond, ENode *expr1, ENode *expr2) {
|
|||
if ((IS_TYPE_CLASS(expr1->rtype) || IS_TYPE_CLASS(expr2->rtype)) && !is_typesame(expr1->rtype, expr2->rtype)) {
|
||||
if (!copts.old_argmatch) {
|
||||
if (CExpr_CondOperatorMatch(expr1, expr2, &conv)) {
|
||||
#line 6246
|
||||
CError_ASSERT(!conv.x0);
|
||||
CError_ASSERT(6246, !conv.x0);
|
||||
expr1 = conv.left;
|
||||
expr2 = conv.right;
|
||||
} else if (CExpr_CanImplicitlyConvert(expr1, expr2->rtype, ENODE_QUALS(expr2))) {
|
||||
|
@ -4289,8 +4214,7 @@ ENode *CExpr_New_ECOND_Node(ENode *cond, ENode *expr1, ENode *expr2) {
|
|||
args->next->next = NULL;
|
||||
|
||||
if (CExpr_CheckOperatorConversion(':', expr1, expr2, args, &conv)) {
|
||||
#line 6274
|
||||
CError_ASSERT(!conv.x0);
|
||||
CError_ASSERT(6274, !conv.x0);
|
||||
expr1 = conv.left;
|
||||
expr2 = conv.right;
|
||||
}
|
||||
|
@ -4479,8 +4403,7 @@ static ENode *makeassignmentnode(ENode *left, ENodeType nt, short token) {
|
|||
if (!conv.x0) {
|
||||
if (nt == EASS)
|
||||
goto continue_anyway;
|
||||
#line 6531
|
||||
CError_FATAL();
|
||||
CError_FATAL(6531);
|
||||
}
|
||||
return conv.x0;
|
||||
}
|
||||
|
@ -4553,11 +4476,9 @@ continue_anyway:
|
|||
case 1:
|
||||
if ((args = args->next))
|
||||
break;
|
||||
#line 6625
|
||||
CError_FATAL();
|
||||
CError_FATAL(6625);
|
||||
default:
|
||||
#line 6626
|
||||
CError_FATAL();
|
||||
CError_FATAL(6626);
|
||||
}
|
||||
if (ENODE_IS(args->node, ETEMP)) {
|
||||
if (!(IS_TYPE_CLASS(left->rtype) && CClass_Destructor(TYPE_CLASS(left->rtype)))) {
|
||||
|
@ -4583,8 +4504,7 @@ static ENode *makepassignmentnode(ENode *left, ENodeType nt, short token) {
|
|||
tk = lex();
|
||||
right = pointer_generation(assignment_expression());
|
||||
if (CExpr_CheckOperator(token, left, right, &conv)) {
|
||||
#line 6669
|
||||
CError_ASSERT(conv.x0);
|
||||
CError_ASSERT(6669, conv.x0);
|
||||
return conv.x0;
|
||||
}
|
||||
left = CExpr_LValue(left, 1, 1);
|
||||
|
@ -4652,8 +4572,7 @@ static ENode *makemulassignmentnode(ENode *left, ENodeType nt, short token) {
|
|||
tk = lex();
|
||||
right = pointer_generation(assignment_expression());
|
||||
if (CExpr_CheckOperator(token, left, right, &conv)) {
|
||||
#line 6753
|
||||
CError_ASSERT(conv.x0);
|
||||
CError_ASSERT(6753, conv.x0);
|
||||
return conv.x0;
|
||||
}
|
||||
if (!IS_TYPE_INT(left->rtype) && !(IS_TYPE_FLOAT(left->rtype) && nt != EMODASS)) {
|
||||
|
@ -4865,8 +4784,7 @@ static Boolean CExpr_HasSideEffect(ENode *expr) {
|
|||
case EINSTRUCTION:
|
||||
return 1;
|
||||
default:
|
||||
#line 7056
|
||||
CError_FATAL();
|
||||
CError_FATAL(7056);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -4911,11 +4829,9 @@ void CExpr_CheckUnusedExpression(ENode *expr) {
|
|||
case 1:
|
||||
if ((arg = arg->next))
|
||||
break;
|
||||
#line 7110
|
||||
CError_FATAL();
|
||||
CError_FATAL(7110);
|
||||
default:
|
||||
#line 7111
|
||||
CError_FATAL();
|
||||
CError_FATAL(7111);
|
||||
}
|
||||
|
||||
if (!ENODE_IS(arg->node, ETEMP))
|
||||
|
@ -4938,8 +4854,7 @@ ENode *s_expression(void) {
|
|||
right = pointer_generation(assignment_expression());
|
||||
|
||||
if (copts.cplusplus && CExpr_CheckOperator(',', left, right, &conv)) {
|
||||
#line 7143
|
||||
CError_ASSERT((left = conv.x0));
|
||||
CError_ASSERT(7143, left = conv.x0);
|
||||
} else {
|
||||
CExpr_CheckUnusedExpression(left);
|
||||
left = makecommaexpression(left, right);
|
||||
|
@ -4986,8 +4901,7 @@ ENode *CExpr_IntegralConstOrDepExpr(void) {
|
|||
expr->rtype = TYPE_ENUM(expr->rtype)->enumtype;
|
||||
return expr;
|
||||
default:
|
||||
#line 7209
|
||||
CError_FATAL();
|
||||
CError_FATAL(7209);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,14 @@
|
|||
#include "compiler/CInline.h"
|
||||
#include "compiler/CMachine.h"
|
||||
#include "compiler/CMangler.h"
|
||||
#include "compiler/CObjC.h"
|
||||
#include "compiler/CObjCModern.h"
|
||||
#include "compiler/CParser.h"
|
||||
#include "compiler/CPrepTokenizer.h"
|
||||
#include "compiler/CScope.h"
|
||||
#include "compiler/CSOM.h"
|
||||
#include "compiler/CTemplateFunc.h"
|
||||
#include "compiler/CTemplateTools.h"
|
||||
#include "compiler/CodeGen.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/enode.h"
|
||||
|
@ -28,21 +33,6 @@
|
|||
#define va_arg(ap, type) (*(((type *) (ap = (char *)((((unsigned long)ap + __builtin_align(type) - 1) & ~(__builtin_align(type) - 1) ) + sizeof(type)))) - 1))
|
||||
#endif
|
||||
|
||||
// TODO MOVE ME
|
||||
extern ENode *CObjC_New(TypeClass *tclass);
|
||||
extern Boolean CObjC_IsType_id(Type *type);
|
||||
extern ENode *CObjC_Delete(TypeClass *tclass, ENode *expr);
|
||||
extern ENode *CSOM_New(TypeClass *tclass);
|
||||
extern ENode *CSOM_Delete(TypeClass *tclass, ENode *expr);
|
||||
extern ENode *CSOM_EnvCheck(ENode *, ENodeList *);
|
||||
extern ENode *CSOM_MethodAccess(BClassList *, Object *, Boolean);
|
||||
extern Boolean CTemplTool_IsTemplateArgumentDependentExpression(ENode *expr);
|
||||
extern ENode *CTemplTool_DeduceDefaultArg(Object *func, ENode *expr);
|
||||
extern Boolean CTempl_CanDeduceFunc(Object *func, TypeFunc *tfunc, TemplArg *templargs);
|
||||
extern void CTempl_FuncMatch(NameSpaceObjectList *nsol, TemplArg *templargs, ENodeList *argexprs, Match13 *match, ENode *expr);
|
||||
extern TemplFuncInstance *CTempl_DeduceFunc(Object *func, TypeFunc *tfunc, TemplArg *templargs, Object *anotherobj, Boolean flag);
|
||||
extern Boolean CObjC_IsCompatibleType(Type *a, Type *b);
|
||||
|
||||
ENode *assign_node;
|
||||
Boolean temp_reference_init;
|
||||
static SInt32 assign_value; // type?
|
||||
|
@ -172,8 +162,7 @@ restart:
|
|||
CExpr_RecSearchExprTree(expr->data.itc.result);
|
||||
return;
|
||||
default:
|
||||
#line 128
|
||||
CError_FATAL();
|
||||
CError_FATAL(128);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -296,8 +285,7 @@ static ENode *CExpr_RecSearchExprTreeReplace(ENode *expr) {
|
|||
expr->data.cond.expr2 = CExpr_RecSearchExprTreeReplace(expr->data.cond.expr2);
|
||||
return expr;
|
||||
default:
|
||||
#line 220
|
||||
CError_FATAL();
|
||||
CError_FATAL(220);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -557,13 +545,13 @@ ENode *CExpr_NewETEMPNode(Type *type, Boolean assign_id) {
|
|||
static ENode *CExpr_DerefETEMPCopy(ENode *expr) {
|
||||
ENode *copy;
|
||||
|
||||
#line 636
|
||||
CError_ASSERT(expr->rtype->type == TYPEPOINTER);
|
||||
CError_ASSERT(636, IS_TYPE_POINTER_ONLY(expr->rtype));
|
||||
|
||||
copy = lalloc(sizeof(ENode));
|
||||
*copy = *expr;
|
||||
copy = makemonadicnode(copy, EINDIRECT);
|
||||
copy->rtype = TYPE_POINTER(copy->rtype)->target;
|
||||
return copy;
|
||||
}
|
||||
|
||||
ENode *CExpr_GetETEMPCopy(ENode *expr) {
|
||||
|
@ -682,8 +670,7 @@ void CExpr_ArithmeticConversion(ENode **left, ENode **right) {
|
|||
if ((*left)->rtype == (Type *) &stsignedlong) {
|
||||
*left = promote(*left, (Type *) &stunsignedlong);
|
||||
} else {
|
||||
#line 838
|
||||
CError_ASSERT((*left)->rtype == (Type *) &stsignedlonglong);
|
||||
CError_ASSERT(838, (*left)->rtype == (Type *) &stsignedlonglong);
|
||||
*left = promote(*left, (Type *) &stunsignedlonglong);
|
||||
}
|
||||
}
|
||||
|
@ -742,14 +729,13 @@ static ENode *CExpr_GetEA(ENode *expr) {
|
|||
}
|
||||
|
||||
ENode *CExpr_TempModifyExpr(ENode *expr) {
|
||||
// register issues
|
||||
Type *type;
|
||||
ENode *tempnode;
|
||||
ENode *eanode;
|
||||
ENode *assnode2;
|
||||
ENode *left;
|
||||
ENode *right;
|
||||
ENode *work;
|
||||
ENode *eanode;
|
||||
ENode *tempnode;
|
||||
ENode *indnode;
|
||||
ENode *truenode;
|
||||
|
||||
type = expr->rtype;
|
||||
tempnode = CExpr_NewETEMPNode(type, 1);
|
||||
|
@ -759,23 +745,24 @@ ENode *CExpr_TempModifyExpr(ENode *expr) {
|
|||
return expr;
|
||||
}
|
||||
|
||||
// tempnode = expr
|
||||
left = makemonadicnode(tempnode, EINDIRECT);
|
||||
left->rtype = type;
|
||||
work = makediadicnode(left, expr, EASS);
|
||||
left = makediadicnode(left, expr, EASS);
|
||||
|
||||
left = makemonadicnode(eanode, EINDIRECT);
|
||||
left->rtype = type;
|
||||
right = nullnode();
|
||||
right->rtype = (Type *) &stbool;
|
||||
CInt64_SetLong(&right->data.intval, 1);
|
||||
assnode2 = makediadicnode(left, right, EASS);
|
||||
// eanode = true
|
||||
indnode = makemonadicnode(eanode, EINDIRECT);
|
||||
indnode->rtype = type;
|
||||
truenode = nullnode();
|
||||
truenode->rtype = (Type *) &stbool;
|
||||
CInt64_SetLong(&truenode->data.intval, 1);
|
||||
right = makediadicnode(indnode, truenode, EASS);
|
||||
|
||||
work = makediadicnode(work, assnode2, ECOMMA);
|
||||
right = makemonadicnode(tempnode, EINDIRECT);
|
||||
right->rtype = type;
|
||||
work = makediadicnode(work, right, ECOMMA);
|
||||
expr = makediadicnode(left, right, ECOMMA);
|
||||
|
||||
return work;
|
||||
indnode = makemonadicnode(tempnode, EINDIRECT);
|
||||
indnode->rtype = type;
|
||||
return makediadicnode(expr, indnode, ECOMMA);
|
||||
}
|
||||
|
||||
Boolean CExpr_IsLValue(ENode *expr) {
|
||||
|
@ -924,7 +911,7 @@ loop:
|
|||
ENode *CExpr_MakeObjRefNode(Object *obj, Boolean flag) {
|
||||
ENode *expr;
|
||||
|
||||
if (obj->sclass == OBJECT_SCLASS_104) {
|
||||
if (obj->sclass == TK_TYPEDEF) {
|
||||
CError_Error(141);
|
||||
return intconstnode((Type *) &void_ptr, 0);
|
||||
}
|
||||
|
@ -978,16 +965,20 @@ ENode *CExpr_IsTempConstruction(ENode *expr, Type *type, ENode **resultexpr) {
|
|||
ENode *funccall;
|
||||
ENode *funcref;
|
||||
|
||||
if (!ENODE_IS(expr, EINDIRECT) || expr->rtype != type || !ENODE_IS((funccall = expr->data.monadic), EFUNCCALL) || !(args = funccall->data.funccall.args))
|
||||
if (
|
||||
!ENODE_IS(expr, EINDIRECT) ||
|
||||
expr->rtype != type ||
|
||||
!ENODE_IS((funccall = expr->data.monadic), EFUNCCALL) ||
|
||||
!(args = funccall->data.funccall.args)
|
||||
)
|
||||
return NULL;
|
||||
|
||||
if (!ENODE_IS((funcref = funccall->data.funccall.funcref), EOBJREF) || !CClass_IsConstructor(funcref->data.objref)) {
|
||||
if (expr->data.monadic->data.funccall.functype->functype != type)
|
||||
return NULL;
|
||||
if (CABI_GetStructResultArgumentIndex() == 1) {
|
||||
if (CABI_GetStructResultArgumentIndex(expr->data.monadic->data.funccall.functype) == 1) {
|
||||
args = args->next;
|
||||
#line 1277
|
||||
CError_ASSERT(args);
|
||||
CError_ASSERT(1277, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1040,8 +1031,7 @@ ENode *funccallexpr(Object *func, ENode *arg1, ENode *arg2, ENode *arg3, ENode *
|
|||
ENodeList *list;
|
||||
|
||||
tfunc = TYPE_FUNC(func->type);
|
||||
#line 1411
|
||||
CError_ASSERT(IS_TYPE_FUNC(tfunc));
|
||||
CError_ASSERT(1411, IS_TYPE_FUNC(tfunc));
|
||||
|
||||
expr = lalloc(sizeof(ENode));
|
||||
expr->type = EFUNCCALL;
|
||||
|
@ -1084,8 +1074,7 @@ ENode *CExpr_FuncCallSix(Object *func, ENode *arg1, ENode *arg2, ENode *arg3, EN
|
|||
ENodeList *list;
|
||||
|
||||
tfunc = TYPE_FUNC(func->type);
|
||||
#line 1460
|
||||
CError_ASSERT(IS_TYPE_FUNC(tfunc));
|
||||
CError_ASSERT(1460, IS_TYPE_FUNC(tfunc));
|
||||
|
||||
expr = lalloc(sizeof(ENode));
|
||||
expr->type = EFUNCCALL;
|
||||
|
@ -1134,8 +1123,7 @@ static void CExpr_CalcStdAssign(short checkresult, Match5 *match, Type *t1, UInt
|
|||
match->x6 += assign_value;
|
||||
break;
|
||||
default:
|
||||
#line 1504
|
||||
CError_FATAL();
|
||||
CError_FATAL(1504);
|
||||
}
|
||||
|
||||
if (flag || (IS_TYPE_POINTER_ONLY(t2) && (IS_TYPE_POINTER_ONLY(t1) || IS_TYPEPOINTER_REFERENCE(TYPE_POINTER(t2))) != 0)) {
|
||||
|
@ -1197,8 +1185,7 @@ Boolean CExpr_MatchAssign(Type *type, UInt32 qual, ENode *expr, Match13 *match)
|
|||
match->match5.x8 += user_std_match.x8;
|
||||
break;
|
||||
default:
|
||||
#line 1585
|
||||
CError_FATAL();
|
||||
CError_FATAL(1585);
|
||||
}
|
||||
|
||||
if (IS_TYPE_POINTER_ONLY(type))
|
||||
|
@ -1234,7 +1221,7 @@ static short CExpr2_MemberPointerConversion(Type *type, ENode *expr, Boolean fla
|
|||
newnode = lalloc(sizeof(ENode));
|
||||
*newnode = *expr;
|
||||
if (!IS_TYPE_MEMBERPOINTER(newnode->rtype)) {
|
||||
newnode = CExpr_MemberPointerConversion(newnode, type, flag1);
|
||||
newnode = CExpr_MemberPointerConversion(newnode, TYPE_MEMBER_POINTER(type), flag1);
|
||||
if (iscpp_typeequal(newnode->rtype, type)) {
|
||||
if (flag1)
|
||||
assign_node = newnode;
|
||||
|
@ -1243,10 +1230,8 @@ static short CExpr2_MemberPointerConversion(Type *type, ENode *expr, Boolean fla
|
|||
}
|
||||
|
||||
if (IS_TYPE_MEMBERPOINTER(newnode->rtype)) {
|
||||
#line 1656
|
||||
CError_ASSERT(IS_TYPE_CLASS(TYPE_MEMBER_POINTER(type)->ty2));
|
||||
#line 1657
|
||||
CError_ASSERT(IS_TYPE_CLASS(TYPE_MEMBER_POINTER(newnode->rtype)->ty2));
|
||||
CError_ASSERT(1656, IS_TYPE_CLASS(TYPE_MEMBER_POINTER(type)->ty2));
|
||||
CError_ASSERT(1657, IS_TYPE_CLASS(TYPE_MEMBER_POINTER(newnode->rtype)->ty2));
|
||||
|
||||
if (CClass_IsBaseClass(TYPE_CLASS(TYPE_MEMBER_POINTER(type)->ty2), TYPE_CLASS(TYPE_MEMBER_POINTER(newnode->rtype)->ty2), &depth, 0, 0)) {
|
||||
assign_value = 1000 - depth;
|
||||
|
@ -1270,8 +1255,7 @@ ENode *CExpr_ClassPointerCast(BClassList *cls, ENode *origexpr, Boolean nullchec
|
|||
expr = origexpr;
|
||||
tclass = TYPE_CLASS(cls->type);
|
||||
do_nullcheck = 0;
|
||||
#line 1691
|
||||
CError_ASSERT(cls);
|
||||
CError_ASSERT(1691, cls);
|
||||
|
||||
if (!IS_TYPE_POINTER_ONLY(origexpr->rtype)) {
|
||||
CError_Error(CErrorStr141);
|
||||
|
@ -1346,10 +1330,8 @@ ENode *CExpr_GetClassAccessNode(BClassList *a, BClassList *b, ENode *expr, Objec
|
|||
expr->rtype = TYPE(cscope_currentclass);
|
||||
}
|
||||
|
||||
#line 1786
|
||||
CError_ASSERT(a);
|
||||
#line 1787
|
||||
CError_ASSERT(IS_TYPE_CLASS(expr->rtype));
|
||||
CError_ASSERT(1786, a);
|
||||
CError_ASSERT(1787, IS_TYPE_CLASS(expr->rtype));
|
||||
|
||||
tclass = TYPE_CLASS(expr->rtype);
|
||||
a = CScope_GetClassAccessPath(a, tclass);
|
||||
|
@ -1411,8 +1393,7 @@ static short std_assign_check_overload(NameSpaceObjectList *list, TemplArg *temp
|
|||
if (IS_TYPE_FUNC(obj->type) && (TYPE_FUNC(obj->type)->flags & FUNC_FLAGS_100000)) {
|
||||
if (!found_non_template_func && CTempl_CanDeduceFunc(obj, TYPE_FUNC(type), templargs)) {
|
||||
instance = CTempl_DeduceFunc(obj, TYPE_FUNC(type), templargs, NULL, 0);
|
||||
#line 1861
|
||||
CError_ASSERT(instance);
|
||||
CError_ASSERT(1861, instance);
|
||||
if (is_typesame(instance->object->type, type)) {
|
||||
if (used_obj && used_obj != instance->object)
|
||||
is_ambig = 1;
|
||||
|
@ -1458,7 +1439,7 @@ static short std_assign_check_overload(NameSpaceObjectList *list, TemplArg *temp
|
|||
}
|
||||
}
|
||||
|
||||
ENode *CExpr_ConvertToBool(ENode *expr, Boolean flag) {
|
||||
ENode *CExpr_ConvertToBool(ENode *expr, Boolean isExplicit) {
|
||||
if (IS_TYPE_MEMBERPOINTER(expr->rtype))
|
||||
expr = CExpr_ConvertToCondition(expr);
|
||||
|
||||
|
@ -1485,7 +1466,7 @@ ENode *CExpr_ConvertToBool(ENode *expr, Boolean flag) {
|
|||
break;
|
||||
default:
|
||||
CError_Error(
|
||||
flag ? CErrorStr247 : CErrorStr209,
|
||||
isExplicit ? CErrorStr247 : CErrorStr209,
|
||||
expr->rtype,
|
||||
expr->flags & ENODE_FLAG_QUALS,
|
||||
&stbool,
|
||||
|
@ -1841,8 +1822,7 @@ short user_assign_check(ENode *expr, Type *type, UInt32 qual, Boolean flag1, Boo
|
|||
UInt16 chk;
|
||||
Boolean is_const, is_volatile;
|
||||
|
||||
#line 2378
|
||||
CError_ASSERT(copts.old_argmatch);
|
||||
CError_ASSERT(2378, copts.old_argmatch);
|
||||
|
||||
memclrw(&stdmatch, sizeof(Match5));
|
||||
r24 = 0;
|
||||
|
@ -1872,8 +1852,7 @@ short user_assign_check(ENode *expr, Type *type, UInt32 qual, Boolean flag1, Boo
|
|||
}
|
||||
if ((result = std_assign_check(r14, type, 0, flag3))) {
|
||||
CExpr_CalcStdAssign(result, &match_98, r17->functype, r17->qual, type, qual, 1);
|
||||
#line 2419
|
||||
CError_ASSERT(r17->args && IS_TYPE_POINTER_ONLY(r17->args->type));
|
||||
CError_ASSERT(2419, r17->args && IS_TYPE_POINTER_ONLY(r17->args->type));
|
||||
chk = expr->flags;
|
||||
if (!(is_const = (r17->args->qual & Q_CONST)) && (chk & Q_CONST) != 0)
|
||||
continue;
|
||||
|
@ -1976,8 +1955,7 @@ short user_assign_check(ENode *expr, Type *type, UInt32 qual, Boolean flag1, Boo
|
|||
if (flag1) {
|
||||
if (r24) {
|
||||
r13 = TYPE_METHOD(r26->type);
|
||||
#line 2537
|
||||
CError_ASSERT(r13->flags & FUNC_FLAGS_METHOD);
|
||||
CError_ASSERT(2537, r13->flags & FUNC_FLAGS_METHOD);
|
||||
r15b = create_objectrefnode(r26);
|
||||
r26->flags |= OBJECT_FLAGS_UNUSED;
|
||||
r14d = lalloc(sizeof(ENodeList));
|
||||
|
@ -2092,8 +2070,7 @@ void CExpr_CheckArithmConversion(ENode *expr, Type *type) {
|
|||
if (IS_TYPE_INT(expr->rtype)) {
|
||||
if (IS_TYPE_FLOAT(type))
|
||||
return;
|
||||
#line 2772
|
||||
CError_ASSERT(IS_TYPE_INT(type));
|
||||
CError_ASSERT(2772, IS_TYPE_INT(type));
|
||||
|
||||
if (type->size > expr->rtype->size)
|
||||
return;
|
||||
|
@ -2152,8 +2129,7 @@ ENode *get_address_of_temp_copy(ENode *expr, Boolean flag) {
|
|||
innertype = TYPE(&stunsignedlong);
|
||||
break;
|
||||
default:
|
||||
#line 2857
|
||||
CError_FATAL();
|
||||
CError_FATAL(2857);
|
||||
}
|
||||
CMach_InitIntMem(innertype, expr->data.intval, buf);
|
||||
} else {
|
||||
|
@ -2440,8 +2416,7 @@ ENode *CExpr_GetDefaultArgument(ENode *funcexpr, FuncArg *arg) {
|
|||
ENode *tmp;
|
||||
|
||||
if (CTemplTool_IsTemplateArgumentDependentExpression(arg->dexpr)) {
|
||||
#line 3264
|
||||
CError_ASSERT(ENODE_IS(funcexpr, EOBJREF));
|
||||
CError_ASSERT(3264, ENODE_IS(funcexpr, EOBJREF));
|
||||
tmp = CTemplTool_DeduceDefaultArg(
|
||||
funcexpr->data.objref,
|
||||
CInline_CopyExpression(arg->dexpr, CopyMode0)
|
||||
|
@ -2650,8 +2625,7 @@ ENode *CExpr_GenericFuncCall(BClassList *path, ENode *funcexpr, Boolean flag1, O
|
|||
scan_arg = tfunc->args;
|
||||
scan_expr = nodes;
|
||||
if (tfunc->flags & FUNC_FLAGS_METHOD) {
|
||||
#line 3599
|
||||
CError_ASSERT(TYPE_METHOD(tfunc)->theclass->sominfo == NULL);
|
||||
CError_ASSERT(3599, TYPE_METHOD(tfunc)->theclass->sominfo == NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2883,8 +2857,7 @@ static Boolean accept_conversion_type(Type *type, short mode) {
|
|||
case 3:
|
||||
return IS_TYPE_POINTER_ONLY(type);
|
||||
default:
|
||||
#line 3912
|
||||
CError_FATAL();
|
||||
CError_FATAL(3912);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -3077,8 +3050,7 @@ static Boolean is_legal_type_combination(Type *left, Type *right, short mode) {
|
|||
diadic_arg2.type = right;
|
||||
return 1;
|
||||
default:
|
||||
#line 4132
|
||||
CError_FATAL();
|
||||
CError_FATAL(4132);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -3272,8 +3244,7 @@ Boolean CExpr_CheckOperator(short token, ENode *left, ENode *right, Conversion *
|
|||
tk = lex();
|
||||
return 1;
|
||||
} else {
|
||||
#line 4371
|
||||
CError_FATAL();
|
||||
CError_FATAL(4371);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -3320,8 +3291,7 @@ Boolean CExpr_CheckOperator(short token, ENode *left, ENode *right, Conversion *
|
|||
tk = lex();
|
||||
return 1;
|
||||
} else {
|
||||
#line 4439
|
||||
CError_FATAL();
|
||||
CError_FATAL(4439);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -3344,8 +3314,7 @@ Boolean CExpr_CheckOperator(short token, ENode *left, ENode *right, Conversion *
|
|||
mylist_B0.object = pr2.obj_10;
|
||||
pr2.nsol_14 = &mylist_B0;
|
||||
} else {
|
||||
#line 4470
|
||||
CError_ASSERT(pr2.nsol_14);
|
||||
CError_ASSERT(4470, pr2.nsol_14);
|
||||
}
|
||||
|
||||
if (token != '=' || (pr2.bcl_18->type == left->rtype && pr2.bcl_18->next == NULL)) {
|
||||
|
@ -3406,15 +3375,13 @@ ENode *CExpr_ConstructObject(TypeClass *tclass, ENode *addr_expr, ENodeList *arg
|
|||
NameSpaceObjectList *ctorlist;
|
||||
BClassList path;
|
||||
|
||||
#line 4595
|
||||
CError_ASSERT(IS_TYPE_POINTER_ONLY(addr_expr->rtype));
|
||||
CError_ASSERT(4595, IS_TYPE_POINTER_ONLY(addr_expr->rtype));
|
||||
|
||||
addr_expr = makemonadicnode(addr_expr, EINDIRECT);
|
||||
addr_expr->rtype = TYPE(tclass);
|
||||
|
||||
if (!flag3 && args && !args->next && args->node->rtype == TYPE(tclass) && !CClass_CopyConstructor(tclass)) {
|
||||
#line 4605
|
||||
CError_ASSERT(IS_TYPE_CLASS(addr_expr->rtype));
|
||||
CError_ASSERT(4605, IS_TYPE_CLASS(addr_expr->rtype));
|
||||
expr = makediadicnode(addr_expr, args->node, EASS);
|
||||
if (!flag1)
|
||||
expr = getnodeaddress(expr, 0);
|
||||
|
@ -3502,8 +3469,7 @@ static ENode *CExpr_CopyPlacementNewArg(ENodeList *list) {
|
|||
|
||||
switch (list->node->rtype->type) {
|
||||
default:
|
||||
#line 4726
|
||||
CError_FATAL();
|
||||
CError_FATAL(4726);
|
||||
case TYPEINT:
|
||||
case TYPEFLOAT:
|
||||
case TYPEENUM:
|
||||
|
@ -3523,12 +3489,10 @@ static ENode *CExpr_PlacementDeleteCall(Type *type, ENode *expr, Object *obj, Bo
|
|||
ENodeList *inputarg;
|
||||
Boolean outflag;
|
||||
|
||||
#line 4752
|
||||
CError_ASSERT(ENODE_IS(expr, EFUNCCALL) && ENODE_IS(expr->data.funccall.funcref, EOBJREF));
|
||||
CError_ASSERT(4752, ENODE_IS(expr, EFUNCCALL) && ENODE_IS(expr->data.funccall.funcref, EOBJREF));
|
||||
|
||||
funcobj = expr->data.funccall.funcref->data.objref;
|
||||
#line 4756
|
||||
CError_ASSERT(IS_TYPE_FUNC(funcobj->type) && TYPE_FUNC(funcobj->type)->args && TYPE_FUNC(funcobj->type)->args->next);
|
||||
CError_ASSERT(4756, IS_TYPE_FUNC(funcobj->type) && TYPE_FUNC(funcobj->type)->args && TYPE_FUNC(funcobj->type)->args->next);
|
||||
|
||||
funcobj = CParser_FindDeallocationObject(type, TYPE_FUNC(funcobj->type)->args->next, flag1, flag2, &outflag);
|
||||
if (!funcobj)
|
||||
|
@ -3546,8 +3510,7 @@ static ENode *CExpr_PlacementDeleteCall(Type *type, ENode *expr, Object *obj, Bo
|
|||
list->node = create_objectnode(obj);
|
||||
result->data.funccall.args = list;
|
||||
|
||||
#line 4780
|
||||
CError_ASSERT((inputarg = expr->data.funccall.args) && (inputarg = inputarg->next));
|
||||
CError_ASSERT(4780, (inputarg = expr->data.funccall.args) && (inputarg = inputarg->next));
|
||||
|
||||
do {
|
||||
list->next = lalloc(sizeof(ENodeList));
|
||||
|
@ -3688,12 +3651,10 @@ static ENode *CExpr_NewAlloc(Type *type, ENodeList *args, Boolean flag1, Boolean
|
|||
if (CScope_FindClassMemberObject(TYPE_CLASS(type), &pr, name)) {
|
||||
list = pr.nsol_14;
|
||||
obj = OBJECT(pr.obj_10);
|
||||
#line 4935
|
||||
CError_ASSERT(list || obj);
|
||||
CError_ASSERT(4935, list || obj);
|
||||
found = 1;
|
||||
} else if (TYPE_CLASS(type)->flags & CLASS_FLAGS_1) {
|
||||
#line 4942
|
||||
CError_ASSERT(!flag2);
|
||||
CError_ASSERT(4942, !flag2);
|
||||
obj = newh_func;
|
||||
found = 1;
|
||||
}
|
||||
|
@ -3764,8 +3725,7 @@ static ENode *CExpr_NewExceptionSafeInit(ENode *expr, ENode *tryexpr) {
|
|||
expr->data.itc.tryexpr = tryexpr;
|
||||
break;
|
||||
default:
|
||||
#line 5056
|
||||
CError_FATAL();
|
||||
CError_FATAL(5056);
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
|
@ -3834,7 +3794,7 @@ static ENode *CExpr_NewArray(Type *type, UInt32 qual, ENodeList *nodelist, Boole
|
|||
|
||||
dtor = CClass_Destructor(TYPE_CLASS(innertype));
|
||||
if (dtor)
|
||||
dtor = CABI_GetDestructorObject(dtor, 1);
|
||||
dtor = CABI_GetDestructorObject(dtor, CABIDestroy1);
|
||||
|
||||
ass = NULL;
|
||||
if (firstarrayexpr) {
|
||||
|
@ -4223,8 +4183,7 @@ ENode *scandelete(Boolean flag) {
|
|||
if (!flag) {
|
||||
result_expr = CABI_DestroyObject(dtor, expr, 2, 0, 1);
|
||||
} else {
|
||||
#line 5650
|
||||
CError_ASSERT(!outflag);
|
||||
CError_ASSERT(5650, !outflag);
|
||||
result_expr = CABI_DestroyObject(dtor, expr, 2, 0, 0);
|
||||
result_expr->rtype = TYPE(&void_ptr);
|
||||
result_expr = funccallexpr(obj, result_expr, NULL, NULL, NULL);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -3,25 +3,21 @@
|
|||
#include "compiler/CClass.h"
|
||||
#include "compiler/CDecl.h"
|
||||
#include "compiler/CError.h"
|
||||
#include "compiler/CException.h"
|
||||
#include "compiler/CExpr.h"
|
||||
#include "compiler/CInline.h"
|
||||
#include "compiler/CInt64.h"
|
||||
#include "compiler/CMachine.h"
|
||||
#include "compiler/CParser.h"
|
||||
#include "compiler/CPrec.h"
|
||||
#include "compiler/CPrep.h"
|
||||
#include "compiler/CPrepTokenizer.h"
|
||||
#include "compiler/CScope.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/ObjGenMachO.h"
|
||||
#include "compiler/objects.h"
|
||||
#include "compiler/types.h"
|
||||
|
||||
// TODO - move me!!
|
||||
extern void PreComp_StaticData(Object *obj, void *data, OLinkList *list, SInt32 size);
|
||||
extern void ObjGen_DeclareReadOnlyData(Object *obj, void *data, OLinkList *list, SInt32 size);
|
||||
extern void ObjGen_DeclareData(Object *obj, void *data, OLinkList *list, SInt32 size);
|
||||
extern void CExcept_RegisterDestructorObject(Object *obj, SInt32 offset, Object *dtor, Boolean flag);
|
||||
extern void CExcept_RegisterLocalArray(Statement *stmt, Object *obj, Object *dtor, SInt32 count, SInt32 size);
|
||||
|
||||
TempNodeCB cinit_tempnodefunc;
|
||||
InitInfo *cinit_initinfo;
|
||||
static PooledString *cinit_stringlist;
|
||||
|
@ -803,7 +799,7 @@ static void CInit_InitTypeArray(CInit_Stuff *s, CInit_Stuff2 *s2, TypePointer *t
|
|||
}
|
||||
}
|
||||
|
||||
static void CInit_InitTypeStruct(CInit_Stuff *s, CInit_Stuff2 *s2, TypeStruct *tstruct, UInt32 qual, Boolean errorflag) {
|
||||
static void CInit_InitTypeStruct(CInit_Stuff *s, CInit_Stuff2 *s2, const TypeStruct *tstruct, UInt32 qual, Boolean errorflag) {
|
||||
StructMember *member;
|
||||
SInt32 start;
|
||||
Boolean flag;
|
||||
|
@ -1257,7 +1253,7 @@ static ENode *CInit_RegisterDtorObject(Type *type, Object *dtor, ENode *objexpr)
|
|||
expr->data.funccall.args = lalloc(sizeof(ENodeList));
|
||||
expr->data.funccall.args->node = objexpr;
|
||||
expr->data.funccall.args->next = lalloc(sizeof(ENodeList));
|
||||
expr->data.funccall.args->next->node = create_objectrefnode(CABI_GetDestructorObject(dtor, 1));
|
||||
expr->data.funccall.args->next->node = create_objectrefnode(CABI_GetDestructorObject(dtor, CABIDestroy1));
|
||||
expr->data.funccall.args->next->next = lalloc(sizeof(ENodeList));
|
||||
expr->data.funccall.args->next->next->node = create_objectrefnode(CInit_CreateStaticData(CInit_GetRegMemType()));
|
||||
expr->data.funccall.args->next->next->next = NULL;
|
||||
|
@ -1266,7 +1262,7 @@ static ENode *CInit_RegisterDtorObject(Type *type, Object *dtor, ENode *objexpr)
|
|||
}
|
||||
|
||||
static Boolean CInit_ConstructGlobalObject(Object *obj, TypeClass *tclass, ENode *valueexpr, SInt32 offset, Boolean flag) {
|
||||
Object *ctor;
|
||||
NameSpaceObjectList *ctor;
|
||||
Object *dtor;
|
||||
ENodeList *list;
|
||||
ENode *expr;
|
||||
|
@ -1336,7 +1332,7 @@ static Boolean CInit_ConstructGlobalObject(Object *obj, TypeClass *tclass, ENode
|
|||
static Boolean CInit_ConstructAutoObject(TypeClass *tclass, ENode *expr, SInt32 offset, Boolean flag) {
|
||||
ENodeList *r30;
|
||||
ENode *r29;
|
||||
Object *ctor;
|
||||
NameSpaceObjectList *ctor;
|
||||
Object *dtor;
|
||||
Boolean r24;
|
||||
|
||||
|
@ -1920,7 +1916,7 @@ static void CInit_AutoInit(Type *type, ENode *valueexpr, Boolean flag) {
|
|||
copy = galloc(sizeof(TypePointer));
|
||||
*TYPE_POINTER(copy) = *TYPE_POINTER(type);
|
||||
type = copy;
|
||||
copy->size = type->size + 1;
|
||||
type->size++;
|
||||
}
|
||||
expr = create_objectrefnode(cinit_initinfo->obj1C);
|
||||
if (!IS_TYPE_POINTER_ONLY(expr->rtype)) {
|
||||
|
@ -2163,7 +2159,7 @@ Statement *CInit_ConstructClassArray(Statement *stmt, TypeClass *tclass, Object
|
|||
stmt = CFunc_AppendStatement(ST_EXPRESSION);
|
||||
|
||||
if (dtor)
|
||||
dtor_expr = create_objectrefnode(CABI_GetDestructorObject(dtor, 1));
|
||||
dtor_expr = create_objectrefnode(CABI_GetDestructorObject(dtor, CABIDestroy1));
|
||||
else
|
||||
dtor_expr = nullnode();
|
||||
|
||||
|
@ -2236,7 +2232,7 @@ static void CInit_InitializeClassArray(Object *obj, TypeClass *tclass, Boolean f
|
|||
expr = nullnode();
|
||||
} else {
|
||||
if (dtor)
|
||||
dtor_expr = create_objectrefnode(CABI_GetDestructorObject(dtor, 1));
|
||||
dtor_expr = create_objectrefnode(CABI_GetDestructorObject(dtor, CABIDestroy1));
|
||||
else
|
||||
dtor_expr = nullnode();
|
||||
expr = CExpr_FuncCallSix(
|
||||
|
@ -2270,7 +2266,7 @@ static void CInit_InitializeClassArray(Object *obj, TypeClass *tclass, Boolean f
|
|||
CParser_RegisterSingleExprFunction(funcobj, funccallexpr(
|
||||
darr_func,
|
||||
create_objectrefnode(obj),
|
||||
create_objectrefnode(CABI_GetDestructorObject(dtor, 1)),
|
||||
create_objectrefnode(CABI_GetDestructorObject(dtor, CABIDestroy1)),
|
||||
intconstnode(TYPE(&stsignedlong), tclass->size),
|
||||
intconstnode(TYPE(&stsignedlong), count)
|
||||
));
|
||||
|
@ -2330,7 +2326,7 @@ static ENode *CInit_GlobalTempNode(Type *type, Boolean flag) {
|
|||
funcnode->data.funccall.args = lalloc(sizeof(ENodeList));
|
||||
funcnode->data.funccall.args->node = node;
|
||||
funcnode->data.funccall.args->next = lalloc(sizeof(ENodeList));
|
||||
funcnode->data.funccall.args->next->node = create_objectrefnode(CABI_GetDestructorObject(dtor, 1));
|
||||
funcnode->data.funccall.args->next->node = create_objectrefnode(CABI_GetDestructorObject(dtor, CABIDestroy1));
|
||||
funcnode->data.funccall.args->next->next = lalloc(sizeof(ENodeList));
|
||||
funcnode->data.funccall.args->next->next->node = create_objectrefnode(CInit_CreateStaticData(CInit_GetRegMemType()));;
|
||||
funcnode->data.funccall.args->next->next->next = NULL;
|
||||
|
@ -2641,7 +2637,7 @@ void CInit_InitializeAutoData(Object *obj, InsertExprCB insert_cb, RegisterObjec
|
|||
}
|
||||
|
||||
if (IS_TYPE_CLASS(obj->type) && CClass_Destructor(TYPE_CLASS(obj->type)))
|
||||
register_cb(obj->type, obj, 0, NULL);
|
||||
register_cb(obj->type, obj, 0, 0);
|
||||
|
||||
CInit_CleanupInitInfo(&initinfo);
|
||||
}
|
||||
|
|
|
@ -47,54 +47,54 @@ HashNameNode *CMangler_DeleteDtorName(void) {
|
|||
return GetHashNameNodeExport("__dt");
|
||||
}
|
||||
|
||||
char *CMangler_GetOperator(HashNameNode *opname) {
|
||||
char *name;
|
||||
char *CMangler_GetOperator(HashNameNode *name) {
|
||||
char *str;
|
||||
|
||||
if (opname == asop_name_node)
|
||||
if (name == asop_name_node)
|
||||
return "operator=";
|
||||
|
||||
name = opname->name;
|
||||
if (!strcmp(name, "__nw")) return "operator new";
|
||||
if (!strcmp(name, "__dl")) return "operator delete";
|
||||
if (!strcmp(name, "__nwa")) return "operator new[]";
|
||||
if (!strcmp(name, "__dla")) return "operator delete[]";
|
||||
if (!strcmp(name, "__pl")) return "operator+";
|
||||
if (!strcmp(name, "__mi")) return "operator-";
|
||||
if (!strcmp(name, "__ml")) return "operator*";
|
||||
if (!strcmp(name, "__dv")) return "operator/";
|
||||
if (!strcmp(name, "__md")) return "operator%";
|
||||
if (!strcmp(name, "__er")) return "operator^";
|
||||
if (!strcmp(name, "__ad")) return "operator&";
|
||||
if (!strcmp(name, "__or")) return "operator|";
|
||||
if (!strcmp(name, "__co")) return "operator~";
|
||||
if (!strcmp(name, "__nt")) return "operator!";
|
||||
if (!strcmp(name, "__lt")) return "operator<";
|
||||
if (!strcmp(name, "__gt")) return "operator>";
|
||||
if (!strcmp(name, "__apl")) return "operator+=";
|
||||
if (!strcmp(name, "__ami")) return "operator-=";
|
||||
if (!strcmp(name, "__amu")) return "operator*=";
|
||||
if (!strcmp(name, "__adv")) return "operator/=";
|
||||
if (!strcmp(name, "__amd")) return "operator%=";
|
||||
if (!strcmp(name, "__aer")) return "operator^=";
|
||||
if (!strcmp(name, "__aad")) return "operator&=";
|
||||
if (!strcmp(name, "__aor")) return "operator|=";
|
||||
if (!strcmp(name, "__ls")) return "operator<<";
|
||||
if (!strcmp(name, "__rs")) return "operator>>";
|
||||
if (!strcmp(name, "__als")) return "operator<<=";
|
||||
if (!strcmp(name, "__ars")) return "operator>>=";
|
||||
if (!strcmp(name, "__eq")) return "operator==";
|
||||
if (!strcmp(name, "__ne")) return "operator!=";
|
||||
if (!strcmp(name, "__le")) return "operator<=";
|
||||
if (!strcmp(name, "__ge")) return "operator>=";
|
||||
if (!strcmp(name, "__aa")) return "operator&&";
|
||||
if (!strcmp(name, "__oo")) return "operator||";
|
||||
if (!strcmp(name, "__pp")) return "operator++";
|
||||
if (!strcmp(name, "__mm")) return "operator--";
|
||||
if (!strcmp(name, "__cm")) return "operator,";
|
||||
if (!strcmp(name, "__rm")) return "operator->*";
|
||||
if (!strcmp(name, "__rf")) return "operator*";
|
||||
if (!strcmp(name, "__cl")) return "operator()";
|
||||
if (!strcmp(name, "__vc")) return "operator[]";
|
||||
str = name->name;
|
||||
if (!strcmp(str, "__nw")) return "operator new";
|
||||
if (!strcmp(str, "__dl")) return "operator delete";
|
||||
if (!strcmp(str, "__nwa")) return "operator new[]";
|
||||
if (!strcmp(str, "__dla")) return "operator delete[]";
|
||||
if (!strcmp(str, "__pl")) return "operator+";
|
||||
if (!strcmp(str, "__mi")) return "operator-";
|
||||
if (!strcmp(str, "__ml")) return "operator*";
|
||||
if (!strcmp(str, "__dv")) return "operator/";
|
||||
if (!strcmp(str, "__md")) return "operator%";
|
||||
if (!strcmp(str, "__er")) return "operator^";
|
||||
if (!strcmp(str, "__ad")) return "operator&";
|
||||
if (!strcmp(str, "__or")) return "operator|";
|
||||
if (!strcmp(str, "__co")) return "operator~";
|
||||
if (!strcmp(str, "__nt")) return "operator!";
|
||||
if (!strcmp(str, "__lt")) return "operator<";
|
||||
if (!strcmp(str, "__gt")) return "operator>";
|
||||
if (!strcmp(str, "__apl")) return "operator+=";
|
||||
if (!strcmp(str, "__ami")) return "operator-=";
|
||||
if (!strcmp(str, "__amu")) return "operator*=";
|
||||
if (!strcmp(str, "__adv")) return "operator/=";
|
||||
if (!strcmp(str, "__amd")) return "operator%=";
|
||||
if (!strcmp(str, "__aer")) return "operator^=";
|
||||
if (!strcmp(str, "__aad")) return "operator&=";
|
||||
if (!strcmp(str, "__aor")) return "operator|=";
|
||||
if (!strcmp(str, "__ls")) return "operator<<";
|
||||
if (!strcmp(str, "__rs")) return "operator>>";
|
||||
if (!strcmp(str, "__als")) return "operator<<=";
|
||||
if (!strcmp(str, "__ars")) return "operator>>=";
|
||||
if (!strcmp(str, "__eq")) return "operator==";
|
||||
if (!strcmp(str, "__ne")) return "operator!=";
|
||||
if (!strcmp(str, "__le")) return "operator<=";
|
||||
if (!strcmp(str, "__ge")) return "operator>=";
|
||||
if (!strcmp(str, "__aa")) return "operator&&";
|
||||
if (!strcmp(str, "__oo")) return "operator||";
|
||||
if (!strcmp(str, "__pp")) return "operator++";
|
||||
if (!strcmp(str, "__mm")) return "operator--";
|
||||
if (!strcmp(str, "__cm")) return "operator,";
|
||||
if (!strcmp(str, "__rm")) return "operator->*";
|
||||
if (!strcmp(str, "__rf")) return "operator*";
|
||||
if (!strcmp(str, "__cl")) return "operator()";
|
||||
if (!strcmp(str, "__vc")) return "operator[]";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -146,12 +146,12 @@ HashNameNode *CMangler_OperatorName(short token) {
|
|||
}
|
||||
}
|
||||
|
||||
HashNameNode *CMangler_VTableName(TypeClass *tclass) {
|
||||
HashNameNode *CMangler_VTableName(TypeClass *theclass) {
|
||||
HashNameNode *name;
|
||||
|
||||
name_mangle_list.size = 0;
|
||||
AppendGListName(&name_mangle_list, "__vt__");
|
||||
CMangler_MangleClassName(tclass);
|
||||
CMangler_MangleClassName(theclass);
|
||||
AppendGListByte(&name_mangle_list, 0);
|
||||
COS_LockHandle(name_mangle_list.data);
|
||||
name = GetHashNameNodeExport(*name_mangle_list.data);
|
||||
|
@ -172,20 +172,20 @@ HashNameNode *CMangler_RTTIObjectName(Type *type, UInt32 qual) {
|
|||
return name;
|
||||
}
|
||||
|
||||
HashNameNode *CMangler_ThunkName(Object *obj, int a, int b, int c) {
|
||||
HashNameNode *CMangler_ThunkName(Object *vfunc, SInt32 this_delta, SInt32 return_delta, SInt32 ctoroffset) {
|
||||
HashNameNode *linkname;
|
||||
HashNameNode *name;
|
||||
char buf[64];
|
||||
|
||||
linkname = CMangler_GetLinkName(obj);
|
||||
linkname = CMangler_GetLinkName(vfunc);
|
||||
name_mangle_list.size = 0;
|
||||
if (b == 0) {
|
||||
if (c < 0)
|
||||
sprintf(buf, "_@%ld@", -a);
|
||||
if (return_delta == 0) {
|
||||
if (ctoroffset < 0)
|
||||
sprintf(buf, "_@%ld@", -this_delta);
|
||||
else
|
||||
sprintf(buf, "_@%ld@%ld@", -a, c);
|
||||
sprintf(buf, "_@%ld@%ld@", -this_delta, ctoroffset);
|
||||
} else {
|
||||
sprintf(buf, "_@%ld@%ld@%ld@", -a, c, b);
|
||||
sprintf(buf, "_@%ld@%ld@%ld@", -this_delta, ctoroffset, return_delta);
|
||||
}
|
||||
AppendGListName(&name_mangle_list, buf);
|
||||
AppendGListID(&name_mangle_list, linkname->name + 1);
|
||||
|
@ -640,15 +640,14 @@ static HashNameNode *CMangler_FunctionLinkName(Object *obj) {
|
|||
return name;
|
||||
}
|
||||
|
||||
HashNameNode *CMangler_GetCovariantFunctionName(Object *obj, Type *type) {
|
||||
HashNameNode *linkname;
|
||||
HashNameNode *CMangler_GetCovariantFunctionName(Object *dobj, TypeClass *theclass) {
|
||||
HashNameNode *name;
|
||||
|
||||
linkname = CMangler_GetLinkName(obj);
|
||||
name = CMangler_GetLinkName(dobj);
|
||||
name_mangle_list.size = 0;
|
||||
AppendGListName(&name_mangle_list, linkname->name);
|
||||
AppendGListName(&name_mangle_list, name->name);
|
||||
AppendGListName(&name_mangle_list, "@@");
|
||||
CMangler_MangleTypeAppend(type, 0);
|
||||
CMangler_MangleTypeAppend(TYPE(theclass), 0);
|
||||
AppendGListByte(&name_mangle_list, 0);
|
||||
|
||||
COS_LockHandle(name_mangle_list.data);
|
||||
|
|
|
@ -8,46 +8,26 @@
|
|||
#include "compiler/CInit.h"
|
||||
#include "compiler/CInline.h"
|
||||
#include "compiler/CInt64.h"
|
||||
#include "compiler/CIRTransform.h"
|
||||
#include "compiler/CMachine.h"
|
||||
#include "compiler/CMangler.h"
|
||||
#include "compiler/CObjC.h"
|
||||
#include "compiler/CPrep.h"
|
||||
#include "compiler/CPrepTokenizer.h"
|
||||
#include "compiler/CScope.h"
|
||||
#include "compiler/CSOM.h"
|
||||
#include "compiler/CTemplateNew.h"
|
||||
#include "compiler/CTemplateTools.h"
|
||||
#include "compiler/CodeGen.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/IrOptimizer.h"
|
||||
#include "compiler/IroPointerAnalysis.h"
|
||||
#include "compiler/ObjGenMachO.h"
|
||||
#include "compiler/objects.h"
|
||||
#include "compiler/scopes.h"
|
||||
#include "compiler/templates.h"
|
||||
#include "cos.h"
|
||||
|
||||
// TODO MOVE ME
|
||||
extern SInt32 symdecloffset;
|
||||
extern void CSOM_Setup(Boolean is_precompiler);
|
||||
extern void CSOM_Cleanup(void);
|
||||
extern void CIRTrans_Setup(void);
|
||||
extern void CObjC_Setup(void);
|
||||
extern void CObjC_GenerateModule(void);
|
||||
extern Type *CObjC_ParseTypeProtocol(Type *type);
|
||||
extern void CObjC_ParseProtocol(void);
|
||||
extern void CObjC_ParseClassDeclaration(void);
|
||||
extern void CObjC_ParseInterface(void);
|
||||
extern void CObjC_ParseImplementation(void);
|
||||
extern void CTempl_Setup(void);
|
||||
extern void CTempl_Parse(TypeClass *tclass, short access);
|
||||
extern Boolean CTempl_Instantiate(void);
|
||||
extern Boolean CInline_GenerateDeferredFuncs(void);
|
||||
extern void CTempl_Cleanup();
|
||||
extern void CIRTrans_Cleanup();
|
||||
extern void CObjC_Cleanup();
|
||||
extern void PointerAnalysis_ParseFunctionModifiesSpecifier(DeclInfo *declinfo);
|
||||
extern void PointerAnalysis_ParseExitPointsToSpecifier(DeclInfo *declinfo);
|
||||
extern void PointerAnalysis_ParseEntryPointsToSpecifier(DeclInfo *declinfo);
|
||||
extern Boolean CTemplTool_TemplDepTypeCompare(TypeTemplDep *a, TypeTemplDep *b);
|
||||
extern Boolean CTemplTool_IsSameTemplateType(Type *a, Type *b);
|
||||
extern TemplStack *ctempl_curinstance;
|
||||
extern Type *CObjC_ParseID(void);
|
||||
extern void CodeGen_UpdateOptimizerOptions(void);
|
||||
|
||||
FileOffsetInfo cparser_fileoffset;
|
||||
TStreamElement symdecltoken;
|
||||
ParserTryBlock *trychain;
|
||||
|
@ -276,16 +256,14 @@ static void CParser_SetupRuntimeObjects(void) {
|
|||
func = CParser_NewRTFunc(
|
||||
TYPE(&stvoid), CMangler_OperatorName(TK_DELETE), 1,
|
||||
1, &void_ptr);
|
||||
#line 379
|
||||
CError_ASSERT(IS_TYPE_FUNC(func->type));
|
||||
CError_ASSERT(379, IS_TYPE_FUNC(func->type));
|
||||
TYPE_FUNC(func->type)->exspecs = exspecs;
|
||||
CScope_AddGlobalObject(func);
|
||||
|
||||
func = CParser_NewRTFunc(
|
||||
TYPE(&stvoid), CMangler_OperatorName(TK_DELETE_ARRAY), 1,
|
||||
1, &void_ptr);
|
||||
#line 387
|
||||
CError_ASSERT(IS_TYPE_FUNC(func->type));
|
||||
CError_ASSERT(387, IS_TYPE_FUNC(func->type));
|
||||
TYPE_FUNC(func->type)->exspecs = exspecs;
|
||||
CScope_AddGlobalObject(func);
|
||||
|
||||
|
@ -374,8 +352,7 @@ static void CParser_SetupRuntimeObjects(void) {
|
|||
1, &void_ptr);
|
||||
|
||||
CodeGen_SetupRuntimeObjects();
|
||||
#line 534
|
||||
CError_ASSERT(CParser_ReInitRuntimeObjects(0));
|
||||
CError_ASSERT(534, CParser_ReInitRuntimeObjects(0));
|
||||
}
|
||||
|
||||
void CParser_Setup(void) {
|
||||
|
@ -825,8 +802,7 @@ FuncArg *CParser_NewFuncArg(void) {
|
|||
Type *atomtype(void) {
|
||||
switch (tksize) {
|
||||
default:
|
||||
#line 1145
|
||||
CError_FATAL();
|
||||
CError_FATAL(1145);
|
||||
case ATOM_VOID: return &stvoid;
|
||||
case ATOM_CHAR: return TYPE(&stchar);
|
||||
case ATOM_WCHAR: return TYPE(&stwchar);
|
||||
|
@ -853,8 +829,8 @@ Object *CParser_FindDeallocationObject(Type *type, FuncArg *args, Boolean flag1,
|
|||
CScopeParseResult pr;
|
||||
Boolean first_time;
|
||||
Boolean retry_flag;
|
||||
Type *sizet;
|
||||
Object *obj;
|
||||
Type *sizet;
|
||||
|
||||
list = NULL;
|
||||
*outflag = 0;
|
||||
|
@ -867,13 +843,11 @@ Object *CParser_FindDeallocationObject(Type *type, FuncArg *args, Boolean flag1,
|
|||
mylist.object = pr.obj_10;
|
||||
list = &mylist;
|
||||
} else {
|
||||
#line 1202
|
||||
CError_ASSERT(pr.nsol_14);
|
||||
CError_ASSERT(1202, pr.nsol_14);
|
||||
list = pr.nsol_14;
|
||||
}
|
||||
} else if (TYPE_CLASS(type)->flags & CLASS_FLAGS_1) {
|
||||
#line 1210
|
||||
CError_ASSERT(!args && !flag1);
|
||||
CError_ASSERT(1210, !args && !flag1);
|
||||
return delh_func;
|
||||
}
|
||||
}
|
||||
|
@ -894,8 +868,7 @@ Object *CParser_FindDeallocationObject(Type *type, FuncArg *args, Boolean flag1,
|
|||
return obj;
|
||||
}
|
||||
|
||||
#line 1231
|
||||
CError_ASSERT(first_time);
|
||||
CError_ASSERT(1231, first_time);
|
||||
|
||||
sizet = CABI_GetSizeTType();
|
||||
for (scan = list; scan; scan = scan->next) {
|
||||
|
@ -1014,19 +987,14 @@ short is_memberpointerequal(Type *a, Type *b) {
|
|||
if ((TYPE_FUNC(a)->flags & (FUNC_FLAGS_F0000000 | FUNC_FLAGS_PASCAL)) != (TYPE_FUNC(b)->flags & (FUNC_FLAGS_F0000000 | FUNC_FLAGS_PASCAL)))
|
||||
return 0;
|
||||
|
||||
#line 1345
|
||||
CError_ASSERT((arg_a = TYPE_FUNC(a)->args));
|
||||
CError_ASSERT((arg_b = TYPE_FUNC(b)->args));
|
||||
CError_ASSERT(1345, arg_a = TYPE_FUNC(a)->args);
|
||||
CError_ASSERT(1346, arg_b = TYPE_FUNC(b)->args);
|
||||
|
||||
if (TYPE_FUNC(a)->flags & FUNC_FLAGS_80) {
|
||||
#line 1351
|
||||
CError_ASSERT((arg_a = arg_a->next));
|
||||
}
|
||||
if (TYPE_FUNC(a)->flags & FUNC_FLAGS_80)
|
||||
CError_ASSERT(1351, arg_a = arg_a->next);
|
||||
|
||||
if (TYPE_FUNC(b)->flags & FUNC_FLAGS_80) {
|
||||
#line 1355
|
||||
CError_ASSERT((arg_b = arg_b->next));
|
||||
}
|
||||
if (TYPE_FUNC(b)->flags & FUNC_FLAGS_80)
|
||||
CError_ASSERT(1355, arg_b = arg_b->next);
|
||||
|
||||
if (arg_a->qual != arg_b->qual)
|
||||
return 0;
|
||||
|
@ -1082,8 +1050,7 @@ restart:
|
|||
case TYPETEMPLATE:
|
||||
return CTemplTool_TemplDepTypeCompare(TYPE_TEMPLATE(a), TYPE_TEMPLATE(b));
|
||||
default:
|
||||
#line 1441
|
||||
CError_FATAL();
|
||||
CError_FATAL(1441);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1135,8 +1102,7 @@ short iscpp_typeequal(Type *a, Type *b) {
|
|||
case TYPETEMPLATE:
|
||||
return CTemplTool_TemplDepTypeCompare(TYPE_TEMPLATE(a), TYPE_TEMPLATE(b));
|
||||
default:
|
||||
#line 1500
|
||||
CError_FATAL();
|
||||
CError_FATAL(1500);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1311,10 +1277,9 @@ restart:
|
|||
return 0;
|
||||
if ((TYPE_FUNC(a)->flags & (FUNC_FLAGS_F0000000 | FUNC_FLAGS_PASCAL)) != (TYPE_FUNC(b)->flags & (FUNC_FLAGS_F0000000 | FUNC_FLAGS_PASCAL)))
|
||||
return 0;
|
||||
return is_arglistequal(TYPE_FUNC(a)->args, TYPE_FUNC(b)->args);
|
||||
return is_arglistsame(TYPE_FUNC(a)->args, TYPE_FUNC(b)->args);
|
||||
default:
|
||||
#line 1709
|
||||
CError_FATAL();
|
||||
CError_FATAL(1709);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1336,8 +1301,7 @@ Type *CParser_GetWCharType(void) {
|
|||
short CParser_GetOperator(ENodeType t) {
|
||||
switch (t) {
|
||||
default:
|
||||
#line 1748
|
||||
CError_FATAL();
|
||||
CError_FATAL(1748);
|
||||
case EMONMIN: return '-';
|
||||
case EBINNOT: return '~';
|
||||
case ELOGNOT: return '!';
|
||||
|
@ -1757,7 +1721,7 @@ Boolean CParserIsVolatileExpr(ENode *expr) {
|
|||
return CParser_IsVolatile(expr->rtype, expr->flags & ENODE_FLAG_QUALS);
|
||||
}
|
||||
|
||||
Boolean CParser_HasInternalLinkage(Object *obj) {
|
||||
Boolean CParser_HasInternalLinkage(const Object *obj) {
|
||||
NameSpace *nspace;
|
||||
|
||||
for (nspace = obj->nspace; nspace; nspace = nspace->parent) {
|
||||
|
@ -1769,24 +1733,26 @@ Boolean CParser_HasInternalLinkage(Object *obj) {
|
|||
return 1;
|
||||
if (obj->qual & (Q_20000 | Q_OVERLOAD))
|
||||
return 0;
|
||||
if (obj->sclass == OBJECT_SCLASS_102)
|
||||
if (obj->sclass == TK_STATIC)
|
||||
return 1;
|
||||
|
||||
// this feels *wrong* but it's the only way to match this function that I can see
|
||||
if (obj->qual & Q_INLINE)
|
||||
obj->qual |= Q_20000;
|
||||
((Object *) obj)->qual |= Q_20000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Boolean CParser_HasInternalLinkage2(Object *obj) {
|
||||
Boolean CParser_HasInternalLinkage2(const Object *obj) {
|
||||
if (obj->datatype == DLOCAL)
|
||||
return 1;
|
||||
if (obj->qual & (Q_20000 | Q_OVERLOAD))
|
||||
return 0;
|
||||
if (obj->sclass == OBJECT_SCLASS_102)
|
||||
if (obj->sclass == TK_STATIC)
|
||||
return 1;
|
||||
|
||||
// this feels *wrong* but it's the only way to match this function that I can see
|
||||
if (obj->qual & Q_INLINE)
|
||||
obj->qual |= Q_20000;
|
||||
((Object *) obj)->qual |= Q_20000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2036,8 +2002,7 @@ void CParser_ParseAttribute(Type *type, DeclInfo *declinfo) {
|
|||
declinfo->qual |= Q_ALIGNED_8192;
|
||||
break;
|
||||
default:
|
||||
#line 2779
|
||||
CError_FATAL();
|
||||
CError_FATAL(2779);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -2638,10 +2603,10 @@ void CParser_GetDeclSpecs(DeclInfo *di, Boolean flag) {
|
|||
SInt32 state;
|
||||
CScopeParseResult pr;
|
||||
|
||||
di->fileoffsetinfo.file = CPrep_BrowserCurrentFile();
|
||||
di->file = CPrep_BrowserCurrentFile();
|
||||
CPrep_BrowserFilePosition(
|
||||
(CPrepFileInfo **) &di->fileoffsetinfo.tokenline,
|
||||
&di->fileoffsetinfo.tokenoffset);
|
||||
(CPrepFileInfo **) &di->file2,
|
||||
&di->x60);
|
||||
|
||||
r24 = 1;
|
||||
r23 = copts.cplusplus;
|
||||
|
@ -2940,8 +2905,7 @@ restart:
|
|||
pr.x8 = TYPE(&stsignedint);
|
||||
break;
|
||||
default:
|
||||
#line 4109
|
||||
CError_FATAL();
|
||||
CError_FATAL(4109);
|
||||
}
|
||||
break;
|
||||
case TEMPLDEP_QUALNAME:
|
||||
|
@ -2954,8 +2918,7 @@ restart:
|
|||
case TEMPLDEP_BITFIELD:
|
||||
break;
|
||||
default:
|
||||
#line 4136
|
||||
CError_FATAL();
|
||||
CError_FATAL(4136);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2980,7 +2943,7 @@ restart:
|
|||
typetoken = -1;
|
||||
tk = lex();
|
||||
if (tk == '<' && copts.objective_c && IS_TYPE_CLASS(di->thetype) && TYPE_CLASS(di->thetype)->objcinfo)
|
||||
di->thetype = CObjC_ParseTypeProtocol(di->thetype);
|
||||
di->thetype = CObjC_ParseTypeProtocol(TYPE_CLASS(di->thetype));
|
||||
goto bailOut;
|
||||
} else if (pr.nsol_14) {
|
||||
if (pr.x1D) {
|
||||
|
@ -3010,8 +2973,7 @@ restart:
|
|||
CError_Error(121);
|
||||
break;
|
||||
default:
|
||||
#line 4217
|
||||
CError_FATAL();
|
||||
CError_FATAL(4217);
|
||||
}
|
||||
} else if (pr.name_4) {
|
||||
if (copts.cplusplus)
|
||||
|
@ -3022,8 +2984,7 @@ restart:
|
|||
tk = lex();
|
||||
r23 = 0;
|
||||
} else {
|
||||
#line 4234
|
||||
CError_FATAL();
|
||||
CError_FATAL(4234);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3216,8 +3177,7 @@ void CParser_CallBackAction(Object *obj) {
|
|||
}
|
||||
}
|
||||
|
||||
#line 4551
|
||||
CError_FATAL();
|
||||
CError_FATAL(4551);
|
||||
}
|
||||
|
||||
static Object *CParser_FindOverloadFunc(NameSpaceObjectList *list, TypeFunc *tfunc) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -7,57 +7,40 @@
|
|||
#include "compiler/CInt64.h"
|
||||
#include "compiler/CMachine.h"
|
||||
#include "compiler/CMangler.h"
|
||||
#include "compiler/COptimizer.h"
|
||||
#include "compiler/CParser.h"
|
||||
#include "compiler/CPrep.h"
|
||||
#include "compiler/CPrepTokenizer.h"
|
||||
#include "compiler/Coloring.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/uDump.h"
|
||||
#include "compiler/Exceptions.h"
|
||||
#include "compiler/InlineAsmPPC.h"
|
||||
#include "compiler/Intrinsics.h"
|
||||
#include "compiler/InstrSelection.h"
|
||||
#include "compiler/GlobalOptimizer.h"
|
||||
#include "compiler/ObjGenMachO.h"
|
||||
#include "compiler/Operands.h"
|
||||
#include "compiler/PCode.h"
|
||||
#include "compiler/PCodeAssembly.h"
|
||||
#include "compiler/PCodeInfo.h"
|
||||
#include "compiler/PCodeListing.h"
|
||||
#include "compiler/PCodeUtilities.h"
|
||||
#include "compiler/Peephole.h"
|
||||
#include "compiler/PPCError.h"
|
||||
#include "compiler/RegisterInfo.h"
|
||||
#include "compiler/Scheduler.h"
|
||||
#include "compiler/StackFrame.h"
|
||||
#include "compiler/Switch.h"
|
||||
#include "compiler/TOC.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/ValueNumbering.h"
|
||||
#include "compiler/enode.h"
|
||||
#include "compiler/objc.h"
|
||||
#include "compiler/objects.h"
|
||||
#include "compiler/scopes.h"
|
||||
#include "compiler/tokens.h"
|
||||
#include "compiler/types.h"
|
||||
|
||||
// TODO: MOVE ME
|
||||
extern void Intrinsics_SetupRuntimeObjects(void);
|
||||
extern void Intrinsics_ReInitRuntimeObjects(Boolean);
|
||||
extern Boolean Intrinsics_IsPublicRuntimeObject(Object *);
|
||||
extern ENode *Intrinsics_HandleIntrinsicCall(Object *func, ENodeList *arg_exprs);
|
||||
extern void PPCError_Error(int, ...);
|
||||
extern void PPCError_Warning(int, ...);
|
||||
extern void PPCError_Message(char *, ...);
|
||||
extern void globallyoptimizepcode(Object *);
|
||||
extern void pclistblocks(char *, char *);
|
||||
extern void pclistblocks_start_scheduler(char *, char *);
|
||||
extern void pclistblocks_end_scheduler();
|
||||
extern void scheduleinstructions(Boolean);
|
||||
extern void peepholemergeblocks(Object *, Boolean);
|
||||
extern void peepholeoptimizeforward(Object *);
|
||||
extern void peepholeoptimizepcode(Object *);
|
||||
extern void colorinstructions(Object *);
|
||||
extern void removecommonsubexpressions(Object *, Boolean);
|
||||
extern int removedcommonsubexpressions;
|
||||
extern SInt32 assemblefunction(Object *, void *);
|
||||
extern void dumpswitchtables(Object *);
|
||||
extern void ObjGen_DeclareInitFunction(Object *);
|
||||
extern void *switchtables;
|
||||
extern void initializeexceptiontables();
|
||||
extern void dumpexceptiontables(Object *, SInt32);
|
||||
extern void switchstatement(ENode *, CLabel *);
|
||||
extern void DumpIR(Statement **, Object *);
|
||||
extern void InlineAsm_TranslateIRtoPCode(Statement *stmt);
|
||||
typedef struct WeirdInlineAsmThing {
|
||||
UInt8 x0, x1, x2;
|
||||
} WeirdInlineAsmThing;
|
||||
extern Statement **COpt_Optimizer(Object *, Statement **);
|
||||
|
||||
static Macro powcM;
|
||||
static Macro __powcM;
|
||||
static Macro ppc_cpu;
|
||||
|
@ -876,7 +859,7 @@ static void callprofiler(char *name) {
|
|||
static void exitprofiler(void) {
|
||||
}
|
||||
|
||||
void CodeGen_Generator(Statement **statements, Object *func, UInt8 mysteryFlag, Boolean callOnModuleBind) {
|
||||
void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, Boolean callOnModuleBind) {
|
||||
Statement *stmt;
|
||||
Boolean has_varargs;
|
||||
PCodeBlock *tmp;
|
||||
|
@ -924,7 +907,7 @@ void CodeGen_Generator(Statement **statements, Object *func, UInt8 mysteryFlag,
|
|||
|
||||
resetTOCvarinfo();
|
||||
init_registers();
|
||||
expandTOCreferences(statements);
|
||||
expandTOCreferences(&statements->next);
|
||||
if (copts.debuglisting)
|
||||
DumpIR(statements, func);
|
||||
|
||||
|
@ -953,10 +936,10 @@ void CodeGen_Generator(Statement **statements, Object *func, UInt8 mysteryFlag,
|
|||
if (copts.profile)
|
||||
callprofiler(CMangler_GetLinkName(func)->name);
|
||||
|
||||
assign_labels(*statements);
|
||||
assign_labels(statements->next);
|
||||
open_temp_registers();
|
||||
|
||||
for (stmt = *statements; stmt; stmt = stmt->next) {
|
||||
for (stmt = statements->next; stmt; stmt = stmt->next) {
|
||||
current_statement = stmt;
|
||||
current_linenumber = stmt->sourceoffset;
|
||||
switch (stmt->type) {
|
||||
|
@ -991,7 +974,7 @@ void CodeGen_Generator(Statement **statements, Object *func, UInt8 mysteryFlag,
|
|||
break;
|
||||
case ST_SWITCH:
|
||||
newstatement(stmt->sourceoffset, stmt->value, (stmt->flags & StmtFlag_10) != 0);
|
||||
switchstatement(stmt->expr, stmt->label);
|
||||
switchstatement(stmt->expr, (SwitchInfo *) stmt->label);
|
||||
break;
|
||||
case ST_BEGINCATCH:
|
||||
capturestackpointer(stmt->expr->data.objref);
|
||||
|
@ -1010,8 +993,7 @@ void CodeGen_Generator(Statement **statements, Object *func, UInt8 mysteryFlag,
|
|||
break;
|
||||
case ST_ASM:
|
||||
if (stmt->expr) {
|
||||
// ... will need to understand inline ASM properly for this ...
|
||||
if (((WeirdInlineAsmThing *) stmt->expr)->x2 & 1) {
|
||||
if (((InlineAsm *) stmt->expr)->flags & IAFlag1) {
|
||||
CError_FATAL(2076);
|
||||
} else {
|
||||
branch_label(makepclabel());
|
||||
|
@ -1911,19 +1893,69 @@ void CodeGen_UpdateBackEndOptions(void) {
|
|||
}
|
||||
|
||||
SInt32 CodeGen_objc_method_self_offset(ObjCMethod *meth) {
|
||||
// TODO objc
|
||||
SInt32 size;
|
||||
|
||||
if (!meth->return_type) {
|
||||
size = 4;
|
||||
} else if (
|
||||
IS_TYPE_ARRAY(meth->return_type) ||
|
||||
IS_TYPE_NONVECTOR_STRUCT(meth->return_type) ||
|
||||
IS_TYPE_CLASS(meth->return_type) ||
|
||||
IS_TYPE_12BYTES_MEMBERPOINTER(meth->return_type)
|
||||
)
|
||||
{
|
||||
size = 8;
|
||||
} else {
|
||||
size = meth->return_type->size;
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
size = 1;
|
||||
|
||||
return (size + 3) & ~3;
|
||||
}
|
||||
|
||||
SInt32 CodeGen_objc_method_sel_offset(ObjCMethod *meth) {
|
||||
// TODO objc
|
||||
return (CodeGen_objc_method_self_offset(meth) + 7) & ~3;
|
||||
}
|
||||
|
||||
SInt32 CodeGen_objc_method_arg_offset(ObjCMethod *meth, ObjCMethodArg *arg) {
|
||||
// TODO objc
|
||||
SInt32 pos;
|
||||
ObjCMethodArg *scan;
|
||||
|
||||
pos = CodeGen_objc_method_sel_offset(meth) + 4;
|
||||
for (scan = meth->selector_args; scan; scan = scan->next) {
|
||||
if (scan == arg)
|
||||
return pos;
|
||||
|
||||
if (scan->type == NULL)
|
||||
pos += 4;
|
||||
else
|
||||
pos += scan->type->size;
|
||||
|
||||
pos = (pos + 3) & ~3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SInt32 CodeGen_objc_method_args_size(ObjCMethod *meth) {
|
||||
// TODO objc
|
||||
SInt32 size;
|
||||
ObjCMethodArg *scan;
|
||||
|
||||
size = CodeGen_objc_method_self_offset(meth);
|
||||
for (scan = meth->selector_args; scan; scan = scan->next) {
|
||||
if (scan->next == NULL && scan->type == NULL)
|
||||
return size;
|
||||
|
||||
size = (size + 3) & ~3;
|
||||
if (scan->type == NULL)
|
||||
size += 4;
|
||||
else
|
||||
size += scan->type->size;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
ENode *CodeGen_HandleIntrinsicCall(Object *func, ENodeList *arg_exprs) {
|
||||
|
@ -1959,11 +1991,16 @@ ENode *CodeGen_HandleTypeCast(ENode *expr, Type *type, UInt32 qual) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
short CodeGen_AssignCheck(ENode *expr, Type *type, Boolean flag1, Boolean flag2) {
|
||||
short CodeGen_AssignCheck(const ENode *expr, const Type *type, Boolean flag1, Boolean flag2) {
|
||||
short result;
|
||||
Type *exprtype = expr->rtype;
|
||||
const Type *exprtype = expr->rtype;
|
||||
|
||||
if (copts.altivec_model && IS_TYPE_VECTOR(type) && IS_TYPE_VECTOR(exprtype) && TYPE_STRUCT(type)->stype == TYPE_STRUCT(exprtype)->stype)
|
||||
if (
|
||||
copts.altivec_model &&
|
||||
IS_TYPE_VECTOR(type) &&
|
||||
IS_TYPE_VECTOR(exprtype) &&
|
||||
TYPE_STRUCT(type)->stype == TYPE_STRUCT(exprtype)->stype
|
||||
)
|
||||
result = CheckResult3;
|
||||
else
|
||||
result = CheckResult0;
|
||||
|
|
|
@ -1,17 +1,120 @@
|
|||
#include "compiler/CodeGenOptPPC.h"
|
||||
#include "compiler/InstrSelection.h"
|
||||
#include "compiler/CCompiler.h"
|
||||
#include "pref_structs.h"
|
||||
#include "compiler/CParser.h"
|
||||
|
||||
static short pref_versions;
|
||||
|
||||
void CodeGen_InitCompiler(void) {
|
||||
init_cgdispatch();
|
||||
}
|
||||
|
||||
void CodeGen_TermCompiler(void) {
|
||||
|
||||
// empty!
|
||||
}
|
||||
|
||||
void CodeGen_InitBackEndOptions(void) {
|
||||
// TODO
|
||||
Handle handle;
|
||||
PBackEnd pb;
|
||||
PMachOLinker pmol;
|
||||
|
||||
CWSecretGetNamedPreferences(cparams.context, "PPC CodeGen Mach-O", &handle);
|
||||
pb = *((PBackEnd *) *handle);
|
||||
pref_versions = pb.version;
|
||||
|
||||
CWSecretGetNamedPreferences(cparams.context, "PPC Mach-O Linker", &handle);
|
||||
pmol = *((PMachOLinker *) *handle);
|
||||
|
||||
copts.code_alignment = 16;
|
||||
copts.misaligned_mem_access = 1;
|
||||
copts.switch_tables = 1;
|
||||
copts.prepare_compress = 0;
|
||||
copts.some_alignment = 4;
|
||||
copts.altivec_model = 0;
|
||||
copts.altivec_vrsave = 1;
|
||||
copts.codegen_pic = pb.pic;
|
||||
copts.codegen_dynamic = pb.dynamic;
|
||||
if (!copts.codegen_dynamic)
|
||||
copts.codegen_pic = 0;
|
||||
copts.no_common = !pb.common;
|
||||
copts.no_implicit_templates = 0;
|
||||
copts.absolutepath = pmol.symfullpath;
|
||||
copts.x06 = pmol.exports;
|
||||
copts.schedule_mode = 2;
|
||||
copts.altivec_model = pb.altivec;
|
||||
copts.readonly_strings = pb.readonlystrings;
|
||||
if (pb.schedule)
|
||||
copts.schedule_mode = 2;
|
||||
else
|
||||
copts.schedule_mode = 0;
|
||||
|
||||
switch (pb.processor) {
|
||||
case 1:
|
||||
copts.cpu = CPU_PPC601;
|
||||
copts.schedule_cpu = 1;
|
||||
break;
|
||||
case 2:
|
||||
copts.cpu = CPU_PPC603;
|
||||
copts.schedule_cpu = 2;
|
||||
break;
|
||||
case 3:
|
||||
copts.cpu = CPU_PPC603e;
|
||||
copts.schedule_cpu = 5;
|
||||
break;
|
||||
case 4:
|
||||
copts.cpu = CPU_PPC604;
|
||||
copts.schedule_cpu = 3;
|
||||
break;
|
||||
case 5:
|
||||
copts.cpu = CPU_PPC604e;
|
||||
copts.schedule_cpu = 6;
|
||||
break;
|
||||
case 6:
|
||||
copts.cpu = CPU_PPC750;
|
||||
copts.schedule_cpu = 4;
|
||||
break;
|
||||
case 7:
|
||||
copts.cpu = CPU_PPC7400;
|
||||
copts.schedule_cpu = 7;
|
||||
break;
|
||||
case 8:
|
||||
copts.cpu = CPU_PPC7450;
|
||||
copts.schedule_cpu = 10;
|
||||
break;
|
||||
default:
|
||||
copts.cpu = CPU_Generic;
|
||||
copts.schedule_cpu = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
copts.peephole = pb.peephole;
|
||||
copts.align_mode = pb.structalignment;
|
||||
copts.profile = pb.profiler;
|
||||
copts.fp_contract = pb.fpcontract;
|
||||
copts.traceback = pb.tracebacktables > 0;
|
||||
copts.x1D = pb.tracebacktables == 2;
|
||||
copts.x1E = 0;
|
||||
if (pb.processorspecific && copts.cpu >= CPU_PPC603)
|
||||
copts.gen_fsel = 10;
|
||||
else
|
||||
copts.gen_fsel = 0;
|
||||
if (pb.vrsave)
|
||||
copts.altivec_vrsave = 1;
|
||||
else
|
||||
copts.altivec_vrsave = 0;
|
||||
copts.ppc_unroll_speculative = 1;
|
||||
copts.ppc_unroll_instructions_limit = 70;
|
||||
copts.ppc_unroll_factor_limit = 10;
|
||||
copts.ppc_opt_bclr_bcctr = 1;
|
||||
copts.use_lmw_stmw = 1;
|
||||
if (copts.optimizationlevel > 2)
|
||||
copts.optimizewithasm = 1;
|
||||
else
|
||||
copts.optimizewithasm = 0;
|
||||
copts.opt_strength_reduction_strict = 1;
|
||||
}
|
||||
|
||||
void Test_Version_Numbers(void) {
|
||||
// empty!
|
||||
}
|
||||
|
|
|
@ -553,7 +553,7 @@ static UInt32 findPC_long(PCode *instr) {
|
|||
return pc;
|
||||
}
|
||||
|
||||
static void initializeexceptiontables(void) {
|
||||
void initializeexceptiontables(void) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < EAT_NACTIONS; i++)
|
||||
|
@ -737,7 +737,7 @@ void recordexceptionactions(PCode *instr, ExceptionAction *actions) {
|
|||
}
|
||||
}
|
||||
|
||||
void deleteexceptionaction(PCAction *pca) {
|
||||
static void deleteexceptionaction(PCAction *pca) {
|
||||
if (pca->prev)
|
||||
pca->prev->next = pca->next;
|
||||
else
|
||||
|
|
|
@ -119,7 +119,7 @@ static void FuncAsm_PreScanDirectives(void) {
|
|||
cprep_eoltokens = 1;
|
||||
|
||||
if (setjmp(InlineAsm_assemblererror) == 0) {
|
||||
while (tk == TK_IDENTIFIER && (directive = InlineAsm_IsDirective(1))) {
|
||||
while (tk == TK_IDENTIFIER && (directive = InlineAsm_IsDirective(AssemblerType_0))) {
|
||||
InlineAsm_ProcessDirective(directive);
|
||||
|
||||
if (tk == ';' || tk == TK_NEG7) {
|
||||
|
|
|
@ -1,33 +1,230 @@
|
|||
#include "compiler/GCCInlineAsm.h"
|
||||
#include "compiler/CError.h"
|
||||
#include "compiler/CExpr.h"
|
||||
#include "compiler/CFunc.h"
|
||||
#include "compiler/CInt64.h"
|
||||
#include "compiler/CParser.h"
|
||||
#include "compiler/CPrep.h"
|
||||
#include "compiler/CPrepTokenizer.h"
|
||||
#include "compiler/InlineAsm.h"
|
||||
#include "compiler/objects.h"
|
||||
|
||||
Statement *first_ST_ASM;
|
||||
IALookupResult gcc_name_list[20];
|
||||
int gcc_name_list_index;
|
||||
|
||||
void InlineAsm_SkipComment() {
|
||||
void InlineAsm_SkipComment(void) {
|
||||
while (1) {
|
||||
if (tk != '/')
|
||||
break;
|
||||
if (lookahead() != '*')
|
||||
break;
|
||||
|
||||
tk = lex();
|
||||
while (!((tk = lex()) == '*' && (tk = lex()) == '/')) {
|
||||
// nothing
|
||||
}
|
||||
tk = lex();
|
||||
}
|
||||
}
|
||||
|
||||
static void gcc_parse_attribute() {
|
||||
static char gcc_parse_attribute(void) {
|
||||
char ch;
|
||||
|
||||
while (tk == TK_NEG7)
|
||||
tk = lex();
|
||||
|
||||
if (tk != '"')
|
||||
CError_Error(CErrorStr105);
|
||||
|
||||
while ((tk = lex()) != TK_IDENTIFIER) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
ch = tkidentifier->name[0];
|
||||
|
||||
if ((tk = lex()) != '"')
|
||||
CError_Error(CErrorStr105);
|
||||
tk = lex();
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
static void gcc_parse_name() {
|
||||
static void gcc_parse_name(Boolean flag, char attribute) {
|
||||
IALookupResult *nameentry;
|
||||
ENode *expr;
|
||||
Object *tempobj;
|
||||
ENode *tempexpr;
|
||||
Statement *stmt;
|
||||
|
||||
while (tk == TK_NEG7)
|
||||
tk = lex();
|
||||
|
||||
if (tk != '(')
|
||||
CError_Error(CErrorStr114);
|
||||
|
||||
tk = lex();
|
||||
|
||||
if (flag) {
|
||||
if (tk != TK_IDENTIFIER)
|
||||
CError_Error(CErrorStr105);
|
||||
|
||||
InlineAsm_LookupSymbol(tkidentifier, &gcc_name_list[++gcc_name_list_index]);
|
||||
if (gcc_name_list[gcc_name_list_index].object && gcc_name_list[gcc_name_list_index].object->u.var.info)
|
||||
gcc_name_list[gcc_name_list_index].object->u.var.info->used = 1;
|
||||
|
||||
tk = lex();
|
||||
} else {
|
||||
in_assembler = 0;
|
||||
cprep_nostring = 0;
|
||||
nameentry = &gcc_name_list[++gcc_name_list_index];
|
||||
|
||||
expr = expression();
|
||||
if (attribute == 'i' || attribute == 'I') {
|
||||
if (!ENODE_IS(expr, EINTCONST))
|
||||
CError_Error(CErrorStr144);
|
||||
nameentry->value = CInt64_GetULong(&expr->data.intval);
|
||||
nameentry->has_value = 1;
|
||||
} else {
|
||||
tempobj = create_temp_object(expr->rtype);
|
||||
tempexpr = create_objectnode(tempobj);
|
||||
if (tempobj->u.var.info)
|
||||
tempobj->u.var.info->used = 1;
|
||||
expr = makediadicnode(tempexpr, expr, EASS);
|
||||
|
||||
stmt = CFunc_InsertBeforeStatement(ST_EXPRESSION, first_ST_ASM);
|
||||
first_ST_ASM = stmt->next;
|
||||
if (!first_ST_ASM->next)
|
||||
curstmt = first_ST_ASM;
|
||||
stmt->expr = expr;
|
||||
|
||||
nameentry->name = tempobj->name;
|
||||
nameentry->object = tempobj;
|
||||
nameentry->label = NULL;
|
||||
nameentry->type = NULL;
|
||||
nameentry->has_value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
cprep_nostring = 1;
|
||||
in_assembler = 1;
|
||||
|
||||
if (tk != ')')
|
||||
CError_Error(CErrorStr115);
|
||||
tk = lex();
|
||||
}
|
||||
|
||||
static void gcc_parse_expression() {
|
||||
static void gcc_parse_expression(Boolean flag) {
|
||||
while (1) {
|
||||
gcc_parse_name(flag, gcc_parse_attribute());
|
||||
if (tk != ',')
|
||||
break;
|
||||
tk = lex();
|
||||
}
|
||||
}
|
||||
|
||||
static void gcc_parse_input() {
|
||||
static void gcc_parse_input(void) {
|
||||
if (tk == ':') {
|
||||
if ((tk = lex()) == ':' || tk == ')' || tk == '}')
|
||||
return;
|
||||
gcc_parse_expression(0);
|
||||
}
|
||||
}
|
||||
|
||||
static void gcc_parse_output() {
|
||||
static void gcc_parse_output(void) {
|
||||
if (tk == ':') {
|
||||
if ((tk = lex()) == ':' || tk == ')' || tk == '}')
|
||||
return;
|
||||
gcc_parse_expression(1);
|
||||
}
|
||||
}
|
||||
|
||||
static void gcc_parse_killed() {
|
||||
static void gcc_parse_killed(void) {
|
||||
if (tk == ':') {
|
||||
while (1) {
|
||||
if ((tk = lex()) != '"')
|
||||
return;
|
||||
|
||||
tk = lex();
|
||||
while (1) {
|
||||
if (tk == '"') {
|
||||
if (lookahead() == ',') {
|
||||
tk = lex();
|
||||
break;
|
||||
}
|
||||
tk = lex();
|
||||
return;
|
||||
}
|
||||
tk = lex();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void gcc_replace_arg_st_asm() {
|
||||
static void gcc_replace_arg_st_asm(Statement *stmt) {
|
||||
InlineAsm *ia;
|
||||
int i;
|
||||
IAOperand *op;
|
||||
short effect;
|
||||
short rclass;
|
||||
SInt32 num;
|
||||
|
||||
if ((ia = (InlineAsm *) stmt->expr)) {
|
||||
for (i = 0, op = ia->args; i < ia->argcount; i++, op++) {
|
||||
switch (op->type) {
|
||||
case IAOpnd_Imm:
|
||||
case IAOpnd_Reg:
|
||||
case IAOpnd_3:
|
||||
case IAOpnd_4:
|
||||
case IAOpnd_Lab:
|
||||
break;
|
||||
|
||||
case IAOpnd_6:
|
||||
if (op->u.unk6.unk4 == 2) {
|
||||
effect = op->u.unk6.effect;
|
||||
rclass = op->u.unk6.rclass;
|
||||
num = op->u.unk6.num;
|
||||
op->type = IAOpnd_Reg;
|
||||
op->u.reg.effect = effect;
|
||||
op->u.reg.rclass = rclass;
|
||||
op->u.reg.object = NULL;
|
||||
if (num <= gcc_name_list_index)
|
||||
op->u.reg.object = gcc_name_list[num].object;
|
||||
else
|
||||
CError_Error(CErrorStr144);
|
||||
op->u.reg.num = 0;
|
||||
} else {
|
||||
CError_FATAL(365);
|
||||
}
|
||||
break;
|
||||
|
||||
case IAOpnd_7:
|
||||
op->type = IAOpnd_Imm;
|
||||
op->u.imm.value = gcc_name_list[op->u.unk7.value].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void gcc_replace_arg() {
|
||||
static void gcc_replace_arg(void) {
|
||||
Statement *stmt;
|
||||
|
||||
for (stmt = first_ST_ASM; stmt; stmt = stmt->next) {
|
||||
if (stmt->type == ST_ASM)
|
||||
gcc_replace_arg_st_asm(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
void InlineAsm_gcc_parse(void) {
|
||||
gcc_name_list_index = -1;
|
||||
cprep_eoltokens = 0;
|
||||
|
||||
if (tk == TK_NEG7)
|
||||
tk = lex();
|
||||
|
||||
gcc_parse_output();
|
||||
gcc_parse_input();
|
||||
gcc_parse_killed();
|
||||
gcc_replace_arg();
|
||||
}
|
||||
|
|
|
@ -591,7 +591,7 @@ Object *InlineAsm_GetObjectOffset(InlineAsm *ia, SInt32 index, SInt32 *offset) {
|
|||
for (i = 0, counter = 0, op = ia->args; i < ia->argcount; i++, op++) {
|
||||
if (op->type == IAOpnd_3) {
|
||||
if (counter++ == index) {
|
||||
*offset = ((SInt32) &op->u.obj.obj) - ((SInt32) ia);
|
||||
*offset = ((intptr_t) &op->u.obj.obj) - ((intptr_t) ia);
|
||||
return op->u.obj.obj;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +1,29 @@
|
|||
#include "compiler/InlineAsmPPC.h"
|
||||
#include "compiler/CError.h"
|
||||
#include "compiler/CExpr.h"
|
||||
#include "compiler/CInt64.h"
|
||||
#include "compiler/CFunc.h"
|
||||
#include "compiler/CMachine.h"
|
||||
#include "compiler/CParser.h"
|
||||
#include "compiler/CPrep.h"
|
||||
#include "compiler/CPrepTokenizer.h"
|
||||
#include "compiler/TOC.h"
|
||||
#include "compiler/Alias.h"
|
||||
#include "compiler/CodeGen.h"
|
||||
#include "compiler/CodeGenOptPPC.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/Exceptions.h"
|
||||
#include "compiler/FuncLevelAsmPPC.h"
|
||||
#include "compiler/InlineAsm.h"
|
||||
#include "compiler/InlineAsmMnemonicsPPC.h"
|
||||
#include "compiler/InlineAsmRegisters.h"
|
||||
#include "compiler/InlineAsmRegistersPPC.h"
|
||||
#include "compiler/CodeGen.h"
|
||||
#include "compiler/CodeGenOptPPC.h"
|
||||
#include "compiler/PPCError.h"
|
||||
#include "compiler/RegisterInfo.h"
|
||||
#include "compiler/objects.h"
|
||||
#include "compiler/CExpr.h"
|
||||
#include "compiler/PCode.h"
|
||||
#include "compiler/PCodeUtilities.h"
|
||||
#include "compiler/PPCError.h"
|
||||
#include "compiler/RegisterInfo.h"
|
||||
#include "compiler/StackFrame.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/Alias.h"
|
||||
|
||||
// TODO: move me
|
||||
extern int countexceptionactionregisters(ExceptionAction *);
|
||||
extern void noteexceptionactionregisters(ExceptionAction *, PCodeArg *);
|
||||
#include "compiler/TOC.h"
|
||||
#include "compiler/objects.h"
|
||||
|
||||
char asm_alloc_flags[10];
|
||||
Section sm_section;
|
||||
|
@ -35,17 +32,12 @@ SInt32 fralloc_parameter_area_size;
|
|||
Boolean user_responsible_for_frame;
|
||||
Boolean supports_hardware_fpu;
|
||||
UInt32 assembledinstructions;
|
||||
UInt8 assembler_type;
|
||||
AssemblerType assembler_type;
|
||||
char volatileasm;
|
||||
Boolean InlineAsm_gccmode;
|
||||
Boolean InlineAsm_labelref;
|
||||
CLabel *pic_base_label;
|
||||
|
||||
enum {
|
||||
NO_REG = 0,
|
||||
INVALID_PIC_REG = -2
|
||||
};
|
||||
|
||||
// forward decls
|
||||
static SInt32 InlineAsm_ConstantExpressionPPC(SInt32 value);
|
||||
static Object *isvariableoperand(void);
|
||||
|
@ -71,8 +63,9 @@ static void IllegalObjectOperator(HashNameNode *name1, HashNameNode *name2, shor
|
|||
case TK_SHR: opstr = ">>"; break;
|
||||
case '<': opstr = "<"; break;
|
||||
case '>': opstr = ">"; break;
|
||||
case TK_LESS_EQUAL: opstr = "<="; break;
|
||||
case TK_GREATER_EQUAL: opstr = ">="; break;
|
||||
// bug? these two seem swapped
|
||||
case TK_LESS_EQUAL: opstr = ">="; break;
|
||||
case TK_GREATER_EQUAL: opstr = "<="; break;
|
||||
case TK_LOGICAL_EQ: opstr = "=="; break;
|
||||
case TK_LOGICAL_NE: opstr = "!="; break;
|
||||
case '&': opstr = "&"; break;
|
||||
|
@ -1478,7 +1471,7 @@ static int mnemonic_has_overflow(char *buf) {
|
|||
return result;
|
||||
}
|
||||
|
||||
static int mnemonic_has_absolute(char *buf) {
|
||||
static int mnemonic_has_absolute(const char *buf) {
|
||||
int result = 0;
|
||||
char last = buf[strlen(buf) - 1];
|
||||
|
||||
|
@ -1488,7 +1481,7 @@ static int mnemonic_has_absolute(char *buf) {
|
|||
return result;
|
||||
}
|
||||
|
||||
static int mnemonic_has_linkregister(char *buf) {
|
||||
static int mnemonic_has_linkregister(const char *buf) {
|
||||
int result = 0;
|
||||
char last = buf[strlen(buf) - 1];
|
||||
|
||||
|
@ -1552,7 +1545,7 @@ void InlineAsm_InitializePPC(void) {
|
|||
cpu |= 0x40000000;
|
||||
}
|
||||
|
||||
void InlineAsm_Initialize(UInt8 assemblertype) {
|
||||
void InlineAsm_Initialize(AssemblerType assemblertype) {
|
||||
assembler_type = assemblertype;
|
||||
|
||||
if (assembler_type == 0) {
|
||||
|
@ -1608,7 +1601,7 @@ static InlineAsm *InlineAsm_CreateFrFree(void) {
|
|||
return ia;
|
||||
}
|
||||
|
||||
SInt32 InlineAsm_IsDirective(UInt8 assemblertype) {
|
||||
SInt32 InlineAsm_IsDirective(AssemblerType assemblertype) {
|
||||
char *name;
|
||||
SInt32 directive = IADirective_Null;
|
||||
|
||||
|
@ -1619,7 +1612,7 @@ SInt32 InlineAsm_IsDirective(UInt8 assemblertype) {
|
|||
name = tkidentifier->name;
|
||||
if (!strcmp(name, "machine")) {
|
||||
directive = IADirective_Machine;
|
||||
} else if (assemblertype == 1) {
|
||||
} else if (assemblertype == AssemblerType_1) {
|
||||
if (!strcmp(name, "entry")) {
|
||||
directive = IADirective_Entry;
|
||||
} else if (!strcmp(name, "fralloc")) {
|
||||
|
@ -1815,6 +1808,7 @@ void InlineAsm_ScanAssemblyInstruction(void) {
|
|||
Boolean flag1;
|
||||
Boolean flag2;
|
||||
SInt32 directive;
|
||||
OpcodeInfo *info;
|
||||
char buf[20];
|
||||
|
||||
flag1 = 0;
|
||||
|
@ -1837,9 +1831,10 @@ void InlineAsm_ScanAssemblyInstruction(void) {
|
|||
if (!mnemonic)
|
||||
CError_Error(CErrorStr261);
|
||||
|
||||
flag3 = (FLAG_SET_F(opcodeinfo[mnemonic->x4].flags) & fPCodeFlag4000000) && (mnemonic->x10 & 0x400);
|
||||
flag4 = (FLAG_SET_T(opcodeinfo[mnemonic->x4].flags) & fPCodeFlag20000000) && (mnemonic->x10 & 2);
|
||||
flag5 = (FLAG_SET_T(opcodeinfo[mnemonic->x4].flags) & fPCodeFlag2000000) && (mnemonic->x10 & 1);
|
||||
info = &opcodeinfo[mnemonic->x4];
|
||||
flag3 = (FLAG_SET_F(info->flags) & fPCodeFlag4000000) && (mnemonic->x10 & 0x400);
|
||||
flag4 = (FLAG_SET_T(info->flags) & fPCodeFlag20000000) && (mnemonic->x10 & 2);
|
||||
flag5 = (FLAG_SET_T(info->flags) & fPCodeFlag2000000) && (mnemonic->x10 & 1);
|
||||
|
||||
if ((cpu == CPUMask_Generic) && (cpu & CPUFLAG_LOW_MASK) != ((cpu & mnemonic->cpu) & CPUFLAG_LOW_MASK)) {
|
||||
CError_Error(CErrorStr152);
|
||||
|
@ -1901,8 +1896,7 @@ void InlineAsm_ScanAssemblyInstruction(void) {
|
|||
++assembledinstructions;
|
||||
}
|
||||
|
||||
static PCode *InlineAsm_TranslateIRtoPCodePPC(InlineAsm *ia, int argcount, UInt8 assemblertype) {
|
||||
OpcodeInfo *info;
|
||||
static PCode *InlineAsm_TranslateIRtoPCodePPC(InlineAsm *ia, int argcount, AssemblerType assemblertype) {
|
||||
PCode *pc;
|
||||
int index;
|
||||
int extra_args;
|
||||
|
@ -1911,6 +1905,7 @@ static PCode *InlineAsm_TranslateIRtoPCodePPC(InlineAsm *ia, int argcount, UInt8
|
|||
SInt32 buffersize;
|
||||
IAOperand *src;
|
||||
PCodeArg *dest;
|
||||
OpcodeInfo *info;
|
||||
|
||||
info = &opcodeinfo[ia->opcode];
|
||||
index = 0;
|
||||
|
@ -2106,7 +2101,7 @@ static PCode *InlineAsm_TranslateIRtoPCodePPC(InlineAsm *ia, int argcount, UInt8
|
|||
dest->kind = PCOp_REGISTER;
|
||||
dest->arg = RegClass_GPR;
|
||||
dest->data.reg.reg = i;
|
||||
dest->data.reg.effect = (short) ((ia->opcode == PC_LMW) ? EffectWrite : EffectRead);
|
||||
dest->data.reg.effect = ((ia->opcode == PC_LMW) ? EffectWrite : EffectRead);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2485,8 +2480,8 @@ void CodeGen_GetAsmEffects(Statement *stmt, IAEffects *effects) {
|
|||
CError_FATAL(4087);
|
||||
}
|
||||
|
||||
CError_ASSERT(4090, effects->numoperands <= 16);
|
||||
CError_ASSERT(4093, effects->numlabels <= 16);
|
||||
CError_ASSERT(4090, (UInt32) effects->numoperands <= IAMaxOperands);
|
||||
CError_ASSERT(4093, (UInt32) effects->numlabels <= IAMaxLabels);
|
||||
}
|
||||
|
||||
for (i = 0, op = ia->args; i < ia->argcount; i++, op++) {
|
||||
|
@ -2526,7 +2521,7 @@ void CodeGen_GetAsmEffects(Statement *stmt, IAEffects *effects) {
|
|||
break;
|
||||
}
|
||||
|
||||
CError_ASSERT(4151, effects->numoperands <= 16);
|
||||
CError_ASSERT(4151, (UInt32) effects->numoperands <= IAMaxOperands);
|
||||
}
|
||||
|
||||
if ((info->flags & (fPCodeFlag1 | fPCodeFlag8)) && (SInt32)effects->numlabels == 0)
|
||||
|
|
|
@ -4,20 +4,20 @@
|
|||
#include "compiler/CMachine.h"
|
||||
#include "compiler/CParser.h"
|
||||
#include "compiler/CodeGen.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/FunctionCalls.h"
|
||||
#include "compiler/Intrinsics.h"
|
||||
#include "compiler/Operands.h"
|
||||
#include "compiler/PCode.h"
|
||||
#include "compiler/PCodeInfo.h"
|
||||
#include "compiler/PCodeUtilities.h"
|
||||
#include "compiler/RegisterInfo.h"
|
||||
#include "compiler/StructMoves.h"
|
||||
#include "compiler/TOC.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/enode.h"
|
||||
#include "compiler/objects.h"
|
||||
#include "compiler/types.h"
|
||||
|
||||
// TODO: move me
|
||||
extern void move_block(Operand *, Operand *, SInt32, SInt32);
|
||||
|
||||
PrecomputedOperand *precomputedoperands;
|
||||
void (*cgdispatch[MAXEXPR + 1])(ENode *, short, short, Operand *);
|
||||
|
||||
|
@ -103,8 +103,7 @@ void gen_DEFINE(ENode *expr, short outputReg, short outputRegHi, Operand *output
|
|||
|
||||
void gen_REUSE(ENode *expr, short outputReg, short outputRegHi, Operand *output) {
|
||||
ENode *inner = expr->data.monadic;
|
||||
#line 250
|
||||
CError_ASSERT(ENODE_IS(inner, EDEFINE));
|
||||
CError_ASSERT(250, ENODE_IS(inner, EDEFINE));
|
||||
gen_DEFINE(inner, outputReg, outputRegHi, output);
|
||||
}
|
||||
|
||||
|
@ -250,8 +249,7 @@ void gen_INDIRECT(ENode *expr, short outputReg, short outputRegHi, Operand *outp
|
|||
output->optype = OpndType_CRField;
|
||||
break;
|
||||
default:
|
||||
#line 456
|
||||
CError_FATAL();
|
||||
CError_FATAL(456);
|
||||
}
|
||||
output->reg = vi->reg;
|
||||
output->object = NULL;
|
||||
|
@ -386,8 +384,7 @@ void gen_FORCELOAD(ENode *expr, short outputReg, short outputRegHi, Operand *out
|
|||
else
|
||||
ENSURE_GPR(output, inner->rtype, outputReg);
|
||||
} else if (!IS_TYPE_VOID(inner->rtype)) {
|
||||
#line 681
|
||||
CError_FATAL();
|
||||
CError_FATAL(681);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1114,8 +1111,7 @@ void gen_ASS(ENode *expr, short outputReg, short outputRegHi, Operand *output) {
|
|||
if (ENODE_IS(left, EINDIRECT)) {
|
||||
left = left->data.monadic;
|
||||
} else {
|
||||
#line 1759
|
||||
CError_FATAL();
|
||||
CError_FATAL(1759);
|
||||
}
|
||||
right = expr->data.cond.expr2;
|
||||
} else {
|
||||
|
@ -1149,8 +1145,7 @@ void gen_ASS(ENode *expr, short outputReg, short outputRegHi, Operand *output) {
|
|||
output->optype = OpndType_VR;
|
||||
break;
|
||||
default:
|
||||
#line 1810
|
||||
CError_FATAL();
|
||||
CError_FATAL(1810);
|
||||
}
|
||||
if (opright.reg != vi->reg) {
|
||||
PCodeArg a, b;
|
||||
|
@ -1382,14 +1377,12 @@ void gen_TYPCON(ENode *expr, short outputReg, short outputRegHi, Operand *output
|
|||
} else if (srctype->size == dsttype->size) {
|
||||
GEN_NODE_TO_REG(inner, outputReg, 0, output);
|
||||
} else {
|
||||
#line 2224
|
||||
CError_FATAL();
|
||||
CError_FATAL(2224);
|
||||
}
|
||||
}
|
||||
|
||||
void gen_BITFIELD(ENode *expr, short outputReg, short outputRegHi, Operand *output) {
|
||||
#line 2238
|
||||
CError_FATAL();
|
||||
CError_FATAL(2238);
|
||||
}
|
||||
|
||||
void gen_INTCONST(ENode *expr, short outputReg, short outputRegHi, Operand *output) {
|
||||
|
@ -1403,13 +1396,11 @@ void gen_INTCONST(ENode *expr, short outputReg, short outputRegHi, Operand *outp
|
|||
}
|
||||
|
||||
void gen_FLOATCONST(ENode *expr, short outputReg, short outputRegHi, Operand *output) {
|
||||
#line 2294
|
||||
CError_FATAL();
|
||||
CError_FATAL(2294);
|
||||
}
|
||||
|
||||
void gen_STRINGCONST(ENode *expr, short outputReg, short outputRegHi, Operand *output) {
|
||||
#line 2308
|
||||
CError_FATAL();
|
||||
CError_FATAL(2308);
|
||||
}
|
||||
|
||||
static Boolean COND_is_ABS_MatchNodes(ENode *cond, ENode *expr1, ENode *expr2) {
|
||||
|
@ -1619,6 +1610,8 @@ void gen_COND(ENode *expr, short outputReg, short outputRegHi, Operand *output)
|
|||
Boolean flag;
|
||||
Operand op;
|
||||
int fneg_reg;
|
||||
int fneg_reg2;
|
||||
int fneg_reg3;
|
||||
int fsel_reg;
|
||||
int final_reg;
|
||||
|
||||
|
@ -1648,8 +1641,7 @@ void gen_COND(ENode *expr, short outputReg, short outputRegHi, Operand *output)
|
|||
right = tmp;
|
||||
break;
|
||||
default:
|
||||
#line 2780
|
||||
CError_FATAL();
|
||||
CError_FATAL(2780);
|
||||
}
|
||||
|
||||
if (ENODE_IS(left, EFLOATCONST) && CMach_FloatIsZero(left->data.floatval)) {
|
||||
|
@ -1680,12 +1672,12 @@ void gen_COND(ENode *expr, short outputReg, short outputRegHi, Operand *output)
|
|||
GEN_NODE_TO_FPR(expr1, &op1, expr1->rtype, 0);
|
||||
GEN_NODE_TO_FPR(expr2, &op2, expr2->rtype, 0);
|
||||
|
||||
fneg_reg = ALLOC_FPR();
|
||||
emitpcode(PC_FNEG, fneg_reg, op.reg);
|
||||
fneg_reg2 = ALLOC_FPR();
|
||||
emitpcode(PC_FNEG, fneg_reg2, op.reg);
|
||||
fsel_reg = ALLOC_FPR();
|
||||
emitpcode(PC_FSEL, fsel_reg, op.reg, op1.reg, op2.reg);
|
||||
final_reg = outputReg ? outputReg : ALLOC_FPR();
|
||||
emitpcode(PC_FSEL, final_reg, fneg_reg, fsel_reg, op2.reg);
|
||||
emitpcode(PC_FSEL, final_reg, fneg_reg2, fsel_reg, op2.reg);
|
||||
}
|
||||
break;
|
||||
case ELESS:
|
||||
|
@ -1695,18 +1687,17 @@ void gen_COND(ENode *expr, short outputReg, short outputRegHi, Operand *output)
|
|||
GEN_NODE_TO_FPR(expr1, &op1, expr1->rtype, 0);
|
||||
GEN_NODE_TO_FPR(expr2, &op2, expr2->rtype, 0);
|
||||
|
||||
fneg_reg = op.reg;
|
||||
fneg_reg3 = op.reg;
|
||||
if (flag) {
|
||||
fneg_reg = ALLOC_FPR();
|
||||
emitpcode(PC_FNEG, fneg_reg, op.reg);
|
||||
fneg_reg3 = ALLOC_FPR();
|
||||
emitpcode(PC_FNEG, fneg_reg3, op.reg);
|
||||
}
|
||||
|
||||
final_reg = outputReg ? outputReg : ALLOC_FPR();
|
||||
emitpcode(PC_FSEL, final_reg, fneg_reg, op1.reg, op2.reg);
|
||||
emitpcode(PC_FSEL, final_reg, fneg_reg3, op1.reg, op2.reg);
|
||||
break;
|
||||
default:
|
||||
#line 2862
|
||||
CError_FATAL();
|
||||
CError_FATAL(2862);
|
||||
}
|
||||
|
||||
output->optype = OpndType_FPR;
|
||||
|
@ -1814,8 +1805,7 @@ void gen_COND(ENode *expr, short outputReg, short outputRegHi, Operand *output)
|
|||
ENSURE_GPR(&op1, expr1->rtype, 0);
|
||||
emitpcode(PC_AND, reg1, op1.reg, isel_op1.reg);
|
||||
} else {
|
||||
#line 3119
|
||||
CError_FATAL();
|
||||
CError_FATAL(3119);
|
||||
}
|
||||
|
||||
output->optype = OpndType_GPR;
|
||||
|
@ -1851,8 +1841,7 @@ void gen_COND(ENode *expr, short outputReg, short outputRegHi, Operand *output)
|
|||
return;
|
||||
|
||||
default:
|
||||
#line 3168
|
||||
CError_FATAL();
|
||||
CError_FATAL(3168);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2157,9 +2146,8 @@ void gen_CONDASS(ENode *expr, short outputReg, short outputRegHi, Operand *outpu
|
|||
flag = 0;
|
||||
memclrw(&op, sizeof(Operand));
|
||||
|
||||
#line 3704
|
||||
CError_ASSERT(ENODE_IS(expr1, EINDIRECT));
|
||||
CError_ASSERT(ENODE_IS(expr1->data.monadic, EOBJREF));
|
||||
CError_ASSERT(3704, ENODE_IS(expr1, EINDIRECT));
|
||||
CError_ASSERT(3705, ENODE_IS(expr1->data.monadic, EOBJREF));
|
||||
|
||||
tmpreg = OBJECT_REG(expr1->data.monadic->data.objref);
|
||||
final_reg = outputReg ? tmpreg : ALLOC_FPR();
|
||||
|
@ -2187,8 +2175,7 @@ void gen_CONDASS(ENode *expr, short outputReg, short outputRegHi, Operand *outpu
|
|||
flag2 = 0;
|
||||
break;
|
||||
default:
|
||||
#line 3744
|
||||
CError_FATAL();
|
||||
CError_FATAL(3744);
|
||||
}
|
||||
|
||||
if (ENODE_IS(left, EFLOATCONST) && CMach_FloatIsZero(left->data.floatval)) {
|
||||
|
@ -2251,8 +2238,7 @@ void gen_CONDASS(ENode *expr, short outputReg, short outputRegHi, Operand *outpu
|
|||
emitpcode(PC_FSEL, final_reg, fneg_reg, op2.reg, op1.reg);
|
||||
break;
|
||||
default:
|
||||
#line 2862
|
||||
CError_FATAL();
|
||||
CError_FATAL(2862);
|
||||
}
|
||||
|
||||
if (op3.optype != OpndType_FPR)
|
||||
|
@ -2270,10 +2256,8 @@ void gen_CONDASS(ENode *expr, short outputReg, short outputRegHi, Operand *outpu
|
|||
ENode *abs_expr;
|
||||
|
||||
memclrw(&isel_op, sizeof(Operand));
|
||||
#line 3966
|
||||
CError_ASSERT(ENODE_IS(expr1, EINDIRECT));
|
||||
#line 3968
|
||||
CError_ASSERT(ENODE_IS(expr1->data.monadic, EOBJREF));
|
||||
CError_ASSERT(3966, ENODE_IS(expr1, EINDIRECT));
|
||||
CError_ASSERT(3968, ENODE_IS(expr1->data.monadic, EOBJREF));
|
||||
|
||||
if (CONDASS_is_ABS(cond, expr1, expr2)) {
|
||||
if (ENODE_IS(cond->data.diadic.left, EASS))
|
||||
|
@ -2282,14 +2266,12 @@ void gen_CONDASS(ENode *expr, short outputReg, short outputRegHi, Operand *outpu
|
|||
GEN_NODE(cond->data.diadic.right, &isel_op);
|
||||
|
||||
outputReg = OBJECT_REG(expr1->data.monadic->data.objref);
|
||||
#line 3979
|
||||
CError_ASSERT(outputReg);
|
||||
CError_ASSERT(3979, outputReg);
|
||||
|
||||
GEN_NODE(expr1, &op1);
|
||||
op3 = op1;
|
||||
|
||||
#line 3986
|
||||
CError_ASSERT(op3.optype == OpndType_GPR && op3.reg == outputReg);
|
||||
CError_ASSERT(3986, op3.optype == OpndType_GPR && op3.reg == outputReg);
|
||||
|
||||
ENSURE_GPR(&op1, expr1->rtype, 0);
|
||||
if (expr1->rtype->size < 4)
|
||||
|
@ -2317,6 +2299,10 @@ void gen_CONDASS(ENode *expr, short outputReg, short outputRegHi, Operand *outpu
|
|||
}
|
||||
|
||||
void gen_FUNCCALL(ENode *expr, short outputReg, short outputRegHi, Operand *output) {
|
||||
if (is_intrinsic_function_call(expr))
|
||||
call_intrinsic_function(expr, outputReg, output);
|
||||
else
|
||||
call_function(expr, output);
|
||||
}
|
||||
|
||||
void gen_OBJREF(ENode *expr, short outputReg, short outputRegHi, Operand *output) {
|
||||
|
@ -2324,8 +2310,7 @@ void gen_OBJREF(ENode *expr, short outputReg, short outputRegHi, Operand *output
|
|||
}
|
||||
|
||||
void gen_UNEXPECTED(ENode *expr, short outputReg, short outputRegHi, Operand *output) {
|
||||
#line 4160
|
||||
CError_FATAL();
|
||||
CError_FATAL(4160);
|
||||
}
|
||||
|
||||
static int small(ENode *expr) {
|
||||
|
@ -2658,8 +2643,7 @@ void gen_LOGICAL(ENode *expr, short outputReg, short outputRegHi, Operand *outpu
|
|||
|
||||
tmpreg1 = ALLOC_GPR();
|
||||
tmpreg2 = ALLOC_GPR();
|
||||
#line 4853
|
||||
CError_ASSERT(output->optype == OpndType_GPR);
|
||||
CError_ASSERT(4853, output->optype == OpndType_GPR);
|
||||
|
||||
emitpcode(PC_CNTLZW, tmpreg2, output->reg);
|
||||
emitpcode(PC_RLWINM, tmpreg1, tmpreg2, 27, 5, 31);
|
||||
|
@ -2685,8 +2669,7 @@ void gen_LOGICAL(ENode *expr, short outputReg, short outputRegHi, Operand *outpu
|
|||
|
||||
tmpreg1 = ALLOC_GPR();
|
||||
tmpreg2 = ALLOC_GPR();
|
||||
#line 4883
|
||||
CError_ASSERT(output->optype == OpndType_GPR);
|
||||
CError_ASSERT(4883, output->optype == OpndType_GPR);
|
||||
|
||||
emitpcode(PC_CNTLZW, tmpreg2, output->reg);
|
||||
emitpcode(PC_RLWINM, tmpreg1, tmpreg2, 27, 5, 31);
|
||||
|
@ -2810,8 +2793,7 @@ void logical_expression(ENode *cond, PCodeLabel *if_true, PCodeLabel *if_false,
|
|||
branch_conditional(op.reg, op.regOffset, 1, if_true);
|
||||
break;
|
||||
default:
|
||||
#line 5160
|
||||
CError_FATAL();
|
||||
CError_FATAL(5160);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2829,8 +2811,7 @@ static void logical_expression_nobranch(ENode *cond, Boolean invert, Operand *ou
|
|||
case ENOTEQU:
|
||||
if (invert) {
|
||||
ENodeType nt = invert_relop(cond->type);
|
||||
#line 5190
|
||||
CError_ASSERT(nt != cond->type);
|
||||
CError_ASSERT(5190, nt != cond->type);
|
||||
cond->type = nt;
|
||||
}
|
||||
|
||||
|
@ -2841,8 +2822,7 @@ static void logical_expression_nobranch(ENode *cond, Boolean invert, Operand *ou
|
|||
|
||||
break;
|
||||
default:
|
||||
#line 5206
|
||||
CError_FATAL();
|
||||
CError_FATAL(5206);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2999,8 +2979,7 @@ void gen_condition_gpr(ENode *cond, Operand *output, short outputReg) {
|
|||
pc->args[1].data.reg.reg,
|
||||
(r6 + r7 + 1) & 31, 31, 31);
|
||||
} else {
|
||||
#line 5434
|
||||
CError_FATAL();
|
||||
CError_FATAL(5434);
|
||||
}
|
||||
output->optype = OpndType_GPR;
|
||||
output->reg = reg;
|
||||
|
@ -3061,8 +3040,7 @@ void gen_condition_gpr(ENode *cond, Operand *output, short outputReg) {
|
|||
(r6 + r7 + 1) & 31, 31, 31);
|
||||
emitpcode(PC_XORI, reg, tmpreg, 1);
|
||||
} else {
|
||||
#line 5503
|
||||
CError_FATAL();
|
||||
CError_FATAL(5503);
|
||||
}
|
||||
output->optype = OpndType_GPR;
|
||||
output->reg = reg;
|
||||
|
@ -3265,8 +3243,7 @@ void gen_condition_gpr(ENode *cond, Operand *output, short outputReg) {
|
|||
}
|
||||
|
||||
default:
|
||||
#line 5777
|
||||
CError_FATAL();
|
||||
CError_FATAL(5777);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3589,8 +3566,7 @@ void I8_gen_ADD(ENode *expr, short outputReg, short outputRegHi, Operand *output
|
|||
case 1 + 8:
|
||||
case 2 + 8:
|
||||
case 4 + 8:
|
||||
#line 6933
|
||||
CError_ASSERT(skipleft == 8);
|
||||
CError_ASSERT(6933, skipleft == 8);
|
||||
if (!is_uns) {
|
||||
tmpreg2 = ALLOC_GPR();
|
||||
emitpcode(PC_SRAWI, tmpreg2, opright.reg, 31);
|
||||
|
@ -3612,8 +3588,7 @@ void I8_gen_ADD(ENode *expr, short outputReg, short outputRegHi, Operand *output
|
|||
emitpcode(PC_ADDE, regHi, opleft.regHi, opright.regHi);
|
||||
break;
|
||||
default:
|
||||
#line 6979
|
||||
CError_FATAL();
|
||||
CError_FATAL(6979);
|
||||
}
|
||||
|
||||
output->optype = OpndType_GPRPair;
|
||||
|
@ -3745,8 +3720,7 @@ void I8_gen_SUB(ENode *expr, short outputReg, short outputRegHi, Operand *output
|
|||
emitpcode(PC_SUBFE, regHi, opright.regHi, opleft.regHi);
|
||||
break;
|
||||
default:
|
||||
#line 7211
|
||||
CError_FATAL();
|
||||
CError_FATAL(7211);
|
||||
}
|
||||
|
||||
output->optype = OpndType_GPRPair;
|
||||
|
@ -3840,10 +3814,8 @@ int I8_log2n(UInt64 val) {
|
|||
}
|
||||
|
||||
void I8_ShiftLeftImmediate(Operand opnd, SInt32 value, int is_unsigned, SInt32 size, short reg, short regHi) {
|
||||
if (opnd.reg == reg || opnd.regHi == regHi || opnd.reg == regHi || opnd.regHi == reg) {
|
||||
#line 7703
|
||||
CError_FATAL();
|
||||
}
|
||||
if (opnd.reg == reg || opnd.regHi == regHi || opnd.reg == regHi || opnd.regHi == reg)
|
||||
CError_FATAL(7703);
|
||||
|
||||
if (value < 32) {
|
||||
emitpcode(PC_RLWINM, reg, opnd.reg, value, 0, 31 - value);
|
||||
|
@ -3860,8 +3832,7 @@ void I8_ShiftLeftImmediate(Operand opnd, SInt32 value, int is_unsigned, SInt32 s
|
|||
emitpcode(PC_RLWINM, regHi, opnd.reg, value - 32, 0, 63 - value);
|
||||
emitpcode(PC_LI, reg, 0);
|
||||
} else {
|
||||
#line 7732
|
||||
CError_FATAL();
|
||||
CError_FATAL(7732);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3871,10 +3842,8 @@ void I8_ShiftRightImmediate(Operand opnd, SInt32 value, int is_unsigned, short r
|
|||
short tmpreg3;
|
||||
short tmpreg4;
|
||||
|
||||
if (opnd.reg == reg || opnd.regHi == regHi || opnd.reg == regHi || opnd.regHi == reg) {
|
||||
#line 7756
|
||||
CError_FATAL();
|
||||
}
|
||||
if (opnd.reg == reg || opnd.regHi == regHi || opnd.reg == regHi || opnd.regHi == reg)
|
||||
CError_FATAL(7756);
|
||||
|
||||
if (value < 32) {
|
||||
emitpcode(PC_RLWINM, reg, opnd.reg, 32 - value, 0, 31);
|
||||
|
@ -3927,8 +3896,7 @@ void I8_ShiftRightImmediate(Operand opnd, SInt32 value, int is_unsigned, short r
|
|||
emitpcode(PC_SRAWI, regHi, opnd.regHi, 31);
|
||||
}
|
||||
} else {
|
||||
#line 7866
|
||||
CError_FATAL();
|
||||
CError_FATAL(7866);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3957,10 +3925,8 @@ void I8_gen_MUL(ENode *expr, short outputReg, short outputRegHi, Operand *output
|
|||
skipleft = GetSizeSkip(left);
|
||||
skipright = GetSizeSkip(right);
|
||||
|
||||
if (ENODE_IS(right, EINTCONST) && ENODE_IS(left, EINTCONST)) {
|
||||
#line 7900
|
||||
CError_FATAL();
|
||||
}
|
||||
if (ENODE_IS(right, EINTCONST) && ENODE_IS(left, EINTCONST))
|
||||
CError_FATAL(7900);
|
||||
|
||||
if (ENODE_IS(left, EINTCONST))
|
||||
leftval = left->data.intval.lo + (((SInt64) ((skipleft < 8) ? 0 : left->data.intval.hi)) << 32);
|
||||
|
@ -4066,8 +4032,7 @@ void I8_gen_MUL(ENode *expr, short outputReg, short outputRegHi, Operand *output
|
|||
case 1 + 8:
|
||||
case 2 + 8:
|
||||
case 4 + 8:
|
||||
#line 8097
|
||||
CError_ASSERT(skipleft == 8);
|
||||
CError_ASSERT(8097, skipleft == 8);
|
||||
if (ENODE_IS(left, EINTCONST) && FITS_IN_SHORT2(left->data.intval.lo) && left->data.intval.hi == 0) {
|
||||
emitpcode(PC_MULLI, reg, opright.reg, LOW_PART(left->data.intval.lo));
|
||||
if (is_uns)
|
||||
|
@ -4143,8 +4108,7 @@ void I8_gen_MUL(ENode *expr, short outputReg, short outputRegHi, Operand *output
|
|||
}
|
||||
break;
|
||||
default:
|
||||
#line 8218
|
||||
CError_FATAL();
|
||||
CError_FATAL(8218);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4206,12 +4170,10 @@ void I8_gen_ASS(ENode *expr, short outputReg, short outputRegHi, Operand *output
|
|||
type = expr->rtype;
|
||||
if (ENODE_IS(expr, ECONDASS)) {
|
||||
left = expr->data.cond.expr1;
|
||||
if (ENODE_IS(left, EINDIRECT)) {
|
||||
if (ENODE_IS(left, EINDIRECT))
|
||||
left = left->data.monadic;
|
||||
} else {
|
||||
#line 8328
|
||||
CError_FATAL();
|
||||
}
|
||||
else
|
||||
CError_FATAL(8238);
|
||||
right = expr->data.cond.expr2;
|
||||
} else {
|
||||
left = expr->data.diadic.left;
|
||||
|
@ -4225,8 +4187,7 @@ void I8_gen_ASS(ENode *expr, short outputReg, short outputRegHi, Operand *output
|
|||
vi = Registers_GetVarInfo(left->data.objref);
|
||||
GEN_NODE_TO_REG(right, vi->reg, vi->regHi, &opright);
|
||||
if (vi->rclass != RegClass_GPR) {
|
||||
#line 8348
|
||||
CError_FATAL();
|
||||
CError_FATAL(8348);
|
||||
} else {
|
||||
coerce_to_register_pair(&opright, type, vi->reg, vi->regHi);
|
||||
*output = opright;
|
||||
|
@ -4239,8 +4200,7 @@ void I8_gen_ASS(ENode *expr, short outputReg, short outputRegHi, Operand *output
|
|||
coerce_to_register_pair(&opright, right->rtype, 0, 0);
|
||||
|
||||
if (ENODE_IS(left, EBITFIELD)) {
|
||||
#line 8376
|
||||
CError_FATAL();
|
||||
CError_FATAL(8376);
|
||||
} else {
|
||||
GEN_NODE(left, &opleft);
|
||||
indirect(&opleft, left);
|
||||
|
@ -4286,8 +4246,7 @@ void I8_gen_POSTINCDEC(ENode *expr, short outputReg, short outputRegHi, Operand
|
|||
return;
|
||||
}
|
||||
|
||||
#line 8446
|
||||
CError_ASSERT(!ENODE_IS(inner, EBITFIELD));
|
||||
CError_ASSERT(8446, !ENODE_IS(inner, EBITFIELD));
|
||||
|
||||
GEN_NODE(inner, &op1);
|
||||
indirect(&op1, inner);
|
||||
|
@ -4329,8 +4288,7 @@ void I8_gen_INDIRECT(ENode *expr, short outputReg, short outputRegHi, Operand *o
|
|||
output->optype = OpndType_FPR;
|
||||
break;
|
||||
default:
|
||||
#line 8511
|
||||
CError_FATAL();
|
||||
CError_FATAL(8511);
|
||||
}
|
||||
|
||||
output->reg = vi->reg;
|
||||
|
@ -4340,8 +4298,7 @@ void I8_gen_INDIRECT(ENode *expr, short outputReg, short outputRegHi, Operand *o
|
|||
}
|
||||
|
||||
if (ENODE_IS(inner, EBITFIELD)) {
|
||||
#line 8529
|
||||
CError_FATAL();
|
||||
CError_FATAL(8529);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4430,8 +4387,7 @@ void I8_gen_condition(ENode *cond, Operand *output, int write_to_gpr) {
|
|||
}
|
||||
}
|
||||
|
||||
#line 8704
|
||||
CError_ASSERT(opleft.optype == OpndType_GPRPair && opright.optype == OpndType_GPRPair);
|
||||
CError_ASSERT(8704, opleft.optype == OpndType_GPRPair && opright.optype == OpndType_GPRPair);
|
||||
|
||||
switch (cond->type) {
|
||||
case EEQU:
|
||||
|
@ -4525,8 +4481,7 @@ void I8_gen_condition(ENode *cond, Operand *output, int write_to_gpr) {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
#line 8814
|
||||
CError_FATAL();
|
||||
CError_FATAL(8814);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4569,8 +4524,7 @@ void I8_gen_SHL_SHR(ENode *expr, short outputReg, short outputRegHi, Operand *ou
|
|||
opright.optype = OpndType_GPR;
|
||||
}
|
||||
|
||||
#line 8890
|
||||
CError_ASSERT(opleft.optype == OpndType_GPRPair && opright.optype == OpndType_GPR);
|
||||
CError_ASSERT(8890, opleft.optype == OpndType_GPRPair && opright.optype == OpndType_GPR);
|
||||
|
||||
if (opleft.regHi != high_reg)
|
||||
emitpcode(PC_MR, high_reg, opleft.regHi);
|
||||
|
@ -4587,8 +4541,7 @@ void I8_gen_SHL_SHR(ENode *expr, short outputReg, short outputRegHi, Operand *ou
|
|||
} else if (ENODE_IS(expr, ESHL)) {
|
||||
branch_subroutine(rt_shl2i, 0, used_regs);
|
||||
} else {
|
||||
#line 8909
|
||||
CError_FATAL();
|
||||
CError_FATAL(8909);
|
||||
}
|
||||
|
||||
emitpcode(PC_MR, output->reg, low_reg);
|
||||
|
@ -4623,8 +4576,7 @@ void I8_gen_DIV_MOD(ENode *expr, short outputReg, short outputRegHi, Operand *ou
|
|||
if (ENODE_IS(right, EINTCONST))
|
||||
constval = (((SInt64) right->data.intval.hi) << 32) + right->data.intval.lo;
|
||||
if (ENODE_IS(right, EINTCONST) && ((shift = I8_log2n(constval)) > 0)) {
|
||||
#line 8976
|
||||
CError_ASSERT(opleft.optype == OpndType_GPRPair);
|
||||
CError_ASSERT(8976, opleft.optype == OpndType_GPRPair);
|
||||
if (ENODE_IS(expr, EDIV)) {
|
||||
I8_ShiftRightImmediate(opleft, shift, is_uns, output->reg, output->regHi, 1);
|
||||
if (!is_uns) {
|
||||
|
@ -4643,8 +4595,7 @@ void I8_gen_DIV_MOD(ENode *expr, short outputReg, short outputRegHi, Operand *ou
|
|||
emitpcode(PC_RLWINM, output->regHi, opleft.regHi, 0, 32 - (shift - 32), 31);
|
||||
emitpcode(PC_MR, output->reg, opleft.reg);
|
||||
} else {
|
||||
#line 9018
|
||||
CError_FATAL();
|
||||
CError_FATAL(9018);
|
||||
}
|
||||
} else {
|
||||
short tmpreg1 = ALLOC_GPR();
|
||||
|
@ -4663,8 +4614,7 @@ void I8_gen_DIV_MOD(ENode *expr, short outputReg, short outputRegHi, Operand *ou
|
|||
GEN_NODE(right, &opright);
|
||||
coerce_to_register_pair(&opright, right->rtype, 0, 0);
|
||||
|
||||
#line 9048
|
||||
CError_ASSERT(opleft.optype == OpndType_GPRPair && opright.optype == OpndType_GPRPair);
|
||||
CError_ASSERT(9048, opleft.optype == OpndType_GPRPair && opright.optype == OpndType_GPRPair);
|
||||
|
||||
if (opleft.regHi != high_reg)
|
||||
emitpcode(PC_MR, high_reg, opleft.regHi);
|
||||
|
@ -4686,8 +4636,7 @@ void I8_gen_DIV_MOD(ENode *expr, short outputReg, short outputRegHi, Operand *ou
|
|||
else
|
||||
branch_subroutine(rt_mod2i, 0, used_regs);
|
||||
} else {
|
||||
#line 9074
|
||||
CError_FATAL();
|
||||
CError_FATAL(9074);
|
||||
}
|
||||
|
||||
emitpcode(PC_MR, output->reg, low_reg);
|
||||
|
@ -4745,8 +4694,7 @@ void I8_gen_TYPCON(ENode *expr, short outputReg, short outputRegHi, Operand *out
|
|||
}
|
||||
|
||||
if (srctype->size < dsttype->size) {
|
||||
#line 9171
|
||||
CError_ASSERT(TYPE_IS_8BYTES(dsttype));
|
||||
CError_ASSERT(9171, TYPE_IS_8BYTES(dsttype));
|
||||
|
||||
GEN_NODE(inner, output);
|
||||
if (srctype->size < 4 &&
|
||||
|
@ -4769,8 +4717,7 @@ void I8_gen_TYPCON(ENode *expr, short outputReg, short outputRegHi, Operand *out
|
|||
|
||||
if (IS_TYPE_POINTER(srctype)) {
|
||||
GEN_NODE_TO_REG(inner, outputReg, 0, output);
|
||||
#line 9200
|
||||
CError_ASSERT(TYPE_IS_8BYTES(expr->rtype));
|
||||
CError_ASSERT(9200, TYPE_IS_8BYTES(expr->rtype));
|
||||
GEN_NODE_TO_REG(inner, outputReg, 0, output);
|
||||
|
||||
regHi = outputRegHi ? outputRegHi : ALLOC_GPR();
|
||||
|
@ -4790,8 +4737,7 @@ void I8_gen_TYPCON(ENode *expr, short outputReg, short outputRegHi, Operand *out
|
|||
|
||||
if (IS_TYPE_FLOAT(srctype)) {
|
||||
if (IS_TYPE_FLOAT(dsttype)) {
|
||||
#line 9222
|
||||
CError_FATAL();
|
||||
CError_FATAL(9222);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4816,14 +4762,12 @@ void I8_gen_TYPCON(ENode *expr, short outputReg, short outputRegHi, Operand *out
|
|||
if (TYPE_IS_8BYTES(expr->rtype) && dsttype->size == srctype->size) {
|
||||
coerce_to_register_pair(output, srctype, outputReg, outputRegHi);
|
||||
} else {
|
||||
#line 9256
|
||||
CError_FATAL();
|
||||
CError_FATAL(9256);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#line 9261
|
||||
CError_FATAL();
|
||||
CError_FATAL(9261);
|
||||
}
|
||||
|
||||
void gen_VECTOR128CONST(ENode *expr, short outputReg, short outputRegHi, Operand *output) {
|
||||
|
@ -4832,10 +4776,8 @@ void gen_VECTOR128CONST(ENode *expr, short outputReg, short outputRegHi, Operand
|
|||
COVCResult result;
|
||||
|
||||
vr = outputReg ? outputReg : ALLOC_VR();
|
||||
if (!canoptimizevectorconst(&expr->data.vector128val, expr->rtype, &result)) {
|
||||
#line 9282
|
||||
CError_FATAL();
|
||||
}
|
||||
if (!canoptimizevectorconst(&expr->data.vector128val, expr->rtype, &result))
|
||||
CError_FATAL(9282);
|
||||
|
||||
if (result.op1 != -1) {
|
||||
emitpcode(result.op1, vr, result.arg);
|
||||
|
@ -4853,6 +4795,5 @@ void gen_VECTOR128CONST(ENode *expr, short outputReg, short outputRegHi, Operand
|
|||
return;
|
||||
}
|
||||
|
||||
#line 9298
|
||||
CError_FATAL();
|
||||
CError_FATAL(9298);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,26 @@
|
|||
#include "compiler/IrOptimizer.h"
|
||||
#include "compiler/CError.h"
|
||||
#include "compiler/CParser.h"
|
||||
#include "compiler/InlineAsmPPC.h"
|
||||
#include "compiler/IroCSE.h"
|
||||
#include "compiler/IroDump.h"
|
||||
#include "compiler/IroEval.h"
|
||||
#include "compiler/IroFlowgraph.h"
|
||||
#include "compiler/IroLinearForm.h"
|
||||
#include "compiler/IroSubable.h"
|
||||
#include "compiler/IroTransform.h"
|
||||
#include "compiler/IROUseDef.h"
|
||||
#include "compiler/IroUtil.h"
|
||||
#include "compiler/IroVars.h"
|
||||
#include "compiler/objects.h"
|
||||
#include "compiler/IroPropagate.h"
|
||||
#include "compiler/IroPointerAnalysis.h"
|
||||
#include "compiler/IroJump.h"
|
||||
#include "compiler/IroRangePropagation.h"
|
||||
#include "compiler/IroEmptyLoop.h"
|
||||
#include "compiler/IroUnrollLoop.h"
|
||||
#include "compiler/IroLoop.h"
|
||||
#include "compiler/IroExprRegeneration.h"
|
||||
|
||||
Boolean DoScalarize;
|
||||
Boolean DoLinearize;
|
||||
|
@ -9,37 +30,367 @@ Boolean VectorPhaseCalledFromUnroll;
|
|||
Boolean IRO_Log;
|
||||
static Boolean stIsSetup;
|
||||
|
||||
static void CountRefToObject() {
|
||||
static void CountRefToObject(Object *object, int depth) {
|
||||
static unsigned short LoopUsage[] = {1, 4, 16, 64};
|
||||
|
||||
if (depth > 3)
|
||||
depth = 3;
|
||||
|
||||
object->u.var.info->usage += LoopUsage[depth];
|
||||
object->u.var.info->used = 1;
|
||||
}
|
||||
|
||||
static void CountARef() {
|
||||
static void CountARef(IROLinear *node, int depth) {
|
||||
Object *object;
|
||||
|
||||
object = node->u.node->data.objref;
|
||||
CError_ASSERT(78, object->datatype != DALIAS);
|
||||
|
||||
if (object->datatype == DLOCAL && object->u.var.info) {
|
||||
CountRefToObject(object, depth);
|
||||
if ((node->flags & IROLF_Used) && (node->flags & IROLF_Assigned))
|
||||
CountRefToObject(object, depth);
|
||||
|
||||
if (!(node->flags & IROLF_Immind) && !object->u.var.info->noregister)
|
||||
object->u.var.info->noregister = 2;
|
||||
}
|
||||
}
|
||||
|
||||
static void CountDoubleInd() {
|
||||
static void CountDoubleInd(IROLinear *node, int depth) {
|
||||
if (IRO_IsVariable(node)) {
|
||||
CountARef(node->u.monadic, depth);
|
||||
} else if (node->type == IROLinearOp2Arg) {
|
||||
if (node->nodetype == EADD) {
|
||||
CountDoubleInd(node->u.diadic.left, depth);
|
||||
CountDoubleInd(node->u.diadic.right, depth);
|
||||
} else if (IRO_IsAddressMultiply(node)) {
|
||||
if (IRO_IsVariable(node->u.diadic.left))
|
||||
CountARef(node->u.diadic.left->u.monadic, depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void CountUsage() {
|
||||
static void CountUsage(void) {
|
||||
IRONode *fnode = IRO_FirstNode;
|
||||
IROLinear *node;
|
||||
|
||||
if (IRO_FirstNode) {
|
||||
for (; fnode; fnode = fnode->nextnode) {
|
||||
for (node = fnode->first; node; node = node->next) {
|
||||
if (IS_LINEAR_ENODE(node, EOBJREF))
|
||||
CountARef(node, fnode->loopdepth);
|
||||
else if (IS_LINEAR_MONADIC(node, EINDIRECT))
|
||||
CountDoubleInd(node->u.monadic, fnode->loopdepth);
|
||||
|
||||
if (node->type == IROLinearAsm) {
|
||||
IAEffects effects;
|
||||
int i;
|
||||
|
||||
CodeGen_GetAsmEffects(node->u.asm_stmt, &effects);
|
||||
for (i = 0; i < effects.numoperands; i++) {
|
||||
Object *object = effects.operands[i].object;
|
||||
if (object->datatype == DLOCAL && object->u.var.info) {
|
||||
CountRefToObject(object, fnode->loopdepth);
|
||||
if (effects.operands[i].type == IAOpnd_3 && !object->u.var.info->noregister)
|
||||
object->u.var.info->noregister = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (node == fnode->last)
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (node = IRO_FirstLinear; node; node = node->next) {
|
||||
if (IS_LINEAR_ENODE(node, EOBJREF))
|
||||
CountARef(node, 0);
|
||||
else if (IS_LINEAR_MONADIC(node, EINDIRECT))
|
||||
CountDoubleInd(node->u.monadic, 0);
|
||||
}
|
||||
}
|
||||
|
||||
IRO_CheckForUserBreak();
|
||||
}
|
||||
|
||||
Statement *IRO_Optimizer(Object *obj, Statement *stmt) {
|
||||
Statement *IRO_Optimizer(Object *func, Statement *statements) {
|
||||
Boolean changed;
|
||||
Boolean changed2;
|
||||
int pass;
|
||||
int passCount;
|
||||
|
||||
CError_ASSERT(234, stIsSetup);
|
||||
|
||||
DisableDueToAsm = 0;
|
||||
FunctionName = func;
|
||||
DoScalarize = 1;
|
||||
DoLinearize = 1;
|
||||
EarlyReturn = 0;
|
||||
IRO_Depends = NULL;
|
||||
LoopOptimizerRun = 0;
|
||||
IRO_IsLeafFunction = 1;
|
||||
IRO_FunctionHasReturn = 0;
|
||||
|
||||
IRO_SetupForUserBreakChecking();
|
||||
|
||||
IRO_Dump("Starting function %s\n", func ? func->name->name : "Init-code");
|
||||
IRO_Dump("--------------------------------------------------------------------------------\n");
|
||||
|
||||
if (DoLinearize)
|
||||
IRO_PreLinearize(statements);
|
||||
if (copts.optimizationlevel > 0)
|
||||
IRO_TransformTree(statements);
|
||||
|
||||
VectorPhaseCalledFromUnroll = 0;
|
||||
|
||||
IRO_Linearize(statements);
|
||||
|
||||
CurStat = NULL;
|
||||
|
||||
IRO_FirstExpr = NULL;
|
||||
IRO_LastExpr = NULL;
|
||||
IRO_FirstAssign = NULL;
|
||||
IRO_LastAssign = NULL;
|
||||
IRO_FirstVarUse = NULL;
|
||||
IRO_LastVarUse = NULL;
|
||||
IRO_FirstNode = NULL;
|
||||
IRO_LastNode = NULL;
|
||||
|
||||
if (copts.optimizationlevel > 0)
|
||||
IRO_DoTransformations();
|
||||
|
||||
IRO_BuildFlowgraph(IRO_FirstLinear);
|
||||
IRO_DumpAfterPhase("IRO_BuildflowGraph", 0);
|
||||
|
||||
IRO_FindAllVars();
|
||||
IRO_CheckInit();
|
||||
|
||||
if (!DisableDueToAsm && copts.optimizationlevel > 0 && copts.opt_pointer_analysis && func) {
|
||||
IRO_AnalyzePointers(func);
|
||||
if (copts.opt_propagation && IRO_EvaluateDefinitePointers(func)) {
|
||||
IRO_UpdateFlagsOnInts();
|
||||
IRO_UpdateVars();
|
||||
IRO_DumpAfterPhase("IRO_EvaluateDefinitePointers", 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (copts.optimizationlevel > 0) {
|
||||
changed = IRO_EvaluateConditionals();
|
||||
|
||||
if (!DisableDueToAsm) {
|
||||
changed |= IRO_RemoveUnreachable();
|
||||
IRO_DumpAfterPhase("IRO_RemoveUnreachable", 0);
|
||||
}
|
||||
|
||||
changed |= IRO_RemoveRedundantJumps();
|
||||
IRO_DumpAfterPhase("IRO_RemoveRedundantJumps", 0);
|
||||
|
||||
if (!DisableDueToAsm) {
|
||||
changed |= IRO_RemoveLabels();
|
||||
IRO_DumpAfterPhase("IRO_RemoveLabels()", 0);
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
IRO_BuildFlowgraph(IRO_FirstLinear);
|
||||
IRO_DumpAfterPhase("IRO_BuildflowGraph--1", 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!DisableDueToAsm && copts.optimizationlevel > 0) {
|
||||
passCount = copts._B4 ? 2 : 1;
|
||||
IRO_CPFirstTime = 1;
|
||||
for (pass = 0; pass < passCount; pass++) {
|
||||
IRO_Dump("*****************\n");
|
||||
IRO_Dump("Dumps for pass=%d\n", pass);
|
||||
IRO_Dump("*****************\n");
|
||||
|
||||
if (DoScalarize)
|
||||
IRO_ScalarizeClassDataMembers();
|
||||
IRO_DumpAfterPhase("IRO_ScalarizeClassDataMembers", 0);
|
||||
|
||||
if (copts.opt_propagation) {
|
||||
IRO_CopyAndConstantPropagation();
|
||||
IRO_CPFirstTime = 0;
|
||||
IRO_ExpressionPropagation();
|
||||
IRO_DumpAfterPhase("Copy and constant propagation", 0);
|
||||
|
||||
IRO_RangePropagateInFNode();
|
||||
IRO_DumpAfterPhase("IRO_RangePropagateInFNode", 0);
|
||||
IRO_UpdateFlagsOnInts();
|
||||
}
|
||||
|
||||
IRO_DumpAfterPhase("IRO_ExpressionPropagation", 0);
|
||||
|
||||
if (copts.opt_dead_assignments || copts.opt_propagation)
|
||||
IRO_UseDef(copts.opt_dead_assignments, copts.opt_propagation);
|
||||
IRO_DumpAfterPhase("after IRO_UseDef", 0);
|
||||
|
||||
IRO_UpdateVars();
|
||||
IRO_ConstantFolding();
|
||||
IRO_DumpAfterPhase("IRO_ConstantFolding", 0);
|
||||
|
||||
IRO_EvaluateConditionals();
|
||||
IRO_RemoveUnreachable();
|
||||
IRO_SimplifyConditionals();
|
||||
|
||||
if (pass == 1 && copts.optimizationlevel > 2) {
|
||||
IRO_RenumberInts();
|
||||
IRO_DumpAfterPhase("Before IRO_FindEmptyLoops", 0);
|
||||
IRO_FindEmptyLoops();
|
||||
IRO_DumpAfterPhase("After IRO_FindEmptyLoops", 0);
|
||||
IRO_RenumberInts();
|
||||
}
|
||||
|
||||
if (copts.opt_unroll_loops && !copts.optimize_for_size && pass == 0) {
|
||||
IRO_DumpAfterPhase("Before IRO_LoopUnroller", 0);
|
||||
IRO_LoopUnroller();
|
||||
IRO_DumpAfterPhase("After IRO_LoopUnroller", 0);
|
||||
IRO_RenumberInts();
|
||||
}
|
||||
|
||||
VectorPhaseCalledFromUnroll = 0;
|
||||
|
||||
if (pass == 0 && (copts.opt_loop_invariants || copts.opt_strength_reduction)) {
|
||||
IRO_DumpAfterPhase("Before IRO_FindLoops", 0);
|
||||
IRO_FindLoops();
|
||||
LoopOptimizerRun = 1;
|
||||
IRO_SetLoopDepth();
|
||||
}
|
||||
IRO_DumpAfterPhase("After IRO_FindLoops", 0);
|
||||
|
||||
if (copts.opt_propagation) {
|
||||
IRO_CopyAndConstantPropagation();
|
||||
IRO_ConstantFolding();
|
||||
IRO_EvaluateConditionals();
|
||||
}
|
||||
|
||||
IRO_DumpAfterPhase("Second pass:IRO_CopyAndConstantPropagation, IRO_ConstantFolding, IRO_EvaluateConditionals", 0);
|
||||
|
||||
if (copts.opt_common_subs)
|
||||
IRO_FindExpressions(NULL, 0);
|
||||
|
||||
if (copts.opt_common_subs) {
|
||||
IRO_ComputeAvail();
|
||||
IRO_CommonSubs();
|
||||
}
|
||||
IRO_DumpAfterPhase("IRO_CommonSubs", 0);
|
||||
|
||||
IRO_UpdateFlagsOnInts();
|
||||
IRO_UpdateVars();
|
||||
IRO_DoTransformations();
|
||||
IRO_ConstantFolding();
|
||||
|
||||
do {
|
||||
IRO_UpdateFlagsOnInts();
|
||||
|
||||
if (copts.opt_dead_code)
|
||||
IRO_RemoveUnreachable();
|
||||
IRO_DumpAfterPhase("IRO_RemoveUnreachable", 0);
|
||||
|
||||
changed2 = IRO_RemoveRedundantJumps();
|
||||
IRO_DumpAfterPhase("IRO_RemoveRedundantJumps", 0);
|
||||
|
||||
changed2 |= IRO_RemoveLabels();
|
||||
IRO_DumpAfterPhase("IRO_RemoveLabels", 0);
|
||||
|
||||
changed2 |= IRO_DoJumpChaining();
|
||||
IRO_DumpAfterPhase("IRO_DoJumpChaining", 0);
|
||||
|
||||
if (copts.opt_propagation) {
|
||||
IRO_RenumberInts();
|
||||
IRO_DumpAfterPhase("Before IRO_CopyAndConstantPropagation", 0);
|
||||
changed2 |= IRO_CopyAndConstantPropagation();
|
||||
IRO_DumpAfterPhase("After IRO_CopyAndConstantPropagation", 0);
|
||||
IRO_ConstantFolding();
|
||||
}
|
||||
|
||||
if (copts.opt_dead_assignments || copts.opt_propagation)
|
||||
changed2 |= IRO_UseDef(copts.opt_dead_assignments, copts.opt_propagation);
|
||||
IRO_DumpAfterPhase("IRO_UseDef", 0);
|
||||
|
||||
changed2 |= IRO_EvaluateConditionals();
|
||||
IRO_DumpAfterPhase("IRO_EvaluateConditionals", 0);
|
||||
} while (changed2);
|
||||
}
|
||||
|
||||
if (copts.opt_lifetimes) {
|
||||
IRO_UseDef(0, 0);
|
||||
IRO_SplitLifetimes();
|
||||
}
|
||||
|
||||
IRO_DoTransformations();
|
||||
IRO_DumpAfterPhase("Before RebuildCondExpressions", 0);
|
||||
}
|
||||
|
||||
IRO_RenumberInts();
|
||||
IRO_DumpAfterPhase("before IRO_RewriteBitFieldTemps", 0);
|
||||
IRO_RewriteBitFieldTemps();
|
||||
IRO_DumpAfterPhase("After IRO_RewriteBitFieldTemps", 0);
|
||||
|
||||
CountUsage();
|
||||
|
||||
if (!DisableDueToAsm) {
|
||||
IRO_RegenerateExpressions();
|
||||
IRO_DumpAfterPhase("IRO_RegenerateExpressions", 0);
|
||||
}
|
||||
|
||||
IRO_DumpAfterPhase("After IRO_Optimizer", 0);
|
||||
|
||||
statements = IRO_Delinearize(IRO_FirstNode, NULL);
|
||||
|
||||
IRO_ZapVarPtrs();
|
||||
freeoheap();
|
||||
return statements;
|
||||
}
|
||||
|
||||
void IRO_Setup(void) {
|
||||
static Boolean ENodeArraysHaveBeenInitialized;
|
||||
|
||||
if (!stIsSetup) {
|
||||
IRO_Log = 0;
|
||||
IRO_SetupDump();
|
||||
if (!ENodeArraysHaveBeenInitialized) {
|
||||
IRO_InitializeNodeNamesArray();
|
||||
IRO_InitializeIsAssociativeENodeTypeArray();
|
||||
IRO_InitializeIsSubableOpArray();
|
||||
IRO_InitializeAssignmentOpArray();
|
||||
IRO_InitializeComplementaryOpArray();
|
||||
IRO_InitializeComplementaryOpLogicalArray();
|
||||
IRO_InitializeNonAssignmentOpArray();
|
||||
IRO_InitializeAssignmentFoldingFunctionArray();
|
||||
IRO_InitializeIRO_IsModifyOpArray();
|
||||
IRO_InitializeIRO_IsAssignOpArray();
|
||||
ENodeArraysHaveBeenInitialized = 1;
|
||||
}
|
||||
stIsSetup = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void IRO_Cleanup(void) {
|
||||
if (stIsSetup) {
|
||||
IRO_CleanupDump();
|
||||
stIsSetup = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CodeGen_UpdateOptimizerOptions(void) {
|
||||
copts.opt_dead_code = copts.optimizationlevel > 0;
|
||||
copts.opt_propagation = copts.optimizationlevel > 1;
|
||||
copts.opt_common_subs = copts.optimizationlevel > 1;
|
||||
copts.opt_vectorize_loops = copts.optimizationlevel > 2;
|
||||
copts.opt_unroll_loops = copts.optimizationlevel > 2;
|
||||
copts.opt_dead_assignments = copts.optimizationlevel > 2;
|
||||
copts.opt_lifetimes = copts.optimizationlevel > 2;
|
||||
copts.opt_strength_reduction = copts.optimizationlevel > 2;
|
||||
copts.opt_loop_invariants = copts.optimizationlevel > 2;
|
||||
copts._B4 = copts.optimizationlevel > 3;
|
||||
Boolean flag;
|
||||
|
||||
flag = copts.optimizationlevel >= 1;
|
||||
copts.opt_dead_code = flag;
|
||||
|
||||
flag = copts.optimizationlevel >= 2;
|
||||
copts.opt_propagation = flag;
|
||||
copts.opt_common_subs = flag;
|
||||
|
||||
flag = copts.optimizationlevel >= 3;
|
||||
copts.opt_vectorize_loops = flag;
|
||||
copts.opt_unroll_loops = flag;
|
||||
copts.opt_dead_assignments = flag;
|
||||
copts.opt_lifetimes = flag;
|
||||
copts.opt_strength_reduction = flag;
|
||||
copts.opt_loop_invariants = flag;
|
||||
|
||||
flag = copts.optimizationlevel >= 4;
|
||||
copts._B4 = flag;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "compiler/IroMalloc.h"
|
||||
#include "compiler/IroPointerAnalysis.h"
|
||||
#include "compiler/IroSubable.h"
|
||||
#include "compiler/IROUseDef.h"
|
||||
#include "compiler/IroUtil.h"
|
||||
#include "compiler/IroVars.h"
|
||||
#include "compiler/CError.h"
|
||||
|
@ -979,10 +980,22 @@ void IRO_CommonSubs(void) {
|
|||
IRO_CheckForUserBreak();
|
||||
}
|
||||
|
||||
static Boolean CountThisSubableOperandUse() {
|
||||
static Boolean CountThisSubableOperandUse(IROUse *use) {
|
||||
return use->x1C != 0;
|
||||
}
|
||||
|
||||
static void GetSubableOperandUseCount() {
|
||||
static int GetSubableOperandUseCount(VarRecord *var) {
|
||||
int count = 0;
|
||||
IROUse *use;
|
||||
|
||||
if (var->uses) {
|
||||
for (use = var->uses; use; use = use->varnext) {
|
||||
if (CountThisSubableOperandUse(use))
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static void IRO_MakeTopLevelExprForSubableOperand(IROLinear *linear) {
|
||||
|
|
|
@ -0,0 +1,914 @@
|
|||
#include "compiler/IroEval.h"
|
||||
#include "compiler/CInt64.h"
|
||||
#include "compiler/CMachine.h"
|
||||
#include "compiler/CParser.h"
|
||||
#include "compiler/IroFlowgraph.h"
|
||||
#include "compiler/IroLinearForm.h"
|
||||
#include "compiler/IroMalloc.h"
|
||||
#include "compiler/IroPointerAnalysis.h"
|
||||
#include "compiler/IroUtil.h"
|
||||
#include "compiler/IroVars.h"
|
||||
#include "compiler/enode.h"
|
||||
#include "compiler/objects.h"
|
||||
#include "compiler/types.h"
|
||||
|
||||
static Boolean IsAssociativeENodeType[MAXEXPR];
|
||||
|
||||
void IRO_InitializeIsAssociativeENodeTypeArray(void) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAXEXPR; i++)
|
||||
IsAssociativeENodeType[i] = 0;
|
||||
|
||||
IsAssociativeENodeType[EPOSTINC] = 0;
|
||||
IsAssociativeENodeType[EPOSTDEC] = 0;
|
||||
IsAssociativeENodeType[EPREINC] = 0;
|
||||
IsAssociativeENodeType[EPREDEC] = 0;
|
||||
IsAssociativeENodeType[EINDIRECT] = 0;
|
||||
IsAssociativeENodeType[EMONMIN] = 0;
|
||||
IsAssociativeENodeType[EBINNOT] = 0;
|
||||
IsAssociativeENodeType[ELOGNOT] = 0;
|
||||
IsAssociativeENodeType[EFORCELOAD] = 0;
|
||||
IsAssociativeENodeType[EMUL] = 1;
|
||||
IsAssociativeENodeType[EMULV] = 1;
|
||||
IsAssociativeENodeType[EDIV] = 0;
|
||||
IsAssociativeENodeType[EMODULO] = 0;
|
||||
IsAssociativeENodeType[EADDV] = 1;
|
||||
IsAssociativeENodeType[ESUBV] = 0;
|
||||
IsAssociativeENodeType[EADD] = 1;
|
||||
IsAssociativeENodeType[ESUB] = 0;
|
||||
IsAssociativeENodeType[ESHL] = 0;
|
||||
IsAssociativeENodeType[ESHR] = 0;
|
||||
IsAssociativeENodeType[ELESS] = 0;
|
||||
IsAssociativeENodeType[EGREATER] = 0;
|
||||
IsAssociativeENodeType[ELESSEQU] = 0;
|
||||
IsAssociativeENodeType[EGREATEREQU] = 0;
|
||||
IsAssociativeENodeType[EEQU] = 0;
|
||||
IsAssociativeENodeType[ENOTEQU] = 0;
|
||||
IsAssociativeENodeType[EAND] = 1;
|
||||
IsAssociativeENodeType[EXOR] = 1;
|
||||
IsAssociativeENodeType[EOR] = 1;
|
||||
IsAssociativeENodeType[ELAND] = 0;
|
||||
IsAssociativeENodeType[ELOR] = 0;
|
||||
IsAssociativeENodeType[EASS] = 0;
|
||||
IsAssociativeENodeType[EMULASS] = 0;
|
||||
IsAssociativeENodeType[EDIVASS] = 0;
|
||||
IsAssociativeENodeType[EMODASS] = 0;
|
||||
IsAssociativeENodeType[EADDASS] = 0;
|
||||
IsAssociativeENodeType[ESUBASS] = 0;
|
||||
IsAssociativeENodeType[ESHLASS] = 0;
|
||||
IsAssociativeENodeType[ESHRASS] = 0;
|
||||
IsAssociativeENodeType[EANDASS] = 0;
|
||||
IsAssociativeENodeType[EXORASS] = 0;
|
||||
IsAssociativeENodeType[EORASS] = 0;
|
||||
IsAssociativeENodeType[ECOMMA] = 0;
|
||||
IsAssociativeENodeType[EPMODULO] = 0;
|
||||
IsAssociativeENodeType[EROTL] = 0;
|
||||
IsAssociativeENodeType[EROTR] = 0;
|
||||
IsAssociativeENodeType[EBCLR] = 0;
|
||||
IsAssociativeENodeType[EBTST] = 0;
|
||||
IsAssociativeENodeType[EBSET] = 0;
|
||||
IsAssociativeENodeType[ETYPCON] = 0;
|
||||
IsAssociativeENodeType[EBITFIELD] = 0;
|
||||
IsAssociativeENodeType[EINTCONST] = 0;
|
||||
IsAssociativeENodeType[EFLOATCONST] = 0;
|
||||
IsAssociativeENodeType[ESTRINGCONST] = 0;
|
||||
IsAssociativeENodeType[ECOND] = 0;
|
||||
IsAssociativeENodeType[EFUNCCALL] = 0;
|
||||
IsAssociativeENodeType[EFUNCCALLP] = 0;
|
||||
IsAssociativeENodeType[EOBJREF] = 0;
|
||||
IsAssociativeENodeType[EMFPOINTER] = 0;
|
||||
IsAssociativeENodeType[ENULLCHECK] = 0;
|
||||
IsAssociativeENodeType[EPRECOMP] = 0;
|
||||
IsAssociativeENodeType[ETEMP] = 0;
|
||||
IsAssociativeENodeType[EARGOBJ] = 0;
|
||||
IsAssociativeENodeType[ELOCOBJ] = 0;
|
||||
IsAssociativeENodeType[ELABEL] = 0;
|
||||
IsAssociativeENodeType[ESETCONST] = 0;
|
||||
IsAssociativeENodeType[ENEWEXCEPTION] = 0;
|
||||
IsAssociativeENodeType[ENEWEXCEPTIONARRAY] = 0;
|
||||
IsAssociativeENodeType[EOBJLIST] = 0;
|
||||
IsAssociativeENodeType[EMEMBER] = 0;
|
||||
IsAssociativeENodeType[ETEMPLDEP] = 0;
|
||||
IsAssociativeENodeType[EINSTRUCTION] = 0;
|
||||
IsAssociativeENodeType[EDEFINE] = 0;
|
||||
IsAssociativeENodeType[EREUSE] = 0;
|
||||
IsAssociativeENodeType[EASSBLK] = 0;
|
||||
IsAssociativeENodeType[EVECTOR128CONST] = 0;
|
||||
IsAssociativeENodeType[ECONDASS] = 0;
|
||||
}
|
||||
|
||||
void IRO_TruncateValueToType(CInt64 *val, Type *type) {
|
||||
if (IRO_IsUnsignedType(type)) {
|
||||
switch (type->size) {
|
||||
case 1:
|
||||
CInt64_ConvertUInt8(val);
|
||||
break;
|
||||
case 2:
|
||||
CInt64_ConvertUInt16(val);
|
||||
break;
|
||||
case 4:
|
||||
CInt64_ConvertUInt32(val);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (type->size) {
|
||||
case 1:
|
||||
CInt64_ConvertInt8(val);
|
||||
break;
|
||||
case 2:
|
||||
CInt64_ConvertInt16(val);
|
||||
break;
|
||||
case 4:
|
||||
CInt64_ConvertInt32(val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IRO_TruncateBitfieldValueToType(CInt64 *val, Type *type, Type *type2) {
|
||||
UInt32 limit;
|
||||
UInt32 i;
|
||||
UInt32 j;
|
||||
CInt64 work;
|
||||
|
||||
work = cint64_zero;
|
||||
limit = TYPE_BITFIELD(type2)->unkB;
|
||||
for (i = 0; i < limit; i++)
|
||||
work = CInt64_Or(work, CInt64_Shl(cint64_one, IRO_MakeULong(i)));
|
||||
*val = CInt64_And(*val, work);
|
||||
|
||||
if (!IRO_IsUnsignedType(type)) {
|
||||
work = cint64_zero;
|
||||
for (j = 0; j <= (i - 1); j++) {
|
||||
if (j == (i - 1))
|
||||
work = CInt64_Or(work, CInt64_Shl(cint64_one, IRO_MakeULong(j)));
|
||||
}
|
||||
if (CInt64_NotEqual(CInt64_And(work, *val), cint64_zero)) {
|
||||
for (j = i - 1; j < 64; j++)
|
||||
*val = CInt64_Or(*val, CInt64_Shl(cint64_one, IRO_MakeULong(j)));
|
||||
}
|
||||
}
|
||||
|
||||
IRO_TruncateValueToType(val, type);
|
||||
}
|
||||
|
||||
void IRO_ConstantFolding(void) {
|
||||
IROLinear *nd;
|
||||
ENode *expr;
|
||||
int isCompare;
|
||||
int flag;
|
||||
CInt64 val;
|
||||
|
||||
for (nd = IRO_FirstLinear; nd; nd = nd->next) {
|
||||
switch (nd->type) {
|
||||
case IROLinearOp1Arg:
|
||||
if (IRO_IsIntConstant(nd->u.monadic)) {
|
||||
expr = NULL;
|
||||
flag = 0;
|
||||
val = nd->u.monadic->u.node->data.intval;
|
||||
if (nd->nodetype == ETYPCON && IS_TYPE_FLOAT(nd->rtype)) {
|
||||
expr = IRO_NewENode(EFLOATCONST);
|
||||
if (!IRO_IsUnsignedType(nd->u.monadic->rtype))
|
||||
expr->data.floatval.value = CInt64_ConvertToLongDouble(&val);
|
||||
else
|
||||
expr->data.floatval.value = CInt64_ConvertUToLongDouble(&val);
|
||||
expr->rtype = nd->rtype;
|
||||
} else {
|
||||
switch (nd->nodetype) {
|
||||
case ETYPCON:
|
||||
flag = 1;
|
||||
break;
|
||||
case ELOGNOT:
|
||||
val = CInt64_Not(val);
|
||||
flag = 1;
|
||||
break;
|
||||
case EBINNOT:
|
||||
val = CInt64_Inv(val);
|
||||
flag = 1;
|
||||
break;
|
||||
case EMONMIN:
|
||||
val = CInt64_Neg(val);
|
||||
flag = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
IRO_TruncateValueToType(&val, nd->rtype);
|
||||
expr = IRO_NewENode(EINTCONST);
|
||||
expr->rtype = nd->rtype;
|
||||
expr->data.intval = val;
|
||||
}
|
||||
}
|
||||
|
||||
if (expr) {
|
||||
nd->u.monadic->type = IROLinearNop;
|
||||
nd->type = IROLinearOperand;
|
||||
nd->u.node = expr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IROLinearOp2Arg:
|
||||
if (IRO_IsIntConstant(nd->u.diadic.left) && !IRO_IsIntConstant(nd->u.diadic.right) && IsAssociativeENodeType[nd->nodetype]) {
|
||||
IROLinear *tmp = nd->u.diadic.right;
|
||||
nd->u.diadic.right = nd->u.diadic.left;
|
||||
nd->u.diadic.left = tmp;
|
||||
}
|
||||
|
||||
if (IRO_IsIntConstant(nd->u.diadic.right) && nd->nodetype == ESUB) {
|
||||
nd->nodetype = EADD;
|
||||
if (IRO_IsIntConstant(nd->u.diadic.right)) {
|
||||
CInt64 v;
|
||||
v = CInt64_Neg(nd->u.diadic.right->u.node->data.intval);
|
||||
nd->u.diadic.right->u.node->data.intval = v;
|
||||
} else {
|
||||
Float f;
|
||||
f = CMach_CalcFloatMonadic(
|
||||
nd->u.diadic.right->rtype,
|
||||
'-',
|
||||
nd->u.diadic.right->u.node->data.floatval);
|
||||
nd->u.diadic.right->u.node->data.floatval = f;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
IRO_IsIntConstant(nd->u.diadic.right) &&
|
||||
IsAssociativeENodeType[nd->nodetype] &&
|
||||
nd->u.diadic.left->type == IROLinearOp2Arg &&
|
||||
nd->u.diadic.left->nodetype == nd->nodetype &&
|
||||
nd->u.diadic.left->rtype == nd->rtype &&
|
||||
IRO_IsIntConstant(nd->u.diadic.left->u.diadic.right) &&
|
||||
nd->u.diadic.left->u.diadic.right->rtype == nd->u.diadic.right->rtype
|
||||
)
|
||||
{
|
||||
IROLinear *tmp = nd->u.diadic.left;
|
||||
nd->u.diadic.left = tmp->u.diadic.left;
|
||||
tmp->u.diadic.left = tmp->u.diadic.right;
|
||||
tmp->u.diadic.right = nd->u.diadic.right;
|
||||
tmp->rtype = tmp->u.diadic.left->rtype;
|
||||
nd->u.diadic.right = tmp;
|
||||
nd = tmp;
|
||||
}
|
||||
|
||||
if (IRO_IsIntConstant(nd->u.diadic.left) && IRO_IsIntConstant(nd->u.diadic.right)) {
|
||||
CInt64 val1 = nd->u.diadic.left->u.node->data.intval;
|
||||
CInt64 val2 = nd->u.diadic.right->u.node->data.intval;
|
||||
flag = 0;
|
||||
switch (nd->nodetype) {
|
||||
case EADD:
|
||||
val = CInt64_Add(val1, val2);
|
||||
flag = 1;
|
||||
break;
|
||||
case ESUB:
|
||||
val = CInt64_Sub(val1, val2);
|
||||
flag = 1;
|
||||
break;
|
||||
case EMUL:
|
||||
if (IRO_IsUnsignedType(nd->rtype))
|
||||
val = CInt64_MulU(val1, val2);
|
||||
else
|
||||
val = CInt64_Mul(val1, val2);
|
||||
flag = 1;
|
||||
break;
|
||||
case EDIV:
|
||||
if (!CInt64_IsZero(&val2)) {
|
||||
if (IRO_IsUnsignedType(nd->rtype))
|
||||
val = CInt64_DivU(val1, val2);
|
||||
else
|
||||
val = CInt64_Div(val1, val2);
|
||||
flag = 1;
|
||||
}
|
||||
break;
|
||||
case EMODULO:
|
||||
if (!CInt64_IsZero(&val2)) {
|
||||
if (IRO_IsUnsignedType(nd->rtype))
|
||||
val = CInt64_ModU(val1, val2);
|
||||
else
|
||||
val = CInt64_Mod(val1, val2);
|
||||
flag = 1;
|
||||
}
|
||||
break;
|
||||
case ESHL:
|
||||
val = CInt64_Shl(val1, val2);
|
||||
flag = 1;
|
||||
break;
|
||||
case ESHR:
|
||||
if (IRO_IsUnsignedType(nd->rtype))
|
||||
val = CInt64_ShrU(val1, val2);
|
||||
else
|
||||
val = CInt64_Shr(val1, val2);
|
||||
flag = 1;
|
||||
break;
|
||||
case EAND:
|
||||
val = CInt64_And(val1, val2);
|
||||
flag = 1;
|
||||
break;
|
||||
case EOR:
|
||||
val = CInt64_Or(val1, val2);
|
||||
flag = 1;
|
||||
break;
|
||||
case EXOR:
|
||||
val = CInt64_Xor(val1, val2);
|
||||
flag = 1;
|
||||
break;
|
||||
case ELESS:
|
||||
if (IRO_IsUnsignedType(nd->u.diadic.left->rtype))
|
||||
CInt64_SetULong(&val, CInt64_LessU(val1, val2));
|
||||
else
|
||||
CInt64_SetULong(&val, CInt64_Less(val1, val2));
|
||||
flag = 1;
|
||||
break;
|
||||
case EGREATER:
|
||||
if (IRO_IsUnsignedType(nd->u.diadic.left->rtype))
|
||||
CInt64_SetULong(&val, CInt64_GreaterU(val1, val2));
|
||||
else
|
||||
CInt64_SetULong(&val, CInt64_Greater(val1, val2));
|
||||
flag = 1;
|
||||
break;
|
||||
case ELESSEQU:
|
||||
if (IRO_IsUnsignedType(nd->u.diadic.left->rtype))
|
||||
CInt64_SetULong(&val, CInt64_LessEqualU(val1, val2));
|
||||
else
|
||||
CInt64_SetULong(&val, CInt64_LessEqual(val1, val2));
|
||||
flag = 1;
|
||||
break;
|
||||
case EGREATEREQU:
|
||||
if (IRO_IsUnsignedType(nd->u.diadic.left->rtype))
|
||||
CInt64_SetULong(&val, CInt64_GreaterEqualU(val1, val2));
|
||||
else
|
||||
CInt64_SetULong(&val, CInt64_GreaterEqual(val1, val2));
|
||||
flag = 1;
|
||||
break;
|
||||
case EEQU:
|
||||
CInt64_SetULong(&val, CInt64_Equal(val1, val2));
|
||||
flag = 1;
|
||||
break;
|
||||
case ENOTEQU:
|
||||
CInt64_SetULong(&val, CInt64_NotEqual(val1, val2));
|
||||
flag = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
IRO_TruncateValueToType(&val, nd->rtype);
|
||||
expr = IRO_NewENode(EINTCONST);
|
||||
expr->rtype = nd->rtype;
|
||||
expr->data.intval = val;
|
||||
nd->u.diadic.left->type = IROLinearNop;
|
||||
nd->u.diadic.right->type = IROLinearNop;
|
||||
nd->type = IROLinearOperand;
|
||||
nd->u.node = expr;
|
||||
}
|
||||
}
|
||||
|
||||
if (IRO_IsFloatConstant(nd->u.diadic.left) && IRO_IsFloatConstant(nd->u.diadic.right)) {
|
||||
Float fval1 = nd->u.diadic.left->u.node->data.floatval;
|
||||
Float fval2 = nd->u.diadic.right->u.node->data.floatval;
|
||||
Float fval;
|
||||
flag = 0;
|
||||
isCompare = 0;
|
||||
switch (nd->nodetype) {
|
||||
case EADD:
|
||||
fval = CMach_CalcFloatDiadic(nd->rtype, fval1, '+', fval2);
|
||||
flag = 1;
|
||||
break;
|
||||
case ESUB:
|
||||
fval = CMach_CalcFloatDiadic(nd->rtype, fval1, '-', fval2);
|
||||
flag = 1;
|
||||
break;
|
||||
case EMUL:
|
||||
fval = CMach_CalcFloatDiadic(nd->rtype, fval1, '*', fval2);
|
||||
flag = 1;
|
||||
break;
|
||||
case EDIV:
|
||||
fval = CMach_CalcFloatDiadic(nd->rtype, fval1, '/', fval2);
|
||||
flag = 1;
|
||||
break;
|
||||
case ELESS:
|
||||
CInt64_SetULong(&val, CMach_CalcFloatDiadicBool(nd->rtype, fval1, '<', fval2));
|
||||
flag = 1;
|
||||
isCompare = 1;
|
||||
break;
|
||||
case EGREATER:
|
||||
CInt64_SetULong(&val, CMach_CalcFloatDiadicBool(nd->rtype, fval1, '>', fval2));
|
||||
flag = 1;
|
||||
isCompare = 1;
|
||||
break;
|
||||
case ELESSEQU:
|
||||
CInt64_SetULong(&val, CMach_CalcFloatDiadicBool(nd->rtype, fval1, TK_LESS_EQUAL, fval2));
|
||||
flag = 1;
|
||||
isCompare = 1;
|
||||
break;
|
||||
case EGREATEREQU:
|
||||
CInt64_SetULong(&val, CMach_CalcFloatDiadicBool(nd->rtype, fval1, TK_GREATER_EQUAL, fval2));
|
||||
flag = 1;
|
||||
isCompare = 1;
|
||||
break;
|
||||
case EEQU:
|
||||
CInt64_SetULong(&val, CMach_CalcFloatDiadicBool(nd->rtype, fval1, TK_LOGICAL_EQ, fval2));
|
||||
flag = 1;
|
||||
isCompare = 1;
|
||||
break;
|
||||
case ENOTEQU:
|
||||
CInt64_SetULong(&val, CMach_CalcFloatDiadicBool(nd->rtype, fval1, TK_LOGICAL_NE, fval2));
|
||||
flag = 1;
|
||||
isCompare = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
if (isCompare) {
|
||||
IRO_TruncateValueToType(&val, nd->rtype);
|
||||
expr = IRO_NewENode(EINTCONST);
|
||||
expr->rtype = nd->rtype;
|
||||
expr->data.intval = val;
|
||||
nd->u.diadic.left->type = IROLinearNop;
|
||||
nd->u.diadic.right->type = IROLinearNop;
|
||||
nd->type = IROLinearOperand;
|
||||
nd->u.node = expr;
|
||||
} else {
|
||||
expr = IRO_NewENode(EFLOATCONST);
|
||||
expr->rtype = nd->rtype;
|
||||
expr->data.floatval = fval;
|
||||
nd->u.diadic.left->type = IROLinearNop;
|
||||
nd->u.diadic.right->type = IROLinearNop;
|
||||
nd->type = IROLinearOperand;
|
||||
nd->u.node = expr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IRO_CheckForUserBreak();
|
||||
}
|
||||
|
||||
Boolean IRO_EvaluateConditionals(void) {
|
||||
IRONode *fnode;
|
||||
IROLinear *nd;
|
||||
Boolean changed = 0;
|
||||
SwitchInfo *switchInfo;
|
||||
SwitchCase *swcase;
|
||||
char found;
|
||||
CInt64 val;
|
||||
|
||||
for (fnode = IRO_FirstNode; fnode; fnode = fnode->nextnode) {
|
||||
nd = fnode->last;
|
||||
switch (nd->type) {
|
||||
case IROLinearIf:
|
||||
case IROLinearIfNot:
|
||||
if (IRO_IsIntConstant(nd->u.label.x4)) {
|
||||
Boolean isZero = CInt64_IsZero(&nd->u.label.x4->u.node->data.intval);
|
||||
IRO_NopOut(nd->u.label.x4);
|
||||
if ((isZero == 0) == (nd->type == IROLinearIf))
|
||||
nd->type = IROLinearGoto;
|
||||
else
|
||||
nd->type = IROLinearNop;
|
||||
changed = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case IROLinearSwitch:
|
||||
if (IRO_IsIntConstant(nd->u.swtch.x4)) {
|
||||
val = nd->u.swtch.x4->u.node->data.intval;
|
||||
switchInfo = nd->u.swtch.info;
|
||||
swcase = switchInfo->cases;
|
||||
|
||||
IRO_NopOut(nd->u.swtch.x4);
|
||||
nd->type = IROLinearGoto;
|
||||
|
||||
found = 0;
|
||||
while (swcase) {
|
||||
if (CInt64_GreaterEqual(val, swcase->min) && CInt64_LessEqual(val, swcase->max)) {
|
||||
found = 1;
|
||||
nd->u.label.label = swcase->label;
|
||||
break;
|
||||
}
|
||||
swcase = swcase->next;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
nd->u.label.label = switchInfo->defaultlabel;
|
||||
changed = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
IRO_ComputeSuccPred();
|
||||
IRO_ComputeDom();
|
||||
}
|
||||
IRO_CheckForUserBreak();
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
static int EEquConst(IROLinear *nd) {
|
||||
return nd && (nd->nodetype == EEQU) && IRO_IsIntConstant(nd->u.diadic.right);
|
||||
}
|
||||
|
||||
static Object *VEquConst(IROLinear *nd) {
|
||||
if (EEquConst(nd))
|
||||
return IRO_IsVariable(nd->u.diadic.left);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int IsConsecutive(CInt64 a, CInt64 b) {
|
||||
CInt64 diff;
|
||||
|
||||
if (!CInt64_Equal(a, cint64_min) && !CInt64_Equal(b, cint64_min)) {
|
||||
diff = CInt64_Sub(b, a);
|
||||
return CInt64_Equal(diff, cint64_one) || CInt64_Equal(diff, cint64_negone);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static IROLinear *findLabel(CLabel *label) {
|
||||
IROLinear *nd;
|
||||
|
||||
for (nd = IRO_FirstLinear; nd; nd = nd->next) {
|
||||
if (nd->type == IROLinearLabel && nd->u.label.label == label)
|
||||
break;
|
||||
}
|
||||
|
||||
return nd;
|
||||
}
|
||||
|
||||
static IROLinear *leftLeaveOf(IROLinear *nd) {
|
||||
switch (nd->type) {
|
||||
case IROLinearOp1Arg:
|
||||
return leftLeaveOf(nd->u.monadic);
|
||||
case IROLinearOp2Arg:
|
||||
return leftLeaveOf(nd->u.diadic.left);
|
||||
case IROLinearOperand:
|
||||
return nd;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int checkNode(IRONode *fnode) {
|
||||
IROLinear *nd;
|
||||
|
||||
if (fnode->numpred <= 1) {
|
||||
nd = fnode->first;
|
||||
while (nd != fnode->last && (nd->type == IROLinearNop || nd->type == IROLinearLabel))
|
||||
nd = nd->next;
|
||||
|
||||
if (nd == leftLeaveOf(fnode->last->u.label.x4))
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int checkLabel(CLabel *label, IRONode *fnode) {
|
||||
switch (fnode->last->type) {
|
||||
case IROLinearIf:
|
||||
if (label == fnode->last->u.label.label)
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Object *checkExpr(Object *a, IROLinear *nd) {
|
||||
Object *b = VEquConst(nd);
|
||||
|
||||
if ((!a || a == b) && !IRO_HasSideEffect(nd))
|
||||
return b;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int checkStruct(IRONode *fnode1, IRONode *fnode2) {
|
||||
CLabel *label;
|
||||
Object *var;
|
||||
|
||||
if (fnode1 == fnode2)
|
||||
return (int) checkExpr(NULL, fnode1->last->u.label.x4);
|
||||
|
||||
label = fnode1->last->u.label.label;
|
||||
var = IRO_IsVariable(fnode1->last->u.label.x4->u.monadic);
|
||||
return checkNode(fnode2) && checkLabel(label, fnode2) && checkExpr(var, fnode2->last->u.label.x4);
|
||||
}
|
||||
|
||||
typedef struct ReduceInfo {
|
||||
int x0;
|
||||
int x4;
|
||||
Object *x8;
|
||||
IRONode *fnode;
|
||||
struct ReduceInfo *next;
|
||||
CInt64 val;
|
||||
} ReduceInfo;
|
||||
|
||||
static int MarkPattern1(ReduceInfo *info1, ReduceInfo *info2, CInt64 *val) {
|
||||
ReduceInfo *scan;
|
||||
|
||||
if (!info2)
|
||||
return 0;
|
||||
|
||||
if (info2->x0)
|
||||
return MarkPattern1(info1, info2->next, val);
|
||||
|
||||
for (scan = info1; scan; scan = scan->next) {
|
||||
if (scan->x0 == 2) {
|
||||
if (CInt64_Equal(info2->val, scan->val)) {
|
||||
IRO_NopOut(scan->fnode->last);
|
||||
IRO_NopOut(scan->fnode->last->u.label.x4); // right union?
|
||||
scan->x0 = -1;
|
||||
return MarkPattern1(info1, info2->next, val);
|
||||
}
|
||||
|
||||
if (IsConsecutive(info2->val, scan->val)) {
|
||||
info2->x0 = 2;
|
||||
if (CInt64_Greater(*val, scan->val))
|
||||
*val = scan->val;
|
||||
if (CInt64_Greater(*val, info2->val))
|
||||
*val = info2->val;
|
||||
MarkPattern1(scan->next, info2, val);
|
||||
MarkPattern1(info1, info1->next, val);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return MarkPattern1(info1, info2->next, val);
|
||||
}
|
||||
|
||||
static int DoReducible1(ReduceInfo *info, CInt64 val) {
|
||||
ReduceInfo *last;
|
||||
ReduceInfo *scan;
|
||||
IROLinear *right;
|
||||
IROLinear *left;
|
||||
IROLinear *typconRight;
|
||||
IROLinear *typconLeft;
|
||||
IROLinear *cond;
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
for (scan = info; scan; scan = scan->next) {
|
||||
if (scan->x0 == 2) {
|
||||
last = scan;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!count)
|
||||
return 0;
|
||||
|
||||
for (scan = info; scan != last; scan = scan->next) {
|
||||
if (scan->x0 == 2) {
|
||||
scan->x0 = -1;
|
||||
IRO_NopOut(scan->fnode->last);
|
||||
IRO_NopOut(scan->fnode->last->u.label.x4);
|
||||
}
|
||||
}
|
||||
|
||||
last->x0 = -1;
|
||||
|
||||
cond = last->fnode->last;
|
||||
cond->u.label.x4->nodetype = ELESSEQU;
|
||||
CInt64_SetULong(&cond->u.label.x4->u.diadic.right->u.node->data.intval, count - 1);
|
||||
|
||||
typconLeft = IRO_NewLinear(IROLinearOp1Arg);
|
||||
typconLeft->nodetype = ETYPCON;
|
||||
typconLeft->rtype = IRO_UnsignedType(cond->u.label.x4->u.diadic.left->rtype);
|
||||
typconLeft->index = ++IRO_NumLinear;
|
||||
|
||||
typconRight = IRO_NewLinear(IROLinearOp1Arg);
|
||||
*typconRight = *typconLeft;
|
||||
typconRight->index = ++IRO_NumLinear;
|
||||
|
||||
left = IRO_NewLinear(IROLinearOp2Arg);
|
||||
left->nodetype = EADD;
|
||||
left->rtype = cond->u.label.x4->u.diadic.left->rtype;
|
||||
left->index = ++IRO_NumLinear;
|
||||
|
||||
right = IRO_NewLinear(IROLinearOperand);
|
||||
right->nodetype = EINTCONST;
|
||||
right->rtype = cond->u.label.x4->u.diadic.left->rtype;
|
||||
right->index = ++IRO_NumLinear;
|
||||
right->u.node = IRO_NewENode(EINTCONST);
|
||||
right->u.node->data.intval = CInt64_Neg(val);
|
||||
right->u.node->rtype = right->rtype;
|
||||
|
||||
typconLeft->next = cond->u.label.x4->u.diadic.left->next;
|
||||
cond->u.label.x4->u.diadic.left->next = right;
|
||||
right->next = left;
|
||||
left->next = typconLeft;
|
||||
|
||||
typconRight->next = cond->u.label.x4->u.diadic.right->next;
|
||||
cond->u.label.x4->u.diadic.right->next = typconRight;
|
||||
|
||||
typconLeft->u.monadic = left;
|
||||
left->u.diadic.left = cond->u.label.x4->u.diadic.left;
|
||||
left->u.diadic.right = right;
|
||||
cond->u.label.x4->u.diadic.left = typconLeft;
|
||||
typconRight->u.monadic = cond->u.label.x4->u.diadic.right;
|
||||
cond->u.label.x4->u.diadic.right = typconRight;
|
||||
|
||||
return count;
|
||||
};
|
||||
|
||||
static int ReducePattern1(IRONode *startnode, IRONode *endnode) {
|
||||
ReduceInfo *infos;
|
||||
ReduceInfo *info;
|
||||
int changed = 0;
|
||||
int count;
|
||||
IRONode *fnode;
|
||||
int i;
|
||||
int j;
|
||||
CInt64 val;
|
||||
|
||||
if (startnode == endnode)
|
||||
return 0;
|
||||
|
||||
count = 0;
|
||||
for (fnode = startnode; fnode != endnode; fnode = fnode->nextnode)
|
||||
count++;
|
||||
|
||||
infos = oalloc(sizeof(ReduceInfo) * ++count);
|
||||
|
||||
fnode = startnode;
|
||||
for (i = 0; i < count; i++) {
|
||||
infos[i].x0 = 0;
|
||||
infos[i].x4 = 0;
|
||||
infos[i].fnode = fnode;
|
||||
infos[i].next = NULL;
|
||||
infos[i].x8 = VEquConst(fnode->last->u.label.x4);
|
||||
if (infos[i].x8) {
|
||||
infos[i].val = fnode->last->u.label.x4->u.diadic.right->u.node->data.intval;
|
||||
infos[i].x4 = 1;
|
||||
}
|
||||
fnode = fnode->nextnode;
|
||||
}
|
||||
|
||||
for (j = 0; j < count; j++) {
|
||||
if (infos[j].x4 == 1 && infos[j].x8) {
|
||||
infos[j].x4 = -1;
|
||||
info = &infos[j];
|
||||
for (i = j + 1; i < count; i++) {
|
||||
if (infos[j].x8 == infos[i].x8) {
|
||||
info->next = &infos[i];
|
||||
info = &infos[i];
|
||||
infos[i].x4 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < count; j++) {
|
||||
if (infos[j].x4 == -1) {
|
||||
for (info = &infos[j]; info; info = info->next) {
|
||||
if (info->x0 == 0) {
|
||||
info->x0 = 2;
|
||||
val = info->val;
|
||||
if (MarkPattern1(&infos[j], info->next, &val)) {
|
||||
changed = 1;
|
||||
DoReducible1(&infos[j], val);
|
||||
} else {
|
||||
info->x0 = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
static int ReduceConsecutiveIf(IRONode *startnode, IRONode *endnode) {
|
||||
IRONode *node31;
|
||||
IRONode *node30;
|
||||
int changed = 0;
|
||||
|
||||
while (startnode != endnode) {
|
||||
if (checkStruct(startnode, startnode))
|
||||
break;
|
||||
startnode = startnode->nextnode;
|
||||
}
|
||||
|
||||
node31 = startnode;
|
||||
if (startnode != endnode) {
|
||||
node30 = startnode;
|
||||
node31 = startnode->nextnode;
|
||||
while (node31 != endnode) {
|
||||
if (checkStruct(startnode, node31)) {
|
||||
node30 = node31;
|
||||
node31 = node31->nextnode;
|
||||
} else {
|
||||
node31 = node30;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (node31 == endnode && !checkStruct(startnode, node31))
|
||||
node31 = node30;
|
||||
|
||||
if (startnode != node31 && ReducePattern1(startnode, node31))
|
||||
changed = 1;
|
||||
|
||||
if (node31 != endnode)
|
||||
node31 = node31->nextnode;
|
||||
}
|
||||
|
||||
if (node31 != endnode && ReduceConsecutiveIf(node31, endnode))
|
||||
changed = 1;
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
int IRO_SimplifyConditionals(void) {
|
||||
IRONode *fnode;
|
||||
IRONode *start;
|
||||
IRONode *end;
|
||||
int changed = 0;
|
||||
|
||||
for (fnode = IRO_FirstNode; fnode; fnode = fnode->nextnode) {
|
||||
if (fnode->last->type == IROLinearIf) {
|
||||
start = end = fnode;
|
||||
while (fnode->nextnode && fnode->nextnode->last->type == IROLinearIf) {
|
||||
end = fnode = fnode->nextnode;
|
||||
}
|
||||
if (start != end && ReduceConsecutiveIf(start, end))
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
IRO_ComputeSuccPred();
|
||||
IRO_ComputeDom();
|
||||
}
|
||||
IRO_CheckForUserBreak();
|
||||
return changed;
|
||||
}
|
||||
|
||||
Boolean IRO_EvaluateDefinitePointers(Object *func) {
|
||||
IROLinear *nd;
|
||||
Boolean result; // r29
|
||||
Boolean changed; // r28
|
||||
Boolean changed2; // r26
|
||||
IROLinear *nd2; // r25
|
||||
IROListNode *scan; // r25
|
||||
IROListNode *list;
|
||||
|
||||
if (!copts.opt_pointer_analysis)
|
||||
return 0;
|
||||
|
||||
result = 0;
|
||||
|
||||
do {
|
||||
changed = 0;
|
||||
|
||||
for (nd = IRO_FirstLinear; nd; nd = nd->next) {
|
||||
if (
|
||||
nd->type == IROLinearOp1Arg &&
|
||||
nd->nodetype == EINDIRECT &&
|
||||
!(nd->flags & IROLF_Assigned) &&
|
||||
nd->pointsToFunction &&
|
||||
!IRO_HasSideEffect(nd) &&
|
||||
PointerAnalysis_IsLinearNodePointerExprDefinite(func, nd)
|
||||
)
|
||||
{
|
||||
list = NULL;
|
||||
PointerAnalysis_LookupLinearNodePointerExpr(func, nd, &list);
|
||||
if (list) {
|
||||
if (list->list.head && list->list.tail && !list->nextList) {
|
||||
changed2 = IRO_LocateFather_Cut_And_Paste(nd, list->list.tail) != NULL;
|
||||
if (changed2) {
|
||||
IRO_PasteAfter(list->list.head, list->list.tail, nd);
|
||||
for (nd2 = list->list.head; nd2 != list->list.tail->next; nd2 = nd2->next) {
|
||||
if (nd2->type == IROLinearOperand && nd2->u.node->type == EOBJREF) {
|
||||
if (nd2->u.node->data.objref->datatype == DDATA || nd2->u.node->data.objref->datatype == DLOCAL)
|
||||
IRO_FindVar(nd2->u.node->data.objref, 1, 1);
|
||||
else
|
||||
nd2->u.node->data.objref->varptr = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
changed |= changed2;
|
||||
}
|
||||
|
||||
while (list) {
|
||||
scan = list->nextList;
|
||||
IRO_free(list);
|
||||
list = scan;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result |= changed;
|
||||
IRO_CheckForUserBreak();
|
||||
} while (changed);
|
||||
|
||||
return result;
|
||||
}
|
|
@ -331,5 +331,109 @@ IRONode *IRO_NewFlowGraphNode(void) {
|
|||
}
|
||||
|
||||
IRONode *IRO_MergeFlowGraphNodes(IRONode *a, IRONode *b) {
|
||||
// TODO
|
||||
IRONode *succ;
|
||||
Boolean found;
|
||||
UInt32 i;
|
||||
UInt32 j;
|
||||
UInt32 k;
|
||||
|
||||
if (a->nextnode == b && a->last && b->first && a->last->next == b->first) {
|
||||
if (b->first->type == IROLinearLabel)
|
||||
IRO_NopOut(b->first);
|
||||
|
||||
a->nextnode = b->nextnode;
|
||||
a->last = b->last;
|
||||
|
||||
for (i = 0; i < a->numsucc; i++) {
|
||||
if (b->index == a->succ[i]) {
|
||||
for (j = i; j < a->numsucc; j++) {
|
||||
if ((j + 1) < a->numsucc)
|
||||
a->succ[j] = a->succ[j + 1];
|
||||
else
|
||||
a->succ[j] = 0;
|
||||
}
|
||||
a->numsucc--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < b->numsucc; i++) {
|
||||
succ = IRO_NodeTable[b->succ[i]];
|
||||
for (j = 0; j < a->numsucc; j++) {
|
||||
if (b->succ[i] == a->succ[j])
|
||||
break;
|
||||
}
|
||||
|
||||
if (j == a->numsucc) {
|
||||
AddSucc(a, IRO_NodeTable[b->succ[i]]);
|
||||
succ->numpred--;
|
||||
}
|
||||
|
||||
found = 0;
|
||||
for (j = 0; j < succ->numpred; j++) {
|
||||
if (a->index == succ->pred[j]) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < succ->numpred; j++) {
|
||||
if (b->index == succ->pred[j]) {
|
||||
if (!found) {
|
||||
succ->pred[j] = a->index;
|
||||
} else {
|
||||
for (k = j; k < succ->numpred; k++) {
|
||||
if ((k + 1) < succ->numpred)
|
||||
succ->pred[k] = succ->pred[k + 1];
|
||||
else
|
||||
succ->pred[k] = 0;
|
||||
}
|
||||
succ->numpred--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
b->numsucc = b->numpred = 0;
|
||||
b->first = b->last = NULL;
|
||||
b->nextnode = NULL;
|
||||
b->x36 = 0;
|
||||
b->x37 = 0;
|
||||
b->mustreach = 0;
|
||||
b->x39 = 0;
|
||||
b->loopdepth = 0;
|
||||
|
||||
if (IRO_LastNode == b)
|
||||
IRO_LastNode = a;
|
||||
|
||||
if (IRO_FirstExpr && IRO_LastExpr) {
|
||||
IROExpr *expr;
|
||||
for (expr = IRO_FirstExpr; expr && expr != IRO_LastExpr->next; expr = expr->next) {
|
||||
if (expr->node == b)
|
||||
expr->node = a;
|
||||
}
|
||||
}
|
||||
|
||||
if (IRO_FirstAssign && IRO_LastAssign) {
|
||||
IROAssign *assign;
|
||||
for (assign = IRO_FirstAssign; assign && assign != IRO_LastAssign->next; assign = assign->next) {
|
||||
if (assign->node == b)
|
||||
assign->node = a;
|
||||
}
|
||||
}
|
||||
|
||||
if (IRO_FirstVarUse && IRO_LastVarUse) {
|
||||
IROUse *use;
|
||||
for (use = IRO_FirstVarUse; use && use != IRO_LastVarUse->globalnext; use = use->globalnext) {
|
||||
if (use->node == b)
|
||||
use->node = a;
|
||||
}
|
||||
}
|
||||
|
||||
IRO_NodeTable[b->index] = NULL;
|
||||
return a;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -1902,7 +1902,7 @@ IROLoop *ExtractLoopInfo(IRONode *fnode) {
|
|||
if (IS_LINEAR_DIADIC_2(loop->nd18, ELESS, ELESSEQU)) {
|
||||
if (nd21->nodetype == EADDASS) {
|
||||
if (scanind->addConst == 1)
|
||||
loop->flags |= LoopFlags_100;
|
||||
loop->flags |= LP_LOOP_STEP_ISADD;
|
||||
if (scanind->addConst > 0)
|
||||
loop->flags |= LP_LOOP_STEP_ISPOS;
|
||||
} else if (nd21->nodetype == EASS &&
|
||||
|
@ -1910,7 +1910,7 @@ IROLoop *ExtractLoopInfo(IRONode *fnode) {
|
|||
IRO_IsIntConstant(tmp18 = nd21->u.diadic.right->u.diadic.right) &&
|
||||
CTool_EndianReadWord32(&tmp18->u.node->data.intval.hi) == 0) {
|
||||
if (CInt64_GetULong(&tmp18->u.node->data.intval) == 1)
|
||||
loop->flags |= LoopFlags_100;
|
||||
loop->flags |= LP_LOOP_STEP_ISADD;
|
||||
if (CInt64_GetULong(&tmp18->u.node->data.intval) > 0)
|
||||
loop->flags |= LP_LOOP_STEP_ISPOS;
|
||||
}
|
||||
|
@ -1918,7 +1918,7 @@ IROLoop *ExtractLoopInfo(IRONode *fnode) {
|
|||
} else if (nd21->type == IROLinearOp1Arg) {
|
||||
if (nd21->nodetype == EPREINC || nd21->nodetype == EPOSTINC) {
|
||||
if (scanind->addConst == 1)
|
||||
loop->flags |= LoopFlags_100;
|
||||
loop->flags |= LP_LOOP_STEP_ISADD;
|
||||
if (scanind->addConst > 0)
|
||||
loop->flags |= LP_LOOP_STEP_ISPOS;
|
||||
}
|
||||
|
@ -1997,7 +1997,7 @@ IROLoop *ExtractLoopInfo(IRONode *fnode) {
|
|||
for (scanind = FirstInd; scanind; scanind = scanind->next) {
|
||||
if (scanind->var->object == obj) {
|
||||
IRO_Dump("Induction has DIV: %s\n", obj->name->name);
|
||||
scanind->flags |= LoopInd_2;
|
||||
scanind->flags |= LoopInd_HasDiv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2008,7 +2008,7 @@ IROLoop *ExtractLoopInfo(IRONode *fnode) {
|
|||
for (scanind = FirstInd; scanind && obj; scanind = scanind->next) {
|
||||
if (scanind->var->object == obj) {
|
||||
IRO_Dump("Induction has MOD: %s\n", obj->name->name);
|
||||
scanind->flags |= LoopInd_1;
|
||||
scanind->flags |= LoopInd_HasMod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -956,10 +956,40 @@ void IRO_ReplaceReferenceWithNode(IROLinear *a, IROLinear *b) {
|
|||
}
|
||||
}
|
||||
|
||||
void IRO_GetTemp(IROExpr *expr) {
|
||||
VarRecord *IRO_GetTemp(IROExpr *expr) {
|
||||
expr->x8 = create_temp_object(expr->linear->rtype);
|
||||
return IRO_FindVar(expr->x8, 1, 1);
|
||||
}
|
||||
|
||||
IROLinear *IRO_AssignToTemp(IROExpr *expr) {
|
||||
IROLinear *objref;
|
||||
IROLinear *ind;
|
||||
IROLinear *ass;
|
||||
|
||||
objref = IRO_NewLinear(IROLinearOperand);
|
||||
objref->u.node = create_objectrefnode(expr->x8);
|
||||
objref->rtype = objref->u.node->data.objref->type;
|
||||
objref->index = ++IRO_NumLinear;
|
||||
objref->flags |= IROLF_Reffed | IROLF_Assigned | IROLF_Ind;
|
||||
|
||||
ind = IRO_NewLinear(IROLinearOp1Arg);
|
||||
ind->nodetype = EINDIRECT;
|
||||
ind->rtype = expr->linear->rtype;
|
||||
ind->u.monadic = objref;
|
||||
ind->index = ++IRO_NumLinear;
|
||||
ind->flags |= IROLF_Reffed | IROLF_Assigned;
|
||||
|
||||
ass = IRO_NewLinear(IROLinearOp2Arg);
|
||||
ass->nodetype = EASS;
|
||||
ass->u.diadic.left = ind;
|
||||
ass->u.diadic.right = expr->linear;
|
||||
ass->rtype = expr->linear->rtype;
|
||||
ass->index = ++IRO_NumLinear;
|
||||
|
||||
objref->next = ind;
|
||||
ind->next = ass;
|
||||
IRO_PasteAfter(objref, ass, expr->linear);
|
||||
return ass;
|
||||
}
|
||||
|
||||
IROLinear *IRO_FindStart(IROLinear *linear) {
|
||||
|
@ -993,7 +1023,7 @@ void IRO_RemoveCommaNodeFromIR(void) {
|
|||
if (!linear)
|
||||
break;
|
||||
if (linear->nodetype == ECOMMA) {
|
||||
linear->u.diadic.left->flags &= ~IROLF_Reffed;
|
||||
linear->u.diadic.left->flags = linear->u.diadic.left->flags & ~IROLF_Reffed;
|
||||
IRO_LocateFather_Cut_And_Paste_Without_Nopping(linear, linear->u.diadic.right);
|
||||
linear->type = IROLinearNop;
|
||||
}
|
||||
|
@ -1200,7 +1230,7 @@ IROLinear *IRO_NewIntConst(CInt64 val, Type *type) {
|
|||
return linear;
|
||||
}
|
||||
|
||||
IROLinear *IRO_NewFloatConst(Float val, Type *type) {
|
||||
IROLinear *IRO_NewFloatConst(const Float val, Type *type) {
|
||||
ENode *node;
|
||||
IROLinear *linear;
|
||||
|
||||
|
@ -1230,4 +1260,3 @@ void IRO_CheckForUserBreak(void) {
|
|||
IRO_LastUserBreakTick = COS_GetTicks();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1113,7 +1113,7 @@ void IRO_ScalarizeClassDataMembers(void) {
|
|||
}
|
||||
if (nd->type == IROLinearAsm) {
|
||||
IAEffects effects;
|
||||
int i;
|
||||
SInt32 i;
|
||||
CodeGen_GetAsmEffects(nd->u.asm_stmt, &effects);
|
||||
for (i = 0; i < effects.numoperands; i++) {
|
||||
if ((var = IRO_FindVar(effects.operands[i].object, 0, 1)))
|
||||
|
|
|
@ -843,19 +843,19 @@ static void rewriteunknownloopwithBDNZ(Loop *loop) {
|
|||
if (loop->unknownCondition == ELESS) {
|
||||
branchOpcode = PC_BF;
|
||||
if (loop->lowerType == LOOP_BOUND_CONSTANT) {
|
||||
branchCondition = 1;
|
||||
branchCondition = 1; // GT
|
||||
value1 = loop->lower;
|
||||
reg1 = addiInstr->args[2].data.reg.reg;
|
||||
value2 = absStep - 1 - loop->lower;
|
||||
mode = 0;
|
||||
} else if (loop->upperType == LOOP_BOUND_CONSTANT) {
|
||||
branchCondition = 0;
|
||||
branchCondition = 0; // LT
|
||||
value1 = loop->upper;
|
||||
reg1 = addiInstr->args[1].data.reg.reg;
|
||||
value2 = absStep - 1 + loop->upper;
|
||||
mode = 1;
|
||||
} else {
|
||||
branchCondition = 0;
|
||||
branchCondition = 0; // LT
|
||||
reg1 = addiInstr->args[1].data.reg.reg;
|
||||
reg2 = addiInstr->args[2].data.reg.reg;
|
||||
value2 = absStep - 1;
|
||||
|
@ -864,19 +864,19 @@ static void rewriteunknownloopwithBDNZ(Loop *loop) {
|
|||
} else if (loop->unknownCondition == ELESSEQU) {
|
||||
branchOpcode = PC_BT;
|
||||
if (loop->lowerType == LOOP_BOUND_CONSTANT) {
|
||||
branchCondition = 0;
|
||||
branchCondition = 0; // LT
|
||||
value1 = loop->lower;
|
||||
reg1 = addiInstr->args[2].data.reg.reg;
|
||||
value2 = absStep - loop->lower;
|
||||
mode = 0;
|
||||
} else if (loop->upperType == LOOP_BOUND_CONSTANT) {
|
||||
branchCondition = 1;
|
||||
branchCondition = 1; // GT
|
||||
value1 = loop->upper;
|
||||
reg1 = addiInstr->args[1].data.reg.reg;
|
||||
value2 = absStep + loop->upper;
|
||||
mode = 1;
|
||||
} else {
|
||||
branchCondition = 1;
|
||||
branchCondition = 1; // GT
|
||||
value1 = 0;
|
||||
reg1 = addiInstr->args[1].data.reg.reg;
|
||||
reg2 = addiInstr->args[2].data.reg.reg;
|
||||
|
@ -886,19 +886,19 @@ static void rewriteunknownloopwithBDNZ(Loop *loop) {
|
|||
} else if (loop->unknownCondition == EGREATER) {
|
||||
branchOpcode = PC_BF;
|
||||
if (loop->lowerType == LOOP_BOUND_CONSTANT) {
|
||||
branchCondition = 0;
|
||||
branchCondition = 0; // LT
|
||||
value1 = loop->lower;
|
||||
reg1 = addiInstr->args[2].data.reg.reg;
|
||||
value2 = absStep - 1 + loop->lower;
|
||||
mode = 1;
|
||||
} else if (loop->upperType == LOOP_BOUND_CONSTANT) {
|
||||
branchCondition = 1;
|
||||
branchCondition = 1; // GT
|
||||
value1 = loop->upper;
|
||||
reg1 = addiInstr->args[1].data.reg.reg;
|
||||
value2 = absStep - 1 - loop->upper;
|
||||
mode = 0;
|
||||
} else {
|
||||
branchCondition = 1;
|
||||
branchCondition = 1; // GT
|
||||
value1 = 0;
|
||||
reg1 = addiInstr->args[1].data.reg.reg;
|
||||
reg2 = addiInstr->args[2].data.reg.reg;
|
||||
|
@ -908,19 +908,19 @@ static void rewriteunknownloopwithBDNZ(Loop *loop) {
|
|||
} else if (loop->unknownCondition == EGREATEREQU) {
|
||||
branchOpcode = PC_BT;
|
||||
if (loop->lowerType == LOOP_BOUND_CONSTANT) {
|
||||
branchCondition = 1;
|
||||
branchCondition = 1; // GT
|
||||
value1 = loop->lower;
|
||||
reg1 = addiInstr->args[2].data.reg.reg;
|
||||
value2 = absStep + loop->lower;
|
||||
mode = 1;
|
||||
} else if (loop->upperType == LOOP_BOUND_CONSTANT) {
|
||||
branchCondition = 0;
|
||||
branchCondition = 0; // LT
|
||||
value1 = loop->upper;
|
||||
reg1 = addiInstr->args[1].data.reg.reg;
|
||||
value2 = absStep - loop->upper;
|
||||
mode = 0;
|
||||
} else {
|
||||
branchCondition = 0;
|
||||
branchCondition = 0; // LT
|
||||
reg1 = addiInstr->args[1].data.reg.reg;
|
||||
reg2 = addiInstr->args[2].data.reg.reg;
|
||||
value2 = absStep;
|
||||
|
@ -928,7 +928,7 @@ static void rewriteunknownloopwithBDNZ(Loop *loop) {
|
|||
}
|
||||
} else if (loop->unknownCondition == ENOTEQU) {
|
||||
branchOpcode = PC_BT;
|
||||
branchCondition = 2;
|
||||
branchCondition = 2; // EQ
|
||||
if (loop->step > 0) {
|
||||
if (loop->lowerType == LOOP_BOUND_CONSTANT) {
|
||||
value1 = loop->lower;
|
||||
|
|
|
@ -75,7 +75,7 @@ void retain_GPR_pair(Object *obj, short reg, short regHi) {
|
|||
}
|
||||
|
||||
int is_register_object(Object *obj) {
|
||||
return obj->sclass == OBJECT_SCLASS_101;
|
||||
return obj->sclass == TK_REGISTER;
|
||||
}
|
||||
|
||||
int GetABIFirstNonVolatile(RegClass rclass) {
|
||||
|
@ -118,10 +118,9 @@ void setup_diagnostic_reg_strings(void) {
|
|||
}
|
||||
|
||||
void init_target_registers(void) {
|
||||
RegClass rclass;
|
||||
int reg;
|
||||
int end;
|
||||
int tmp;
|
||||
RegClass rclass;
|
||||
|
||||
static int last_nonvolatile_reg[] = {3, 5, 31, 31, 31};
|
||||
static int nonvol_reserve[] = {0, 0, 0, 4, 3};
|
||||
|
@ -153,8 +152,7 @@ void init_target_registers(void) {
|
|||
end = first_nonvolatile_reg(rclass);
|
||||
for (reg = last_nonvolatile_reg[rclass]; reg >= end; reg--) {
|
||||
if (reg_state[rclass][reg] == RegState0) {
|
||||
tmp = n_nonvolatile_registers[rclass]++;
|
||||
nonvolatile_registers[rclass][tmp] = reg;
|
||||
nonvolatile_registers[rclass][n_nonvolatile_registers[rclass]++] = reg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,8 +165,7 @@ void init_target_registers(void) {
|
|||
for (reg = 0; reg < n_real_registers[rclass]; reg++) {
|
||||
if (reg < GetABIFirstNonVolatile(rclass) || reg > last_nonvolatile_reg[rclass]) {
|
||||
if (reg_state[rclass][reg] == RegState0) {
|
||||
tmp = n_scratch_registers[rclass]++;
|
||||
scratch_registers[rclass][tmp] = reg;
|
||||
scratch_registers[rclass][n_scratch_registers[rclass]++] = reg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -250,9 +247,6 @@ void open_fe_temp_registers(void) {
|
|||
first_fe_temporary_register[RegClass_FPR] = last_temporary_register[RegClass_FPR] = r;
|
||||
r = used_virtual_registers[RegClass_VR];
|
||||
first_fe_temporary_register[RegClass_VR] = last_temporary_register[RegClass_VR] = r;
|
||||
//first_fe_temporary_register[RegClass_GPR] = last_temporary_register[RegClass_GPR] = used_virtual_registers[RegClass_GPR];
|
||||
//first_fe_temporary_register[RegClass_FPR] = last_temporary_register[RegClass_FPR] = used_virtual_registers[RegClass_FPR];
|
||||
//first_fe_temporary_register[RegClass_VR] = last_temporary_register[RegClass_VR] = used_virtual_registers[RegClass_VR];
|
||||
}
|
||||
|
||||
void set_last_exception_registers(void) {
|
||||
|
@ -371,14 +365,17 @@ void init_endian(void) {
|
|||
|
||||
void update_asm_nonvolatile_registers(void) {
|
||||
RegClass rclass;
|
||||
int r31;
|
||||
int i;
|
||||
int reg;
|
||||
|
||||
for (rclass = 0; rclass < RegClassMax; rclass++) {
|
||||
for (r31 = n_nonvolatile_registers[rclass] - 1; r31 >= 0; r31--) {
|
||||
if (reg_state[rclass][nonvolatile_registers[rclass][r31]] == RegState1)
|
||||
reg = n_nonvolatile_registers[rclass];
|
||||
for (i = n_nonvolatile_registers[rclass] - 1; i >= 0; i--) {
|
||||
if (reg_state[rclass][nonvolatile_registers[rclass][i]] == RegState1)
|
||||
break;
|
||||
reg--;
|
||||
}
|
||||
if (r31 > used_nonvolatile_registers[rclass])
|
||||
used_nonvolatile_registers[rclass] = r31;
|
||||
if (reg > used_nonvolatile_registers[rclass])
|
||||
used_nonvolatile_registers[rclass] = reg;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,8 +71,8 @@ static void restore_nonvolatile_GPRs(int reg, SInt32 offset);
|
|||
static void do_allocate_dynamic_stack_space(Boolean isConstantSize, int reg1, int reg2, SInt32 size);
|
||||
|
||||
void init_stack_globals(Object *funcobj) {
|
||||
char rclass;
|
||||
UInt8 oclass;
|
||||
RegClass rclass;
|
||||
ObjClass oclass;
|
||||
|
||||
requires_frame = 0;
|
||||
makes_call = 0;
|
||||
|
@ -109,7 +109,7 @@ void init_stack_globals(Object *funcobj) {
|
|||
LR_save_offset = -1;
|
||||
|
||||
for (rclass = 0; rclass < RegClassMax; rclass++)
|
||||
non_volatile_save_offset[(char) rclass] = -1;
|
||||
non_volatile_save_offset[rclass] = -1;
|
||||
|
||||
dummyprofiler = NULL;
|
||||
dummyvaparam = NULL;
|
||||
|
|
|
@ -10,8 +10,12 @@
|
|||
#include "compiler/CMangler.h"
|
||||
#include "compiler/CParser.h"
|
||||
#include "compiler/CodeGen.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/Exceptions.h"
|
||||
#include "compiler/InlineAsm.h"
|
||||
#include "compiler/InlineAsmPPC.h"
|
||||
#include "compiler/InstrSelection.h"
|
||||
#include "compiler/Intrinsics.h"
|
||||
#include "compiler/ObjGenMachO.h"
|
||||
#include "compiler/Operands.h"
|
||||
#include "compiler/PCode.h"
|
||||
|
@ -19,7 +23,6 @@
|
|||
#include "compiler/PPCError.h"
|
||||
#include "compiler/RegisterInfo.h"
|
||||
#include "compiler/StackFrame.h"
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/enode.h"
|
||||
#include "compiler/objects.h"
|
||||
#include "compiler/types.h"
|
||||
|
@ -27,10 +30,10 @@
|
|||
ObjectList *toclist;
|
||||
ObjectList *exceptionlist;
|
||||
void *descriptorlist;
|
||||
void *floatconstpool;
|
||||
void *doubleconstpool;
|
||||
PoolEntry *floatconstpool;
|
||||
PoolEntry *doubleconstpool;
|
||||
ObjectList *floatconstlist;
|
||||
void *vectorconstpool;
|
||||
PoolEntry *vectorconstpool;
|
||||
ObjectList *vectorconstlist;
|
||||
Object toc0;
|
||||
Boolean no_descriptors;
|
||||
|
@ -126,7 +129,7 @@ void createNonLazyPointer(Object *obj) {
|
|||
toc->toc = NULL;
|
||||
toc->section = SECT_NONLAZY_PTRS;
|
||||
toc->u.toc.info = CodeGen_GetNewVarInfo();
|
||||
toc->sclass = OBJECT_SCLASS_102;
|
||||
toc->sclass = TK_STATIC;
|
||||
toc->qual = Q_CONST;
|
||||
toc->datatype = DNONLAZYPTR;
|
||||
toc->flags |= OBJECT_FLAGS_2;
|
||||
|
@ -193,7 +196,7 @@ Object *createfloatconstant(Type *type, Float *data) {
|
|||
obj->toc = NULL;
|
||||
obj->u.data.info = NULL;
|
||||
obj->u.data.linkname = obj->name;
|
||||
obj->sclass = OBJECT_SCLASS_102;
|
||||
obj->sclass = TK_STATIC;
|
||||
obj->qual = Q_CONST | Q_10000;
|
||||
obj->datatype = DDATA;
|
||||
if (type->size == 8)
|
||||
|
@ -238,7 +241,7 @@ Object *createvectorconstant(Type *type, MWVector128 *data) {
|
|||
obj->toc = NULL;
|
||||
obj->u.data.info = NULL;
|
||||
obj->u.data.linkname = obj->name;
|
||||
obj->sclass = OBJECT_SCLASS_102;
|
||||
obj->sclass = TK_STATIC;
|
||||
obj->qual = Q_CONST | Q_10000;
|
||||
obj->datatype = DDATA;
|
||||
if (type->size == 16)
|
||||
|
@ -261,16 +264,153 @@ Object *createvectorconstant(Type *type, MWVector128 *data) {
|
|||
return obj;
|
||||
}
|
||||
|
||||
void DeclarePooledConstants() {
|
||||
// TODO CInit
|
||||
void DeclarePooledConstants(void) {
|
||||
PoolEntry *entry;
|
||||
char *buffer;
|
||||
SInt32 fsize;
|
||||
SInt32 dsize;
|
||||
SInt32 vsize;
|
||||
|
||||
fsize = 0;
|
||||
for (entry = floatconstpool; entry; entry = entry->next)
|
||||
fsize += 4;
|
||||
|
||||
if (fsize) {
|
||||
floatconstpool->object->type = CDecl_NewArrayType(TYPE(&stfloat), fsize);
|
||||
buffer = galloc(fsize);
|
||||
for (entry = floatconstpool; entry; entry = entry->next)
|
||||
memcpy(buffer + entry->offset, entry->buffer, 4);
|
||||
CInit_DeclareReadOnlyData(floatconstpool->object, buffer, NULL, fsize);
|
||||
}
|
||||
|
||||
dsize = 0;
|
||||
for (entry = doubleconstpool; entry; entry = entry->next)
|
||||
dsize += 8;
|
||||
|
||||
if (dsize) {
|
||||
doubleconstpool->object->type = CDecl_NewArrayType(TYPE(&stdouble), dsize);
|
||||
buffer = galloc(dsize);
|
||||
for (entry = doubleconstpool; entry; entry = entry->next)
|
||||
memcpy(buffer + entry->offset, entry->buffer, 8);
|
||||
CInit_DeclareReadOnlyData(doubleconstpool->object, buffer, NULL, dsize);
|
||||
}
|
||||
|
||||
vsize = 0;
|
||||
for (entry = vectorconstpool; entry; entry = entry->next)
|
||||
vsize += 16;
|
||||
|
||||
if (vsize) {
|
||||
vectorconstpool->object->type = CDecl_NewArrayType(TYPE(&stvectorsignedlong), vsize);
|
||||
buffer = galloc(vsize);
|
||||
for (entry = vectorconstpool; entry; entry = entry->next)
|
||||
memcpy(buffer + entry->offset, entry->buffer, 16);
|
||||
CInit_DeclareReadOnlyData(vectorconstpool->object, buffer, NULL, vsize);
|
||||
}
|
||||
}
|
||||
|
||||
static Object *CreatePooledFloatConst(Type *type, Float *data, SInt32 *unkptr) {
|
||||
// TODO CDecl
|
||||
static Object *CreatePooledFloatConst(Type *type, Float *data, SInt32 *pOffset) {
|
||||
if (type->size == 8u) {
|
||||
PoolEntry *entry;
|
||||
void *buffer;
|
||||
Object *object;
|
||||
SInt32 offset;
|
||||
|
||||
buffer = galloc(8u);
|
||||
CMach_InitFloatMem(type, *data, buffer);
|
||||
if (cparamblkptr->isPrecompiling == 1)
|
||||
CError_Error(CErrorStr180);
|
||||
|
||||
for (entry = doubleconstpool; entry; entry = entry->next) {
|
||||
if (!memcmp(entry->buffer, buffer, 8u))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!entry) {
|
||||
if (doubleconstpool) {
|
||||
object = doubleconstpool->object;
|
||||
offset = doubleconstpool->offset + 8u;
|
||||
doubleconstpool->object->type->size += 8u;
|
||||
} else {
|
||||
DeclInfo di;
|
||||
memclrw(&di, sizeof(di));
|
||||
di.thetype = CDecl_NewArrayType(TYPE(&stdouble), 8u);
|
||||
di.name = GetHashNameNodeExport("@doubleBase0");
|
||||
di.qual = Q_CONST;
|
||||
di.storageclass = TK_STATIC;
|
||||
di.x4E = 1;
|
||||
di.section = SECT_CONST;
|
||||
object = CParser_NewGlobalDataObject(&di);
|
||||
object->nspace = cscope_root;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
entry = galloc(sizeof(PoolEntry));
|
||||
entry->next = doubleconstpool;
|
||||
doubleconstpool = entry;
|
||||
entry->object = object;
|
||||
entry->offset = offset;
|
||||
entry->buffer = galloc(8u);
|
||||
memcpy(entry->buffer, buffer, 8u);
|
||||
}
|
||||
|
||||
*pOffset = entry->offset;
|
||||
return entry->object;
|
||||
}
|
||||
|
||||
if (type->size == 4u) {
|
||||
PoolEntry *entry;
|
||||
void *buffer;
|
||||
Object *object;
|
||||
SInt32 offset;
|
||||
|
||||
buffer = galloc(4u);
|
||||
CMach_InitFloatMem(type, *data, buffer);
|
||||
if (cparamblkptr->isPrecompiling == 1)
|
||||
CError_Error(CErrorStr180);
|
||||
|
||||
for (entry = floatconstpool; entry; entry = entry->next) {
|
||||
if (!memcmp(entry->buffer, buffer, 4u))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!entry) {
|
||||
if (floatconstpool) {
|
||||
object = floatconstpool->object;
|
||||
offset = floatconstpool->offset + 4u;
|
||||
object->type->size += 4u;
|
||||
} else {
|
||||
DeclInfo di;
|
||||
memclrw(&di, sizeof(di));
|
||||
di.thetype = CDecl_NewArrayType(TYPE(&stfloat), 4u);
|
||||
di.name = GetHashNameNodeExport("@floatBase0");
|
||||
di.qual = Q_CONST;
|
||||
di.storageclass = TK_STATIC;
|
||||
di.x4E = 1;
|
||||
di.section = SECT_CONST;
|
||||
object = CParser_NewGlobalDataObject(&di);
|
||||
object->nspace = cscope_root;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
entry = galloc(sizeof(PoolEntry));
|
||||
entry->next = floatconstpool;
|
||||
floatconstpool = entry;
|
||||
entry->object = object;
|
||||
entry->offset = offset;
|
||||
entry->buffer = galloc(4u);
|
||||
memcpy(entry->buffer, buffer, 4u);
|
||||
}
|
||||
|
||||
*pOffset = entry->offset;
|
||||
return entry->object;
|
||||
}
|
||||
|
||||
CError_FATAL(1183);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Object *CreateFloatConst(Type *type, Float *data, SInt32 *unkptr) {
|
||||
*unkptr = 0;
|
||||
Object *CreateFloatConst(Type *type, Float *data, SInt32 *pOffset) {
|
||||
*pOffset = 0;
|
||||
return createfloatconstant(type, data);
|
||||
}
|
||||
|
||||
|
@ -281,7 +421,7 @@ static void RewriteFloatConst(ENode *expr) {
|
|||
|
||||
obj = CreateFloatConst(expr->rtype, &expr->data.floatval, &n);
|
||||
if (n) {
|
||||
subexpr = makediadicnode(create_objectrefnode(obj), intconstnode(&stunsignedlong, n), EADD);
|
||||
subexpr = makediadicnode(create_objectrefnode(obj), intconstnode(TYPE(&stunsignedlong), n), EADD);
|
||||
} else {
|
||||
subexpr = create_objectrefnode(obj);
|
||||
}
|
||||
|
@ -293,8 +433,63 @@ static void RewriteFloatConst(ENode *expr) {
|
|||
}
|
||||
|
||||
static void RewriteVectorConst(ENode *expr) {
|
||||
PoolEntry *entry;
|
||||
Object *object;
|
||||
SInt32 offset;
|
||||
ENode *inner;
|
||||
UInt8 data[16];
|
||||
// TODO
|
||||
|
||||
CMach_InitVectorMem(expr->rtype, expr->data.vector128val, data, 1);
|
||||
|
||||
if (cparamblkptr->isPrecompiling == 1)
|
||||
CError_Error(CErrorStr180);
|
||||
|
||||
for (entry = vectorconstpool; entry; entry = entry->next) {
|
||||
if (!memcmp(entry->buffer, data, 16))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!entry) {
|
||||
if (vectorconstpool) {
|
||||
object = vectorconstpool->object;
|
||||
offset = vectorconstpool->offset + 16;
|
||||
vectorconstpool->object->type->size += 16;
|
||||
} else {
|
||||
DeclInfo di;
|
||||
memclrw(&di, sizeof(di));
|
||||
di.thetype = CDecl_NewArrayType(TYPE(&stvectorsignedlong), 16);
|
||||
di.name = GetHashNameNodeExport("@vectorBase0");
|
||||
di.qual = Q_CONST;
|
||||
di.storageclass = TK_STATIC;
|
||||
di.x4E = 1;
|
||||
di.section = SECT_CONST;
|
||||
object = CParser_NewGlobalDataObject(&di);
|
||||
object->nspace = cscope_root;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
entry = galloc(sizeof(PoolEntry));
|
||||
entry->next = vectorconstpool;
|
||||
vectorconstpool = entry;
|
||||
entry->object = object;
|
||||
entry->offset = offset;
|
||||
entry->buffer = galloc(16);
|
||||
memcpy(entry->buffer, data, 16);
|
||||
}
|
||||
|
||||
if (entry->offset) {
|
||||
inner = makediadicnode(
|
||||
create_objectrefnode(entry->object),
|
||||
intconstnode(TYPE(&stunsignedlong), entry->offset),
|
||||
EADD);
|
||||
} else {
|
||||
inner = create_objectrefnode(entry->object);
|
||||
}
|
||||
|
||||
expr->type = EINDIRECT;
|
||||
expr->cost = 1;
|
||||
expr->flags |= ENODE_FLAG_CONST;
|
||||
expr->data.monadic = inner;
|
||||
}
|
||||
|
||||
static Object *createcodelabel(CLabel *label) {
|
||||
|
@ -313,7 +508,7 @@ static Object *createcodelabel(CLabel *label) {
|
|||
obj->name = label->uniquename;
|
||||
obj->toc = NULL;
|
||||
obj->u.data.info = NULL; // not sure if this is the right union!
|
||||
obj->sclass = OBJECT_SCLASS_102;
|
||||
obj->sclass = TK_STATIC;
|
||||
obj->qual = Q_CONST;
|
||||
obj->datatype = DDATA;
|
||||
obj->flags |= OBJECT_FLAGS_2 | OBJECT_FLAGS_4;
|
||||
|
@ -748,9 +943,13 @@ Boolean canoptimizevectorconst(MWVector128 *vecp, Type *type, COVCResult *result
|
|||
|
||||
first8 = vec.sc[0];
|
||||
flag = 1;
|
||||
for (i = 0; flag && i < 16; i++) {
|
||||
i = 1;
|
||||
while (flag && i < 16)
|
||||
flag = first8 == vec.sc[i++];
|
||||
/*flag = 1;
|
||||
for (i = 1; flag && i < 16; i++) {
|
||||
flag = first8 == vec.sc[i];
|
||||
}
|
||||
}*/
|
||||
|
||||
if (flag && first8 < 16 && first8 > -17) {
|
||||
if (result) {
|
||||
|
@ -954,6 +1153,12 @@ static Boolean DetectCondSideAffect(ENode *expr) {
|
|||
case EXOR:
|
||||
case EOR:
|
||||
case ECOMMA:
|
||||
case EPMODULO:
|
||||
case EROTL:
|
||||
case EROTR:
|
||||
case EBCLR:
|
||||
case EBTST:
|
||||
case EBSET:
|
||||
if (DetectCondSideAffect(expr->data.diadic.left))
|
||||
return 1;
|
||||
return DetectCondSideAffect(expr->data.diadic.right);
|
||||
|
@ -961,7 +1166,7 @@ static Boolean DetectCondSideAffect(ENode *expr) {
|
|||
if (expr->data.monadic->type == EINDIRECT)
|
||||
return 1;
|
||||
if (expr->data.monadic->type == EOBJREF) {
|
||||
if (expr->data.monadic->data.objref->datatype != DDATA && expr->data.monadic->data.objref->datatype != DLOCAL)
|
||||
if (expr->data.monadic->data.objref->datatype != DLOCAL && expr->data.monadic->data.objref->datatype != DDATA)
|
||||
return 1;
|
||||
if (IS_TYPE_POINTER(expr->data.monadic->data.objref->type))
|
||||
return 1;
|
||||
|
@ -1509,12 +1714,12 @@ static void expandTOCexpression(ENode *expr, Type *type, int ignored) {
|
|||
case EFUNCCALLP:
|
||||
if (is_intrinsic_function_call(expr)) {
|
||||
expr->hascall = 0;
|
||||
if ((expr->data.funccall.funcref->data.objref->u.func.u.intrinsicid & 0xFFFFu) == INTRINSIC_8) {
|
||||
if ((expr->data.funccall.funcref->data.objref->u.func.u.intrinsicid & 0xFFFFu) == Intrinsic_008) {
|
||||
if (copts.altivec_model)
|
||||
update_frame_align(16);
|
||||
dynamic_stack = 1;
|
||||
requires_frame = 1;
|
||||
} else if ((expr->data.funccall.funcref->data.objref->u.func.u.intrinsicid & 0xFFFFu) == INTRINSIC_35) {
|
||||
} else if ((expr->data.funccall.funcref->data.objref->u.func.u.intrinsicid & 0xFFFFu) == Intrinsic_035) {
|
||||
if (expr->data.funccall.args->next->node->type == ESTRINGCONST) {
|
||||
rewritestrcpy(expr);
|
||||
} else {
|
||||
|
@ -1522,7 +1727,7 @@ static void expandTOCexpression(ENode *expr, Type *type, int ignored) {
|
|||
makes_call = 1;
|
||||
expr->hascall = 1;
|
||||
}
|
||||
} else if ((expr->data.funccall.funcref->data.objref->u.func.u.intrinsicid & 0xFFFFu) == INTRINSIC_36) {
|
||||
} else if ((expr->data.funccall.funcref->data.objref->u.func.u.intrinsicid & 0xFFFFu) == Intrinsic_036) {
|
||||
if (expr->data.funccall.args->next->next->node->type != EINTCONST) {
|
||||
requires_frame = 1;
|
||||
makes_call = 1;
|
||||
|
@ -1929,6 +2134,10 @@ static void checkexceptionreferences(ExceptionAction *action) {
|
|||
|
||||
void expandTOCreferences(Statement **stmts) {
|
||||
Statement *stmt;
|
||||
IAOperand *op;
|
||||
int i;
|
||||
InlineAsm *ia;
|
||||
VarInfo *vi;
|
||||
|
||||
codelabellist = NULL;
|
||||
exceptionlist = NULL;
|
||||
|
@ -1952,7 +2161,7 @@ void expandTOCreferences(Statement **stmts) {
|
|||
break;
|
||||
case ST_IFGOTO:
|
||||
case ST_IFNGOTO:
|
||||
if (stmt->expr->type >= ELESS && stmt->expr->type <= ENOTEQU)
|
||||
if (stmt->expr->type < ELESS || stmt->expr->type > ENOTEQU)
|
||||
stmt->expr = comparewithzero(stmt->expr);
|
||||
expandTOCexpression(stmt->expr, NULL, 0);
|
||||
break;
|
||||
|
@ -1973,8 +2182,29 @@ void expandTOCreferences(Statement **stmts) {
|
|||
makes_call = 1;
|
||||
break;
|
||||
case ST_ASM:
|
||||
if (stmt->expr) {
|
||||
// TODO - ASM weirdness here
|
||||
if ((ia = (InlineAsm *) stmt->expr)) {
|
||||
if (ia->flags & IAFlag1) {
|
||||
if (ia->opcode == IADirective_FrFree)
|
||||
requires_frame = 1;
|
||||
} else {
|
||||
for (i = 0, op = ia->args; i < ia->argcount; i++, op++) {
|
||||
if (op->type == IAOpnd_Reg) {
|
||||
if (!op->u.reg.object) {
|
||||
if (op->u.reg.num == INVALID_PIC_REG)
|
||||
uses_globals = 1;
|
||||
else if (op->u.reg.effect & EffectWrite)
|
||||
asm_used_register(op->u.reg.rclass, op->u.reg.num);
|
||||
} else if ((vi = Registers_GetVarInfo(op->u.reg.object))) {
|
||||
vi->flags |= VarInfoFlag40;
|
||||
}
|
||||
} else if (op->type == IAOpnd_3) {
|
||||
uses_globals = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ia->flags & IAFlag2)
|
||||
makes_call = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2021,7 +2251,7 @@ Object *createstaticinitobject(void) {
|
|||
obj->otype = OT_OBJECT;
|
||||
obj->type = (Type *) tfunc;
|
||||
obj->name = GetHashNameNodeExport(buf);
|
||||
obj->sclass = OBJECT_SCLASS_102;
|
||||
obj->sclass = TK_STATIC;
|
||||
obj->datatype = DFUNC;
|
||||
|
||||
return obj;
|
||||
|
|
|
@ -12,23 +12,7 @@
|
|||
|
||||
|
||||
|
||||
struct DefArgCtorInfo {
|
||||
Object *default_func;
|
||||
ENode *default_arg;
|
||||
};
|
||||
|
||||
typedef struct XRefOffset {
|
||||
UInt32 xrefoffset;
|
||||
SInt32 offset;
|
||||
} XRefOffset;
|
||||
|
||||
struct InlineXRef {
|
||||
InlineXRef *next;
|
||||
Object *object;
|
||||
UInt16 xrefmode;
|
||||
UInt16 numxrefs;
|
||||
XRefOffset xref[1];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,13 @@
|
|||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
typedef enum CABIDestroyMode {
|
||||
CABIDestroy0 = 0,
|
||||
CABIDestroy1 = 1,
|
||||
CABIDestroy2 = 2,
|
||||
CABIDestroy3 = 3
|
||||
} CABIDestroyMode;
|
||||
|
||||
extern short CABI_GetStructResultArgumentIndex(TypeFunc *tfunc);
|
||||
extern Type *CABI_GetSizeTType(void);
|
||||
extern Type *CABI_GetPtrDiffTType(void);
|
||||
|
@ -16,21 +23,21 @@ extern void CABI_ReverseBitField(TypeBitfield *tbitfield);
|
|||
extern void CABI_AddVTable(TypeClass *tclass);
|
||||
extern SInt32 CABI_GetVTableOffset(TypeClass *tclass);
|
||||
extern void CABI_LayoutClass(DeclE *decle, TypeClass *tclass);
|
||||
extern void CABI_MakeDefaultArgConstructor(TypeClass *tclass, Object *obj);
|
||||
extern void CABI_MakeDefaultArgConstructor(TypeClass *tclass, Object *func);
|
||||
extern ENode *CABI_MakeThisExpr(TypeClass *tclass, SInt32 offset);
|
||||
extern SInt32 CABI_GetCtorOffsetOffset(TypeClass *tclass, TypeClass *base);
|
||||
extern Object *CABI_ConstructorCallsNew(TypeClass *tclass);
|
||||
typedef Statement *(*TransConstructorCallback)(Statement *stmt, TypeClass *tclass, TypeClass *base, SInt32 offset, Boolean flag);
|
||||
extern void CABI_TransConstructor(Object *obj, Statement *stmt, TypeClass *tclass, TransConstructorCallback callback, Boolean flag);
|
||||
extern void CABI_MakeDefaultConstructor(TypeClass *tclass, Object *obj);
|
||||
extern void CABI_MakeDefaultCopyConstructor(TypeClass *tclass, Object *obj);
|
||||
extern void CABI_MakeDefaultAssignmentOperator(TypeClass *tclass, Object *obj);
|
||||
extern void CABI_TransDestructor(Object *obj1, Object *obj2, Statement *stmt, TypeClass *tclass);
|
||||
extern void CABI_MakeDefaultDestructor(TypeClass *tclass, Object *obj);
|
||||
extern void CABI_MakeLayeredDestructor(TypeClass *tclass, Object *obj);
|
||||
extern Object *CABI_GetDestructorObject(Object *obj, int what);
|
||||
extern void CABI_TransConstructor(Object *obj, Statement *stmt, TypeClass *tclass, TransConstructorCallback callback, Boolean has_try);
|
||||
extern void CABI_MakeDefaultConstructor(TypeClass *tclass, Object *func);
|
||||
extern void CABI_MakeDefaultCopyConstructor(TypeClass *tclass, Object *func);
|
||||
extern void CABI_MakeDefaultAssignmentOperator(TypeClass *tclass, Object *func);
|
||||
extern void CABI_TransDestructor(Object *obj1, Object *obj2, Statement *stmt, TypeClass *tclass, CABIDestroyMode mode);
|
||||
extern void CABI_MakeDefaultDestructor(TypeClass *tclass, Object *func);
|
||||
extern void CABI_MakeLayeredDestructor(TypeClass *tclass, Object *func);
|
||||
extern Object *CABI_GetDestructorObject(Object *obj, CABIDestroyMode mode);
|
||||
extern void CABI_AddLayeredDestructors(TypeClass *tclass);
|
||||
extern ENode *CABI_DestroyObject(Object *dtor, ENode *objexpr, UInt8 mode, Boolean flag1, Boolean flag2);
|
||||
extern ENode *CABI_DestroyObject(Object *dtor, ENode *objexpr, CABIDestroyMode mode, Boolean flag1, Boolean flag2);
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
|
|
|
@ -7,21 +7,21 @@
|
|||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
typedef struct VTableObjectLink {
|
||||
/*typedef struct VTableObjectLink {
|
||||
struct VTableObjectLink *next;
|
||||
Object *methodobj;
|
||||
SInt32 offset;
|
||||
SInt32 xC;
|
||||
} VTableObjectLink;
|
||||
} VTableObjectLink;*/
|
||||
|
||||
extern void CClass_Init(void);
|
||||
extern void CClass_GenThunks(void);
|
||||
extern UInt8 CClass_GetOverrideKind(TypeFunc *a, TypeFunc *b, Boolean errorflag);
|
||||
extern Boolean CClass_IsEmpty(TypeClass *tclass);
|
||||
extern Boolean CClass_IsNonStaticMemberFunc(TypeMethod *tmethod);
|
||||
extern Boolean CClass_IsNonStaticMemberFunc(TypeFunc *tfunc);
|
||||
extern Object *CClass_DefaultConstructor(TypeClass *tclass);
|
||||
extern Object *CClass_DummyDefaultConstructor(TypeClass *tclass);
|
||||
extern ENode *CClass_DefaultConstructorCall(TypeClass *a, TypeClass *b, ENode *expr, SInt32 unkshortparam, Boolean flag1, Boolean flag2, Boolean *errorflag);
|
||||
extern ENode *CClass_DefaultConstructorCall(TypeClass *tclass, TypeClass *b, ENode *objexpr, SInt32 varg, Boolean flag1, Boolean flag2, Boolean *errorflag);
|
||||
extern Object *CClass_AssignmentOperator(TypeClass *tclass);
|
||||
extern Object *CClass_CopyConstructor(TypeClass *tclass);
|
||||
extern NameSpaceObjectList *CClass_MemberObject(TypeClass *tclass, HashNameNode *name);
|
||||
|
@ -34,19 +34,19 @@ extern Boolean CClass_IsTrivialCopyClass(TypeClass *tclass);
|
|||
extern Boolean CClass_IsTrivialCopyAssignClass(TypeClass *tclass);
|
||||
extern Boolean CClass_ReferenceArgument(TypeClass *tclass);
|
||||
extern BClassList *CClass_GetPathCopy(BClassList *path, Boolean is_global);
|
||||
extern BClassList *CClass_AppendPath(BClassList *a, BClassList *b);
|
||||
extern BClassList *CClass_AppendPath(BClassList *dest, BClassList *src);
|
||||
extern Boolean CClass_IsMoreAccessiblePath(BClassList *path1, BClassList *path2);
|
||||
extern BClassList *CClass_GetBasePath(TypeClass *a, TypeClass *b, short *founddepth, Boolean *isambigbase);
|
||||
extern Boolean CClass_IsBaseClass(TypeClass *a, TypeClass *b, short *founddepth, Boolean pathcheckflag, Boolean ambigerrorflag);
|
||||
extern TypeClass *CClass_GetQualifiedClass(void);
|
||||
extern ENode *CClass_AccessPathCast(BClassList *path, ENode *expr, Boolean flag);
|
||||
extern ENode *CClass_AccessPathCast(BClassList *path, ENode *expr, Boolean reverse);
|
||||
extern ENode *CClass_ClassPointerCast(ENode *expr, TypeClass *a, TypeClass *b, Boolean typconflag, Boolean ambigerrorflag, Boolean pathcheckflag);
|
||||
extern ENode *CClass_DirectBasePointerCast(ENode *expr, TypeClass *a, TypeClass *b);
|
||||
extern SInt32 CClass_GetPathOffset(BClassList *path);
|
||||
extern Boolean CClass_ClassDominates(TypeClass *a, TypeClass *b);
|
||||
extern SInt32 CClass_VirtualBaseOffset(TypeClass *a, TypeClass *b);
|
||||
extern SInt32 CClass_VirtualBaseVTableOffset(TypeClass *a, TypeClass *b);
|
||||
extern SInt32 CClass_GetMemberOffset(TypeClass *tclass, HashNameNode *name, ObjMemberVar **obj);
|
||||
extern Boolean CClass_ClassDominates(TypeClass *tclass, TypeClass *baseclass);
|
||||
extern SInt32 CClass_VirtualBaseOffset(TypeClass *tclass, TypeClass *baseclass);
|
||||
extern SInt32 CClass_VirtualBaseVTableOffset(TypeClass *tclass, TypeClass *baseclass);
|
||||
extern SInt32 CClass_GetMemberOffset(TypeClass *tclass, HashNameNode *name, ObjMemberVar **resultIvar);
|
||||
extern Boolean CClass_OverridesBaseMember(TypeClass *tclass, HashNameNode *name, Object *obj);
|
||||
extern void CClass_DefineCovariantFuncs(Object *method, CI_FuncData *ifuncdata);
|
||||
extern void CClass_CheckOverrides(TypeClass *tclass);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// named because it's 0xE bytes big (hurr)
|
||||
struct DeclE {
|
||||
ObjBase **objlist;
|
||||
void *x4;
|
||||
ObjMemberVar *vtable_ivar;
|
||||
unsigned short x8; // lex_order_count?
|
||||
unsigned short xA;
|
||||
Boolean xC;
|
||||
|
@ -31,8 +31,8 @@ struct DeclInfo {
|
|||
HashNameNode *name;
|
||||
Object *x10;
|
||||
NameSpaceObjectList *x14;
|
||||
void *x18;
|
||||
void *x1C;
|
||||
FuncArg *x18;
|
||||
NameSpace *x1C;
|
||||
Type *x20;
|
||||
ENode *x24;
|
||||
TemplClass *x28;
|
||||
|
@ -46,8 +46,8 @@ struct DeclInfo {
|
|||
short storageclass;
|
||||
UInt8 section;
|
||||
UInt8 exportflags;
|
||||
Boolean x44;
|
||||
Boolean x45;
|
||||
Boolean x44; // has args in identifier list
|
||||
Boolean x45; // has oldstyle args
|
||||
Boolean x46;
|
||||
Boolean x47;
|
||||
Boolean x48;
|
||||
|
@ -56,7 +56,7 @@ struct DeclInfo {
|
|||
Boolean x4B;
|
||||
Boolean x4C;
|
||||
Boolean x4D;
|
||||
Boolean x4E;
|
||||
Boolean x4E; // is_extern_c?
|
||||
Boolean x4F;
|
||||
Boolean x50;
|
||||
Boolean x51;
|
||||
|
@ -70,7 +70,7 @@ struct DeclInfo {
|
|||
CPrepFileInfo *file;
|
||||
CPrepFileInfo *file2;
|
||||
SInt32 x60; // file offset?
|
||||
short x64;
|
||||
Boolean x64;
|
||||
};
|
||||
|
||||
typedef struct BigDeclInfo {
|
||||
|
|
|
@ -3,6 +3,13 @@
|
|||
|
||||
#include "compiler/common.h"
|
||||
|
||||
typedef struct DtorTemp {
|
||||
struct DtorTemp *next;
|
||||
Object *object;
|
||||
Object *dtor;
|
||||
Object *temp;
|
||||
} DtorTemp;
|
||||
|
||||
extern ExceptionAction *cexcept_dobjstack;
|
||||
extern Boolean cexcept_hasdobjects;
|
||||
extern Boolean cexcept_magic;
|
||||
|
|
|
@ -64,7 +64,9 @@ typedef struct Conversion {
|
|||
} Conversion;
|
||||
|
||||
// CExpr.c
|
||||
extern Boolean (*name_obj_check)(HashNameNode *, Object *);
|
||||
typedef Boolean (*NameObjCheckCB)(HashNameNode *, Object *);
|
||||
|
||||
extern NameObjCheckCB name_obj_check;
|
||||
extern Boolean disallowgreaterthan;
|
||||
|
||||
// CExpr2.c
|
||||
|
@ -174,7 +176,7 @@ extern void CExpr_MatchCV(Type *t1, UInt32 q1, Type *t2, UInt32 q2, Match13 *mat
|
|||
extern Boolean CExpr_MatchAssign(Type *type, UInt32 qual, ENode *expr, Match13 *match);
|
||||
extern ENode *CExpr_ClassPointerCast(BClassList *cls, ENode *expr, Boolean nullcheckflag);
|
||||
extern ENode *CExpr_GetClassAccessNode(BClassList *a, BClassList *b, ENode *expr, Object *obj, AccessType access, Boolean flag);
|
||||
extern ENode *CExpr_ConvertToBool(ENode *expr, Boolean flag);
|
||||
extern ENode *CExpr_ConvertToBool(ENode *expr, Boolean isExplicit);
|
||||
extern void CExpr_ConversionIteratorInit(ConversionIterator *iter, TypeClass *tclass);
|
||||
extern Object *CExpr_ConversionIteratorNext(ConversionIterator *iter);
|
||||
extern short user_assign_check(ENode *expr, Type *type, UInt32 qual, Boolean flag1, Boolean flag2, Boolean flag3);
|
||||
|
@ -197,45 +199,12 @@ extern ENode *scannew(Boolean flag);
|
|||
extern ENode *scandelete(Boolean flag);
|
||||
|
||||
// CExprConvMatch.c
|
||||
// static void CExpr_GetImplictObjectParamType();
|
||||
// static void CExpr_GetParamType();
|
||||
// static void CExpr_HasNParams();
|
||||
// static void CExpr_TypeCompare();
|
||||
// static void CExpr_IsReferenceCompatible();
|
||||
// static void CExpr_IsBaseOf();
|
||||
// static void CExpr_IsBetterClassConversion();
|
||||
// static void CExpr_IsBetterStandardConv();
|
||||
// static void CExpr_IsBetterImplicitConv();
|
||||
// static void CExpr_SetupStandardConversionResult();
|
||||
// static void CExpr_SetQualConversionResult();
|
||||
// static void CExpr_OverloadFuncMatch();
|
||||
// static void CExpr_StandardConversionMatch();
|
||||
// static void CExpr_UserConversion();
|
||||
// static void CExpr_UserConversionMatch();
|
||||
// static void CExpr_ImplicitConversionMatch();
|
||||
extern Boolean CExpr_CanImplicitlyConvert(ENode *expr, Type *type, UInt32 qual);
|
||||
// static void CExpr_DerivedToBase();
|
||||
// static void CExpr_ClassReferenceConversion();
|
||||
// static void CExpr_BindToReference();
|
||||
extern ENode *CExpr_Convert(ENode *expr, Type *type, UInt32 qual, Boolean flag1, Boolean flag2);
|
||||
extern ENode *CExpr_AssignmentPromotion(ENode *expr, Type *type, UInt32 qual, Boolean flag);
|
||||
// static void CExpr_IsBetterMatch();
|
||||
// static void CExpr_MatchArgs();
|
||||
// static void CExpr_GetMatchObject();
|
||||
// static void CExpr_FindBestMatch();
|
||||
extern void CExpr_FuncArgMatch(NameSpaceObjectList *nsol, TemplArg *templargs, ENodeList *argexprs, Match13 *match, ENode *expr, Boolean flag);
|
||||
// static void CExpr_BuildConversionTypeList();
|
||||
// static void CExpr_NextPromotedIntegralType();
|
||||
// static void CExpr_NextArithmeticType();
|
||||
// static void CExpr_NextPromotedArithmeticType();
|
||||
// static void CExpr_MatchBuiltin();
|
||||
// static void CExpr_CheckIncDecBuiltin();
|
||||
// static void CExpr_CheckUnaryBuiltin();
|
||||
// static void CExpr_CheckBinaryBuiltin();
|
||||
// static void CExpr_MatchOperands();
|
||||
extern Boolean CExpr_CanImplicitlyConvert(ENode *expr, Type *type2, UInt32 qual2);
|
||||
extern ENode *CExpr_Convert(ENode *expr, Type *type, UInt32 qual, Boolean isExplicit, Boolean flag2);
|
||||
extern ENode *CExpr_AssignmentPromotion(ENode *expr, Type *type2, UInt32 qual2, Boolean flag);
|
||||
extern void CExpr_FuncArgMatch(NameSpaceObjectList *list, TemplArg *templargs, ENodeList *argexprs, Match13 *match13, ENode *expr, Boolean flag);
|
||||
extern Boolean CExpr_CondOperatorMatch(ENode *left, ENode *right, Conversion *conv);
|
||||
extern Boolean CExpr_OperatorMatch(short token, ENode *left, ENode *right, Conversion *conv);
|
||||
// static void CExpr_ClassCopyInit();
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
|
|
|
@ -49,6 +49,7 @@ typedef enum StatementType {
|
|||
enum {
|
||||
StmtFlag_1 = 1,
|
||||
StmtFlag_2 = 2,
|
||||
StmtFlag_4 = 4,
|
||||
StmtFlag_8 = 8,
|
||||
StmtFlag_10 = 0x10
|
||||
};
|
||||
|
@ -80,9 +81,15 @@ typedef struct InitExpr {
|
|||
Object *object;
|
||||
} InitExpr;
|
||||
|
||||
typedef enum CtorChainType {
|
||||
CtorChain_Base = 0,
|
||||
CtorChain_VBase = 1,
|
||||
CtorChain_MemberVar = 2
|
||||
} CtorChainType;
|
||||
|
||||
typedef struct CtorChain {
|
||||
struct CtorChain *next;
|
||||
UInt8 what;
|
||||
CtorChainType what;
|
||||
ENode *objexpr;
|
||||
union {
|
||||
ClassList *base; // 0
|
||||
|
@ -91,17 +98,19 @@ typedef struct CtorChain {
|
|||
} u;
|
||||
} CtorChain;
|
||||
|
||||
typedef struct CFuncSave {
|
||||
CScopeSave scope;
|
||||
// lots of fields
|
||||
} CFuncSave;
|
||||
typedef struct CFuncSave CFuncSave;
|
||||
|
||||
struct DeclThing {
|
||||
Type *thetype;
|
||||
UInt32 qual;
|
||||
NameSpace *nspace;
|
||||
CLabel *xC;
|
||||
CLabel *x10;
|
||||
SwitchInfo *switchinfo;
|
||||
CLabel *loopContinue;
|
||||
CLabel *loopBreak;
|
||||
};
|
||||
|
||||
struct DefArgCtorInfo {
|
||||
Object *default_func;
|
||||
ENode *default_arg;
|
||||
};
|
||||
|
||||
extern FuncArg elipsis;
|
||||
|
@ -122,7 +131,7 @@ extern Statement *curstmt;
|
|||
extern DeclBlock *CFunc_NewDeclBlock(void);
|
||||
extern void CFunc_RestoreBlock(DeclBlock *block);
|
||||
extern void CFunc_SetupLocalVarInfo(Object *obj);
|
||||
extern void CFunc_DefaultArg(Type *type, short qual, FuncArg *args);
|
||||
extern ENode *CFunc_DefaultArg(Type *type, UInt32 qual, FuncArg *args);
|
||||
extern Boolean CFunc_ParseFakeArgList(Boolean flag);
|
||||
extern FuncArg *parameter_type_list(DeclInfo *declinfo);
|
||||
extern CLabel *findlabel(void);
|
||||
|
@ -137,19 +146,19 @@ extern ENode *create_temp_node2(Type *type);
|
|||
extern void CFunc_WarnUnused(void);
|
||||
extern void CFunc_CodeCleanup(Statement *stmt);
|
||||
extern void CFunc_DestructorCleanup(Statement *stmt);
|
||||
extern Statement *CFunc_GenerateLoop(Statement *stmt, Type *type, ENode *expr1, ENode *expr2, ENode *expr3, ENode *expr4, ENode (*callback)(ENode *, ENode *));
|
||||
extern Statement *CFunc_GenerateLoop(Statement *stmt, Type *type, ENode *lowerBound, ENode *upperBound, ENode *increment1, ENode *increment2, ENode *(*callback)(ENode *, ENode *));
|
||||
extern void CFunc_CompoundStatement(DeclThing *thing);
|
||||
extern void CFunc_SetupNewFuncArgs(Object *obj, FuncArg *args);
|
||||
extern void CFunc_SetupNewFuncArgs(Object *func, FuncArg *args);
|
||||
extern NameSpace *CFunc_FuncGenSetup(Statement *stmt, Object *func);
|
||||
extern void CFunc_GetGlobalCompilerState(CFuncSave *state);
|
||||
extern CFuncSave *CFunc_GetGlobalCompilerState(void);
|
||||
extern void CFunc_SetGlobalCompilerState(CFuncSave *state);
|
||||
extern void CFunc_Gen(Statement *stmt, Object *obj, UInt8 unk);
|
||||
extern void CFunc_Gen(Statement *stmt, Object *func, UInt8 unk);
|
||||
extern void CFunc_CheckClassCtors(TypeClass *tclass);
|
||||
extern void CFunc_ParseFuncDef(Object *obj, DeclInfo *declinfo, TypeClass *tclass, Boolean is_method, Boolean is_static, NameSpace *nspace);
|
||||
extern void CFunc_ParseFuncDef(Object *func, DeclInfo *di, TypeClass *tclass, Boolean is_method, Boolean is_static, NameSpace *nspace);
|
||||
extern void InitExpr_Register(ENode *expr, Object *object);
|
||||
extern void CFunc_GenerateDummyFunction(Object *a);
|
||||
extern void CFunc_GenerateSingleExprFunc(Object *a, ENode *expr);
|
||||
extern void CFunc_GenerateDummyCtorFunc(Object *a, Object *b);
|
||||
extern void CFunc_GenerateDummyFunction(Object *func);
|
||||
extern void CFunc_GenerateSingleExprFunc(Object *func, ENode *expr);
|
||||
extern void CFunc_GenerateDummyCtorFunc(Object *func, Object *real_ctor);
|
||||
|
||||
#ifdef __MWERKS__
|
||||
#pragma options align=reset
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
typedef void (*ExprCB)(Type *type, ENode *expr, Boolean flag);
|
||||
typedef void (*InitExprRegisterCB)(ENode *expr);
|
||||
typedef void (*InsertExprCB)(ENode *expr);
|
||||
// fix last arg
|
||||
typedef ENode *(*RegisterObjectCB)(Type *type, Object *obj, SInt32 offset, void *);
|
||||
typedef ENode *(*RegisterObjectCB)(Type *type, Object *obj, SInt32 offset, Boolean flag);
|
||||
typedef ENode *(*TempNodeCB)(Type *type, Boolean flag);
|
||||
|
||||
struct OLinkList {
|
||||
|
|
|
@ -9,6 +9,22 @@
|
|||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
// 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];
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef struct CI_Var {
|
||||
HashNameNode *name;
|
||||
Type *type;
|
||||
|
@ -33,10 +49,10 @@ typedef struct CI_SwitchCase {
|
|||
|
||||
typedef struct CI_Switch {
|
||||
ENode *expr;
|
||||
void *unkSwitch8;
|
||||
Type *unkSwitch8;
|
||||
short defaultlabelID;
|
||||
short numcases;
|
||||
CI_SwitchCase cases[0];
|
||||
CI_SwitchCase cases[1];
|
||||
} CI_Switch;
|
||||
|
||||
typedef struct CI_Statement {
|
||||
|
|
|
@ -17,15 +17,15 @@ extern HashNameNode *CMangler_VBaseDtorName(void);
|
|||
extern HashNameNode *CMangler_ArrayDtorName(void);
|
||||
extern HashNameNode *CMangler_SDeleteDtorName(void);
|
||||
extern HashNameNode *CMangler_DeleteDtorName(void);
|
||||
extern char *CMangler_GetOperator(HashNameNode *opname);
|
||||
extern char *CMangler_GetOperator(HashNameNode *name);
|
||||
extern HashNameNode *CMangler_OperatorName(short token);
|
||||
extern HashNameNode *CMangler_VTableName(TypeClass *tclass);
|
||||
extern HashNameNode *CMangler_VTableName(TypeClass *theclass);
|
||||
extern HashNameNode *CMangler_RTTIObjectName(Type *type, UInt32 qual);
|
||||
extern HashNameNode *CMangler_ThunkName(Object *obj, int a, int b, int c);
|
||||
extern HashNameNode *CMangler_ThunkName(Object *vfunc, SInt32 this_delta, SInt32 return_delta, SInt32 ctoroffset);
|
||||
extern HashNameNode *CMangler_TemplateInstanceName(HashNameNode *basename, TemplArg *args);
|
||||
extern void CMangler_MangleType(Type *type, UInt32 qual);
|
||||
extern HashNameNode *CMangler_ConversionFuncName(Type *type, UInt32 qual);
|
||||
extern HashNameNode *CMangler_GetCovariantFunctionName(Object *obj, Type *type);
|
||||
extern HashNameNode *CMangler_GetCovariantFunctionName(Object *dobj, TypeClass *theclass);
|
||||
extern HashNameNode *CMangler_GetLinkName(Object *obj);
|
||||
|
||||
#ifdef __MWERKS__
|
||||
|
|
|
@ -77,7 +77,7 @@ typedef struct COpts {
|
|||
Boolean altivec_model;
|
||||
UInt8 altivec_vrsave;
|
||||
UInt8 code_alignment;
|
||||
char x1D;
|
||||
UInt8 x1D;
|
||||
UInt8 x1E; // some register used in TOC_use_isel
|
||||
UInt8 gen_fsel;
|
||||
Boolean ppc_opt_bclr_bcctr;
|
||||
|
@ -99,7 +99,7 @@ typedef struct COpts {
|
|||
Boolean objective_c;
|
||||
Boolean objc_strict;
|
||||
Boolean ARM_conform;
|
||||
char ARM_scoping;
|
||||
Boolean ARM_scoping;
|
||||
Boolean require_prototypes;
|
||||
Boolean trigraphs;
|
||||
Boolean only_std_keywords;
|
||||
|
@ -130,14 +130,14 @@ typedef struct COpts {
|
|||
Boolean flat_include;
|
||||
char syspath_once;
|
||||
Boolean always_import;
|
||||
char simple_class_byval;
|
||||
Boolean simple_class_byval;
|
||||
Boolean wchar_type;
|
||||
Boolean vbase_ctor_offset;
|
||||
char vbase_abi_v2;
|
||||
Boolean vbase_abi_v2;
|
||||
Boolean def_inherited;
|
||||
Boolean template_patch;
|
||||
char template_friends;
|
||||
char faster_pch_gen;
|
||||
Boolean faster_pch_gen;
|
||||
Boolean array_new_delete;
|
||||
Boolean dollar_identifiers;
|
||||
char def_inline_tfuncs;
|
||||
|
@ -146,7 +146,7 @@ typedef struct COpts {
|
|||
Boolean line_prepdump;
|
||||
Boolean fullpath_prepdump;
|
||||
char old_mtemplparser;
|
||||
char suppress_init_code;
|
||||
Boolean suppress_init_code;
|
||||
Boolean reverse_bitfields;
|
||||
Boolean c9x;
|
||||
Boolean float_constants;
|
||||
|
@ -166,15 +166,15 @@ typedef struct COpts {
|
|||
char microsoft;
|
||||
Boolean warningerrors;
|
||||
Boolean pedantic;
|
||||
char check_header_flags;
|
||||
Boolean check_header_flags;
|
||||
Boolean supress_warnings;
|
||||
Boolean warn_illpragma;
|
||||
Boolean warn_emptydecl;
|
||||
Boolean warn_possunwant;
|
||||
char warn_unusedvar;
|
||||
char warn_unusedarg;
|
||||
Boolean warn_unusedvar;
|
||||
Boolean warn_unusedarg;
|
||||
Boolean warn_extracomma;
|
||||
char warn_hidevirtual;
|
||||
Boolean warn_hidevirtual;
|
||||
Boolean warn_largeargs;
|
||||
Boolean warn_implicitconv;
|
||||
Boolean warn_notinlined;
|
||||
|
@ -182,7 +182,7 @@ typedef struct COpts {
|
|||
Boolean warn_padding;
|
||||
Boolean warn_no_side_effect;
|
||||
Boolean warn_resultnotused;
|
||||
char warn_ptr_int_conv;
|
||||
Boolean warn_ptr_int_conv;
|
||||
char align_mode;
|
||||
Boolean align_array_members;
|
||||
Boolean dont_reuse_strings;
|
||||
|
@ -208,16 +208,16 @@ typedef struct COpts {
|
|||
Boolean crippled;
|
||||
Boolean opt_common_subs;
|
||||
Boolean opt_loop_invariants;
|
||||
char opt_propagation;
|
||||
char opt_dead_assignments;
|
||||
Boolean opt_propagation;
|
||||
Boolean opt_dead_assignments;
|
||||
Boolean opt_strength_reduction;
|
||||
Boolean opt_strength_reduction_strict;
|
||||
char opt_dead_code;
|
||||
char opt_lifetimes;
|
||||
Boolean opt_dead_code;
|
||||
Boolean opt_lifetimes;
|
||||
char _B1; // unused?
|
||||
char opt_unroll_loops;
|
||||
Boolean opt_unroll_loops;
|
||||
char opt_vectorize_loops;
|
||||
char _B4; // amount of IRO passes?
|
||||
Boolean _B4; // amount of IRO passes?
|
||||
Boolean opt_pointer_analysis;
|
||||
unsigned char opt_pointer_analysis_mode;
|
||||
char loop_unroll_count;
|
||||
|
@ -386,8 +386,8 @@ extern Boolean is_const_object(Object *obj);
|
|||
extern Boolean is_volatile_object(Object *obj);
|
||||
extern Boolean CParserIsConstExpr(ENode *expr);
|
||||
extern Boolean CParserIsVolatileExpr(ENode *expr);
|
||||
extern Boolean CParser_HasInternalLinkage(Object *obj);
|
||||
extern Boolean CParser_HasInternalLinkage2(Object *obj);
|
||||
extern Boolean CParser_HasInternalLinkage(const Object *obj);
|
||||
extern Boolean CParser_HasInternalLinkage2(const Object *obj);
|
||||
extern Boolean CParser_IsVirtualFunction(Object *obj, TypeClass **tclass, SInt32 *index);
|
||||
extern Boolean is_pascal_object(Object *obj);
|
||||
extern Boolean is_cfm_type(Type *type);
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef COMPILER_CPREC_H
|
||||
#define COMPILER_CPREC_H
|
||||
|
||||
#include "compiler/common.h"
|
||||
|
||||
extern void SetupPrecompiler(void);
|
||||
extern void CleanupPrecompiler(void);
|
||||
extern void PreComp_StaticData(Object *obj, const void *data, OLinkList *links, SInt32 size);
|
||||
extern void PrecompilerWrite(void);
|
||||
extern void PrecompilerRead(short refnum, void *buffer);
|
||||
|
||||
#endif
|
|
@ -11,11 +11,11 @@
|
|||
struct Macro {
|
||||
Macro *next;
|
||||
HashNameNode *name;
|
||||
void *c;
|
||||
char *c;
|
||||
unsigned short xC;
|
||||
Boolean is_special;
|
||||
Boolean xF;
|
||||
void *e;
|
||||
HashNameNode *names[1];
|
||||
};
|
||||
typedef struct TokenStack {
|
||||
char *pos;
|
||||
|
@ -71,6 +71,7 @@ extern CPrepFileInfo *prep_file;
|
|||
extern short filesp;
|
||||
extern SInt32 linenumber;
|
||||
extern struct GList pplist;
|
||||
extern TStreamElement *ts_last;
|
||||
extern TStreamElement *ts_current;
|
||||
extern SInt32 ts_preread_elements;
|
||||
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
|
||||
extern short prepskipnextchar(void);
|
||||
extern short prepnextchar(void);
|
||||
extern short prepnextstringchar(char *str, Boolean flag);
|
||||
extern short prepnextstringchar(StringPtr str, Boolean flag);
|
||||
extern void CPrep_MatchChar(char ch, Boolean flag);
|
||||
extern char *CPrep_MatchChar2(char *start, char ch, Boolean flag);
|
||||
extern short prepcurchar(void);
|
||||
extern char *ReadIdentifier(char *p);
|
||||
extern char *CPrep_SkipNewComment(char *str);
|
||||
extern Boolean skipendoflinematch(char *str, short token);
|
||||
extern char *ReadIdentifier(const char *p);
|
||||
extern StringPtr CPrep_SkipNewComment(StringPtr str);
|
||||
extern Boolean skipendoflinematch(StringPtr str, short token);
|
||||
extern void skipendofline(void);
|
||||
extern void CPrep_SkipAsmComment(void);
|
||||
extern short lookahead(void);
|
||||
|
|
|
@ -57,7 +57,7 @@ extern void CScope_SetNameSpaceScope(NameSpace *nspace, CScopeSave *save);
|
|||
extern void CScope_SetClassScope(TypeClass *cls, CScopeSave *save);
|
||||
extern void CScope_SetClassDefScope(TypeClass *cls, CScopeSave *save);
|
||||
extern void CScope_SetFunctionScope(Object *function, CScopeSave *save);
|
||||
extern void CScope_SetMethodScope(Object *function, TypeClass *cls, Boolean unknownFlag, CScopeSave *save);
|
||||
extern void CScope_SetMethodScope(Object *function, TypeClass *cls, Boolean is_static, CScopeSave *save);
|
||||
extern void CScope_RestoreScope(CScopeSave *saved);
|
||||
extern Boolean CScope_IsEmptySymTable(void);
|
||||
extern Boolean CScope_IsInLocalNameSpace(NameSpace *nspace);
|
||||
|
|
|
@ -65,7 +65,7 @@ extern SInt32 CodeGen_objc_method_arg_offset(ObjCMethod *meth, ObjCMethodArg *ar
|
|||
extern SInt32 CodeGen_objc_method_args_size(ObjCMethod *meth);
|
||||
extern ENode *CodeGen_HandleIntrinsicCall(Object *func, ENodeList *arg_exprs);
|
||||
extern ENode *CodeGen_HandleTypeCast(ENode *expr, Type *type, UInt32 qual);
|
||||
extern short CodeGen_AssignCheck(ENode *expr, Type *type, Boolean flag1, Boolean flag2);
|
||||
extern short CodeGen_AssignCheck(const ENode *expr, const Type *type, Boolean flag1, Boolean flag2);
|
||||
extern Boolean CodeGen_CollapseVectorExpression(ENode *expr, MWVector128 *vec, Type *type);
|
||||
extern void CodeGen_InsertSpecialMacros(void);
|
||||
extern char *CodeGen_ExpandSpecialMacro(Macro *macro);
|
||||
|
|
|
@ -128,7 +128,7 @@ extern UInt32 CTool_EndianReadWord32(void *ptr);
|
|||
#define CTool_EndianConvertWord32(value) value
|
||||
#define CTool_EndianConvertWord16(value) value
|
||||
#define CTool_EndianConvertMem(data, len) ((void)0)
|
||||
#define CTool_EndianReadWord32(ptr) (*((UInt32 *) (ptr)))
|
||||
#define CTool_EndianReadWord32(ptr) (*((SInt32 *) (ptr)))
|
||||
#endif
|
||||
extern void CTool_EndianConvertWord64(CInt64 ci, char *result);
|
||||
extern UInt16 CTool_EndianConvertInPlaceWord16Ptr(UInt16 *x);
|
||||
|
|
|
@ -143,10 +143,10 @@ typedef struct PCAction {
|
|||
|
||||
extern EANode *DAG[EAT_NACTIONS];
|
||||
|
||||
extern void initializeexceptiontables(void);
|
||||
extern int countexceptionactionregisters(ExceptionAction *actions);
|
||||
extern void noteexceptionactionregisters(ExceptionAction *actions, PCodeArg *ops);
|
||||
extern void recordexceptionactions(PCode *instr, ExceptionAction *actions);
|
||||
extern void deleteexceptionaction(PCAction *pca);
|
||||
extern void dumpexceptiontables(Object *function, SInt32 codesize);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "compiler/common.h"
|
||||
|
||||
extern void InlineAsm_SkipComment();
|
||||
extern void InlineAsm_SkipComment(void);
|
||||
extern void InlineAsm_gcc_parse(void);
|
||||
|
||||
extern Statement *first_ST_ASM;
|
||||
|
|
|
@ -160,6 +160,11 @@ typedef struct IAEffect {
|
|||
SInt32 size;
|
||||
} IAEffect;
|
||||
|
||||
enum {
|
||||
IAMaxOperands = 16,
|
||||
IAMaxLabels = 16
|
||||
};
|
||||
|
||||
typedef struct IAEffects {
|
||||
Boolean x0;
|
||||
Boolean x1;
|
||||
|
@ -169,8 +174,8 @@ typedef struct IAEffects {
|
|||
Boolean x5;
|
||||
SInt32 numoperands;
|
||||
SInt32 numlabels;
|
||||
IAEffect operands[16];
|
||||
CLabel *labels[16];
|
||||
IAEffect operands[IAMaxOperands];
|
||||
CLabel *labels[IAMaxLabels];
|
||||
} IAEffects;
|
||||
|
||||
#ifdef __MWERKS__
|
||||
|
|
|
@ -4,6 +4,16 @@
|
|||
#include "compiler/common.h"
|
||||
#include "compiler/InlineAsm.h"
|
||||
|
||||
typedef enum AssemblerType {
|
||||
AssemblerType_0,
|
||||
AssemblerType_1
|
||||
} AssemblerType;
|
||||
|
||||
enum {
|
||||
NO_REG = 0,
|
||||
INVALID_PIC_REG = -2
|
||||
};
|
||||
|
||||
extern char asm_alloc_flags[10];
|
||||
extern Section sm_section;
|
||||
extern UInt32 cpu;
|
||||
|
@ -11,7 +21,7 @@ extern SInt32 fralloc_parameter_area_size;
|
|||
extern Boolean user_responsible_for_frame;
|
||||
extern Boolean supports_hardware_fpu;
|
||||
extern UInt32 assembledinstructions;
|
||||
extern UInt8 assembler_type;
|
||||
extern AssemblerType assembler_type;
|
||||
extern char volatileasm;
|
||||
extern Boolean InlineAsm_gccmode;
|
||||
extern Boolean InlineAsm_labelref;
|
||||
|
@ -68,8 +78,8 @@ enum {
|
|||
};
|
||||
|
||||
extern void InlineAsm_InitializePPC(void);
|
||||
extern void InlineAsm_Initialize(UInt8 assemblertype);
|
||||
extern SInt32 InlineAsm_IsDirective(UInt8 assemblertype);
|
||||
extern void InlineAsm_Initialize(AssemblerType assemblertype);
|
||||
extern SInt32 InlineAsm_IsDirective(AssemblerType assemblertype);
|
||||
extern void InlineAsm_ProcessDirective(SInt32 directive);
|
||||
extern void InlineAsm_ScanAssemblyDirective(void);
|
||||
extern void InlineAsm_ScanAssemblyInstruction(void);
|
||||
|
|
|
@ -22,7 +22,7 @@ extern Boolean IRO_CPFirstTime;
|
|||
extern Boolean VectorPhaseCalledFromUnroll;
|
||||
extern Boolean IRO_Log;
|
||||
|
||||
extern Statement *IRO_Optimizer(Object *obj, Statement *stmt);
|
||||
extern Statement *IRO_Optimizer(Object *func, Statement *statements);
|
||||
extern void IRO_Setup(void);
|
||||
extern void IRO_Cleanup(void);
|
||||
extern void CodeGen_UpdateOptimizerOptions(void);
|
||||
|
|
|
@ -3,8 +3,12 @@
|
|||
|
||||
#include "compiler/IrOptimizer.h"
|
||||
|
||||
// TODO
|
||||
extern void IRO_TruncateBitfieldValueToType(CInt64 *val, Type *type, Type *type2);
|
||||
extern void IRO_InitializeIsAssociativeENodeTypeArray(void);
|
||||
extern void IRO_TruncateValueToType(CInt64 *val, Type *type);
|
||||
extern void IRO_TruncateBitfieldValueToType(CInt64 *val, Type *type, Type *type2);
|
||||
extern void IRO_ConstantFolding(void);
|
||||
extern Boolean IRO_EvaluateConditionals(void);
|
||||
extern int IRO_SimplifyConditionals(void);
|
||||
extern Boolean IRO_EvaluateDefinitePointers(Object *func);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -157,7 +157,9 @@ 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
|
||||
|
|
|
@ -5,32 +5,32 @@
|
|||
#include "compiler/BitVector.h"
|
||||
|
||||
typedef enum IROLoopIndFlags {
|
||||
LoopInd_1 = 1,
|
||||
LoopInd_2 = 2,
|
||||
LoopInd_HasMod = 1,
|
||||
LoopInd_HasDiv = 2,
|
||||
LoopInd_4 = 4,
|
||||
LoopInd_8 = 8
|
||||
} IROLoopIndFlags;
|
||||
|
||||
typedef enum IROLoopFlags {
|
||||
LoopFlags_1 = 1,
|
||||
LoopFlags_1 = 1, // LP_INDUCTION_AT_LEFT
|
||||
LP_LOOP_HAS_CALLS = 2,
|
||||
LP_LOOP_HAS_CNTRLFLOW = 4,
|
||||
LoopFlags_8 = 8,
|
||||
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,
|
||||
LoopFlags_100 = 0x100,
|
||||
LoopFlags_200 = 0x200,
|
||||
LP_LOOP_STEP_ISADD = 0x100,
|
||||
LoopFlags_200 = 0x200, // LP_HEADER_FOLLOWS_UPDATE?
|
||||
LP_LOOP_STEP_ISPOS = 0x400,
|
||||
LoopFlags_800 = 0x800,
|
||||
LoopFlags_1000 = 0x1000,
|
||||
LoopFlags_2000 = 0x2000,
|
||||
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,
|
||||
LoopFlags_20000 = 0x20000,
|
||||
LoopFlags_40000 = 0x40000
|
||||
LoopFlags_10000 = 0x10000, // LP_WHILE_LOOP
|
||||
LoopFlags_20000 = 0x20000, // maybe LP_RECURSIVE_LOOP?
|
||||
LoopFlags_40000 = 0x40000 // LP_IS_REDUCTION_CAND
|
||||
} IROLoopFlags;
|
||||
|
||||
#ifdef __MWERKS__
|
||||
|
@ -50,10 +50,10 @@ struct IROLoop {
|
|||
SInt32 flags;
|
||||
IRONode *fnode;
|
||||
int x8;
|
||||
int xC;
|
||||
int x10;
|
||||
IRONode *xC;
|
||||
IRONode *x10;
|
||||
IROLinear *nd14; // assignment expression that sets the initial value of induction
|
||||
IROLinear *nd18;
|
||||
IROLinear *nd18; // ifexpr?
|
||||
IROLoopInd *induction;
|
||||
int index20;
|
||||
int index24;
|
||||
|
|
|
@ -13,7 +13,7 @@ extern Boolean PointerAnalysis_IsENodePointerExprDefinite(Object *proc, ENode *n
|
|||
extern Boolean PointerAnalysis_IsVariableValueDefinite(Object *proc, VarRecord *var, PointsToFunction *pointsTo);
|
||||
extern void PointerAnalysis_LookupLinearNodePointerExpr(Object *proc, IROLinear *indirect, IROListNode **list);
|
||||
extern void PointerAnalysis_LookupENodePointerExpr(Object *proc, ENode *indirect, ENodeList **list);
|
||||
extern void PointerAnalysis_LookupVariableIntoLinearNodeExprs(Object *proc, VarRecord *var, PointsToFunction *pointsTo, IROList **list);
|
||||
extern void PointerAnalysis_LookupVariableIntoLinearNodeExprs(Object *proc, VarRecord *var, PointsToFunction *pointsTo, IROListNode **list);
|
||||
extern void PointerAnalysis_LookupVariableIntoENodeExprs(Object *proc, VarRecord *var, PointsToFunction *pointsTo, ENodeList **list);
|
||||
extern void PointerAnalysis_GetFunctionKills(Object *proc, IROLinear *funccall, ObjectList **list);
|
||||
extern void PointerAnalysis_GetFunctionDependencies(Object *proc, IROLinear *funccall, ObjectList **list);
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
|
||||
#include "compiler/IrOptimizer.h"
|
||||
|
||||
// TODO
|
||||
extern Boolean IRO_TransformSelfAssignmentToAssignment(IROLinear *linear);
|
||||
extern void IRO_InitializeAssignmentOpArray(void);
|
||||
extern void IRO_InitializeComplementaryOpArray(void);
|
||||
extern void IRO_InitializeComplementaryOpLogicalArray(void);
|
||||
extern void IRO_DoTransformations(void);
|
||||
extern Boolean IRO_TransformSelfAssignmentToAssignment(IROLinear *nd);
|
||||
extern void IRO_TransformTree(Statement *statements);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,21 +2,22 @@
|
|||
#define COMPILER_IROUNROLLLOOP_H
|
||||
|
||||
#include "compiler/IrOptimizer.h"
|
||||
#include "compiler/IroLinearForm.h"
|
||||
|
||||
extern void IRO_LoopUnroller(void);
|
||||
extern void IRO_IterateForLoopBody();
|
||||
extern void IRO_LinearizeForLoopPostLoop();
|
||||
extern void BuildEarlyLoopExitTest();
|
||||
extern void BuildLoopExitTest();
|
||||
extern void IsIterationCountConstant();
|
||||
extern void NoOpBlock();
|
||||
extern void IRO_TestConstantIterationCount();
|
||||
extern void BuildOrigIterationCount();
|
||||
extern void BuildNewFinalvalue();
|
||||
extern void BuildUnrolledBodyEntryTest();
|
||||
extern void ChangeInductionReference();
|
||||
extern void UpdateInductionIncrement();
|
||||
extern void GenInitialAssignment();
|
||||
extern void GenNewInduction();
|
||||
extern void IRO_IterateForLoopBody(IRONode *start, IRONode *end, IROLoop *loop, IROLinear *destnode, SInt32 addConst, CInt64 *val, Boolean funkyFlag);
|
||||
extern void IRO_LinearizeForLoopPostLoop(IRONode *fnode1, IRONode *fnode2, IROLoop *loop, IRONode *fnode3, UInt32 unrollFactor);
|
||||
extern IROLinear *BuildEarlyLoopExitTest(IROLinearType type, IROList *list);
|
||||
extern IROLinear *BuildLoopExitTest(IROLinearType type, IROList *list);
|
||||
extern int IsIterationCountConstant(IROLoop *loop, CInt64 *pval);
|
||||
extern void NoOpBlock(IRONode *fnode);
|
||||
extern void IRO_TestConstantIterationCount(IROLoop *loop, CInt64 *iterCount, SInt32 vectorStride, UInt32 *unrollFactor, SInt32 *leftOver, UInt32 *needOrigLoop, UInt32 *needUnrollBodyTest, UInt32 *resetUnrolledFinalValue);
|
||||
extern IROLinear *BuildOrigIterationCount(IROList *list, IROLoop *loop);
|
||||
extern IROLinear *BuildNewFinalvalue(IROLinear *iterCount, UInt32 unrollFactor, IROList *list, IROLoop *loop);
|
||||
extern void BuildUnrolledBodyEntryTest(IROList *list, IROLinear *iterCount, UInt32 unrollFactor, CLabel *label);
|
||||
extern void ChangeInductionReference(IROLinear *first, IROLinear *last, CInt64 val, IROLoop *loop);
|
||||
extern IROLinear *UpdateInductionIncrement(IROLoop *loop, SInt32 value, IROLinear *before);
|
||||
extern void GenInitialAssignment(IROLoop *loop, Object *var, IROList *list);
|
||||
extern void GenNewInduction(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define COMPILER_IROUTIL_H
|
||||
|
||||
#include "compiler/IrOptimizer.h"
|
||||
#include "compiler/CInt64.h"
|
||||
#include "compiler/CParser.h"
|
||||
|
||||
#ifdef __MWERKS__
|
||||
|
@ -87,7 +88,7 @@ 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 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);
|
||||
|
@ -99,7 +100,7 @@ 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 IROLinear *IRO_NewFloatConst(const Float val, Type *type);
|
||||
extern Boolean IRO_IsAddressMultiply(IROLinear *linear);
|
||||
extern void IRO_SetupForUserBreakChecking(void);
|
||||
extern void IRO_CheckForUserBreak(void);
|
||||
|
@ -109,4 +110,18 @@ inline Boolean IRO_IsUnsignedType(Type *type) {
|
|||
return is_unsigned(type);
|
||||
}
|
||||
|
||||
// 4B4D40
|
||||
inline CInt64 IRO_MakeULong(UInt32 i) {
|
||||
CInt64 val;
|
||||
CInt64_SetULong(&val, i);
|
||||
return val;
|
||||
}
|
||||
|
||||
// 4BAAA0
|
||||
inline CInt64 IRO_MakeLong(SInt32 i) {
|
||||
CInt64 val;
|
||||
CInt64_SetLong(&val, i);
|
||||
return val;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -86,7 +86,7 @@ typedef struct InductionVar {
|
|||
extern Loop *loopsinflowgraph;
|
||||
extern int loopdetection_nblocks;
|
||||
extern BitVector *LoopTemp;
|
||||
extern void *LoopList_First;
|
||||
extern struct LoopList *LoopList_First;
|
||||
|
||||
extern void addblocktoloop(Loop *loop, PCodeBlock *block);
|
||||
extern void insertpreheaderblock(Loop *loop);
|
||||
|
|
|
@ -198,17 +198,18 @@ enum {
|
|||
};
|
||||
|
||||
enum {
|
||||
fPCBlockFlag1 = 1, // prologue
|
||||
fPCBlockFlag2 = 2, // epilogue
|
||||
fPCBlockFlag4 = 4,
|
||||
fPCBlockFlag8 = 8, // scheduled?
|
||||
fPCBlockFlag10 = 0x10,
|
||||
fPCBlockFlag20 = 0x20,
|
||||
fPCBlockFlag1 = 1, // fIsProlog
|
||||
fPCBlockFlag2 = 2, // fIsEpilogue
|
||||
fPCBlockFlag4 = 4, // fVisited
|
||||
fPCBlockFlag8 = 8, // fScheduled
|
||||
fPCBlockFlag10 = 0x10, // maybe fIsSwitch based off v3?
|
||||
fPCBlockFlag20 = 0x20, // fDeleted
|
||||
fPCBlockFlag2000 = 0x2000,
|
||||
fPCBlockFlag4000 = 0x4000,
|
||||
fPCBlockFlag6000 = 0x6000,
|
||||
fPCBlockFlag8000 = 0x8000
|
||||
};
|
||||
// v3 has fCCisLiveOnExit, fUnrolled, fAlignBlock
|
||||
|
||||
extern PCodeBlock *pcbasicblocks;
|
||||
extern PCodeBlock *pclastblock;
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
#pragma options align=mac68k
|
||||
#endif
|
||||
|
||||
enum ObjClass {
|
||||
typedef enum ObjClass {
|
||||
ObjClass0,
|
||||
ObjClass1,
|
||||
ObjClass2,
|
||||
ObjClassMax
|
||||
};
|
||||
} ObjClass;
|
||||
|
||||
extern Boolean requires_frame;
|
||||
extern Boolean makes_call;
|
||||
|
|
|
@ -18,7 +18,7 @@ typedef struct CaseRange {
|
|||
struct SwitchInfo {
|
||||
SwitchCase *cases;
|
||||
CLabel *defaultlabel;
|
||||
void *x8;
|
||||
Type *x8;
|
||||
};
|
||||
|
||||
extern ObjectList *switchtables;
|
||||
|
|
|
@ -13,13 +13,20 @@ typedef struct CodeLabelList {
|
|||
CLabel *label;
|
||||
} CodeLabelList;
|
||||
|
||||
typedef struct PoolEntry {
|
||||
struct PoolEntry *next;
|
||||
Object *object;
|
||||
SInt32 offset;
|
||||
void *buffer;
|
||||
} PoolEntry;
|
||||
|
||||
extern ObjectList *toclist;
|
||||
extern ObjectList *exceptionlist;
|
||||
extern void *descriptorlist;
|
||||
extern void *floatconstpool;
|
||||
extern void *doubleconstpool;
|
||||
extern PoolEntry *floatconstpool;
|
||||
extern PoolEntry *doubleconstpool;
|
||||
extern ObjectList *floatconstlist;
|
||||
extern void *vectorconstpool;
|
||||
extern PoolEntry *vectorconstpool;
|
||||
extern ObjectList *vectorconstlist;
|
||||
extern Object toc0;
|
||||
extern Boolean no_descriptors;
|
||||
|
@ -34,8 +41,8 @@ extern void referenceIndirectPointer(Object *obj);
|
|||
extern Object *createIndirect(Object *obj, Boolean flag1, Boolean flag2);
|
||||
extern Object *createfloatconstant(Type *type, Float *data);
|
||||
extern Object *createvectorconstant(Type *type, MWVector128 *data);
|
||||
extern void DeclarePooledConstants();
|
||||
extern Object *CreateFloatConst(Type *type, Float *data, SInt32 *unkptr);
|
||||
extern void DeclarePooledConstants(void);
|
||||
extern Object *CreateFloatConst(Type *type, Float *data, SInt32 *pOffset);
|
||||
extern void dumpcodelabels(Object *func);
|
||||
typedef struct COVCResult {
|
||||
// this struct might be used in other places too???
|
||||
|
|
|
@ -235,6 +235,7 @@ typedef enum TemplDepSubType {
|
|||
enum {
|
||||
Q_CONST = 1,
|
||||
Q_VOLATILE = 2,
|
||||
Q_CV = Q_CONST | Q_VOLATILE,
|
||||
Q_ASM = 4,
|
||||
Q_PASCAL = 8,
|
||||
Q_INLINE = 0x10,
|
||||
|
|
|
@ -230,6 +230,7 @@ enum {
|
|||
#define ENODE_IS2(_enode, _etype1, _etype2) ( ENODE_IS((_enode), (_etype1)) || ENODE_IS((_enode), (_etype2)) )
|
||||
#define ENODE_IS3(_enode, _etype1, _etype2, _etype3) ( ENODE_IS((_enode), (_etype1)) || ENODE_IS((_enode), (_etype2)) || ENODE_IS((_enode), (_etype3)) )
|
||||
#define ENODE_IS4(_enode, _etype1, _etype2, _etype3, _etype4) ( ENODE_IS((_enode), (_etype1)) || ENODE_IS((_enode), (_etype2)) || ENODE_IS((_enode), (_etype3)) || ENODE_IS((_enode), (_etype4)) )
|
||||
#define ENODE_IS5(_enode, _etype1, _etype2, _etype3, _etype4, _etype5) ( ENODE_IS((_enode), (_etype1)) || ENODE_IS((_enode), (_etype2)) || ENODE_IS((_enode), (_etype3)) || ENODE_IS((_enode), (_etype4)) || ENODE_IS((_enode), (_etype5)) )
|
||||
#define ENODE_IS_RANGE(_enode, _lo, _hi) ( ((_enode)->type >= (_lo)) && ((_enode)->type <= (_hi)) )
|
||||
#define ENODE_QUALS(_enode) ( (UInt32) ( (_enode)->flags & ENODE_FLAG_QUALS ) )
|
||||
#define ENODE_IS_INDIRECT_TO(_enode, _etype) ( ENODE_IS((_enode), EINDIRECT) && ENODE_IS((_enode)->data.monadic, (_etype)) )
|
||||
|
@ -288,6 +289,7 @@ enum {
|
|||
case EBCLR: \
|
||||
case EBSET
|
||||
|
||||
// 9 to 0x2F
|
||||
#define ENODE_CASE_DIADIC_ALL \
|
||||
case EMUL: \
|
||||
case EMULV: \
|
||||
|
|
|
@ -156,12 +156,12 @@ struct Object {
|
|||
TemplFuncInstance *inst;
|
||||
PTFList *ptfList;
|
||||
ObjectList *argList;
|
||||
} func;
|
||||
} func; // Used with DFUNC and DVFUNC
|
||||
struct {
|
||||
char *data;
|
||||
SInt32 size;
|
||||
InlineXRef *xrefs;
|
||||
} ifunc;
|
||||
} ifunc; // Used with DINLINEFUNC
|
||||
struct {
|
||||
VarInfo *info;
|
||||
SInt32 uid;
|
||||
|
@ -198,14 +198,6 @@ enum {
|
|||
OBJECT_FLAGS_60 = 0x60 // lib export
|
||||
};
|
||||
|
||||
enum {
|
||||
OBJECT_SCLASS_101 = 0x101,
|
||||
OBJECT_SCLASS_102 = 0x102,
|
||||
OBJECT_SCLASS_103 = 0x103,
|
||||
OBJECT_SCLASS_104 = 0x104,
|
||||
OBJECT_SCLASS_12B = 0x12B
|
||||
};
|
||||
|
||||
#define OBJ_BASE(obj) ((ObjBase *) (obj))
|
||||
#define OBJ_ENUM_CONST(obj) ((ObjEnumConst *) (obj))
|
||||
#define OBJ_TYPE(obj) ((ObjType *) (obj))
|
||||
|
@ -238,6 +230,8 @@ enum {
|
|||
VarInfoFlag80 = 0x80
|
||||
};
|
||||
|
||||
#define OBJECT_OR_ALIAS(_object) ( ((_object)->datatype == DALIAS) ? ((_object)->u.alias.object) : (_object) )
|
||||
|
||||
// placing these here until further notice
|
||||
|
||||
// unknown name, mwcppc.exe 7.0: 484870
|
||||
|
|
|
@ -142,8 +142,8 @@ struct ClassList { // checked via CPrec
|
|||
struct VClassList { // checked via CPrec
|
||||
VClassList *next;
|
||||
TypeClass *base;
|
||||
SInt32 offset;
|
||||
SInt32 voffset;
|
||||
SInt32 offset; // offset within the class instance
|
||||
SInt32 voffset; // offset within the vtable
|
||||
Boolean has_override;
|
||||
char alignsave;
|
||||
};
|
||||
|
@ -205,7 +205,7 @@ enum {
|
|||
CLASS_FLAGS_100 = 0x100, // is TemplClass
|
||||
CLASS_FLAGS_800 = 0x800, // is TemplClassInst
|
||||
CLASS_FLAGS_900 = 0x900,
|
||||
CLASS_FLAGS_1000 = 0x1000,
|
||||
CLASS_FLAGS_1000 = 0x1000, // is empty class
|
||||
CLASS_FLAGS_2000 = 0x2000,
|
||||
CLASS_FLAGS_4000 = 0x4000,
|
||||
CLASS_FLAGS_8000 = 0x8000
|
||||
|
@ -215,7 +215,8 @@ enum {
|
|||
enum {
|
||||
CLASS_EFLAGS_INTERNAL = 1,
|
||||
CLASS_EFLAGS_IMPORT = 2,
|
||||
CLASS_EFLAGS_EXPORT = 4
|
||||
CLASS_EFLAGS_EXPORT = 4,
|
||||
CLASS_EFLAGS_F0 = 0xF0
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -269,8 +270,10 @@ enum {
|
|||
FUNC_FLAGS_4000 = 0x4000, // objc method?
|
||||
FUNC_FLAGS_CONST = 0x8000,
|
||||
FUNC_FLAGS_VOLATILE = 0x10000,
|
||||
FUNC_FLAGS_CV = FUNC_FLAGS_CONST | FUNC_FLAGS_VOLATILE,
|
||||
FUNC_FLAGS_100000 = 0x100000, // is template?
|
||||
FUNC_FLAGS_200000 = 0x200000,
|
||||
FUNC_FLAGS_400000 = 0x400000, // covariant?
|
||||
FUNC_FLAGS_800000 = 0x800000,
|
||||
FUNC_FLAGS_900000 = 0x900000,
|
||||
FUNC_FLAGS_4000000 = 0x4000000,
|
||||
|
@ -412,10 +415,12 @@ struct TypeList {
|
|||
#define IS_TYPE_INT_OR_FLOAT(ty) ( IS_TYPE_INT(ty) || IS_TYPE_FLOAT(ty) )
|
||||
#define IS_TYPE_STRUCT(ty) ( (ty)->type == TYPESTRUCT )
|
||||
#define IS_TYPE_CLASS(ty) ( (ty)->type == TYPECLASS )
|
||||
#define IS_TYPE_SOM_CLASS(ty) ( (ty)->type == TYPECLASS && TYPE_CLASS((ty))->sominfo )
|
||||
#define IS_TYPE_OBJC_CLASS(ty) ( (ty)->type == TYPECLASS && TYPE_CLASS((ty))->objcinfo )
|
||||
#define IS_TYPE_FUNC(ty) ( (ty)->type == TYPEFUNC )
|
||||
#define IS_TYPEFUNC_METHOD(ty) ( (ty)->flags & FUNC_FLAGS_METHOD )
|
||||
#define IS_TYPE_METHOD(ty) ( IS_TYPE_FUNC(ty) && IS_TYPEFUNC_METHOD(TYPE_FUNC(ty)) )
|
||||
#define IS_TYPE_NONMETHOD(ty) ( IS_TYPE_FUNC(ty) && !IS_TYPEFUNC_METHOD(TYPE_FUNC(ty)) )
|
||||
#define IS_TYPE_NONSTATIC_METHOD(ty) ( IS_TYPE_FUNC(ty) && IS_TYPEFUNC_METHOD(TYPE_FUNC(ty)) && !TYPE_METHOD(ty)->x26 )
|
||||
#define IS_TYPE_STATIC_METHOD(ty) ( IS_TYPE_FUNC(ty) && IS_TYPEFUNC_METHOD(TYPE_FUNC(ty)) && TYPE_METHOD(ty)->x26 )
|
||||
#define IS_TYPEFUNC_NONSTATIC_METHOD(ty) ( IS_TYPEFUNC_METHOD(ty) && !TYPE_METHOD(ty)->x26 )
|
||||
|
@ -428,7 +433,7 @@ struct TypeList {
|
|||
#define IS_TYPE_ARRAY(ty) ( (ty)->type == TYPEARRAY )
|
||||
#define IS_TYPE_BITFIELD(ty) ( (ty)->type == TYPEBITFIELD )
|
||||
#define IS_TYPE_TEMPLDEPEXPR(ty) ( (ty)->type == TYPETEMPLDEPEXPR )
|
||||
#define IS_TYPESTRUCT_VECTOR(ty) ( TYPE_STRUCT(ty)->stype >= STRUCT_TYPE_4 && TYPE_STRUCT(ty)->stype <= STRUCT_TYPE_E )
|
||||
#define IS_TYPESTRUCT_VECTOR(ty) ( (ty)->stype >= STRUCT_TYPE_4 && (ty)->stype <= STRUCT_TYPE_E )
|
||||
#define IS_TYPE_VECTOR(ty) ( (ty)->type == TYPESTRUCT && IS_TYPESTRUCT_VECTOR(TYPE_STRUCT(ty)) )
|
||||
#define IS_TYPE_NONVECTOR_STRUCT(ty) ( (ty)->type == TYPESTRUCT && !IS_TYPESTRUCT_VECTOR(TYPE_STRUCT(ty)) )
|
||||
#define IS_TYPE_MEMBERPOINTER(ty) ( (ty)->type == TYPEMEMBERPOINTER )
|
||||
|
|
|
@ -22,7 +22,7 @@ extern SInt32 COS_GetTicks();
|
|||
extern SInt32 COS_GetTime();
|
||||
extern void COS_GetString(char *buffer, SInt16 strListID, SInt16 index);
|
||||
extern void COS_GetPString(StringPtr buffer, SInt16 strListID, SInt16 index);
|
||||
extern Boolean COS_IsMultiByte(const char *str1, const char *str2);
|
||||
extern Boolean COS_IsMultiByte(const void *str1, const void *str2);
|
||||
extern OSErr COS_FileNew(const FSSpec *spec, SInt16 *refNum, OSType creator, OSType fileType);
|
||||
extern OSErr COS_FileOpen(const FSSpec *spec, SInt16 *refNum);
|
||||
extern OSErr COS_FileGetType(const FSSpec *spec, OSType *fileType);
|
||||
|
|
70
notes
70
notes
|
@ -1,5 +1,15 @@
|
|||
~/bin/mwccppc -c -g -opt l=4,noschedule,speed -enum min -Iincludes -Isdk_hdrs -w all,nounused -wchar_t on -bool off -Cpp_exceptions off
|
||||
|
||||
TODO:
|
||||
- rename LiveInfo to LiveVariables
|
||||
- locate COS stuff based off EPPC 8 debug info
|
||||
- command_line/C++_Parser/Src/Library/OptimizerHelpers.c
|
||||
- compiler_and_linker/CmdLine_Tools/Embedded_PPC/Tools_EPPC/Src/Options/Glue/TargetOptimizerHelpers-eppc.c
|
||||
- compiler_and_linker/FrontEnd/Common/COSToolsMemory.h
|
||||
- compiler_and_linker/FrontEnd/Common/COSToolsFileSpecs.h
|
||||
- compiler_and_linker/FrontEnd/Common/COSToolsWin32.c
|
||||
also worth checking ~/s/mwcc/reversing/ftp_backup/Metrowerks/CWPPC6/ext_65/Disk1/PPC_EABI_Tools-CLT/mwcceppc.exe strings
|
||||
|
||||
* - has issues
|
||||
|
||||
[CL / command_line]
|
||||
|
@ -58,52 +68,52 @@ DONE compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-ma
|
|||
---- WarningHelpers.c
|
||||
|
||||
DONE CCompiler.c
|
||||
STUB CParser.c
|
||||
99% CParser.c
|
||||
DONE compiler_and_linker/FrontEnd/Common/CompilerTools.c (except for endian work)
|
||||
---- CodeGenOptPPC.c
|
||||
---- IrOptimizer.c
|
||||
PART CodeGen.c
|
||||
DONE CodeGenOptPPC.c
|
||||
99% IrOptimizer.c
|
||||
90% CodeGen.c
|
||||
MOST CPrep.c
|
||||
MOST CScope.c
|
||||
MOST CMachine.c
|
||||
STUB CExpr.c
|
||||
STUB CFunc.c
|
||||
DONE CExpr.c
|
||||
90% CFunc.c
|
||||
99% CTemplateNew.c
|
||||
STUB CError.c
|
||||
DONE CError.c
|
||||
95% ObjGenMachO.c
|
||||
STUB CDecl.c
|
||||
85% CDecl.c
|
||||
DONE CMangler.c
|
||||
99% CSOM.c
|
||||
STUB CABI.c
|
||||
STUB CInit.c
|
||||
STUB CClass.c
|
||||
95% CABI.c
|
||||
97% CInit.c
|
||||
95% CClass.c
|
||||
DONE CIRTransform.c
|
||||
99% CObjC.c
|
||||
97% CInline.c
|
||||
PART CPrepTokenizer.c
|
||||
99% CPrepTokenizer.c
|
||||
DONE CTemplateTools.c
|
||||
MOST IroPointerAnalysis.c
|
||||
80% IroPointerAnalysis.c
|
||||
PART InstrSelection.c
|
||||
PART IroFlowgraph.c
|
||||
99% IroFlowgraph.c
|
||||
DONE IroLinearForm.c
|
||||
MOST IroUtil.c
|
||||
MOST IroCSE.c
|
||||
99% IroUtil.c
|
||||
90% IroCSE.c
|
||||
DONE IroPropagate.c
|
||||
MOST IROUseDef.c
|
||||
MOST InlineAsmPPC.c
|
||||
95% IROUseDef.c
|
||||
99% InlineAsmPPC.c
|
||||
99% IroDump.c
|
||||
---- IroTransform.c
|
||||
MOST IroVars.c
|
||||
---- IroEval.c
|
||||
DONE IroTransform.c
|
||||
95% IroVars.c
|
||||
DONE IroEval.c
|
||||
DONE IroJump.c
|
||||
99% IroRangePropagation.c
|
||||
DONE IroEmptyLoop.c
|
||||
---- IroUnrollLoop.c
|
||||
DONE IroUnrollLoop.c
|
||||
99% IroLoop.c
|
||||
90% IroExprRegeneration.c
|
||||
DONE IroSubable.c
|
||||
MOST RegisterInfo.c
|
||||
MOST TOC.c
|
||||
DONE RegisterInfo.c
|
||||
90% TOC.c
|
||||
MOST StackFrame.c
|
||||
DONE Registers.c
|
||||
DONE PCode.c
|
||||
|
@ -122,16 +132,16 @@ DONE Coloring.c
|
|||
90% PCodeAssembly.c
|
||||
99% Intrinsics.c
|
||||
DONE PPCError.c
|
||||
STUB CExpr2.c
|
||||
95% CExpr2.c
|
||||
DONE* CInt64.c
|
||||
PART CPrec.c
|
||||
90% CPrec.c
|
||||
99% CBrowse.c
|
||||
DONE CPreprocess.c
|
||||
95%? FuncLevelAsmPPC.c
|
||||
99% CException.c
|
||||
99% CTemplateClass.c
|
||||
95% ScanFloat.c
|
||||
---- CExprConvMatch.c
|
||||
95% CExprConvMatch.c
|
||||
98% CRTTI.c
|
||||
DONE CObjCModern.c
|
||||
DONE InlineAsm.c
|
||||
|
@ -169,7 +179,7 @@ DONE ?? computelivevariables, dead
|
|||
---- MachineSimulation821.c
|
||||
99% InterferenceGraph.c
|
||||
99% SpillCode.c
|
||||
---- GCCInlineAsm.c
|
||||
DONE GCCInlineAsm.c
|
||||
DONE BitVectors.c
|
||||
|
||||
[Parser]
|
||||
|
@ -189,9 +199,13 @@ DONE* (debug) Utils.c
|
|||
DONE# (debug) Parameter.c
|
||||
DONE# (debug) Help.c
|
||||
DONE uContext1.cpp
|
||||
-- command_line\PluginLib\Src\Library\CWPluginsPrivate.cpp
|
||||
DONE uContextCL.cpp
|
||||
-- command_line\PluginLib\Src\Library\DropInCompilerLinkerPrivate.cpp
|
||||
DONE uContextSecret.cpp
|
||||
-- command_line\PluginLib\Src\Internal\CWSecretPluginCallbacks.cpp
|
||||
DONE* ?? COS
|
||||
DONE uContextParser.cpp
|
||||
-- command_line\PluginLib\Src\Library\CWParserPluginsPrivate.cpp
|
||||
DONE uLibImporter.c
|
||||
---- Various MSL objects
|
||||
|
|
|
@ -140,7 +140,7 @@ void COS_GetPString(StringPtr buffer, SInt16 strListID, SInt16 index) {
|
|||
GetIndString((StringPtr) buffer, strListID, index);
|
||||
}
|
||||
|
||||
Boolean COS_IsMultiByte(const char *str1, const char *str2) {
|
||||
Boolean COS_IsMultiByte(const void *str1, const void *str2) {
|
||||
return OS_IsMultiByte(str1, str2);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue