Improve load_symbol_addr

git-svn-id: http://caml.inria.fr/svn/ocaml/branches/abstract_intel_emit@15208 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Alain Frisch 2014-09-10 11:37:28 +00:00
parent 5868f17c7b
commit 9eb911370b
1 changed files with 10 additions and 17 deletions

View File

@ -137,25 +137,18 @@ let emit_jump s =
else _l (emit_symbol s)
)
let windows =
match system with
| S_mingw64 | S_cygwin | S_win64 -> true
| _ -> false
let load_symbol_addr s arg =
(* TODO: review that carefully, and simplify *)
if system = S_win64 || system = S_mingw64 then
(* What about Cygwin? *)
if !pic_code then
I.leaq (at_rip (abs s), arg)
else
I.movq (_offset (abs s), arg)
if !Clflags.dlcode && not windows then
I.movq (at_rip (abs s ~tbl:GOTPCREL), arg)
else if !pic_code then
I.leaq (at_rip (abs s), arg)
else
let addr =
if !Clflags.dlcode && (match system with
S_mingw64 | S_cygwin | S_win64 -> false
| _ -> true)
then at_rip (abs s ~tbl:GOTPCREL)
else if !pic_code
then at_rip (abs s) (* check *)
else _offset (abs s)
in
I.movq (addr, arg)
I.movq (_offset (abs s), arg)
(* Output a label *)