63 #define DEBUG_TYPE "asm-printer" 118 const char *ExtraCode,
121 if (ExtraCode && ExtraCode[0]) {
122 if (ExtraCode[1] != 0)
125 switch (ExtraCode[0]) {
140 unsigned RegNumber = MO.
getReg();
142 if (Hexagon::DoubleRegsRegClass.
contains(RegNumber))
143 RegNumber = TRI->
getSubReg(RegNumber, ExtraCode[0] ==
'L' ?
165 const char *ExtraCode,
167 if (ExtraCode && ExtraCode[0])
178 if (Offset.
isImm()) {
180 O <<
"+#" << Offset.
getImm();
193 if (Imm.
getExpr()->evaluateAsAbsolute(Value)) {
195 std::string ImmString;
197 if (AlignSize == 8) {
198 Name =
".CONST_0000000000000000";
199 sectionPrefix =
".gnu.linkonce.l8";
202 Name =
".CONST_00000000";
203 sectionPrefix =
".gnu.linkonce.l4";
204 ImmString =
utohexstr(static_cast<uint32_t>(Value));
207 std::string symbolName =
208 Name.
drop_back(ImmString.size()).str() + ImmString;
209 std::string sectionName = sectionPrefix.
str() + symbolName;
223 assert(Imm.
isExpr() &&
"Expected expression and found none");
225 assert(MO.isGlobal() || MO.isCPI() || MO.isJTI());
237 std::string LitaName =
".CONST_" + SymbolName.
str();
265 int32_t V = cast<MCConstantExpr>(HE->getExpr())->getValue();
279 unsigned VectorSize = HRI.getRegSizeInBits(Hexagon::HvxVRRegClass) / 8;
285 case Hexagon::A2_iconst: {
298 case Hexagon::A2_tfrf: {
305 case Hexagon::A2_tfrt: {
312 case Hexagon::A2_tfrfnew: {
319 case Hexagon::A2_tfrtnew: {
326 case Hexagon::A2_zxtb: {
334 case Hexagon::CONST64:
341 OutStreamer->SwitchSection(Current.first, Current.second);
348 MappedInst = TmpInst;
357 OutStreamer->SwitchSection(Current.first, Current.second);
364 MappedInst = TmpInst;
371 case Hexagon::C2_pxfer_map: {
381 case Hexagon::M2_vrcmpys_acc_s1: {
383 assert(Rt.
isReg() &&
"Expected register and none was found");
384 unsigned Reg = RI->getEncodingValue(Rt.
getReg());
386 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_acc_s1_h);
388 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_acc_s1_l);
392 case Hexagon::M2_vrcmpys_s1: {
394 assert(Rt.
isReg() &&
"Expected register and none was found");
395 unsigned Reg = RI->getEncodingValue(Rt.
getReg());
397 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_s1_h);
399 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_s1_l);
404 case Hexagon::M2_vrcmpys_s1rp: {
406 assert(Rt.
isReg() &&
"Expected register and none was found");
407 unsigned Reg = RI->getEncodingValue(Rt.
getReg());
409 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_s1rp_h);
411 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_s1rp_l);
416 case Hexagon::A4_boundscheck: {
418 assert(Rs.
isReg() &&
"Expected register and none was found");
419 unsigned Reg = RI->getEncodingValue(Rs.
getReg());
421 MappedInst.
setOpcode(Hexagon::A4_boundscheck_hi);
423 MappedInst.
setOpcode(Hexagon::A4_boundscheck_lo);
428 case Hexagon::PS_call_nr:
432 case Hexagon::S5_asrhub_rnd_sat_goodsyntax: {
436 bool Success = Expr->evaluateAsAbsolute(Imm);
437 assert(Success &&
"Expected immediate and none was found");
444 MappedInst = TmpInst;
447 TmpInst.
setOpcode(Hexagon::S5_asrhub_rnd_sat);
454 MappedInst = TmpInst;
458 case Hexagon::S5_vasrhrnd_goodsyntax:
459 case Hexagon::S2_asr_i_p_rnd_goodsyntax: {
463 bool Success = Expr->evaluateAsAbsolute(Imm);
464 assert(Success &&
"Expected immediate and none was found");
471 unsigned High = RI->getSubReg(MO1.
getReg(), Hexagon::isub_hi);
472 unsigned Low = RI->getSubReg(MO1.
getReg(), Hexagon::isub_lo);
476 MappedInst = TmpInst;
480 if (Inst.
getOpcode() == Hexagon::S2_asr_i_p_rnd_goodsyntax)
481 TmpInst.
setOpcode(Hexagon::S2_asr_i_p_rnd);
490 MappedInst = TmpInst;
495 case Hexagon::S2_asr_i_r_rnd_goodsyntax: {
499 bool Success = Expr->evaluateAsAbsolute(Imm);
500 assert(Success &&
"Expected immediate and none was found");
507 MappedInst = TmpInst;
510 TmpInst.
setOpcode(Hexagon::S2_asr_i_r_rnd);
517 MappedInst = TmpInst;
522 case Hexagon::A2_tfrpi: {
527 TmpInst.
setOpcode(Hexagon::A2_combineii);
531 if (Success && Imm < 0) {
541 MappedInst = TmpInst;
546 case Hexagon::A2_tfrp: {
548 unsigned High = RI->getSubReg(MO.
getReg(), Hexagon::isub_hi);
549 unsigned Low = RI->getSubReg(MO.
getReg(), Hexagon::isub_lo);
553 MappedInst.
setOpcode(Hexagon::A2_combinew);
557 case Hexagon::A2_tfrpt:
558 case Hexagon::A2_tfrpf: {
560 unsigned High = RI->getSubReg(MO.
getReg(), Hexagon::isub_hi);
561 unsigned Low = RI->getSubReg(MO.
getReg(), Hexagon::isub_lo);
566 ? Hexagon::C2_ccombinewt
567 : Hexagon::C2_ccombinewf);
571 case Hexagon::A2_tfrptnew:
572 case Hexagon::A2_tfrpfnew: {
574 unsigned High = RI->getSubReg(MO.
getReg(), Hexagon::isub_hi);
575 unsigned Low = RI->getSubReg(MO.
getReg(), Hexagon::isub_lo);
580 ? Hexagon::C2_ccombinewnewt
581 : Hexagon::C2_ccombinewnewf);
585 case Hexagon::M2_mpysmi: {
589 bool Success = Expr->evaluateAsAbsolute(Value);
593 MappedInst.
setOpcode(Hexagon::M2_mpysin);
597 MappedInst.
setOpcode(Hexagon::M2_mpysip);
601 case Hexagon::A2_addsp: {
603 assert(Rt.
isReg() &&
"Expected register and none was found");
604 unsigned Reg = RI->getEncodingValue(Rt.
getReg());
606 MappedInst.
setOpcode(Hexagon::A2_addsph);
608 MappedInst.
setOpcode(Hexagon::A2_addspl);
613 case Hexagon::V6_vd0: {
616 "Expected register and none was found");
622 MappedInst = TmpInst;
626 case Hexagon::V6_vdd0: {
629 "Expected register and none was found");
635 MappedInst = TmpInst;
639 case Hexagon::V6_vL32Ub_pi:
640 case Hexagon::V6_vL32b_cur_pi:
641 case Hexagon::V6_vL32b_nt_cur_pi:
642 case Hexagon::V6_vL32b_pi:
643 case Hexagon::V6_vL32b_nt_pi:
644 case Hexagon::V6_vL32b_nt_tmp_pi:
645 case Hexagon::V6_vL32b_tmp_pi:
649 case Hexagon::V6_vL32Ub_ai:
650 case Hexagon::V6_vL32b_ai:
651 case Hexagon::V6_vL32b_cur_ai:
652 case Hexagon::V6_vL32b_nt_ai:
653 case Hexagon::V6_vL32b_nt_cur_ai:
654 case Hexagon::V6_vL32b_nt_tmp_ai:
655 case Hexagon::V6_vL32b_tmp_ai:
659 case Hexagon::V6_vS32Ub_pi:
660 case Hexagon::V6_vS32b_new_pi:
661 case Hexagon::V6_vS32b_nt_new_pi:
662 case Hexagon::V6_vS32b_nt_pi:
663 case Hexagon::V6_vS32b_pi:
667 case Hexagon::V6_vS32Ub_ai:
668 case Hexagon::V6_vS32b_ai:
669 case Hexagon::V6_vS32b_new_ai:
670 case Hexagon::V6_vS32b_nt_ai:
671 case Hexagon::V6_vS32b_nt_new_ai:
675 case Hexagon::V6_vL32b_cur_npred_pi:
676 case Hexagon::V6_vL32b_cur_pred_pi:
677 case Hexagon::V6_vL32b_npred_pi:
678 case Hexagon::V6_vL32b_nt_cur_npred_pi:
679 case Hexagon::V6_vL32b_nt_cur_pred_pi:
680 case Hexagon::V6_vL32b_nt_npred_pi:
681 case Hexagon::V6_vL32b_nt_pred_pi:
682 case Hexagon::V6_vL32b_nt_tmp_npred_pi:
683 case Hexagon::V6_vL32b_nt_tmp_pred_pi:
684 case Hexagon::V6_vL32b_pred_pi:
685 case Hexagon::V6_vL32b_tmp_npred_pi:
686 case Hexagon::V6_vL32b_tmp_pred_pi:
690 case Hexagon::V6_vL32b_cur_npred_ai:
691 case Hexagon::V6_vL32b_cur_pred_ai:
692 case Hexagon::V6_vL32b_npred_ai:
693 case Hexagon::V6_vL32b_nt_cur_npred_ai:
694 case Hexagon::V6_vL32b_nt_cur_pred_ai:
695 case Hexagon::V6_vL32b_nt_npred_ai:
696 case Hexagon::V6_vL32b_nt_pred_ai:
697 case Hexagon::V6_vL32b_nt_tmp_npred_ai:
698 case Hexagon::V6_vL32b_nt_tmp_pred_ai:
699 case Hexagon::V6_vL32b_pred_ai:
700 case Hexagon::V6_vL32b_tmp_npred_ai:
701 case Hexagon::V6_vL32b_tmp_pred_ai:
705 case Hexagon::V6_vS32Ub_npred_pi:
706 case Hexagon::V6_vS32Ub_pred_pi:
707 case Hexagon::V6_vS32b_new_npred_pi:
708 case Hexagon::V6_vS32b_new_pred_pi:
709 case Hexagon::V6_vS32b_npred_pi:
710 case Hexagon::V6_vS32b_nqpred_pi:
711 case Hexagon::V6_vS32b_nt_new_npred_pi:
712 case Hexagon::V6_vS32b_nt_new_pred_pi:
713 case Hexagon::V6_vS32b_nt_npred_pi:
714 case Hexagon::V6_vS32b_nt_nqpred_pi:
715 case Hexagon::V6_vS32b_nt_pred_pi:
716 case Hexagon::V6_vS32b_nt_qpred_pi:
717 case Hexagon::V6_vS32b_pred_pi:
718 case Hexagon::V6_vS32b_qpred_pi:
722 case Hexagon::V6_vS32Ub_npred_ai:
723 case Hexagon::V6_vS32Ub_pred_ai:
724 case Hexagon::V6_vS32b_new_npred_ai:
725 case Hexagon::V6_vS32b_new_pred_ai:
726 case Hexagon::V6_vS32b_npred_ai:
727 case Hexagon::V6_vS32b_nqpred_ai:
728 case Hexagon::V6_vS32b_nt_new_npred_ai:
729 case Hexagon::V6_vS32b_nt_new_pred_ai:
730 case Hexagon::V6_vS32b_nt_npred_ai:
731 case Hexagon::V6_vS32b_nt_nqpred_ai:
732 case Hexagon::V6_vS32b_nt_pred_ai:
733 case Hexagon::V6_vS32b_nt_qpred_ai:
734 case Hexagon::V6_vS32b_pred_ai:
735 case Hexagon::V6_vS32b_qpred_ai:
740 case Hexagon::V6_vS32b_srls_ai:
744 case Hexagon::V6_vS32b_srls_pi:
761 for (++MII; MII != MBB->
instr_end() && MII->isInsideBundle(); ++MII)
762 if (!MII->isDebugInstr() && !MII->isImplicitDef())
770 if (MI->
isBundle() && HII.getBundleNoShuf(*MI))
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
instr_iterator instr_end()
MachineBasicBlock * getMBB() const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MCContext & OutContext
This is the context for the output file that we are streaming.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
static MCOperand createExpr(const MCExpr *Val)
const MCSubtargetInfo & getSubtargetInfo() const
Return information about subtarget.
unsigned getReg() const
getReg - Returns the register number.
MachineBasicBlock reference.
static MCSymbol * smallData(AsmPrinter &AP, const MachineInstr &MI, MCStreamer &OutStreamer, const MCOperand &Imm, int AlignSize)
unsigned const TargetRegisterInfo * TRI
MachineFunction * MF
The current machine function.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
return AArch64::GPR64RegClass contains(Reg)
MCContext & getContext() const
amdgpu Simplify well known AMD library false Value Value const Twine & Name
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
static MCOperand createReg(unsigned Reg)
MCSuperRegIterator enumerates all super-registers of Reg.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Base class for the full range of assembler expressions which are needed for parsing.
unsigned getReg() const
Returns the register number.
void setMemReorderDisabled(MCInst &MCI)
Context object for machine code objects.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool canonicalizePacket(MCInstrInfo const &MCII, MCSubtargetInfo const &STI, MCContext &Context, MCInst &MCB, HexagonMCChecker *Checker)
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
const MCExpr * getExpr() const
void printOffset(int64_t Offset, raw_ostream &OS) const
This is just convenient handler for printing offsets.
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...
void EmitInstruction(const MachineInstr *MI) override
Print out a single Hexagon MI to the current output stream.
void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Instances of this class represent a single low-level machine instruction.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
static unsigned getHexagonRegisterPair(unsigned Reg, const MCRegisterInfo *RI)
void HexagonLowerToMC(const MCInstrInfo &MCII, const MachineInstr *MI, MCInst &MCB, HexagonAsmPrinter &AP)
void HexagonProcessInstruction(MCInst &Inst, const MachineInstr &MBB)
Address of a global value.
Streaming machine code generation interface.
static HexagonMCExpr * create(MCExpr const *Expr, MCContext &Ctx)
const MCAsmInfo * MAI
Target Asm Printer information.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
const GlobalValue * getGlobal() const
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
Interface to description of machine instruction set.
unsigned getSubReg(unsigned Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
This class is intended to be used as a driving class for all asm writers.
virtual bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS) override
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant as...
self_iterator getIterator()
unsigned getNumOperands() const
static MCInst ScaleVectorOffset(MCInst &Inst, unsigned OpNo, unsigned VectorSize, MCContext &Ctx)
bool hasAddressTaken() const
Test whether this block is potentially the target of an indirect branch.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual MCSymbol * GetCPISymbol(unsigned CPID) const
Return the symbol for the specified constant pool entry.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static const MCUnaryExpr * createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
void LLVMInitializeHexagonAsmPrinter()
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
void printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O)
Iterator for intrusive lists based on ilist_node.
void setOpcode(unsigned Op)
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS) override
PrintAsmOperand - Print out an operand for an inline asm expression.
std::pair< MCSection *, const MCExpr * > MCSectionSubPair
MCSymbol * getSymbol(const GlobalValue *GV) const
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
MachineOperand class - Representation of each machine instruction operand.
virtual void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit=0)
Emit nops until the byte alignment ByteAlignment is reached.
const MCOperand & getOperand(unsigned i) const
const MachineBasicBlock * getParent() const
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
Return the symbol for the specified jump table entry.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
int64_t getOffset() const
Return the offset from the symbol in this operand.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
This represents a section on linux, lots of unix variants and some bare metal systems.
void setMustNotExtend(MCExpr const &Expr, bool Val=true)
size_t bundleSize(MCInst const &MCI)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
void setReg(unsigned Reg)
Set the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
LLVM Value Representation.
static char const * getRegisterName(unsigned RegNo)
const HexagonInstrInfo * getInstrInfo() const override
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
This class implements an extremely fast bulk output stream that can only output to a stream...
void addOperand(const MCOperand &Op)
StringRef - Represent a constant reference to a string, i.e.
bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const override
Return true if the basic block has exactly one predecessor and the control transfer mechanism between...
Address of indexed Constant in Constant Pool.
void setS27_2_reloc(MCExpr const &Expr, bool Val=true)
unsigned getOpcode() const
const MachineOperand & getOperand(unsigned i) const
Instances of this class represent operands of the MCInst class.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
static MCOperand createImm(int64_t Val)
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
Target & getTheHexagonTarget()
std::string utohexstr(uint64_t X, bool LowerCase=false)
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
void setExpr(const MCExpr *Val)