Changeset 8069
- Timestamp:
- Jan 14, 2008, 6:49:45 PM (17 years ago)
- File:
-
- 1 edited
-
branches/ia32/lisp-kernel/x86-macros.s (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ia32/lisp-kernel/x86-macros.s
r6529 r8069 41 41 42 42 define([box_fixnum],[ 43 imul q[$]fixnumone,$1,$243 imul [$]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),$2 50 ]) 51 49 lea (,$1,fixnumone),$2 50 ]) 51 52 ifdef([X8632],[ 53 define([save_node_regs],[ 54 push %arg_z 55 push %arg_y 56 push %temp0 57 push %temp1 58 push %fn 59 ])],[ 52 60 define([save_node_regs],[ 53 61 push %arg_z … … 63 71 push %ra0 64 72 push %fn 65 ]) 73 ])]) 66 74 67 75 /* This needs to be done before we transition back to the lisp stack */ 68 76 /* from the foreign stack. */ 69 77 78 ifdef([X8632],[ 79 define([zero_node_regs],[ 80 xor %fn,%fn 81 mov %fn,%temp1 82 mov %fn,%temp0 83 mov %fn,%arg_y 84 mov %fn,%arg_z 85 ])],[ 70 86 define([zero_node_regs],[ 71 87 xor %fn,%fn … … 81 97 mov %fn,%arg_y 82 98 mov %fn,arg_z 83 ]) 99 ])]) 100 101 ifdef([X8632],[ 102 define([restore_node_regs],[ 103 pop %fn 104 pop %temp1 105 pop %temp0 106 pop %arg_y 107 pop %arg_z 108 ])],[ 84 109 define([restore_node_regs],[ 85 110 pop %fn … … 95 120 pop %arg_y 96 121 pop %arg_z 97 ]) 122 ])]) 98 123 99 124 /* Zero $3 bytes worth of dnodes, starting at offset $2 relative */ … … 104 129 .macro zero_dnodes 105 130 .if $2 131 ifdef([X8632],[ 132 movsd %fpzero,$1($0) 133 ],[ 106 134 movapd %fpzero,$1($0) 135 ]) 107 136 zero_dnodes $0,$1+dnode_size,$2-dnode_size 108 137 .endif … … 111 140 .macro zero_dnodes base,disp,nbytes 112 141 .ifgt \nbytes 142 ifdef([X8632],[ 143 movsd %fpzero,\disp(\base) 144 ],[ 113 145 movapd %fpzero,\disp(\base) 146 ]) 114 147 zero_dnodes \base,"\disp+dnode_size","\nbytes-dnode_size" 115 148 .endif … … 120 153 /* Allocate $1+dnode_size zeroed bytes on the tstack, using $2 as a temp */ 121 154 /* reg. */ 122 155 156 ifdef([X8632],[ 157 define([TSP_Alloc_Fixed],[ 158 define([TSP_Alloc_Size],[((($1+node_size) & ~(dnode_size-1))+dnode_size)]) 159 subl [$]TSP_Alloc_Size,%rcontext:tcr.next_tsp 160 movd %rcontext:tcr.save_tsp,%stack_temp 161 movl %rcontext:tcr.next_tsp,$2 162 zero_dnodes $2,0,TSP_Alloc_Size 163 movd %stack_temp,($2) 164 movl $2,%rcontext:tcr.save_tsp 165 undefine([TSP_Alloc_Size]) 166 ])],[ 123 167 define([TSP_Alloc_Fixed],[ 124 168 define([TSP_Alloc_Size],[((($1+node_size) & ~(dnode_size-1))+dnode_size)]) … … 130 174 movq $2,%rcontext:tcr.save_tsp 131 175 undefine([TSP_Alloc_Size]) 132 ]) 176 ])]) 133 177 134 178 /* $1 = size (dnode-aligned, including tsp overhead, $2 scratch. */ 135 179 /* Modifies both $1 and $2; on exit, $2 = new_tsp+tsp_overhead, $1 = old tsp */ 136 180 181 ifdef([X8632],[ 182 define([TSP_Alloc_Var],[ 183 new_macro_labels() 184 subl $1,%rcontext:tcr.next_tsp 185 movd %rcontext:tcr.save_tsp,%stack_temp 186 movl %rcontext:tcr.next_tsp,$2 187 jmp macro_label(test) 188 macro_label(loop): 189 movapd %fpzero,0($2) 190 addl $dnode_size,$2 191 macro_label(test): 192 subl $dnode_size,$1 193 jge macro_label(loop) 194 movl %rcontext:tcr.next_tsp,$2 195 movd %stack_temp,$1 196 movl $1,($2) 197 movl $2,%rcontext:tcr.save_tsp 198 addl $dnode_size,$2 199 ])],[ 137 200 define([TSP_Alloc_Var],[ 138 201 new_macro_labels() … … 152 215 movq $2,%rcontext:tcr.save_tsp 153 216 addq $dnode_size,$2 154 ]) 155 156 157 217 ])]) 218 219 220 ifdef([X8632],[ 221 define([Allocate_Catch_Frame],[ 222 TSP_Alloc_Fixed(catch_frame.size,$1) 223 movl [$](catch_frame.element_count<<subtag_shift)|subtag_catch_frame,dnode_size($1) 224 addl [$]dnode_size+fulltag_misc,$1 225 ])],[ 158 226 define([Allocate_Catch_Frame],[ 159 227 TSP_Alloc_Fixed(catch_frame.size,$1) 160 228 movq [$](catch_frame.element_count<<subtag_shift)|subtag_catch_frame,dnode_size($1) 161 229 addq [$]dnode_size+fulltag_misc,$1 162 ]) 230 ])]) 163 231 164 232 /* %arg_z = tag, %xfn = pc, $1 = mvflag */ 165 233 234 ifdef([X8632],[ 235 define([Make_Catch],[ 236 Allocate_Catch_Frame(%imm0) 237 movd %rcontext:tcr.catch_top,%mm0 238 movd %rcontext:tcr.db_link,%mm1 239 movq %arg_z,catch_frame.catch_tag(%imm0) 240 movd %mm0,catch_frame.link(%imm0) 241 movq [$]$1,catch_frame.mvflag(%imm0) 242 movd %rcontext:tcr.xframe,%mm0 243 movq %esp,catch_frame.esp(%imm0) 244 movq %ebp,catch_frame.ebp(%imm0) 245 movd %rcontext:tcr.foreign_sp,%stack_temp 246 movd %mm1,catch_frame.db_link(%imm0) 247 movd %imm0,catch_frame.xframe(%imm0) 248 movd %stack_temp,catch_frame.foreign_sp(%imm0) 249 movl %xfn,catch_frame.pc(%imm0) 250 movd %imm0,%rcontext:tcr.catch_top 251 ])],[ 166 252 define([Make_Catch],[ 167 253 Allocate_Catch_Frame(%imm2) … … 184 270 movq %xfn,catch_frame.pc(%imm2) 185 271 movq %imm2,%rcontext:tcr.catch_top 186 ]) 187 272 ])]) 273 274 ifdef([X8632],[ 275 define([nMake_Catch],[ 276 Allocate_Catch_Frame(%imm0) 277 movd %rcontext:tcr.catch_top,%mm0 278 movd %rcontext:tcr.db_link,%mm1 279 movl %arg_z,catch_frame.catch_tag(%imm0) 280 movd %mm0,catch_frame.link(%imm0) 281 movl %esp,catch_frame.esp(%imm0) 282 addl $node_size,catch_frame.esp(%imm0) 283 movl [$]$1,catch_frame.mvflag(%imm0) 284 movd %rcontext:tcr.xframe,%mm0 285 movl %ebp,catch_frame.ebp(%imm0) 286 movd %rcontext:tcr.foreign_sp,%stack_temp 287 movd %mm1,catch_frame.db_link(%imm0) 288 movd %mm0,catch_frame.xframe(%imm0) 289 movd %stack_temp,catch_frame.foreign_sp(%imm0) 290 movl %xfn,catch_frame.pc(%imm0) 291 movl %imm0,%rcontext:tcr.catch_top 292 ])],[ 188 293 define([nMake_Catch],[ 189 294 Allocate_Catch_Frame(%imm2) … … 207 312 movq %xfn,catch_frame.pc(%imm2) 208 313 movq %imm2,%rcontext:tcr.catch_top 209 ]) 314 ])]) 210 315 211 316 … … 242 347 ]) 243 348 244 /* The header has to be in %imm0, and the physical size in bytes has */ 245 /* to be in %imm1. We bash %imm1. */ 246 349 ifdef([X8632],[ 350 /* Header in %mm0, size in bytes in %imm0. We bash %imm0. */ 351 define([Misc_Alloc],[ 352 sub [$]fulltag_misc,%imm0 353 Misc_Alloc_Internal($1) 354 ])],[ 355 /* Header in %imm0, size in bytes in %imm1. We bash %imm1. */ 247 356 define([Misc_Alloc],[ 248 357 subq [$]fulltag_misc,%imm1 249 358 Misc_Alloc_Internal($1) 250 ]) 251 252 define([Misc_Alloc_Internal],[ 359 ])]) 360 361 253 362 /* Here Be Monsters: we have to treat some/all of this instruction */ 254 363 /* sequence atomically, as soon as tcr.save_allocptr becomes tagged. */ 255 364 365 ifdef([X8632],[ 366 define([Misc_Alloc_Internal],[ 367 new_macro_labels() 368 subl %imm0,%rcontext:tcr.save_allocptr /* decrement allocptr */ 369 movl %rcontext:tcr.save_allocptr,%allocptr /* load into temp0 */ 370 cmpl %rcontext:tcr.save_allocbase,%allocptr /* above allocbase? */ 371 jg macro_label(no_trap) /* yes, skip trap */ 372 uuo_alloc() /* uh, don't skip trap */ 373 macro_label(no_trap): 374 movd %mm0,misc_header_offset(%allocptr) /* write header */ 375 andb $~fulltagmask,%rcontext:tcr.save_allocptr /* untag allocptr */ 376 /* Now that tcr.save_allocptr is untagged, it's easier to be interrupted */ 377 ifelse($1,[],[],[ 378 mov %allocptr,$1 379 ]) 380 ])],[ 381 define([Misc_Alloc_Internal],[ 256 382 new_macro_labels() 257 383 subq %imm1,%rcontext:tcr.save_allocptr … … 267 393 mov %allocptr,$1 268 394 ]) 269 ]) 270 395 ])]) 396 397 ifdef([X8632],[ 271 398 define([Misc_Alloc_Fixed],[ 272 mov q [$]$2-fulltag_misc,%imm1399 mov [$]$2-fulltag_misc,%imm0 273 400 Misc_Alloc_Internal($1) 274 ]) 401 ])],[ 402 define([Misc_Alloc_Fixed],[ 403 mov [$]$2-fulltag_misc,%imm1 404 Misc_Alloc_Internal($1) 405 ])]) 275 406 276 407 define([vrefr],[ … … 279 410 280 411 define([jump_fn],[ 281 jmp q*%fn412 jmp *%fn 282 413 ]) 283 414 … … 296 427 297 428 define([_car],[ 298 mov qcons.car($1),$2429 mov cons.car($1),$2 299 430 ]) 300 431 301 432 define([_rplaca],[ 302 mov q$2,cons.car($1)433 mov $2,cons.car($1) 303 434 ]) 304 435 305 436 define([_cdr],[ 306 mov qcons.cdr($1),$2437 mov cons.cdr($1),$2 307 438 ]) 308 439 309 440 define([_rplacd],[ 310 mov q$2,cons.cdr($1)441 mov $2,cons.cdr($1) 311 442 ]) 312 443 313 444 314 445 ifdef([X8632],[ 446 define([tra],[ 447 .p2align 3 448 .long 0 449 .byte 0 450 $1: 451 ])],[ 315 452 define([tra],[ 316 453 .p2align 3 … … 321 458 ]) 322 459 $1: 323 ]) 324 460 ])]) 461 462 ifdef([X8632],[ 463 define([do_funcall],[ 464 new_macro_labels() 465 movl %imm0,%temp1 /* preserve nargs */ 466 extract_fulltag(%temp0,%imm0) 467 cmpb $fulltag_misc,%imm0_b 468 movl %temp1,%imm0 469 jne macro_label(bad) 470 cmpb $subtag_function,misc_subtag_offset(%temp0) 471 jne macro_label(maybe_symbol) 472 mov %temp0,%fn 473 jmp *%fn 474 macro_label(maybe_symbol): 475 cmpb $subtag_symbol,misc_subtag_offset(%temp0) 476 jne macro_label(bad) 477 /* %fname == %temp0 */ 478 mov symbol.fcell(%fname),%fn 479 jmp *%fn 480 macro_label(bad): 481 __(uuo_error_not_callable) 482 ])],[ 325 483 define([do_funcall],[ 326 484 new_macro_labels() … … 335 493 macro_label(bad): 336 494 __(uuo_error_not_callable) 337 ]) 495 ])]) 338 496 339 497 define([getvheader],[ 340 mov qmisc_header_offset($1),$2498 mov misc_header_offset($1),$2 341 499 ]) 342 500 … … 344 502 /* both be immediate registers */ 345 503 define([header_size],[ 346 mov q$1,$2504 mov $1,$2 347 505 shr $num_subtag_bits,$2 348 506 ]) … … 350 508 /* $2 (length) is fixnum element-count. */ 351 509 define([header_length],[ 352 mov q$~255,$2353 and q$1,$2510 mov $~255,$2 511 and $1,$2 354 512 shr $num_subtag_bits-fixnumshift,$2 355 513 ]) … … 363 521 /* $1 = vector, $2 = dest */ 364 522 define([vector_length],[ 365 mov q$~255,$2366 and qmisc_header_offset($1),$2523 mov $~255,$2 524 and misc_header_offset($1),$2 367 525 shr $num_subtag_bits-fixnumshift,$2 368 526 ]) … … 392 550 ]) 393 551 552 ifdef([X8632],[ 553 define([compare_reg_to_nil],[ 554 cmp $nil_value,$1 555 ])],[ 394 556 define([compare_reg_to_nil],[ 395 557 cmpb $fulltag_nil,$1_b 396 ]) 558 ])]) 397 559 398 560 define([extract_lisptag],[ … … 413 575 define([extract_typecode],[ 414 576 new_macro_labels() 415 mov zbl $1_b,$2_l577 mov $1,$2 416 578 andb $tagmask,$2_b 417 579 cmpb $tag_misc,$2_b … … 423 585 /* dnode_align(src,delta,dest) */ 424 586 425 define([dnode_align],[587 define([dnode_align],[ 426 588 lea ($2+(dnode_size-1))($1),$3 427 589 andb $~(dnode_size-1),$3_b 428 590 ]) 429 591 592 ifdef([X8632],[ 593 define([push_argregs],[ 594 new_macro_labels() 595 cmpw [$]1*node_size,%nargs 596 jb macro_label(done) 597 je macro_label(z) 598 push %arg_y 599 macro_label(z): 600 push %arg_z 601 macro_label(done): 602 ])],[ 430 603 define([push_argregs],[ 431 604 new_macro_labels() … … 441 614 push %arg_z 442 615 macro_label(done): 443 ]) 616 ])]) 444 617 445 618 … … 448 621 449 622 define([discard_temp_frame],[ 450 movq %rcontext:tcr.save_tsp,$1 451 movq ($1),$1 452 movq $1,%rcontext:tcr.save_tsp 453 movq $1,%rcontext:tcr.next_tsp 454 455 ]) 456 623 mov %rcontext:tcr.save_tsp,$1 624 mov ($1),$1 625 mov $1,%rcontext:tcr.save_tsp 626 mov $1,%rcontext:tcr.next_tsp 627 628 ]) 629 630 ifdef([X8632],[ 631 define([check_pending_enabled_interrupt],[ 632 btrl [$]31,%rcontext:tcr.interrupt_pending 633 jnc,pt $1 634 interrupt_now() 635 ])],[ 457 636 define([check_pending_enabled_interrupt],[ 458 637 btrq [$]63,%rcontext:tcr.interrupt_pending 459 638 jnc,pt $1 460 639 interrupt_now() 461 ]) 640 ])]) 462 641 463 642 /* $1 = scratch register, used to access tcr.tlb_pointer. An interrupt */ … … 468 647 define([check_pending_interrupt],[ 469 648 new_macro_labels() 470 mov q%rcontext:tcr.tlb_pointer,$1471 cmp q[$]0,INTERRUPT_LEVEL_BINDING_INDEX($1)649 mov %rcontext:tcr.tlb_pointer,$1 650 cmp [$]0,INTERRUPT_LEVEL_BINDING_INDEX($1) 472 651 js,pt macro_label(done) 473 652 check_pending_enabled_interrupt(macro_label(done)) … … 513 692 ret 514 693 ]) 515 516 694 695 ifdef([X8632],[ 696 define([regnum],[ifelse($1, [eax], [0], 697 $1, [ecx], [1], 698 $1, [edx], [2], 699 $1, [ebx], [3], 700 $1, [esp], [4], 701 $1, [ebp], [5], 702 $1, [esi], [6], 703 $1, [edi], [7])dnl 704 ]) 705 706 define([mark_as_node], [ 707 xorl %$1, %$1 708 orb [$](1<<regnum($1)), %rcontext:tcr.node_regs_mask 709 ]) 710 711 define([mark_as_imm],[ 712 andb [$]~(1<<regnum($1)), %rcontext:tcr.node_regs_mask 713 ]) 714 715 ]) 716
Note:
See TracChangeset
for help on using the changeset viewer.
