mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Post process 'and', 'sub' instructions and select better encoding, if available.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148489 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f460bf8cd8
commit
a951f77ca3
@ -1331,6 +1331,84 @@ processInstruction(MCInst &Inst,
|
||||
Inst = TmpInst;
|
||||
return true;
|
||||
}
|
||||
case X86::ADD16i16: {
|
||||
if (!Inst.getOperand(0).isImm() ||
|
||||
!isImmSExti16i8Value(Inst.getOperand(0).getImm()))
|
||||
return false;
|
||||
|
||||
MCInst TmpInst;
|
||||
TmpInst.setOpcode(X86::ADD16ri8);
|
||||
TmpInst.addOperand(MCOperand::CreateReg(X86::AX));
|
||||
TmpInst.addOperand(MCOperand::CreateReg(X86::AX));
|
||||
TmpInst.addOperand(Inst.getOperand(0));
|
||||
Inst = TmpInst;
|
||||
return true;
|
||||
}
|
||||
case X86::ADD32i32: {
|
||||
if (!Inst.getOperand(0).isImm() ||
|
||||
!isImmSExti32i8Value(Inst.getOperand(0).getImm()))
|
||||
return false;
|
||||
|
||||
MCInst TmpInst;
|
||||
TmpInst.setOpcode(X86::ADD32ri8);
|
||||
TmpInst.addOperand(MCOperand::CreateReg(X86::EAX));
|
||||
TmpInst.addOperand(MCOperand::CreateReg(X86::EAX));
|
||||
TmpInst.addOperand(Inst.getOperand(0));
|
||||
Inst = TmpInst;
|
||||
return true;
|
||||
}
|
||||
case X86::ADD64i32: {
|
||||
if (!Inst.getOperand(0).isImm() ||
|
||||
!isImmSExti64i8Value(Inst.getOperand(0).getImm()))
|
||||
return false;
|
||||
|
||||
MCInst TmpInst;
|
||||
TmpInst.setOpcode(X86::ADD64ri8);
|
||||
TmpInst.addOperand(MCOperand::CreateReg(X86::RAX));
|
||||
TmpInst.addOperand(MCOperand::CreateReg(X86::RAX));
|
||||
TmpInst.addOperand(Inst.getOperand(0));
|
||||
Inst = TmpInst;
|
||||
return true;
|
||||
}
|
||||
case X86::SUB16i16: {
|
||||
if (!Inst.getOperand(0).isImm() ||
|
||||
!isImmSExti16i8Value(Inst.getOperand(0).getImm()))
|
||||
return false;
|
||||
|
||||
MCInst TmpInst;
|
||||
TmpInst.setOpcode(X86::SUB16ri8);
|
||||
TmpInst.addOperand(MCOperand::CreateReg(X86::AX));
|
||||
TmpInst.addOperand(MCOperand::CreateReg(X86::AX));
|
||||
TmpInst.addOperand(Inst.getOperand(0));
|
||||
Inst = TmpInst;
|
||||
return true;
|
||||
}
|
||||
case X86::SUB32i32: {
|
||||
if (!Inst.getOperand(0).isImm() ||
|
||||
!isImmSExti32i8Value(Inst.getOperand(0).getImm()))
|
||||
return false;
|
||||
|
||||
MCInst TmpInst;
|
||||
TmpInst.setOpcode(X86::SUB32ri8);
|
||||
TmpInst.addOperand(MCOperand::CreateReg(X86::EAX));
|
||||
TmpInst.addOperand(MCOperand::CreateReg(X86::EAX));
|
||||
TmpInst.addOperand(Inst.getOperand(0));
|
||||
Inst = TmpInst;
|
||||
return true;
|
||||
}
|
||||
case X86::SUB64i32: {
|
||||
if (!Inst.getOperand(0).isImm() ||
|
||||
!isImmSExti64i8Value(Inst.getOperand(0).getImm()))
|
||||
return false;
|
||||
|
||||
MCInst TmpInst;
|
||||
TmpInst.setOpcode(X86::SUB64ri8);
|
||||
TmpInst.addOperand(MCOperand::CreateReg(X86::RAX));
|
||||
TmpInst.addOperand(MCOperand::CreateReg(X86::RAX));
|
||||
TmpInst.addOperand(Inst.getOperand(0));
|
||||
Inst = TmpInst;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -24,3 +24,11 @@
|
||||
// CHECK: encoding: [0x48,0x89,0x44,0x24,0xf0]
|
||||
mov QWORD PTR [RSP - 16], RAX
|
||||
|
||||
// CHECK: encoding: [0x66,0x83,0xc0,0xf4]
|
||||
add ax, -12
|
||||
// CHECK: encoding: [0x83,0xc0,0xf4]
|
||||
add eax, -12
|
||||
// CHECK: encoding: [0x48,0x83,0xc0,0xf4]
|
||||
add rax, -12
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user