diff options
-rw-r--r-- | share/txr/stdlib/asm.tl | 47 | ||||
-rw-r--r-- | vm.c | 53 | ||||
-rw-r--r-- | vmop.h | 72 |
3 files changed, 35 insertions, 137 deletions
diff --git a/share/txr/stdlib/asm.tl b/share/txr/stdlib/asm.tl index 365cda78..8b63a557 100644 --- a/share/txr/stdlib/asm.tl +++ b/share/txr/stdlib/asm.tl @@ -387,9 +387,8 @@ (:method dis (me asm extension res) ^(,me.symbol ,(operand-to-sym res)))) -(defopcode-derived op-fin fin auto op-end) -(defopcode-derived op-prof prof auto op-fin) +(defopcode-derived op-prof prof auto op-end) (defopcode op-call call auto (:method asm (me asm syntax) @@ -484,50 +483,6 @@ (t 'movrr))])) real.(asm asm syntax))))) -(defopcode op-movrsi movrsi auto - (:static deprecated t) - (:method asm (me asm syntax) - me.(chk-arg-count 2 syntax) - (tree-bind (dst imm) asm.(parse-args me syntax '(d si)) - asm.(put-insn me.code (logtrunc (sys:bits imm) 10) dst))) - - (:method dis (me asm imm dst) - ^(,me.symbol ,(operand-to-sym dst) ,(bits-to-obj imm 10)))) - -(defopcode op-movsmi movsmi auto - (:static deprecated t) - (:method asm (me asm syntax) - me.(chk-arg-count 2 syntax) - (tree-bind (dst imm) asm.(parse-args me syntax '(ds mi)) - asm.(put-insn me.code (enc-small-op dst) - (logtrunc (sys:bits imm) 16)))) - - (:method dis (me asm dst imm ) - ^(,me.symbol ,(small-op-to-sym dst) ,(bits-to-obj imm 16)))) - -(defopcode op-movrbi movrbi auto - (:static deprecated t) - (:method asm (me asm syntax) - me.(chk-arg-count 2 syntax) - (tree-bind (dst imm) asm.(parse-args me syntax '(d bi)) - asm.(put-insn me.code 0 dst) - asm.(put-word (logtrunc (sys:bits imm) 32)))) - - (:method dis (me asm extension dst) - (let ((imm asm.(get-word))) - ^(,me.symbol ,(operand-to-sym dst) ,(bits-to-obj imm 32))))) - -(defopcode op-movi-pseudo movi nil - (:static deprecated t) - (:method asm (me asm syntax) - (tree-bind (dst src) asm.(parse-args me syntax '(d bi)) - (let ((real [%oc-hash% (cond - (asm.(immediate-fits-type src 'si) 'movrsi) - ((and asm.(immediate-fits-type src 'si) - (small-op-p dst)) 'movsmi) - (t 'movrbi))])) - real.(asm asm syntax))))) - (defopcode op-jmp jmp auto (:method asm (me asm syntax) me.(chk-arg-count 1 syntax) @@ -458,12 +458,6 @@ NOINLINE static val vm_end(struct vm *vm, vm_word_t insn) return vm_get(vm->dspl, vm_insn_operand(insn)); } -NOINLINE static val vm_fin(struct vm *vm, vm_word_t insn) -{ - vm->ip--; - return vm_get(vm->dspl, vm_insn_operand(insn)); -} - NOINLINE static void vm_call(struct vm *vm, vm_word_t insn) { unsigned nargs = vm_insn_extra(insn); @@ -674,42 +668,6 @@ NOINLINE static void vm_movrr(struct vm *vm, vm_word_t insn) vm_set(vm->dspl, vm_insn_operand(insn), datum); } -NOINLINE static void vm_movrsi(struct vm *vm, vm_word_t insn) -{ - unsigned dst = vm_insn_operand(insn); - ucnum negmask = ~convert(ucnum, 0x3FF); - ucnum imm = vm_insn_extra(insn); - - if ((imm & TAG_MASK) == NUM && (imm & 0x200)) - imm |= negmask; - - vm_set(vm->dspl, dst, coerce(val, imm)); -} - -NOINLINE static void vm_movsmi(struct vm *vm, vm_word_t insn) -{ - unsigned dst = vm_insn_extra(insn); - ucnum negmask = ~convert(ucnum, 0xFFFF); - ucnum imm = vm_insn_operand(insn); - - if ((imm & TAG_MASK) == NUM && (imm & 0x8000)) - imm |= negmask; - - vm_sm_set(vm->dspl, dst, coerce(val, imm)); -} - -NOINLINE static void vm_movrbi(struct vm *vm, vm_word_t insn) -{ - unsigned dst = vm_insn_operand(insn); - ucnum negmask = ~convert(ucnum, 0xFFFFFFFF); - ucnum imm = vm->code[vm->ip++]; - - if ((imm & TAG_MASK) == NUM && (imm & 0x80000000)) - imm |= negmask; - - vm_set(vm->dspl, dst, coerce(val, imm)); -} - static void vm_jmp(struct vm *vm, vm_word_t insn) { vm->ip = vm_insn_bigop(insn); @@ -1004,8 +962,6 @@ NOINLINE static val vm_execute(struct vm *vm) break; case END: return vm_end(vm, insn); - case FIN: - return vm_fin(vm, insn); case PROF: vm_prof(vm, insn); break; @@ -1030,15 +986,6 @@ NOINLINE static val vm_execute(struct vm *vm) case MOVRR: vm_movrr(vm, insn); break; - case MOVRSI: - vm_movrsi(vm, insn); - break; - case MOVSMI: - vm_movsmi(vm, insn); - break; - case MOVRBI: - vm_movrbi(vm, insn); - break; case JMP: vm_jmp(vm, insn); break; @@ -31,44 +31,40 @@ typedef enum vm_op { SFRAME = 2, DFRAME = 3, END = 4, - FIN = 5, - PROF = 6, - CALL = 7, - APPLY = 8, - GCALL = 9, - GAPPLY = 10, - MOVRS = 11, - MOVSR = 12, - MOVRR = 13, - MOVRSI = 14, /* deprecated */ - MOVSMI = 15, /* deprecated */ - MOVRBI = 16, /* deprecated */ - JMP = 17, - IF = 18, - IFQ = 19, - IFQL = 20, - SWTCH = 21, - UWPROT = 22, - BLOCK = 23, - RETSR = 24, - RETRS = 25, - RETRR = 26, - ABSCSR = 27, - CATCH = 28, - HANDLE = 29, - GETV = 30, - OLDGETF = 31, - GETL1 = 32, - GETVB = 33, - GETFB = 34, - GETL1B = 35, - SETV = 36, - SETL1 = 37, - BINDV = 38, - CLOSE = 39, - GETLX = 40, - SETLX = 41, - GETF = 42, + PROF = 5, + CALL = 6, + APPLY = 7, + GCALL = 8, + GAPPLY = 9, + MOVRS = 10, + MOVSR = 11, + MOVRR = 12, + JMP = 13, + IF = 14, + IFQ = 15, + IFQL = 16, + SWTCH = 17, + UWPROT = 18, + BLOCK = 19, + RETSR = 20, + RETRS = 21, + RETRR = 22, + ABSCSR = 23, + CATCH = 24, + HANDLE = 25, + GETV = 26, + OLDGETF = 27, + GETL1 = 28, + GETVB = 29, + GETFB = 30, + GETL1B = 31, + SETV = 32, + SETL1 = 33, + BINDV = 34, + CLOSE = 35, + GETLX = 36, + SETLX = 37, + GETF = 38, } vm_op_t; #define VM_LEV_BITS 10 |