mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 14:19:31 +02:00
+ MIPS: added profiling support
git-svn-id: trunk@23950 -
This commit is contained in:
parent
889181c4a5
commit
6f1997f5e5
@ -84,6 +84,7 @@ type
|
||||
procedure g_adjust_self_value(list:TAsmList;procdef: tprocdef;ioffset: tcgint); override;
|
||||
procedure g_intf_wrapper(list: tasmlist; procdef: tprocdef; const labelname: string; ioffset: longint); override;
|
||||
procedure g_external_wrapper(list : TAsmList; procdef: tprocdef; const externalname: string);override;
|
||||
procedure g_profilecode(list: TAsmList);override;
|
||||
{ Transform unsupported methods into Internal errors }
|
||||
procedure a_bit_scan_reg_reg(list: TAsmList; reverse: boolean; size: TCGSize; src, dst: TRegister); override;
|
||||
procedure g_stackpointer_alloc(list : TAsmList;localsize : longint);override;
|
||||
@ -1746,6 +1747,21 @@ procedure TCGMIPS.g_external_wrapper(list: TAsmList; procdef: tprocdef; const ex
|
||||
end;
|
||||
|
||||
|
||||
procedure TCGMIPS.g_profilecode(list:TAsmList);
|
||||
var
|
||||
href: treference;
|
||||
begin
|
||||
if not (cs_create_pic in current_settings.moduleswitches) then
|
||||
begin
|
||||
reference_reset_symbol(href,current_asmdata.RefAsmSymbol('_gp'),0,sizeof(pint));
|
||||
a_loadaddr_ref_reg(list,href,NR_GP);
|
||||
end;
|
||||
list.concat(taicpu.op_reg_reg(A_MOVE,NR_R1,NR_RA));
|
||||
list.concat(taicpu.op_reg_reg_const(A_ADDIU,NR_SP,NR_SP,-8));
|
||||
a_call_sym_pic(list,current_asmdata.RefAsmSymbol('_mcount'));
|
||||
end;
|
||||
|
||||
|
||||
procedure TCGMIPS.g_adjust_self_value(list:TAsmList;procdef: tprocdef;ioffset: tcgint);
|
||||
begin
|
||||
{ This method is integrated into g_intf_wrapper and shouldn't be called separately }
|
||||
|
@ -122,7 +122,7 @@ const
|
||||
+ [system_powerpc_morphos];
|
||||
|
||||
{ gprof (requires implementation of g_profilecode in the code generator) }
|
||||
supported_targets_pg = [system_i386_linux,system_x86_64_linux]
|
||||
supported_targets_pg = [system_i386_linux,system_x86_64_linux,system_mipseb_linux,system_mipsel_linux]
|
||||
+ [system_i386_win32]
|
||||
+ [system_powerpc_darwin,system_x86_64_darwin]
|
||||
+ [system_i386_GO32V2]
|
||||
|
@ -64,6 +64,7 @@
|
||||
void (*rtld_fini) (void), void *stack_end)
|
||||
*/
|
||||
.text
|
||||
.globl main
|
||||
.globl __start
|
||||
.type __start,@function
|
||||
__start:
|
||||
@ -84,7 +85,9 @@ _start:
|
||||
/* Setup GP correctly if we're non-PIC. */
|
||||
la $28,_gp
|
||||
|
||||
la $4, main /* main */
|
||||
lui $4, %hi(main_stub) /* main */
|
||||
addiu $4,$4,%lo(main_stub)
|
||||
|
||||
lw $5, 0($29) /* argc */
|
||||
addiu $6, $29, 4 /* argv */
|
||||
/* store argc */
|
||||
@ -121,16 +124,35 @@ _start:
|
||||
jalr $t9
|
||||
.end _start
|
||||
.size _start, . - _start
|
||||
/* Crash if somehow it does return. */
|
||||
|
||||
.globl main_stub
|
||||
.type main_stub,@function
|
||||
main_stub:
|
||||
lui $v0,%hi(__fpc_ret_sp)
|
||||
sw $sp,%lo(__fpc_ret_sp)($v0)
|
||||
lui $v0,%hi(__fpc_ret_ra)
|
||||
sw $ra,%lo(__fpc_ret_ra)($v0)
|
||||
lui $v0,%hi(main)
|
||||
addiu $t9,$v0,%lo(main)
|
||||
jr $t9
|
||||
nop
|
||||
.size main_stub,.-main_stub
|
||||
|
||||
|
||||
.globl _haltproc
|
||||
.ent _haltproc
|
||||
.type _haltproc,@function
|
||||
_haltproc:
|
||||
hlt:
|
||||
li $v0,4001
|
||||
syscall
|
||||
b hlt
|
||||
.end _haltproc
|
||||
lui $v0,%hi(__fpc_ret_sp)
|
||||
lw $sp,%lo(__fpc_ret_sp)($v0)
|
||||
lui $v0,%hi(__fpc_ret_ra)
|
||||
lw $ra,%lo(__fpc_ret_ra)($v0)
|
||||
jr $ra
|
||||
nop
|
||||
hlt:
|
||||
b hlt
|
||||
.end _haltproc
|
||||
.size _haltproc,.-_haltproc
|
||||
|
||||
/* Define a symbol for the first piece of initialized data. */
|
||||
.data
|
||||
@ -142,6 +164,8 @@ __data_start:
|
||||
|
||||
.comm __stkptr,4
|
||||
.comm __dl_fini,4
|
||||
.comm __fpc_ret_sp,4
|
||||
.comm __fpc_ret_ra,4
|
||||
|
||||
.comm operatingsystem_parameter_envp,4
|
||||
.comm operatingsystem_parameter_argc,4
|
||||
|
@ -1 +1,45 @@
|
||||
.include "mips/prt0.as"
|
||||
.include "mips/cprt0.as"
|
||||
|
||||
.option pic2
|
||||
.text
|
||||
.set nomips16
|
||||
.set noreorder
|
||||
.globl __gmon_start__
|
||||
.type __gmon_start__,@function
|
||||
__gmon_start__:
|
||||
.ent __gmon_start__
|
||||
|
||||
.frame $sp,32,$ra
|
||||
.mask 0x80000000,-4
|
||||
.fmask 0x00000000,0
|
||||
.cpload $25
|
||||
addiu $sp,$sp,-32
|
||||
sw $ra,28($sp)
|
||||
.cprestore 16
|
||||
lui $v0,%hi(called)
|
||||
lw $v1,%lo(called)($v0)
|
||||
bne $v1,$zero,10f
|
||||
|
||||
lw $a0,%got(__start)($gp)
|
||||
lw $a1,%got(etext)($gp)
|
||||
li $v1,1
|
||||
lw $t9,%call16(__monstartup)($gp)
|
||||
jalr $t9
|
||||
sw $v1,%lo(called)($v0) /* in delay slot */
|
||||
lw $gp,16($sp)
|
||||
lw $a0,%got(_mcleanup)($gp)
|
||||
lw $t9,%call16(atexit)($gp)
|
||||
jalr $t9
|
||||
nop
|
||||
10:
|
||||
lw $ra,28($sp)
|
||||
jr $ra
|
||||
addiu $sp,$sp,32
|
||||
.end __gmon_start__
|
||||
.size __gmon_start__,.-__gmon_start__
|
||||
|
||||
.bss
|
||||
called: .space 4
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user