mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
Allow negative offsets in MipsMCInstLower::LowerOperand
Summary: We rely on this in our CHERI backend to address the GOT by generating a $pc-relative addresses. For this we emit the following code sequence: lui $1, %pcrel_hi(_CHERI_CAPABILITY_TABLE_-8) daddiu $1, $1, %pcrel_lo(_CHERI_CAPABILITY_TABLE_-4) cgetpccincoffset $c1, $1 However, without this change the addend is implicitly converted to UINT32_MAX and an invalid pointer value is generated. Reviewers: atanasyan Reviewed By: atanasyan Subscribers: merge_guards_bot, sdardis, hiraditya, jrtc27, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70953
This commit is contained in:
parent
8a152514d8
commit
1e20340b43
@ -34,7 +34,7 @@ void MipsMCInstLower::Initialize(MCContext *C) {
|
|||||||
|
|
||||||
MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
|
MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
|
||||||
MachineOperandType MOTy,
|
MachineOperandType MOTy,
|
||||||
unsigned Offset) const {
|
int64_t Offset) const {
|
||||||
MCSymbolRefExpr::VariantKind Kind = MCSymbolRefExpr::VK_None;
|
MCSymbolRefExpr::VariantKind Kind = MCSymbolRefExpr::VK_None;
|
||||||
MipsMCExpr::MipsExprKind TargetKind = MipsMCExpr::MEK_None;
|
MipsMCExpr::MipsExprKind TargetKind = MipsMCExpr::MEK_None;
|
||||||
bool IsGpOff = false;
|
bool IsGpOff = false;
|
||||||
@ -161,9 +161,7 @@ MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
|
|||||||
const MCExpr *Expr = MCSymbolRefExpr::create(Symbol, Kind, *Ctx);
|
const MCExpr *Expr = MCSymbolRefExpr::create(Symbol, Kind, *Ctx);
|
||||||
|
|
||||||
if (Offset) {
|
if (Offset) {
|
||||||
// Assume offset is never negative.
|
// Note: Offset can also be negative
|
||||||
assert(Offset > 0);
|
|
||||||
|
|
||||||
Expr = MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(Offset, *Ctx),
|
Expr = MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(Offset, *Ctx),
|
||||||
*Ctx);
|
*Ctx);
|
||||||
}
|
}
|
||||||
@ -177,7 +175,7 @@ MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
|
|||||||
}
|
}
|
||||||
|
|
||||||
MCOperand MipsMCInstLower::LowerOperand(const MachineOperand &MO,
|
MCOperand MipsMCInstLower::LowerOperand(const MachineOperand &MO,
|
||||||
unsigned offset) const {
|
int64_t offset) const {
|
||||||
MachineOperandType MOTy = MO.getType();
|
MachineOperandType MOTy = MO.getType();
|
||||||
|
|
||||||
switch (MOTy) {
|
switch (MOTy) {
|
||||||
|
@ -35,11 +35,11 @@ public:
|
|||||||
|
|
||||||
void Initialize(MCContext *C);
|
void Initialize(MCContext *C);
|
||||||
void Lower(const MachineInstr *MI, MCInst &OutMI) const;
|
void Lower(const MachineInstr *MI, MCInst &OutMI) const;
|
||||||
MCOperand LowerOperand(const MachineOperand& MO, unsigned offset = 0) const;
|
MCOperand LowerOperand(const MachineOperand &MO, int64_t offset = 0) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MCOperand LowerSymbolOperand(const MachineOperand &MO,
|
MCOperand LowerSymbolOperand(const MachineOperand &MO,
|
||||||
MachineOperandType MOTy, unsigned Offset) const;
|
MachineOperandType MOTy, int64_t Offset) const;
|
||||||
MCOperand createSub(MachineBasicBlock *BB1, MachineBasicBlock *BB2,
|
MCOperand createSub(MachineBasicBlock *BB1, MachineBasicBlock *BB2,
|
||||||
MipsMCExpr::MipsExprKind Kind) const;
|
MipsMCExpr::MipsExprKind Kind) const;
|
||||||
void lowerLongBranchLUi(const MachineInstr *MI, MCInst &OutMI) const;
|
void lowerLongBranchLUi(const MachineInstr *MI, MCInst &OutMI) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user