Changeset 14838
- Timestamp:
- Jun 22, 2011, 7:10:43 PM (13 years ago)
- Location:
- trunk/source
- Files:
-
- 2 edited
-
compiler/X86/x86-asm.lisp (modified) (1 diff)
-
level-1/x86-trap-support.lisp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/compiler/X86/x86-asm.lisp
r14622 r14838 4848 4848 (match-template-types template type0 type1 type2)))))) 4849 4849 4850 (defun ccl::register-operand-regno (op type) 4851 (when (and (typep op 'x86::x86-register-operand) 4852 (eql (x86::x86-register-operand-type op) 4853 type)) 4854 (x86::reg-entry-reg-num 4855 (x86::x86-register-operand-entry op)))) 4856 4850 4857 4851 4858 (provide "X86-ASM") -
trunk/source/level-1/x86-trap-support.lisp
r14428 r14838 31 31 (defun xp-mxcsr (xp) 32 32 (pref xp :ucontext.uc_mcontext.fpregs.mxcsr)) 33 (defmacro xp-xmm-regs (xp) 34 `(pref ,xp :ucontext.uc_mcontext.fpregs._xmm)) 33 35 (defparameter *encoded-gpr-to-indexed-gpr* 34 36 #(13 ;rax … … 59 61 (with-macptrs ((state (pref xp :__ucontext.uc_mcontext.mc_fpstate))) 60 62 (pref state :savefpu.sv_env.en_mxcsr))) 63 (defmacro xp-xmm-regs (xp) 64 (let* ((state (gensym))) 65 `(with-macptrs ((,state (pref ,xp :__ucontext.uc_mcontext.mc_fpstate))) 66 (pref ,state :savefpu.sv_xmm)))) 67 61 68 (defparameter *encoded-gpr-to-indexed-gpr* 62 69 #(7 ;rax … … 85 92 (defmacro xp-gp-regs (xp) 86 93 `(pref ,xp :ucontext_t.uc_mcontext.__ss)) 94 (defmacro xp-xmm-regs (xp) 95 `(pref ,xp :ucontext_t.uc_mcontext.__fs.__fpu_xmm0)) 87 96 88 97 (defconstant flags-register-offset 17) … … 116 125 (defun xp-mxcsr (xp) 117 126 (pref xp :ucontext.uc_mcontext.fpregs.fp_reg_set.fpchip_state.mxcsr)) 127 (defmacro xp-mmx-regs (xp) 128 `(pref ,xp :ucontext.uc_mcontext.fpregs.fp_reg_set.fpchip_state.xmm)) 118 129 (defparameter *encoded-gpr-to-indexed-gpr* 119 130 #(14 ;rax … … 142 153 (defun xp-mxcsr (xp) 143 154 (pref xp #>CONTEXT.MxCsr)) 155 (defmacro xp-xmm-regs (xp) 156 `(pref ,xp #>CONTEXT.nil.FltSave.XmmRegisters)) 144 157 (defparameter *encoded-gpr-to-indexed-gpr* 145 158 #(0 ;rax … … 168 181 (defun xp-mxcsr (xp) 169 182 (pref xp :ucontext_t.uc_mcontext.__fs.__fpu_mxcsr)) 183 (defmacro xp-xmm-regs (xp) 184 `(pref ,xp :ucontext_t.uc_mcontext.__fs.__fpu_xmm0)) 170 185 (defconstant flags-register-offset 9) 171 186 (defconstant eip-register-offset 10) … … 189 204 (pref (pref (pref xp :ucontext.uc_mcontext) :mcontext_t.fpregs) 190 205 :_fpstate.mxcsr)) 206 (defmacro xp-xmm-regs (xp) 207 `(pref ,xp :ucontext.uc_mcontext.fpregs._xmm)) 191 208 (defconstant flags-register-offset #$REG_EFL) 192 209 (defconstant eip-register-offset #$REG_EIP) … … 210 227 (defun xp-mxcsr (xp) 211 228 (%get-unsigned-long (pref xp #>CONTEXT.ExtendedRegisters) 24)) 229 (defmacro xp-xmm-regs (xp) 230 `(%inc-ptr ,xp #x16c)) 212 231 (defconstant flags-register-offset 48) 213 232 (defconstant eip-register-offset 45) … … 232 251 (pref xp :ucontext.uc_mcontext.fpregs.fp_reg_set.fpchip_state.mxcsr)) 233 252 (defconstant flags-register-offset #$EFL) 253 (defmacro xp-xmm-regs (xp) 254 `(pref ,xp :ucontext.uc_mcontext.fpregs.fp_reg_set.fpchip_state.xmm)) 234 255 (defconstant eip-register-offset #$EIP) 235 256 (defparameter *encoded-gpr-to-indexed-gpr* … … 308 329 #+x8632-target 309 330 (%get-signed-long (xp-gp-regs xp) (+ gp-regs-offset (ash flags-register-offset x8632::fixnumshift))))) 310 311 331 (defmacro xp-xmm-single-float (xp n) 332 `(%get-single-float (xp-xmm-regs ,xp) (ash ,n 4))) 333 (defmacro xp-xmm-double-float (xp n) 334 `(%get-double-float (xp-xmm-regs ,xp) (ash ,n 4))) 312 335 313 336 (defun %get-xcf-byte (xcf-ptr delta) … … 337 360 -1) 338 361 skip)) 339 362 363 (defun arithmetic-error-operation-from-instruction (instruction) 364 (let* ((name (make-keyword (string-upcase (x86-di-mnemonic instruction))))) 365 (case name 366 ((:divss :divsd :idivl :idivd) '/) 367 ((:mulss :mulsd) '*) 368 ((:addss :addsd) '+) 369 ((:subss :subsd) '-) 370 (t 'coerce)))) 371 372 (defun arithmetic-error-operands-from-instruction (instruction xp) 373 (let* ((name (make-keyword (string-upcase (x86-di-mnemonic instruction))))) 374 (let* ((op0 (x86-di-op0 instruction)) 375 (op1 (x86-di-op1 instruction)) 376 (xmmop0 (register-operand-regno op0 #.x86::+operand-type-RegXMM+)) 377 (xmmop1 (register-operand-regno op1 #.x86::+operand-type-RegXMM+))) 378 (collect ((opvals)) 379 (case name 380 ((:divss :mulss :addss :subss) 381 (when (and xmmop0 xmmop1) 382 (opvals (xp-xmm-single-float xp xmmop1)) 383 (opvals (xp-xmm-single-float xp xmmop0)))) 384 ((:divsd :mulsd :addsd :subsd) 385 (when (and xmmop0 xmmop1) 386 (opvals (xp-xmm-double-float xp xmmop1)) 387 (opvals (xp-xmm-double-float xp xmmop0)))) 388 389 ) 390 (opvals))))) 391 392 340 393 341 394 (defun decode-arithmetic-error (xp xcf) 342 (declare (ignore xp xcf)) 343 (values 'unknown nil)) 395 (declare (ignorable xp xcf)) 396 (let* ((code-vector (make-array 15 :element-type '(unsigned-byte 8))) 397 (xfunction (%alloc-misc 1 target::subtag-xfunction))) 398 (dotimes (i 15) ;maximum instructon size 399 (setf (aref code-vector i) (%get-xcf-byte xcf i))) 400 (setf (uvref xfunction 0) code-vector) 401 (let* ((ds (make-x86-disassembly-state 402 :mode-64 #+x8664-target t #+x8632-target nil 403 :code-vector code-vector 404 :constants-vector xfunction 405 :entry-point 0 406 :code-pointer 0 ; for next-u32/next-u16 below 407 :symbolic-names nil 408 :pending-labels (list 0) 409 :code-limit 15 410 :code-pointer 0)) 411 (instruction (ignore-errors (x86-disassemble-instruction ds nil)))) 412 (if instruction 413 (values (arithmetic-error-operation-from-instruction instruction) 414 (arithmetic-error-operands-from-instruction instruction xp)) 415 (values 'unknown nil))))) 344 416 345 417 (eval-when (:compile-toplevel :execute)
Note:
See TracChangeset
for help on using the changeset viewer.
