Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Cmm.memory_chunk.Double_u #10433

Merged
merged 3 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Working version

### Internal/compiler-libs changes:

- #10433: Remove the distinction between 32-bit aligned and 64-bit aligned
64-bit floats in Cmm.memory_chunk.
(Greta Yorsh, review by Xavier Leroy)

### Build system:

### Bug fixes:
Expand Down
4 changes: 2 additions & 2 deletions asmcomp/amd64/emit.mlp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ let emit_instr env fallthrough i =
I.movsxd (addressing addr DWORD i 0) dest
| Single ->
I.cvtss2sd (addressing addr REAL4 i 0) dest
| Double | Double_u ->
| Double ->
I.movsd (addressing addr REAL8 i 0) dest
end
| Lop(Istore(chunk, addr, _)) ->
Expand All @@ -581,7 +581,7 @@ let emit_instr env fallthrough i =
| Single ->
I.cvtsd2ss (arg i 0) xmm15;
I.movss xmm15 (addressing addr REAL4 i 1)
| Double | Double_u ->
| Double ->
I.movsd (arg i 0) (addressing addr REAL8 i 1)
end
| Lop(Ialloc { bytes = n; dbginfo }) ->
Expand Down
6 changes: 3 additions & 3 deletions asmcomp/amd64/selection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ method! select_operation op args dbg =
self#select_floatarith false Idivf Ifloatdiv args
| Cextcall("sqrt", _, _, false) ->
begin match args with
[Cop(Cload ((Double|Double_u as chunk), _), [loc], _dbg)] ->
[Cop(Cload ((Double as chunk), _), [loc], _dbg)] ->
let (addr, arg) = self#select_addressing chunk loc in
(Ispecific(Ifloatsqrtf addr), [arg])
| [arg] ->
Expand Down Expand Up @@ -251,11 +251,11 @@ method! select_operation op args dbg =

method select_floatarith commutative regular_op mem_op args =
match args with
[arg1; Cop(Cload ((Double|Double_u as chunk), _), [loc2], _)] ->
[arg1; Cop(Cload ((Double as chunk), _), [loc2], _)] ->
let (addr, arg2) = self#select_addressing chunk loc2 in
(Ispecific(Ifloatarithmem(mem_op, addr)),
[arg1; arg2])
| [Cop(Cload ((Double|Double_u as chunk), _), [loc1], _); arg2]
| [Cop(Cload ((Double as chunk), _), [loc1], _); arg2]
when commutative ->
let (addr, arg1) = self#select_addressing chunk loc1 in
(Ispecific(Ifloatarithmem(mem_op, addr)),
Expand Down
10 changes: 4 additions & 6 deletions asmcomp/arm/emit.mlp
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ let emit_instr env i =
| Lop(Iload(Single, addr, _mut)) when !fpu >= VFPv2 ->
` flds s14, {emit_addressing addr i.arg 0}\n`;
` fcvtds {emit_reg i.res.(0)}, s14\n`; 2
| Lop(Iload((Double | Double_u), addr, _mut)) when !fpu = Soft ->
| Lop(Iload(Double, addr, _mut)) when !fpu = Soft ->
(* Use LDM or LDRD if possible *)
begin match i.res.(0), i.res.(1), addr with
{loc = Reg rt}, {loc = Reg rt2}, Iindexed 0
Expand All @@ -555,14 +555,13 @@ let emit_instr env i =
| Byte_signed -> "ldrsb"
| Sixteen_unsigned -> "ldrh"
| Sixteen_signed -> "ldrsh"
| Double
| Double_u -> "fldd"
| Double -> "fldd"
| _ (* 32-bit quantities *) -> "ldr" in
` {emit_string instr} {emit_reg r}, {emit_addressing addr i.arg 0}\n`; 1
| Lop(Istore(Single, addr, _)) when !fpu >= VFPv2 ->
` fcvtsd s14, {emit_reg i.arg.(0)}\n`;
` fsts s14, {emit_addressing addr i.arg 1}\n`; 2
| Lop(Istore((Double | Double_u), addr, _)) when !fpu = Soft ->
| Lop(Istore(Double, addr, _)) when !fpu = Soft ->
(* Use STM or STRD if possible *)
begin match i.arg.(0), i.arg.(1), addr with
{loc = Reg rt}, {loc = Reg rt2}, Iindexed 0
Expand All @@ -584,8 +583,7 @@ let emit_instr env i =
| Byte_signed -> "strb"
| Sixteen_unsigned
| Sixteen_signed -> "strh"
| Double
| Double_u -> "fstd"
| Double -> "fstd"
| _ (* 32-bit quantities *) -> "str" in
` {emit_string instr} {emit_reg r}, {emit_addressing addr i.arg 1}\n`; 1
| Lop(Ialloc { bytes = n; dbginfo }) ->
Expand Down
2 changes: 1 addition & 1 deletion asmcomp/arm/selection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ open Mach
let is_offset chunk n =
match chunk with
(* VFPv{2,3} load/store have -1020 to 1020. Offset must be multiple of 4 *)
| Single | Double | Double_u
| Single | Double
when !fpu >= VFPv2 ->
n >= -1020 && n <= 1020 && n mod 4 = 0
(* ARM load/store byte/word have -4095 to 4095 *)
Expand Down
4 changes: 2 additions & 2 deletions asmcomp/arm64/emit.mlp
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ let emit_instr env i =
| Single ->
` ldr s7, {emit_addressing addr base}\n`;
` fcvt {emit_reg dst}, s7\n`
| Word_int | Word_val | Double | Double_u ->
| Word_int | Word_val | Double ->
` ldr {emit_reg dst}, {emit_addressing addr base}\n`
end
| Lop(Istore(size, addr, _)) ->
Expand All @@ -720,7 +720,7 @@ let emit_instr env i =
| Single ->
` fcvt s7, {emit_reg src}\n`;
` str s7, {emit_addressing addr base}\n`;
| Word_int | Word_val | Double | Double_u ->
| Word_int | Word_val | Double ->
` str {emit_reg src}, {emit_addressing addr base}\n`
end
| Lop(Ialloc { bytes = n; dbginfo }) ->
Expand Down
2 changes: 1 addition & 1 deletion asmcomp/arm64/selection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let is_offset chunk n =
n land 1 = 0 && n lsr 1 < 0x1000
| Thirtytwo_unsigned | Thirtytwo_signed | Single ->
n land 3 = 0 && n lsr 2 < 0x1000
| Word_int | Word_val | Double | Double_u ->
| Word_int | Word_val | Double ->
n land 7 = 0 && n lsr 3 < 0x1000)

