ef736a1c39
There's a few relevant forward declarations in there that may require downstream adding explicit includes: llvm/MC/MCContext.h no longer includes llvm/BinaryFormat/ELF.h, llvm/MC/MCSubtargetInfo.h, llvm/MC/MCTargetOptions.h llvm/MC/MCObjectStreamer.h no longer include llvm/MC/MCAssembler.h llvm/MC/MCAssembler.h no longer includes llvm/MC/MCFixup.h, llvm/MC/MCFragment.h Counting preprocessed lines required to rebuild llvm-project on my setup: before: 1052436830 after: 1049293745 Which is significant and backs up the change in addition to the usual benefits of decreasing coupling between headers and compilation units. Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D119244
54 lines
1.9 KiB
C++
54 lines
1.9 KiB
C++
//===------ llvm/MC/MCInstrDesc.cpp- Instruction Descriptors --------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines methods on the MCOperandInfo and MCInstrDesc classes, which
|
|
// are used to describe target instructions and their operands.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/MC/MCInstrDesc.h"
|
|
#include "llvm/MC/MCInst.h"
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
|
|
|
using namespace llvm;
|
|
|
|
bool MCInstrDesc::mayAffectControlFlow(const MCInst &MI,
|
|
const MCRegisterInfo &RI) const {
|
|
if (isBranch() || isCall() || isReturn() || isIndirectBranch())
|
|
return true;
|
|
unsigned PC = RI.getProgramCounter();
|
|
if (PC == 0)
|
|
return false;
|
|
if (hasDefOfPhysReg(MI, PC, RI))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
bool MCInstrDesc::hasImplicitDefOfPhysReg(unsigned Reg,
|
|
const MCRegisterInfo *MRI) const {
|
|
if (const MCPhysReg *ImpDefs = ImplicitDefs)
|
|
for (; *ImpDefs; ++ImpDefs)
|
|
if (*ImpDefs == Reg || (MRI && MRI->isSubRegister(Reg, *ImpDefs)))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
bool MCInstrDesc::hasDefOfPhysReg(const MCInst &MI, unsigned Reg,
|
|
const MCRegisterInfo &RI) const {
|
|
for (int i = 0, e = NumDefs; i != e; ++i)
|
|
if (MI.getOperand(i).isReg() &&
|
|
RI.isSubRegisterEq(Reg, MI.getOperand(i).getReg()))
|
|
return true;
|
|
if (variadicOpsAreDefs())
|
|
for (int i = NumOperands - 1, e = MI.getNumOperands(); i != e; ++i)
|
|
if (MI.getOperand(i).isReg() &&
|
|
RI.isSubRegisterEq(Reg, MI.getOperand(i).getReg()))
|
|
return true;
|
|
return hasImplicitDefOfPhysReg(Reg, &RI);
|
|
}
|