Changeset 6469


Ignore:
Timestamp:
May 9, 2007, 7:35:40 AM (15 years ago)
Author:
gb
Message:

Support the new (call/ret) calling sequence, new tra/talign scheme.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/compiler/X86/x86-lapmacros.lisp

    r4721 r6469  
    210210  `(movq (@ (+ x8664::nil-value ,(x8664::%kernel-global global))) (% ,reg)))
    211211
     212(defx86lapmacro ref-global.l (global reg)
     213  `(movl (@ (+ x8664::nil-value ,(x8664::%kernel-global global))) (%l ,reg)))
     214
    212215(defx86lapmacro set-global (reg global)
    213216  `(movq (% ,reg) (@ (+ x8664::nil-value ,(x8664::%kernel-global global)))))
     
    240243(defx86lapmacro save-simple-frame ()
    241244  `(progn
    242     (pushq (% ra0))
    243245    (pushq (% rbp))
    244246    (movq (% rsp) (% rbp))))
     
    251253    (subq ($ (* $numx8664argregs x8664::node-size)) (% imm0))
    252254    (jle ,push)
    253     (movq (% rbp) (@ (% rsp) (% imm0)))
    254     (leaq (@ (% rsp) (% imm0)) (% rbp))
    255     (movq (% ra0) (@ 8 (% rbp)))
     255    (movq (% rbp) (@ 8 (% rsp) (% imm0)))
     256    (leaq (@ 8 (% rsp) (% imm0)) (% rbp))
     257    (popq (@ 8 (% rbp)))
    256258    (jmp ,done)
    257259    ,push
     
    262264(defx86lapmacro restore-simple-frame ()
    263265  `(progn
    264     (leave)
    265     (popq (% ra0))))
    266 
    267 
    268 ;;; Caller pushed zeros to reserve space for stack frame before
    269 ;;; pushing args.  We have to discard it before returning.
     266    (leave)))
     267
     268
     269
    270270(defx86lapmacro discard-reserved-frame ()
    271271  `(add ($ '2) (% rsp)))
    272272
    273 ;;; Return to caller.  (% RA0) should contain a tagged return
    274 ;;; address inside the caller's (% FN).
    275 (defx86lapmacro single-value-return ()
    276   `(jmp (% ra0)))
    277 
    278 (defx86lapmacro recover-fn-from-ra0 (here)
    279   `(leaq (@ (- (:^ ,here)) (% ra0)) (% fn)))
     273;;; Return to caller.
     274(defx86lapmacro single-value-return (&optional (words-to-discard 0))
     275  (if (zerop words-to-discard)
     276    `(ret)
     277    `(ret ($ ,(* x8664::node-size words-to-discard)))))
    280278
    281279;;; Using *x8664-backend* here is wrong but expedient.
     
    290288  `(jmp (@ ,(x86-subprim-offset name))))
    291289
    292 (defx86lapmacro call-subprim (name &optional (recover-fn t))
    293   (let* ((label (gensym)))
    294     `(progn
    295       (leaq (@ (:^ ,label) (% fn)) (% ra0))
    296       (jmp-subprim ,name)
    297       (:tra ,label)
    298       ,@(if recover-fn
    299             `((recover-fn-from-ra0 ,label))))))
     290(defx86lapmacro call-subprim (name)
     291  `(progn
     292    (:talign 4)
     293    (call (@ ,(x86-subprim-offset name)))
     294    (recover-fn-from-rip)))
     295
    300296     
    301297(defx86lapmacro %car (src dest)
     
    315311(defx86lapmacro load-constant (constant dest &optional (fn 'fn))
    316312  `(movq (@ ',constant (% ,fn)) (% ,dest)))
     313
     314(defx86lapmacro recover-fn-from-rip ()
     315  (let* ((next (gensym)))
     316    `(progn
     317      (lea (@ (- (:^ ,next)) (% rip)) (% fn))
     318      ,next)))
    317319
    318320;;; call symbol named NAME, setting nargs to NARGS.  Do the TRA
     
    320322;;; to return a single value.
    321323(defx86lapmacro call-symbol (name nargs)
    322   (let* ((return (gensym)))
    323     `(progn
    324       (load-constant ,name fname)
    325       (set-nargs ,nargs)
    326       (lea (@ (:^ ,return) (% fn)) (% ra0))
    327       (movq (@ x8664::symbol.fcell (% fname)) (% fn))
    328       (jmp (% fn))
    329       (:tra ,return)
    330       (recover-fn-from-ra0 ,return))))
     324  `(progn
     325    (load-constant ,name fname)
     326    (set-nargs ,nargs)
     327    (:talign 4)
     328    (call (@ x8664::symbol.fcell (% fname)))
     329    (recover-fn-from-rip)))
     330
    331331
    332332;;;  tail call the function named by NAME with nargs NARGS.  %FN is
     
    339339  `(progn
    340340    (load-constant ,name fname)
    341     (movq (% fn) (% xfn))
    342     (movq (@ x8664::symbol.fcell (% fname)) (% fn))
    343341    (set-nargs ,nargs)
    344     (jmp (% fn))))
     342    (jmp (@ x8664::symbol.fcell (% fname)))))
    345343
    346344(defx86lapmacro push-argregs ()
Note: See TracChangeset for help on using the changeset viewer.