let is_logical_immediate n =
Expand Down
1 change: 0 additions & 1 deletion asmcomp/cmm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ type memory_chunk =
| Word_val
| Single
| Double
| Double_u

and operation =
Capply of machtype
Expand Down
4 changes: 2 additions & 2 deletions asmcomp/cmm.mli
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ type memory_chunk =
| Word_int (* integer or pointer outside heap *)
| Word_val (* pointer inside heap or encoded int *)
| Single
| Double (* 64-bit-aligned 64-bit float *)
| Double_u (* word-aligned 64-bit float *)
| Double (* word-aligned 64-bit float
see PR#10433 *)

and operation =
Capply of machtype
Expand Down
16 changes: 8 additions & 8 deletions asmcomp/cmm_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -569,18 +569,18 @@ let unbox_float dbg =
| Some (Uconst_float x) ->
Cconst_float (x, dbg) (* or keep _dbg? *)
| _ ->
Cop(Cload (Double_u, Immutable), [cmm], dbg)
Cop(Cload (Double, Immutable), [cmm], dbg)
end
| cmm -> Cop(Cload (Double_u, Immutable), [cmm], dbg)
| cmm -> Cop(Cload (Double, Immutable), [cmm], dbg)
)

(* Complex *)

let box_complex dbg c_re c_im =
Cop(Calloc, [alloc_floatarray_header 2 dbg; c_re; c_im], dbg)

