diff options
Diffstat (limited to 'includes/compiler.h')
-rw-r--r-- | includes/compiler.h | 806 |
1 files changed, 210 insertions, 596 deletions
diff --git a/includes/compiler.h b/includes/compiler.h index 319f95e..6557749 100644 --- a/includes/compiler.h +++ b/includes/compiler.h @@ -8,276 +8,29 @@ #pragma options align=mac68k #endif -enum { - AlignMode0_Mac68k, - AlignMode1_Mac68k4byte, - AlignMode2_PPC, - AlignMode3_1Byte, - AlignMode4_2Byte, - AlignMode5_4Byte, - AlignMode6_8Byte, - AlignMode7_16Byte, - AlignMode8 -}; -// not sure how many of these are char and how many are unsigned char or Boolean -typedef struct COpts { - char little_endian; - char codegen_dynamic; - char codegen_pic; - char no_common; - char no_implicit_templates; - char absolutepath; // determines the path written to debug info - char x06; // linker/objgen related - short cpu; - char schedule_cpu; - unsigned char schedule_mode; // may be an enum?? - SInt32 debuglisting; - char profile; - char traceback; - char disable_registers; - char fp_contract; - char no_register_save_helpers; - char ppc_unroll_speculative; - short ppc_unroll_instructions_limit; - short ppc_unroll_factor_limit; - char altivec_model; - UInt8 x1B; // altivec/vrsave related - UInt8 code_alignment; - char x1D; - UInt8 x1E; // some register used in TOC_use_isel - UInt8 gen_fsel; - char ppc_opt_bclr_bcctr; - char use_lmw_stmw; - char report_heap_info; - char misaligned_mem_access; - char switch_tables; - char prepare_compress; - char some_alignment; // used in CMach_AllocationAlignment - char asmsemicolcomment; - char asmpoundcomment; - StringPtr oldprefixname; - short inlinelevel; - int inline_max_size; - int inline_max_total_size; - char inline_bottom_up; - Boolean cplusplus; - Boolean ecplusplus; - char objective_c; - char objc_strict; - char ARM_conform; - char ARM_scoping; - char require_prototypes; - char trigraphs; - char only_std_keywords; - char enumsalwaysint; - char ANSI_strict; - char mpwc_relax; - char mpwc_newline; - char ignore_oldstyle; - char cpp_extensions; - char pointercast_lvalue; - char useRTTI; - char delete_exception; - char _4B; - Boolean oldalignment; - char unsignedchars; - char multibyteaware; - char autoinline; - char defer_codegen; - Boolean direct_to_som; - char som_env_check; - char som_call_opt; - char booltruefalse; - char old_enum_mangler; - char longlong; - char longlong_enums; - char no_tfuncinline; - char _59; - char flat_include; - char syspath_once; - char always_import; - char simple_class_byval; - char wchar_type; - char vbase_ctor_offset; - char vbase_abi_v2; - char def_inherited; - char template_patch; - char template_friends; - char faster_pch_gen; - char array_new_delete; - Boolean dollar_identifiers; - char def_inline_tfuncs; - char arg_dep_lookup; - Boolean simple_prepdump; - char line_prepdump; - char fullpath_prepdump; - char old_mtemplparser; - char suppress_init_code; - char reverse_bitfields; - Boolean c9x; - char float_constants; - char no_static_dtors; - char longlong_prepeval; - char const_strings; - char dumpir; - char experimental; - char gcc_extensions; - char stdc_fp_contract; - char stdc_fenv_access; - char stdc_cx_limitedr; - char old_argmatch; - char optEH; - char optEH2; - char new_mangler; - char microsoft; - Boolean warningerrors; - char pedantic; - char check_header_flags; - Boolean supress_warnings; - Boolean warn_illpragma; - char warn_emptydecl; - char warn_possunwant; - char warn_unusedvar; - char warn_unusedarg; - char warn_extracomma; - char warn_hidevirtual; - char warn_largeargs; - char warn_implicitconv; - char warn_notinlined; - char warn_structclass; - char warn_padding; - char warn_no_side_effect; - char warn_resultnotused; - char warn_ptr_int_conv; - char align_mode; - Boolean align_array_members; - char dont_reuse_strings; - char pool_strings; - char explicit_zero_data; - char readonly_strings; - char exceptions; - char _99; - char dont_inline; - char always_inline; - char peephole; - char global_optimizer; - char side_effects; - char internal; - char import; - char export; - char lib_export; - char nosyminline; - char force_active; - char optimizationlevel; - char optimize_for_size; - char optimizewithasm; - char crippled; - char opt_common_subs; - char opt_loop_invariants; - char opt_propagation; - char opt_dead_assignments; - char opt_strength_reduction; - char opt_strength_reduction_strict; - char opt_dead_code; - char opt_lifetimes; - char _B1; // unused? - char opt_unroll_loops; - char opt_vectorize_loops; - char _B4; // amount of IRO passes? - char opt_pointer_analysis; - char opt_pointer_analysis_mode; - char loop_unroll_count; - char loop_unroll_size_threshold; - char isGeneratingDebugInfo; - CWDataType pchCreator; - CWDataType pchType; - CWDataType text; - HashNameNode *forcedSegment; // when set by #pragma segment -} COpts; - -typedef struct CParams { - CWPluginContext context; - CWObjectData objectdata; - Handle objectDataHandle; - Handle browseDataHandle; - SInt32 pluginRequest; - SInt32 apiVersion; - FSSpec projectFile; - SInt32 projectFileCount; - SInt32 mainFileNumber; - FSSpec mainFileSpec; - const char *mainFileText; - SInt32 mainFileTextLength; - Boolean isPrecompiling; - Boolean isAutoPrecompiling; - Boolean isPreprocessing; - Boolean isGeneratingDebugInfo; - Boolean isCachingPrecompiledHeaders; - CWBrowseOptions browseOptions; - Boolean field276; - SInt16 mainFileID; - CWDataType targetOS; - CWDataType targetCPU; - char *targetName; -} CParams; - - -typedef struct VarInfo { // OK! - Object *func; - SInt32 usage; - TStreamElement deftoken; - SInt16 varnumber; - Boolean noregister; - Boolean used; - UInt8 flags; - UInt8 rclass; - SInt16 reg; - SInt16 regHi; -} VarInfo; - - - -typedef struct DefArgCtorInfo { + + + +struct DefArgCtorInfo { Object *default_func; ENode *default_arg; -} DefArgCtorInfo; +}; typedef struct XRefOffset { UInt32 xrefoffset; SInt32 offset; } XRefOffset; -typedef struct InlineXRef { - struct InlineXRef *next; +struct InlineXRef { + InlineXRef *next; Object *object; UInt16 xrefmode; UInt16 numxrefs; XRefOffset xref[1]; -} InlineXRef; - - -typedef enum StatementType { - ST_NOP = 1, - ST_LABEL, - ST_GOTO, - ST_EXPRESSION, - ST_SWITCH, - ST_IFGOTO, - ST_IFNGOTO, - ST_RETURN, - ST_OVF, - ST_EXIT, - ST_ENTRY, - ST_BEGINCATCH, - ST_ENDCATCH, - ST_ENDCATCHDTOR, - ST_GOTOEXPR, - ST_ASM, - ST_BEGINLOOP, - ST_ENDLOOP, - ST_ILLEGAL -} StatementType; +}; + + typedef enum ExceptionActionType { EAT_NOP, @@ -301,8 +54,8 @@ typedef enum ExceptionActionType { EAT_NACTIONS } ExceptionActionType; -typedef struct ExceptionAction { - struct ExceptionAction *prev; +struct ExceptionAction { + ExceptionAction *prev; union { struct { Object *local; @@ -385,32 +138,10 @@ typedef struct ExceptionAction { } local; } data; ExceptionActionType type; -} ExceptionAction; - -typedef struct Statement { - struct Statement *next; - StatementType type; - char marked; - UInt8 flags; - UInt16 value; - ENode *expr; - CLabel *label; - ExceptionAction *dobjstack; - SInt32 sourceoffset; - HashNameNode *sourcefilepath; -} Statement; - -typedef struct CLabel { - struct CLabel *next; - Statement *stmt; - HashNameNode *uniquename; - HashNameNode *name; - PCodeLabel *pclabel; - void *sicg_label; -} CLabel; - -typedef struct MemInitializer { - struct MemInitializer *next; +}; + +struct MemInitializer { + MemInitializer *next; union { ENodeList *nodes; ENode *expr; @@ -421,7 +152,7 @@ typedef struct MemInitializer { } u; Boolean is_ivar; Boolean is_expr; -} MemInitializer; +}; typedef enum DepNameType { @@ -434,8 +165,8 @@ typedef enum DepNameType { DNT_TYPENAME } DepNameType; -typedef struct DepName { - struct DepName *next; +struct DepName { + DepName *next; union { HashNameNode *name; NameSpace *nspace; @@ -453,7 +184,7 @@ typedef struct DepName { } tname; } u; DepNameType type; -} DepName; +}; @@ -479,314 +210,110 @@ typedef struct Substitution { SubKind kind; } 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 +};*/ -// CScope.c -extern Boolean cscope_is_member_func; -extern Object *cscope_currentfunc; -extern TypeClass *cscope_currentclass; -extern NameSpace *cscope_current; -extern NameSpace *cscope_root; - -typedef struct CScopeSave { - NameSpace *current; - TypeClass *currentclass; - Object *currentfunc; - Boolean is_member_func; -} CScopeSave; // assumed name - -typedef struct CScopeParseResult { - NameSpace *nspace_0; - HashNameNode *name_4; - Type *x8; - void *xC; - ObjBase *obj_10; - NameSpaceObjectList *nsol_14; - BClassList *bcl_18; - Boolean x1C; - Boolean x1D; - Boolean isambig; - Boolean x1F; - Boolean x20; - Boolean x21; -} CScopeParseResult; - -typedef struct CScopeNSIterator { - NameSpace *nspace; - NameSpaceLookupList *lookup; - CScopeParseResult *result; -} CScopeNSIterator; - -typedef struct CScopeObjectIterator { - NameSpace *nspace; - NameSpaceName *nextname; - NameSpaceObjectList *currlist; - int hashindex; -} CScopeObjectIterator; - -extern void CScope_Setup(); -extern void CScope_Cleanup(); -extern void CScope_GetScope(CScopeSave *save); -extern void CScope_SetNameSpaceScope(NameSpace *nspace, CScopeSave *save); -extern void CScope_SetClassScope(TypeClass *cls, CScopeSave *save); -extern void CScope_SetClassDefScope(TypeClass *cls, CScopeSave *save); -extern void CScope_SetFunctionScope(Object *function, CScopeSave *save); -extern void CScope_SetMethodScope(Object *function, TypeClass *cls, Boolean unknownFlag, CScopeSave *save); -extern void CScope_RestoreScope(CScopeSave *saved); -extern Boolean CScope_IsEmptySymTable(); -extern Boolean CScope_IsInLocalNameSpace(NameSpace *nspace); -extern NameSpaceObjectList *CScope_FindName(NameSpace *nspace, HashNameNode *name); -extern NameSpaceName *CScope_FindNameSpaceName(NameSpace *nspace, HashNameNode *name); -extern NameSpaceObjectList *CScope_InsertName(NameSpace *nspace, HashNameNode *name); -extern NameSpaceObjectList *CScope_ArgumentDependentNameLookup(NameSpaceObjectList *list, HashNameNode *name, ENodeList *argNodes, Boolean flag); -extern NameSpace *CScope_NewHashNameSpace(HashNameNode *name); -extern NameSpace *CScope_NewListNameSpace(HashNameNode *name, Boolean is_global); -extern NameSpace *CScope_FindNonClassNonFunctionNS(NameSpace *nspace); -extern NameSpace *CScope_FindGlobalNS(NameSpace *nspoce); -extern Boolean CScope_IsStdNameSpace(NameSpace *nspace); -extern Boolean CScope_IsEmptyNameSpace(NameSpace *nspace); -extern void CScope_MergeNameSpace(NameSpace *dst, NameSpace *src); -extern void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj); -extern void CScope_AddGlobalObject(Object *obj); -extern NameSpaceLookupList *CScope_BuildNameSpaceLookupList(NameSpace *nspace); -extern Boolean CScope_FindQualifiedClassMember(CScopeParseResult *result, TypeClass *tclass, HashNameNode *name); -extern Type *CScope_GetType(NameSpace *nspace, HashNameNode *name, void **unk6); -extern Type *CScope_GetTagType(NameSpace *nspace, HashNameNode *name); -extern Boolean CScope_ParseExprName(CScopeParseResult *result); -extern Boolean CScope_ParseDeclName(CScopeParseResult *result); -extern Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, Boolean flag2); -extern Boolean CScope_ParseElaborateName(CScopeParseResult *result); -extern Boolean CScope_FindObject(NameSpace *nspace, CScopeParseResult *result, HashNameNode *name); -extern Boolean CScope_FindNonClassObject(NameSpace *nspace, CScopeParseResult *result, HashNameNode *name); -extern NameSpaceObjectList *CScope_FindObjectList(CScopeParseResult *result, HashNameNode *name); -extern Boolean CScope_PossibleTypeName(HashNameNode *name); -extern Boolean CScope_FindClassMemberObject(TypeClass *tclass, CScopeParseResult *result, HashNameNode *name); -extern void CScope_InitObjectIterator(CScopeObjectIterator *iterator, NameSpace *nspace); -extern ObjBase *CScope_NextObjectIteratorObject(CScopeObjectIterator *iterator); -extern NameSpaceObjectList *CScope_NextObjectIteratorObjectList(CScopeObjectIterator *iterator); -extern void CScope_DefineTypeTag(NameSpace *nspace, HashNameNode *name, Type *type); -extern Type *CScope_GetLocalTagType(NameSpace *nspace, HashNameNode *name); -extern Boolean CScope_FindTypeName(NameSpace *nspace, HashNameNode *name, CScopeParseResult *result); -extern NameSpaceObjectList *CScope_GetLocalObject(NameSpace *nspace, HashNameNode *name); -extern BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass); -extern Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boolean flag); -extern void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, HashNameNode *name, AccessType access); -extern void CScope_ParseUsingDeclaration(NameSpace *nspace, AccessType access); -extern void CScope_ParseNameSpaceAlias(HashNameNode *name); -extern void CScope_ParseUsingDirective(NameSpace *nspace); - -// CMachine.c -extern TypeIntegral stbool; -extern TypeIntegral stchar; -extern TypeIntegral stsignedchar; -extern TypeIntegral stunsignedchar; -extern TypeIntegral stwchar; -extern TypeIntegral stsignedshort; -extern TypeIntegral stunsignedshort; -extern TypeIntegral stsignedint; -extern TypeIntegral stunsignedint; -extern TypeIntegral stsignedlong; -extern TypeIntegral stunsignedlong; -extern TypeIntegral stsignedlonglong; -extern TypeIntegral stunsignedlonglong; -extern TypeIntegral stfloat; -extern TypeIntegral stshortdouble; -extern TypeIntegral stdouble; -extern TypeIntegral stlongdouble; - -extern TypeStruct stvectorunsignedchar; -extern TypeStruct stvectorsignedchar; -extern TypeStruct stvectorboolchar; -extern TypeStruct stvectorunsignedshort; -extern TypeStruct stvectorsignedshort; -extern TypeStruct stvectorboolshort; -extern TypeStruct stvectorunsignedlong; -extern TypeStruct stvectorsignedlong; -extern TypeStruct stvectorboollong; -extern TypeStruct stvectorfloat; -extern TypeStruct stvectorpixel; -extern TypeStruct stvector; - -extern void CMach_Configure(); -extern SInt32 CMach_GetQUALalign(UInt32 qual); -extern SInt32 CMach_ArgumentAlignment(Type *type); -extern SInt32 CMach_AllocationAlignment(Type *type, UInt32 qual); -extern CInt64 CMach_CalcIntDiadic(Type *type, CInt64 left, short op, CInt64 right); -extern CInt64 CMach_CalcIntMonadic(Type *type, short op, CInt64 val); -extern CInt64 CMach_CalcIntConvertFromFloat(Type *type, Float fval); -extern void CMach_InitIntMem(Type *type, CInt64 val, void *mem); -extern void CMach_InitVectorMem(Type *type, MWVector128 val, void *mem); -extern Float CMach_CalcFloatDiadic(Type *type, Float left, short op, Float right); -extern Float CMach_CalcFloatMonadic(Type *type, short op, Float fval); -extern Boolean CMach_CalcFloatDiadicBool(Type *type, Float left, short op, Float right); -extern Boolean CMach_CalcVectorDiadicBool(Type *type, MWVector128 *left, short op, MWVector128 *right); -extern char *CMach_FloatScan(char *input, Float *result, Boolean *fail); -extern Float CMach_CalcFloatConvertFromInt(Type *type, CInt64 val); -extern Float CMach_CalcFloatConvert(Type *type, Float fval); -extern Boolean CMach_FloatIsZero(Float fval); -extern Boolean CMach_FloatIsOne(Float fval); -extern Boolean CMach_FloatIsNegOne(Float fval); -extern void CMach_InitFloatMem(Type *type, Float val, void *mem); -extern void CMach_PrintFloat(char *buf, Float val); -extern void CMach_PragmaParams(); -extern void CMach_AdjustFuntionArgs(); -extern SInt16 CMach_GetStructAlign(TypeStruct *tstruct); -extern SInt16 CMach_GetClassAlign(TypeClass *tclass); -extern SInt16 CMach_GetTypeAlign(Type *type); -extern SInt16 CMach_MemberAlignValue(Type *type, SInt32 var); -extern void CMach_StructLayoutInitOffset(SInt32 offset); -extern SInt32 CMach_StructLayoutGetCurSize(); -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(); -extern Boolean CMach_FloatIsPowerOf2(Float flt); -extern Float CMach_FloatReciprocal(Float flt); -extern SInt32 CMach_RoundedSizeOf(Object *object); -extern void CMach_ReInitRuntimeObjects(); - -// CPrep.c -typedef struct Macro { - struct Macro *next; - HashNameNode *name; - void *c; - Boolean xC; - Boolean xD; - Boolean is_special; - Boolean xF; - void *e; -} Macro; -typedef struct TokenStack { - char *pos; - char *macrostart; - Macro *macro; - Boolean macrocheck; -} TokenStack; +enum { + RegState0 = 0, + RegState1 = 1, + RegState2 = 2 +}; -extern CParams *cparamblkptr; -extern short tk; -extern CInt64 tkintconst; -extern Float tkfloatconst; -extern char *tkstring; -extern HashNameNode *tkidentifier; -extern SInt32 tksize; -extern short ispascalstring; -extern short nlflag; -extern SInt32 lines; -extern Boolean spaceskip; -extern struct Macro **macrohashtable; -extern Boolean cprep_nomem_exit; -extern Boolean cprep_nostring; -extern Boolean cprep_eoltokens; -extern TokenStack tokenstack[128]; -extern short tokenstacklevel; -extern SInt32 cprep_cursymfile; // might be a ptr? -extern char *pos; -extern char *macropos; -extern char *nextcharpos; -extern char CPrep_SkipNewCommentChar; -extern Boolean preprocessing_only; -extern Handle stringmem; -extern SInt32 maxstringsize; -extern char cprep_idarray[256]; -extern Boolean was_escchar; -extern Boolean macrocheck; -extern Boolean widestring; -extern Boolean at_linestart; -extern char *prep_file_start; -extern char *prep_file_end; -extern char *macrostart; -extern Boolean cprep_strconcat; -extern CPrepFileInfo *prep_file; -extern short filesp; -extern SInt32 linenumber; -extern GList pplist; -extern TStreamElement *ts_current; -extern SInt32 ts_preread_elements; - -extern void CPrep_InsertSpecialMacro(Macro *macro, char *name); -extern void CPrep_InsertSpecialMacros(); -extern void CPrep_RemoveSpecialMacros(); -extern Boolean setupprep(); -extern void cleanupprep(); -extern void CPrep_TSBufferGrow(int amount); -extern void CPrep_TokenStreamGetState(SInt32 *state); -extern void CPrep_TokenStreamSetState(SInt32 *state); -extern void CPrep_UnLex(); -extern void CPrep_TokenStreamSetCurState(SInt32 *state); -extern void CPrep_StreamGetBlock(); -extern void CPrep_StreamGetSemicolon(); -extern void CPrep_StreamGetTemplate(); -extern void CPrep_StreamInsert(); -extern void CPrep_StreamRemove(); -extern void CPrep_RemoveTokens(); -extern void CPrep_TokenStreamFlush(); -extern void CPrep_CurStreamElement(); -extern void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SInt32 *selectionoffset, short *tokensize, SInt32 *linenumber, char *buf1, short *tokenoffset, short *tokenlength, char *buf2, short *lastarg); -extern void CPrep_Error(short code); -extern void CPrep_ErrorName(short code, const char *name); -extern void CPrep_Warning(short code); -extern void CPrep_WarningName(short code, const char *name); -extern void CPrep_ErrorMessage(int errTable, char *str, Boolean flag1, Boolean flag2); -extern void CPrep_ErrorMessageVA(int code, const char *format, va_list list, Boolean flag1, Boolean flag2); -extern void popfile(); -extern void CPrep_SetSourceFile(); -extern void CPrep_GetSourceFilePath(); -extern void CPrep_NewFileOffsetInfo(); -extern void CPrep_GetFileOffsetInfo(); -extern void CPrep_GetFileOffsetInfo2(); -extern void CPrep_ResetFileInfo(); -extern void CPrep_GetPrepPos(); -extern Boolean C_Compiler(CParams *param); -extern void poptokenseq(); -extern void foundnl(); -extern void newline(); -extern short notendofline(); -extern char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2); -extern void macrotest(); -extern void CPrep_PragmaLex(); -extern void CPrep_PushOption(); -extern void CPrep_PopOption(); -extern void preprocessor(); -extern void CPrep_BrowserTokenOffset(); -extern void CPrep_BrowserFileOffset(); -extern void CPrep_BrowserFilePosition(CPrepFileInfo **fileinfo, SInt32 *offset); -extern CPrepFileInfo *CPrep_BrowserCurrentFile(); - -// CPrepTokenizer.c -extern short prepskipnextchar(); -extern short prepnextchar(); -extern short prepnextstringchar(char *str, Boolean flag); -extern void CPrep_MatchChar(char ch, Boolean flag); -extern char *CPrep_MatchChar2(char *str, char ch, Boolean flag); -extern short prepcurchar(); -extern char *ReadIdentifier(char *str); -extern char *CPrep_SkipNewComment(char *str); -extern Boolean skipendoflinematch(char *str, Boolean flag); -extern void skipendofline(); -extern void CPrep_SkipAsmComment(); -extern short lookahead(); -extern short lookahead_noeol(); -extern short lex(); -extern short plex(); -extern short lexidentifier(); +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 Boolean C_Compiler(CParams *param); +extern short high_offset; +extern short low_offset; +extern short high_reg; +extern short low_reg; +extern short high_reg2; +extern short low_reg2; extern void PrecompilerRead(short refnum, void *buffer); +extern void PrecompilerWrite(); extern void CodeGen_InitCompiler(); extern void CodeGen_TermCompiler(); extern void CodeGen_InitBackEndOptions(); extern void CodeGen_UpdateOptimizerOptions(); extern void CodeGen_UpdateBackEndOptions(); extern void MWUnmangle(const char *name, char *buf, int size); -extern COpts copts; +//extern COpts copts; extern CParams *cparamblkptr; extern FuncArg elipsis; extern FuncArg oldstyle; -extern HashNameNode *constructor_name_node; -extern HashNameNode *destructor_name_node; -extern char *CMangler_GetOperator(HashNameNode *str); extern jmp_buf errorreturn; extern Boolean cprep_nomem_exit; extern Boolean anyerrors; @@ -794,17 +321,7 @@ extern Boolean fatalerrors; extern SInt32 lines; extern char string[256]; extern TemplStack *ctempl_curinstance; -typedef struct ParserTryBlock { - struct ParserTryBlock *next; - jmp_buf jmpbuf; - NameSpace *cscope_current; - TypeClass *cscope_currentclass; - Object *cscope_currentfunc; - TemplStack *ctempl_curinstance; - TStreamElement *cerror_locktoken; - Boolean cscope_is_member_func; -} ParserTryBlock; -extern ParserTryBlock *trychain; +//extern ParserTryBlock *trychain; extern Boolean in_assembler; extern Boolean preprocessing_only; extern void AssemblerError(); @@ -817,14 +334,25 @@ extern short lookahead(); extern Object *CClass_Constructor(TypeClass *tclass); extern Object *CClass_Destructor(TypeClass *tclass); extern int CClass_CheckPures(TypeClass *tclass); +extern Boolean CClass_IsConstructor(Object *func); +extern short CABI_GetStructResultArgumentIndex(); +extern Boolean CParser_HasInternalLinkage(Object *obj); +extern HashNameNode *CParser_GetUniqueName(); +extern SInt32 CParser_GetUniqueID(); +extern Boolean CParserIsVolatileExpr(ENode *expr); +extern Boolean CParserIsConstExpr(ENode *expr); extern Boolean CParser_IsPublicRuntimeObject(Object *obj); extern Boolean CParser_ParseOperatorName(short *token, Boolean flag1, Boolean flag2); extern Boolean CTemplTool_EqualArgs(TemplArg *a, TemplArg *b); +extern Boolean CTemplTool_IsTemplateArgumentDependentType(Type *type); extern TypeTemplDep *CDecl_NewTemplDepType(TypeTemplDepType tdtype); +extern Type *CDecl_NewPointerType(Type *type); +extern Type *CDecl_NewStructType(SInt32 size, SInt32 align); +extern Type *CDecl_NewArrayType(Type *type, SInt32 num); extern GList name_mangle_list; extern void CPrep_UnLex(); extern Type *CTempl_ClassGetType(TypeClass *tclass); -extern short is_typesame(Type *t1, Type *t2); +//extern short is_typesame(Type *t1, Type *t2); extern Boolean is_unsigned(Type *type); extern void CDecl_CompleteType(Type *type); extern TemplArg *CTempl_ParseUncheckTemplArgs(void *fixmelater, Boolean flag); @@ -835,14 +363,95 @@ extern Boolean CParser_CheckTemplateClassUsage(TemplClass *tmclass, Boolean flag extern Type *CTempl_ParseTemplTemplParam(Type *t); extern void CClass_CheckPathAccess(BClassList *bcl, void *unk, AccessType access); extern BClassList *CClass_GetPathCopy(BClassList *path, Boolean flag); +extern Object *CClass_ThisSelfObject(); extern AccessType global_access; +extern HashNameNode *this_name_node; +extern void CParser_Setup(); +extern Boolean CParser_IsConst(Type *type, UInt32 qual); +extern void CParser_Cleanup(); +extern void SetupPrecompiler(Boolean flag); +extern void CleanupPrecompiler(); +extern void SetupAssembler(); +extern void CleanupAssembler(); +extern void ObjGen_Setup(); +extern void ObjGen_Finish(); +extern void ObjGen_Cleanup(); +extern void ObjGen_CodeCleanup(); +extern void ObjGen_DeclareFloatConst(Object *obj); +extern void ObjGen_DeclareVectorConst(Object *obj); +extern void ObjGen_DeclareCodeLabel(Object *labelobj, SInt32 offset, Object *funcobj); +extern Boolean ObjGen_IsExported(Object *obj); +extern void PointerAnalysis_Setup(); +extern void PointerAnalysis_Cleanup(); +extern Boolean CPrep_Preprocess(); +extern void cparser(); +extern void CBrowse_Setup(CParams *param); +extern void CBrowse_Finish(CParams *param); +extern void CBrowse_Cleanup(CParams *param); extern UInt32 CParser_GetTypeQualifiers(Type *type, UInt32 qual); extern void CTemplClass_RegisterUsingDecl(TemplClass *tclass, Type *target, AccessType access); extern void CodeGen_InsertSpecialMacros(); -extern char *CodeGen_ExpandSpecialMacro(Macro *macro); extern void CPrep_PreprocessDumpFileInfo(Boolean flag); +extern void CPrep_PreprocessDumpNewLine(); extern Boolean gForceSourceLoc; extern void ObjGen_SegmentName(); // might take an arg, not sure since it's empty +extern void ObjGen_SrcBreakName(HashNameNode *name, SInt32 modDate, Boolean flag); +extern char *precomp_target_str; +extern Object *CParser_ParseObject(); +extern void PointerAnalysis_PragmaMode(); +extern void CExcept_Terminate(); +extern void CExcept_ArrayInit(); +extern void CExcept_Magic(); +extern void CSOM_PragmaReleaseOrder(); +extern void CSOM_PragmaClassVersion(); +extern void CSOM_PragmaMetaClass(); +extern void CSOM_PragmaCallStyle(); +extern short GetPrec(short t); +extern short localcount; +extern Boolean InlineAsm_gccmode; +extern void initialize_aliases(); +extern Statement *current_statement; +extern int pclist_bad_operand; +extern int n_real_registers[]; +extern short pic_base_reg; +extern Object pic_base; +extern ObjectList *exceptionlist; +extern ObjectList *arguments; +extern ObjectList *locals; +extern ObjectList *toclist; +extern Boolean uses_globals; +extern Boolean requires_frame; +extern void assign_locals_to_memory(ObjectList *locals); +extern PCodeLabel *pic_base_pcodelabel; +extern void *make_alias(Object *obj, SInt32 offset, SInt32 size); +extern Boolean is_volatile_object(Object *obj); +extern Boolean is_pascal_object(Object *obj); +extern Boolean local_is_16bit_offset(Object *obj); +extern Boolean can_add_displ_to_local(Object *obj, SInt32 displ); +extern int local_base_register(Object *obj); +extern int disable_optimizer; +extern Boolean IsTempName(HashNameNode *name); +extern void assign_local_memory(Object *obj); +extern void move_varargs_to_memory(); +extern Type stvoid; +extern TypePointer void_ptr; +extern int countexceptionactionregisters(ExceptionAction *exc); +extern void noteexceptionactionregisters(ExceptionAction *exc, PCodeArg *); +extern void recordexceptionactions(PCode *pc, ExceptionAction *exc); +extern SInt32 functionbodyoffset; +extern Object *CParser_NewRTFunc(Type *returntype, HashNameNode *name, Boolean unkflag, int argcount, ...); +extern SInt32 curstmtvalue; +extern Object *__memcpy_object; +extern void CInit_RewriteString(ENode *expr, Boolean flag); +extern int is_intrinsic_function_call(ENode *expr); +extern SInt32 I8_log2n(SInt64 value); +extern void PPCError_Error(int code); + +enum { + INTRINSIC_8 = 8, + INTRINSIC_35 = 35, + INTRINSIC_36 = 36 +}; enum { CPU_PPC401, @@ -875,6 +484,11 @@ enum { 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 |