mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-24 15:12:36 +00:00
[Hexagon] Moving more functions off of HexagonMCInst and in to HexagonMCInstrInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229903 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b7e0193c4d
commit
f45c1a4d12
@ -64,132 +64,3 @@ void HexagonMCInst::resetPacket() {
|
||||
setPacketBegin(false);
|
||||
setPacketEnd(false);
|
||||
}
|
||||
|
||||
// Return the Hexagon ISA class for the insn.
|
||||
unsigned HexagonMCInst::getType() const {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(*MCII, *this).TSFlags;
|
||||
|
||||
return ((F >> HexagonII::TypePos) & HexagonII::TypeMask);
|
||||
}
|
||||
|
||||
// Return whether the insn is an actual insn.
|
||||
bool HexagonMCInst::isCanon() const {
|
||||
return (!HexagonMCInstrInfo::getDesc(*MCII, *this).isPseudo() &&
|
||||
!isPrefix() && getType() != HexagonII::TypeENDLOOP);
|
||||
}
|
||||
|
||||
// Return whether the insn is a prefix.
|
||||
bool HexagonMCInst::isPrefix() const {
|
||||
return (getType() == HexagonII::TypePREFIX);
|
||||
}
|
||||
|
||||
// Return whether the insn is solo, i.e., cannot be in a packet.
|
||||
bool HexagonMCInst::isSolo() const {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(*MCII, *this).TSFlags;
|
||||
return ((F >> HexagonII::SoloPos) & HexagonII::SoloMask);
|
||||
}
|
||||
|
||||
// Return whether the insn is a new-value consumer.
|
||||
bool HexagonMCInst::isNewValue() const {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(*MCII, *this).TSFlags;
|
||||
return ((F >> HexagonII::NewValuePos) & HexagonII::NewValueMask);
|
||||
}
|
||||
|
||||
// Return whether the instruction is a legal new-value producer.
|
||||
bool HexagonMCInst::hasNewValue() const {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(*MCII, *this).TSFlags;
|
||||
return ((F >> HexagonII::hasNewValuePos) & HexagonII::hasNewValueMask);
|
||||
}
|
||||
|
||||
// Return the operand that consumes or produces a new value.
|
||||
const MCOperand &HexagonMCInst::getNewValue() const {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(*MCII, *this).TSFlags;
|
||||
const unsigned O =
|
||||
(F >> HexagonII::NewValueOpPos) & HexagonII::NewValueOpMask;
|
||||
const MCOperand &MCO = getOperand(O);
|
||||
|
||||
assert((isNewValue() || hasNewValue()) && MCO.isReg());
|
||||
return (MCO);
|
||||
}
|
||||
|
||||
// Return whether the instruction needs to be constant extended.
|
||||
// 1) Always return true if the instruction has 'isExtended' flag set.
|
||||
//
|
||||
// isExtendable:
|
||||
// 2) For immediate extended operands, return true only if the value is
|
||||
// out-of-range.
|
||||
// 3) For global address, always return true.
|
||||
|
||||
bool HexagonMCInst::isConstExtended(void) const {
|
||||
if (isExtended())
|
||||
return true;
|
||||
|
||||
if (!isExtendable())
|
||||
return false;
|
||||
|
||||
short ExtOpNum = getCExtOpNum();
|
||||
int MinValue = getMinValue();
|
||||
int MaxValue = HexagonMCInstrInfo::getMaxValue(*MCII, *this);
|
||||
const MCOperand &MO = getOperand(ExtOpNum);
|
||||
|
||||
// We could be using an instruction with an extendable immediate and shoehorn
|
||||
// a global address into it. If it is a global address it will be constant
|
||||
// extended. We do this for COMBINE.
|
||||
// We currently only handle isGlobal() because it is the only kind of
|
||||
// object we are going to end up with here for now.
|
||||
// In the future we probably should add isSymbol(), etc.
|
||||
if (MO.isExpr())
|
||||
return true;
|
||||
|
||||
// If the extendable operand is not 'Immediate' type, the instruction should
|
||||
// have 'isExtended' flag set.
|
||||
assert(MO.isImm() && "Extendable operand must be Immediate type");
|
||||
|
||||
int ImmValue = MO.getImm();
|
||||
return (ImmValue < MinValue || ImmValue > MaxValue);
|
||||
}
|
||||
|
||||
// Return whether the instruction must be always extended.
|
||||
bool HexagonMCInst::isExtended(void) const {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(*MCII, *this).TSFlags;
|
||||
return (F >> HexagonII::ExtendedPos) & HexagonII::ExtendedMask;
|
||||
}
|
||||
|
||||
// Return true if the instruction may be extended based on the operand value.
|
||||
bool HexagonMCInst::isExtendable(void) const {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(*MCII, *this).TSFlags;
|
||||
return (F >> HexagonII::ExtendablePos) & HexagonII::ExtendableMask;
|
||||
}
|
||||
|
||||
// Return number of bits in the constant extended operand.
|
||||
unsigned HexagonMCInst::getBitCount(void) const {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(*MCII, *this).TSFlags;
|
||||
return ((F >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask);
|
||||
}
|
||||
|
||||
// Return constant extended operand number.
|
||||
unsigned short HexagonMCInst::getCExtOpNum(void) const {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(*MCII, *this).TSFlags;
|
||||
return ((F >> HexagonII::ExtendableOpPos) & HexagonII::ExtendableOpMask);
|
||||
}
|
||||
|
||||
// Return whether the operand can be constant extended.
|
||||
bool HexagonMCInst::isOperandExtended(const unsigned short OperandNum) const {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(*MCII, *this).TSFlags;
|
||||
return ((F >> HexagonII::ExtendableOpPos) & HexagonII::ExtendableOpMask) ==
|
||||
OperandNum;
|
||||
}
|
||||
|
||||
// Return the min value that a constant extendable operand can have
|
||||
// without being extended.
|
||||
int HexagonMCInst::getMinValue(void) const {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(*MCII, *this).TSFlags;
|
||||
unsigned isSigned =
|
||||
(F >> HexagonII::ExtentSignedPos) & HexagonII::ExtentSignedMask;
|
||||
unsigned bits = (F >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask;
|
||||
|
||||
if (isSigned) // if value is signed
|
||||
return -1U << (bits - 1);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -48,50 +48,6 @@ public:
|
||||
bool isPacketEnd() const;
|
||||
static const size_t packetEndIndex = 1;
|
||||
void resetPacket();
|
||||
|
||||
// Return the Hexagon ISA class for the insn.
|
||||
unsigned getType() const;
|
||||
|
||||
// Return whether the insn is an actual insn.
|
||||
bool isCanon() const;
|
||||
|
||||
// Return whether the insn is a prefix.
|
||||
bool isPrefix() const;
|
||||
|
||||
// Return whether the insn is solo, i.e., cannot be in a packet.
|
||||
bool isSolo() const;
|
||||
|
||||
// Return whether the instruction needs to be constant extended.
|
||||
bool isConstExtended() const;
|
||||
|
||||
// Return constant extended operand number.
|
||||
unsigned short getCExtOpNum(void) const;
|
||||
|
||||
// Return whether the insn is a new-value consumer.
|
||||
bool isNewValue() const;
|
||||
|
||||
// Return whether the instruction is a legal new-value producer.
|
||||
bool hasNewValue() const;
|
||||
|
||||
// Return the operand that consumes or produces a new value.
|
||||
const MCOperand &getNewValue() const;
|
||||
|
||||
// Return number of bits in the constant extended operand.
|
||||
unsigned getBitCount(void) const;
|
||||
|
||||
private:
|
||||
// Return whether the instruction must be always extended.
|
||||
bool isExtended() const;
|
||||
|
||||
// Return true if the insn may be extended based on the operand value.
|
||||
bool isExtendable() const;
|
||||
|
||||
// Return true if the operand can be constant extended.
|
||||
bool isOperandExtended(const unsigned short OperandNum) const;
|
||||
|
||||
// Return the min value that a constant extendable operand can have
|
||||
// without being extended.
|
||||
int getMinValue() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -16,15 +16,29 @@
|
||||
#include "llvm/MC/MCInstrInfo.h"
|
||||
|
||||
namespace llvm {
|
||||
unsigned HexagonMCInstrInfo::getBitCount(MCInstrInfo const &MCII,
|
||||
MCInst const &MCI) {
|
||||
uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags;
|
||||
return ((F >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask);
|
||||
}
|
||||
|
||||
MCInstrDesc const &HexagonMCInstrInfo::getDesc(MCInstrInfo const &MCII,
|
||||
MCInst const &MCI) {
|
||||
return (MCII.get(MCI.getOpcode()));
|
||||
}
|
||||
|
||||
// Return constant extended operand number.
|
||||
unsigned short HexagonMCInstrInfo::getCExtOpNum(MCInstrInfo const &MCII,
|
||||
MCInst const &MCI) {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags;
|
||||
return ((F >> HexagonII::ExtendableOpPos) & HexagonII::ExtendableOpMask);
|
||||
}
|
||||
|
||||
// Return the max value that a constant extendable operand can have
|
||||
// without being extended.
|
||||
int HexagonMCInstrInfo::getMaxValue(MCInstrInfo const &MCII,
|
||||
MCInst const &MCI) {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags;
|
||||
uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags;
|
||||
unsigned isSigned =
|
||||
(F >> HexagonII::ExtentSignedPos) & HexagonII::ExtentSignedMask;
|
||||
unsigned bits = (F >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask;
|
||||
@ -34,4 +48,134 @@ int HexagonMCInstrInfo::getMaxValue(MCInstrInfo const &MCII,
|
||||
else
|
||||
return ~(-1U << bits);
|
||||
}
|
||||
|
||||
// Return the min value that a constant extendable operand can have
|
||||
// without being extended.
|
||||
int HexagonMCInstrInfo::getMinValue(MCInstrInfo const &MCII,
|
||||
MCInst const &MCI) {
|
||||
uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags;
|
||||
unsigned isSigned =
|
||||
(F >> HexagonII::ExtentSignedPos) & HexagonII::ExtentSignedMask;
|
||||
unsigned bits = (F >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask;
|
||||
|
||||
if (isSigned) // if value is signed
|
||||
return -1U << (bits - 1);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Return the operand that consumes or produces a new value.
|
||||
MCOperand const &HexagonMCInstrInfo::getNewValue(MCInstrInfo const &MCII,
|
||||
MCInst const &MCI) {
|
||||
uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags;
|
||||
unsigned const O =
|
||||
(F >> HexagonII::NewValueOpPos) & HexagonII::NewValueOpMask;
|
||||
MCOperand const &MCO = MCI.getOperand(O);
|
||||
|
||||
assert((HexagonMCInstrInfo::isNewValue(MCII, MCI) ||
|
||||
HexagonMCInstrInfo::hasNewValue(MCII, MCI)) &&
|
||||
MCO.isReg());
|
||||
return (MCO);
|
||||
}
|
||||
|
||||
// Return the Hexagon ISA class for the insn.
|
||||
unsigned HexagonMCInstrInfo::getType(MCInstrInfo const &MCII,
|
||||
MCInst const &MCI) {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags;
|
||||
|
||||
return ((F >> HexagonII::TypePos) & HexagonII::TypeMask);
|
||||
}
|
||||
|
||||
// Return whether the instruction is a legal new-value producer.
|
||||
bool HexagonMCInstrInfo::hasNewValue(MCInstrInfo const &MCII,
|
||||
MCInst const &MCI) {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags;
|
||||
return ((F >> HexagonII::hasNewValuePos) & HexagonII::hasNewValueMask);
|
||||
}
|
||||
|
||||
// Return whether the insn is an actual insn.
|
||||
bool HexagonMCInstrInfo::isCanon(MCInstrInfo const &MCII, MCInst const &MCI) {
|
||||
return (!HexagonMCInstrInfo::getDesc(MCII, MCI).isPseudo() &&
|
||||
!HexagonMCInstrInfo::isPrefix(MCII, MCI) &&
|
||||
HexagonMCInstrInfo::getType(MCII, MCI) != HexagonII::TypeENDLOOP);
|
||||
}
|
||||
|
||||
// Return whether the instruction needs to be constant extended.
|
||||
// 1) Always return true if the instruction has 'isExtended' flag set.
|
||||
//
|
||||
// isExtendable:
|
||||
// 2) For immediate extended operands, return true only if the value is
|
||||
// out-of-range.
|
||||
// 3) For global address, always return true.
|
||||
|
||||
bool HexagonMCInstrInfo::isConstExtended(MCInstrInfo const &MCII,
|
||||
MCInst const &MCI) {
|
||||
if (HexagonMCInstrInfo::isExtended(MCII, MCI))
|
||||
return true;
|
||||
|
||||
if (!HexagonMCInstrInfo::isExtendable(MCII, MCI))
|
||||
return false;
|
||||
|
||||
short ExtOpNum = HexagonMCInstrInfo::getCExtOpNum(MCII, MCI);
|
||||
int MinValue = HexagonMCInstrInfo::getMinValue(MCII, MCI);
|
||||
int MaxValue = HexagonMCInstrInfo::getMaxValue(MCII, MCI);
|
||||
MCOperand const &MO = MCI.getOperand(ExtOpNum);
|
||||
|
||||
// We could be using an instruction with an extendable immediate and shoehorn
|
||||
// a global address into it. If it is a global address it will be constant
|
||||
// extended. We do this for COMBINE.
|
||||
// We currently only handle isGlobal() because it is the only kind of
|
||||
// object we are going to end up with here for now.
|
||||
// In the future we probably should add isSymbol(), etc.
|
||||
if (MO.isExpr())
|
||||
return true;
|
||||
|
||||
// If the extendable operand is not 'Immediate' type, the instruction should
|
||||
// have 'isExtended' flag set.
|
||||
assert(MO.isImm() && "Extendable operand must be Immediate type");
|
||||
|
||||
int ImmValue = MO.getImm();
|
||||
return (ImmValue < MinValue || ImmValue > MaxValue);
|
||||
}
|
||||
|
||||
// Return true if the instruction may be extended based on the operand value.
|
||||
bool HexagonMCInstrInfo::isExtendable(MCInstrInfo const &MCII,
|
||||
MCInst const &MCI) {
|
||||
uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags;
|
||||
return (F >> HexagonII::ExtendablePos) & HexagonII::ExtendableMask;
|
||||
}
|
||||
|
||||
// Return whether the instruction must be always extended.
|
||||
bool HexagonMCInstrInfo::isExtended(MCInstrInfo const &MCII,
|
||||
MCInst const &MCI) {
|
||||
uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags;
|
||||
return (F >> HexagonII::ExtendedPos) & HexagonII::ExtendedMask;
|
||||
}
|
||||
|
||||
// Return whether the insn is a new-value consumer.
|
||||
bool HexagonMCInstrInfo::isNewValue(MCInstrInfo const &MCII,
|
||||
MCInst const &MCI) {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags;
|
||||
return ((F >> HexagonII::NewValuePos) & HexagonII::NewValueMask);
|
||||
}
|
||||
|
||||
// Return whether the operand can be constant extended.
|
||||
bool HexagonMCInstrInfo::isOperandExtended(MCInstrInfo const &MCII,
|
||||
MCInst const &MCI,
|
||||
unsigned short OperandNum) {
|
||||
uint64_t const F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags;
|
||||
return ((F >> HexagonII::ExtendableOpPos) & HexagonII::ExtendableOpMask) ==
|
||||
OperandNum;
|
||||
}
|
||||
|
||||
// Return whether the insn is a prefix.
|
||||
bool HexagonMCInstrInfo::isPrefix(MCInstrInfo const &MCII, MCInst const &MCI) {
|
||||
return (HexagonMCInstrInfo::getType(MCII, MCI) == HexagonII::TypePREFIX);
|
||||
}
|
||||
|
||||
// Return whether the insn is solo, i.e., cannot be in a packet.
|
||||
bool HexagonMCInstrInfo::isSolo(MCInstrInfo const &MCII, MCInst const &MCI) {
|
||||
const uint64_t F = HexagonMCInstrInfo::getDesc(MCII, MCI).TSFlags;
|
||||
return ((F >> HexagonII::SoloPos) & HexagonII::SoloMask);
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,57 @@ namespace llvm {
|
||||
class MCInstrDesc;
|
||||
class MCInstrInfo;
|
||||
class MCInst;
|
||||
class MCOperand;
|
||||
namespace HexagonMCInstrInfo {
|
||||
// Return number of bits in the constant extended operand.
|
||||
unsigned getBitCount(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
// Return constant extended operand number.
|
||||
unsigned short getCExtOpNum(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
MCInstrDesc const &getDesc(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
// Return the max value that a constant extendable operand can have
|
||||
// without being extended.
|
||||
int getMaxValue(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
// Return the min value that a constant extendable operand can have
|
||||
// without being extended.
|
||||
int getMinValue(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
// Return the operand that consumes or produces a new value.
|
||||
MCOperand const &getNewValue(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
// Return the Hexagon ISA class for the insn.
|
||||
unsigned getType(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
// Return whether the instruction is a legal new-value producer.
|
||||
bool hasNewValue(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
// Return whether the insn is an actual insn.
|
||||
bool isCanon(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
// Return whether the instruction needs to be constant extended.
|
||||
bool isConstExtended(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
// Return true if the insn may be extended based on the operand value.
|
||||
bool isExtendable(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
// Return whether the instruction must be always extended.
|
||||
bool isExtended(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
// Return whether the insn is a new-value consumer.
|
||||
bool isNewValue(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
// Return true if the operand can be constant extended.
|
||||
bool isOperandExtended(MCInstrInfo const &MCII, MCInst const &MCI,
|
||||
unsigned short OperandNum);
|
||||
|
||||
// Return whether the insn is a prefix.
|
||||
bool isPrefix(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
|
||||
// Return whether the insn is solo, i.e., cannot be in a packet.
|
||||
bool isSolo(MCInstrInfo const &MCII, MCInst const &MCI);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user