forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MCInstrAnalysis class. This allows the targets to specify own ver…
…sions of MCInstrDescs functions. - Add overrides for ARM. - Teach llvm-objdump to use this instead of plain MCInstrDesc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137059 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
7 changed files
with
176 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//===-- 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; | ||
|
||
MCInstrAnalysis(const MCInstrInfo *Info) : Info(Info) {} | ||
public: | ||
virtual bool isBranch(const MCInst &Inst) const { | ||
return Info->get(Inst.getOpcode()).isBranch(); | ||
} | ||
|
||
virtual bool isConditionalBranch(const MCInst &Inst) const { | ||
return Info->get(Inst.getOpcode()).isBranch(); | ||
} | ||
|
||
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(); | ||
} | ||
|
||
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; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===-- MCInstrAnalysis.cpp - 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. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "llvm/MC/MCInstrAnalysis.h" | ||
using namespace llvm; | ||
|
||
uint64_t MCInstrAnalysis::evaluateBranch(const MCInst &Inst, uint64_t Addr, | ||
uint64_t Size) const { | ||
if (Info->get(Inst.getOpcode()).OpInfo[0].OperandType != MCOI::OPERAND_PCREL) | ||
return -1ULL; | ||
|
||
int64_t Imm = Inst.getOperand(0).getImm(); | ||
return Addr+Size+Imm; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters