mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
Fix big numeric literal movement
This commit is contained in:
parent
3805a0896b
commit
aeb4675210
1 changed files with 4 additions and 2 deletions
|
|
@ -228,10 +228,12 @@ let show instr =
|
||||||
open SM
|
open SM
|
||||||
|
|
||||||
let in_memory = function M _ | S _ | I _ -> true | R _ | L _ -> false
|
let in_memory = function M _ | S _ | I _ -> true | R _ | L _ -> false
|
||||||
|
let big_numeric_literal = function L num -> num > 0xFFFFFFFF | _ -> false
|
||||||
|
|
||||||
let mov x s =
|
let mov x s =
|
||||||
if x = s then []
|
if x = s then []
|
||||||
else if in_memory x && in_memory s then [ Mov (x, rax); Mov (rax, s) ]
|
else if (in_memory x && in_memory s) || big_numeric_literal x then
|
||||||
|
[ Mov (x, rax); Mov (rax, s) ]
|
||||||
else [ Mov (x, s) ]
|
else [ Mov (x, s) ]
|
||||||
|
|
||||||
let box n = (n lsl 1) lor 1
|
let box n = (n lsl 1) lor 1
|
||||||
|
|
@ -747,7 +749,7 @@ let compile cmd env imports code =
|
||||||
| SEXP (t, n) ->
|
| SEXP (t, n) ->
|
||||||
let s, env = env#allocate in
|
let s, env = env#allocate in
|
||||||
let env, code = compile_call env ~fname:".sexp" (n + 1) false in
|
let env, code = compile_call env ~fname:".sexp" (n + 1) false in
|
||||||
(env, [ Mov (L (box (env#hash t)), s) ] @ code)
|
(env, (mov L (box (env#hash t))) s @ code)
|
||||||
| DROP -> (snd env#pop, [])
|
| DROP -> (snd env#pop, [])
|
||||||
| DUP ->
|
| DUP ->
|
||||||
let x = env#peek in
|
let x = env#peek in
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue