diff options
| author | Colin LeMahieu <colinl@codeaurora.org> | 2014-11-04 00:14:36 +0000 |
|---|---|---|
| committer | Colin LeMahieu <colinl@codeaurora.org> | 2014-11-04 00:14:36 +0000 |
| commit | 5241881bbc39eaf5f557e4d08ac74f2fe39cae6d (patch) | |
| tree | 4199b6480f16b28b8cbd31ac1a8dfede726d430e /llvm/lib/Target/Hexagon/MCTargetDesc | |
| parent | 429c9cae09089becc2df489d2eff4b62a295f0c8 (diff) | |
| download | bcm5719-llvm-5241881bbc39eaf5f557e4d08ac74f2fe39cae6d.tar.gz bcm5719-llvm-5241881bbc39eaf5f557e4d08ac74f2fe39cae6d.zip | |
[Hexagon] Reverting 220584 to address ASAN errors.
llvm-svn: 221210
Diffstat (limited to 'llvm/lib/Target/Hexagon/MCTargetDesc')
9 files changed, 157 insertions, 441 deletions
diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/Hexagon/MCTargetDesc/CMakeLists.txt index cb21eaf31dd..2b7cc851957 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/CMakeLists.txt +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/CMakeLists.txt @@ -1,5 +1,4 @@ add_llvm_library(LLVMHexagonDesc - HexagonInstPrinter.cpp HexagonMCAsmInfo.cpp HexagonMCCodeEmitter.cpp HexagonMCInst.cpp diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonInstPrinter.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonInstPrinter.cpp deleted file mode 100644 index 0765f185e61..00000000000 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonInstPrinter.cpp +++ /dev/null @@ -1,253 +0,0 @@ -//===- HexagonInstPrinter.cpp - Convert Hexagon MCInst to assembly syntax -===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This class prints an Hexagon MCInst to a .s file. -// -//===----------------------------------------------------------------------===// - -#include "HexagonAsmPrinter.h" -#include "Hexagon.h" -#include "HexagonInstPrinter.h" -#include "MCTargetDesc/HexagonMCInst.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/MC/MCAsmInfo.h" -#include "llvm/MC/MCExpr.h" -#include "llvm/MC/MCInst.h" -#include "llvm/Support/raw_ostream.h" - -using namespace llvm; - -#define DEBUG_TYPE "asm-printer" - -#define GET_INSTRUCTION_NAME -#include "HexagonGenAsmWriter.inc" - -const char HexagonInstPrinter::PacketPadding = '\t'; -// Return the minimum value that a constant extendable operand can have -// without being extended. -static int getMinValue(uint64_t TSFlags) { - unsigned isSigned = - (TSFlags >> HexagonII::ExtentSignedPos) & HexagonII::ExtentSignedMask; - unsigned bits = - (TSFlags >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask; - - if (isSigned) - return -1U << (bits - 1); - - return 0; -} - -// Return the maximum value that a constant extendable operand can have -// without being extended. -static int getMaxValue(uint64_t TSFlags) { - unsigned isSigned = - (TSFlags >> HexagonII::ExtentSignedPos) & HexagonII::ExtentSignedMask; - unsigned bits = - (TSFlags >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask; - - if (isSigned) - return ~(-1U << (bits - 1)); - - return ~(-1U << bits); -} - -// Return true if the instruction must be extended. -static bool isExtended(uint64_t TSFlags) { - return (TSFlags >> HexagonII::ExtendedPos) & HexagonII::ExtendedMask; -} - -// Currently just used in an assert statement -static bool isExtendable(uint64_t TSFlags) LLVM_ATTRIBUTE_UNUSED; -// Return true if the instruction may be extended based on the operand value. -static bool isExtendable(uint64_t TSFlags) { - return (TSFlags >> HexagonII::ExtendablePos) & HexagonII::ExtendableMask; -} - -StringRef HexagonInstPrinter::getOpcodeName(unsigned Opcode) const { - return MII.getName(Opcode); -} - -StringRef HexagonInstPrinter::getRegName(unsigned RegNo) const { - return getRegisterName(RegNo); -} - -void HexagonInstPrinter::printInst(const MCInst *MI, raw_ostream &O, - StringRef Annot) { - printInst((const HexagonMCInst*)(MI), O, Annot); -} - -void HexagonInstPrinter::printInst(const HexagonMCInst *MI, raw_ostream &O, - StringRef Annot) { - const char startPacket = '{', - endPacket = '}'; - // TODO: add outer HW loop when it's supported too. - if (MI->getOpcode() == Hexagon::ENDLOOP0) { - // Ending a harware loop is different from ending an regular packet. - assert(MI->isPacketEnd() && "Loop-end must also end the packet"); - - if (MI->isPacketBegin()) { - // There must be a packet to end a loop. - // FIXME: when shuffling is always run, this shouldn't be needed. - HexagonMCInst Nop (Hexagon::NOP); - StringRef NoAnnot; - - Nop.setPacketBegin (MI->isPacketBegin()); - printInst (&Nop, O, NoAnnot); - } - - // Close the packet. - if (MI->isPacketEnd()) - O << PacketPadding << endPacket; - - printInstruction(MI, O); - } - else { - // Prefix the insn opening the packet. - if (MI->isPacketBegin()) - O << PacketPadding << startPacket << '\n'; - - printInstruction(MI, O); - - // Suffix the insn closing the packet. - if (MI->isPacketEnd()) - // Suffix the packet in a new line always, since the GNU assembler has - // issues with a closing brace on the same line as CONST{32,64}. - O << '\n' << PacketPadding << endPacket; - } - - printAnnotation(O, Annot); -} - -void HexagonInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { - const MCOperand& MO = MI->getOperand(OpNo); - - if (MO.isReg()) { - O << getRegisterName(MO.getReg()); - } else if(MO.isExpr()) { - O << *MO.getExpr(); - } else if(MO.isImm()) { - printImmOperand(MI, OpNo, O); - } else { - llvm_unreachable("Unknown operand"); - } -} - -void HexagonInstPrinter::printImmOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { - const MCOperand& MO = MI->getOperand(OpNo); - - if(MO.isExpr()) { - O << *MO.getExpr(); - } else if(MO.isImm()) { - O << MI->getOperand(OpNo).getImm(); - } else { - llvm_unreachable("Unknown operand"); - } -} - -void HexagonInstPrinter::printExtOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { - const MCOperand &MO = MI->getOperand(OpNo); - const MCInstrDesc &MII = getMII().get(MI->getOpcode()); - - assert((isExtendable(MII.TSFlags) || isExtended(MII.TSFlags)) && - "Expecting an extendable operand"); - - if (MO.isExpr() || isExtended(MII.TSFlags)) { - O << "#"; - } else if (MO.isImm()) { - int ImmValue = MO.getImm(); - if (ImmValue < getMinValue(MII.TSFlags) || - ImmValue > getMaxValue(MII.TSFlags)) - O << "#"; - } - printOperand(MI, OpNo, O); -} - -void HexagonInstPrinter::printUnsignedImmOperand(const MCInst *MI, - unsigned OpNo, raw_ostream &O) const { - O << MI->getOperand(OpNo).getImm(); -} - -void HexagonInstPrinter::printNegImmOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { - O << -MI->getOperand(OpNo).getImm(); -} - -void HexagonInstPrinter::printNOneImmOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { - O << -1; -} - -void HexagonInstPrinter::printMEMriOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { - const MCOperand& MO0 = MI->getOperand(OpNo); - const MCOperand& MO1 = MI->getOperand(OpNo + 1); - - O << getRegisterName(MO0.getReg()); - O << " + #" << MO1.getImm(); -} - -void HexagonInstPrinter::printFrameIndexOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { - const MCOperand& MO0 = MI->getOperand(OpNo); - const MCOperand& MO1 = MI->getOperand(OpNo + 1); - - O << getRegisterName(MO0.getReg()) << ", #" << MO1.getImm(); -} - -void HexagonInstPrinter::printGlobalOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { - assert(MI->getOperand(OpNo).isExpr() && "Expecting expression"); - - printOperand(MI, OpNo, O); -} - -void HexagonInstPrinter::printJumpTable(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { - assert(MI->getOperand(OpNo).isExpr() && "Expecting expression"); - - printOperand(MI, OpNo, O); -} - -void HexagonInstPrinter::printConstantPool(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { - assert(MI->getOperand(OpNo).isExpr() && "Expecting expression"); - - printOperand(MI, OpNo, O); -} - -void HexagonInstPrinter::printBranchOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { - // Branches can take an immediate operand. This is used by the branch - // selection pass to print $+8, an eight byte displacement from the PC. - llvm_unreachable("Unknown branch operand."); -} - -void HexagonInstPrinter::printCallOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { -} - -void HexagonInstPrinter::printAbsAddrOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { -} - -void HexagonInstPrinter::printPredicateOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const { -} - -void HexagonInstPrinter::printSymbol(const MCInst *MI, unsigned OpNo, - raw_ostream &O, bool hi) const { - assert(MI->getOperand(OpNo).isImm() && "Unknown symbol operand"); - - O << '#' << (hi ? "HI" : "LO") << "(#"; - printOperand(MI, OpNo, O); - O << ')'; -} diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonInstPrinter.h b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonInstPrinter.h deleted file mode 100644 index 55ae95cd06d..00000000000 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonInstPrinter.h +++ /dev/null @@ -1,87 +0,0 @@ -//===-- HexagonInstPrinter.h - Convert Hexagon MCInst to assembly syntax --===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This class prints an Hexagon MCInst to a .s file. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_TARGET_HEXAGON_INSTPRINTER_HEXAGONINSTPRINTER_H -#define LLVM_LIB_TARGET_HEXAGON_INSTPRINTER_HEXAGONINSTPRINTER_H - -#include "llvm/MC/MCInstPrinter.h" -#include "llvm/MC/MCInstrInfo.h" - -namespace llvm { - class HexagonMCInst; - - class HexagonInstPrinter : public MCInstPrinter { - public: - explicit HexagonInstPrinter(const MCAsmInfo &MAI, - const MCInstrInfo &MII, - const MCRegisterInfo &MRI) - : MCInstPrinter(MAI, MII, MRI), MII(MII) {} - - void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot) override; - void printInst(const HexagonMCInst *MI, raw_ostream &O, StringRef Annot); - virtual StringRef getOpcodeName(unsigned Opcode) const; - void printInstruction(const MCInst *MI, raw_ostream &O); - StringRef getRegName(unsigned RegNo) const; - static const char *getRegisterName(unsigned RegNo); - - void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const; - void printImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const; - void printExtOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) const; - void printUnsignedImmOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const; - void printNegImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) - const; - void printNOneImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) - const; - void printMEMriOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) - const; - void printFrameIndexOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const; - void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) - const; - void printCallOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) - const; - void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) - const; - void printPredicateOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) - const; - void printGlobalOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) - const; - void printJumpTable(const MCInst *MI, unsigned OpNo, raw_ostream &O) const; - - void printConstantPool(const MCInst *MI, unsigned OpNo, - raw_ostream &O) const; - - void printSymbolHi(const MCInst *MI, unsigned OpNo, raw_ostream &O) const - { printSymbol(MI, OpNo, O, true); } - void printSymbolLo(const MCInst *MI, unsigned OpNo, raw_ostream &O) const - { printSymbol(MI, OpNo, O, false); } - - const MCInstrInfo &getMII() const { - return MII; - } - - protected: - void printSymbol(const MCInst *MI, unsigned OpNo, raw_ostream &O, bool hi) - const; - - static const char PacketPadding; - - private: - const MCInstrInfo &MII; - - }; - -} // end namespace llvm - -#endif diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp index 2ec0bd2ea86..4471977ab49 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCodeEmitter.cpp @@ -38,7 +38,7 @@ enum class ParseField { duplex = 0x0, last0 = 0x1, last1 = 0x2, end = 0x3 }; uint32_t getPacketBits(HexagonMCInst const &HMI) { unsigned const ParseFieldOffset = 14; ParseField Field = HMI.isPacketEnd() ? ParseField::end : ParseField::last0; - return static_cast<uint32_t>(Field) << ParseFieldOffset; + return static_cast <uint32_t> (Field) << ParseFieldOffset; } void emitLittleEndian(uint64_t Binary, raw_ostream &OS) { OS << static_cast<uint8_t>((Binary >> 0x00) & 0xff); @@ -57,9 +57,8 @@ void HexagonMCCodeEmitter::EncodeInstruction(MCInst const &MI, raw_ostream &OS, SmallVectorImpl<MCFixup> &Fixups, MCSubtargetInfo const &STI) const { HexagonMCInst const &HMB = static_cast<HexagonMCInst const &>(MI); - uint64_t Binary = - getBinaryCodeForInstr(HMB, Fixups, STI) | getPacketBits(HMB); - Binary |= getPacketBits(HMB); + uint64_t Binary = getBinaryCodeForInstr(HMB, Fixups, STI) | getPacketBits(HMB); + assert(HMB.getDesc().getSize() == 4 && "All instructions should be 32bit"); emitLittleEndian(Binary, OS); ++MCNumEmitted; } diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.cpp index 0f7a337ba61..c842b9b7cf3 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.cpp @@ -12,52 +12,68 @@ //===----------------------------------------------------------------------===// #include "HexagonInstrInfo.h" -#include "HexagonTargetMachine.h" #include "MCTargetDesc/HexagonBaseInfo.h" #include "MCTargetDesc/HexagonMCInst.h" #include "MCTargetDesc/HexagonMCTargetDesc.h" -#include "llvm/Support/TargetRegistry.h" using namespace llvm; -HexagonMCInst::HexagonMCInst(unsigned op) - : packetBegin(false), packetEnd(false), - MCID(llvm::TheHexagonTarget.createMCInstrInfo()->get(op)) { - assert(MCID.getSize() == 4 && "All instructions should be 32bit"); - setOpcode(op); +// Return the slots used by the insn. +unsigned HexagonMCInst::getUnits(const HexagonTargetMachine* TM) const { + const HexagonInstrInfo *QII = TM->getSubtargetImpl()->getInstrInfo(); + const InstrItineraryData *II = + TM->getSubtargetImpl()->getInstrItineraryData(); + const InstrStage* + IS = II->beginStage(QII->get(this->getOpcode()).getSchedClass()); + + return (IS->getUnits()); } -bool HexagonMCInst::isPacketBegin() const { return packetBegin; } -bool HexagonMCInst::isPacketEnd() const { return packetEnd; } -void HexagonMCInst::setPacketEnd(bool Y) { packetEnd = Y; } -void HexagonMCInst::setPacketBegin(bool Y) { packetBegin = Y; } +// Return the Hexagon ISA class for the insn. +unsigned HexagonMCInst::getType() const { + const uint64_t F = MCID->TSFlags; -unsigned HexagonMCInst::getUnits(HexagonTargetMachine const &TM) const { - const HexagonInstrInfo *QII = TM.getSubtargetImpl()->getInstrInfo(); - const InstrItineraryData *II = TM.getSubtargetImpl()->getInstrItineraryData(); - const InstrStage *IS = - II->beginStage(QII->get(this->getOpcode()).getSchedClass()); + return ((F >> HexagonII::TypePos) & HexagonII::TypeMask); +} - return (IS->getUnits()); +// Return whether the insn is an actual insn. +bool HexagonMCInst::isCanon() const { + return (!MCID->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 = MCID->TSFlags; + return ((F >> HexagonII::SoloPos) & HexagonII::SoloMask); +} + +// Return whether the insn is a new-value consumer. bool HexagonMCInst::isNewValue() const { - const uint64_t F = MCID.TSFlags; + const uint64_t F = MCID->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 = MCID.TSFlags; + const uint64_t F = MCID->TSFlags; return ((F >> HexagonII::hasNewValuePos) & HexagonII::hasNewValueMask); } -MCOperand const &HexagonMCInst::getNewValue() const { - const uint64_t F = MCID.TSFlags; - const unsigned O = - (F >> HexagonII::NewValueOpPos) & HexagonII::NewValueOpMask; - const MCOperand &MCO = getOperand(O); +// Return the operand that consumes or produces a new value. +const MCOperand& HexagonMCInst::getNewValue() const { + const uint64_t F = MCID->TSFlags; + const unsigned O = (F >> HexagonII::NewValueOpPos) & + HexagonII::NewValueOpMask; + const MCOperand& MCO = getOperand(O); - assert((isNewValue() || hasNewValue()) && MCO.isReg()); + assert ((isNewValue() || hasNewValue()) && MCO.isReg()); return (MCO); } @@ -68,6 +84,7 @@ MCOperand const &HexagonMCInst::getNewValue() const { // 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; @@ -76,9 +93,9 @@ bool HexagonMCInst::isConstExtended(void) const { return false; short ExtOpNum = getCExtOpNum(); - int MinValue = getMinValue(); - int MaxValue = getMaxValue(); - const MCOperand &MO = getOperand(ExtOpNum); + int MinValue = getMinValue(); + int MaxValue = getMaxValue(); + 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 @@ -97,51 +114,62 @@ bool HexagonMCInst::isConstExtended(void) const { return (ImmValue < MinValue || ImmValue > MaxValue); } +// Return whether the instruction must be always extended. bool HexagonMCInst::isExtended(void) const { - const uint64_t F = MCID.TSFlags; + const uint64_t F = MCID->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 = MCID.TSFlags; + const uint64_t F = MCID->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 = MCID.TSFlags; + const uint64_t F = MCID->TSFlags; return ((F >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask); } +// Return constant extended operand number. unsigned short HexagonMCInst::getCExtOpNum(void) const { - const uint64_t F = MCID.TSFlags; + const uint64_t F = MCID->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 = MCID.TSFlags; - return ((F >> HexagonII::ExtendableOpPos) & HexagonII::ExtendableOpMask) == - OperandNum; + const uint64_t F = MCID->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 = MCID.TSFlags; - unsigned isSigned = - (F >> HexagonII::ExtentSignedPos) & HexagonII::ExtentSignedMask; - unsigned bits = (F >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask; + const uint64_t F = MCID->TSFlags; + unsigned isSigned = (F >> HexagonII::ExtentSignedPos) + & HexagonII::ExtentSignedMask; + unsigned bits = (F >> HexagonII::ExtentBitsPos) + & HexagonII::ExtentBitsMask; - if (isSigned) + if (isSigned) // if value is signed return -1U << (bits - 1); else return 0; } +// Return the max value that a constant extendable operand can have +// without being extended. int HexagonMCInst::getMaxValue(void) const { - const uint64_t F = MCID.TSFlags; - unsigned isSigned = - (F >> HexagonII::ExtentSignedPos) & HexagonII::ExtentSignedMask; - unsigned bits = (F >> HexagonII::ExtentBitsPos) & HexagonII::ExtentBitsMask; + const uint64_t F = MCID->TSFlags; + unsigned isSigned = (F >> HexagonII::ExtentSignedPos) + & HexagonII::ExtentSignedMask; + unsigned bits = (F >> HexagonII::ExtentBitsPos) + & HexagonII::ExtentBitsMask; - if (isSigned) + if (isSigned) // if value is signed return ~(-1U << (bits - 1)); else return ~(-1U << bits); diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.h b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.h index e456aefcefb..90fbbf3f60a 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.h +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInst.h @@ -14,55 +14,87 @@ #ifndef LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINST_H #define LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINST_H +#include "HexagonTargetMachine.h" #include "llvm/MC/MCInst.h" namespace llvm { -class MCInstrDesc; -class MCOperand; -class HexagonTargetMachine; - -class HexagonMCInst : public MCInst { -public: - explicit HexagonMCInst(unsigned op); - - /// 10.6 Instruction Packets - bool isPacketBegin() const; - /// \brief Is this marked as last in packet. - bool isPacketEnd() const; - void setPacketBegin(bool Y); - /// \brief Mark this as last in packet. - void setPacketEnd(bool Y); - /// \brief Return the slots used. - unsigned getUnits(HexagonTargetMachine const &TM) const; - bool isConstExtended() const; - /// \brief Return constant extended operand number. - unsigned short getCExtOpNum(void) const; - /// \brief Return whether this is a new-value consumer. - bool isNewValue() const; - /// \brief Return whether this is a legal new-value producer. - bool hasNewValue() const; - /// \brief Return the operand that consumes or produces a new value. - MCOperand const &getNewValue() const; - /// \brief Return number of bits in the constant extended operand. - unsigned getBitCount(void) const; - -private: - /// \brief Return whether this must be always extended. - bool isExtended() const; - /// \brief Return true if this may be extended based on the operand value. - bool isExtendable() const; - /// \brief Return if the operand can be constant extended. - bool isOperandExtended(unsigned short const OperandNum) const; - /// \brief Return the min value that a constant extendable operand can have - /// without being extended. - int getMinValue() const; - /// \brief Return the max value that a constant extendable operand can have - /// without being extended. - int getMaxValue() const; - bool packetBegin; - bool packetEnd; - MCInstrDesc const &MCID; -}; + class MCOperand; + + class HexagonMCInst: public MCInst { + // MCID is set during instruction lowering. + // It is needed in order to access TSFlags for + // use in checking MC instruction properties. + const MCInstrDesc *MCID; + + // Packet start and end markers + unsigned packetStart: 1, packetEnd: 1; + + public: + explicit HexagonMCInst(): + MCInst(), MCID(nullptr), packetStart(0), packetEnd(0) {}; + HexagonMCInst(const MCInstrDesc& mcid): + MCInst(), MCID(&mcid), packetStart(0), packetEnd(0) {}; + + bool isPacketStart() const { return (packetStart); }; + bool isPacketEnd() const { return (packetEnd); }; + void setPacketStart(bool Y) { packetStart = Y; }; + void setPacketEnd(bool Y) { packetEnd = Y; }; + void resetPacket() { setPacketStart(false); setPacketEnd(false); }; + + // Return the slots used by the insn. + unsigned getUnits(const HexagonTargetMachine* TM) const; + + // Return the Hexagon ISA class for the insn. + unsigned getType() const; + + void setDesc(const MCInstrDesc& mcid) { MCID = &mcid; }; + const MCInstrDesc& getDesc(void) const { return *MCID; }; + + // 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; + + // Return the max value that a constant extendable operand can have + // without being extended. + int getMaxValue() const; + }; } #endif diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp index 1ae25376469..65cf42ae648 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp @@ -13,7 +13,7 @@ #include "HexagonMCTargetDesc.h" #include "HexagonMCAsmInfo.h" -#include "MCTargetDesc/HexagonInstPrinter.h" +#include "InstPrinter/HexagonInstPrinter.h" #include "llvm/MC/MCCodeGenInfo.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCRegisterInfo.h" @@ -34,7 +34,7 @@ using namespace llvm; #define GET_REGINFO_MC_DESC #include "HexagonGenRegisterInfo.inc" -static llvm::MCInstrInfo *createHexagonMCInstrInfo() { +static MCInstrInfo *createHexagonMCInstrInfo() { MCInstrInfo *X = new MCInstrInfo(); InitHexagonMCInstrInfo(X); return X; diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.h b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.h index c99815ce477..4ce429c4420 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.h +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.h @@ -15,8 +15,6 @@ #define LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCTARGETDESC_H namespace llvm { -struct InstrItinerary; -struct InstrStage; class MCCodeEmitter; class MCContext; class MCInstrInfo; diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/LLVMBuild.txt b/llvm/lib/Target/Hexagon/MCTargetDesc/LLVMBuild.txt index f559a21e3f9..5ecdd504e8c 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/LLVMBuild.txt +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/LLVMBuild.txt @@ -19,5 +19,5 @@ type = Library name = HexagonDesc parent = Hexagon -required_libraries = HexagonInfo MC Support +required_libraries = HexagonAsmPrinter HexagonInfo MC Support add_to_library_groups = Hexagon |