let complex_re c dbg = Cop(Cload (Double_u, Immutable), [c], dbg)
let complex_im c dbg = Cop(Cload (Double_u, Immutable),
let complex_re c dbg = Cop(Cload (Double, Immutable), [c], dbg)
let complex_im c dbg = Cop(Cload (Double, Immutable),
[Cop(Cadda, [c; Cconst_int (size_float, dbg)], dbg)],
dbg)

Expand Down Expand Up @@ -728,7 +728,7 @@ let int_array_ref arr ofs dbg =
Cop(Cload (Word_int, Mutable),
[array_indexing log2_size_addr arr ofs dbg], dbg)
let unboxed_float_array_ref arr ofs dbg =
Cop(Cload (Double_u, Mutable),
Cop(Cload (Double, Mutable),
[array_indexing log2_size_float arr ofs dbg], dbg)
let float_array_ref arr ofs dbg =
box_float dbg (unboxed_float_array_ref arr ofs dbg)
Expand All @@ -743,7 +743,7 @@ let int_array_set arr ofs newval dbg =
Cop(Cstore (Word_int, Lambda.Assignment),
[array_indexing log2_size_addr arr ofs dbg; newval], dbg)
let float_array_set arr ofs newval dbg =
Cop(Cstore (Double_u, Lambda.Assignment),
Cop(Cstore (Double, Lambda.Assignment),
[array_indexing log2_size_float arr ofs dbg; newval], dbg)

(* String length *)
Expand Down Expand Up @@ -2096,7 +2096,7 @@ let generic_functions shared units =
type unary_primitive = expression -> Debuginfo.t -> expression

let floatfield n ptr dbg =
Cop(Cload (Double_u, Mutable),
Cop(Cload (Double, Mutable),
[if n = 0 then ptr
else Cop(Cadda, [ptr; Cconst_int(n * size_float, dbg)], dbg)],
dbg)
Expand Down Expand Up @@ -2200,7 +2200,7 @@ let setfield n ptr init arg1 arg2 dbg =

let setfloatfield n init arg1 arg2 dbg =
return_unit dbg (
Cop(Cstore (Double_u, init),
Cop(Cstore (Double, init),
[if n = 0 then arg1
else Cop(Cadda, [arg1; Cconst_int(n * size_float, dbg)], dbg);
arg2], dbg))
Expand Down
2 changes: 1 addition & 1 deletion asmcomp/i386/CSE.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ method! class_of_operation op =
(* Operations that affect the floating-point stack cannot be factored *)
| Iconst_float _ | Inegf | Iabsf | Iaddf | Isubf | Imulf | Idivf
| Iintoffloat | Ifloatofint
| Iload((Single | Double | Double_u), _, _) -> Op_other
| Iload((Single | Double), _, _) -> Op_other
(* Specific ops *)
| Ispecific(Ilea _) -> Op_pure
| Ispecific(Istore_int(_, _, is_asg)) -> Op_store is_asg
Expand Down
4 changes: 2 additions & 2 deletions asmcomp/i386/emit.mlp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ let emit_instr env fallthrough i =
I.movsx (addressing addr WORD i 0) (reg dest)
| Single ->
I.fld (addressing addr REAL4 i 0)
| Double | Double_u ->
| Double ->
I.fld (addressing addr REAL8 i 0)
end
| Lop(Istore(chunk, addr, _)) ->
Expand All @@ -573,7 +573,7 @@ let emit_instr env fallthrough i =
I.fld (reg i.arg.(0));
I.fstp (addressing addr REAL4 i 1)
end
| Double | Double_u ->
| Double ->
if is_tos i.arg.(0) then
I.fstp (addressing addr REAL8 i 1)
else begin
Expand Down
7 changes: 3 additions & 4 deletions asmcomp/i386/selection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ let pseudoregs_for_operation op arg res =
(* For floating-point operations and floating-point loads,
the result is always left at the top of the floating-point stack *)
| Iconst_float _ | Inegf | Iabsf | Iaddf | Isubf | Imulf | Idivf
| Ifloatofint | Iload((Single | Double | Double_u), _, _)
| Ifloatofint | Iload((Single | Double ), _, _)
| Ispecific(Isubfrev | Idivfrev | Ifloatarithmem _ | Ifloatspecial _) ->
(arg, [| tos |], false) (* don't move it immediately *)
(* For storing a byte, the argument must be in eax...edx.
Expand All @@ -149,7 +149,6 @@ let pseudoregs_for_operation op arg res =
let chunk_double = function
Single -> false
| Double -> true
| Double_u -> true
| _ -> assert false

(* The selector class *)
Expand Down Expand Up @@ -293,8 +292,8 @@ method select_push exp =
| Cop(Cload ((Word_int | Word_val as chunk), _), [loc], _) ->
let (addr, arg) = self#select_addressing chunk loc in
(Ispecific(Ipush_load addr), arg)
| Cop(Cload (Double_u, _), [loc], _) ->
let (addr, arg) = self#select_addressing Double_u loc in
| Cop(Cload (Double, _), [loc], _) ->
let (addr, arg) = self#select_addressing Double loc in
(Ispecific(Ipush_load_float addr), arg)
| _ -> (Ispecific(Ipush), exp)

Expand Down
4 changes: 2 additions & 2 deletions asmcomp/power/emit.mlp
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ let emit_instr env i =
| Thirtytwo_signed -> if ppc64 then "lwa" else "lwz"
| Word_int | Word_val -> lg
| Single -> "lfs"
| Double | Double_u -> "lfd" in
| Double -> "lfd" in
emit_load_store loadinstr addr i.arg 0 i.res.(0);
if chunk = Byte_signed then
` extsb {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n`
Expand All @@ -755,7 +755,7 @@ let emit_instr env i =
| Thirtytwo_unsigned | Thirtytwo_signed -> "stw"
| Word_int | Word_val -> stg
| Single -> "stfs"
| Double | Double_u -> "stfd" in
| Double -> "stfd" in
emit_load_store storeinstr addr i.arg 1 i.arg.(0)
| Lop(Ialloc { bytes; dbginfo }) ->
emit_alloc env i bytes dbginfo false
Expand Down
1 change: 0 additions & 1 deletion asmcomp/printcmm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ let chunk = function
| Word_val -> "val"
| Single -> "float32"
| Double -> "float64"
| Double_u -> "float64u"

let phantom_defining_expr ppf defining_expr =
match defining_expr with
Expand Down
4 changes: 2 additions & 2 deletions asmcomp/riscv/emit.mlp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ let emit_instr env i =
| Thirtytwo_signed -> "lw"
| Word_int | Word_val -> "ld"
| Single -> assert false
| Double | Double_u -> "fld"
| Double -> "fld"
in
` {emit_string instr} {emit_reg i.res.(0)}, {emit_int ofs}({emit_reg i.arg.(0)})\n`
| Lop(Istore(Single, Iindexed ofs, _)) ->
Expand All @@ -331,7 +331,7 @@ let emit_instr env i =
| Thirtytwo_unsigned | Thirtytwo_signed -> "sw"
| Word_int | Word_val -> "sd"
| Single -> assert false
| Double | Double_u -> "fsd"
| Double -> "fsd"
in
` {emit_string instr} {emit_reg i.arg.(0)}, {emit_int ofs}({emit_reg i.arg.(1)})\n`
| Lop(Ialloc {bytes; dbginfo}) ->
Expand Down
4 changes: 2 additions & 2 deletions asmcomp/s390x/emit.mlp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ let emit_instr env i =
| Thirtytwo_signed -> "lgf"
| Word_int | Word_val -> "lg"
| Single -> "ley"
| Double | Double_u -> "ldy" in
| Double -> "ldy" in
emit_load_store loadinstr addr i.arg 0 i.res.(0);
if chunk = Single then
` ldebr {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n`
Expand All @@ -386,7 +386,7 @@ let emit_instr env i =
| Thirtytwo_unsigned | Thirtytwo_signed -> "sty"
| Word_int | Word_val -> "stg"
| Single -> assert false
| Double | Double_u -> "stdy" in
| Double -> "stdy" in
emit_load_store storeinstr addr i.arg 1 i.arg.(0)

| Lop(Ialloc { bytes = n; dbginfo }) ->
Expand Down
4 changes: 2 additions & 2 deletions asmcomp/selectgen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ let oper_result_type = function
| Cload (c, _) ->
begin match c with
| Word_val -> typ_val
| Single | Double | Double_u -> typ_float
| Single | Double -> typ_float
| _ -> typ_int
end
| Calloc -> typ_val
Expand Down Expand Up @@ -995,7 +995,7 @@ method emit_stores env data regs_addr =
Istore(_, _, _) ->
for i = 0 to Array.length regs - 1 do
let r = regs.(i) in
let kind = if r.typ = Float then Double_u else Word_val in
let kind = if r.typ = Float then Double else Word_val in
self#insert env
(Iop(Istore(kind, !a, false)))
(Array.append [|r|] regs_addr) [||];
Expand Down
6 changes: 3 additions & 3 deletions testsuite/tools/parsecmm.mly
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ expr:
Debuginfo.none) }
| LPAREN FLOATAREF expr expr RPAREN
{ let open Asttypes in
Cop(Cload (Double_u, Mutable), [access_array $3 $4 Arch.size_float],
Cop(Cload (Double, Mutable), [access_array $3 $4 Arch.size_float],
Debuginfo.none) }
| LPAREN ADDRASET expr expr expr RPAREN
{ let open Lambda in
Expand All @@ -279,7 +279,7 @@ expr:
[access_array $3 $4 Arch.size_int; $5], Debuginfo.none) }
| LPAREN FLOATASET expr expr expr RPAREN
{ let open Lambda in
Cop(Cstore (Double_u, Assignment),
Cop(Cstore (Double, Assignment),
[access_array $3 $4 Arch.size_float; $5], Debuginfo.none) }
;
exprlist:
Expand Down Expand Up @@ -319,7 +319,7 @@ chunk:
| ADDR { Word_val }
| FLOAT32 { Single }
| FLOAT64 { Double }
| FLOAT { Double_u }
| FLOAT { Double }
| VAL { Word_val }
;
unaryop:
Expand Down