From 33dfbe7601ad16fcea5377563fa7ceb4053cb85a Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Sat, 22 Aug 2015 09:46:37 +0200 Subject: Renaming {BA,BR}_longofwords -> {BA,BR}_splitlong. Use EF_debug instead of EF_annot for line number annotations. Introduce PrintAsmaux.print_debug_info (very incomplete). powerpc/Asmexpand: revise expand_memcpy_small. --- powerpc/Asm.v | 2 +- powerpc/Asmexpand.ml | 36 +++++++++++++++++------------------- powerpc/SelectOp.vp | 2 +- powerpc/TargetPrinter.ml | 17 +++++------------ 4 files changed, 24 insertions(+), 33 deletions(-) (limited to 'powerpc') diff --git a/powerpc/Asm.v b/powerpc/Asm.v index a724f932..589d66fe 100644 --- a/powerpc/Asm.v +++ b/powerpc/Asm.v @@ -393,7 +393,7 @@ Fixpoint set_res (res: builtin_res preg) (v: val) (rs: regset) : regset := match res with | BR r => rs#r <- v | BR_none => rs - | BR_longofwords hi lo => set_res lo (Val.loword v) (set_res hi (Val.hiword v) rs) + | BR_splitlong hi lo => set_res lo (Val.loword v) (set_res hi (Val.hiword v) rs) end. Section RELSEM. diff --git a/powerpc/Asmexpand.ml b/powerpc/Asmexpand.ml index 9f6c5f76..e09291cc 100644 --- a/powerpc/Asmexpand.ml +++ b/powerpc/Asmexpand.ml @@ -62,7 +62,7 @@ let expand_annot_val txt targ args res = So, use 64-bit accesses only if alignment >= 4. Note that lfd and stfd cannot trap on ill-formed floats. *) -let memcpy_small_arg sz arg otherarg tmp1 tmp2 = +let memcpy_small_arg sz arg tmp = match arg with | BA (IR r) -> (r, _0) @@ -71,17 +71,15 @@ let memcpy_small_arg sz arg otherarg tmp1 tmp2 = && Int.eq (Asmgen.high_s (Int.add ofs (Int.repr (Z.of_uint sz)))) Int.zero then (GPR1, ofs) - else begin - let tmp = if otherarg = BA (IR tmp1) then tmp2 else tmp1 in - emit_addimm tmp GPR1 ofs; - (tmp, _0) - end + else begin emit_addimm tmp GPR1 ofs; (tmp, _0) end | _ -> assert false let expand_builtin_memcpy_small sz al src dst = - let (rsrc, osrc) = memcpy_small_arg sz src dst GPR11 GPR12 in - let (rdst, odst) = memcpy_small_arg sz dst src GPR12 GPR11 in + let (tsrc, tdst) = + if dst <> BA (IR GPR11) then (GPR11, GPR12) else (GPR12, GPR11) in + let (rsrc, osrc) = memcpy_small_arg sz src tsrc in + let (rdst, odst) = memcpy_small_arg sz dst tdst in let rec copy osrc odst sz = if sz >= 8 && al >= 4 && !Clflags.option_ffpu then begin emit (Plfd(FPR13, Cint osrc, rsrc)); @@ -174,7 +172,7 @@ let rec expand_builtin_vload_common chunk base offset res = emit (Plfs(res, offset, base)) | (Mfloat64 | Many64), BR(FR res) -> emit (Plfd(res, offset, base)) - | Mint64, BR_longofwords(BR(IR hi), BR(IR lo)) -> + | Mint64, BR_splitlong(BR(IR hi), BR(IR lo)) -> begin match offset_constant offset _4 with | Some offset' -> if hi <> base then begin @@ -232,7 +230,7 @@ let expand_builtin_vstore_common chunk base offset src = emit (Pstfs(src, offset, base)) | (Mfloat64 | Many64), BA(FR src) -> emit (Pstfd(src, offset, base)) - | Mint64, BA_longofwords(BA(IR hi), BA(IR lo)) -> + | Mint64, BA_splitlong(BA(IR hi), BA(IR lo)) -> begin match offset_constant offset _4 with | Some offset' -> emit (Pstw(hi, offset, base)); @@ -371,25 +369,25 @@ let expand_builtin_inline name args res = emit (Paddi(GPR1, GPR1, Cint _8)); emit (Pcfi_adjust _m8) (* 64-bit integer arithmetic *) - | "__builtin_negl", [BA_longofwords(BA(IR ah), BA(IR al))], - BR_longofwords(BR(IR rh), BR(IR rl)) -> + | "__builtin_negl", [BA_splitlong(BA(IR ah), BA(IR al))], + BR_splitlong(BR(IR rh), BR(IR rl)) -> expand_int64_arith (rl = ah) rl (fun rl -> emit (Psubfic(rl, al, Cint _0)); emit (Psubfze(rh, ah))) - | "__builtin_addl", [BA_longofwords(BA(IR ah), BA(IR al)); - BA_longofwords(BA(IR bh), BA(IR bl))], - BR_longofwords(BR(IR rh), BR(IR rl)) -> + | "__builtin_addl", [BA_splitlong(BA(IR ah), BA(IR al)); + BA_splitlong(BA(IR bh), BA(IR bl))], + BR_splitlong(BR(IR rh), BR(IR rl)) -> expand_int64_arith (rl = ah || rl = bh) rl (fun rl -> emit (Paddc(rl, al, bl)); emit (Padde(rh, ah, bh))) - | "__builtin_subl", [BA_longofwords(BA(IR ah), BA(IR al)); - BA_longofwords(BA(IR bh), BA(IR bl))], - BR_longofwords(BR(IR rh), BR(IR rl)) -> + | "__builtin_subl", [BA_splitlong(BA(IR ah), BA(IR al)); + BA_splitlong(BA(IR bh), BA(IR bl))], + BR_splitlong(BR(IR rh), BR(IR rl)) -> expand_int64_arith (rl = ah || rl = bh) rl (fun rl -> emit (Psubfc(rl, bl, al)); emit (Psubfe(rh, bh, ah))) | "__builtin_mull", [BA(IR a); BA(IR b)], - BR_longofwords(BR(IR rh), BR(IR rl)) -> + BR_splitlong(BR(IR rh), BR(IR rl)) -> expand_int64_arith (rl = a || rl = b) rl (fun rl -> emit (Pmullw(rl, a, b)); emit (Pmulhwu(rh, a, b))) diff --git a/powerpc/SelectOp.vp b/powerpc/SelectOp.vp index 31f7e2e4..6d39569e 100644 --- a/powerpc/SelectOp.vp +++ b/powerpc/SelectOp.vp @@ -533,7 +533,7 @@ Nondetfunction builtin_arg (e: expr) := | Eop (Oaddrstack ofs) Enil => BA_addrstack ofs | Eop Omakelong (Eop (Ointconst h) Enil ::: Eop (Ointconst l) Enil ::: Enil) => BA_long (Int64.ofwords h l) - | Eop Omakelong (h ::: l ::: Enil) => BA_longofwords (BA h) (BA l) + | Eop Omakelong (h ::: l ::: Enil) => BA_splitlong (BA h) (BA l) | Eload chunk (Aglobal id ofs) Enil => BA_loadglobal chunk id ofs | Eload chunk (Ainstack ofs) Enil => BA_loadstack chunk ofs | _ => BA e diff --git a/powerpc/TargetPrinter.ml b/powerpc/TargetPrinter.ml index 5431d88d..ced26783 100644 --- a/powerpc/TargetPrinter.ml +++ b/powerpc/TargetPrinter.ml @@ -358,17 +358,6 @@ module Target (System : SYSTEM):TARGET = assert (!count = 2 || (!count = 0 && !last)); (!mb, !me-1) - (* Handling of annotations *) - - let print_annot_stmt oc txt targs args = - if Str.string_match re_file_line txt 0 then begin - print_file_line oc (Str.matched_group 1 txt) - (int_of_string (Str.matched_group 2 txt)) - end else begin - fprintf oc "%s annotation: " comment; - print_annot_stmt preg_annot "R1" oc txt targs args - end - (* Determine if the displacement of a conditional branch fits the short form *) let short_cond_branch tbl pc lbl_dest = @@ -698,7 +687,11 @@ module Target (System : SYSTEM):TARGET = | Pbuiltin(ef, args, res) -> begin match ef with | EF_annot(txt, targs) -> - print_annot_stmt oc (extern_atom txt) targs args + fprintf oc "%s annotation: " comment; + print_annot_text preg_annot "r1" oc (extern_atom txt) args + | EF_debug(kind, txt, targs) -> + print_debug_info comment print_file_line preg_annot "r1" oc + (P.to_int kind) (extern_atom txt) args | EF_inline_asm(txt, sg, clob) -> fprintf oc "%s begin inline assembly\n\t" comment; print_inline_asm preg oc (extern_atom txt) sg args res; -- cgit