1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

Change void getNoop(MCInst &NopInst) to MCInst getNop()

Prefer (self-documenting) return values to output parameters (which are
liable to be used).
While here, rename Noop to Nop which is more widely used and improves
consistency with hasEmitNops/setEmitNops/emitNop/etc.
This commit is contained in:
Fangrui Song 2021-03-15 12:05:33 -07:00
parent bea426ec19
commit 0fdd473f7e
16 changed files with 36 additions and 36 deletions

View File

@ -1395,7 +1395,7 @@ public:
unsigned Quantity) const;
/// Return the noop instruction to use for a noop.
virtual void getNoop(MCInst &NopInst) const;
virtual MCInst getNop() const;
/// Return true for post-incremented instructions.
virtual bool isPostIncrement(const MachineInstr &MI) const { return false; }

View File

@ -1363,8 +1363,7 @@ void AsmPrinter::emitFunctionBody() {
const Triple &TT = TM.getTargetTriple();
if (!HasAnyRealCode && (MAI->hasSubsectionsViaSymbols() ||
(TT.isOSWindows() && TT.isOSBinFormatCOFF()))) {
MCInst Noop;
MF->getSubtarget().getInstrInfo()->getNoop(Noop);
MCInst Noop = MF->getSubtarget().getInstrInfo()->getNop();
// Targets can opt-out of emitting the noop here by leaving the opcode
// unspecified.
@ -3003,8 +3002,7 @@ void AsmPrinter::printOffset(int64_t Offset, raw_ostream &OS) const {
}
void AsmPrinter::emitNops(unsigned N) {
MCInst Nop;
MF->getSubtarget().getInstrInfo()->getNoop(Nop);
MCInst Nop = MF->getSubtarget().getInstrInfo()->getNop();
for (; N; --N)
EmitToStreamer(*OutStreamer, Nop);
}

View File

@ -309,10 +309,9 @@ static bool avoidZeroOffsetLandingPad(MachineFunction &MF) {
MachineBasicBlock::iterator MI = MBB.begin();
while (!MI->isEHLabel())
++MI;
MCInst Noop;
MF.getSubtarget().getInstrInfo()->getNoop(Noop);
MCInst Nop = MF.getSubtarget().getInstrInfo()->getNop();
BuildMI(MBB, MI, DebugLoc(),
MF.getSubtarget().getInstrInfo()->get(Noop.getOpcode()));
MF.getSubtarget().getInstrInfo()->get(Nop.getOpcode()));
return false;
}
}

View File

