mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
fix PR7465, mishandling of lcall and ljmp: intersegment long
call and jumps. llvm-svn: 111496
This commit is contained in:
parent
ba5736d2fe
commit
355d472093
@ -39,6 +39,7 @@ def MRM_E8 : Format<39>;
|
||||
def MRM_F0 : Format<40>;
|
||||
def MRM_F8 : Format<41>;
|
||||
def MRM_F9 : Format<42>;
|
||||
def RawFrmImm16 : Format<43>;
|
||||
|
||||
// ImmType - This specifies the immediate type used by an instruction. This is
|
||||
// part of the ad-hoc solution used to emit machine instruction encodings by our
|
||||
|
@ -311,6 +311,12 @@ namespace X86II {
|
||||
MRM_F0 = 40,
|
||||
MRM_F8 = 41,
|
||||
MRM_F9 = 42,
|
||||
|
||||
/// RawFrmImm16 - This is used for CALL FAR instructions, which have two
|
||||
/// immediates, the first of which is a 16 or 32-bit immediate (specified by
|
||||
/// the imm encoding) and the second is a 16-bit fixed value. In the AMD
|
||||
/// manual, this operand is described as pntr16:32 and pntr16:16
|
||||
RawFrmImm16 = 43,
|
||||
|
||||
FormMask = 63,
|
||||
|
||||
@ -522,6 +528,7 @@ namespace X86II {
|
||||
case X86II::AddRegFrm:
|
||||
case X86II::MRMDestReg:
|
||||
case X86II::MRMSrcReg:
|
||||
case X86II::RawFrmImm16:
|
||||
return -1;
|
||||
case X86II::MRMDestMem:
|
||||
return 0;
|
||||
|
@ -675,12 +675,12 @@ let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
|
||||
def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
|
||||
[(brind (loadi32 addr:$dst))]>, Requires<[In32BitMode]>;
|
||||
|
||||
def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
|
||||
(ins i16imm:$seg, i16imm:$off),
|
||||
"ljmp{w}\t$seg, $off", []>, OpSize;
|
||||
def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
|
||||
(ins i16imm:$seg, i32imm:$off),
|
||||
"ljmp{l}\t$seg, $off", []>;
|
||||
def FARJMP16i : Iseg16<0xEA, RawFrmImm16, (outs),
|
||||
(ins i16imm:$off, i16imm:$seg),
|
||||
"ljmp{w}\t{$seg, $off|$off, $seg}", []>, OpSize;
|
||||
def FARJMP32i : Iseg32<0xEA, RawFrmImm16, (outs),
|
||||
(ins i32imm:$off, i16imm:$seg),
|
||||
"ljmp{l}\t{$seg, $off|$off, $seg}", []>;
|
||||
|
||||
def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
|
||||
"ljmp{w}\t{*}$dst", []>, OpSize;
|
||||
@ -716,12 +716,12 @@ let isCall = 1 in
|
||||
def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
|
||||
"call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
|
||||
|
||||
def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
|
||||
(ins i16imm:$seg, i16imm:$off),
|
||||
"lcall{w}\t$seg, $off", []>, OpSize;
|
||||
def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
|
||||
(ins i16imm:$seg, i32imm:$off),
|
||||
"lcall{l}\t$seg, $off", []>;
|
||||
def FARCALL16i : Iseg16<0x9A, RawFrmImm16, (outs),
|
||||
(ins i16imm:$off, i16imm:$seg),
|
||||
"lcall{w}\t{$seg, $off|$off, $seg}", []>, OpSize;
|
||||
def FARCALL32i : Iseg32<0x9A, RawFrmImm16, (outs),
|
||||
(ins i32imm:$off, i16imm:$seg),
|
||||
"lcall{l}\t{$seg, $off|$off, $seg}", []>;
|
||||
|
||||
def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
|
||||
"lcall{w}\t{*}$dst", []>, OpSize;
|
||||
|
@ -827,6 +827,14 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
||||
case X86II::RawFrm:
|
||||
EmitByte(BaseOpcode, CurByte, OS);
|
||||
break;
|
||||
|
||||
case X86II::RawFrmImm16:
|
||||
EmitByte(BaseOpcode, CurByte, OS);
|
||||
EmitImmediate(MI.getOperand(CurOp++),
|
||||
X86II::getSizeOfImm(TSFlags), getImmFixupKind(TSFlags),
|
||||
CurByte, OS, Fixups);
|
||||
EmitImmediate(MI.getOperand(CurOp++), 2, FK_Data_2, CurByte, OS, Fixups);
|
||||
break;
|
||||
|
||||
case X86II::AddRegFrm:
|
||||
EmitByte(BaseOpcode + GetX86RegNum(MI.getOperand(CurOp++)), CurByte, OS);
|
||||
|
@ -418,3 +418,8 @@ retl
|
||||
// CHECK: jmpl *8(%eax)
|
||||
// CHECK: encoding: [0xff,0x60,0x08]
|
||||
jmp *8(%eax)
|
||||
|
||||
// PR7465
|
||||
// CHECK: lcalll $2, $4660
|
||||
// CHECK: encoding: [0x9a,0x34,0x12,0x00,0x00,0x02,0x00]
|
||||
lcalll $0x2, $0x1234
|
||||
|
Loading…
Reference in New Issue
Block a user