Skip to content

Commit

Permalink
Merge pull request #8017 from LemonBoy/b18553
Browse files Browse the repository at this point in the history
Fix issue 18553 - Allow mov reg64,crn and mov crn,reg64
merged-on-behalf-of: Walter Bright <WalterBright@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Mar 22, 2018
2 parents 4bf3211 + 1cd441e commit a73766d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/dmd/backend/ptrntab.c
Expand Up @@ -627,6 +627,8 @@ PTRNTAB2 aptb2MOV[] = /* MOV */ {
#endif
{ 0x0f20, _r, _r32, _special | _crn },
{ 0x0f22, _r, _special|_crn, _r32 },
{ 0x0f20, _r, _r64, _special | _crn },
{ 0x0f22, _r, _special|_crn, _r64 },
{ 0x0f21, _r, _r32, _special | _drn },
{ 0x0f23, _r, _special|_drn, _r32 },
{ 0x0f24, _r, _r32, _special | _trn },
Expand Down
1 change: 1 addition & 0 deletions src/dmd/iasm.d
Expand Up @@ -394,6 +394,7 @@ immutable REG[73] regtab64 =
{"YMM13", 13, _ymm},
{"YMM14", 14, _ymm},
{"YMM15", 15, _ymm},
{"CR8", 8, _r64 | _special | _crn},
];


Expand Down
49 changes: 49 additions & 0 deletions test/runnable/iasm64.d
Expand Up @@ -6748,6 +6748,54 @@ L1: pop RAX;

/****************************************************/

void test18553()
{
ubyte* p;

static ubyte[] data =
[
0x0F, 0x20, 0xC0,
0x0F, 0x20, 0xD0,
0x0F, 0x20, 0xD8,
0x0F, 0x20, 0xE0,

0x0F, 0x22, 0xC0,
0x0F, 0x22, 0xD0,
0x0F, 0x22, 0xD8,
0x0F, 0x22, 0xE0,

0x44, 0x0F, 0x22, 0xC0,
0x44, 0x0F, 0x20, 0xC0,
];

asm
{
call L1;

mov RAX, CR0;
mov RAX, CR2;
mov RAX, CR3;
mov RAX, CR4;
mov CR0, RAX;
mov CR2, RAX;
mov CR3, RAX;
mov CR4, RAX;

mov CR8, RAX;
mov RAX, CR8;

L1: pop RAX;
mov p[RBP],RAX;
}

foreach (ref i, b; data)
{
assert(p[i] == b);
}
}

/****************************************************/

int main()
{
printf("Testing iasm64.d\n");
Expand Down Expand Up @@ -6822,6 +6870,7 @@ int main()
test15999();
testconst();
test17027();
test18553();

printf("Success\n");
return 0;
Expand Down

0 comments on commit a73766d

Please sign in to comment.