2011-08-08 18:56:44 +00:00
|
|
|
//===-- llvm/MC/MCInstrAnalysis.h - InstrDesc target hooks ------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the MCInstrAnalysis class which the MCTargetDescs can
|
|
|
|
// derive from to give additional information to MC.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/MC/MCInst.h"
|
|
|
|
#include "llvm/MC/MCInstrDesc.h"
|
|
|
|
#include "llvm/MC/MCInstrInfo.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class MCInstrAnalysis {
|
|
|
|
protected:
|
|
|
|
friend class Target;
|
|
|
|
const MCInstrInfo *Info;
|
|
|
|
|
|
|
|
public:
|
2011-08-23 20:15:21 +00:00
|
|
|
MCInstrAnalysis(const MCInstrInfo *Info) : Info(Info) {}
|
|
|
|
|
2011-08-08 19:09:02 +00:00
|
|
|
virtual ~MCInstrAnalysis() {}
|
|
|
|
|
2011-08-08 18:56:44 +00:00
|
|
|
virtual bool isBranch(const MCInst &Inst) const {
|
|
|
|
return Info->get(Inst.getOpcode()).isBranch();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isConditionalBranch(const MCInst &Inst) const {
|
2011-10-17 21:21:44 +00:00
|
|
|
return Info->get(Inst.getOpcode()).isConditionalBranch();
|
2011-08-08 18:56:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isUnconditionalBranch(const MCInst &Inst) const {
|
|
|
|
return Info->get(Inst.getOpcode()).isUnconditionalBranch();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isIndirectBranch(const MCInst &Inst) const {
|
|
|
|
return Info->get(Inst.getOpcode()).isIndirectBranch();
|
|
|
|
}
|
|
|
|
|
2011-08-22 23:41:41 +00:00
|
|
|
virtual bool isCall(const MCInst &Inst) const {
|
|
|
|
return Info->get(Inst.getOpcode()).isCall();
|
|
|
|
}
|
|
|
|
|
2011-08-08 18:56:44 +00:00
|
|
|
virtual bool isReturn(const MCInst &Inst) const {
|
|
|
|
return Info->get(Inst.getOpcode()).isReturn();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// evaluateBranch - Given a branch instruction try to get the address the
|
|
|
|
/// branch targets. Otherwise return -1.
|
|
|
|
virtual uint64_t
|
|
|
|
evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|