LLVM API Documentation

HexagonMCInst.h
Go to the documentation of this file.
00001 //===- HexagonMCInst.h - Hexagon sub-class of MCInst ----------------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This class extends MCInst to allow some VLIW annotations.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINST_H
00015 #define LLVM_LIB_TARGET_HEXAGON_MCTARGETDESC_HEXAGONMCINST_H
00016 
00017 #include "HexagonTargetMachine.h"
00018 #include "llvm/MC/MCInst.h"
00019 
00020 namespace llvm {
00021   class MCOperand;
00022 
00023   class HexagonMCInst: public MCInst {
00024     // MCID is set during instruction lowering.
00025     // It is needed in order to access TSFlags for
00026     // use in checking MC instruction properties.
00027     const MCInstrDesc *MCID;
00028 
00029     // Packet start and end markers
00030     unsigned packetStart: 1, packetEnd: 1;
00031 
00032   public:
00033     explicit HexagonMCInst():
00034       MCInst(), MCID(nullptr), packetStart(0), packetEnd(0) {};
00035     HexagonMCInst(const MCInstrDesc& mcid):
00036       MCInst(), MCID(&mcid), packetStart(0), packetEnd(0) {};
00037 
00038     bool isPacketStart() const { return (packetStart); };
00039     bool isPacketEnd() const { return (packetEnd); };
00040     void setPacketStart(bool Y) { packetStart = Y; };
00041     void setPacketEnd(bool Y) { packetEnd = Y; };
00042     void resetPacket() { setPacketStart(false); setPacketEnd(false); };
00043 
00044     // Return the slots used by the insn.
00045     unsigned getUnits(const HexagonTargetMachine* TM) const;
00046 
00047     // Return the Hexagon ISA class for the insn.
00048     unsigned getType() const;
00049 
00050     void setDesc(const MCInstrDesc& mcid) { MCID = &mcid; };
00051     const MCInstrDesc& getDesc(void) const { return *MCID; };
00052 
00053     // Return whether the insn is an actual insn.
00054     bool isCanon() const;
00055 
00056     // Return whether the insn is a prefix.
00057     bool isPrefix() const;
00058 
00059     // Return whether the insn is solo, i.e., cannot be in a packet.
00060     bool isSolo() const;
00061 
00062     // Return whether the instruction needs to be constant extended.
00063     bool isConstExtended() const;
00064 
00065     // Return constant extended operand number.
00066     unsigned short getCExtOpNum(void) const;
00067 
00068     // Return whether the insn is a new-value consumer.
00069     bool isNewValue() const;
00070 
00071     // Return whether the instruction is a legal new-value producer.
00072     bool hasNewValue() const;
00073 
00074     // Return the operand that consumes or produces a new value.
00075     const MCOperand& getNewValue() const;
00076 
00077     // Return number of bits in the constant extended operand.
00078     unsigned getBitCount(void) const;
00079 
00080   private:
00081     // Return whether the instruction must be always extended.
00082     bool isExtended() const;
00083 
00084     // Return true if the insn may be extended based on the operand value.
00085     bool isExtendable() const;
00086 
00087     // Return true if the operand can be constant extended.
00088     bool isOperandExtended(const unsigned short OperandNum) const;
00089 
00090     // Return the min value that a constant extendable operand can have
00091     // without being extended.
00092     int getMinValue() const;
00093 
00094     // Return the max value that a constant extendable operand can have
00095     // without being extended.
00096     int getMaxValue() const;
00097   };
00098 }
00099 
00100 #endif