65#define DEBUG_TYPE "asm-printer"
71 unsigned Pair = *RI->
superregs(Reg).begin();
116 const char *ExtraCode,
119 if (ExtraCode && ExtraCode[0]) {
120 if (ExtraCode[1] != 0)
123 switch (ExtraCode[0]) {
136 if (Hexagon::DoubleRegsRegClass.
contains(RegNumber))
137 RegNumber =
TRI->getSubReg(RegNumber, ExtraCode[0] ==
'L' ?
146 if (
MI->getOperand(OpNo).isImm())
158 const char *ExtraCode,
160 if (ExtraCode && ExtraCode[0])
173 O <<
"+#" <<
Offset.getImm();
186 if (Imm.getExpr()->evaluateAsAbsolute(
Value)) {
188 std::string ImmString;
190 if (AlignSize == 8) {
191 Name =
".CONST_0000000000000000";
192 sectionPrefix =
".gnu.linkonce.l8";
193 ImmString = utohexstr(
Value);
195 Name =
".CONST_00000000";
196 sectionPrefix =
".gnu.linkonce.l4";
200 std::string symbolName =
201 Name.drop_back(ImmString.size()).str() + ImmString;
202 std::string sectionName = sectionPrefix.
str() + symbolName;
209 if (
Sym->isUndefined()) {
216 assert(Imm.isExpr() &&
"Expected expression and found none");
230 std::string LitaName =
".CONST_" + SymbolName.str();
237 if (
Sym->isUndefined()) {
240 OutStreamer.
emitValue(Imm.getExpr(), AlignSize);
258 int32_t V = cast<MCConstantExpr>(HE->getExpr())->getValue();
272 unsigned VectorSize = HRI.getRegSizeInBits(Hexagon::HvxVRRegClass) / 8;
278 case Hexagon::A2_iconst: {
291 case Hexagon::A2_tfrf: {
298 case Hexagon::A2_tfrt: {
305 case Hexagon::A2_tfrfnew: {
312 case Hexagon::A2_tfrtnew: {
319 case Hexagon::A2_zxtb: {
327 case Hexagon::CONST64:
335 OutStreamer->switchSection(Current.first, Current.second);
342 MappedInst = TmpInst;
346 case Hexagon::CONST32:
352 OutStreamer->switchSection(Current.first, Current.second);
359 MappedInst = TmpInst;
366 case Hexagon::C2_pxfer_map: {
376 case Hexagon::M2_vrcmpys_acc_s1: {
378 assert(Rt.
isReg() &&
"Expected register and none was found");
381 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_acc_s1_h);
383 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_acc_s1_l);
387 case Hexagon::M2_vrcmpys_s1: {
389 assert(Rt.
isReg() &&
"Expected register and none was found");
392 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_s1_h);
394 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_s1_l);
399 case Hexagon::M2_vrcmpys_s1rp: {
401 assert(Rt.
isReg() &&
"Expected register and none was found");
404 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_s1rp_h);
406 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_s1rp_l);
411 case Hexagon::A4_boundscheck: {
413 assert(Rs.
isReg() &&
"Expected register and none was found");
416 MappedInst.
setOpcode(Hexagon::A4_boundscheck_hi);
418 MappedInst.
setOpcode(Hexagon::A4_boundscheck_lo);
423 case Hexagon::PS_call_nr:
427 case Hexagon::S5_asrhub_rnd_sat_goodsyntax: {
431 bool Success = Expr->evaluateAsAbsolute(Imm);
439 MappedInst = TmpInst;
442 TmpInst.
setOpcode(Hexagon::S5_asrhub_rnd_sat);
449 MappedInst = TmpInst;
453 case Hexagon::S5_vasrhrnd_goodsyntax:
454 case Hexagon::S2_asr_i_p_rnd_goodsyntax: {
458 bool Success = Expr->evaluateAsAbsolute(Imm);
471 MappedInst = TmpInst;
475 if (Inst.
getOpcode() == Hexagon::S2_asr_i_p_rnd_goodsyntax)
476 TmpInst.
setOpcode(Hexagon::S2_asr_i_p_rnd);
485 MappedInst = TmpInst;
490 case Hexagon::S2_asr_i_r_rnd_goodsyntax: {
494 bool Success = Expr->evaluateAsAbsolute(Imm);
502 MappedInst = TmpInst;
505 TmpInst.
setOpcode(Hexagon::S2_asr_i_r_rnd);
512 MappedInst = TmpInst;
517 case Hexagon::A2_tfrpi: {
522 TmpInst.
setOpcode(Hexagon::A2_combineii);
536 MappedInst = TmpInst;
541 case Hexagon::A2_tfrp: {
548 MappedInst.
setOpcode(Hexagon::A2_combinew);
552 case Hexagon::A2_tfrpt:
553 case Hexagon::A2_tfrpf: {
561 ? Hexagon::C2_ccombinewt
562 : Hexagon::C2_ccombinewf);
566 case Hexagon::A2_tfrptnew:
567 case Hexagon::A2_tfrpfnew: {
575 ? Hexagon::C2_ccombinewnewt
576 : Hexagon::C2_ccombinewnewf);
580 case Hexagon::M2_mpysmi: {
582 MCExpr const *Expr = Imm.getExpr();
587 if (Value < 0 && Value > -256) {
588 MappedInst.
setOpcode(Hexagon::M2_mpysin);
592 MappedInst.
setOpcode(Hexagon::M2_mpysip);
596 case Hexagon::A2_addsp: {
598 assert(Rt.
isReg() &&
"Expected register and none was found");
601 MappedInst.
setOpcode(Hexagon::A2_addsph);
603 MappedInst.
setOpcode(Hexagon::A2_addspl);
608 case Hexagon::V6_vd0: {
611 "Expected register and none was found");
617 MappedInst = TmpInst;
621 case Hexagon::V6_vdd0: {
624 "Expected register and none was found");
630 MappedInst = TmpInst;
634 case Hexagon::V6_vL32Ub_pi:
635 case Hexagon::V6_vL32b_cur_pi:
636 case Hexagon::V6_vL32b_nt_cur_pi:
637 case Hexagon::V6_vL32b_pi:
638 case Hexagon::V6_vL32b_nt_pi:
639 case Hexagon::V6_vL32b_nt_tmp_pi:
640 case Hexagon::V6_vL32b_tmp_pi:
644 case Hexagon::V6_vL32Ub_ai:
645 case Hexagon::V6_vL32b_ai:
646 case Hexagon::V6_vL32b_cur_ai:
647 case Hexagon::V6_vL32b_nt_ai:
648 case Hexagon::V6_vL32b_nt_cur_ai:
649 case Hexagon::V6_vL32b_nt_tmp_ai:
650 case Hexagon::V6_vL32b_tmp_ai:
654 case Hexagon::V6_vS32Ub_pi:
655 case Hexagon::V6_vS32b_new_pi:
656 case Hexagon::V6_vS32b_nt_new_pi:
657 case Hexagon::V6_vS32b_nt_pi:
658 case Hexagon::V6_vS32b_pi:
662 case Hexagon::V6_vS32Ub_ai:
663 case Hexagon::V6_vS32b_ai:
664 case Hexagon::V6_vS32b_new_ai:
665 case Hexagon::V6_vS32b_nt_ai:
666 case Hexagon::V6_vS32b_nt_new_ai:
670 case Hexagon::V6_vL32b_cur_npred_pi:
671 case Hexagon::V6_vL32b_cur_pred_pi:
672 case Hexagon::V6_vL32b_npred_pi:
673 case Hexagon::V6_vL32b_nt_cur_npred_pi:
674 case Hexagon::V6_vL32b_nt_cur_pred_pi:
675 case Hexagon::V6_vL32b_nt_npred_pi:
676 case Hexagon::V6_vL32b_nt_pred_pi:
677 case Hexagon::V6_vL32b_nt_tmp_npred_pi:
678 case Hexagon::V6_vL32b_nt_tmp_pred_pi:
679 case Hexagon::V6_vL32b_pred_pi:
680 case Hexagon::V6_vL32b_tmp_npred_pi:
681 case Hexagon::V6_vL32b_tmp_pred_pi:
685 case Hexagon::V6_vL32b_cur_npred_ai:
686 case Hexagon::V6_vL32b_cur_pred_ai:
687 case Hexagon::V6_vL32b_npred_ai:
688 case Hexagon::V6_vL32b_nt_cur_npred_ai:
689 case Hexagon::V6_vL32b_nt_cur_pred_ai:
690 case Hexagon::V6_vL32b_nt_npred_ai:
691 case Hexagon::V6_vL32b_nt_pred_ai:
692 case Hexagon::V6_vL32b_nt_tmp_npred_ai:
693 case Hexagon::V6_vL32b_nt_tmp_pred_ai:
694 case Hexagon::V6_vL32b_pred_ai:
695 case Hexagon::V6_vL32b_tmp_npred_ai:
696 case Hexagon::V6_vL32b_tmp_pred_ai:
700 case Hexagon::V6_vS32Ub_npred_pi:
701 case Hexagon::V6_vS32Ub_pred_pi:
702 case Hexagon::V6_vS32b_new_npred_pi:
703 case Hexagon::V6_vS32b_new_pred_pi:
704 case Hexagon::V6_vS32b_npred_pi:
705 case Hexagon::V6_vS32b_nqpred_pi:
706 case Hexagon::V6_vS32b_nt_new_npred_pi:
707 case Hexagon::V6_vS32b_nt_new_pred_pi:
708 case Hexagon::V6_vS32b_nt_npred_pi:
709 case Hexagon::V6_vS32b_nt_nqpred_pi:
710 case Hexagon::V6_vS32b_nt_pred_pi:
711 case Hexagon::V6_vS32b_nt_qpred_pi:
712 case Hexagon::V6_vS32b_pred_pi:
713 case Hexagon::V6_vS32b_qpred_pi:
717 case Hexagon::V6_vS32Ub_npred_ai:
718 case Hexagon::V6_vS32Ub_pred_ai:
719 case Hexagon::V6_vS32b_new_npred_ai:
720 case Hexagon::V6_vS32b_new_pred_ai:
721 case Hexagon::V6_vS32b_npred_ai:
722 case Hexagon::V6_vS32b_nqpred_ai:
723 case Hexagon::V6_vS32b_nt_new_npred_ai:
724 case Hexagon::V6_vS32b_nt_new_pred_ai:
725 case Hexagon::V6_vS32b_nt_npred_ai:
726 case Hexagon::V6_vS32b_nt_nqpred_ai:
727 case Hexagon::V6_vS32b_nt_pred_ai:
728 case Hexagon::V6_vS32b_nt_qpred_ai:
729 case Hexagon::V6_vS32b_pred_ai:
730 case Hexagon::V6_vS32b_qpred_ai:
735 case Hexagon::V6_vS32b_srls_ai:
739 case Hexagon::V6_vS32b_srls_pi:
747 Hexagon_MC::verifyInstructionPredicates(
MI->getOpcode(),
755 if (
MI->isBundle()) {
759 for (++MII; MII !=
MBB->
instr_end() && MII->isInsideBundle(); ++MII)
760 if (!MII->isDebugInstr() && !MII->isImplicitDef())
768 if (
MI->isBundle() && HII.getBundleNoShuf(*
MI))
792void HexagonAsmPrinter::emitAttributes() {
799 static const int8_t NoopsInSledCount = 4;
833 SledJumpPacket.
setOpcode(Hexagon::BUNDLE);
#define LLVM_EXTERNAL_VISIBILITY
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonAsmPrinter()
static MCSymbol * smallData(AsmPrinter &AP, const MachineInstr &MI, MCStreamer &OutStreamer, const MCOperand &Imm, int AlignSize, const MCSubtargetInfo &STI)
static MCInst ScaleVectorOffset(MCInst &Inst, unsigned OpNo, unsigned VectorSize, MCContext &Ctx)
static unsigned getHexagonRegisterPair(unsigned Reg, const MCRegisterInfo *RI)
unsigned const TargetRegisterInfo * TRI
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This class is intended to be used as a driving class for all asm writers.
MCSymbol * getSymbol(const GlobalValue *GV) const
void emitNops(unsigned N)
Emit N NOP instructions.
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
TargetMachine & TM
Target machine description.
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
const MCAsmInfo * MAI
Target Asm Printer information.
MachineFunction * MF
The current machine function.
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind, uint8_t Version=0)
MCContext & OutContext
This is the context for the output file that we are streaming.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant.
void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI)
void EmitSled(const MachineInstr &MI, SledKind Kind)
void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI)
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const override
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) override
PrintAsmOperand - Print out an operand for an inline asm expression.
void emitInstruction(const MachineInstr *MI) override
Print out a single Hexagon MI to the current output stream.
void emitEndOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the end of their file...
void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI)
void emitStartOfAsmFile(Module &M) override
This virtual method can be overridden by targets that want to emit something at the start of their fi...
void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O)
void HexagonProcessInstruction(MCInst &Inst, const MachineInstr &MBB)
static char const * getRegisterName(MCRegister Reg)
static HexagonMCExpr * create(MCExpr const *Expr, MCContext &Ctx)
const HexagonInstrInfo * getInstrInfo() const override
void emitTargetAttributes(const MCSubtargetInfo &STI)
virtual void finishAttributeSection()
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Base class for the full range of assembler expressions which are needed for parsing.
Instances of this class represent a single low-level machine instruction.
unsigned getNumOperands() const
unsigned getOpcode() const
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
const MCOperand & getOperand(unsigned i) const
Interface to description of machine instruction set.
Instances of this class represent operands of the MCInst class.
static MCOperand createReg(unsigned Reg)
static MCOperand createExpr(const MCExpr *Val)
void setReg(unsigned Reg)
Set the register number.
static MCOperand createImm(int64_t Val)
unsigned getReg() const
Returns the register number.
const MCExpr * getExpr() const
static MCOperand createInst(const MCInst *Val)
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
iterator_range< MCSuperRegIterator > superregs(MCRegister Reg) const
Return an iterator range over all super-registers of Reg, excluding Reg.
uint16_t getEncodingValue(MCRegister RegNo) const
Returns the encoding for RegNo.
MCRegister getSubReg(MCRegister Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo.
This represents a section on linux, lots of unix variants and some bare metal systems.
Streaming machine code generation interface.
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
MCContext & getContext() const
void emitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
virtual void emitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers.
virtual void emitCodeAlignment(Align Alignment, const MCSubtargetInfo *STI, unsigned MaxBytesToEmit=0)
Emit nops until the byte alignment ByteAlignment is reached.
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
Generic base class for all target subtargets.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
StringRef getName() const
getName - Get the symbol name.
static const MCUnaryExpr * createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
bool hasAddressTaken() const
Test whether this block is used as something other than the target of a terminator,...
instr_iterator instr_end()
Instructions::const_iterator const_instr_iterator
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineBasicBlock * getMBB() const
bool isCPI() const
isCPI - Tests if this is a MO_ConstantPoolIndex operand.
bool isJTI() const
isJTI - Tests if this is a MO_JumpTableIndex operand.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
Register getReg() const
getReg - Returns the register number.
@ MO_Immediate
Immediate operand.
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.
@ MO_GlobalAddress
Address of a global value.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
A Module instance is used to store all the information related to an LLVM module.
Wrapper class representing virtual and physical registers.
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
const Triple & getTargetTriple() const
const MCSubtargetInfo * getMCSubtargetInfo() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
size_t bundleSize(MCInst const &MCI)
void setS27_2_reloc(MCExpr const &Expr, bool Val=true)
void setMemReorderDisabled(MCInst &MCI)
bool canonicalizePacket(MCInstrInfo const &MCII, MCSubtargetInfo const &STI, MCContext &Context, MCInst &MCB, HexagonMCChecker *Checker, bool AttemptCompatibility=false)
void setMustNotExtend(MCExpr const &Expr, bool Val=true)
This is an optimization pass for GlobalISel generic memory operations.
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
Target & getTheHexagonTarget()
std::pair< MCSection *, uint32_t > MCSectionSubPair
void HexagonLowerToMC(const MCInstrInfo &MCII, const MachineInstr *MI, MCInst &MCB, HexagonAsmPrinter &AP)
@ MCSA_Global
.type _foo, @gnu_unique_object
This struct is a compact representation of a valid (non-zero power of two) alignment.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...