Changeset 8242
- Timestamp:
- Jan 22, 2008, 10:10:26 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/source/lisp-kernel/x86-macros.s (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/lisp-kernel/x86-macros.s
r8130 r8242 20 20 21 21 define([ref_global],[ 22 mov lisp_global($1),$222 __(mov lisp_global($1),$2) 23 23 ]) 24 24 25 25 define([set_global],[ 26 mov $1,lisp_global($2)26 __(mov $1,lisp_global($2)) 27 27 ]) 28 28 29 29 define([ref_nrs_value],[ 30 mov nrs.$1+symbol.vcell,$230 __(mov nrs.$1+symbol.vcell,$2) 31 31 ]) 32 32 33 33 define([set_nrs_value],[ 34 mov $1,nrs.$2+symbol.vcell34 __(mov $1,nrs.$2+symbol.vcell) 35 35 ]) 36 36 37 37 define([unbox_fixnum],[ 38 mov $1,$239 sar [$]fixnumshift,$238 __(mov $1,$2) 39 __(sar [$]fixnumshift,$2) 40 40 ]) 41 41 42 42 define([box_fixnum],[ 43 imulq [$]fixnumone,$1,$243 __(imulq [$]fixnumone,$1,$2) 44 44 ]) 45 45 … … 47 47 /* box_fixnum, with no effect on flags */ 48 48 define([box_fixnum_no_flags],[ 49 leaq (,$1,8),$249 __(leaq (,$1,8),$2) 50 50 ]) 51 51 52 define([save_node_regs],[53 push %arg_z54 push %arg_y55 push %arg_x56 push %temp057 push %temp158 push %temp259 push %save060 push %save161 push %save262 push %save363 push %ra064 push %fn65 ])66 67 /* This needs to be done before we transition back to the lisp stack */68 /* from the foreign stack. */69 70 define([zero_node_regs],[71 xor %fn,%fn72 mov %fn,%ra073 mov %fn,%save374 mov %fn,%save275 mov %fn,%save176 mov %fn,%save077 mov %fn,%temp278 mov %fn,%temp179 mov %fn,%temp080 mov %fn,%arg_x81 mov %fn,%arg_y82 mov %fn,arg_z83 ])84 define([restore_node_regs],[85 pop %fn86 pop %ra087 pop %save388 pop %save289 pop %save190 pop %save091 pop %temp292 pop %temp193 pop %temp094 pop %arg_x95 pop %arg_y96 pop %arg_z97 ])98 52 99 53 /* Zero $3 bytes worth of dnodes, starting at offset $2 relative */ … … 104 58 .macro zero_dnodes 105 59 .if $2 106 movapd %fpzero,$1($0)107 zero_dnodes $0,$1+dnode_size,$2-dnode_size60 __(movapd %fpzero,$1($0)) 61 __(zero_dnodes $0,$1+dnode_size,$2-dnode_size) 108 62 .endif 109 63 .endmacro … … 111 65 .macro zero_dnodes base,disp,nbytes 112 66 .ifgt \nbytes 113 movapd %fpzero,\disp(\base)67 __(movapd %fpzero,\disp(\base)) 114 68 zero_dnodes \base,"\disp+dnode_size","\nbytes-dnode_size" 115 69 .endif … … 123 77 define([TSP_Alloc_Fixed],[ 124 78 define([TSP_Alloc_Size],[((($1+node_size) & ~(dnode_size-1))+dnode_size)]) 125 subq [$]TSP_Alloc_Size,%rcontext:tcr.next_tsp126 movq %rcontext:tcr.save_tsp,%stack_temp127 movq %rcontext:tcr.next_tsp,$279 __(subq [$]TSP_Alloc_Size,%rcontext:tcr.next_tsp) 80 __(movq %rcontext:tcr.save_tsp,%stack_temp) 81 __(movq %rcontext:tcr.next_tsp,$2) 128 82 zero_dnodes $2,0,TSP_Alloc_Size 129 movq %stack_temp,($2)130 movq %rbp,tsp_frame.save_rbp($2)131 movq $2,%rcontext:tcr.save_tsp83 __(movq %stack_temp,($2)) 84 __(movq %rbp,tsp_frame.save_rbp($2)) 85 __(movq $2,%rcontext:tcr.save_tsp) 132 86 undefine([TSP_Alloc_Size]) 133 87 ]) … … 139 93 new_macro_labels() 140 94 subq $1,%rcontext:tcr.next_tsp 141 movq %rcontext:tcr.save_tsp,%stack_temp142 movq %rcontext:tcr.next_tsp,$2143 jmp macro_label(test)95 __(movq %rcontext:tcr.save_tsp,%stack_temp) 96 __(movq %rcontext:tcr.next_tsp,$2) 97 __(jmp macro_label(test)) 144 98 macro_label(loop): 145 movapd %fpzero,0($2)146 addq $dnode_size,$299 __(movapd %fpzero,0($2)) 100 __(addq $dnode_size,$2) 147 101 macro_label(test): 148 subq $dnode_size,$1149 jge macro_label(loop)150 movq %rcontext:tcr.next_tsp,$2151 movd %stack_temp,$1152 movq $1,($2)153 movq %rbp,tsp_frame.save_rbp($2)154 movq $2,%rcontext:tcr.save_tsp155 addq $dnode_size,$2102 __(subq $dnode_size,$1) 103 __(jge macro_label(loop)) 104 __(movq %rcontext:tcr.next_tsp,$2) 105 __(movd %stack_temp,$1) 106 __(movq $1,($2)) 107 __(movq %rbp,tsp_frame.save_rbp($2)) 108 __(movq $2,%rcontext:tcr.save_tsp) 109 __(addq $dnode_size,$2) 156 110 ]) 157 111 … … 160 114 define([Allocate_Catch_Frame],[ 161 115 TSP_Alloc_Fixed(catch_frame.size,$1) 162 movq [$](catch_frame.element_count<<subtag_shift)|subtag_catch_frame,dnode_size($1)163 addq [$]dnode_size+fulltag_misc,$1116 __(movq [$](catch_frame.element_count<<subtag_shift)|subtag_catch_frame,dnode_size($1)) 117 __(addq [$]dnode_size+fulltag_misc,$1) 164 118 ]) 165 119 … … 168 122 define([Make_Catch],[ 169 123 Allocate_Catch_Frame(%imm2) 170 movq %rcontext:tcr.catch_top,%imm0171 movq %rcontext:tcr.db_link,%imm1172 movq %arg_z,catch_frame.catch_tag(%imm2)173 movq %imm0,catch_frame.link(%imm2)174 movq [$]$1,catch_frame.mvflag(%imm2)175 movq %rcontext:tcr.xframe,%imm0176 movq %rsp,catch_frame.rsp(%imm2)177 movq %rbp,catch_frame.rbp(%imm2)178 movq %rcontext:tcr.foreign_sp,%stack_temp179 movq %imm1,catch_frame.db_link(%imm2)180 movq %save3,catch_frame._save3(%imm2)181 movq %save2,catch_frame._save2(%imm2)182 movq %save1,catch_frame._save1(%imm2)183 movq %save0,catch_frame._save0(%imm2)184 movq %imm0,catch_frame.xframe(%imm2)185 movq %stack_temp,catch_frame.foreign_sp(%imm2)186 movq %xfn,catch_frame.pc(%imm2)187 movq %imm2,%rcontext:tcr.catch_top124 __(movq %rcontext:tcr.catch_top,%imm0) 125 __(movq %rcontext:tcr.db_link,%imm1) 126 __(movq %arg_z,catch_frame.catch_tag(%imm2)) 127 __(movq %imm0,catch_frame.link(%imm2)) 128 __(movq [$]$1,catch_frame.mvflag(%imm2)) 129 __(movq %rcontext:tcr.xframe,%imm0) 130 __(movq %rsp,catch_frame.rsp(%imm2)) 131 __(movq %rbp,catch_frame.rbp(%imm2)) 132 __(movq %rcontext:tcr.foreign_sp,%stack_temp) 133 __(movq %imm1,catch_frame.db_link(%imm2)) 134 __(movq %save3,catch_frame._save3(%imm2)) 135 __(movq %save2,catch_frame._save2(%imm2)) 136 __(movq %save1,catch_frame._save1(%imm2)) 137 __(movq %save0,catch_frame._save0(%imm2)) 138 __(movq %imm0,catch_frame.xframe(%imm2)) 139 __(movq %stack_temp,catch_frame.foreign_sp(%imm2)) 140 __(movq %xfn,catch_frame.pc(%imm2)) 141 __(movq %imm2,%rcontext:tcr.catch_top) 188 142 ]) 189 143 190 144 define([nMake_Catch],[ 191 145 Allocate_Catch_Frame(%imm2) 192 movq %rcontext:tcr.catch_top,%imm0193 movq %rcontext:tcr.db_link,%imm1194 movq %arg_z,catch_frame.catch_tag(%imm2)195 movq %imm0,catch_frame.link(%imm2)196 lea node_size(%rsp),%imm0197 movq [$]$1,catch_frame.mvflag(%imm2)198 movq %imm0,catch_frame.rsp(%imm2)199 movq %rcontext:tcr.xframe,%imm0200 movq %rbp,catch_frame.rbp(%imm2)201 movq %rcontext:tcr.foreign_sp,%stack_temp202 movq %imm1,catch_frame.db_link(%imm2)203 movq %save3,catch_frame._save3(%imm2)204 movq %save2,catch_frame._save2(%imm2)205 movq %save1,catch_frame._save1(%imm2)206 movq %save0,catch_frame._save0(%imm2)207 movq %imm0,catch_frame.xframe(%imm2)208 movq %stack_temp,catch_frame.foreign_sp(%imm2)209 movq %xfn,catch_frame.pc(%imm2)210 movq %imm2,%rcontext:tcr.catch_top146 __(movq %rcontext:tcr.catch_top,%imm0) 147 __(movq %rcontext:tcr.db_link,%imm1) 148 __(movq %arg_z,catch_frame.catch_tag(%imm2)) 149 __(movq %imm0,catch_frame.link(%imm2)) 150 __(lea node_size(%rsp),%imm0) 151 __(movq [$]$1,catch_frame.mvflag(%imm2)) 152 __(movq %imm0,catch_frame.rsp(%imm2)) 153 __(movq %rcontext:tcr.xframe,%imm0) 154 __(movq %rbp,catch_frame.rbp(%imm2)) 155 __(movq %rcontext:tcr.foreign_sp,%stack_temp) 156 __(movq %imm1,catch_frame.db_link(%imm2)) 157 __(movq %save3,catch_frame._save3(%imm2)) 158 __(movq %save2,catch_frame._save2(%imm2)) 159 __(movq %save1,catch_frame._save1(%imm2)) 160 __(movq %save0,catch_frame._save0(%imm2)) 161 __(movq %imm0,catch_frame.xframe(%imm2)) 162 __(movq %stack_temp,catch_frame.foreign_sp(%imm2)) 163 __(movq %xfn,catch_frame.pc(%imm2)) 164 __(movq %imm2,%rcontext:tcr.catch_top) 211 165 ]) 212 166 … … 229 183 /* to interrupt; the interrupting code has to recognize and possibly */ 230 184 /* emulate the instructions in between */ 231 subq $cons.size-fulltag_cons,%rcontext:tcr.save_allocptr232 movq %rcontext:tcr.save_allocptr,%allocptr233 rcmpq(%allocptr,%rcontext:tcr.save_allocbase)234 jg macro_label(no_trap)185 __(subq $cons.size-fulltag_cons,%rcontext:tcr.save_allocptr) 186 __(movq %rcontext:tcr.save_allocptr,%allocptr) 187 __(rcmpq(%allocptr,%rcontext:tcr.save_allocbase)) 188 __(jg macro_label(no_trap)) 235 189 uuo_alloc() 236 190 macro_label(no_trap): 237 andb $~fulltagmask,%rcontext:tcr.save_allocptr191 __(andb $~fulltagmask,%rcontext:tcr.save_allocptr) 238 192 /* Easy to interrupt now that tcr.save_allocptr isn't tagged as a cons */ 239 movq $2,cons.cdr(%allocptr)240 movq $1,cons.car(%allocptr)193 __(movq $2,cons.cdr(%allocptr)) 194 __(movq $1,cons.car(%allocptr)) 241 195 ifelse($3,[],[],[ 242 movq %allocptr,$3196 __(movq %allocptr,$3) 243 197 ]) 244 198 ]) … … 248 202 249 203 define([Misc_Alloc],[ 250 subq [$]fulltag_misc,%imm1204 __(subq [$]fulltag_misc,%imm1) 251 205 Misc_Alloc_Internal($1) 252 206 ]) … … 257 211 258 212 new_macro_labels() 259 subq %imm1,%rcontext:tcr.save_allocptr260 movq %rcontext:tcr.save_allocptr,%allocptr261 rcmpq(%allocptr,%rcontext:tcr.save_allocbase)262 jg macro_label(no_trap)213 __(subq %imm1,%rcontext:tcr.save_allocptr) 214 __(movq %rcontext:tcr.save_allocptr,%allocptr) 215 __(rcmpq(%allocptr,%rcontext:tcr.save_allocbase)) 216 __(jg macro_label(no_trap)) 263 217 uuo_alloc() 264 218 macro_label(no_trap): 265 movq %imm0,misc_header_offset(%allocptr)266 andb $~fulltagmask,%rcontext:tcr.save_allocptr219 __(movq %imm0,misc_header_offset(%allocptr)) 220 __(andb $~fulltagmask,%rcontext:tcr.save_allocptr) 267 221 /* Now that tcr.save_allocptr is untagged, it's easier to be interrupted */ 268 222 ifelse($1,[],[],[ 269 mov %allocptr,$1223 __(mov %allocptr,$1) 270 224 ]) 271 225 ]) 272 226 273 227 define([Misc_Alloc_Fixed],[ 274 movq [$]$2-fulltag_misc,%imm1228 __(movq [$]$2-fulltag_misc,%imm1) 275 229 Misc_Alloc_Internal($1) 276 230 ]) 277 231 278 232 define([vrefr],[ 279 mov misc_data_offset+($3<<word_shift)($2),$1233 __(mov misc_data_offset+($3<<word_shift)($2),$1) 280 234 ]) 281 235 282 236 define([jump_fn],[ 283 jmpq *%fn237 __(jmpq *%fn) 284 238 ]) 285 239 286 240 define([jump_fname],[ 287 mov symbol.fcell(%fname),%fn241 __(mov symbol.fcell(%fname),%fn) 288 242 jump_fn() 289 243 ]) 290 244 291 245 define([set_nargs],[ 292 movw [$]$1<<fixnumshift,%nargs 293 ]) 246 ifelse(eval($1>15),1,[ 247 __(movl [$]$1<<fixnumshift,%nargs_l) 248 ],[ 249 __(xorl %nargs_l,%nargs_l) 250 ifelse(eval($1),0,[],[ 251 __(addl [$]$1<<fixnumshift,%nargs_l) 252 ])])]) 253 254 294 255 295 256 /* $1 = ndigits. Assumes 4-byte digits */ … … 298 259 299 260 define([_car],[ 300 movq cons.car($1),$2261 __(movq cons.car($1),$2) 301 262 ]) 302 263 303 264 define([_rplaca],[ 304 movq $2,cons.car($1)265 __(movq $2,cons.car($1)) 305 266 ]) 306 267 307 268 define([_cdr],[ 308 movq cons.cdr($1),$2269 __(movq cons.cdr($1),$2) 309 270 ]) 310 271 311 272 define([_rplacd],[ 312 movq $2,cons.cdr($1)273 __(movq $2,cons.cdr($1)) 313 274 ]) 314 275 … … 327 288 define([do_funcall],[ 328 289 new_macro_labels() 329 movb %temp0_b,%imm0_b330 andb $fulltagmask,%imm0_b331 cmpb $fulltag_symbol,%imm0_b290 __(movb %temp0_b,%imm0_b) 291 __(andb $fulltagmask,%imm0_b) 292 __(cmpb $fulltag_symbol,%imm0_b) 332 293 /* %fname == %temp0 */ 333 cmovgq %temp0,%fn294 __(cmovgq %temp0,%fn) 334 295 jl macro_label(bad) 335 cmoveq symbol.fcell(%fname),%fn336 jmp *%fn296 __(cmoveq symbol.fcell(%fname),%fn) 297 __(jmp *%fn) 337 298 macro_label(bad): 338 299 __(uuo_error_not_callable) … … 340 301 341 302 define([getvheader],[ 342 movq misc_header_offset($1),$2303 __(movq misc_header_offset($1),$2) 343 304 ]) 344 305 … … 346 307 /* both be immediate registers */ 347 308 define([header_size],[ 348 movq $1,$2349 shr $num_subtag_bits,$2309 __(movq $1,$2) 310 __(shr $num_subtag_bits,$2) 350 311 ]) 351 312 352 313 /* $2 (length) is fixnum element-count. */ 353 314 define([header_length],[ 354 movq $~255,$2355 andq $1,$2356 shr $num_subtag_bits-fixnumshift,$2315 __(movq $~255,$2) 316 __(andq $1,$2) 317 __(shr $num_subtag_bits-fixnumshift,$2) 357 318 ]) 358 319 … … 365 326 /* $1 = vector, $2 = dest */ 366 327 define([vector_length],[ 367 movq $~255,$2368 andq misc_header_offset($1),$2369 shr $num_subtag_bits-fixnumshift,$2328 __(movq $~255,$2) 329 __(andq misc_header_offset($1),$2) 330 __(shr $num_subtag_bits-fixnumshift,$2) 370 331 ]) 371 332 372 333 /* GAS/ATT comparison arg order drives me nuts */ 373 334 define([rcmpq],[ 374 cmpq $2,$1335 __(cmpq $2,$1) 375 336 ]) 376 337 377 338 define([rcmpl],[ 378 cmpl $2,$1339 __(cmpl $2,$1) 379 340 ]) 380 341 381 342 define([rcmpw],[ 382 cmpw $2,$1343 __(cmpw $2,$1) 383 344 ]) 384 345 385 346 define([rcmpb],[ 386 cmpb $2,$1347 __(cmpb $2,$1) 387 348 ]) 388 349 389 350 390 351 define([condition_to_boolean],[ 391 movl [$]t_value,$2_l392 lea (-t_offset)($2),$3393 cmov$1l $2_l,$3_l352 __(movl [$]t_value,$2_l) 353 __(lea (-t_offset)($2),$3) 354 __(cmov$1l $2_l,$3_l) 394 355 ]) 395 356 396 357 define([compare_reg_to_nil],[ 397 cmpb $fulltag_nil,$1_b358 __(cmpb $fulltag_nil,$1_b) 398 359 ]) 399 360 400 361 define([extract_lisptag],[ 401 movzbl $1_b,$2_l402 andb [$]tagmask,$2_b362 __(movzbl $1_b,$2_l) 363 __(andb [$]tagmask,$2_b) 403 364 ]) 404 365 405 366 406 367 define([extract_fulltag],[ 407 movzbl $1_b,$2_l408 andb [$]fulltagmask,$2_b368 __(movzbl $1_b,$2_l) 369 __(andb [$]fulltagmask,$2_b) 409 370 ]) 410 371 411 372 define([extract_subtag],[ 412 movb misc_subtag_offset($1),$2373 __(movb misc_subtag_offset($1),$2) 413 374 ]) 414 375 415 376 define([extract_typecode],[ 416 377 new_macro_labels() 417 movzbl $1_b,$2_l418 andb $tagmask,$2_b419 cmpb $tag_misc,$2_b420 jne macro_label(done)421 movb misc_subtag_offset($1),$2_b378 __(movzbl $1_b,$2_l) 379 __(andb $tagmask,$2_b) 380 __(cmpb $tag_misc,$2_b) 381 __(jne macro_label(done)) 382 __(movb misc_subtag_offset($1),$2_b) 422 383 macro_label(done): 423 384 ]) … … 426 387 427 388 define([dnode_align],[ 428 lea ($2+(dnode_size-1))($1),$3429 andb $~(dnode_size-1),$3_b389 __(lea ($2+(dnode_size-1))($1),$3) 390 __(andb $~(dnode_size-1),$3_b) 430 391 ]) 431 392 432 393 define([push_argregs],[ 433 394 new_macro_labels() 434 testw %nargs,%nargs435 jz macro_label(done)436 cmpw [$]2*node_size,%nargs437 je macro_label(yz)438 jb macro_label(z)439 push %arg_x395 __(testw %nargs,%nargs) 396 __(jz macro_label(done)) 397 __(cmpw [$]2*node_size,%nargs) 398 __(je macro_label(yz)) 399 __(jb macro_label(z)) 400 __(push %arg_x) 440 401 macro_label(yz): 441 push %arg_y402 __(push %arg_y) 442 403 macro_label(z): 443 push %arg_z404 __(push %arg_z) 444 405 macro_label(done): 445 406 ]) … … 450 411 451 412 define([discard_temp_frame],[ 452 movq %rcontext:tcr.save_tsp,$1453 movq ($1),$1454 movq $1,%rcontext:tcr.save_tsp455 movq $1,%rcontext:tcr.next_tsp413 __(movq %rcontext:tcr.save_tsp,$1) 414 __(movq ($1),$1) 415 __(movq $1,%rcontext:tcr.save_tsp) 416 __(movq $1,%rcontext:tcr.next_tsp) 456 417 457 418 ]) 458 419 459 420 define([check_pending_enabled_interrupt],[ 460 btrq [$]63,%rcontext:tcr.interrupt_pending461 jnc,pt $1421 __(btrq [$]63,%rcontext:tcr.interrupt_pending) 422 __(jnc,pt $1) 462 423 interrupt_now() 463 424 ]) … … 470 431 define([check_pending_interrupt],[ 471 432 new_macro_labels() 472 movq %rcontext:tcr.tlb_pointer,$1473 cmpq [$]0,INTERRUPT_LEVEL_BINDING_INDEX($1)474 js,pt macro_label(done)433 __(movq %rcontext:tcr.tlb_pointer,$1) 434 __(cmpq [$]0,INTERRUPT_LEVEL_BINDING_INDEX($1)) 435 __(js,pt macro_label(done)) 475 436 check_pending_enabled_interrupt(macro_label(done)) 476 437 macro_label(done): … … 486 447 ifelse($1,[],[ 487 448 ],[ 488 movq $1,%rdi449 __(movq $1,%rdi) 489 450 ]) 490 movl [$]0x3000003,%eax491 syscall451 __(movl [$]0x3000003,%eax) 452 __(syscall) 492 453 ]) 493 454 … … 503 464 504 465 define([save_tcr_linear],[ 505 movq %rcontext:tcr.linear,$1466 __(movq %rcontext:tcr.linear,$1) 506 467 ]) 507 468 … … 512 473 /* branch or (b) immediately follows a conditional branch not taken. */ 513 474 define([repret],[ 514 .byte 0xf3515 ret475 __(.byte 0xf3) 476 __(ret) 516 477 ]) 517 478
Note:
See TracChangeset
for help on using the changeset viewer.
