mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
[mips] Inline emitStoreWithSymOffset and emitLoadWithSymOffset methods. NFC
Both methods `MipsTargetStreamer::emitStoreWithSymOffset` and `MipsTargetStreamer::emitLoadWithSymOffset` are almost the same and differ argument names only. These methods are used in the single place so it's better to inline their code and remove original methods. llvm-svn: 370354
This commit is contained in:
parent
697287cd2f
commit
894a4b8230
@ -3675,18 +3675,23 @@ void MipsAsmParser::expandMemInst(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
|
|||||||
TOut.emitRRI(Inst.getOpcode(), DstReg, TmpReg, Res.getConstant(), IDLoc,
|
TOut.emitRRI(Inst.getOpcode(), DstReg, TmpReg, Res.getConstant(), IDLoc,
|
||||||
STI);
|
STI);
|
||||||
} else {
|
} else {
|
||||||
|
// FIXME: Implement 64-bit case.
|
||||||
|
// 1) lw $8, sym => lui $8, %hi(sym)
|
||||||
|
// lw $8, %lo(sym)($8)
|
||||||
|
// 2) sw $8, sym => lui $at, %hi(sym)
|
||||||
|
// sw $8, %lo(sym)($at)
|
||||||
const MCExpr *ExprOffset = OffsetOp.getExpr();
|
const MCExpr *ExprOffset = OffsetOp.getExpr();
|
||||||
MCOperand LoOperand = MCOperand::createExpr(
|
MCOperand LoOperand = MCOperand::createExpr(
|
||||||
MipsMCExpr::create(MipsMCExpr::MEK_LO, ExprOffset, getContext()));
|
MipsMCExpr::create(MipsMCExpr::MEK_LO, ExprOffset, getContext()));
|
||||||
MCOperand HiOperand = MCOperand::createExpr(
|
MCOperand HiOperand = MCOperand::createExpr(
|
||||||
MipsMCExpr::create(MipsMCExpr::MEK_HI, ExprOffset, getContext()));
|
MipsMCExpr::create(MipsMCExpr::MEK_HI, ExprOffset, getContext()));
|
||||||
|
|
||||||
if (IsLoad)
|
// Generate the base address in TmpReg.
|
||||||
TOut.emitLoadWithSymOffset(Inst.getOpcode(), DstReg, BaseReg, HiOperand,
|
TOut.emitRX(Mips::LUi, TmpReg, HiOperand, IDLoc, STI);
|
||||||
LoOperand, TmpReg, IDLoc, STI);
|
if (BaseReg != Mips::ZERO)
|
||||||
else
|
TOut.emitRRR(Mips::ADDu, TmpReg, TmpReg, BaseReg, IDLoc, STI);
|
||||||
TOut.emitStoreWithSymOffset(Inst.getOpcode(), DstReg, BaseReg,
|
// Emit the load or store with the adjusted base and offset.
|
||||||
HiOperand, LoOperand, TmpReg, IDLoc, STI);
|
TOut.emitRRX(Inst.getOpcode(), DstReg, TmpReg, LoOperand, IDLoc, STI);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -332,23 +332,6 @@ void MipsTargetStreamer::emitStoreWithImmOffset(
|
|||||||
emitRRI(Opcode, SrcReg, ATReg, LoOffset, IDLoc, STI);
|
emitRRI(Opcode, SrcReg, ATReg, LoOffset, IDLoc, STI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit a store instruction with an symbol offset. Symbols are assumed to be
|
|
||||||
/// out of range for a simm16 will be expanded to appropriate instructions.
|
|
||||||
void MipsTargetStreamer::emitStoreWithSymOffset(
|
|
||||||
unsigned Opcode, unsigned SrcReg, unsigned BaseReg, MCOperand &HiOperand,
|
|
||||||
MCOperand &LoOperand, unsigned ATReg, SMLoc IDLoc,
|
|
||||||
const MCSubtargetInfo *STI) {
|
|
||||||
// sw $8, sym => lui $at, %hi(sym)
|
|
||||||
// sw $8, %lo(sym)($at)
|
|
||||||
|
|
||||||
// Generate the base address in ATReg.
|
|
||||||
emitRX(Mips::LUi, ATReg, HiOperand, IDLoc, STI);
|
|
||||||
if (BaseReg != Mips::ZERO)
|
|
||||||
emitRRR(Mips::ADDu, ATReg, ATReg, BaseReg, IDLoc, STI);
|
|
||||||
// Emit the store with the adjusted base and offset.
|
|
||||||
emitRRX(Opcode, SrcReg, ATReg, LoOperand, IDLoc, STI);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Emit a store instruction with an symbol offset.
|
/// Emit a store instruction with an symbol offset.
|
||||||
void MipsTargetStreamer::emitSCWithSymOffset(unsigned Opcode, unsigned SrcReg,
|
void MipsTargetStreamer::emitSCWithSymOffset(unsigned Opcode, unsigned SrcReg,
|
||||||
unsigned BaseReg,
|
unsigned BaseReg,
|
||||||
@ -415,30 +398,6 @@ void MipsTargetStreamer::emitLoadWithImmOffset(unsigned Opcode, unsigned DstReg,
|
|||||||
emitRRI(Opcode, DstReg, TmpReg, LoOffset, IDLoc, STI);
|
emitRRI(Opcode, DstReg, TmpReg, LoOffset, IDLoc, STI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit a load instruction with an symbol offset. Symbols are assumed to be
|
|
||||||
/// out of range for a simm16 will be expanded to appropriate instructions.
|
|
||||||
/// DstReg and TmpReg are permitted to be the same register iff DstReg is a
|
|
||||||
/// GPR. It is the callers responsibility to identify such cases and pass the
|
|
||||||
/// appropriate register in TmpReg.
|
|
||||||
void MipsTargetStreamer::emitLoadWithSymOffset(unsigned Opcode, unsigned DstReg,
|
|
||||||
unsigned BaseReg,
|
|
||||||
MCOperand &HiOperand,
|
|
||||||
MCOperand &LoOperand,
|
|
||||||
unsigned TmpReg, SMLoc IDLoc,
|
|
||||||
const MCSubtargetInfo *STI) {
|
|
||||||
// 1) lw $8, sym => lui $8, %hi(sym)
|
|
||||||
// lw $8, %lo(sym)($8)
|
|
||||||
// 2) ldc1 $f0, sym => lui $at, %hi(sym)
|
|
||||||
// ldc1 $f0, %lo(sym)($at)
|
|
||||||
|
|
||||||
// Generate the base address in TmpReg.
|
|
||||||
emitRX(Mips::LUi, TmpReg, HiOperand, IDLoc, STI);
|
|
||||||
if (BaseReg != Mips::ZERO)
|
|
||||||
emitRRR(Mips::ADDu, TmpReg, TmpReg, BaseReg, IDLoc, STI);
|
|
||||||
// Emit the load with the adjusted base and offset.
|
|
||||||
emitRRX(Opcode, DstReg, TmpReg, LoOperand, IDLoc, STI);
|
|
||||||
}
|
|
||||||
|
|
||||||
MipsTargetAsmStreamer::MipsTargetAsmStreamer(MCStreamer &S,
|
MipsTargetAsmStreamer::MipsTargetAsmStreamer(MCStreamer &S,
|
||||||
formatted_raw_ostream &OS)
|
formatted_raw_ostream &OS)
|
||||||
: MipsTargetStreamer(S), OS(OS) {}
|
: MipsTargetStreamer(S), OS(OS) {}
|
||||||
|
@ -156,10 +156,6 @@ public:
|
|||||||
unsigned BaseReg, int64_t Offset,
|
unsigned BaseReg, int64_t Offset,
|
||||||
function_ref<unsigned()> GetATReg, SMLoc IDLoc,
|
function_ref<unsigned()> GetATReg, SMLoc IDLoc,
|
||||||
const MCSubtargetInfo *STI);
|
const MCSubtargetInfo *STI);
|
||||||
void emitStoreWithSymOffset(unsigned Opcode, unsigned SrcReg,
|
|
||||||
unsigned BaseReg, MCOperand &HiOperand,
|
|
||||||
MCOperand &LoOperand, unsigned ATReg, SMLoc IDLoc,
|
|
||||||
const MCSubtargetInfo *STI);
|
|
||||||
void emitSCWithSymOffset(unsigned Opcode, unsigned SrcReg, unsigned BaseReg,
|
void emitSCWithSymOffset(unsigned Opcode, unsigned SrcReg, unsigned BaseReg,
|
||||||
MCOperand &HiOperand, MCOperand &LoOperand,
|
MCOperand &HiOperand, MCOperand &LoOperand,
|
||||||
unsigned ATReg, SMLoc IDLoc,
|
unsigned ATReg, SMLoc IDLoc,
|
||||||
@ -167,10 +163,6 @@ public:
|
|||||||
void emitLoadWithImmOffset(unsigned Opcode, unsigned DstReg, unsigned BaseReg,
|
void emitLoadWithImmOffset(unsigned Opcode, unsigned DstReg, unsigned BaseReg,
|
||||||
int64_t Offset, unsigned TmpReg, SMLoc IDLoc,
|
int64_t Offset, unsigned TmpReg, SMLoc IDLoc,
|
||||||
const MCSubtargetInfo *STI);
|
const MCSubtargetInfo *STI);
|
||||||
void emitLoadWithSymOffset(unsigned Opcode, unsigned DstReg, unsigned BaseReg,
|
|
||||||
MCOperand &HiOperand, MCOperand &LoOperand,
|
|
||||||
unsigned ATReg, SMLoc IDLoc,
|
|
||||||
const MCSubtargetInfo *STI);
|
|
||||||
void emitGPRestore(int Offset, SMLoc IDLoc, const MCSubtargetInfo *STI);
|
void emitGPRestore(int Offset, SMLoc IDLoc, const MCSubtargetInfo *STI);
|
||||||
|
|
||||||
void forbidModuleDirective() { ModuleDirectiveAllowed = false; }
|
void forbidModuleDirective() { ModuleDirectiveAllowed = false; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user