Skip to content

Commit

Permalink
fix confusion of MOVHLPS and MOVLPS
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Mar 23, 2021
1 parent 3632fbc commit b894e9d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dm/src/dmc/cgreg.d
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void cgreg_init()
{ uint sz;
Symbol *s = globsym[i];

//printf("considering candidate '%s' for register\n",s.Sident);
//printf("considering candidate '%s' for register\n", s.Sident.ptr);

if (s.Srange)
s.Srange = vec_realloc(s.Srange,dfo.length);
Expand Down
13 changes: 11 additions & 2 deletions dm/src/dmc/cgxmm.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Compiler implementation of the
* $(LINK2 http://www.dlang.org, D programming language).
*
* Copyright: Copyright (C) 2011-2020 by The D Language Foundation, All Rights Reserved
* Copyright: Copyright (C) 2011-2021 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 /~https://github.com/dlang/dmd/blob/master/src/dmd/backend/cgxmm.d, backend/cgxmm.d)
Expand Down Expand Up @@ -1180,12 +1180,21 @@ static if (0)
codelem(cdb,op1,&retregs,false); // eval left leaf
const reg = findreg(retregs);

if ((op2.Eoper == OPind && !op2.Ecount) || op2.Eoper == OPvar)
/* MOVHLPS and LODLPS have the same opcode. They are distinguished
* by MOVHLPS has a second operand of size 128, LODLPS has 64
* https://www.felixcloutier.com/x86/movlps
* https://www.felixcloutier.com/x86/movhlps
* MOVHLPS must be an XMM operand, LODLPS must be a memory operand
*/
const isMOVHLPS = op == MOVHLPS && tysize(ty2) == 16;

if (((op2.Eoper == OPind && !op2.Ecount) || op2.Eoper == OPvar) && !isMOVHLPS)
{
getlvalue(cdb,&cs, op2, RMload | retregs); // get addressing mode
}
else
{
// load op2 into XMM register
regm_t rretregs = XMMREGS & ~retregs;
scodelem(cdb, op2, &rretregs, retregs, true);
const rreg = findreg(rretregs) - XMM0;
Expand Down
1 change: 1 addition & 0 deletions dm/src/dmc/cod3.d
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ void cgreg_dst_regs(reg_t* dst_integer_reg, reg_t* dst_float_reg)

void cgreg_set_priorities(tym_t ty, const(reg_t)** pseq, const(reg_t)** pseqmsw)
{
//printf("cgreg_set_priorities %x\n", ty);
const sz = tysize(ty);

if (tyxmmreg(ty))
Expand Down
4 changes: 2 additions & 2 deletions dm/src/dmc/xmm.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Compiler implementation of the
* $(LINK2 http://www.dlang.org, D programming language).
*
* Copyright: Copyright (C) ?-2020 by The D Language Foundation, All Rights Reserved
* Copyright: Copyright (C) ?-2021 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 /~https://github.com/dlang/dmd/blob/master/src/dmd/backend/xmm.d, backend/_xmm.d)
Expand Down Expand Up @@ -74,14 +74,14 @@ enum
LODDQU = 0xF30F6F, // MOVDQU xmm1, xmm2/mem128 F3 0F 6F /r
STODQU = 0xF30F7F, // MOVDQU xmm1/mem128, xmm2 F3 0F 7F /r
MOVDQ2Q = 0xF20FD6, // MOVDQ2Q mmx, xmm F2 0F D6 /r
MOVHLPS = 0x0F12, // MOVHLPS xmm1, xmm2 0F 12 /r
LODHPD = 0x660F16, // MOVHPD xmm, mem64 66 0F 16 /r
STOHPD = 0x660F17, // MOVHPD mem64, xmm 66 0F 17 /r
LODHPS = 0x0F16, // MOVHPS xmm, mem64 0F 16 /r
STOHPS = 0x0F17, // MOVHPS mem64, xmm 0F 17 /r
MOVLHPS = 0x0F16, // MOVLHPS xmm1, xmm2 0F 16 /r
LODLPD = 0x660F12, // MOVLPD xmm, mem64 66 0F 12 /r
STOLPD = 0x660F13, // MOVLPD mem64, xmm 66 0F 13 /r
MOVHLPS = 0x0F12, // MOVHLPS xmm1, xmm2 0F 12 /r
LODLPS = 0x0F12, // MOVLPS xmm, mem64 0F 12 /r
STOLPS = 0x0F13, // MOVLPS mem64, xmm 0F 13 /r
MOVMSKPD = 0x660F50, // MOVMSKPD reg32, xmm 66 0F 50 /r
Expand Down

0 comments on commit b894e9d

Please sign in to comment.