@ -472,9 +472,7 @@ static const TargetRegisterClass *canFoldCopy(const MachineInstr &MI,
return nullptr;
}
void TargetInstrInfo::getNoop(MCInst &NopInst) const {
llvm_unreachable("Not implemented");
}
MCInst TargetInstrInfo::getNop() const { llvm_unreachable("Not implemented"); }
static MachineInstr *foldPatchpoint(MachineFunction &MF, MachineInstr &MI,
ArrayRef<unsigned> Ops, int FrameIndex,

View File

@ -35,6 +35,7 @@
#include "llvm/IR/GlobalValue.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstBuilder.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CodeGen.h"
@ -4054,9 +4055,8 @@ bool llvm::rewriteAArch64FrameIndex(MachineInstr &MI, unsigned FrameRegIdx,
return false;
}
void AArch64InstrInfo::getNoop(MCInst &NopInst) const {
NopInst.setOpcode(AArch64::HINT);
NopInst.addOperand(MCOperand::createImm(0));
MCInst AArch64InstrInfo::getNop() const {
return MCInstBuilder(AArch64::HINT).addImm(0);
}
// AArch64 supports MachineCombiner.

View File

@ -209,7 +209,7 @@ public:
const DebugLoc &DL, Register DstReg,
ArrayRef<MachineOperand> Cond, Register TrueReg,
Register FalseReg) const override;
void getNoop(MCInst &NopInst) const override;
MCInst getNop() const override;
bool isSchedulingBoundary(const MachineInstr &MI,
const MachineBasicBlock *MBB,

View File

@ -32,7 +32,8 @@ ARMInstrInfo::ARMInstrInfo(const ARMSubtarget &STI)
: ARMBaseInstrInfo(STI), RI() {}
/// Return the noop instruction to use for a noop.
void ARMInstrInfo::getNoop(MCInst &NopInst) const {
MCInst ARMInstrInfo::getNop() const {
MCInst NopInst;
if (hasNOP()) {
NopInst.setOpcode(ARM::HINT);
NopInst.addOperand(MCOperand::createImm(0));
@ -46,6 +47,7 @@ void ARMInstrInfo::getNoop(MCInst &NopInst) const {
NopInst.addOperand(MCOperand::createReg(0));
NopInst.addOperand(MCOperand::createReg(0));
}
return NopInst;
}
unsigned ARMInstrInfo::getUnindexedOpcode(unsigned Opc) const {

View File

@ -25,7 +25,7 @@ public:
explicit ARMInstrInfo(const ARMSubtarget &STI);
/// Return the noop instruction to use for a noop.
void getNoop(MCInst &NopInst) const override;
MCInst getNop() const override;
// Return the non-pre/post incrementing version of 'Opc'. Return 0
// if there is not such an opcode.

View File

@ -16,6 +16,7 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstBuilder.h"
using namespace llvm;
@ -23,12 +24,12 @@ Thumb1InstrInfo::Thumb1InstrInfo(const ARMSubtarget &STI)
: ARMBaseInstrInfo(STI), RI() {}
/// Return the noop instruction to use for a noop.
void Thumb1InstrInfo::getNoop(MCInst &NopInst) const {
NopInst.setOpcode(ARM::tMOVr);
NopInst.addOperand(MCOperand::createReg(ARM::R8));
NopInst.addOperand(MCOperand::createReg(ARM::R8));
NopInst.addOperand(MCOperand::createImm(ARMCC::AL));
NopInst.addOperand(MCOperand::createReg(0));
MCInst Thumb1InstrInfo::getNop() const {
return MCInstBuilder(ARM::tMOVr)
.addReg(ARM::R8)
.addReg(ARM::R8)
.addImm(ARMCC::AL)
.addReg(0);
}
unsigned Thumb1InstrInfo::getUnindexedOpcode(unsigned Opc) const {

View File

@ -25,7 +25,7 @@ public:
explicit Thumb1InstrInfo(const ARMSubtarget &STI);
/// Return the noop instruction to use for a noop.
void getNoop(MCInst &NopInst) const override;
MCInst getNop() const override;
// Return the non-pre/post incrementing version of 'Opc'. Return 0
// if there is not such an opcode.

View File

@ -25,6 +25,7 @@
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstBuilder.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
@ -48,11 +49,8 @@ Thumb2InstrInfo::Thumb2InstrInfo(const ARMSubtarget &STI)
: ARMBaseInstrInfo(STI) {}
/// Return the noop instruction to use for a noop.
void Thumb2InstrInfo::getNoop(MCInst &NopInst) const {
NopInst.setOpcode(ARM::tHINT);
NopInst.addOperand(MCOperand::createImm(0));
NopInst.addOperand(MCOperand::createImm(ARMCC::AL));
NopInst.addOperand(MCOperand::createReg(0));
MCInst Thumb2InstrInfo::getNop() const {
return MCInstBuilder(ARM::tHINT).addImm(0).addImm(ARMCC::AL).addReg(0);
}
unsigned Thumb2InstrInfo::getUnindexedOpcode(unsigned Opc) const {

View File

@ -26,7 +26,7 @@ public:
explicit Thumb2InstrInfo(const ARMSubtarget &STI);
/// Return the noop instruction to use for a noop.
void getNoop(MCInst &NopInst) const override;
MCInst getNop() const override;
// Return the non-pre/post incrementing version of 'Opc'. Return 0
// if there is not such an opcode.

View File

@ -1258,8 +1258,10 @@ void PPCInstrInfo::insertNoop(MachineBasicBlock &MBB,
}
/// Return the noop instruction to use for a noop.
void PPCInstrInfo::getNoop(MCInst &NopInst) const {
NopInst.setOpcode(PPC::NOP);
MCInst PPCInstrInfo::getNop() const {
MCInst Nop;
Nop.setOpcode(PPC::NOP);
return Nop;
}
// Branch analysis.

View File

@ -559,7 +559,7 @@ public:
///
unsigned getInstSizeInBytes(const MachineInstr &MI) const override;
void getNoop(MCInst &NopInst) const override;
MCInst getNop() const override;
std::pair<unsigned, unsigned>
decomposeMachineOperandsTargetFlags(unsigned TF) const override;

View File

@ -7709,8 +7709,10 @@ void X86InstrInfo::setExecutionDomain(MachineInstr &MI, unsigned Domain) const {
}
/// Return the noop instruction to use for a noop.
void X86InstrInfo::getNoop(MCInst &NopInst) const {
NopInst.setOpcode(X86::NOOP);
MCInst X86InstrInfo::getNop() const {
MCInst Nop;
Nop.setOpcode(X86::NOOP);
return Nop;
}
bool X86InstrInfo::isHighLatencyDef(int opc) const {

View File

@ -439,7 +439,7 @@ public:
int64_t Offset2,
unsigned NumLoads) const override;
void getNoop(MCInst &NopInst) const override;
MCInst getNop() const override;
bool
reverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const override;