63 #define DEBUG_TYPE "asm-printer" 115 const char *ExtraCode,
118 if (ExtraCode && ExtraCode[0]) {
119 if (ExtraCode[1] != 0)
122 switch (ExtraCode[0]) {
135 if (Hexagon::DoubleRegsRegClass.
contains(RegNumber))
136 RegNumber = TRI->
getSubReg(RegNumber, ExtraCode[0] ==
'L' ?
157 const char *ExtraCode,
159 if (ExtraCode && ExtraCode[0])
170 if (Offset.
isImm()) {
172 O <<
"+#" << Offset.
getImm();
185 if (Imm.
getExpr()->evaluateAsAbsolute(Value)) {
187 std::string ImmString;
189 if (AlignSize == 8) {
190 Name =
".CONST_0000000000000000";
191 sectionPrefix =
".gnu.linkonce.l8";
194 Name =
".CONST_00000000";
195 sectionPrefix =
".gnu.linkonce.l4";
196 ImmString =
utohexstr(static_cast<uint32_t>(Value));
199 std::string symbolName =
200 Name.
drop_back(ImmString.size()).str() + ImmString;
201 std::string sectionName = sectionPrefix.
str() + symbolName;
215 assert(Imm.
isExpr() &&
"Expected expression and found none");
217 assert(MO.isGlobal() || MO.isCPI() || MO.isJTI());
229 std::string LitaName =
".CONST_" + SymbolName.
str();
257 int32_t V = cast<MCConstantExpr>(HE->getExpr())->getValue();
271 unsigned VectorSize = HRI.getRegSizeInBits(Hexagon::HvxVRRegClass) / 8;
277 case Hexagon::A2_iconst: {
290 case Hexagon::A2_tfrf: {
297 case Hexagon::A2_tfrt: {
304 case Hexagon::A2_tfrfnew: {
311 case Hexagon::A2_tfrtnew: {
318 case Hexagon::A2_zxtb: {
326 case Hexagon::CONST64:
333 OutStreamer->SwitchSection(Current.first, Current.second);
340 MappedInst = TmpInst;
349 OutStreamer->SwitchSection(Current.first, Current.second);
356 MappedInst = TmpInst;
363 case Hexagon::C2_pxfer_map: {
373 case Hexagon::M2_vrcmpys_acc_s1: {
375 assert(Rt.
isReg() &&
"Expected register and none was found");
376 unsigned Reg = RI->getEncodingValue(Rt.
getReg());
378 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_acc_s1_h);
380 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_acc_s1_l);
384 case Hexagon::M2_vrcmpys_s1: {
386 assert(Rt.
isReg() &&
"Expected register and none was found");
387 unsigned Reg = RI->getEncodingValue(Rt.
getReg());
389 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_s1_h);
391 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_s1_l);
396 case Hexagon::M2_vrcmpys_s1rp: {
398 assert(Rt.
isReg() &&
"Expected register and none was found");
399 unsigned Reg = RI->getEncodingValue(Rt.
getReg());
401 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_s1rp_h);
403 MappedInst.
setOpcode(Hexagon::M2_vrcmpys_s1rp_l);
408 case Hexagon::A4_boundscheck: {
410 assert(Rs.
isReg() &&
"Expected register and none was found");
411 unsigned Reg = RI->getEncodingValue(Rs.
getReg());
413 MappedInst.
setOpcode(Hexagon::A4_boundscheck_hi);
415 MappedInst.
setOpcode(Hexagon::A4_boundscheck_lo);
420 case Hexagon::PS_call_nr:
424 case Hexagon::S5_asrhub_rnd_sat_goodsyntax: {
428 bool Success = Expr->evaluateAsAbsolute(Imm);
429 assert(Success &&
"Expected immediate and none was found");
436 MappedInst = TmpInst;
439 TmpInst.
setOpcode(Hexagon::S5_asrhub_rnd_sat);
446 MappedInst = TmpInst;
450 case Hexagon::S5_vasrhrnd_goodsyntax:
451 case Hexagon::S2_asr_i_p_rnd_goodsyntax: {
455 bool Success = Expr->evaluateAsAbsolute(Imm);
456 assert(Success &&
"Expected immediate and none was found");
463 unsigned High = RI->getSubReg(MO1.
getReg(), Hexagon::isub_hi);
464 unsigned Low = RI->getSubReg(MO1.
getReg(), Hexagon::isub_lo);
468 MappedInst = TmpInst;
472 if (Inst.
getOpcode() == Hexagon::S2_asr_i_p_rnd_goodsyntax)
473 TmpInst.
setOpcode(Hexagon::S2_asr_i_p_rnd);
482 MappedInst = TmpInst;
487 case Hexagon::S2_asr_i_r_rnd_goodsyntax: {
491 bool Success = Expr->evaluateAsAbsolute(Imm);
492 assert(Success &&
"Expected immediate and none was found");
499 MappedInst = TmpInst;
502 TmpInst.
setOpcode(Hexagon::S2_asr_i_r_rnd);
509 MappedInst = TmpInst;
514 case Hexagon::A2_tfrpi: {
519 TmpInst.
setOpcode(Hexagon::A2_combineii);
523 if (Success && Imm < 0) {
533 MappedInst = TmpInst;
538 case Hexagon::A2_tfrp: {
540 unsigned High = RI->getSubReg(MO.
getReg(), Hexagon::isub_hi);
541 unsigned Low = RI->getSubReg(MO.
getReg(), Hexagon::isub_lo);
545 MappedInst.
setOpcode(Hexagon::A2_combinew);
549 case Hexagon::A2_tfrpt:
550 case Hexagon::A2_tfrpf: {
552 unsigned High = RI->getSubReg(MO.
getReg(), Hexagon::isub_hi);
553 unsigned Low = RI->getSubReg(MO.
getReg(), Hexagon::isub_lo);
558 ? Hexagon::C2_ccombinewt
559 : Hexagon::C2_ccombinewf);
563 case Hexagon::A2_tfrptnew:
564 case Hexagon::A2_tfrpfnew: {
566 unsigned High = RI->getSubReg(MO.
getReg(), Hexagon::isub_hi);
567 unsigned Low = RI->getSubReg(MO.
getReg(), Hexagon::isub_lo);
572 ? Hexagon::C2_ccombinewnewt
573 : Hexagon::C2_ccombinewnewf);
577 case Hexagon::M2_mpysmi: {
581 bool Success = Expr->evaluateAsAbsolute(Value);
585 MappedInst.
setOpcode(Hexagon::M2_mpysin);
589 MappedInst.
setOpcode(Hexagon::M2_mpysip);
593 case Hexagon::A2_addsp: {
595 assert(Rt.
isReg() &&
"Expected register and none was found");
596 unsigned Reg = RI->getEncodingValue(Rt.
getReg());
598 MappedInst.
setOpcode(Hexagon::A2_addsph);
600 MappedInst.
setOpcode(Hexagon::A2_addspl);
605 case Hexagon::V6_vd0: {
608 "Expected register and none was found");
614 MappedInst = TmpInst;
618 case Hexagon::V6_vdd0: {
621 "Expected register and none was found");
627 MappedInst = TmpInst;
631 case Hexagon::V6_vL32Ub_pi:
632 case Hexagon::V6_vL32b_cur_pi:
633 case Hexagon::V6_vL32b_nt_cur_pi:
634 case Hexagon::V6_vL32b_pi:
635 case Hexagon::V6_vL32b_nt_pi:
636 case Hexagon::V6_vL32b_nt_tmp_pi:
637 case Hexagon::V6_vL32b_tmp_pi:
641 case Hexagon::V6_vL32Ub_ai:
642 case Hexagon::V6_vL32b_ai:
643 case Hexagon::V6_vL32b_cur_ai:
644 case Hexagon::V6_vL32b_nt_ai:
645 case Hexagon::V6_vL32b_nt_cur_ai:
646 case Hexagon::V6_vL32b_nt_tmp_ai:
647 case Hexagon::V6_vL32b_tmp_ai:
651 case Hexagon::V6_vS32Ub_pi:
652 case Hexagon::V6_vS32b_new_pi:
653 case Hexagon::V6_vS32b_nt_new_pi:
654 case Hexagon::V6_vS32b_nt_pi:
655 case Hexagon::V6_vS32b_pi:
659 case Hexagon::V6_vS32Ub_ai:
660 case Hexagon::V6_vS32b_ai:
661 case Hexagon::V6_vS32b_new_ai:
662 case Hexagon::V6_vS32b_nt_ai:
663 case Hexagon::V6_vS32b_nt_new_ai:
667 case Hexagon::V6_vL32b_cur_npred_pi:
668 case Hexagon::V6_vL32b_cur_pred_pi:
669 case Hexagon::V6_vL32b_npred_pi:
670 case Hexagon::V6_vL32b_nt_cur_npred_pi:
671 case Hexagon::V6_vL32b_nt_cur_pred_pi:
672 case Hexagon::V6_vL32b_nt_npred_pi:
673 case Hexagon::V6_vL32b_nt_pred_pi:
674 case Hexagon::V6_vL32b_nt_tmp_npred_pi:
675 case Hexagon::V6_vL32b_nt_tmp_pred_pi:
676 case Hexagon::V6_vL32b_pred_pi:
677 case Hexagon::V6_vL32b_tmp_npred_pi:
678 case Hexagon::V6_vL32b_tmp_pred_pi:
682 case Hexagon::V6_vL32b_cur_npred_ai:
683 case Hexagon::V6_vL32b_cur_pred_ai:
684 case Hexagon::V6_vL32b_npred_ai:
685 case Hexagon::V6_vL32b_nt_cur_npred_ai:
686 case Hexagon::V6_vL32b_nt_cur_pred_ai:
687 case Hexagon::V6_vL32b_nt_npred_ai:
688 case Hexagon::V6_vL32b_nt_pred_ai:
689 case Hexagon::V6_vL32b_nt_tmp_npred_ai:
690 case Hexagon::V6_vL32b_nt_tmp_pred_ai:
691 case Hexagon::V6_vL32b_pred_ai:
692 case Hexagon::V6_vL32b_tmp_npred_ai:
693 case Hexagon::V6_vL32b_tmp_pred_ai:
697 case Hexagon::V6_vS32Ub_npred_pi:
698 case Hexagon::V6_vS32Ub_pred_pi:
699 case Hexagon::V6_vS32b_new_npred_pi:
700 case Hexagon::V6_vS32b_new_pred_pi:
701 case Hexagon::V6_vS32b_npred_pi:
702 case Hexagon::V6_vS32b_nqpred_pi:
703 case Hexagon::V6_vS32b_nt_new_npred_pi:
704 case Hexagon::V6_vS32b_nt_new_pred_pi:
705 case Hexagon::V6_vS32b_nt_npred_pi:
706 case Hexagon::V6_vS32b_nt_nqpred_pi:
707 case Hexagon::V6_vS32b_nt_pred_pi:
708 case Hexagon::V6_vS32b_nt_qpred_pi:
709 case Hexagon::V6_vS32b_pred_pi:
710 case Hexagon::V6_vS32b_qpred_pi:
714 case Hexagon::V6_vS32Ub_npred_ai:
715 case Hexagon::V6_vS32Ub_pred_ai:
716 case Hexagon::V6_vS32b_new_npred_ai:
717 case Hexagon::V6_vS32b_new_pred_ai:
718 case Hexagon::V6_vS32b_npred_ai:
719 case Hexagon::V6_vS32b_nqpred_ai:
720 case Hexagon::V6_vS32b_nt_new_npred_ai:
721 case Hexagon::V6_vS32b_nt_new_pred_ai:
722 case Hexagon::V6_vS32b_nt_npred_ai:
723 case Hexagon::V6_vS32b_nt_nqpred_ai:
724 case Hexagon::V6_vS32b_nt_pred_ai:
725 case Hexagon::V6_vS32b_nt_qpred_ai:
726 case Hexagon::V6_vS32b_pred_ai:
727 case Hexagon::V6_vS32b_qpred_ai:
732 case Hexagon::V6_vS32b_srls_ai:
736 case Hexagon::V6_vS32b_srls_pi:
753 for (++MII; MII != MBB->
instr_end() && MII->isInsideBundle(); ++MII)
754 if (!MII->isDebugInstr() && !MII->isImplicitDef())
762 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 ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
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.
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
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
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...
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)
Register getSubReg(MCRegister Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
const MCExpr * getExpr() const
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.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
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.
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.
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.
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 printOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O)
Iterator for intrusive lists based on ilist_node.
void setOpcode(unsigned Op)
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
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...
#define LLVM_EXTERNAL_VISIBILITY
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.
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS) override
PrintAsmOperand - Print out an operand for an inline asm expression.
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.
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
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
LLVM_NODISCARD StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
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...
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonAsmPrinter()
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.
Register getReg() const
getReg - Returns the register number.
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)
Target & getTheHexagonTarget()
Wrapper class representing virtual and physical registers.
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)