/* Copyright (C) 2005-2009 Clozure Associates */ /* This file is part of Clozure CL. */ /* Clozure CL is licensed under the terms of the Lisp Lesser GNU Public */ /* License , known as the LLGPL and distributed with Clozure CL as the */ /* file "LICENSE". The LLGPL consists of a preamble and the LGPL, */ /* which is distributed with Clozure CL as the file "LGPL". Where these */ /* conflict, the preamble takes precedence. */ /* Clozure CL is referenced in the preamble as the "LIBRARY." */ /* The LLGPL is also available online at */ /* http://opensource.franz.com/preamble.html */ /* Try to make macros follow GAS/ATT conventions, where source precedes */ /* destination. */ define(`lisp_global',`lisp_globals.$1') define(`ref_global',` __(mov lisp_global($1),$2) ') define(`set_global',` __(mov $1,lisp_global($2)) ') define(`ref_nrs_value',` __(mov nrs.$1+symbol.vcell,$2) ') define(`set_nrs_value',` __(mov $1,nrs.$2+symbol.vcell) ') define(`unbox_fixnum',` __(mov $1,$2) __(sar `$'fixnumshift,$2) ') define(`box_fixnum',` __(imul `$'fixnumone,$1,$2) ') /* box_fixnum, with no effect on flags */ define(`box_fixnum_no_flags',` __(lea (,$1,fixnumone),$2) ') /* Zero $3 bytes worth of dnodes, starting at offset $2 relative */ /* to the base register $1. */ ifdef(`DarwinAssembler',` .macro zero_dnodes .if $2 ifdef(`X8664',` __(movapd %fpzero,$1($0)) ',` __(movsd %fpzero,$1($0)) ') __(zero_dnodes $0,$1+dnode_size,$2-dnode_size) .endif .endmacro ',` .macro zero_dnodes base,disp,nbytes .ifgt \nbytes ifdef(`X8664',` movapd %fpzero,\disp(\base) ',` movsd %fpzero,\disp(\base) ') zero_dnodes \base,"\disp+dnode_size","\nbytes-dnode_size" .endif .endm ') /* Allocate $1+dnode_size zeroed bytes on the tstack, using $2 as a temp */ /* reg. */ ifdef(`X8632',` define(`TSP_Alloc_Fixed',` define(`TSP_Alloc_Size',`((($1+node_size) & ~(dnode_size-1))+dnode_size)') __(subl `$'TSP_Alloc_Size,rcontext(tcr.next_tsp)) __(movd rcontext(tcr.save_tsp),%stack_temp) __(movl rcontext(tcr.next_tsp),$2) zero_dnodes $2,0,TSP_Alloc_Size __(movd %stack_temp,($2)) __(movl %ebp,tsp_frame.save_ebp($2)) __(movl $2,rcontext(tcr.save_tsp)) undefine(`TSP_Alloc_Size') ')',` define(`TSP_Alloc_Fixed',` define(`TSP_Alloc_Size',`((($1+node_size) & ~(dnode_size-1))+dnode_size)') __(subq `$'TSP_Alloc_Size,rcontext(tcr.next_tsp)) __(movq rcontext(tcr.save_tsp),%stack_temp) __(movq rcontext(tcr.next_tsp),$2) zero_dnodes $2,0,TSP_Alloc_Size __(movq %stack_temp,($2)) __(movq %rbp,tsp_frame.save_rbp($2)) __(movq $2,rcontext(tcr.save_tsp)) undefine(`TSP_Alloc_Size') ')') /* $1 = size (dnode-aligned, including tsp overhead, $2 scratch. */ /* Modifies both $1 and $2; on exit, $2 = new_tsp+tsp_overhead, $1 = old tsp */ ifdef(`X8632',` define(`TSP_Alloc_Var',` new_macro_labels() __(subl $1,rcontext(tcr.next_tsp)) __(movd rcontext(tcr.save_tsp),%stack_temp) __(movl rcontext(tcr.next_tsp),$2) __(jmp macro_label(test)) macro_label(loop): __(movsd %fpzero,0($2)) __(addl $dnode_size,$2) macro_label(test): __(subl $dnode_size,$1) __(jge macro_label(loop)) __(movl rcontext(tcr.next_tsp),$2) __(movd %stack_temp,$1) __(movl $1,($2)) __(movl %ebp,tsp_frame.save_ebp($2)) __(movl $2,rcontext(tcr.save_tsp)) __(addl $dnode_size,$2) ')',` define(`TSP_Alloc_Var',` new_macro_labels() subq $1,rcontext(tcr.next_tsp) __(movq rcontext(tcr.save_tsp),%stack_temp) __(movq rcontext(tcr.next_tsp),$2) __(jmp macro_label(test)) macro_label(loop): __(movapd %fpzero,0($2)) __(addq $dnode_size,$2) macro_label(test): __(subq $dnode_size,$1) __(jge macro_label(loop)) __(movq rcontext(tcr.next_tsp),$2) __(movd %stack_temp,$1) __(movq $1,($2)) __(movq %rbp,tsp_frame.save_rbp($2)) __(movq $2,rcontext(tcr.save_tsp)) __(addq $dnode_size,$2) ')') ifdef(`X8632',` define(`Allocate_Catch_Frame',` TSP_Alloc_Fixed(catch_frame.size,$1) __(movl `$'(catch_frame.element_count<15),1,` __(movl `$'$1<