diff options
Diffstat (limited to 'x86/Asmexpand.ml')
-rw-r--r-- | x86/Asmexpand.ml | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/x86/Asmexpand.ml b/x86/Asmexpand.ml index 9927d2fb..16426ce3 100644 --- a/x86/Asmexpand.ml +++ b/x86/Asmexpand.ml @@ -331,9 +331,17 @@ let expand_builtin_inline name args res = if a1 <> res then emit (Pmov_rr (res,a1)); emit (Pbswap16 res) - | ("__builtin_clz"|"__builtin_clzl"), [BA(IR a1)], BR(IR res) -> + | "__builtin_clz", [BA(IR a1)], BR(IR res) -> emit (Pbsrl (res,a1)); emit (Pxorl_ri(res,coqint_of_camlint 31l)) + | "__builtin_clzl", [BA(IR a1)], BR(IR res) -> + if not(Archi.ptr64) then begin + emit (Pbsrl (res,a1)); + emit (Pxorl_ri(res,coqint_of_camlint 31l)) + end else begin + emit (Pbsrq (res,a1)); + emit (Pxorl_ri(res,coqint_of_camlint 63l)) + end | "__builtin_clzll", [BA(IR a1)], BR(IR res) -> emit (Pbsrq (res,a1)); emit (Pxorl_ri(res,coqint_of_camlint 63l)) @@ -349,8 +357,13 @@ let expand_builtin_inline name args res = emit (Pbsrl(res, al)); emit (Pxorl_ri(res, coqint_of_camlint 63l)); emit (Plabel lbl2) - | ("__builtin_ctz" | "__builtin_ctzl"), [BA(IR a1)], BR(IR res) -> + | "__builtin_ctz", [BA(IR a1)], BR(IR res) -> emit (Pbsfl (res,a1)) + | "__builtin_ctzl", [BA(IR a1)], BR(IR res) -> + if not(Archi.ptr64) then + emit (Pbsfl (res,a1)) + else + emit (Pbsfq (res,a1)) | "__builtin_ctzll", [BA(IR a1)], BR(IR res) -> emit (Pbsfq (res,a1)) | "__builtin_ctzll", [BA_splitlong(BA (IR ah), BA (IR al))], BR(IR res) -> @@ -462,7 +475,7 @@ let expand_builtin_inline name args res = () (* no operation *) | "__builtin_nop", [], _ -> - emit (Pmov_rr (RAX,RAX)) + emit Pnop (* Catch-all *) | _ -> raise (Error ("unrecognized builtin " ^ name)) @@ -619,10 +632,7 @@ let preg_to_dwarf = function let expand_function id fn = try set_current_function fn; - if !Clflags.option_g then - expand_debug id (int_reg_to_dwarf RSP) preg_to_dwarf expand_instruction fn.fn_code - else - List.iter expand_instruction fn.fn_code; + expand id (int_reg_to_dwarf RSP) preg_to_dwarf expand_instruction fn.fn_code; Errors.OK (get_current_function ()) with Error s -> Errors.Error (Errors.msg (coqstring_of_camlstring s)) |