mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-20 13:04:00 +00:00
Keep source location information for X86 MCFixup's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149106 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f3c936769b
commit
cb5dca3815
@ -1459,6 +1459,7 @@ MatchAndEmitInstruction(SMLoc IDLoc,
|
|||||||
Op->getToken() == "fstenv" || Op->getToken() == "fclex") {
|
Op->getToken() == "fstenv" || Op->getToken() == "fclex") {
|
||||||
MCInst Inst;
|
MCInst Inst;
|
||||||
Inst.setOpcode(X86::WAIT);
|
Inst.setOpcode(X86::WAIT);
|
||||||
|
Inst.setLoc(IDLoc);
|
||||||
Out.EmitInstruction(Inst);
|
Out.EmitInstruction(Inst);
|
||||||
|
|
||||||
const char *Repl =
|
const char *Repl =
|
||||||
@ -1492,6 +1493,7 @@ MatchAndEmitInstruction(SMLoc IDLoc,
|
|||||||
while (processInstruction(Inst, Operands))
|
while (processInstruction(Inst, Operands))
|
||||||
;
|
;
|
||||||
|
|
||||||
|
Inst.setLoc(IDLoc);
|
||||||
Out.EmitInstruction(Inst);
|
Out.EmitInstruction(Inst);
|
||||||
return false;
|
return false;
|
||||||
case Match_MissingFeature:
|
case Match_MissingFeature:
|
||||||
@ -1549,6 +1551,7 @@ MatchAndEmitInstruction(SMLoc IDLoc,
|
|||||||
(Match1 == Match_Success) + (Match2 == Match_Success) +
|
(Match1 == Match_Success) + (Match2 == Match_Success) +
|
||||||
(Match3 == Match_Success) + (Match4 == Match_Success);
|
(Match3 == Match_Success) + (Match4 == Match_Success);
|
||||||
if (NumSuccessfulMatches == 1) {
|
if (NumSuccessfulMatches == 1) {
|
||||||
|
Inst.setLoc(IDLoc);
|
||||||
Out.EmitInstruction(Inst);
|
Out.EmitInstruction(Inst);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitImmediate(const MCOperand &Disp,
|
void EmitImmediate(const MCOperand &Disp, SMLoc Loc,
|
||||||
unsigned ImmSize, MCFixupKind FixupKind,
|
unsigned ImmSize, MCFixupKind FixupKind,
|
||||||
unsigned &CurByte, raw_ostream &OS,
|
unsigned &CurByte, raw_ostream &OS,
|
||||||
SmallVectorImpl<MCFixup> &Fixups,
|
SmallVectorImpl<MCFixup> &Fixups,
|
||||||
@ -202,8 +202,8 @@ StartsWithGlobalOffsetTable(const MCExpr *Expr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void X86MCCodeEmitter::
|
void X86MCCodeEmitter::
|
||||||
EmitImmediate(const MCOperand &DispOp, unsigned Size, MCFixupKind FixupKind,
|
EmitImmediate(const MCOperand &DispOp, SMLoc Loc, unsigned Size,
|
||||||
unsigned &CurByte, raw_ostream &OS,
|
MCFixupKind FixupKind, unsigned &CurByte, raw_ostream &OS,
|
||||||
SmallVectorImpl<MCFixup> &Fixups, int ImmOffset) const {
|
SmallVectorImpl<MCFixup> &Fixups, int ImmOffset) const {
|
||||||
const MCExpr *Expr = NULL;
|
const MCExpr *Expr = NULL;
|
||||||
if (DispOp.isImm()) {
|
if (DispOp.isImm()) {
|
||||||
@ -249,7 +249,7 @@ EmitImmediate(const MCOperand &DispOp, unsigned Size, MCFixupKind FixupKind,
|
|||||||
Ctx);
|
Ctx);
|
||||||
|
|
||||||
// Emit a symbolic constant as a fixup and 4 zeros.
|
// Emit a symbolic constant as a fixup and 4 zeros.
|
||||||
Fixups.push_back(MCFixup::Create(CurByte, Expr, FixupKind));
|
Fixups.push_back(MCFixup::Create(CurByte, Expr, FixupKind, Loc));
|
||||||
EmitConstant(0, Size, CurByte, OS);
|
EmitConstant(0, Size, CurByte, OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ void X86MCCodeEmitter::EmitMemModRMByte(const MCInst &MI, unsigned Op,
|
|||||||
// expression to emit.
|
// expression to emit.
|
||||||
int ImmSize = X86II::hasImm(TSFlags) ? X86II::getSizeOfImm(TSFlags) : 0;
|
int ImmSize = X86II::hasImm(TSFlags) ? X86II::getSizeOfImm(TSFlags) : 0;
|
||||||
|
|
||||||
EmitImmediate(Disp, 4, MCFixupKind(FixupKind),
|
EmitImmediate(Disp, MI.getLoc(), 4, MCFixupKind(FixupKind),
|
||||||
CurByte, OS, Fixups, -ImmSize);
|
CurByte, OS, Fixups, -ImmSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -309,7 +309,7 @@ void X86MCCodeEmitter::EmitMemModRMByte(const MCInst &MI, unsigned Op,
|
|||||||
|
|
||||||
if (BaseReg == 0) { // [disp32] in X86-32 mode
|
if (BaseReg == 0) { // [disp32] in X86-32 mode
|
||||||
EmitByte(ModRMByte(0, RegOpcodeField, 5), CurByte, OS);
|
EmitByte(ModRMByte(0, RegOpcodeField, 5), CurByte, OS);
|
||||||
EmitImmediate(Disp, 4, FK_Data_4, CurByte, OS, Fixups);
|
EmitImmediate(Disp, MI.getLoc(), 4, FK_Data_4, CurByte, OS, Fixups);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,13 +325,13 @@ void X86MCCodeEmitter::EmitMemModRMByte(const MCInst &MI, unsigned Op,
|
|||||||
// Otherwise, if the displacement fits in a byte, encode as [REG+disp8].
|
// Otherwise, if the displacement fits in a byte, encode as [REG+disp8].
|
||||||
if (Disp.isImm() && isDisp8(Disp.getImm())) {
|
if (Disp.isImm() && isDisp8(Disp.getImm())) {
|
||||||
EmitByte(ModRMByte(1, RegOpcodeField, BaseRegNo), CurByte, OS);
|
EmitByte(ModRMByte(1, RegOpcodeField, BaseRegNo), CurByte, OS);
|
||||||
EmitImmediate(Disp, 1, FK_Data_1, CurByte, OS, Fixups);
|
EmitImmediate(Disp, MI.getLoc(), 1, FK_Data_1, CurByte, OS, Fixups);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, emit the most general non-SIB encoding: [REG+disp32]
|
// Otherwise, emit the most general non-SIB encoding: [REG+disp32]
|
||||||
EmitByte(ModRMByte(2, RegOpcodeField, BaseRegNo), CurByte, OS);
|
EmitByte(ModRMByte(2, RegOpcodeField, BaseRegNo), CurByte, OS);
|
||||||
EmitImmediate(Disp, 4, MCFixupKind(X86::reloc_signed_4byte), CurByte, OS,
|
EmitImmediate(Disp, MI.getLoc(), 4, MCFixupKind(X86::reloc_signed_4byte), CurByte, OS,
|
||||||
Fixups);
|
Fixups);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -390,10 +390,10 @@ void X86MCCodeEmitter::EmitMemModRMByte(const MCInst &MI, unsigned Op,
|
|||||||
|
|
||||||
// Do we need to output a displacement?
|
// Do we need to output a displacement?
|
||||||
if (ForceDisp8)
|
if (ForceDisp8)
|
||||||
EmitImmediate(Disp, 1, FK_Data_1, CurByte, OS, Fixups);
|
EmitImmediate(Disp, MI.getLoc(), 1, FK_Data_1, CurByte, OS, Fixups);
|
||||||
else if (ForceDisp32 || Disp.getImm() != 0)
|
else if (ForceDisp32 || Disp.getImm() != 0)
|
||||||
EmitImmediate(Disp, 4, MCFixupKind(X86::reloc_signed_4byte), CurByte, OS,
|
EmitImmediate(Disp, MI.getLoc(), 4, MCFixupKind(X86::reloc_signed_4byte),
|
||||||
Fixups);
|
CurByte, OS, Fixups);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitVEXOpcodePrefix - AVX instructions are encoded using a opcode prefix
|
/// EmitVEXOpcodePrefix - AVX instructions are encoded using a opcode prefix
|
||||||
@ -952,17 +952,19 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
|||||||
break;
|
break;
|
||||||
case X86II::RawFrmImm8:
|
case X86II::RawFrmImm8:
|
||||||
EmitByte(BaseOpcode, CurByte, OS);
|
EmitByte(BaseOpcode, CurByte, OS);
|
||||||
EmitImmediate(MI.getOperand(CurOp++),
|
EmitImmediate(MI.getOperand(CurOp++), MI.getLoc(),
|
||||||
X86II::getSizeOfImm(TSFlags), getImmFixupKind(TSFlags),
|
X86II::getSizeOfImm(TSFlags), getImmFixupKind(TSFlags),
|
||||||
CurByte, OS, Fixups);
|
CurByte, OS, Fixups);
|
||||||
EmitImmediate(MI.getOperand(CurOp++), 1, FK_Data_1, CurByte, OS, Fixups);
|
EmitImmediate(MI.getOperand(CurOp++), MI.getLoc(), 1, FK_Data_1, CurByte,
|
||||||
|
OS, Fixups);
|
||||||
break;
|
break;
|
||||||
case X86II::RawFrmImm16:
|
case X86II::RawFrmImm16:
|
||||||
EmitByte(BaseOpcode, CurByte, OS);
|
EmitByte(BaseOpcode, CurByte, OS);
|
||||||
EmitImmediate(MI.getOperand(CurOp++),
|
EmitImmediate(MI.getOperand(CurOp++), MI.getLoc(),
|
||||||
X86II::getSizeOfImm(TSFlags), getImmFixupKind(TSFlags),
|
X86II::getSizeOfImm(TSFlags), getImmFixupKind(TSFlags),
|
||||||
CurByte, OS, Fixups);
|
CurByte, OS, Fixups);
|
||||||
EmitImmediate(MI.getOperand(CurOp++), 2, FK_Data_2, CurByte, OS, Fixups);
|
EmitImmediate(MI.getOperand(CurOp++), MI.getLoc(), 2, FK_Data_2, CurByte,
|
||||||
|
OS, Fixups);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case X86II::AddRegFrm:
|
case X86II::AddRegFrm:
|
||||||
@ -1122,8 +1124,8 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
|||||||
RegNum |= Val;
|
RegNum |= Val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EmitImmediate(MCOperand::CreateImm(RegNum), 1, FK_Data_1, CurByte, OS,
|
EmitImmediate(MCOperand::CreateImm(RegNum), MI.getLoc(), 1, FK_Data_1,
|
||||||
Fixups);
|
CurByte, OS, Fixups);
|
||||||
} else {
|
} else {
|
||||||
unsigned FixupKind;
|
unsigned FixupKind;
|
||||||
// FIXME: Is there a better way to know that we need a signed relocation?
|
// FIXME: Is there a better way to know that we need a signed relocation?
|
||||||
@ -1134,7 +1136,7 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
|
|||||||
FixupKind = X86::reloc_signed_4byte;
|
FixupKind = X86::reloc_signed_4byte;
|
||||||
else
|
else
|
||||||
FixupKind = getImmFixupKind(TSFlags);
|
FixupKind = getImmFixupKind(TSFlags);
|
||||||
EmitImmediate(MI.getOperand(CurOp++),
|
EmitImmediate(MI.getOperand(CurOp++), MI.getLoc(),
|
||||||
X86II::getSizeOfImm(TSFlags), MCFixupKind(FixupKind),
|
X86II::getSizeOfImm(TSFlags), MCFixupKind(FixupKind),
|
||||||
CurByte, OS, Fixups);
|
CurByte, OS, Fixups);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user