本文整理汇总了C++中machinebasicblock::const_instr_iterator类的典型用法代码示例。如果您正苦于以下问题:C++ const_instr_iterator类的具体用法?C++ const_instr_iterator怎么用?C++ const_instr_iterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了const_instr_iterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EmitInstruction
void EpiphanyAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// Do any auto-generated pseudo lowerings.
if (emitPseudoExpansionLowering(*OutStreamer, MI))
return;
switch (MI->getOpcode()) {
case Epiphany::DBG_VALUE: {
if (isVerbose() && OutStreamer->hasRawTextSupport()) {
SmallString<128> TmpStr;
raw_svector_ostream OS(TmpStr);
PrintDebugValueComment(MI, OS);
OutStreamer->EmitRawText(StringRef(OS.str()));
}
return;
}
case Epiphany::MOVT32ri: {
EmitToStreamer(*OutStreamer, MCInstBuilder(Epiphany::MOVT32ri)
.addReg(MI->getOperand(0).getReg())
.addReg(MI->getOperand(0).getReg())
.addImm(MI->getOperand(1).getImm()));
return;
}
}
// Generic way
MachineBasicBlock::const_instr_iterator I = MI;
MachineBasicBlock::const_instr_iterator E = MI->getParent()->instr_end();
do {
MCInst TmpInst;
MCInstLowering.Lower(I, TmpInst);
EmitToStreamer(*OutStreamer, TmpInst);
} while ((++I != E) && I->isInsideBundle());
}
示例2: EmitInstruction
void AMDGPUAsmPrinter::EmitInstruction(const MachineInstr *MI) {
AMDGPUMCInstLower MCInstLowering;
// Ignore placeholder instructions:
if (MI->getOpcode() == AMDGPU::MASK_WRITE) {
return;
}
if (MI->isBundle()) {
const MachineBasicBlock *MBB = MI->getParent();
MachineBasicBlock::const_instr_iterator I = MI;
++I;
while (I != MBB->end() && I->isInsideBundle()) {
MCInst MCBundleInst;
const MachineInstr *BundledInst = I;
MCInstLowering.lower(BundledInst, MCBundleInst);
OutStreamer.EmitInstruction(MCBundleInst);
++I;
}
} else {
MCInst TmpInst;
MCInstLowering.lower(MI, TmpInst);
OutStreamer.EmitInstruction(TmpInst);
}
}
示例3: EmitInstruction
void AMDGPUAsmPrinter::EmitInstruction(const MachineInstr *MI) {
const AMDGPUSubtarget &STI = MF->getSubtarget<AMDGPUSubtarget>();
AMDGPUMCInstLower MCInstLowering(OutContext, STI);
#ifdef _DEBUG
StringRef Err;
if (!STI.getInstrInfo()->verifyInstruction(MI, Err)) {
errs() << "Warning: Illegal instruction detected: " << Err << "\n";
MI->dump();
}
#endif
if (MI->isBundle()) {
const MachineBasicBlock *MBB = MI->getParent();
MachineBasicBlock::const_instr_iterator I = MI;
++I;
while (I != MBB->end() && I->isInsideBundle()) {
EmitInstruction(I);
++I;
}
} else {
MCInst TmpInst;
MCInstLowering.lower(MI, TmpInst);
EmitToStreamer(OutStreamer, TmpInst);
if (STI.dumpCode()) {
// Disassemble instruction/operands to text.
DisasmLines.resize(DisasmLines.size() + 1);
std::string &DisasmLine = DisasmLines.back();
raw_string_ostream DisasmStream(DisasmLine);
AMDGPUInstPrinter InstPrinter(*TM.getMCAsmInfo(),
*MF->getSubtarget().getInstrInfo(),
*MF->getSubtarget().getRegisterInfo());
InstPrinter.printInst(&TmpInst, DisasmStream, StringRef());
// Disassemble instruction/operands to hex representation.
SmallVector<MCFixup, 4> Fixups;
SmallVector<char, 16> CodeBytes;
raw_svector_ostream CodeStream(CodeBytes);
MCObjectStreamer &ObjStreamer = (MCObjectStreamer &)OutStreamer;
MCCodeEmitter &InstEmitter = ObjStreamer.getAssembler().getEmitter();
InstEmitter.EncodeInstruction(TmpInst, CodeStream, Fixups,
MF->getSubtarget<MCSubtargetInfo>());
CodeStream.flush();
HexLines.resize(HexLines.size() + 1);
std::string &HexLine = HexLines.back();
raw_string_ostream HexStream(HexLine);
for (size_t i = 0; i < CodeBytes.size(); i += 4) {
unsigned int CodeDWord = *(unsigned int *)&CodeBytes[i];
HexStream << format("%s%08X", (i > 0 ? " " : ""), CodeDWord);
}
DisasmStream.flush();
DisasmLineMaxLen = std::max(DisasmLineMaxLen, DisasmLine.size());
}
}
}
示例4: if
const Function *PatmosInstrInfo::getCallee(const MachineInstr *MI) const
{
const Function *F = NULL;
if (MI->isBundle()) {
MachineBasicBlock::const_instr_iterator it = MI;
while ((++it)->isBundledWithPred()) {
if (!it->isCall()) continue;
if (F) return NULL;
F = getCallee(it);
if (!F) return NULL;
}
return F;
}
// get target
const MachineOperand &MO(MI->getOperand(2));
// try to find the target of the call
if (MO.isGlobal()) {
// is the global value a function?
F = dyn_cast<Function>(MO.getGlobal());
}
else if (MO.isSymbol()) {
// find the function in the current module
const Module &M = *MI->getParent()->getParent()->getFunction()->getParent();
F = dyn_cast_or_null<Function>(M.getNamedValue(MO.getSymbolName()));
}
return F;
}
示例5: getInstrSize
unsigned int PatmosInstrInfo::getInstrSize(const MachineInstr *MI) const {
if (MI->isInlineAsm()) {
// TODO is there a way to get the current context?
MCContext Ctx(PTM.getMCAsmInfo(),
PTM.getRegisterInfo(), PTM.getInstrInfo(), 0);
// PIA is deleted by AsmPrinter
PatmosInstrAnalyzer *PIA = createPatmosInstrAnalyzer(Ctx);
PatmosAsmPrinter PAP(PTM, *PIA);
PAP.EmitInlineAsm(MI);
return PIA->getSize();
}
else if (MI->isBundle()) {
const MachineBasicBlock *MBB = MI->getParent();
MachineBasicBlock::const_instr_iterator I = MI, E = MBB->instr_end();
unsigned Size = 0;
while ((++I != E) && I->isInsideBundle()) {
Size += getInstrSize(I);
}
return Size;
}
else if (MI->isPseudo()) {
return 0;
}
else {
// trust the desc..
return MI->getDesc().getSize();
}
}
示例6: EmitInstruction
/// printMachineInstruction -- Print out a single Hexagon MI in Darwin syntax to
/// the current output stream.
///
void HexagonAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCInst MCB = HexagonMCInstrInfo::createBundle();
const MCInstrInfo &MCII = *Subtarget->getInstrInfo();
if (MI->isBundle()) {
const MachineBasicBlock* MBB = MI->getParent();
MachineBasicBlock::const_instr_iterator MII = MI->getIterator();
unsigned IgnoreCount = 0;
for (++MII; MII != MBB->instr_end() && MII->isInsideBundle(); ++MII)
if (MII->getOpcode() == TargetOpcode::DBG_VALUE ||
MII->getOpcode() == TargetOpcode::IMPLICIT_DEF)
++IgnoreCount;
else
HexagonLowerToMC(MCII, &*MII, MCB, *this);
}
else
HexagonLowerToMC(MCII, MI, MCB, *this);
bool Ok = HexagonMCInstrInfo::canonicalizePacket(
MCII, *Subtarget, OutStreamer->getContext(), MCB, nullptr);
assert(Ok);
(void)Ok;
if(HexagonMCInstrInfo::bundleSize(MCB) == 0)
return;
OutStreamer->EmitInstruction(MCB, getSubtargetInfo());
}
示例7: isPseudo
bool PatmosInstrInfo::isPseudo(const MachineInstr *MI) const {
if (MI->isBundle()) {
MachineBasicBlock::const_instr_iterator II = MI; ++II;
const MachineBasicBlock *MBB = MI->getParent();
while (II != MBB->instr_end() && II->isBundledWithPred()) {
if (!isPseudo(II)) return false;
II++;
}
return true;
}
if (MI->isDebugValue())
return true;
// We must emit inline assembly
if (MI->isInlineAsm())
return false;
// We check if MI has any functional units mapped to it.
// If it doesn't, we ignore the instruction.
const MCInstrDesc& TID = MI->getDesc();
unsigned SchedClass = TID.getSchedClass();
const InstrStage* IS = PST.getInstrItineraryData().beginStage(SchedClass);
unsigned FuncUnits = IS->getUnits();
return !FuncUnits;
}
示例8: getMemType
PatmosII::MemType PatmosInstrInfo::getMemType(const MachineInstr *MI) const {
assert(MI->mayLoad() || MI->mayStore());
if (MI->isBundle()) {
// find mem instruction in bundle (does not need to be the first
// instruction, they might be sorted later!)
MachineBasicBlock::const_instr_iterator II = MI; ++II;
while (II->isInsideBundle() && !II->mayLoad() && !II->mayStore()) {
++II;
}
return getMemType(II);
}
// FIXME: Maybe there is a better way to get this info directly from
// the instruction definitions in the .td files
using namespace Patmos;
unsigned opc = MI->getOpcode();
switch (opc) {
case LWS: case LHS: case LBS: case LHUS: case LBUS:
case SWS: case SHS: case SBS:
return PatmosII::MEM_S;
case LWL: case LHL: case LBL: case LHUL: case LBUL:
case SWL: case SHL: case SBL:
return PatmosII::MEM_L;
case LWC: case LHC: case LBC: case LHUC: case LBUC:
case SWC: case SHC: case SBC:
return PatmosII::MEM_C;
case LWM: case LHM: case LBM: case LHUM: case LBUM:
case SWM: case SHM: case SBM:
return PatmosII::MEM_M;
default: llvm_unreachable("Unexpected memory access instruction!");
}
}
示例9: getCallees
bool PatmosInstrInfo::getCallees(const MachineInstr *MI,
SmallSet<const Function*,2> &Callees) const
{
if (MI->isBundle()) {
MachineBasicBlock::const_instr_iterator it = MI;
bool safe = true;
while ((++it)->isBundledWithPred()) {
if (!it->isCall() && !it->isInlineAsm()) continue;
safe = getCallees(it, Callees) && safe;
}
return safe;
}
if (MI->isCall()) {
const Function *F = getCallee(MI);
if (F) {
Callees.insert(F);
return true;
} else {
// Could be an indirect call..
return false;
}
}
else if (MI->isInlineAsm()) {
// We can skip the first operand as this should be the asm string.
for (unsigned int i = 1; i < MI->getNumOperands(); i++) {
const MachineOperand &MO(MI->getOperand(i));
const Function *F = NULL;
// try to find the target of the call
if (MO.isGlobal()) {
// is the global value a function?
F = dyn_cast_or_null<Function>(MO.getGlobal());
}
else if (MO.isSymbol()) {
// find the function in the current module
const Module &M =
*MI->getParent()->getParent()->getFunction()->getParent();
F = dyn_cast_or_null<Function>(M.getNamedValue(MO.getSymbolName()));
}
if (F) {
// We are assuming here that if inline-asm uses a function reference
// as operand, then it is probably used for a call.
Callees.insert(F);
}
}
// TODO for now we assume that inline asm does not contain CALLR and
// that all callees are passed as asm operands. We should do a check
// similar to hasCall() here.
return true;
}
else {
// No other instruction should do a call.
return true;
}
}
示例10: customEmitInstruction
void OR1KAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MachineBasicBlock::const_instr_iterator I = MI;
MachineBasicBlock::const_instr_iterator E = MI->getParent()->instr_end();
do {
customEmitInstruction(I++);
} while ((I != E) && I->isInsideBundle());
}
示例11: while
unsigned AArch64InstrInfo::getInstBundleLength(const MachineInstr &MI) const {
unsigned Size = 0;
MachineBasicBlock::const_instr_iterator I = MI;
MachineBasicBlock::const_instr_iterator E = MI.getParent()->instr_end();
while (++I != E && I->isInsideBundle()) {
assert(!I->isBundle() && "No nested bundle!");
Size += getInstSizeInBytes(*I);
}
return Size;
}
示例12: EmitInstruction
void NyuziAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MachineBasicBlock::const_instr_iterator I = MI->getIterator();
MachineBasicBlock::const_instr_iterator E = MI->getParent()->instr_end();
do {
MCInst TmpInst;
MCInstLowering.Lower(MI, TmpInst);
EmitToStreamer(*OutStreamer, TmpInst);
if (MI->getOpcode() == Nyuzi::JUMP_TABLE) {
EmitInlineJumpTable(MI);
}
} while ((I != E) && I->isInsideBundle());
}
示例13: EmitInstruction
void LanaiAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MachineBasicBlock::const_instr_iterator I = MI->getIterator();
MachineBasicBlock::const_instr_iterator E = MI->getParent()->instr_end();
do {
if (I->isCall()) {
emitCallInstruction(&*I);
continue;
}
customEmitInstruction(&*I);
} while ((++I != E) && I->isInsideBundle());
}
示例14: EmitInstruction
void AMDGPUAsmPrinter::EmitInstruction(const MachineInstr *MI) {
AMDGPUMCInstLower MCInstLowering(OutContext);
if (MI->isBundle()) {
const MachineBasicBlock *MBB = MI->getParent();
MachineBasicBlock::const_instr_iterator I = MI;
++I;
while (I != MBB->end() && I->isInsideBundle()) {
EmitInstruction(I);
++I;
}
} else {
MCInst TmpInst;
MCInstLowering.lower(MI, TmpInst);
OutStreamer.EmitInstruction(TmpInst);
if (DisasmEnabled) {
// Disassemble instruction/operands to text.
DisasmLines.resize(DisasmLines.size() + 1);
std::string &DisasmLine = DisasmLines.back();
raw_string_ostream DisasmStream(DisasmLine);
AMDGPUInstPrinter InstPrinter(*TM.getMCAsmInfo(), *TM.getInstrInfo(),
*TM.getRegisterInfo());
InstPrinter.printInst(&TmpInst, DisasmStream, StringRef());
// Disassemble instruction/operands to hex representation.
SmallVector<MCFixup, 4> Fixups;
SmallVector<char, 16> CodeBytes;
raw_svector_ostream CodeStream(CodeBytes);
MCObjectStreamer &ObjStreamer = (MCObjectStreamer &)OutStreamer;
MCCodeEmitter &InstEmitter = ObjStreamer.getAssembler().getEmitter();
InstEmitter.EncodeInstruction(TmpInst, CodeStream, Fixups);
CodeStream.flush();
HexLines.resize(HexLines.size() + 1);
std::string &HexLine = HexLines.back();
raw_string_ostream HexStream(HexLine);
for (size_t i = 0; i < CodeBytes.size(); i += 4) {
unsigned int CodeDWord = *(unsigned int *)&CodeBytes[i];
HexStream << format("%s%08X", (i > 0 ? " " : ""), CodeDWord);
}
DisasmStream.flush();
DisasmLineMaxLen = std::max(DisasmLineMaxLen, DisasmLine.size());
}
}
}
示例15: EmitInstruction
void PatmosAsmPrinter::EmitInstruction(const MachineInstr *MI) {
SmallVector<const MachineInstr*, 2> BundleMIs;
unsigned Size = 1;
// Unpack BUNDLE instructions
if (MI->isBundle()) {
const MachineBasicBlock *MBB = MI->getParent();
MachineBasicBlock::const_instr_iterator MII = MI;
++MII;
while (MII != MBB->end() && MII->isInsideBundle()) {
const MachineInstr *MInst = MII;
if (MInst->isPseudo()) {
// DBG_VALUE and IMPLICIT_DEFs outside of bundles are handled in
// AsmPrinter::EmitFunctionBody()
MInst->dump();
report_fatal_error("Pseudo instructions must not be bundled!");
}
BundleMIs.push_back(MInst);
++MII;
}
Size = BundleMIs.size();
assert(Size == MI->getBundleSize() && "Corrupt Bundle!");
}
else {
if (MI->getOpcode() == Patmos::PSEUDO_LOOPBOUND) {
int LoopBoundMin = MI->getOperand(0).getImm();
int LoopBoundMax = MI->getOperand(1).getImm();
OutStreamer.GetCommentOS() << "Loop bound: ["
<< LoopBoundMin << ", " << LoopBoundMax << "]\n";
return;
}
BundleMIs.push_back(MI);
}
// Emit all instructions in the bundle.
for (unsigned Index = 0; Index < Size; Index++) {
MCInst MCI;
MCInstLowering.Lower(BundleMIs[Index], MCI);
// Set bundle marker
bool isBundled = (Index < Size - 1);
MCI.addOperand(MCOperand::CreateImm(isBundled));
OutStreamer.EmitInstruction(MCI);
}
}