On Sun, 2008-10-12 at 21:23 -0700, Kjell Godo wrote: > Could you please explain: > > (:reg (:early-cleanup :reg) ,#'(lambda (op cg) > (movl-reg cg (output (lhs op)) :reg (eax cg)) > > (emit-epilogue cg))) > ?
This is a pseudo-instruction that takes the return value as an argument and places it in the eax register. It then emits the cleanup code to return from the function. > What is the op and the cg = codeGenerator? op is the early-cleanup instruction. cg is the code generator object. > movl-reg ? moves a long from a register to a register > (output (leftHandSide op))? returns the register allocated for the left-hand side of the early-cleanup instruction > What is ccrs standing for? call-clobbered registers These are registers whose values are not preserved after a CALL/RET. The call-saved registers (ebx, esi, edi) must be saved by a function before it uses them, and the values restored before returning. > (add (ccrs c) (setf (ecx c) (make-instance 'register :register-class > :I4 :name :ecx :encoding #x41)) ) > > Why is the encoding hex 41? Why isn't it just 1? If you look at the initialization code: (defmethod initialize-instance :after ((c i32-code-generator) &key) (add (ccrs c) (setf (eax c) (make-instance 'register :register-class :I4 :name :eax :encoding #x40))) (add (ccrs c) (setf (ecx c) (make-instance 'register :register-class :I4 :name :ecx :encoding #x41)) ) (add (ccrs c) (setf (edx c) (make-instance 'register :register-class :I4 :name :edx :encoding #x42)) ) (add (csrs c) (setf (ebx c) (make-instance 'register :register-class :I4 :name :ebx :encoding #x43)) ) (add (csrs c) (setf (esi c) (make-instance 'register :register-class :I4 :name :esi :encoding #x46)) ) (add (csrs c) (setf (edi c) (make-instance 'register :register-class :I4 :name :edi :encoding #x47)) ) (setf (esp c) (make-instance 'register :register-class :P4 :name :esp :encoding #x44)) (setf (ebp c) (make-instance 'register :register-class :P4 :name :ebp :encoding #x45)) (setf (cx c) (make-instance 'register :register-class :I2 :name :cx :encoding #x21)) (setf (cl c) (make-instance 'register :register-class :II :name :cl :encoding #x11)) c) You can see that 32-bit registers are marked with the #x40 bit, 16-bit with #x20, and 8-bit with #x10 John _______________________________________________ fonc mailing list fonc@vpri.org http://vpri.org/mailman/listinfo/fonc