diff options
author | Ash Wolf <ninji@wuffs.org> | 2022-11-20 00:07:22 -0500 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2022-11-20 00:07:22 -0500 |
commit | 9d2728a5605f651934fe67a6fe6986b3e4a2c011 (patch) | |
tree | e81e0a3588a0c8d1855bf28316efe27d86b04d66 /includes | |
parent | 9a46dd0e2e80790d9848c0bbd718932a27c23269 (diff) | |
download | MWCC-9d2728a5605f651934fe67a6fe6986b3e4a2c011.tar.gz MWCC-9d2728a5605f651934fe67a6fe6986b3e4a2c011.zip |
add a bunch of code and a ton of stub files for later
Diffstat (limited to 'includes')
98 files changed, 1943 insertions, 795 deletions
diff --git a/includes/compiler.h b/includes/compiler.h index 6557749..cea535f 100644 --- a/includes/compiler.h +++ b/includes/compiler.h @@ -32,113 +32,6 @@ struct InlineXRef { -typedef enum ExceptionActionType { - EAT_NOP, - EAT_DESTROYLOCAL, - EAT_DESTROYLOCALCOND, - EAT_DESTROYLOCALOFFSET, - EAT_DESTROYLOCALPOINTER, - EAT_DESTROYLOCALARRAY, - EAT_DESTROYPARTIALARRAY, - EAT_DESTROYMEMBER, - EAT_DESTROYMEMBERCOND, - EAT_DESTROYMEMBERARRAY, - EAT_DELETEPOINTER, - EAT_DELETELOCALPOINTER, - EAT_DELETEPOINTERCOND, - EAT_CATCHBLOCK, - EAT_ACTIVECATCHBLOCK, - EAT_SPECIFICATION, - EAT_TERMINATE, - EAT_DESTROYBASE, - EAT_NACTIONS -} ExceptionActionType; - -struct ExceptionAction { - ExceptionAction *prev; - union { - struct { - Object *local; - Object *dtor; - } destroy_local; - struct { - Object *local; - Object *cond; - Object *dtor; - } destroy_local_cond; - struct { - Object *local; - Object *dtor; - SInt32 offset; - } destroy_local_offset; - struct { - Object *pointer; - Object *dtor; - } destroy_local_pointer; - struct { - Object *localarray; - Object *dtor; - SInt32 elements; - SInt32 element_size; - } destroy_local_array; - struct { - Object *arraypointer; - Object *arraycounter; - Object *dtor; - Object *element_size; - } destroy_partial_array; - struct { - Object *objectptr; - Object *dtor; - SInt32 offset; - } destroy_member; - struct { - Object *objectptr; - Object *cond; - Object *dtor; - SInt32 offset; - } destroy_member_cond; - struct { - Object *objectptr; - Object *dtor; - SInt32 offset; - SInt32 elements; - SInt32 element_size; - } destroy_member_array; - struct { - Object *pointerobject; - Object *deletefunc; - } delete_pointer; - struct { - Object *pointerobject; - Object *deletefunc; - Object *cond; - } delete_pointer_cond; - struct { - Object *catch_object; - Object *catch_info_object; - CLabel *catch_label; - Object *catch_typeid; - Type *catch_type; - UInt32 catch_qual; - } catch_block; - struct { - Object *catch_info_object; - Boolean call_dtor; - } active_catch_block; - struct { - SInt32 unexp_ids; - Object **unexp_id; - CLabel *unexp_label; - Object *unexp_info_object; - } specification; - struct { - Object *object; - Boolean is_dep; - } local; - } data; - ExceptionActionType type; -}; struct MemInitializer { MemInitializer *next; @@ -211,89 +104,8 @@ typedef struct Substitution { } Substitution; // Registers.c -enum { - RegisterMax = 32 -}; -const char RegClass_SPR = 0; -const char RegClass_CRFIELD = 1; -const char RegClass_VR = 2; -const char RegClass_FPR = 3; -const char RegClass_GPR = 4; -const char RegClassMax = 5; -/*enum RegClass { - RegClass_SPR, - RegClass_CRFIELD, - RegClass_VR, - RegClass_FPR, - RegClass_GPR, - RegClassMax -};*/ - -enum { - RegState0 = 0, - RegState1 = 1, - RegState2 = 2 -}; - -extern int used_virtual_registers[RegClassMax]; -extern int used_nonvolatile_registers[RegClassMax]; -extern int assignable_registers[RegClassMax]; -extern int n_real_registers[RegClassMax]; -extern int n_scratch_registers[RegClassMax]; -extern int scratch_registers[RegClassMax][RegisterMax]; -extern int n_nonvolatile_registers[RegClassMax]; -extern int nonvolatile_registers[RegClassMax][RegisterMax]; -extern UInt8 reg_state[RegClassMax][RegisterMax]; -extern int first_temporary_register[RegClassMax]; -extern int last_temporary_register[RegClassMax]; -extern char *register_class_name[RegClassMax]; -extern char *register_class_format[RegClassMax]; -extern int coloring; -extern int optimizing; - -extern void init_registers(); -extern void assign_register_to_variable(Object *obj, char rclass); -extern void retain_register_for_argument(Object *obj, char rclass, short reg); -extern int available_registers(char rclass); -extern UInt32 volatile_registers(char rclass); -extern short obtain_nonvolatile_register(char rclass); -extern void open_temp_registers(); -extern void check_temp_registers(); -extern void close_temp_registers(); -extern int count_scratch_registers(); -extern void init_modified_registers(); -extern void note_modified_registers(Object *obj); -extern void find_modified_registers(Object *obj, UInt32 *masks); // RegisterInfo.c -extern short last_exception_register[RegClassMax]; -extern short first_fe_temporary_register[RegClassMax]; -extern short last_argument_register[RegClassMax]; -extern short _FP_; -extern short _CALLER_SP_; -extern char *special_register_names[RegClassMax][RegisterMax]; -extern short spr_to_sysreg[4]; - -extern void asm_used_register(char rclass, short reg); -extern void retain_register(Object *obj, char rclass, short reg); -extern void retain_GPR_pair(Object *obj, short reg, short regHi); -extern int is_register_object(Object *obj); -extern int GetABIFirstNonVolatile(char rclass); -extern char GetRegisterClassName(char rclass); -extern void setup_diagnostic_reg_strings(); -extern void init_target_registers(); -extern void assign_register_by_type(Object *obj); -extern void assign_GPR_pair(Object *obj); -extern void open_fe_temp_registers(); -extern void set_last_exception_registers(); -extern VarInfo *Registers_GetVarInfo(Object *obj); -extern int used_vrstate_VRs(); -extern UInt32 colored_vrs_as_vrsave(PCodeBlock *block); -extern void save_before_coloring_nonvolatile_registers(char rclass); -extern void reset_nonvolatile_registers(char rclass); -extern int is_nonvolatile_register(char rclass, int reg); -extern void init_endian(); -extern void update_asm_nonvolatile_registers(); // LOOSE DECLS extern short high_offset; @@ -453,42 +265,8 @@ enum { INTRINSIC_36 = 36 }; -enum { - CPU_PPC401, - CPU_PPC403, - CPU_PPC505, - CPU_PPC509, - CPU_PPC555, - CPU_PPC601, - CPU_PPC602, - CPU_PPC603, - CPU_PPC603e, - CPU_PPC604, - CPU_PPC604e, - CPU_PPC740, - CPU_PPC750, - CPU_PPC801, - CPU_PPC821, - CPU_PPC823, - CPU_PPC850, - CPU_PPC860, - CPU_PPC8240, - CPU_PPC8260, - CPU_PPC7400 = 0x15, - CPU_PPCGEKKO, - CPU_PPCELF, - CPU_PPC7450, - CPU_PPC556, - CPU_PPC565 -}; - extern char *ScanFloat(char *input, double *output, Boolean *fail); -#define FITS_IN_SHORT(value) ( (value) == ((short) (value)) ) -// should HIGH_PART have (short) around it? -#define HIGH_PART(value) ( (((value) >> 16) + (((value) & 0x8000) >> 15)) ) -#define LOW_PART(value) ( (short) (value) ) - #ifdef __MWERKS__ #pragma options align=reset #endif diff --git a/includes/compiler/AddPropagation.h b/includes/compiler/AddPropagation.h new file mode 100644 index 0000000..1f4b94a --- /dev/null +++ b/includes/compiler/AddPropagation.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_ADDPROPAGATION_H +#define COMPILER_ADDPROPAGATION_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/Alias.h b/includes/compiler/Alias.h new file mode 100644 index 0000000..39f7220 --- /dev/null +++ b/includes/compiler/Alias.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_ALIAS_H +#define COMPILER_ALIAS_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/BitVectors.h b/includes/compiler/BitVectors.h new file mode 100644 index 0000000..7849dcb --- /dev/null +++ b/includes/compiler/BitVectors.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_BITVECTORS_H +#define COMPILER_BITVECTORS_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/CABI.h b/includes/compiler/CABI.h index fde5b21..8f0d3f4 100644 --- a/includes/compiler/CABI.h +++ b/includes/compiler/CABI.h @@ -8,7 +8,7 @@ #pragma options align=mac68k #endif -extern short CABI_GetStructResultArgumentIndex(void); +extern short CABI_GetStructResultArgumentIndex(TypeFunc *tfunc); extern Type *CABI_GetSizeTType(void); extern Type *CABI_GetPtrDiffTType(void); extern SInt16 CABI_StructSizeAlignValue(Type *type, SInt32 size); diff --git a/includes/compiler/CBrowse.h b/includes/compiler/CBrowse.h new file mode 100644 index 0000000..2bcfb51 --- /dev/null +++ b/includes/compiler/CBrowse.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_CBROWSE_H +#define COMPILER_CBROWSE_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/CClass.h b/includes/compiler/CClass.h index edefa92..083588c 100644 --- a/includes/compiler/CClass.h +++ b/includes/compiler/CClass.h @@ -25,7 +25,7 @@ extern ENode *CClass_DefaultConstructorCall(TypeClass *a, TypeClass *b, ENode *e extern Object *CClass_AssignmentOperator(TypeClass *tclass); extern Object *CClass_CopyConstructor(TypeClass *tclass); extern NameSpaceObjectList *CClass_MemberObject(TypeClass *tclass, HashNameNode *name); -extern Object *CClass_Constructor(TypeClass *tclass); +extern NameSpaceObjectList *CClass_Constructor(TypeClass *tclass); extern Object *CClass_Destructor(TypeClass *tclass); extern Boolean CClass_IsConstructor(Object *obj); extern Boolean CClass_IsDestructor(Object *obj); diff --git a/includes/compiler/CCompiler.h b/includes/compiler/CCompiler.h new file mode 100644 index 0000000..92b483c --- /dev/null +++ b/includes/compiler/CCompiler.h @@ -0,0 +1,14 @@ +#ifndef COMPILER_CCOMPILER_H +#define COMPILER_CCOMPILER_H + +#include "compiler/common.h" + +extern Boolean systemHandles; +extern Boolean crippled; +extern SInt32 license_cookie; +extern CParams cparams; + +extern CWPLUGIN_ENTRY(MWC_main)(CWPluginContext context); +extern void PrintProgressFunction(const char *str); + +#endif diff --git a/includes/compiler/CException.h b/includes/compiler/CException.h new file mode 100644 index 0000000..0a4d60d --- /dev/null +++ b/includes/compiler/CException.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_CEXCEPTION_H +#define COMPILER_CEXCEPTION_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/CExpr.h b/includes/compiler/CExpr.h index a82e56e..24f0646 100644 --- a/includes/compiler/CExpr.h +++ b/includes/compiler/CExpr.h @@ -45,19 +45,26 @@ typedef struct Match5 { } Match5; typedef struct Match13 { - short x0; - short x2; - short x4; - short x6; - short x8; - short xA; - short xC; + Object *obj; + Match5 anotherm5; short xE; Match5 match5; + ObjectList *list; } Match13; +typedef struct FuncMatchArgs { + ENodeList *exprs; + FuncArg *args; +} FuncMatchArgs; + +typedef struct Conversion { + ENode *x0; + ENode *left; + ENode *right; +} Conversion; + // CExpr.c -extern Boolean (*name_obj_check)(void *, Object *); // TODO figure out the right type +extern Boolean (*name_obj_check)(HashNameNode *, Object *); extern Boolean disallowgreaterthan; // CExpr2.c @@ -65,63 +72,63 @@ extern ENode *assign_node; extern Boolean temp_reference_init; // CExpr.c -extern void CExpr_RewriteConst(); +extern ENode *CExpr_RewriteConst(ENode *expr); extern void optimizecomm(ENode *expr); extern short canadd(ENode *expr, SInt32 value); extern ENode *checkreference(ENode *expr); extern ENode *pointer_generation(ENode *expr); -extern void CExpr_PointerGeneration(); -extern void oldassignmentpromotion(); +extern ENode *CExpr_PointerGeneration(ENode *expr); +extern ENode *oldassignmentpromotion(ENode *expr, Type *type, short qual, Boolean flag); extern ENode *argumentpromotion(ENode *expr, Type *type, short qual, Boolean flag); extern ENode *classargument(ENode *expr); -extern ENodeList *CExpr_ScanExpressionList(Boolean flag); -extern void CExpr_DoExplicitConversion(); -extern void CExpr_MakeNameLookupResultExpr(); -extern void scansizeof(); -extern void scanalignof(); +extern ENodeList *CExpr_ScanExpressionList(Boolean is_parens); +extern ENode *CExpr_DoExplicitConversion(Type *type, UInt32 qual, ENodeList *list); +extern ENode *CExpr_MakeNameLookupResultExpr(CScopeParseResult *pr); +extern SInt32 scansizeof(void); +extern SInt32 scanalignof(void); extern ENode *getnodeaddress(ENode *expr, Boolean flag); -extern void getpointertomemberfunc(); -extern void CExpr_New_ELOGNOT_Node(); -extern void CExpr_New_EMONMIN_Node(); -extern void CExpr_New_EBINNOT_Node(); +extern ENode *getpointertomemberfunc(ENode *expr, Type *type, Boolean flag); +extern ENode *CExpr_New_ELOGNOT_Node(ENode *expr); +extern ENode *CExpr_New_EMONMIN_Node(ENode *expr); +extern ENode *CExpr_New_EBINNOT_Node(ENode *expr); extern ENode *unary_expression(void); -extern ENode *do_castnullcheck(ENode *a, ENode *b); -extern void CExpr_SafeClassPointerCast(); +extern ENode *do_castnullcheck(ENode *condexpr, ENode *nullcheckexpr); +extern ENode *CExpr_SafeClassPointerCast(ENode *expr, TypeClass *a, TypeClass *b, Boolean typconflag, Boolean pathcheckflag); extern ENode *PointerToMemberCast(ENode *expr, TypeMemberPointer *tm1, TypeMemberPointer *tm2, Boolean flag); -extern void CExpr_MemberPointerConversion(); +extern ENode *CExpr_MemberPointerConversion(ENode *expr, TypeMemberPointer *type, Boolean flag1); extern ENode *do_typecast(ENode *expr, Type *type, UInt32 qual); -extern void cast_expression(); -extern void CExpr_New_EMUL_Node(); -extern void CExpr_New_EDIV_Node(); -extern void CExpr_New_EMODULO_Node(); -extern void CExpr_New_EADD_Node(); -extern void CExpr_New_ESUB_Node(); -extern void CExpr_New_ESHL_Node(); -extern void CExpr_New_ESHR_Node(); -extern void CExpr_New_ELESS_Node(); -extern void CExpr_New_ELESSEQU_Node(); -extern void CExpr_New_EGREATER_Node(); -extern void CExpr_New_EGREATEREQU_Node(); +extern ENode *cast_expression(void); +extern ENode *CExpr_New_EMUL_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_EDIV_Node(ENode *left, ENode *right, Boolean no_warning); +extern ENode *CExpr_New_EMODULO_Node(ENode *left, ENode *right, Boolean no_warning); +extern ENode *CExpr_New_EADD_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_ESUB_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_ESHL_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_ESHR_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_ELESS_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_ELESSEQU_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_EGREATER_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_EGREATEREQU_Node(ENode *left, ENode *right); extern ENode *memberpointercompare(ENodeType t, ENode *left, ENode *right); -extern void CExpr_New_EEQU_Node(); -extern void CExpr_New_ENOTEQU_Node(); -extern void CExpr_New_EAND_Node(); -extern void CExpr_New_EXOR_Node(); -extern void CExpr_New_EOR_Node(); -extern void CExpr_New_ELAND_Node(); -extern void CExpr_New_ELOR_Node(); -extern void CExpr_NewDyadicNode(); -extern void CExpr_New_ECOND_Node(); +extern ENode *CExpr_New_EEQU_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_ENOTEQU_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_EAND_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_EXOR_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_EOR_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_ELAND_Node(ENode *left, ENode *right); +extern ENode *CExpr_New_ELOR_Node(ENode *left, ENode *right); +extern ENode *CExpr_NewDyadicNode(ENode *left, ENodeType nt, ENode *right); +extern ENode *CExpr_New_ECOND_Node(ENode *cond, ENode *expr1, ENode *expr2); extern ENode *assignment_expression(void); extern ENode *conv_assignment_expression(void); -extern void CExpr_CheckUnusedExpression(); -extern void s_expression(); +extern void CExpr_CheckUnusedExpression(ENode *expr); +extern ENode *s_expression(void); extern ENode *expression(void); extern CInt64 CExpr_IntegralConstExprType(Type **tint); extern ENode *CExpr_IntegralConstOrDepExpr(void); extern CInt64 CExpr_IntegralConstExpr(void); -extern void CExpr_CheckUnwantedAssignment(); -extern void CExpr_ParseAsmExpr(); +extern void CExpr_CheckUnwantedAssignment(ENode *expr); +extern Boolean CExpr_ParseAsmExpr(Object **objptr, CInt64 *valptr); // CExpr2.c typedef void (*CExprSearchCB)(ENode *expr); @@ -170,24 +177,24 @@ extern ENode *CExpr_GetClassAccessNode(BClassList *a, BClassList *b, ENode *expr extern ENode *CExpr_ConvertToBool(ENode *expr, Boolean flag); extern void CExpr_ConversionIteratorInit(ConversionIterator *iter, TypeClass *tclass); extern Object *CExpr_ConversionIteratorNext(ConversionIterator *iter); -extern void user_assign_check(); +extern short user_assign_check(ENode *expr, Type *type, UInt32 qual, Boolean flag1, Boolean flag2, Boolean flag3); extern ENode *CExpr_ConvertToCondition(ENode *expr); -extern void CExpr_ConvertToIntegral(); -extern void CExpr_CheckArithmConversion(); -extern void get_address_of_temp_copy(); +extern ENode *CExpr_ConvertToIntegral(ENode *expr); +extern void CExpr_CheckArithmConversion(ENode *expr, Type *type); +extern ENode *get_address_of_temp_copy(ENode *expr, Boolean flag); extern short assign_check(ENode *expr, Type *type, UInt32 qual, Boolean flag1, Boolean flag2, Boolean flag3); -extern void CExpr_MatchCompare(); -extern void CExpr_GetFuncMatchArgs(); +extern Boolean CExpr_MatchCompare(Object *obj, Match13 *a, Match13 *b); +extern Boolean CExpr_GetFuncMatchArgs(Object *obj, ENodeList *argexprs, ENode *expr, FuncMatchArgs *result); extern ENode *CExpr_GetDefaultArgument(ENode *funcexpr, FuncArg *arg); extern ENode *CExpr_VarArgPromotion(ENode *expr, Boolean flag); -extern void CExpr_GenericFuncCall(); -extern void CExpr_GenericPtmfCall(); -extern void CExpr_MakeFunctionCall(); -extern void CExpr_CheckOperatorConversion(); -extern void CExpr_CheckOperator(); +extern ENode *CExpr_GenericFuncCall(BClassList *path, ENode *funcexpr, Boolean flag1, Object *obj, NameSpaceObjectList *nsol, TemplArg *templargs, ENodeList *nodes, Boolean flag2, Boolean flag3, Boolean flag4); +extern ENode *CExpr_GenericPtmfCall(Object *obj, TypeFunc *tfunc, ENodeList *arg_exprs); +extern ENode *CExpr_MakeFunctionCall(ENode *funcexpr, ENodeList *arg_exprs); +extern Boolean CExpr_CheckOperatorConversion(short token, ENode *left, ENode *right, ENodeList *list, Conversion *conv); +extern Boolean CExpr_CheckOperator(short token, ENode *left, ENode *right, Conversion *conv); extern ENode *CExpr_ConstructObject(TypeClass *tclass, ENode *addr_expr, ENodeList *args, Boolean flag1, Boolean flag2, Boolean flag3, Boolean flag4, Boolean flag5); -extern void scannew(); -extern void scandelete(); +extern ENode *scannew(Boolean flag); +extern ENode *scandelete(Boolean flag); // CExprConvMatch.c // static void CExpr_GetImplictObjectParamType(); @@ -216,7 +223,7 @@ extern ENode *CExpr_AssignmentPromotion(ENode *expr, Type *type, UInt32 qual, Bo // static void CExpr_MatchArgs(); // static void CExpr_GetMatchObject(); // static void CExpr_FindBestMatch(); -extern void CExpr_FuncArgMatch(); +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(); @@ -226,8 +233,8 @@ extern void CExpr_FuncArgMatch(); // static void CExpr_CheckUnaryBuiltin(); // static void CExpr_CheckBinaryBuiltin(); // static void CExpr_MatchOperands(); -extern void CExpr_CondOperatorMatch(); -extern void CExpr_OperatorMatch(); +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__ diff --git a/includes/compiler/CFunc.h b/includes/compiler/CFunc.h index 2247e5e..a0fadad 100644 --- a/includes/compiler/CFunc.h +++ b/includes/compiler/CFunc.h @@ -47,9 +47,19 @@ typedef enum StatementType { } StatementType; enum { - StmtFlag_1 = 1 + StmtFlag_1 = 1, + StmtFlag_8 = 8, + StmtFlag_10 = 0x10 }; +// TODO: move me - ST_BEGINLOOP related? +typedef struct LoopInfo { + int x0; + int x4; + short x8; + Statement *stmt; +} LoopInfo; + struct Statement { Statement *next; StatementType type; diff --git a/includes/compiler/CIRTransform.h b/includes/compiler/CIRTransform.h new file mode 100644 index 0000000..b4d9227 --- /dev/null +++ b/includes/compiler/CIRTransform.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_CIRTRANSFORM_H +#define COMPILER_CIRTRANSFORM_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/CInline.h b/includes/compiler/CInline.h index 1b5abd5..576f7e1 100644 --- a/includes/compiler/CInline.h +++ b/includes/compiler/CInline.h @@ -101,7 +101,7 @@ extern Boolean CInline_ExpressionHasSideEffect(ENode *expr); extern ENode *CInline_CopyExpression(ENode *expr, CInlineCopyMode mode); extern void CInline_SerializeStatement(Statement *stmt); extern Object *CInline_GetLocalObj(SInt32 id, Boolean flag); -extern SInt32 CInline_GetStatementNumber(Statement *first, Statement *stmt); +extern SInt16 CInline_GetStatementNumber(Statement *first, Statement *stmt); extern void CInline_PackIFunctionData(CI_FuncData *packed, Statement *stmt, Object *obj); extern void CInline_UnpackIFunctionData(Object *obj, CI_FuncData *packed, Statement *stmt); extern void CInline_AddDefaultFunctionAction(Object *obj); diff --git a/includes/compiler/CMachine.h b/includes/compiler/CMachine.h index a4bc1a5..be763d5 100644 --- a/includes/compiler/CMachine.h +++ b/includes/compiler/CMachine.h @@ -71,7 +71,7 @@ extern SInt32 CMach_StructLayoutGetOffset(Type *type, UInt32 qual); extern SInt32 CMach_StructLayoutBitfield(TypeBitfield *tbitfield, UInt32 qual); extern UInt8 CMach_GetFunctionResultClass(TypeFunc *tfunc); extern Boolean CMach_PassResultInHiddenArg(Type *type); -extern const char *CMach_GetCPU(void); +extern char *CMach_GetCPU(void); extern Boolean CMach_FloatIsPowerOf2(Float flt); extern Float CMach_FloatReciprocal(Float flt); extern SInt32 CMach_RoundedSizeOf(Object *object); diff --git a/includes/compiler/CObjC.h b/includes/compiler/CObjC.h new file mode 100644 index 0000000..92a4efa --- /dev/null +++ b/includes/compiler/CObjC.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_COBJC_H +#define COMPILER_COBJC_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/CObjCModern.h b/includes/compiler/CObjCModern.h new file mode 100644 index 0000000..df21f56 --- /dev/null +++ b/includes/compiler/CObjCModern.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_COBJCMODERN_H +#define COMPILER_COBJCMODERN_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/COptimizer.h b/includes/compiler/COptimizer.h new file mode 100644 index 0000000..4e01334 --- /dev/null +++ b/includes/compiler/COptimizer.h @@ -0,0 +1,55 @@ +#ifndef COMPILER_COPTIMIZER_H +#define COMPILER_COPTIMIZER_H + +#include "compiler/common.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif +typedef struct COptBlockList { + struct COptBlockList *next; + struct COptBlock *block; +} COptBlockList; + +typedef struct COptBlock { + struct COptBlock *next; + COptBlockList *blocks; + COptBlockList *blocks2; + Statement *stmt; + short *set1; + short *set2; + UInt32 allocmask; + short x1C; + Boolean x1E; +} COptBlock; + +typedef struct COptCSE { + struct COptCSE *next; + struct COptCSE *left; + struct COptCSE *right; + COptBlock *block; + ENode *expr; + ENode *mexpr; + ENode *replaced; + short x1C; +} COptCSE; + +typedef struct COptCSEList { + struct COptCSEList *next; + COptCSE *cse; + ENode *expr; +} COptCSEList; +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +extern COptBlock *basicblocks; +extern Boolean copt_isleaffunction; + +extern UInt32 RegAllocMask(short var); +extern void MarkRegAllocMask(short var, short bit, Boolean flag); +extern void SetVarUsage(Object *obj, Boolean noregister); +extern void COpt_SimpleOptimizer(Object *obj, Statement *stmt); +extern Statement *COpt_Optimizer(Object *obj, Statement *stmt); + +#endif diff --git a/includes/compiler/CParser.h b/includes/compiler/CParser.h index 21a3d59..4eb1abb 100644 --- a/includes/compiler/CParser.h +++ b/includes/compiler/CParser.h @@ -22,6 +22,37 @@ enum { AlignMode8_Packed }; +enum { + CPU_PPC401, + CPU_PPC403, + CPU_PPC505, + CPU_PPC509, + CPU_PPC555, + CPU_PPC601, + CPU_PPC602, + CPU_PPC603, + CPU_PPC603e, + CPU_PPC604, + CPU_PPC604e, + CPU_PPC740, + CPU_PPC750, + CPU_PPC801, + CPU_PPC821, + CPU_PPC823, + CPU_PPC850, + CPU_PPC860, + CPU_PPC8240, + CPU_PPC8260, + CPU_Generic, + CPU_PPC7400, + CPU_PPCGEKKO, + CPU_PPCELF, + CPU_PPC7450, + CPU_PPC556, + CPU_PPC565 +}; + + // not sure how many of these are char and how many are unsigned char or Boolean typedef struct COpts { Boolean little_endian; @@ -33,18 +64,18 @@ typedef struct COpts { char x06; // linker/objgen related short cpu; char schedule_cpu; - unsigned char schedule_mode; // may be an enum?? + char schedule_mode; // may be an enum?? SInt32 debuglisting; - char profile; - char traceback; + Boolean profile; + Boolean traceback; Boolean disable_registers; - char fp_contract; + Boolean fp_contract; Boolean no_register_save_helpers; char ppc_unroll_speculative; short ppc_unroll_instructions_limit; short ppc_unroll_factor_limit; Boolean altivec_model; - UInt8 x1B; // altivec/vrsave related + UInt8 altivec_vrsave; UInt8 code_alignment; char x1D; UInt8 x1E; // some register used in TOC_use_isel @@ -53,7 +84,7 @@ typedef struct COpts { Boolean use_lmw_stmw; char report_heap_info; char misaligned_mem_access; - char switch_tables; + Boolean switch_tables; char prepare_compress; char some_alignment; // used in CMach_AllocationAlignment Boolean asmsemicolcomment; @@ -80,7 +111,7 @@ typedef struct COpts { Boolean cpp_extensions; Boolean pointercast_lvalue; char useRTTI; - char delete_exception; + Boolean delete_exception; char _4B; Boolean oldalignment; Boolean unsignedchars; @@ -95,7 +126,7 @@ typedef struct COpts { Boolean longlong; Boolean longlong_enums; char no_tfuncinline; - char _59; + Boolean _59; Boolean flat_include; char syspath_once; Boolean always_import; @@ -110,7 +141,7 @@ typedef struct COpts { Boolean array_new_delete; Boolean dollar_identifiers; char def_inline_tfuncs; - char arg_dep_lookup; + Boolean arg_dep_lookup; Boolean simple_prepdump; char line_prepdump; char fullpath_prepdump; @@ -139,18 +170,18 @@ typedef struct COpts { Boolean supress_warnings; Boolean warn_illpragma; Boolean warn_emptydecl; - char warn_possunwant; + Boolean warn_possunwant; char warn_unusedvar; char warn_unusedarg; Boolean warn_extracomma; char warn_hidevirtual; Boolean warn_largeargs; - char warn_implicitconv; + Boolean warn_implicitconv; char warn_notinlined; Boolean warn_structclass; Boolean warn_padding; - char warn_no_side_effect; - char warn_resultnotused; + Boolean warn_no_side_effect; + Boolean warn_resultnotused; char warn_ptr_int_conv; char align_mode; Boolean align_array_members; @@ -163,7 +194,7 @@ typedef struct COpts { char dont_inline; char always_inline; Boolean peephole; - char global_optimizer; + Boolean global_optimizer; char side_effects; Boolean internal; Boolean import; @@ -173,7 +204,7 @@ typedef struct COpts { char force_active; char optimizationlevel; Boolean optimize_for_size; - char optimizewithasm; + Boolean optimizewithasm; Boolean crippled; char opt_common_subs; char opt_loop_invariants; diff --git a/includes/compiler/CPrep.h b/includes/compiler/CPrep.h index a681ec5..749303d 100644 --- a/includes/compiler/CPrep.h +++ b/includes/compiler/CPrep.h @@ -24,6 +24,15 @@ typedef struct TokenStack { Boolean macrocheck; } TokenStack; +//#define OPT_OFFSET(optname) ((short) (((char *) (&copts.optname)) - ((char *) &copts))) +#define OPT_OFFSET(optname) ((short) ( &((COpts *)0)->optname )) +enum { + OPT_OFFSET_MASK = 0x1FFF, + OPT_FLAG_2000 = 0x2000, + OPT_FLAG_4000 = 0x4000, + OPT_FLAG_8000 = 0x8000 +}; + extern CParams *cparamblkptr; extern short tk; extern CInt64 tkintconst; @@ -71,9 +80,12 @@ extern void CPrep_RemoveSpecialMacros(void); extern Boolean setupprep(void); extern void cleanupprep(void); extern void CPrep_TSBufferGrow(int amount); +// this is actually an arg of `PrepState *` extern void CPrep_TokenStreamGetState(SInt32 *state); +// this is actually an arg of `const PrepState *` extern void CPrep_TokenStreamSetState(SInt32 *state); extern void CPrep_UnLex(void); +// this is actually an arg of `const PrepState *` extern void CPrep_TokenStreamSetCurState(SInt32 *state); typedef void (*CPrepStreamFuncPtr)(TStreamElement *); extern void CPrep_StreamGetBlock(TStream *stream, CPrepStreamFuncPtr func, int arg); diff --git a/includes/compiler/CPreprocess.h b/includes/compiler/CPreprocess.h new file mode 100644 index 0000000..55ba280 --- /dev/null +++ b/includes/compiler/CPreprocess.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_CPREPROCESS_H +#define COMPILER_CPREPROCESS_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/CRTTI.h b/includes/compiler/CRTTI.h new file mode 100644 index 0000000..6543e0f --- /dev/null +++ b/includes/compiler/CRTTI.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_CRTTI_H +#define COMPILER_CRTTI_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/CSOM.h b/includes/compiler/CSOM.h new file mode 100644 index 0000000..560993b --- /dev/null +++ b/includes/compiler/CSOM.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_CSOM_H +#define COMPILER_CSOM_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/CScope.h b/includes/compiler/CScope.h index 95266b1..b5c8348 100644 --- a/includes/compiler/CScope.h +++ b/includes/compiler/CScope.h @@ -20,6 +20,7 @@ typedef struct CScopeSave { Boolean is_member_func; } CScopeSave; // assumed name +// this might be called NameResult typedef struct CScopeParseResult { NameSpace *nspace_0; HashNameNode *name_4; diff --git a/includes/compiler/CTemplateClass.h b/includes/compiler/CTemplateClass.h new file mode 100644 index 0000000..747a944 --- /dev/null +++ b/includes/compiler/CTemplateClass.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_CTEMPLATECLASS_H +#define COMPILER_CTEMPLATECLASS_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/CTemplateFunc.h b/includes/compiler/CTemplateFunc.h new file mode 100644 index 0000000..1461ee4 --- /dev/null +++ b/includes/compiler/CTemplateFunc.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_CTEMPLATEFUNC_H +#define COMPILER_CTEMPLATEFUNC_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/CTemplateNew.h b/includes/compiler/CTemplateNew.h new file mode 100644 index 0000000..3fbdeb9 --- /dev/null +++ b/includes/compiler/CTemplateNew.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_CTEMPLATENEW_H +#define COMPILER_CTEMPLATENEW_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/CTemplateTools.h b/includes/compiler/CTemplateTools.h new file mode 100644 index 0000000..df4ad30 --- /dev/null +++ b/includes/compiler/CTemplateTools.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_CTEMPLATETOOLS_H +#define COMPILER_CTEMPLATETOOLS_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/CodeGen.h b/includes/compiler/CodeGen.h index 3954d51..fb8ff94 100644 --- a/includes/compiler/CodeGen.h +++ b/includes/compiler/CodeGen.h @@ -11,8 +11,8 @@ extern Macro vecM; extern Macro altivecM; extern Object *gFunction; -extern PCodeLabel *returnlabel; -extern PCodeLabel *cleanreturnlabel; +extern CLabel *returnlabel; +extern CLabel *cleanreturnlabel; extern Boolean needs_cleanup; extern Statement *current_statement; extern int has_catch_blocks; @@ -48,29 +48,29 @@ extern Object *maketemporary(Type *type); typedef void (*ArgumentProcessor)(Object *obj, short reg); extern void process_arguments(ArgumentProcessor func, Boolean flag); extern void move_assigned_argument(Object *obj, short reg); -extern void assign_labels(); -extern void CodeGen_Generator(); -extern void CodeGen_GenVDispatchThunk(); -extern void CodeGen_SetupRuntimeObjects(); +extern void assign_labels(Statement *stmt); +extern void CodeGen_Generator(Statement **statements, Object *func, UInt8 mysteryFlag, Boolean callOnModuleBind); +extern void CodeGen_GenVDispatchThunk(Object *thunkobj, Object *obj, SInt32 a, SInt32 b, SInt32 c); +extern void CodeGen_SetupRuntimeObjects(void); extern Boolean CodeGen_ReInitRuntimeObjects(Boolean is_precompiler); extern Boolean CodeGen_IsPublicRuntimeObject(Object *obj); -extern void CodeGen_SOMStub(); +extern void CodeGen_SOMStub(Object *a, Object *b, Object *c, SInt32 offset); extern void CodeGen_ParseDeclSpec(HashNameNode *identifier, DeclInfo *declinfo); extern void CodeGen_ParsePragma(HashNameNode *name); extern void CodeGen_UpdateObject(Object *object); -extern void CodeGen_UpdateBackEndOptions(); +extern void CodeGen_UpdateBackEndOptions(void); extern void CodeGen_objc_method_self_offset(); extern void CodeGen_objc_method_sel_offset(); extern void CodeGen_objc_method_arg_offset(); extern void CodeGen_objc_method_args_size(); -extern void CodeGen_HandleIntrinsicCall(); -extern void CodeGen_HandleTypeCast(); +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 void CodeGen_CollapseVectorExpression(); -extern void CodeGen_InsertSpecialMacros(); +extern Boolean CodeGen_CollapseVectorExpression(ENode *expr, MWVector128 *vec, Type *type); +extern void CodeGen_InsertSpecialMacros(void); extern char *CodeGen_ExpandSpecialMacro(Macro *macro); -extern void CodeGen_reportheapinfo(); -extern void CodeGen_InitialSanityCheck(); +extern void CodeGen_reportheapinfo(Boolean release_flag, char *name, char *text); +extern void CodeGen_InitialSanityCheck(void); #ifdef __MWERKS__ #pragma options align=reset diff --git a/includes/compiler/CodeGenOptPPC.h b/includes/compiler/CodeGenOptPPC.h new file mode 100644 index 0000000..f51c49f --- /dev/null +++ b/includes/compiler/CodeGenOptPPC.h @@ -0,0 +1,11 @@ +#ifndef COMPILER_CODEGENOPTPPC_H +#define COMPILER_CODEGENOPTPPC_H + +#include "compiler/common.h" + +extern void CodeGen_InitCompiler(void); +extern void CodeGen_TermCompiler(void); +extern void CodeGen_InitBackEndOptions(void); +extern void Test_Version_Numbers(void); + +#endif diff --git a/includes/compiler/CodeMotion.h b/includes/compiler/CodeMotion.h new file mode 100644 index 0000000..5d25726 --- /dev/null +++ b/includes/compiler/CodeMotion.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_CODEMOTION_H +#define COMPILER_CODEMOTION_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/Coloring.h b/includes/compiler/Coloring.h new file mode 100644 index 0000000..85bacf6 --- /dev/null +++ b/includes/compiler/Coloring.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_COLORING_H +#define COMPILER_COLORING_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/ConstantPropagation.h b/includes/compiler/ConstantPropagation.h new file mode 100644 index 0000000..4b702ee --- /dev/null +++ b/includes/compiler/ConstantPropagation.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_CONSTANTPROPAGATION_H +#define COMPILER_CONSTANTPROPAGATION_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/CopyPropagation.h b/includes/compiler/CopyPropagation.h new file mode 100644 index 0000000..841f8dc --- /dev/null +++ b/includes/compiler/CopyPropagation.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_COPYPROPAGATION_H +#define COMPILER_COPYPROPAGATION_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/Exceptions.h b/includes/compiler/Exceptions.h new file mode 100644 index 0000000..f1096c8 --- /dev/null +++ b/includes/compiler/Exceptions.h @@ -0,0 +1,122 @@ +#ifndef COMPILER_EXCEPTIONS_H +#define COMPILER_EXCEPTIONS_H + +#include "compiler/common.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif + +typedef enum ExceptionActionType { + EAT_NOP, + EAT_DESTROYLOCAL, + EAT_DESTROYLOCALCOND, + EAT_DESTROYLOCALOFFSET, + EAT_DESTROYLOCALPOINTER, + EAT_DESTROYLOCALARRAY, + EAT_DESTROYPARTIALARRAY, + EAT_DESTROYMEMBER, + EAT_DESTROYMEMBERCOND, + EAT_DESTROYMEMBERARRAY, + EAT_DELETEPOINTER, + EAT_DELETELOCALPOINTER, + EAT_DELETEPOINTERCOND, + EAT_CATCHBLOCK, + EAT_ACTIVECATCHBLOCK, + EAT_SPECIFICATION, + EAT_TERMINATE, + EAT_DESTROYBASE, + EAT_NACTIONS +} ExceptionActionType; + +struct ExceptionAction { + ExceptionAction *prev; + union { + struct { + Object *local; + Object *dtor; + } destroy_local; + struct { + Object *local; + Object *cond; + Object *dtor; + } destroy_local_cond; + struct { + Object *local; + Object *dtor; + SInt32 offset; + } destroy_local_offset; + struct { + Object *pointer; + Object *dtor; + } destroy_local_pointer; + struct { + Object *localarray; + Object *dtor; + SInt32 elements; + SInt32 element_size; + } destroy_local_array; + struct { + Object *arraypointer; + Object *arraycounter; + Object *dtor; + Object *element_size; + } destroy_partial_array; + struct { + Object *objectptr; + Object *dtor; + SInt32 offset; + } destroy_member; + struct { + Object *objectptr; + Object *cond; + Object *dtor; + SInt32 offset; + } destroy_member_cond; + struct { + Object *objectptr; + Object *dtor; + SInt32 offset; + SInt32 elements; + SInt32 element_size; + } destroy_member_array; + struct { + Object *pointerobject; + Object *deletefunc; + } delete_pointer; + struct { + Object *pointerobject; + Object *deletefunc; + Object *cond; + } delete_pointer_cond; + struct { + Object *catch_object; + Object *catch_info_object; + CLabel *catch_label; + Object *catch_typeid; + Type *catch_type; + UInt32 catch_qual; + } catch_block; + struct { + Object *catch_info_object; + Boolean call_dtor; + } active_catch_block; + struct { + SInt32 unexp_ids; + Object **unexp_id; + CLabel *unexp_label; + Object *unexp_info_object; + } specification; + struct { + Object *object; + Boolean is_dep; + } local; + } data; + ExceptionActionType type; +}; + +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +#endif diff --git a/includes/compiler/FuncLevelAsmPPC.h b/includes/compiler/FuncLevelAsmPPC.h new file mode 100644 index 0000000..45c1727 --- /dev/null +++ b/includes/compiler/FuncLevelAsmPPC.h @@ -0,0 +1,12 @@ +#ifndef COMPILER_FUNCLEVELASMPPC_H +#define COMPILER_FUNCLEVELASMPPC_H + +#include "compiler/common.h" + +extern void setup_assembly_argument(Object *obj, short i); +extern void assign_local_addresses(); +extern void Assembler(); +extern void SetupAssembler(); +extern void CleanupAssembler(); + +#endif diff --git a/includes/compiler/FunctionCalls.h b/includes/compiler/FunctionCalls.h new file mode 100644 index 0000000..b915a39 --- /dev/null +++ b/includes/compiler/FunctionCalls.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_FUNCTIONCALLS_H +#define COMPILER_FUNCTIONCALLS_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/GCCInlineAsm.h b/includes/compiler/GCCInlineAsm.h new file mode 100644 index 0000000..0b61384 --- /dev/null +++ b/includes/compiler/GCCInlineAsm.h @@ -0,0 +1,11 @@ +#ifndef COMPILER_GCCINLINEASM_H +#define COMPILER_GCCINLINEASM_H + +#include "compiler/common.h" + +extern void InlineAsm_SkipComment(); +extern void InlineAsm_gcc_parse(void); + +extern Statement *first_ST_ASM; + +#endif diff --git a/includes/compiler/GenStabs.h b/includes/compiler/GenStabs.h new file mode 100644 index 0000000..16fd204 --- /dev/null +++ b/includes/compiler/GenStabs.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_GENSTABS_H +#define COMPILER_GENSTABS_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/GlobalOptimizer.h b/includes/compiler/GlobalOptimizer.h new file mode 100644 index 0000000..5460edd --- /dev/null +++ b/includes/compiler/GlobalOptimizer.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_GLOBALOPTIMIZER_H +#define COMPILER_GLOBALOPTIMIZER_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IROUseDef.h b/includes/compiler/IROUseDef.h new file mode 100644 index 0000000..5a13581 --- /dev/null +++ b/includes/compiler/IROUseDef.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROUSEDEF_H +#define COMPILER_IROUSEDEF_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/InlineAsm.h b/includes/compiler/InlineAsm.h new file mode 100644 index 0000000..aadbc1f --- /dev/null +++ b/includes/compiler/InlineAsm.h @@ -0,0 +1,239 @@ +#ifndef COMPILER_INLINEASM_H +#define COMPILER_INLINEASM_H + +#include "compiler/common.h" +#include "compiler/PCodeInfo.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif +typedef struct IAMnemonic { + char *name; + UInt32 x4; + char *format; + UInt32 cpu; + UInt32 x10; +} IAMnemonic; + +typedef struct IARegister { + char *name; + char rclass; + SInt32 num; + Object *object; +} IARegister; + +typedef enum IAOperandType { + IAOpnd_0, + IAOpnd_Imm, + IAOpnd_Reg, + IAOpnd_3, + IAOpnd_4, + IAOpnd_Lab, + IAOpnd_6, + IAOpnd_7, + IAOpnd_LabDiff +} IAOperandType; +typedef struct IAOperand { + IAOperandType type; + Boolean negated; + union { + // type 1 + struct { + SInt32 value; + } imm; + // type 2 + struct { + SInt32 num; + Object *object; + short effect; + short rclass; + } reg; + // type 3, 4 + struct { + SInt32 offset; + Object *obj; + short unk; + } obj; + // type 5 + struct { + CLabel *label; + } lab; + // type 6 + struct { + SInt32 num; + UInt8 unk4; + short effect; + short rclass; + } unk6; + // type 7 + struct { + SInt32 value; + Boolean unk1; + short unk2; + short unk3; + } unk7; + // type 8 + struct { + CLabel *label1; + CLabel *label2; + SInt32 offset; + } labdiff; + } u; +} IAOperand; + +typedef enum IAExprType { + IAExpr_0, + IAExpr_1, + IAExpr_2, + IAExpr_3, + IAExpr_4, + IAExpr_5, + IAExpr_6, + IAExpr_7, + IAExpr_8, + IAExpr_9, + IAExpr_10 +} IAExprType; + +typedef struct IAExpr { + IAExprType type; + UInt8 flags; + short reg; + SInt32 value; + Object *object; + Object *xC; + Object *x10; + CLabel *label; + CLabel *x18; +} IAExpr; + +enum { + IAFlag1 = 1, + IAFlag2 = 2 +}; +enum { + IAFlagsB_1 = 1, + IAFlagsB_2 = 2, + IAFlagsB_4 = 4, + IAFlagsB_8 = 8, + IAFlagsB_10 = 0x10, + IAFlagsB_20 = 0x20, + IAFlagsB_40 = 0x40 +}; + +typedef struct InlineAsm { + Opcode opcode; + unsigned char flags; + unsigned char flags2; + short argcount; + IAOperand args[0]; +} InlineAsm; + +typedef struct IALookupResult { + HashNameNode *name; + CLabel *label; + Object *object; + Type *type; + UInt32 value; + Boolean has_value; +} IALookupResult; + +typedef struct IAEntryPoint { + short x0; + char x2; + int x4; + Object *x8; + SInt32 size; +} IAEntryPoint; + +typedef enum IAEffectType { + IAEffect_0, + IAEffect_1, + IAEffect_2, + IAEffect_3 +} IAEffectType; +typedef struct IAEffect { + IAEffectType type; + Object *object; + SInt32 offset; + SInt32 size; +} IAEffect; + +typedef struct IAEffects { + Boolean x0; + Boolean x1; + Boolean x2; + Boolean x3; + Boolean x4; + Boolean x5; + UInt32 numoperands; + UInt32 numlabels; + IAEffect operands[16]; + CLabel *labels[16]; +} IAEffects; + +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +extern int backtracking; +extern jmp_buf backtrack; +extern jmp_buf InlineAsm_assemblererror; + +extern int allow_array_expressions; + +extern void AssemblerError(void); +extern void InlineAsm_SyntaxError(short code); +extern CLabel *InlineAsm_LookupLabel(HashNameNode *name); +extern CLabel *InlineAsm_DeclareLabel(HashNameNode *name); +extern Boolean InlineAsm_LookupSymbolOrTag(HashNameNode *name, IALookupResult *result, Boolean allow_tag); +extern Boolean InlineAsm_LookupSymbol(HashNameNode *name, IALookupResult *result); +extern SInt32 InlineAsm_StructMemberOffset(Type *type); +extern SInt32 InlineAsm_StructArrayMemberOffset(Type *type); +extern SInt32 InlineAsm_StructPointerMemberOffset(Type *type); +extern SInt32 InlineAsm_ConstantExpression(void); +extern HashNameNode *MakeLocalLabel(CInt64 num); +extern void InlineAsm_ScanStatements(volatile short endToken); +extern void InlineAsm_ScanFunction(volatile short endToken); +extern void InlineAsm_Assemble(void); +extern void InlineAsm_PackAsmStatement(Statement *stmt, Statement *first, void **output, SInt32 *outsize); +extern void InlineAsm_UnpackAsmStatement(Statement *stmt, CLabel **labelArray, Boolean flag, void *data, SInt32 size); +extern void InlineAsm_CheckLocalUsage(Statement *stmt); +extern CLabel *InlineAsm_GetReferencedLabel(Statement *stmt); +extern CLabel *InlineAsm_GetReferencedLabel2(Statement *stmt); +extern Object *InlineAsm_GetObjectOffset(InlineAsm *ia, SInt32 index, SInt32 *offset); +extern char *InlineAsm_DumpStatement(Statement *stmt); + +// unknown name +inline void InlineAsm_InitExpr5(IAExpr *expr, SInt32 value) { + expr->type = IAExpr_5; + expr->flags = 0; + expr->value = value; + expr->reg = 0; + expr->object = NULL; + expr->xC = NULL; + expr->x10 = NULL; + expr->label = NULL; + expr->x18 = NULL; +} + +// unknown name +inline int InlineAsm_CheckExpr(IAExpr *expr) { + return (expr->xC == NULL && expr->object == NULL && expr->label == NULL); +} + +// unknown name +inline SInt32 InlineAsm_GetExprValue(IAExpr *expr) { + switch (expr->type) { + case IAExpr_8: + return HIGH_PART(expr->value); + case IAExpr_7: + return (short) (expr->value >> 16); + case IAExpr_6: + return (short) expr->value; + default: + return expr->value; + } +} + +#endif diff --git a/includes/compiler/InlineAsmMnemonicsPPC.h b/includes/compiler/InlineAsmMnemonicsPPC.h new file mode 100644 index 0000000..9f87910 --- /dev/null +++ b/includes/compiler/InlineAsmMnemonicsPPC.h @@ -0,0 +1,10 @@ +#ifndef COMPILER_INLINEASMMNEMONICSPPC_H +#define COMPILER_INLINEASMMNEMONICSPPC_H + +#include "compiler/common.h" +#include "compiler/InlineAsm.h" + +extern void InlineAsm_InitializeMnemonicsPPC(void); +extern IAMnemonic *InlineAsm_LookupMnemonicPPC(char *name); + +#endif diff --git a/includes/compiler/InlineAsmPPC.h b/includes/compiler/InlineAsmPPC.h new file mode 100644 index 0000000..feb5132 --- /dev/null +++ b/includes/compiler/InlineAsmPPC.h @@ -0,0 +1,82 @@ +#ifndef COMPILER_INLINEASMPPC_H +#define COMPILER_INLINEASMPPC_H + +#include "compiler/common.h" +#include "compiler/InlineAsm.h" + +extern char asm_alloc_flags[10]; +extern unsigned char sm_section; +extern UInt32 cpu; +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 char volatileasm; +extern Boolean InlineAsm_gccmode; +extern Boolean InlineAsm_labelref; +extern CLabel *pic_base_label; + +enum { + IADirective_Null, + IADirective_Entry, + IADirective_FrAlloc, + IADirective_NoFrAlloc, + IADirective_FrFree, + IADirective_Machine, + IADirective_SmClass, + IADirective_PicBase +}; + +enum { + CPUFLAG_LOW_MASK = 0xFFFFF, + CPUFLAG_100000 = 0x100000, + CPUFLAG_200000 = 0x200000, + CPUFLAG_400000 = 0x400000, + CPUFLAG_800000 = 0x800000, + CPUFLAG_1000000 = 0x1000000, + CPUFLAG_2000000 = 0x2000000, + CPUFLAG_4000000 = 0x4000000, + CPUFLAG_8000000 = 0x8000000, + CPUFLAG_10000000 = 0x10000000, + CPUFLAG_20000000 = 0x20000000, + CPUFLAG_40000000 = 0x40000000, + CPUFLAG_80000000 = 0x80000000 +}; + +#define OPCODE_PART_1(opcode) ( (opcode) >> 26 ) +#define OPCODE_PART_2(opcode) ( ((opcode) >> 21) & 0x1F ) +#define OPCODE_PART_3(opcode) ( ((opcode) >> 1) & 0x3FF ) + +enum { + CPUMask_401 = CPUFLAG_8000000 | 0x40, + CPUMask_403 = CPUFLAG_8000000 | 0x80, + CPUMask_50x = CPUFLAG_10000000 | CPUFLAG_80000000 | 0x800, + CPUMask_55x_56x = CPUFLAG_10000000 | CPUFLAG_80000000 | 0x1000, + CPUMask_601 = CPUFLAG_1000000 | CPUFLAG_2000000 | CPUFLAG_4000000 | CPUFLAG_8000000 | CPUFLAG_80000000 | 1, + CPUMask_602 = CPUFLAG_800000 | CPUFLAG_1000000 | CPUFLAG_4000000 | CPUFLAG_8000000 | CPUFLAG_10000000 | CPUFLAG_80000000 | 2, + CPUMask_8240 = CPUFLAG_800000 | CPUFLAG_1000000 | CPUFLAG_2000000 | CPUFLAG_4000000 | CPUFLAG_8000000 | CPUFLAG_10000000 | CPUFLAG_80000000 | 0x10000, + CPUMask_8260 = CPUFLAG_1000000 | CPUFLAG_2000000 | CPUFLAG_4000000 | CPUFLAG_8000000 | CPUFLAG_10000000 | 0x10000, + CPUMask_603 = CPUFLAG_800000 | CPUFLAG_1000000 | CPUFLAG_2000000 | CPUFLAG_4000000 | CPUFLAG_8000000 | CPUFLAG_10000000 | CPUFLAG_80000000 | 4, + CPUMask_604 = CPUFLAG_800000 | CPUFLAG_1000000 | CPUFLAG_2000000 | CPUFLAG_4000000 | CPUFLAG_8000000 | CPUFLAG_10000000 | CPUFLAG_80000000 | 8, + CPUMask_740_750 = CPUFLAG_800000 | CPUFLAG_1000000 | CPUFLAG_2000000 | CPUFLAG_4000000 | CPUFLAG_8000000 | CPUFLAG_10000000 | CPUFLAG_80000000 | 0x2000, + CPUMask_801_821_860 = CPUFLAG_4000000 | CPUFLAG_8000000 | CPUFLAG_10000000 | 0x10, + CPUMask_823_850 = CPUFLAG_4000000 | CPUFLAG_8000000 | CPUFLAG_10000000 | 0x20, + CPUMask_74xx = CPUFLAG_800000 | CPUFLAG_1000000 | CPUFLAG_2000000 | CPUFLAG_4000000 | CPUFLAG_8000000 | CPUFLAG_10000000 | CPUFLAG_40000000 | CPUFLAG_80000000 | 0x6000, + CPUMask_All = CPUFLAG_800000 | CPUFLAG_1000000 | CPUFLAG_2000000 | CPUFLAG_4000000 | CPUFLAG_8000000 | CPUFLAG_10000000 | CPUFLAG_40000000 | CPUFLAG_80000000 | 0xFFFFF, + CPUMask_Generic = CPUFLAG_800000 | CPUFLAG_1000000 | CPUFLAG_2000000 | CPUFLAG_4000000 | CPUFLAG_8000000 | CPUFLAG_10000000 | CPUFLAG_40000000 | CPUFLAG_80000000 | 0xE00E +}; + +extern void InlineAsm_InitializePPC(void); +extern void InlineAsm_Initialize(UInt8 assemblertype); +extern SInt32 InlineAsm_IsDirective(UInt8 assemblertype); +extern void InlineAsm_ProcessDirective(SInt32 directive); +extern void InlineAsm_ScanAssemblyDirective(void); +extern void InlineAsm_ScanAssemblyInstruction(void); +extern void InlineAsm_TranslateIRtoPCode(Statement *stmt); +extern const char *InlineAsm_GetMnemonic(InlineAsm *ia); +extern void CodeGen_GetAsmEffects(Statement *stmt, IAEffects *effects); +extern void CodeGen_PropagateIntoAsm(Statement *stmt, Object *obj, ENode *expr); +extern Statement *CodeGen_CopyAsmStat(Statement *stmt); + +#endif diff --git a/includes/compiler/InlineAsmRegisters.h b/includes/compiler/InlineAsmRegisters.h new file mode 100644 index 0000000..6cd8ef7 --- /dev/null +++ b/includes/compiler/InlineAsmRegisters.h @@ -0,0 +1,11 @@ +#ifndef COMPILER_INLINEASMREGISTERS_H +#define COMPILER_INLINEASMREGISTERS_H + +#include "compiler/common.h" +#include "compiler/InlineAsm.h" + +extern void InlineAsm_InitializeRegisters(void); +extern void InlineAsm_InsertRegister(char *name, char rclass, short num, Object *object); +extern IARegister *InlineAsm_LookupRegister(char *name); + +#endif diff --git a/includes/compiler/InlineAsmRegistersPPC.h b/includes/compiler/InlineAsmRegistersPPC.h new file mode 100644 index 0000000..dd65644 --- /dev/null +++ b/includes/compiler/InlineAsmRegistersPPC.h @@ -0,0 +1,12 @@ +#ifndef COMPILER_INLINEASMREGISTERSPPC_H +#define COMPILER_INLINEASMREGISTERSPPC_H + +#include "compiler/common.h" +#include "compiler/InlineAsm.h" + +extern IARegister *InlineAsm_LookupRegisterPPCName(HashNameNode *name); +extern IARegister *InlineAsm_LookupRegisterPPC(char *name); +extern IARegister *InlineAsm_LookupDCRRegister(char *name); +extern void InlineAsm_InitializeRegistersPPC(void); + +#endif diff --git a/includes/compiler/InstrSelection.h b/includes/compiler/InstrSelection.h new file mode 100644 index 0000000..a3b90b3 --- /dev/null +++ b/includes/compiler/InstrSelection.h @@ -0,0 +1,128 @@ +#ifndef COMPILER_INSTRSELECTION_H +#define COMPILER_INSTRSELECTION_H + +#include "compiler/common.h" +#include "compiler/enode.h" +#include "compiler/Operands.h" +#include "compiler/PCodeInfo.h" + +typedef struct PrecomputedOperand { + struct PrecomputedOperand *next; + SInt32 precompid; + Operand operand; +} PrecomputedOperand; + +extern PrecomputedOperand *precomputedoperands; +extern void (*cgdispatch[MAXEXPR + 1])(ENode *, short, short, Operand *); + +extern void init_cgdispatch(void); +extern void gen_DEFINE(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_REUSE(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_POSTINCDEC(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_INDIRECT(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_MONMIN(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_BINNOT(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_FORCELOAD(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_MUL(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_DIV(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_MODULO(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_ADD(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_SUB(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_SHL(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_SHR(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_AND(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_XOR(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_OR(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_ASS(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern ENode *evaluate_and_skip_comma(ENode *expr); +extern void gen_COMMA(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_TYPCON(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_BITFIELD(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_INTCONST(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_FLOATCONST(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_STRINGCONST(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_COND(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_CONDASS(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_FUNCCALL(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_OBJREF(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_UNEXPECTED(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void binary_operator(Opcode opcode, ENode *left, ENode *right, short outputReg, Operand *output); +extern void unary_operator(Opcode opcode, ENode *expr, short outputReg, Operand *output); +extern void fp_unary_operator(Opcode opcode, ENode *expr, short outputReg, Operand *output); +extern void fp_multiply_add(Opcode opcode, ENode *a, ENode *b, ENode *c, short outputReg, Operand *output); +extern void gen_COMPARE(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_LOGICAL(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_NULLCHECK(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_PRECOMP(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void logical_expression(ENode *cond, PCodeLabel *a, PCodeLabel *b, PCodeLabel *c); +extern void gen_condition(ENode *cond, Operand *output); +extern void gen_condition_gpr(ENode *cond, Operand *output, short outputReg); +extern void gen_negated_condition_gpr(ENode *cond, Operand *output, short outputReg); +extern void compare_floating(short nt, ENode *left, ENode *right, Operand *output); +extern void compare_integer(short nt, ENode *left, ENode *right, Operand *output); +extern void compare_immediate(short nt, ENode *left, SInt32 value, Operand *output); +extern void compare_immediate_long(short nt, ENode *left, SInt32 value, Operand *output); +extern int ismaskconstant(SInt32 value, short *first, short *last); +extern int ispostincrementopportunity(ENode *expr, Operand *op, SInt32 *value); +extern void add_register_immediate(short regA, short regB, SInt32 value); +extern void I8_gen_ADD(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void I8_gen_INTCONST(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void I8_gen_SUB(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void I8_gen_XOR(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void I8_gen_OR(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void I8_gen_AND(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern int I8_getbit(UInt64 val); +extern int I8_log2n(UInt64 val); +extern void I8_ShiftLeftImmediate(Operand opnd, SInt32 value, int is_unsigned, SInt32 size, short reg, short regHi); +extern void I8_ShiftRightImmediate(Operand opnd, SInt32 value, int is_unsigned, short reg, short regHi, int unk); +extern void I8_gen_MUL(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void I8_gen_BINNOT(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void I8_gen_MONMIN(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void I8_gen_ASS(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void I8_gen_POSTINCDEC(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void I8_gen_INDIRECT(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void I8_gen_condition(ENode *cond, Operand *output, int write_to_gpr); +extern void I8_gen_SHL_SHR(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void I8_gen_DIV_MOD(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void I8_gen_TYPCON(ENode *expr, short outputReg, short outputRegHi, Operand *output); +extern void gen_VECTOR128CONST(ENode *expr, short outputReg, short outputRegHi, Operand *output); + +#define GEN_NODE(node, opnd) cgdispatch[(node)->type]((node), 0, 0, (opnd)) +#define GEN_NODE_TO_REG(node, reg, regHi, opnd) cgdispatch[(node)->type]((node), (reg), (regHi), (opnd)) + +#define ENSURE_GPR(opnd, type, reg) \ +do { \ + if ((opnd)->optype != OpndType_GPR) \ + Coerce_to_register((opnd), (type), (reg)); \ +} while (0) +#define ENSURE_FPR(opnd, type, reg) \ +do { \ + if ((opnd)->optype != OpndType_FPR) \ + Coerce_to_fp_register((opnd), (type), (reg)); \ +} while (0) +#define ENSURE_VR(opnd, type, reg) \ +do { \ + if ((opnd)->optype != OpndType_VR) \ + Coerce_to_v_register((opnd), (type), (reg)); \ +} while (0) + +#define GEN_NODE_TO_GPR(node, opnd, type, reg) \ +do { \ + GEN_NODE((node), (opnd)); \ + ENSURE_GPR((opnd), (type), (reg)); \ +} while (0) + +#define GEN_NODE_TO_FPR(node, opnd, type, reg) \ +do { \ + GEN_NODE((node), (opnd)); \ + ENSURE_FPR((opnd), (type), (reg)); \ +} while (0) + +#define GEN_NODE_TO_VR(node, opnd, type, reg) \ +do { \ + GEN_NODE((node), (opnd)); \ + ENSURE_VR((opnd), (type), (reg)); \ +} while (0) + + +#endif diff --git a/includes/compiler/InterferenceGraph.h b/includes/compiler/InterferenceGraph.h new file mode 100644 index 0000000..588450c --- /dev/null +++ b/includes/compiler/InterferenceGraph.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_INTERFERENCEGRAPH_H +#define COMPILER_INTERFERENCEGRAPH_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/Intrinsics.h b/includes/compiler/Intrinsics.h new file mode 100644 index 0000000..19150f7 --- /dev/null +++ b/includes/compiler/Intrinsics.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_INTRINSICS_H +#define COMPILER_INTRINSICS_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IrOptimizer.h b/includes/compiler/IrOptimizer.h new file mode 100644 index 0000000..ef86286 --- /dev/null +++ b/includes/compiler/IrOptimizer.h @@ -0,0 +1,9 @@ +#ifndef COMPILER_IROPTIMIZER_H +#define COMPILER_IROPTIMIZER_H + +#include "compiler/common.h" + +// do me +extern Statement *IRO_Optimizer(Object *obj, Statement *stmt); + +#endif diff --git a/includes/compiler/IroBitVect.h b/includes/compiler/IroBitVect.h new file mode 100644 index 0000000..7bbca22 --- /dev/null +++ b/includes/compiler/IroBitVect.h @@ -0,0 +1,35 @@ +#ifndef COMPILER_IROBITVECT_H +#define COMPILER_IROBITVECT_H + +#include "compiler/common.h" +#include "compiler/CError.h" + +typedef struct BitVector { + UInt32 size; + UInt32 data[0]; +} BitVector; + +extern void Bv_AllocVector(BitVector **bv, UInt32 size); +extern void Bv_AllocVectorLocal(BitVector **bv, UInt32 size); +extern void Bv_ClearBit(UInt32 bit, BitVector *bv); +extern void Bv_And(const BitVector *a, BitVector *b); +extern void Bv_Or(const BitVector *a, BitVector *b); +extern Boolean Bv_BitsInCommon(const BitVector *a, const BitVector *b); +extern Boolean Bv_Compare(const BitVector *a, const BitVector *b); +extern void Bv_Minus(const BitVector *a, BitVector *b); +extern void Bv_Copy(const BitVector *src, BitVector *dst); +extern void Bv_Clear(BitVector *bv); +extern void Bv_Set(BitVector *bv); +extern Boolean Bv_IsSubset(const BitVector *a, const BitVector *b); +extern Boolean Bv_IsEmpty(const BitVector *bv); + +inline void Bv_SetBit(UInt32 bit, BitVector *bv) { + if ((bit / 32) < bv->size) { + bv->data[bit / 32] |= ~(1 << (bit & 31)); + } else { +#line 56 + CError_FATAL(); + } +} + +#endif diff --git a/includes/compiler/IroCSE.h b/includes/compiler/IroCSE.h new file mode 100644 index 0000000..2030e5b --- /dev/null +++ b/includes/compiler/IroCSE.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROCSE_H +#define COMPILER_IROCSE_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroDump.h b/includes/compiler/IroDump.h new file mode 100644 index 0000000..a2f74ff --- /dev/null +++ b/includes/compiler/IroDump.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IRODUMP_H +#define COMPILER_IRODUMP_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroEmptyLoop.h b/includes/compiler/IroEmptyLoop.h new file mode 100644 index 0000000..6eb4edc --- /dev/null +++ b/includes/compiler/IroEmptyLoop.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROEMPTYLOOP_H +#define COMPILER_IROEMPTYLOOP_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroEval.h b/includes/compiler/IroEval.h new file mode 100644 index 0000000..2d650b7 --- /dev/null +++ b/includes/compiler/IroEval.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROEVAL_H +#define COMPILER_IROEVAL_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroExprRegeneration.h b/includes/compiler/IroExprRegeneration.h new file mode 100644 index 0000000..2012c2d --- /dev/null +++ b/includes/compiler/IroExprRegeneration.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROEXPRREGENERATION_H +#define COMPILER_IROEXPRREGENERATION_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroFlowgraph.h b/includes/compiler/IroFlowgraph.h new file mode 100644 index 0000000..1faf2d9 --- /dev/null +++ b/includes/compiler/IroFlowgraph.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROFLOWGRAPH_H +#define COMPILER_IROFLOWGRAPH_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroJump.h b/includes/compiler/IroJump.h new file mode 100644 index 0000000..a2368c9 --- /dev/null +++ b/includes/compiler/IroJump.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROJUMP_H +#define COMPILER_IROJUMP_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroLinearForm.h b/includes/compiler/IroLinearForm.h new file mode 100644 index 0000000..9f2ece1 --- /dev/null +++ b/includes/compiler/IroLinearForm.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROLINEARFORM_H +#define COMPILER_IROLINEARFORM_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroLoop.h b/includes/compiler/IroLoop.h new file mode 100644 index 0000000..10bc36a --- /dev/null +++ b/includes/compiler/IroLoop.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROLOOP_H +#define COMPILER_IROLOOP_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroMalloc.h b/includes/compiler/IroMalloc.h new file mode 100644 index 0000000..bc7df31 --- /dev/null +++ b/includes/compiler/IroMalloc.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROMALLOC_H +#define COMPILER_IROMALLOC_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroPointerAnalysis.h b/includes/compiler/IroPointerAnalysis.h new file mode 100644 index 0000000..f6912cb --- /dev/null +++ b/includes/compiler/IroPointerAnalysis.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROPOINTERANALYSIS_H +#define COMPILER_IROPOINTERANALYSIS_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroPropagate.h b/includes/compiler/IroPropagate.h new file mode 100644 index 0000000..689b5fa --- /dev/null +++ b/includes/compiler/IroPropagate.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROPROPAGATE_H +#define COMPILER_IROPROPAGATE_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroRangePropagation.h b/includes/compiler/IroRangePropagation.h new file mode 100644 index 0000000..210cd9e --- /dev/null +++ b/includes/compiler/IroRangePropagation.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IRORANGEPROPAGATION_H +#define COMPILER_IRORANGEPROPAGATION_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroSubable.h b/includes/compiler/IroSubable.h new file mode 100644 index 0000000..ff0cbd9 --- /dev/null +++ b/includes/compiler/IroSubable.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROSUBABLE_H +#define COMPILER_IROSUBABLE_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroUnrollLoop.h b/includes/compiler/IroUnrollLoop.h new file mode 100644 index 0000000..b48510f --- /dev/null +++ b/includes/compiler/IroUnrollLoop.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROUNROLLLOOP_H +#define COMPILER_IROUNROLLLOOP_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroUtil.h b/includes/compiler/IroUtil.h new file mode 100644 index 0000000..b4c71e7 --- /dev/null +++ b/includes/compiler/IroUtil.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROUTIL_H +#define COMPILER_IROUTIL_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/IroVars.h b/includes/compiler/IroVars.h new file mode 100644 index 0000000..3fbfc2f --- /dev/null +++ b/includes/compiler/IroVars.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_IROVARS_H +#define COMPILER_IROVARS_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/LoadDeletion.h b/includes/compiler/LoadDeletion.h new file mode 100644 index 0000000..743d5bb --- /dev/null +++ b/includes/compiler/LoadDeletion.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_LOADDELETION_H +#define COMPILER_LOADDELETION_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/LoopDetection.h b/includes/compiler/LoopDetection.h new file mode 100644 index 0000000..7f27467 --- /dev/null +++ b/includes/compiler/LoopDetection.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_LOOPDETECTION_H +#define COMPILER_LOOPDETECTION_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/LoopOptimization.h b/includes/compiler/LoopOptimization.h new file mode 100644 index 0000000..5911b03 --- /dev/null +++ b/includes/compiler/LoopOptimization.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_LOOPOPTIMIZATION_H +#define COMPILER_LOOPOPTIMIZATION_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/MachO.h b/includes/compiler/MachO.h new file mode 100644 index 0000000..eb8ad57 --- /dev/null +++ b/includes/compiler/MachO.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_MACHO_H +#define COMPILER_MACHO_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/ObjGenMachO.h b/includes/compiler/ObjGenMachO.h new file mode 100644 index 0000000..ba06522 --- /dev/null +++ b/includes/compiler/ObjGenMachO.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_OBJGENMACHO_H +#define COMPILER_OBJGENMACHO_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/Operands.h b/includes/compiler/Operands.h index 8c6aa93..cd9c035 100644 --- a/includes/compiler/Operands.h +++ b/includes/compiler/Operands.h @@ -18,7 +18,7 @@ enum OperandType { OpndType_GPR_Indexed = 2, // Value in two registers (identified by 'reg' and 'regHi') OpndType_GPRPair = 3, - // Value at an absolute address (identified by 'abs_address') + // Immediate 32-bit value OpndType_Absolute = 4, // Value in a float register (identified by 'reg') OpndType_FPR = 5, @@ -49,7 +49,7 @@ struct Operand { SInt16 regHi; SInt16 regOffset; SInt32 immOffset; - SInt32 abs_address; + SInt32 immediate; Object *object; UInt32 flags; }; @@ -61,15 +61,15 @@ extern void combine(Operand *opA, Operand *opB, short output_reg, Operand *opOut extern void coerce_to_addressable(Operand *op); extern void Coerce_to_register(Operand *op, Type *type, short output_reg); extern void coerce_to_register_pair(Operand *op, Type *type, short output_reg, short output_regHi); -extern void Coerce_to_fp_register(Operand *op, TypeIntegral *tint, short output_reg); -extern void Coerce_to_v_register(Operand *op, TypeStruct *tstruct, short output_reg); +extern void Coerce_to_fp_register(Operand *op, Type *tint, short output_reg); +extern void Coerce_to_v_register(Operand *op, Type *tstruct, short output_reg); extern void store(short reg, Operand *op, Type *type); extern void store_pair(short reg, short regHi, Operand *op, Type *type); -extern void store_fp(short reg, Operand *op, TypeIntegral *tint); -extern void store_v(short reg, Operand *op, TypeStruct *tstruct); +extern void store_fp(short reg, Operand *op, Type *tint); +extern void store_v(short reg, Operand *op, Type *tstruct); extern void extend32(Operand *op, Type *type, short output_reg); extern void extend64(Operand *op, Type *type, short output_reg, short output_regHi); -extern void load_floating_constant(short reg, TypeIntegral *type, double *data); +extern void load_floating_constant(short reg, Type *type, double *data); extern void convert_integer_to_floating(Operand *op, Boolean is_single, short output_reg); extern void convert_unsigned_to_floating(Operand *op, Boolean is_single, short output_reg); extern void convert_floating_to_integer(Operand *op, short output_reg); diff --git a/includes/compiler/PCode.h b/includes/compiler/PCode.h index 55aac38..b56ed2f 100644 --- a/includes/compiler/PCode.h +++ b/includes/compiler/PCode.h @@ -2,11 +2,15 @@ #define COMPILER_PCODE_H #include "compiler/common.h" +#include "compiler/PCodeInfo.h" #ifdef __MWERKS__ #pragma options align=mac68k #endif +#define FLAG_SET_T(flags) (((flags) & (fPCodeFlag1 | fPCodeFlag8)) ? (flags) : 0) +#define FLAG_SET_F(flags) (((flags) & (fPCodeFlag1 | fPCodeFlag8)) ? 0 : (flags)) + #define PCODE_FLAG_SET_T(pcode) (((pcode)->flags & (fPCodeFlag1 | fPCodeFlag8)) ? (pcode)->flags : 0) #define PCODE_FLAG_SET_F(pcode) (((pcode)->flags & (fPCodeFlag1 | fPCodeFlag8)) ? 0 : (pcode)->flags) @@ -15,7 +19,7 @@ enum { EffectWrite = 2 }; -typedef enum { +/*typedef enum { PCOp_REGISTER, PCOp_SYSREG, PCOp_IMMEDIATE, @@ -23,7 +27,7 @@ typedef enum { PCOp_LABEL, PCOp_LABELDIFF, PCOp_PLACEHOLDEROPERAND -} PCOpKind; +} PCOpKind;*/ typedef enum { RefType_0, @@ -142,6 +146,8 @@ enum { fOverflow = 0x800000, fSetsCarry = 0x10000000, // ?? + fPCodeFlag2000000 = 0x2000000, + fPCodeFlag4000000 = 0x4000000, fPCodeFlag8000000 = 0x8000000, fPCodeFlag10000000 = 0x10000000, fPCodeFlag20000000 = 0x20000000, @@ -167,25 +173,25 @@ extern PCodeBlock **depthfirstordering; extern int pcblockcount; extern int pcloopweight; -extern void initpcode(); -extern PCode *makepcode(short op, ...); -extern void emitpcode(short op, ...); +extern void initpcode(void); +extern PCode *makepcode(Opcode op, ...); +extern void emitpcode(Opcode op, ...); extern PCode *copypcode(PCode *pcode); -extern PCodeLabel *makepclabel(); -extern PCodeBlock *makepcblock(); +extern PCodeLabel *makepclabel(void); +extern PCodeBlock *makepcblock(void); extern void pclabel(PCodeBlock *block, PCodeLabel *label); extern void pcbranch(PCodeBlock *block, PCodeLabel *label); -extern void pccomputepredecessors(); +extern void pccomputepredecessors(void); extern void deleteblock(PCodeBlock *block); -extern void deleteunreachableblocks(); +extern void deleteunreachableblocks(void); extern void appendpcode(PCodeBlock *block, PCode *pcode); extern void deletepcode(PCode *pcode); extern void insertpcodebefore(PCode *anchor, PCode *newpcode); extern void insertpcodeafter(PCode *anchor, PCode *newpcode); extern void setpcodeflags(int flags); extern void clearpcodeflags(int flags); -extern int pccomputeoffsets(); -extern void computedepthfirstordering(); +extern int pccomputeoffsets(void); +extern void computedepthfirstordering(void); #ifdef __MWERKS__ #pragma options align=reset diff --git a/includes/compiler/PCodeAssembly.h b/includes/compiler/PCodeAssembly.h new file mode 100644 index 0000000..682482c --- /dev/null +++ b/includes/compiler/PCodeAssembly.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_PCODEASSEMBLY_H +#define COMPILER_PCODEASSEMBLY_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/PCodeInfo.h b/includes/compiler/PCodeInfo.h index 137e10a..c7cee47 100644 --- a/includes/compiler/PCodeInfo.h +++ b/includes/compiler/PCodeInfo.h @@ -1,22 +1,33 @@ #ifndef COMPILER_PCODEINFO_H #define COMPILER_PCODEINFO_H -#include "compiler/PCode.h" +#include "compiler/common.h" #ifdef __MWERKS__ #pragma options align=mac68k #endif +typedef enum { + PCOp_REGISTER, + PCOp_SYSREG, + PCOp_IMMEDIATE, + PCOp_MEMORY, + PCOp_LABEL, + PCOp_LABELDIFF, + PCOp_PLACEHOLDEROPERAND +} PCOpKind; + typedef struct _OpcodeInfo { const char *name; const char *format; unsigned char x8; unsigned char x9; - int flags; - unsigned int insn; + UInt32 flags; + SInt32 insn; } OpcodeInfo; -/*enum { +typedef enum Opcode { + PC_INVALID = -1, PC_B = 0x0, PC_BL = 0x1, PC_BC = 0x2, @@ -448,7 +459,7 @@ typedef struct _OpcodeInfo { PC_PENTRY = 0x1AC, PC_PEXIT = 0x1AD, OPCODE_MAX = 0x1AE -};*/ +} Opcode; //#define PC_B 0x0 //#define PC_BL 0x1 //#define PC_BC 0x2 @@ -880,443 +891,443 @@ typedef struct _OpcodeInfo { //#define PC_PENTRY 0x1AC //#define PC_PEXIT 0x1AD //#define OPCODE_MAX 0x1AE -const short PC_B = 0x0; -const short PC_BL = 0x1; -const short PC_BC = 0x2; -const short PC_BCLR = 0x3; -const short PC_BCCTR = 0x4; -const short PC_BT = 0x5; -const short PC_BTLR = 0x6; -const short PC_BTCTR = 0x7; -const short PC_BF = 0x8; -const short PC_BFLR = 0x9; -const short PC_BFCTR = 0xA; -const short PC_BDNZ = 0xB; -const short PC_BDNZT = 0xC; -const short PC_BDNZF = 0xD; -const short PC_BDZ = 0xE; -const short PC_BDZT = 0xF; -const short PC_BDZF = 0x10; -const short PC_BLR = 0x11; -const short PC_BCTR = 0x12; -const short PC_BCTRL = 0x13; -const short PC_BLRL = 0x14; -const short PC_LBZ = 0x15; -const short PC_LBZU = 0x16; -const short PC_LBZX = 0x17; -const short PC_LBZUX = 0x18; -const short PC_LHZ = 0x19; -const short PC_LHZU = 0x1A; -const short PC_LHZX = 0x1B; -const short PC_LHZUX = 0x1C; -const short PC_LHA = 0x1D; -const short PC_LHAU = 0x1E; -const short PC_LHAX = 0x1F; -const short PC_LHAUX = 0x20; -const short PC_LHBRX = 0x21; -const short PC_LWZ = 0x22; -const short PC_LWZU = 0x23; -const short PC_LWZX = 0x24; -const short PC_LWZUX = 0x25; -const short PC_LWBRX = 0x26; -const short PC_LMW = 0x27; -const short PC_STB = 0x28; -const short PC_STBU = 0x29; -const short PC_STBX = 0x2A; -const short PC_STBUX = 0x2B; -const short PC_STH = 0x2C; -const short PC_STHU = 0x2D; -const short PC_STHX = 0x2E; -const short PC_STHUX = 0x2F; -const short PC_STHBRX = 0x30; -const short PC_STW = 0x31; -const short PC_STWU = 0x32; -const short PC_STWX = 0x33; -const short PC_STWUX = 0x34; -const short PC_STWBRX = 0x35; -const short PC_STMW = 0x36; -const short PC_DCBF = 0x37; -const short PC_DCBST = 0x38; -const short PC_DCBT = 0x39; -const short PC_DCBTST = 0x3A; -const short PC_DCBZ = 0x3B; -const short PC_ADD = 0x3C; -const short PC_ADDC = 0x3D; -const short PC_ADDE = 0x3E; -const short PC_ADDI = 0x3F; -const short PC_ADDIC = 0x40; -const short PC_ADDICR = 0x41; -const short PC_ADDIS = 0x42; -const short PC_ADDME = 0x43; -const short PC_ADDZE = 0x44; -const short PC_DIVW = 0x45; -const short PC_DIVWU = 0x46; -const short PC_MULHW = 0x47; -const short PC_MULHWU = 0x48; -const short PC_MULLI = 0x49; -const short PC_MULLW = 0x4A; -const short PC_NEG = 0x4B; -const short PC_SUBF = 0x4C; -const short PC_SUBFC = 0x4D; -const short PC_SUBFE = 0x4E; -const short PC_SUBFIC = 0x4F; -const short PC_SUBFME = 0x50; -const short PC_SUBFZE = 0x51; -const short PC_CMPI = 0x52; -const short PC_CMP = 0x53; -const short PC_CMPLI = 0x54; -const short PC_CMPL = 0x55; -const short PC_ANDI = 0x56; -const short PC_ANDIS = 0x57; -const short PC_ORI = 0x58; -const short PC_ORIS = 0x59; -const short PC_XORI = 0x5A; -const short PC_XORIS = 0x5B; -const short PC_AND = 0x5C; -const short PC_OR = 0x5D; -const short PC_XOR = 0x5E; -const short PC_NAND = 0x5F; -const short PC_NOR = 0x60; -const short PC_EQV = 0x61; -const short PC_ANDC = 0x62; -const short PC_ORC = 0x63; -const short PC_EXTSB = 0x64; -const short PC_EXTSH = 0x65; -const short PC_CNTLZW = 0x66; -const short PC_RLWINM = 0x67; -const short PC_RLWNM = 0x68; -const short PC_RLWIMI = 0x69; -const short PC_SLW = 0x6A; -const short PC_SRW = 0x6B; -const short PC_SRAWI = 0x6C; -const short PC_SRAW = 0x6D; -const short PC_CRAND = 0x6E; -const short PC_CRANDC = 0x6F; -const short PC_CREQV = 0x70; -const short PC_CRNAND = 0x71; -const short PC_CRNOR = 0x72; -const short PC_CROR = 0x73; -const short PC_CRORC = 0x74; -const short PC_CRXOR = 0x75; -const short PC_MCRF = 0x76; -const short PC_MTXER = 0x77; -const short PC_MTCTR = 0x78; -const short PC_MTLR = 0x79; -const short PC_MTCRF = 0x7A; -const short PC_MTMSR = 0x7B; -const short PC_MTSPR = 0x7C; -const short PC_MFMSR = 0x7D; -const short PC_MFSPR = 0x7E; -const short PC_MFXER = 0x7F; -const short PC_MFCTR = 0x80; -const short PC_MFLR = 0x81; -const short PC_MFCR = 0x82; -const short PC_MFFS = 0x83; -const short PC_MTFSF = 0x84; -const short PC_EIEIO = 0x85; -const short PC_ISYNC = 0x86; -const short PC_SYNC = 0x87; -const short PC_RFI = 0x88; -const short PC_LI = 0x89; -const short PC_LIS = 0x8A; -const short PC_MR = 0x8B; -const short PC_NOP = 0x8C; -const short PC_NOT = 0x8D; -const short PC_LFS = 0x8E; -const short PC_LFSU = 0x8F; -const short PC_LFSX = 0x90; -const short PC_LFSUX = 0x91; -const short PC_LFD = 0x92; -const short PC_LFDU = 0x93; -const short PC_LFDX = 0x94; -const short PC_LFDUX = 0x95; -const short PC_STFS = 0x96; -const short PC_STFSU = 0x97; -const short PC_STFSX = 0x98; -const short PC_STFSUX = 0x99; -const short PC_STFD = 0x9A; -const short PC_STFDU = 0x9B; -const short PC_STFDX = 0x9C; -const short PC_STFDUX = 0x9D; -const short PC_FMR = 0x9E; -const short PC_FABS = 0x9F; -const short PC_FNEG = 0xA0; -const short PC_FNABS = 0xA1; -const short PC_FADD = 0xA2; -const short PC_FADDS = 0xA3; -const short PC_FSUB = 0xA4; -const short PC_FSUBS = 0xA5; -const short PC_FMUL = 0xA6; -const short PC_FMULS = 0xA7; -const short PC_FDIV = 0xA8; -const short PC_FDIVS = 0xA9; -const short PC_FMADD = 0xAA; -const short PC_FMADDS = 0xAB; -const short PC_FMSUB = 0xAC; -const short PC_FMSUBS = 0xAD; -const short PC_FNMADD = 0xAE; -const short PC_FNMADDS = 0xAF; -const short PC_FNMSUB = 0xB0; -const short PC_FNMSUBS = 0xB1; -const short PC_FRES = 0xB2; -const short PC_FRSQRTE = 0xB3; -const short PC_FSEL = 0xB4; -const short PC_FRSP = 0xB5; -const short PC_FCTIW = 0xB6; -const short PC_FCTIWZ = 0xB7; -const short PC_FCMPU = 0xB8; -const short PC_FCMPO = 0xB9; -const short PC_LWARX = 0xBA; -const short PC_LSWI = 0xBB; -const short PC_LSWX = 0xBC; -const short PC_STFIWX = 0xBD; -const short PC_STSWI = 0xBE; -const short PC_STSWX = 0xBF; -const short PC_STWCX = 0xC0; -const short PC_ECIWX = 0xC1; -const short PC_ECOWX = 0xC2; -const short PC_DCBI = 0xC3; -const short PC_ICBI = 0xC4; -const short PC_MCRFS = 0xC5; -const short PC_MCRXR = 0xC6; -const short PC_MFTB = 0xC7; -const short PC_MFSR = 0xC8; -const short PC_MTSR = 0xC9; -const short PC_MFSRIN = 0xCA; -const short PC_MTSRIN = 0xCB; -const short PC_MTFSB0 = 0xCC; -const short PC_MTFSB1 = 0xCD; -const short PC_MTFSFI = 0xCE; -const short PC_SC = 0xCF; -const short PC_FSQRT = 0xD0; -const short PC_FSQRTS = 0xD1; -const short PC_TLBIA = 0xD2; -const short PC_TLBIE = 0xD3; -const short PC_TLBLD = 0xD4; -const short PC_TLBLI = 0xD5; -const short PC_TLBSYNC = 0xD6; -const short PC_TW = 0xD7; -const short PC_TRAP = 0xD8; -const short PC_TWI = 0xD9; -const short PC_OPWORD = 0xDA; -const short PC_MFROM = 0xDB; -const short PC_DSA = 0xDC; -const short PC_ESA = 0xDD; -const short PC_DCCCI = 0xDE; -const short PC_DCREAD = 0xDF; -const short PC_ICBT = 0xE0; -const short PC_ICCCI = 0xE1; -const short PC_ICREAD = 0xE2; -const short PC_RFCI = 0xE3; -const short PC_TLBRE = 0xE4; -const short PC_TLBSX = 0xE5; -const short PC_TLBWE = 0xE6; -const short PC_WRTEE = 0xE7; -const short PC_WRTEEI = 0xE8; -const short PC_MFDCR = 0xE9; -const short PC_MTDCR = 0xEA; -const short PC_DCBA = 0xEB; -const short PC_DSS = 0xEC; -const short PC_DSSALL = 0xED; -const short PC_DST = 0xEE; -const short PC_DSTT = 0xEF; -const short PC_DSTST = 0xF0; -const short PC_DSTSTT = 0xF1; -const short PC_LVEBX = 0xF2; -const short PC_LVEHX = 0xF3; -const short PC_LVEWX = 0xF4; -const short PC_LVSL = 0xF5; -const short PC_LVSR = 0xF6; -const short PC_LVX = 0xF7; -const short PC_LVXL = 0xF8; -const short PC_STVEBX = 0xF9; -const short PC_STVEHX = 0xFA; -const short PC_STVEWX = 0xFB; -const short PC_STVX = 0xFC; -const short PC_STVXL = 0xFD; -const short PC_MFVSCR = 0xFE; -const short PC_MTVSCR = 0xFF; -const short PC_VADDCUW = 0x100; -const short PC_VADDFP = 0x101; -const short PC_VADDSBS = 0x102; -const short PC_VADDSHS = 0x103; -const short PC_VADDSWS = 0x104; -const short PC_VADDUBM = 0x105; -const short PC_VADDUBS = 0x106; -const short PC_VADDUHM = 0x107; -const short PC_VADDUHS = 0x108; -const short PC_VADDUWM = 0x109; -const short PC_VADDUWS = 0x10A; -const short PC_VAND = 0x10B; -const short PC_VANDC = 0x10C; -const short PC_VAVGSB = 0x10D; -const short PC_VAVGSH = 0x10E; -const short PC_VAVGSW = 0x10F; -const short PC_VAVGUB = 0x110; -const short PC_VAVGUH = 0x111; -const short PC_VAVGUW = 0x112; -const short PC_VCFSX = 0x113; -const short PC_VCFUX = 0x114; -const short PC_VCMPBFP = 0x115; -const short PC_VCMPEQFP = 0x116; -const short PC_VCMPEQUB = 0x117; -const short PC_VCMPEQUH = 0x118; -const short PC_VCMPEQUW = 0x119; -const short PC_VCMPGEFP = 0x11A; -const short PC_VCMPGTFP = 0x11B; -const short PC_VCMPGTSB = 0x11C; -const short PC_VCMPGTSH = 0x11D; -const short PC_VCMPGTSW = 0x11E; -const short PC_VCMPGTUB = 0x11F; -const short PC_VCMPGTUH = 0x120; -const short PC_VCMPGTUW = 0x121; -const short PC_VCTSXS = 0x122; -const short PC_VCTUXS = 0x123; -const short PC_VEXPTEFP = 0x124; -const short PC_VLOGEFP = 0x125; -const short PC_VMAXFP = 0x126; -const short PC_VMAXSB = 0x127; -const short PC_VMAXSH = 0x128; -const short PC_VMAXSW = 0x129; -const short PC_VMAXUB = 0x12A; -const short PC_VMAXUH = 0x12B; -const short PC_VMAXUW = 0x12C; -const short PC_VMINFP = 0x12D; -const short PC_VMINSB = 0x12E; -const short PC_VMINSH = 0x12F; -const short PC_VMINSW = 0x130; -const short PC_VMINUB = 0x131; -const short PC_VMINUH = 0x132; -const short PC_VMINUW = 0x133; -const short PC_VMRGHB = 0x134; -const short PC_VMRGHH = 0x135; -const short PC_VMRGHW = 0x136; -const short PC_VMRGLB = 0x137; -const short PC_VMRGLH = 0x138; -const short PC_VMRGLW = 0x139; -const short PC_VMULESB = 0x13A; -const short PC_VMULESH = 0x13B; -const short PC_VMULEUB = 0x13C; -const short PC_VMULEUH = 0x13D; -const short PC_VMULOSB = 0x13E; -const short PC_VMULOSH = 0x13F; -const short PC_VMULOUB = 0x140; -const short PC_VMULOUH = 0x141; -const short PC_VNOR = 0x142; -const short PC_VOR = 0x143; -const short PC_VPKPX = 0x144; -const short PC_VPKSHSS = 0x145; -const short PC_VPKSHUS = 0x146; -const short PC_VPKSWSS = 0x147; -const short PC_VPKSWUS = 0x148; -const short PC_VPKUHUM = 0x149; -const short PC_VPKUHUS = 0x14A; -const short PC_VPKUWUM = 0x14B; -const short PC_VPKUWUS = 0x14C; -const short PC_VREFP = 0x14D; -const short PC_VRFIM = 0x14E; -const short PC_VRFIN = 0x14F; -const short PC_VRFIP = 0x150; -const short PC_VRFIZ = 0x151; -const short PC_VRLB = 0x152; -const short PC_VRLH = 0x153; -const short PC_VRLW = 0x154; -const short PC_VRSQRTEFP = 0x155; -const short PC_VSL = 0x156; -const short PC_VSLB = 0x157; -const short PC_VSLH = 0x158; -const short PC_VSLO = 0x159; -const short PC_VSLW = 0x15A; -const short PC_VSPLTB = 0x15B; -const short PC_VSPLTH = 0x15C; -const short PC_VSPLTW = 0x15D; -const short PC_VSPLTISB = 0x15E; -const short PC_VSPLTISH = 0x15F; -const short PC_VSPLTISW = 0x160; -const short PC_VSR = 0x161; -const short PC_VSRAB = 0x162; -const short PC_VSRAH = 0x163; -const short PC_VSRAW = 0x164; -const short PC_VSRB = 0x165; -const short PC_VSRH = 0x166; -const short PC_VSRO = 0x167; -const short PC_VSRW = 0x168; -const short PC_VSUBCUW = 0x169; -const short PC_VSUBFP = 0x16A; -const short PC_VSUBSBS = 0x16B; -const short PC_VSUBSHS = 0x16C; -const short PC_VSUBSWS = 0x16D; -const short PC_VSUBUBM = 0x16E; -const short PC_VSUBUBS = 0x16F; -const short PC_VSUBUHM = 0x170; -const short PC_VSUBUHS = 0x171; -const short PC_VSUBUWM = 0x172; -const short PC_VSUBUWS = 0x173; -const short PC_VSUMSWS = 0x174; -const short PC_VSUM2SWS = 0x175; -const short PC_VSUM4SBS = 0x176; -const short PC_VSUM4SHS = 0x177; -const short PC_VSUM4UBS = 0x178; -const short PC_VUPKHPX = 0x179; -const short PC_VUPKHSB = 0x17A; -const short PC_VUPKHSH = 0x17B; -const short PC_VUPKLPX = 0x17C; -const short PC_VUPKLSB = 0x17D; -const short PC_VUPKLSH = 0x17E; -const short PC_VXOR = 0x17F; -const short PC_VMADDFP = 0x180; -const short PC_VMHADDSHS = 0x181; -const short PC_VMHRADDSHS = 0x182; -const short PC_VMLADDUHM = 0x183; -const short PC_VMSUMMBM = 0x184; -const short PC_VMSUMSHM = 0x185; -const short PC_VMSUMSHS = 0x186; -const short PC_VMSUMUBM = 0x187; -const short PC_VMSUMUHM = 0x188; -const short PC_VMSUMUHS = 0x189; -const short PC_VNMSUBFP = 0x18A; -const short PC_VPERM = 0x18B; -const short PC_VSEL = 0x18C; -const short PC_VSLDOI = 0x18D; -const short PC_VMR = 0x18E; -const short PC_VMRP = 0x18F; -const short PC_SLE = 0x190; -const short PC_SLEQ = 0x191; -const short PC_SLIQ = 0x192; -const short PC_SLLIQ = 0x193; -const short PC_SLLQ = 0x194; -const short PC_SLQ = 0x195; -const short PC_SRAIQ = 0x196; -const short PC_SRAQ = 0x197; -const short PC_SRE = 0x198; -const short PC_SREA = 0x199; -const short PC_SREQ = 0x19A; -const short PC_SRIQ = 0x19B; -const short PC_SRLIQ = 0x19C; -const short PC_SRLQ = 0x19D; -const short PC_SRQ = 0x19E; -const short PC_MASKG = 0x19F; -const short PC_MASKIR = 0x1A0; -const short PC_LSCBX = 0x1A1; -const short PC_DIV = 0x1A2; -const short PC_DIVS = 0x1A3; -const short PC_DOZ = 0x1A4; -const short PC_MUL = 0x1A5; -const short PC_NABS = 0x1A6; -const short PC_ABS = 0x1A7; -const short PC_CLCS = 0x1A8; -const short PC_DOZI = 0x1A9; -const short PC_RLMI = 0x1AA; -const short PC_RRIB = 0x1AB; -const short PC_PENTRY = 0x1AC; -const short PC_PEXIT = 0x1AD; -const short OPCODE_MAX = 0x1AE; +//const short PC_B = 0x0; +//const short PC_BL = 0x1; +//const short PC_BC = 0x2; +//const short PC_BCLR = 0x3; +//const short PC_BCCTR = 0x4; +//const short PC_BT = 0x5; +//const short PC_BTLR = 0x6; +//const short PC_BTCTR = 0x7; +//const short PC_BF = 0x8; +//const short PC_BFLR = 0x9; +//const short PC_BFCTR = 0xA; +//const short PC_BDNZ = 0xB; +//const short PC_BDNZT = 0xC; +//const short PC_BDNZF = 0xD; +//const short PC_BDZ = 0xE; +//const short PC_BDZT = 0xF; +//const short PC_BDZF = 0x10; +//const short PC_BLR = 0x11; +//const short PC_BCTR = 0x12; +//const short PC_BCTRL = 0x13; +//const short PC_BLRL = 0x14; +//const short PC_LBZ = 0x15; +//const short PC_LBZU = 0x16; +//const short PC_LBZX = 0x17; +//const short PC_LBZUX = 0x18; +//const short PC_LHZ = 0x19; +//const short PC_LHZU = 0x1A; +//const short PC_LHZX = 0x1B; +//const short PC_LHZUX = 0x1C; +//const short PC_LHA = 0x1D; +//const short PC_LHAU = 0x1E; +//const short PC_LHAX = 0x1F; +//const short PC_LHAUX = 0x20; +//const short PC_LHBRX = 0x21; +//const short PC_LWZ = 0x22; +//const short PC_LWZU = 0x23; +//const short PC_LWZX = 0x24; +//const short PC_LWZUX = 0x25; +//const short PC_LWBRX = 0x26; +//const short PC_LMW = 0x27; +//const short PC_STB = 0x28; +//const short PC_STBU = 0x29; +//const short PC_STBX = 0x2A; +//const short PC_STBUX = 0x2B; +//const short PC_STH = 0x2C; +//const short PC_STHU = 0x2D; +//const short PC_STHX = 0x2E; +//const short PC_STHUX = 0x2F; +//const short PC_STHBRX = 0x30; +//const short PC_STW = 0x31; +//const short PC_STWU = 0x32; +//const short PC_STWX = 0x33; +//const short PC_STWUX = 0x34; +//const short PC_STWBRX = 0x35; +//const short PC_STMW = 0x36; +//const short PC_DCBF = 0x37; +//const short PC_DCBST = 0x38; +//const short PC_DCBT = 0x39; +//const short PC_DCBTST = 0x3A; +//const short PC_DCBZ = 0x3B; +//const short PC_ADD = 0x3C; +//const short PC_ADDC = 0x3D; +//const short PC_ADDE = 0x3E; +//const short PC_ADDI = 0x3F; +//const short PC_ADDIC = 0x40; +//const short PC_ADDICR = 0x41; +//const short PC_ADDIS = 0x42; +//const short PC_ADDME = 0x43; +//const short PC_ADDZE = 0x44; +//const short PC_DIVW = 0x45; +//const short PC_DIVWU = 0x46; +//const short PC_MULHW = 0x47; +//const short PC_MULHWU = 0x48; +//const short PC_MULLI = 0x49; +//const short PC_MULLW = 0x4A; +//const short PC_NEG = 0x4B; +//const short PC_SUBF = 0x4C; +//const short PC_SUBFC = 0x4D; +//const short PC_SUBFE = 0x4E; +//const short PC_SUBFIC = 0x4F; +//const short PC_SUBFME = 0x50; +//const short PC_SUBFZE = 0x51; +//const short PC_CMPI = 0x52; +//const short PC_CMP = 0x53; +//const short PC_CMPLI = 0x54; +//const short PC_CMPL = 0x55; +//const short PC_ANDI = 0x56; +//const short PC_ANDIS = 0x57; +//const short PC_ORI = 0x58; +//const short PC_ORIS = 0x59; +//const short PC_XORI = 0x5A; +//const short PC_XORIS = 0x5B; +//const short PC_AND = 0x5C; +//const short PC_OR = 0x5D; +//const short PC_XOR = 0x5E; +//const short PC_NAND = 0x5F; +//const short PC_NOR = 0x60; +//const short PC_EQV = 0x61; +//const short PC_ANDC = 0x62; +//const short PC_ORC = 0x63; +//const short PC_EXTSB = 0x64; +//const short PC_EXTSH = 0x65; +//const short PC_CNTLZW = 0x66; +//const short PC_RLWINM = 0x67; +//const short PC_RLWNM = 0x68; +//const short PC_RLWIMI = 0x69; +//const short PC_SLW = 0x6A; +//const short PC_SRW = 0x6B; +//const short PC_SRAWI = 0x6C; +//const short PC_SRAW = 0x6D; +//const short PC_CRAND = 0x6E; +//const short PC_CRANDC = 0x6F; +//const short PC_CREQV = 0x70; +//const short PC_CRNAND = 0x71; +//const short PC_CRNOR = 0x72; +//const short PC_CROR = 0x73; +//const short PC_CRORC = 0x74; +//const short PC_CRXOR = 0x75; +//const short PC_MCRF = 0x76; +//const short PC_MTXER = 0x77; +//const short PC_MTCTR = 0x78; +//const short PC_MTLR = 0x79; +//const short PC_MTCRF = 0x7A; +//const short PC_MTMSR = 0x7B; +//const short PC_MTSPR = 0x7C; +//const short PC_MFMSR = 0x7D; +//const short PC_MFSPR = 0x7E; +//const short PC_MFXER = 0x7F; +//const short PC_MFCTR = 0x80; +//const short PC_MFLR = 0x81; +//const short PC_MFCR = 0x82; +//const short PC_MFFS = 0x83; +//const short PC_MTFSF = 0x84; +//const short PC_EIEIO = 0x85; +//const short PC_ISYNC = 0x86; +//const short PC_SYNC = 0x87; +//const short PC_RFI = 0x88; +//const short PC_LI = 0x89; +//const short PC_LIS = 0x8A; +//const short PC_MR = 0x8B; +//const short PC_NOP = 0x8C; +//const short PC_NOT = 0x8D; +//const short PC_LFS = 0x8E; +//const short PC_LFSU = 0x8F; +//const short PC_LFSX = 0x90; +//const short PC_LFSUX = 0x91; +//const short PC_LFD = 0x92; +//const short PC_LFDU = 0x93; +//const short PC_LFDX = 0x94; +//const short PC_LFDUX = 0x95; +//const short PC_STFS = 0x96; +//const short PC_STFSU = 0x97; +//const short PC_STFSX = 0x98; +//const short PC_STFSUX = 0x99; +//const short PC_STFD = 0x9A; +//const short PC_STFDU = 0x9B; +//const short PC_STFDX = 0x9C; +//const short PC_STFDUX = 0x9D; +//const short PC_FMR = 0x9E; +//const short PC_FABS = 0x9F; +//const short PC_FNEG = 0xA0; +//const short PC_FNABS = 0xA1; +//const short PC_FADD = 0xA2; +//const short PC_FADDS = 0xA3; +//const short PC_FSUB = 0xA4; +//const short PC_FSUBS = 0xA5; +//const short PC_FMUL = 0xA6; +//const short PC_FMULS = 0xA7; +//const short PC_FDIV = 0xA8; +//const short PC_FDIVS = 0xA9; +//const short PC_FMADD = 0xAA; +//const short PC_FMADDS = 0xAB; +//const short PC_FMSUB = 0xAC; +//const short PC_FMSUBS = 0xAD; +//const short PC_FNMADD = 0xAE; +//const short PC_FNMADDS = 0xAF; +//const short PC_FNMSUB = 0xB0; +//const short PC_FNMSUBS = 0xB1; +//const short PC_FRES = 0xB2; +//const short PC_FRSQRTE = 0xB3; +//const short PC_FSEL = 0xB4; +//const short PC_FRSP = 0xB5; +//const short PC_FCTIW = 0xB6; +//const short PC_FCTIWZ = 0xB7; +//const short PC_FCMPU = 0xB8; +//const short PC_FCMPO = 0xB9; +//const short PC_LWARX = 0xBA; +//const short PC_LSWI = 0xBB; +//const short PC_LSWX = 0xBC; +//const short PC_STFIWX = 0xBD; +//const short PC_STSWI = 0xBE; +//const short PC_STSWX = 0xBF; +//const short PC_STWCX = 0xC0; +//const short PC_ECIWX = 0xC1; +//const short PC_ECOWX = 0xC2; +//const short PC_DCBI = 0xC3; +//const short PC_ICBI = 0xC4; +//const short PC_MCRFS = 0xC5; +//const short PC_MCRXR = 0xC6; +//const short PC_MFTB = 0xC7; +//const short PC_MFSR = 0xC8; +//const short PC_MTSR = 0xC9; +//const short PC_MFSRIN = 0xCA; +//const short PC_MTSRIN = 0xCB; +//const short PC_MTFSB0 = 0xCC; +//const short PC_MTFSB1 = 0xCD; +//const short PC_MTFSFI = 0xCE; +//const short PC_SC = 0xCF; +//const short PC_FSQRT = 0xD0; +//const short PC_FSQRTS = 0xD1; +//const short PC_TLBIA = 0xD2; +//const short PC_TLBIE = 0xD3; +//const short PC_TLBLD = 0xD4; +//const short PC_TLBLI = 0xD5; +//const short PC_TLBSYNC = 0xD6; +//const short PC_TW = 0xD7; +//const short PC_TRAP = 0xD8; +//const short PC_TWI = 0xD9; +//const short PC_OPWORD = 0xDA; +//const short PC_MFROM = 0xDB; +//const short PC_DSA = 0xDC; +//const short PC_ESA = 0xDD; +//const short PC_DCCCI = 0xDE; +//const short PC_DCREAD = 0xDF; +//const short PC_ICBT = 0xE0; +//const short PC_ICCCI = 0xE1; +//const short PC_ICREAD = 0xE2; +//const short PC_RFCI = 0xE3; +//const short PC_TLBRE = 0xE4; +//const short PC_TLBSX = 0xE5; +//const short PC_TLBWE = 0xE6; +//const short PC_WRTEE = 0xE7; +//const short PC_WRTEEI = 0xE8; +//const short PC_MFDCR = 0xE9; +//const short PC_MTDCR = 0xEA; +//const short PC_DCBA = 0xEB; +//const short PC_DSS = 0xEC; +//const short PC_DSSALL = 0xED; +//const short PC_DST = 0xEE; +//const short PC_DSTT = 0xEF; +//const short PC_DSTST = 0xF0; +//const short PC_DSTSTT = 0xF1; +//const short PC_LVEBX = 0xF2; +//const short PC_LVEHX = 0xF3; +//const short PC_LVEWX = 0xF4; +//const short PC_LVSL = 0xF5; +//const short PC_LVSR = 0xF6; +//const short PC_LVX = 0xF7; +//const short PC_LVXL = 0xF8; +//const short PC_STVEBX = 0xF9; +//const short PC_STVEHX = 0xFA; +//const short PC_STVEWX = 0xFB; +//const short PC_STVX = 0xFC; +//const short PC_STVXL = 0xFD; +//const short PC_MFVSCR = 0xFE; +//const short PC_MTVSCR = 0xFF; +//const short PC_VADDCUW = 0x100; +//const short PC_VADDFP = 0x101; +//const short PC_VADDSBS = 0x102; +//const short PC_VADDSHS = 0x103; +//const short PC_VADDSWS = 0x104; +//const short PC_VADDUBM = 0x105; +//const short PC_VADDUBS = 0x106; +//const short PC_VADDUHM = 0x107; +//const short PC_VADDUHS = 0x108; +//const short PC_VADDUWM = 0x109; +//const short PC_VADDUWS = 0x10A; +//const short PC_VAND = 0x10B; +//const short PC_VANDC = 0x10C; +//const short PC_VAVGSB = 0x10D; +//const short PC_VAVGSH = 0x10E; +//const short PC_VAVGSW = 0x10F; +//const short PC_VAVGUB = 0x110; +//const short PC_VAVGUH = 0x111; +//const short PC_VAVGUW = 0x112; +//const short PC_VCFSX = 0x113; +//const short PC_VCFUX = 0x114; +//const short PC_VCMPBFP = 0x115; +//const short PC_VCMPEQFP = 0x116; +//const short PC_VCMPEQUB = 0x117; +//const short PC_VCMPEQUH = 0x118; +//const short PC_VCMPEQUW = 0x119; +//const short PC_VCMPGEFP = 0x11A; +//const short PC_VCMPGTFP = 0x11B; +//const short PC_VCMPGTSB = 0x11C; +//const short PC_VCMPGTSH = 0x11D; +//const short PC_VCMPGTSW = 0x11E; +//const short PC_VCMPGTUB = 0x11F; +//const short PC_VCMPGTUH = 0x120; +//const short PC_VCMPGTUW = 0x121; +//const short PC_VCTSXS = 0x122; +//const short PC_VCTUXS = 0x123; +//const short PC_VEXPTEFP = 0x124; +//const short PC_VLOGEFP = 0x125; +//const short PC_VMAXFP = 0x126; +//const short PC_VMAXSB = 0x127; +//const short PC_VMAXSH = 0x128; +//const short PC_VMAXSW = 0x129; +//const short PC_VMAXUB = 0x12A; +//const short PC_VMAXUH = 0x12B; +//const short PC_VMAXUW = 0x12C; +//const short PC_VMINFP = 0x12D; +//const short PC_VMINSB = 0x12E; +//const short PC_VMINSH = 0x12F; +//const short PC_VMINSW = 0x130; +//const short PC_VMINUB = 0x131; +//const short PC_VMINUH = 0x132; +//const short PC_VMINUW = 0x133; +//const short PC_VMRGHB = 0x134; +//const short PC_VMRGHH = 0x135; +//const short PC_VMRGHW = 0x136; +//const short PC_VMRGLB = 0x137; +//const short PC_VMRGLH = 0x138; +//const short PC_VMRGLW = 0x139; +//const short PC_VMULESB = 0x13A; +//const short PC_VMULESH = 0x13B; +//const short PC_VMULEUB = 0x13C; +//const short PC_VMULEUH = 0x13D; +//const short PC_VMULOSB = 0x13E; +//const short PC_VMULOSH = 0x13F; +//const short PC_VMULOUB = 0x140; +//const short PC_VMULOUH = 0x141; +//const short PC_VNOR = 0x142; +//const short PC_VOR = 0x143; +//const short PC_VPKPX = 0x144; +//const short PC_VPKSHSS = 0x145; +//const short PC_VPKSHUS = 0x146; +//const short PC_VPKSWSS = 0x147; +//const short PC_VPKSWUS = 0x148; +//const short PC_VPKUHUM = 0x149; +//const short PC_VPKUHUS = 0x14A; +//const short PC_VPKUWUM = 0x14B; +//const short PC_VPKUWUS = 0x14C; +//const short PC_VREFP = 0x14D; +//const short PC_VRFIM = 0x14E; +//const short PC_VRFIN = 0x14F; +//const short PC_VRFIP = 0x150; +//const short PC_VRFIZ = 0x151; +//const short PC_VRLB = 0x152; +//const short PC_VRLH = 0x153; +//const short PC_VRLW = 0x154; +//const short PC_VRSQRTEFP = 0x155; +//const short PC_VSL = 0x156; +//const short PC_VSLB = 0x157; +//const short PC_VSLH = 0x158; +//const short PC_VSLO = 0x159; +//const short PC_VSLW = 0x15A; +//const short PC_VSPLTB = 0x15B; +//const short PC_VSPLTH = 0x15C; +//const short PC_VSPLTW = 0x15D; +//const short PC_VSPLTISB = 0x15E; +//const short PC_VSPLTISH = 0x15F; +//const short PC_VSPLTISW = 0x160; +//const short PC_VSR = 0x161; +//const short PC_VSRAB = 0x162; +//const short PC_VSRAH = 0x163; +//const short PC_VSRAW = 0x164; +//const short PC_VSRB = 0x165; +//const short PC_VSRH = 0x166; +//const short PC_VSRO = 0x167; +//const short PC_VSRW = 0x168; +//const short PC_VSUBCUW = 0x169; +//const short PC_VSUBFP = 0x16A; +//const short PC_VSUBSBS = 0x16B; +//const short PC_VSUBSHS = 0x16C; +//const short PC_VSUBSWS = 0x16D; +//const short PC_VSUBUBM = 0x16E; +//const short PC_VSUBUBS = 0x16F; +//const short PC_VSUBUHM = 0x170; +//const short PC_VSUBUHS = 0x171; +//const short PC_VSUBUWM = 0x172; +//const short PC_VSUBUWS = 0x173; +//const short PC_VSUMSWS = 0x174; +//const short PC_VSUM2SWS = 0x175; +//const short PC_VSUM4SBS = 0x176; +//const short PC_VSUM4SHS = 0x177; +//const short PC_VSUM4UBS = 0x178; +//const short PC_VUPKHPX = 0x179; +//const short PC_VUPKHSB = 0x17A; +//const short PC_VUPKHSH = 0x17B; +//const short PC_VUPKLPX = 0x17C; +//const short PC_VUPKLSB = 0x17D; +//const short PC_VUPKLSH = 0x17E; +//const short PC_VXOR = 0x17F; +//const short PC_VMADDFP = 0x180; +//const short PC_VMHADDSHS = 0x181; +//const short PC_VMHRADDSHS = 0x182; +//const short PC_VMLADDUHM = 0x183; +//const short PC_VMSUMMBM = 0x184; +//const short PC_VMSUMSHM = 0x185; +//const short PC_VMSUMSHS = 0x186; +//const short PC_VMSUMUBM = 0x187; +//const short PC_VMSUMUHM = 0x188; +//const short PC_VMSUMUHS = 0x189; +//const short PC_VNMSUBFP = 0x18A; +//const short PC_VPERM = 0x18B; +//const short PC_VSEL = 0x18C; +//const short PC_VSLDOI = 0x18D; +//const short PC_VMR = 0x18E; +//const short PC_VMRP = 0x18F; +//const short PC_SLE = 0x190; +//const short PC_SLEQ = 0x191; +//const short PC_SLIQ = 0x192; +//const short PC_SLLIQ = 0x193; +//const short PC_SLLQ = 0x194; +//const short PC_SLQ = 0x195; +//const short PC_SRAIQ = 0x196; +//const short PC_SRAQ = 0x197; +//const short PC_SRE = 0x198; +//const short PC_SREA = 0x199; +//const short PC_SREQ = 0x19A; +//const short PC_SRIQ = 0x19B; +//const short PC_SRLIQ = 0x19C; +//const short PC_SRLQ = 0x19D; +//const short PC_SRQ = 0x19E; +//const short PC_MASKG = 0x19F; +//const short PC_MASKIR = 0x1A0; +//const short PC_LSCBX = 0x1A1; +//const short PC_DIV = 0x1A2; +//const short PC_DIVS = 0x1A3; +//const short PC_DOZ = 0x1A4; +//const short PC_MUL = 0x1A5; +//const short PC_NABS = 0x1A6; +//const short PC_ABS = 0x1A7; +//const short PC_CLCS = 0x1A8; +//const short PC_DOZI = 0x1A9; +//const short PC_RLMI = 0x1AA; +//const short PC_RRIB = 0x1AB; +//const short PC_PENTRY = 0x1AC; +//const short PC_PEXIT = 0x1AD; +//const short OPCODE_MAX = 0x1AE; extern OpcodeInfo opcodeinfo[OPCODE_MAX]; extern void pcode_get_hi_lo(int bits, char typechar, SInt32 *hi, SInt32 *lo); extern int pcode_check_imm_bits(SInt32 value, int bits, char typechar); -extern int pcode_const_from_format(const char *format, int *pResult); +extern int pcode_const_from_format(const char *format, SInt32 *pResult); extern PCode *vformatpcode(short opcode, va_list argList); extern int expectandformatoperand(PCodeArg *operand, PCOpKind expectedKind, char a3, int bitCount, char *buf); extern int formatoperand(PCodeArg *operand, char *buf); diff --git a/includes/compiler/PCodeListing.h b/includes/compiler/PCodeListing.h new file mode 100644 index 0000000..32390ac --- /dev/null +++ b/includes/compiler/PCodeListing.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_PCODELISTING_H +#define COMPILER_PCODELISTING_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/PPCError.h b/includes/compiler/PPCError.h new file mode 100644 index 0000000..c211912 --- /dev/null +++ b/includes/compiler/PPCError.h @@ -0,0 +1,11 @@ +#ifndef COMPILER_PPCERROR_H +#define COMPILER_PPCERROR_H + +#include "compiler/common.h" + +extern void PPCError_Error(int code, ...); +extern void PPCError_Warning(int code, ...); +extern void PPCError_Message(char *format, ...); +extern void PPCError_ErrorTerm(short code, ...); + +#endif diff --git a/includes/compiler/Peephole.h b/includes/compiler/Peephole.h new file mode 100644 index 0000000..d391c09 --- /dev/null +++ b/includes/compiler/Peephole.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_PEEPHOLE_H +#define COMPILER_PEEPHOLE_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/RegisterInfo.h b/includes/compiler/RegisterInfo.h new file mode 100644 index 0000000..2ef2a82 --- /dev/null +++ b/includes/compiler/RegisterInfo.h @@ -0,0 +1,42 @@ +#ifndef COMPILER_REGISTERINFO_H +#define COMPILER_REGISTERINFO_H + +#include "compiler/common.h" +#include "compiler/Registers.h" + +extern short last_exception_register[RegClassMax]; +extern short first_fe_temporary_register[RegClassMax]; +extern short last_argument_register[RegClassMax]; +extern short _FP_; +extern short _CALLER_SP_; +extern char *special_register_names[RegClassMax][RegisterMax]; +extern short spr_to_sysreg[4]; + +extern void asm_used_register(char rclass, short reg); +extern void retain_register(Object *obj, char rclass, short reg); +extern void retain_GPR_pair(Object *obj, short reg, short regHi); +extern int is_register_object(Object *obj); +extern int GetABIFirstNonVolatile(char rclass); +extern char GetRegisterClassName(char rclass); +extern void setup_diagnostic_reg_strings(void); +extern void init_target_registers(void); +extern void assign_register_by_type(Object *obj); +extern void assign_GPR_pair(Object *obj); +extern void open_fe_temp_registers(void); +extern void set_last_exception_registers(void); +extern VarInfo *Registers_GetVarInfo(Object *obj); +extern int used_vrstate_VRs(void); +extern UInt32 colored_vrs_as_vrsave(PCodeBlock *block); +extern void save_before_coloring_nonvolatile_registers(char rclass); +extern void reset_nonvolatile_registers(char rclass); +extern int is_nonvolatile_register(char rclass, int reg); +extern void init_endian(void); +extern void update_asm_nonvolatile_registers(void); + +#define OBJECT_REG(obj) ( Registers_GetVarInfo((obj)) ? (Registers_GetVarInfo((obj))->reg) : 0 ) +#define OBJECT_REG_HI(obj) ( Registers_GetVarInfo((obj)) ? (Registers_GetVarInfo((obj))->regHi) : 0 ) +#define ALLOC_GPR() (used_virtual_registers[RegClass_GPR]++) +#define ALLOC_FPR() (used_virtual_registers[RegClass_FPR]++) +#define ALLOC_VR() (used_virtual_registers[RegClass_VR]++) + +#endif diff --git a/includes/compiler/Registers.h b/includes/compiler/Registers.h new file mode 100644 index 0000000..692d9dc --- /dev/null +++ b/includes/compiler/Registers.h @@ -0,0 +1,54 @@ +#ifndef COMPILER_REGISTERS_H +#define COMPILER_REGISTERS_H + +#include "compiler/common.h" + +enum { + RegisterMax = 32 +}; +const char RegClass_SPR = 0; +const char RegClass_CRFIELD = 1; +const char RegClass_VR = 2; +const char RegClass_FPR = 3; +const char RegClass_GPR = 4; +const char RegClassMax = 5; +const char RegClass_6 = 6; +const char RegClass_DCR = 7; + +enum { + RegState0 = 0, + RegState1 = 1, + RegState2 = 2 +}; + +extern int used_virtual_registers[RegClassMax]; +extern int used_nonvolatile_registers[RegClassMax]; +extern int assignable_registers[RegClassMax]; +extern int n_real_registers[RegClassMax]; +extern int n_scratch_registers[RegClassMax]; +extern int scratch_registers[RegClassMax][RegisterMax]; +extern int n_nonvolatile_registers[RegClassMax]; +extern int nonvolatile_registers[RegClassMax][RegisterMax]; +extern UInt8 reg_state[RegClassMax][RegisterMax]; +extern int first_temporary_register[RegClassMax]; +extern int last_temporary_register[RegClassMax]; +extern char *register_class_name[RegClassMax]; +extern char *register_class_format[RegClassMax]; +extern int coloring; +extern int optimizing; + +extern void init_registers(void); +extern void assign_register_to_variable(Object *obj, char rclass); +extern void retain_register_for_argument(Object *obj, char rclass, short reg); +extern int available_registers(char rclass); +extern UInt32 volatile_registers(char rclass); +extern short obtain_nonvolatile_register(char rclass); +extern void open_temp_registers(void); +extern void check_temp_registers(void); +extern void close_temp_registers(void); +extern int count_scratch_registers(void); +extern void init_modified_registers(void); +extern void note_modified_registers(Object *obj); +extern void find_modified_registers(Object *obj, UInt32 *masks); + +#endif diff --git a/includes/compiler/Scheduler.h b/includes/compiler/Scheduler.h new file mode 100644 index 0000000..535bab5 --- /dev/null +++ b/includes/compiler/Scheduler.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_SCHEDULER_H +#define COMPILER_SCHEDULER_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/SpillCode.h b/includes/compiler/SpillCode.h new file mode 100644 index 0000000..3d6b911 --- /dev/null +++ b/includes/compiler/SpillCode.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_SPILLCODE_H +#define COMPILER_SPILLCODE_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/StackFrame.h b/includes/compiler/StackFrame.h index 3145bdb..04ebb0d 100644 --- a/includes/compiler/StackFrame.h +++ b/includes/compiler/StackFrame.h @@ -22,12 +22,12 @@ extern Boolean large_stack; extern Object *dummyvaparam; extern void *dummyprofiler; -extern void init_stack_globals(void); -extern void init_frame_sizes(void); +extern void init_stack_globals(Object *funcobj); +extern void init_frame_sizes(Boolean has_varargs); extern void assign_local_memory(Object *obj); extern void assign_locals_to_memory(ObjectList *first); extern void compute_frame_sizes(void); -extern void generate_prologue(PCodeBlock *block); +extern void generate_prologue(PCodeBlock *block, Boolean has_varargs); extern void generate_epilogue(PCodeBlock *block, Boolean add_blr); extern void allocate_dynamic_stack_space(Boolean flag1, int reg1, int reg2, SInt32 size); extern char *generate_traceback(SInt32 funcsize, char *funcname, SInt32 *tbsize, Object *func); diff --git a/includes/compiler/StrengthReduction.h b/includes/compiler/StrengthReduction.h new file mode 100644 index 0000000..3686c4b --- /dev/null +++ b/includes/compiler/StrengthReduction.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_STRENGTHREDUCTION_H +#define COMPILER_STRENGTHREDUCTION_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/StructMoves.h b/includes/compiler/StructMoves.h new file mode 100644 index 0000000..3a1107b --- /dev/null +++ b/includes/compiler/StructMoves.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_STRUCTMOVES_H +#define COMPILER_STRUCTMOVES_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/Switch.h b/includes/compiler/Switch.h new file mode 100644 index 0000000..4d2c2b3 --- /dev/null +++ b/includes/compiler/Switch.h @@ -0,0 +1,28 @@ +#ifndef COMPILER_SWITCH_H +#define COMPILER_SWITCH_H + +#include "compiler/common.h" + +typedef struct SwitchCase { + struct SwitchCase *next; + CLabel *label; + CInt64 min; + CInt64 max; +} SwitchCase; +typedef struct CaseRange { + CInt64 min; + CInt64 range; + PCodeLabel *label; +} CaseRange; + +typedef struct SwitchInfo { + SwitchCase *cases; + CLabel *defaultlabel; +} SwitchInfo; + +extern ObjectList *switchtables; + +extern void switchstatement(ENode *expr, SwitchInfo *info); +extern void dumpswitchtables(Object *funcobj); + +#endif diff --git a/includes/compiler/TOC.h b/includes/compiler/TOC.h index 59ec8a1..c5eabb0 100644 --- a/includes/compiler/TOC.h +++ b/includes/compiler/TOC.h @@ -41,7 +41,7 @@ typedef struct COVCResult { // this struct might be used in other places too??? short op1; short op2; - unsigned char arg; + char arg; } COVCResult; extern Boolean canoptimizevectorconst(MWVector128 *vecp, Type *type, COVCResult *result); extern Boolean TOC_use_fsel(ENode *expr); diff --git a/includes/compiler/Unmangle.h b/includes/compiler/Unmangle.h new file mode 100644 index 0000000..5e230b0 --- /dev/null +++ b/includes/compiler/Unmangle.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_UNMANGLE_H +#define COMPILER_UNMANGLE_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/UseDefChains.h b/includes/compiler/UseDefChains.h new file mode 100644 index 0000000..bcdbfe0 --- /dev/null +++ b/includes/compiler/UseDefChains.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_USEDEFCHAINS_H +#define COMPILER_USEDEFCHAINS_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/ValueNumbering.h b/includes/compiler/ValueNumbering.h new file mode 100644 index 0000000..0d15e5a --- /dev/null +++ b/includes/compiler/ValueNumbering.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_VALUENUMBERING_H +#define COMPILER_VALUENUMBERING_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/VectorArraysToRegs.h b/includes/compiler/VectorArraysToRegs.h new file mode 100644 index 0000000..ab0a966 --- /dev/null +++ b/includes/compiler/VectorArraysToRegs.h @@ -0,0 +1,6 @@ +#ifndef COMPILER_VECTORARRAYSTOREGS_H +#define COMPILER_VECTORARRAYSTOREGS_H + +#include "compiler/common.h" + +#endif diff --git a/includes/compiler/common.h b/includes/compiler/common.h index 15043f5..48a33dc 100644 --- a/includes/compiler/common.h +++ b/includes/compiler/common.h @@ -204,14 +204,15 @@ typedef struct TemplParamID { typedef enum TemplDepSubType { TDE_PARAM, TDE_TYPEEXPR, + TDE_unk2, // may actually be 1? TDE_CAST, TDE_QUALNAME, TDE_QUALTEMPL, - TDE_OBJACCESS, - TDE_SOURCEREF, - TDE_FUNCCALL, - TDE_LOCAL, - TDE_MONAND, + //TDE_OBJACCESS, + //TDE_SOURCEREF, + //TDE_FUNCCALL, + //TDE_LOCAL, + TDE_MONAND = 7, TDE_MONPLUS, TDE_MONMUL, TDE_NEW, @@ -333,6 +334,14 @@ struct CParams { CWDataType targetCPU; char *targetName; }; + +#define FITS_IN_SHORT(value) ( (value) == ((short) (value)) ) +#define FITS_IN_USHORT(value) ( (value) == ((unsigned short) (value)) ) +#define FITS_IN_HI_SHORT(value) ( (value) == (value & 0xFFFF0000) ) +#define FITS_IN_SHORT2(value) ( ((short) (value)) == (value) ) +#define HIGH_PART(value) ( (short) (((value) >> 16) + (((value) & 0x8000) >> 15)) ) +#define LOW_PART(value) ( (short) (value) ) + #ifdef __MWERKS__ #pragma options align=reset #endif diff --git a/includes/compiler/enode.h b/includes/compiler/enode.h index e12b1ae..92c7d2c 100644 --- a/includes/compiler/enode.h +++ b/includes/compiler/enode.h @@ -91,10 +91,12 @@ typedef enum ENodeType { struct EMemberInfo { BClassList *path; - ENodeList *nodes; - void *x8; - void *xC; - void *x10; + ENode *expr; + NameSpaceObjectList *list; + TemplArg *templargs; + Boolean pr_1D; + Boolean x11; + Boolean isambig; }; @@ -172,7 +174,9 @@ typedef union ENodeUnion { struct { NameSpaceObjectList *list; TemplArg *templargs; + HashNameNode *name; } objlist; + EMemberInfo *emember; void *inst; MemInitializer *ctorinit; Statement *stmt; @@ -275,9 +279,13 @@ enum { }; #define ENODE_IS(_enode, _etype) ( (_enode)->type == (_etype) ) -#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_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_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)) ) +#define ENODE_IS_ASSIGN(_enode) ( ENODE_IS_RANGE((_enode), EASS, EORASS) ) +#define ENODE_IS_ASSIGN_TO(_enode, _etype) ( ENODE_IS_RANGE((_enode), EASS, EORASS) && ENODE_IS((_enode)->data.diadic.left->data.monadic, (_etype)) ) #ifdef __MWERKS__ #pragma options align=reset diff --git a/includes/compiler/objects.h b/includes/compiler/objects.h index 5f01d26..a6a170b 100644 --- a/includes/compiler/objects.h +++ b/includes/compiler/objects.h @@ -2,6 +2,7 @@ #define COMPILER_OBJECTS_H #include "compiler/common.h" +#include "compiler/tokens.h" #ifdef __MWERKS__ #pragma options align=mac68k diff --git a/includes/compiler/templates.h b/includes/compiler/templates.h index 85bc5ec..227dd7b 100644 --- a/includes/compiler/templates.h +++ b/includes/compiler/templates.h @@ -160,6 +160,7 @@ struct TemplClassInst { #define TEMPL_CLASS(ty) ( (TemplClass *) (ty) ) #define TEMPL_CLASS_INST(ty) ( (TemplClassInst *) (ty) ) +#define IS_TEMPL_CLASS(ty) ( IS_TYPE_CLASS(ty) && (TYPE_CLASS(ty)->flags & CLASS_FLAGS_100) ) /*************/ /* Functions */ @@ -189,6 +190,10 @@ struct TemplFuncInstance { // verified via CPrec Boolean static_instantiated; }; +#define TEMPL_FUNC(ty) ( (TemplateFunction *) (ty) ) +#define TEMPL_FUNC_INST(ty) ( (TemplFuncInstance *) (ty) ) +#define IS_TEMPL_FUNC(ty) ( IS_TYPE_FUNC(ty) && (TYPE_FUNC(ty)->flags & FUNC_FLAGS_100000) ) + /***********/ /* Actions */ /***********/ diff --git a/includes/compiler/tokens.h b/includes/compiler/tokens.h index 2f49f98..9a3a258 100644 --- a/includes/compiler/tokens.h +++ b/includes/compiler/tokens.h @@ -180,6 +180,7 @@ struct TStreamElement { TData data; }; +// this is actually called TokenStream struct TStream { SInt32 tokens; TStreamElement *firsttoken; diff --git a/includes/compiler/types.h b/includes/compiler/types.h index e5b4d94..47f6421 100644 --- a/includes/compiler/types.h +++ b/includes/compiler/types.h @@ -51,9 +51,18 @@ typedef enum IntegralType { IT_FLOAT = 13, IT_SHORTDOUBLE = 14, IT_DOUBLE = 15, - IT_LONGDOUBLE = 16 + IT_LONGDOUBLE = 16, + IT_17 = 17, + IT_18 = 18, + IT_19 = 19, + IT_20 = 20, + IT_21 = 21, + IT_22 = 22, + IT_23 = 23, + IT_24 = 24 } IntegralType; +// This is probably actually called AtomType / TypeAtom struct TypeIntegral { TypeType type; SInt32 size; @@ -87,10 +96,11 @@ struct StructMember { UInt32 qual; }; -enum { +/*enum { STRUCT_TYPE_STRUCT = 0, STRUCT_TYPE_UNION = 1, STRUCT_TYPE_CLASS = 2, + STRUCT_TYPE_3 = 3, STRUCT_TYPE_4 = 4, STRUCT_TYPE_5 = 5, STRUCT_TYPE_6 = 6, @@ -102,7 +112,22 @@ enum { STRUCT_TYPE_C = 12, STRUCT_TYPE_D = 13, STRUCT_TYPE_E = 14 -}; +};*/ +const char STRUCT_TYPE_STRUCT = 0; +const char STRUCT_TYPE_UNION = 1; +const char STRUCT_TYPE_CLASS = 2; +const char STRUCT_TYPE_3 = 3; +const char STRUCT_TYPE_4 = 4; +const char STRUCT_TYPE_5 = 5; +const char STRUCT_TYPE_6 = 6; +const char STRUCT_TYPE_7 = 7; +const char STRUCT_TYPE_8 = 8; +const char STRUCT_TYPE_9 = 9; +const char STRUCT_TYPE_A = 10; +const char STRUCT_TYPE_B = 11; +const char STRUCT_TYPE_C = 12; +const char STRUCT_TYPE_D = 13; +const char STRUCT_TYPE_E = 14; struct ClassList { // checked via CPrec @@ -235,7 +260,7 @@ enum { FUNC_FLAGS_40 = 0x40, // func that's like "operator SomeOtherType()" FUNC_FLAGS_80 = 0x80, FUNC_FLAGS_100 = 0x100, - FUNC_FLAGS_200 = 0x200, + FUNC_FLAGS_200 = 0x200, // intrinsic? FUNC_FLAGS_NOTHROW = 0x400, FUNC_FLAGS_800 = 0x800, FUNC_FLAGS_1000 = 0x1000, @@ -367,16 +392,22 @@ struct TypeList { #define TYPE_TEMPLATE(ty) ((TypeTemplDep *) (ty)) #define TYPE_MEMBER_POINTER(ty) ((TypeMemberPointer *) (ty)) #define TYPE_POINTER(ty) ((TypePointer *) (ty)) +#define TPTR_TARGET(ty) (TYPE_POINTER(ty)->target) +#define TPTR_QUAL(ty) (TYPE_POINTER(ty)->qual) #define IS_TYPE_VOID(ty) ( (ty)->type == TYPEVOID ) #define IS_TYPE_INT(ty) ( (ty)->type == TYPEINT ) #define IS_TYPE_ENUM(ty) ( (ty)->type == TYPEENUM ) #define IS_TYPE_INT_OR_ENUM(ty) ( IS_TYPE_INT(ty) || IS_TYPE_ENUM(ty) ) #define IS_TYPE_FLOAT(ty) ( (ty)->type == TYPEFLOAT ) +#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_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_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_TYPE_TEMPLATE(ty) ( (ty)->type == TYPETEMPLATE ) #define IS_TYPE_POINTER(ty) ( (ty)->type == TYPEPOINTER || (ty)->type == TYPEARRAY ) #define IS_TYPE_POINTER_ONLY(ty) ( (ty)->type == TYPEPOINTER ) @@ -384,7 +415,8 @@ struct TypeList { #define IS_TYPEPOINTER_REFERENCE(ty) ( (ty)->qual & Q_REFERENCE ) #define IS_TYPE_ARRAY(ty) ( (ty)->type == TYPEARRAY ) #define IS_TYPE_BITFIELD(ty) ( (ty)->type == TYPEBITFIELD ) -#define IS_TYPESTRUCT_VECTOR(ty) ( (ty)->stype >= STRUCT_TYPE_4 && (ty)->stype <= STRUCT_TYPE_E ) +#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_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 ) @@ -393,6 +425,8 @@ struct TypeList { #define TYPE_FITS_IN_REGISTER(ty) ( ((ty)->type == TYPEINT) || ((ty)->type == TYPEENUM) || (IS_TYPE_POINTER(ty) && ((ty)->type != TYPEARRAY)) || IS_TYPE_4BYTES_MEMBERPOINTER(ty) ) #define TYPE_IS_8BYTES(ty) ( (((ty)->type == TYPEINT) || ((ty)->type == TYPEENUM)) && ((ty)->size == 8) ) +#define TYPE_FITS_IN_REGISTER_2(ty) ( ((ty)->type == TYPEINT) || ((ty)->type == TYPEENUM) || IS_TYPE_POINTER(ty) || IS_TYPE_4BYTES_MEMBERPOINTER(ty) ) + #define OBJ_GET_TARGET_VOLATILE(obj) ( IS_TYPE_POINTER((obj)->type) ? (TYPE_POINTER((obj)->type)->qual & Q_VOLATILE) : ((obj)->qual & Q_VOLATILE) ) #define OBJ_GET_TARGET_CONST(obj) ( IS_TYPE_POINTER((obj)->type) ? (TYPE_POINTER((obj)->type)->qual & Q_CONST) : ((obj)->qual & Q_CONST) ) |