68#define DEBUG_TYPE "mips-asm-parser"
78class MipsAssemblerOptions {
80 MipsAssemblerOptions(
const FeatureBitset &Features_) : Features(Features_) {}
82 MipsAssemblerOptions(
const MipsAssemblerOptions *Opts) {
83 ATReg = Opts->getATRegIndex();
84 Reorder = Opts->isReorder();
85 Macro = Opts->isMacro();
86 Features = Opts->getFeatures();
89 unsigned getATRegIndex()
const {
return ATReg; }
90 bool setATRegIndex(
unsigned Reg) {
98 bool isReorder()
const {
return Reorder; }
99 void setReorder() { Reorder =
true; }
100 void setNoReorder() { Reorder =
false; }
102 bool isMacro()
const {
return Macro; }
103 void setMacro() {
Macro =
true; }
104 void setNoMacro() {
Macro =
false; }
106 const FeatureBitset &
getFeatures()
const {
return Features; }
107 void setFeatures(
const FeatureBitset &Features_) { Features = Features_; }
114 static const FeatureBitset AllArchRelatedMask;
120 FeatureBitset Features;
125const FeatureBitset MipsAssemblerOptions::AllArchRelatedMask = {
126 Mips::FeatureMips1, Mips::FeatureMips2, Mips::FeatureMips3,
127 Mips::FeatureMips3_32, Mips::FeatureMips3_32r2, Mips::FeatureMips4,
128 Mips::FeatureMips4_32, Mips::FeatureMips4_32r2, Mips::FeatureMips5,
129 Mips::FeatureMips5_32r2, Mips::FeatureMips32, Mips::FeatureMips32r2,
130 Mips::FeatureMips32r3, Mips::FeatureMips32r5, Mips::FeatureMips32r6,
131 Mips::FeatureMips64, Mips::FeatureMips64r2, Mips::FeatureMips64r3,
132 Mips::FeatureMips64r5, Mips::FeatureMips64r6, Mips::FeatureCnMips,
133 Mips::FeatureCnMipsP, Mips::FeatureFP64Bit, Mips::FeatureGP64Bit,
134 Mips::FeatureNaN2008, Mips::FeatureNanoMips};
139 MipsTargetStreamer &getTargetStreamer() {
140 assert(getParser().getStreamer().getTargetStreamer() &&
141 "do not have a target streamer");
142 MCTargetStreamer &TS = *getParser().getStreamer().getTargetStreamer();
143 return static_cast<MipsTargetStreamer &
>(TS);
146 const MipsMCOptions &CLOpts;
156 bool CurForbiddenSlotAttr;
159 MipsTargetStreamer *TS;
162 DenseMap<const MCSection *, SmallVector<MCInst, 2>> RecentInsts;
166 bool InMacroExpansion =
false;
167 unsigned MacroInsts = 0;
169 unsigned CpSaveLocation;
171 bool CpSaveLocationIsRegister;
174 StringMap<AsmToken> RegisterSets;
177 void printWarningWithFixIt(
const Twine &
Msg,
const Twine &FixMsg,
178 SMRange
Range,
bool ShowColors =
true);
181 template <
unsigned Opcode,
bool IsMFTR>
182 void ConvertMTTransferCOP0Operands(MCInst &Inst,
185 ConvertMTTransferCOP0Operands<Mips::MFTR, true>(Inst,
Operands);
188 ConvertMTTransferCOP0Operands<Mips::MTTR, false>(Inst,
Operands);
191#define GET_ASSEMBLER_HEADER
192#include "MipsGenAsmMatcher.inc"
195 checkEarlyTargetMatchPredicate(
MCInst &Inst,
197 unsigned checkTargetMatchPredicate(
MCInst &Inst)
override;
199 bool matchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
202 bool MatchingInlineAsm)
override;
207 SMLoc &EndLoc)
override;
213 bool mnemonicIsValid(
StringRef Mnemonic,
unsigned VariantID);
218 bool ParseDirective(
AsmToken DirectiveID)
override;
222 const MCExpr *parseMemOffset();
233 const MCExpr *parseRelocExpr();
234 bool parsePrimaryExpr(
const MCExpr *&Res,
SMLoc &EndLoc)
override;
240 enum MacroExpanderResultTy {
247 MacroExpanderResultTy tryExpandInstruction(MCInst &Inst, SMLoc IDLoc,
249 const MCSubtargetInfo *STI);
251 bool expandJalWithRegs(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
252 const MCSubtargetInfo *STI);
254 bool loadImmediate(int64_t ImmValue, MCRegister DstReg, MCRegister SrcReg,
255 bool Is32BitImm,
bool IsAddress, SMLoc IDLoc,
256 MCStreamer &Out,
const MCSubtargetInfo *STI);
258 bool canDeferGOTLoad(
const MCSymbol *Sym);
260 bool loadAndAddSymbolAddress(
const MCExpr *SymExpr, MCRegister DstReg,
261 MCRegister SrcReg,
bool Is32BitSym, SMLoc IDLoc,
262 MCStreamer &Out,
const MCSubtargetInfo *STI);
264 bool emitPartialAddress(MipsTargetStreamer &TOut, SMLoc IDLoc, MCSymbol *Sym);
266 bool expandLoadImm(MCInst &Inst,
bool Is32BitImm, SMLoc IDLoc,
267 MCStreamer &Out,
const MCSubtargetInfo *STI);
269 bool expandLoadSingleImmToGPR(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
270 const MCSubtargetInfo *STI);
271 bool expandLoadSingleImmToFPR(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
272 const MCSubtargetInfo *STI);
273 bool expandLoadDoubleImmToGPR(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
274 const MCSubtargetInfo *STI);
275 bool expandLoadDoubleImmToFPR(MCInst &Inst,
bool Is64FPU, SMLoc IDLoc,
276 MCStreamer &Out,
const MCSubtargetInfo *STI);
278 bool expandLoadAddress(MCRegister DstReg, MCRegister BaseReg,
279 const MCOperand &
Offset,
bool Is32BitAddress,
280 SMLoc IDLoc, MCStreamer &Out,
281 const MCSubtargetInfo *STI);
283 bool expandUncondBranchMMPseudo(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
284 const MCSubtargetInfo *STI);
286 void expandMem16Inst(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
287 const MCSubtargetInfo *STI,
bool IsLoad);
288 void expandMem9Inst(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
289 const MCSubtargetInfo *STI,
bool IsLoad);
291 bool expandLoadStoreMultiple(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
292 const MCSubtargetInfo *STI);
294 bool expandAliasImmediate(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
295 const MCSubtargetInfo *STI);
297 bool expandBranchImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
298 const MCSubtargetInfo *STI);
300 bool expandCondBranches(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
301 const MCSubtargetInfo *STI);
303 bool expandDivRem(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
304 const MCSubtargetInfo *STI,
const bool IsMips64,
307 bool expandTrunc(MCInst &Inst,
bool IsDouble,
bool Is64FPU, SMLoc IDLoc,
308 MCStreamer &Out,
const MCSubtargetInfo *STI);
310 bool expandUlh(MCInst &Inst,
bool Signed, SMLoc IDLoc, MCStreamer &Out,
311 const MCSubtargetInfo *STI);
313 bool expandUsh(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
314 const MCSubtargetInfo *STI);
316 bool expandUxw(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
317 const MCSubtargetInfo *STI);
319 bool expandSge(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
320 const MCSubtargetInfo *STI);
322 bool expandSgeImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
323 const MCSubtargetInfo *STI);
325 bool expandSgtImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
326 const MCSubtargetInfo *STI);
328 bool expandSle(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
329 const MCSubtargetInfo *STI);
331 bool expandSleImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
332 const MCSubtargetInfo *STI);
334 bool expandRotation(MCInst &Inst, SMLoc IDLoc,
335 MCStreamer &Out,
const MCSubtargetInfo *STI);
336 bool expandRotationImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
337 const MCSubtargetInfo *STI);
338 bool expandDRotation(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
339 const MCSubtargetInfo *STI);
340 bool expandDRotationImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
341 const MCSubtargetInfo *STI);
343 bool expandAbs(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
344 const MCSubtargetInfo *STI);
346 bool expandMulImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
347 const MCSubtargetInfo *STI);
349 bool expandMulO(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
350 const MCSubtargetInfo *STI);
352 bool expandMulOU(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
353 const MCSubtargetInfo *STI);
355 bool expandMULMacro(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
356 const MCSubtargetInfo *STI);
358 bool expandLoadStoreDMacro(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
359 const MCSubtargetInfo *STI,
bool IsLoad);
361 bool expandLoadStoreDM1Macro(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
362 const MCSubtargetInfo *STI,
bool IsLoad);
364 bool expandSeq(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
365 const MCSubtargetInfo *STI);
367 bool expandSeqI(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
368 const MCSubtargetInfo *STI);
370 bool expandSne(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
371 const MCSubtargetInfo *STI);
373 bool expandSneI(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
374 const MCSubtargetInfo *STI);
376 bool expandMXTRAlias(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
377 const MCSubtargetInfo *STI);
379 bool expandSaaAddr(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
380 const MCSubtargetInfo *STI);
382 bool reportParseError(
const Twine &ErrorMsg);
383 bool reportParseError(SMLoc Loc,
const Twine &ErrorMsg);
385 bool parseSetMips0Directive();
386 bool parseSetArchDirective();
387 bool parseSetFeature(
uint64_t Feature);
388 bool isPicAndNotNxxAbi();
389 bool parseDirectiveCpAdd(SMLoc Loc);
390 bool parseDirectiveCpLoad(SMLoc Loc);
391 bool parseDirectiveCpLocal(SMLoc Loc);
392 bool parseDirectiveCpRestore(SMLoc Loc);
393 bool parseDirectiveCPSetup();
394 bool parseDirectiveCPReturn();
395 bool parseDirectiveNaN();
396 bool parseDirectiveSet();
397 bool parseDirectiveOption();
398 bool parseInsnDirective();
399 bool parseRSectionDirective(StringRef Section);
400 bool parseSSectionDirective(StringRef Section,
unsigned Type);
402 bool parseSetAtDirective();
403 bool parseSetNoAtDirective();
404 bool parseSetMacroDirective();
405 bool parseSetNoMacroDirective();
406 bool parseSetMsaDirective();
407 bool parseSetNoMsaDirective();
408 bool parseSetNoDspDirective();
409 bool parseSetNoMips3DDirective();
410 bool parseSetReorderDirective();
411 bool parseSetNoReorderDirective();
412 bool parseSetMips16Directive();
413 bool parseSetNoMips16Directive();
414 bool parseSetFpDirective();
415 bool parseSetOddSPRegDirective();
416 bool parseSetNoOddSPRegDirective();
417 bool parseSetPopDirective();
418 bool parseSetPushDirective();
419 bool parseSetSoftFloatDirective();
420 bool parseSetHardFloatDirective();
421 bool parseSetMtDirective();
422 bool parseSetNoMtDirective();
423 bool parseSetNoCRCDirective();
424 bool parseSetNoVirtDirective();
425 bool parseSetNoGINVDirective();
426 bool parseSetNoEVADirective();
428 bool parseSetAssignment();
430 bool parseDirectiveGpWord();
431 bool parseDirectiveGpDWord();
432 bool parseDirectiveDtpRelWord();
433 bool parseDirectiveDtpRelDWord();
434 bool parseDirectiveTpRelWord();
435 bool parseDirectiveTpRelDWord();
436 bool parseDirectiveModule();
437 bool parseDirectiveModuleFP();
439 StringRef Directive);
441 bool parseInternalDirectiveReallowModule();
443 bool eatComma(StringRef ErrorStr);
445 int matchCPURegisterName(StringRef Symbol);
447 int matchHWRegsRegisterName(StringRef Symbol);
449 int matchFPURegisterName(StringRef Name);
451 int matchFCCRegisterName(StringRef Name);
453 int matchACRegisterName(StringRef Name);
455 int matchMSA128RegisterName(StringRef Name);
457 int matchMSA128CtrlRegisterName(StringRef Name);
459 MCRegister
getReg(
int RC,
int RegNo);
464 MCRegister getATReg(SMLoc Loc);
468 bool processInstruction(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
469 const MCSubtargetInfo *STI);
493 void selectArch(StringRef ArchFeature) {
494 MCSubtargetInfo &STI = copySTI();
496 FeatureBitset FeatureBits = OldFeatures;
497 FeatureBits &= ~MipsAssemblerOptions::AllArchRelatedMask;
499 setAvailableFeatures(
502 emitHazardNopsForISAChange(OldFeatures);
505 void setFeatureBits(
uint64_t Feature, StringRef FeatureString) {
507 FeatureBitset OldFeatures = getSTI().getFeatureBits();
508 MCSubtargetInfo &STI = copySTI();
509 setAvailableFeatures(
512 emitHazardNopsForISAChange(OldFeatures);
516 void clearFeatureBits(
uint64_t Feature, StringRef FeatureString) {
518 FeatureBitset OldFeatures = getSTI().getFeatureBits();
519 MCSubtargetInfo &STI = copySTI();
520 setAvailableFeatures(
523 emitHazardNopsForISAChange(OldFeatures);
527 void setModuleFeatureBits(
uint64_t Feature, StringRef FeatureString) {
528 setFeatureBits(Feature, FeatureString);
529 AssemblerOptions.front()->setFeatures(getSTI().getFeatureBits());
532 void clearModuleFeatureBits(
uint64_t Feature, StringRef FeatureString) {
533 clearFeatureBits(Feature, FeatureString);
534 AssemblerOptions.front()->setFeatures(getSTI().getFeatureBits());
538 enum MipsMatchResultTy {
539 Match_RequiresDifferentSrcAndDst = FIRST_TARGET_MATCH_RESULT_TY,
540 Match_RequiresDifferentOperands,
541 Match_RequiresNoZeroRegister,
542 Match_RequiresSameSrcAndDst,
543 Match_NoFCCRegisterForCurrentISA,
544 Match_NonZeroOperandForSync,
545 Match_NonZeroOperandForMTCX,
546 Match_RequiresPosSizeRange0_32,
547 Match_RequiresPosSizeRange33_64,
548 Match_RequiresPosSizeUImm6,
549#define GET_OPERAND_DIAGNOSTIC_TYPES
550#include "MipsGenAsmMatcher.inc"
551#undef GET_OPERAND_DIAGNOSTIC_TYPES
554 MipsAsmParser(
const MCSubtargetInfo &sti, MCAsmParser &parser,
555 const MCInstrInfo &MII)
556 : MCTargetAsmParser(sti, MII),
559 sti.getTargetTriple(),
569 setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
572 AssemblerOptions.push_back(
573 std::make_unique<MipsAssemblerOptions>(getSTI().getFeatureBits()));
576 AssemblerOptions.push_back(
577 std::make_unique<MipsAssemblerOptions>(getSTI().getFeatureBits()));
579 TS = &getTargetStreamer();
580 TS->updateABIInfo(*
this);
581 TS->setInstEmitter(
this);
583 if (!isABI_O32() && !useOddSPReg() != 0)
588 CurForbiddenSlotAttr =
false;
589 IsPicEnabled =
getContext().getObjectFileInfo()->isPositionIndependent();
591 IsCpRestoreSet =
false;
592 CpRestoreOffset = -1;
593 GPReg = ABI.GetGlobalPtr();
598 if (getSTI().
getCPU() ==
"mips64r6" && inMicroMipsMode())
601 if (!isABI_O32() && inMicroMipsMode())
605 ~MipsAsmParser()
override {
606 if (TS->getInstEmitter() ==
this)
607 TS->setInstEmitter(
nullptr);
612 void emitInstruction(
const MCInst &Inst,
const MCSubtargetInfo &STI)
override;
615 bool hasEightFccRegisters()
const {
return hasMips4() || hasMips32(); }
617 bool isGP64bit()
const {
618 return getSTI().hasFeature(Mips::FeatureGP64Bit);
621 bool isFP64bit()
const {
622 return getSTI().hasFeature(Mips::FeatureFP64Bit);
625 bool isJalrRelocAvailable(
const MCExpr *JalExpr) {
626 if (!CLOpts.jalr_reloc)
634 return ABI.IsN32() || ABI.IsN64();
638 const MipsABIInfo &
getABI()
const {
return ABI; }
639 bool isABI_N32()
const {
return ABI.IsN32(); }
640 bool isABI_N64()
const {
return ABI.IsN64(); }
641 bool isABI_O32()
const {
return ABI.IsO32(); }
642 bool isABI_FPXX()
const {
643 return getSTI().hasFeature(Mips::FeatureFPXX);
646 bool useOddSPReg()
const {
647 return !(getSTI().hasFeature(Mips::FeatureNoOddSPReg));
650 bool inMicroMipsMode()
const {
651 return getSTI().hasFeature(Mips::FeatureMicroMips);
654 bool hasMips1()
const {
655 return getSTI().hasFeature(Mips::FeatureMips1);
658 bool hasMips2()
const {
659 return getSTI().hasFeature(Mips::FeatureMips2);
662 bool hasMips3()
const {
663 return getSTI().hasFeature(Mips::FeatureMips3);
666 bool hasMips4()
const {
667 return getSTI().hasFeature(Mips::FeatureMips4);
670 bool hasMips5()
const {
671 return getSTI().hasFeature(Mips::FeatureMips5);
674 bool hasMips32()
const {
675 return getSTI().hasFeature(Mips::FeatureMips32);
678 bool hasMips64()
const {
679 return getSTI().hasFeature(Mips::FeatureMips64);
682 bool hasMips32r2()
const {
683 return getSTI().hasFeature(Mips::FeatureMips32r2);
686 bool hasMips64r2()
const {
687 return getSTI().hasFeature(Mips::FeatureMips64r2);
690 bool hasMips32r3()
const {
691 return (getSTI().
hasFeature(Mips::FeatureMips32r3));
694 bool hasMips64r3()
const {
695 return (getSTI().
hasFeature(Mips::FeatureMips64r3));
698 bool hasMips32r5()
const {
699 return (getSTI().
hasFeature(Mips::FeatureMips32r5));
702 bool hasMips64r5()
const {
703 return (getSTI().
hasFeature(Mips::FeatureMips64r5));
706 bool hasMips32r6()
const {
707 return getSTI().hasFeature(Mips::FeatureMips32r6);
710 bool hasMips64r6()
const {
711 return getSTI().hasFeature(Mips::FeatureMips64r6);
714 bool hasNanoMips()
const {
715 return getSTI().hasFeature(Mips::FeatureNanoMips);
718 bool hasDSP()
const {
719 return getSTI().hasFeature(Mips::FeatureDSP);
722 bool hasDSPR2()
const {
723 return getSTI().hasFeature(Mips::FeatureDSPR2);
726 bool hasDSPR3()
const {
727 return getSTI().hasFeature(Mips::FeatureDSPR3);
730 bool hasMSA()
const {
731 return getSTI().hasFeature(Mips::FeatureMSA);
734 bool hasCnMips()
const {
735 return (getSTI().
hasFeature(Mips::FeatureCnMips));
738 bool hasCnMipsP()
const {
739 return (getSTI().
hasFeature(Mips::FeatureCnMipsP));
742 bool isR5900()
const {
return (getSTI().
hasFeature(Mips::FeatureR5900)); }
748 bool inMips16Mode()
const {
749 return getSTI().hasFeature(Mips::FeatureMips16);
752 bool useTraps()
const {
753 return getSTI().hasFeature(Mips::FeatureUseTCCInDIV);
756 bool useSoftFloat()
const {
757 return getSTI().hasFeature(Mips::FeatureSoftFloat);
760 bool isSingleFloat()
const {
761 return getSTI().hasFeature(Mips::FeatureSingleFloat);
765 return getSTI().hasFeature(Mips::FeatureMT);
768 bool hasCRC()
const {
769 return getSTI().hasFeature(Mips::FeatureCRC);
772 bool hasVirt()
const {
773 return getSTI().hasFeature(Mips::FeatureVirt);
776 bool hasGINV()
const {
777 return getSTI().hasFeature(Mips::FeatureGINV);
780 bool hasForbiddenSlot(
const MCInstrDesc &MCID)
const {
784 bool SafeInForbiddenSlot(
const MCInstrDesc &MCID)
const {
788 void onEndOfFile()
override;
791 bool hasHazards()
const {
792 return !hasMips32() && !inMicroMipsMode() && !inMips16Mode();
794 unsigned getInstsBetween(
const MCInst &
First,
const MCInst *Second);
795 unsigned getHazardNops(
const MCInst *
Next,
unsigned Window = 2);
796 void emitHazardNops(
unsigned Count,
const MCSubtargetInfo &STI);
798 void emitHazardNopsBefore(
const MCInst &Inst,
const MCSubtargetInfo &STI);
801 void emitPendingHazardNops();
806 void emitHazardNopsForISAChange(
const FeatureBitset &OldFeatures);
809 void warnIfRegIndexIsAT(MCRegister RegIndex, SMLoc Loc);
811 void warnIfNoMacro(SMLoc Loc);
813 bool isLittle()
const {
return IsLittleEndian; }
815 bool areEqualRegs(
const MCParsedAsmOperand &Op1,
816 const MCParsedAsmOperand &Op2)
const override;
831 RegKind_MSACtrl = 16,
836 RegKind_HWRegs = 256,
840 RegKind_Numeric = RegKind_GPR | RegKind_FGR | RegKind_FCC | RegKind_MSA128 |
841 RegKind_MSACtrl | RegKind_COP2 | RegKind_ACC |
842 RegKind_CCR | RegKind_HWRegs | RegKind_COP3 | RegKind_COP0
855 MipsOperand(KindTy K, MipsAsmParser &Parser) : Kind(
K), AsmParser(Parser) {}
857 ~MipsOperand()
override {
866 case k_RegisterIndex:
874 MipsAsmParser &AsmParser;
885 const MCRegisterInfo *RegInfo;
903 struct RegIdxOp RegIdx;
906 struct RegListOp RegList;
909 SMLoc StartLoc, EndLoc;
912 static std::unique_ptr<MipsOperand> CreateReg(
unsigned Index, StringRef Str,
914 const MCRegisterInfo *RegInfo,
916 MipsAsmParser &Parser) {
917 auto Op = std::make_unique<MipsOperand>(k_RegisterIndex, Parser);
919 Op->RegIdx.RegInfo = RegInfo;
920 Op->RegIdx.Kind = RegKind;
921 Op->RegIdx.Tok.Data = Str.data();
922 Op->RegIdx.Tok.Length = Str.size();
931 MCRegister getGPR32Reg()
const {
932 assert(isRegIdx() && (RegIdx.Kind & RegKind_GPR) &&
"Invalid access!");
933 AsmParser.warnIfRegIndexIsAT(RegIdx.Index, StartLoc);
934 unsigned ClassID = Mips::GPR32RegClassID;
935 return RegIdx.RegInfo->getRegClass(ClassID).getRegister(RegIdx.Index);
940 MCRegister getGPRMM16Reg()
const {
941 assert(isRegIdx() && (RegIdx.Kind & RegKind_GPR) &&
"Invalid access!");
942 unsigned ClassID = Mips::GPR32RegClassID;
943 return RegIdx.RegInfo->getRegClass(ClassID).getRegister(RegIdx.Index);
948 MCRegister getGPR64Reg()
const {
949 assert(isRegIdx() && (RegIdx.Kind & RegKind_GPR) &&
"Invalid access!");
950 unsigned ClassID = Mips::GPR64RegClassID;
951 return RegIdx.RegInfo->getRegClass(ClassID).getRegister(RegIdx.Index);
957 MCRegister getAFGR64Reg()
const {
958 assert(isRegIdx() && (RegIdx.Kind & RegKind_FGR) &&
"Invalid access!");
959 if (RegIdx.Index % 2 != 0)
960 AsmParser.Warning(StartLoc,
"Float register should be even.");
961 return RegIdx.RegInfo->getRegClass(Mips::AFGR64RegClassID)
962 .getRegister(RegIdx.Index / 2);
967 MCRegister getFGR64Reg()
const {
968 assert(isRegIdx() && (RegIdx.Kind & RegKind_FGR) &&
"Invalid access!");
969 return RegIdx.RegInfo->getRegClass(Mips::FGR64RegClassID)
970 .getRegister(RegIdx.Index);
975 MCRegister getFGR32Reg()
const {
976 assert(isRegIdx() && (RegIdx.Kind & RegKind_FGR) &&
"Invalid access!");
977 return RegIdx.RegInfo->getRegClass(Mips::FGR32RegClassID)
978 .getRegister(RegIdx.Index);
983 MCRegister getFCCReg()
const {
984 assert(isRegIdx() && (RegIdx.Kind & RegKind_FCC) &&
"Invalid access!");
985 return RegIdx.RegInfo->getRegClass(Mips::FCCRegClassID)
986 .getRegister(RegIdx.Index);
991 MCRegister getMSA128Reg()
const {
992 assert(isRegIdx() && (RegIdx.Kind & RegKind_MSA128) &&
"Invalid access!");
995 unsigned ClassID = Mips::MSA128BRegClassID;
996 return RegIdx.RegInfo->getRegClass(ClassID).getRegister(RegIdx.Index);
1001 MCRegister getMSACtrlReg()
const {
1002 assert(isRegIdx() && (RegIdx.Kind & RegKind_MSACtrl) &&
"Invalid access!");
1003 unsigned ClassID = Mips::MSACtrlRegClassID;
1004 return RegIdx.RegInfo->getRegClass(ClassID).getRegister(RegIdx.Index);
1009 MCRegister getCOP0Reg()
const {
1015 MCRegister getCOP2Reg()
const {
1016 assert(isRegIdx() && (RegIdx.Kind & RegKind_COP2) &&
"Invalid access!");
1017 unsigned ClassID = Mips::COP2RegClassID;
1018 return RegIdx.RegInfo->getRegClass(ClassID).getRegister(RegIdx.Index);
1023 MCRegister getCOP3Reg()
const {
1024 assert(isRegIdx() && (RegIdx.Kind & RegKind_COP3) &&
"Invalid access!");
1025 unsigned ClassID = Mips::COP3RegClassID;
1026 return RegIdx.RegInfo->getRegClass(ClassID).getRegister(RegIdx.Index);
1031 MCRegister getACC64DSPReg()
const {
1032 assert(isRegIdx() && (RegIdx.Kind & RegKind_ACC) &&
"Invalid access!");
1033 unsigned ClassID = Mips::ACC64DSPRegClassID;
1034 return RegIdx.RegInfo->getRegClass(ClassID).getRegister(RegIdx.Index);
1039 MCRegister getHI32DSPReg()
const {
1040 assert(isRegIdx() && (RegIdx.Kind & RegKind_ACC) &&
"Invalid access!");
1041 unsigned ClassID = Mips::HI32DSPRegClassID;
1042 return RegIdx.RegInfo->getRegClass(ClassID).getRegister(RegIdx.Index);
1047 MCRegister getLO32DSPReg()
const {
1048 assert(isRegIdx() && (RegIdx.Kind & RegKind_ACC) &&
"Invalid access!");
1049 unsigned ClassID = Mips::LO32DSPRegClassID;
1050 return RegIdx.RegInfo->getRegClass(ClassID).getRegister(RegIdx.Index);
1055 MCRegister getCCRReg()
const {
1056 assert(isRegIdx() && (RegIdx.Kind & RegKind_CCR) &&
"Invalid access!");
1057 unsigned ClassID = Mips::CCRRegClassID;
1058 return RegIdx.RegInfo->getRegClass(ClassID).getRegister(RegIdx.Index);
1063 MCRegister getHWRegsReg()
const {
1064 assert(isRegIdx() && (RegIdx.Kind & RegKind_HWRegs) &&
"Invalid access!");
1065 unsigned ClassID = Mips::HWRegsRegClassID;
1066 return RegIdx.RegInfo->getRegClass(ClassID).getRegister(RegIdx.Index);
1070 void addExpr(MCInst &Inst,
const MCExpr *Expr)
const {
1080 void addRegOperands(MCInst &Inst,
unsigned N)
const {
1087 void addGPR32ZeroAsmRegOperands(MCInst &Inst,
unsigned N)
const {
1088 assert(
N == 1 &&
"Invalid number of operands!");
1092 void addGPR32NonZeroAsmRegOperands(MCInst &Inst,
unsigned N)
const {
1093 assert(
N == 1 &&
"Invalid number of operands!");
1097 void addGPR32AsmRegOperands(MCInst &Inst,
unsigned N)
const {
1098 assert(
N == 1 &&
"Invalid number of operands!");
1102 void addGPRMM16AsmRegOperands(MCInst &Inst,
unsigned N)
const {
1103 assert(
N == 1 &&
"Invalid number of operands!");
1107 void addGPRMM16AsmRegZeroOperands(MCInst &Inst,
unsigned N)
const {
1108 assert(
N == 1 &&
"Invalid number of operands!");
1112 void addGPRMM16AsmRegMovePOperands(MCInst &Inst,
unsigned N)
const {
1113 assert(
N == 1 &&
"Invalid number of operands!");
1117 void addGPRMM16AsmRegMovePPairFirstOperands(MCInst &Inst,
unsigned N)
const {
1118 assert(
N == 1 &&
"Invalid number of operands!");
1122 void addGPRMM16AsmRegMovePPairSecondOperands(MCInst &Inst,
1124 assert(
N == 1 &&
"Invalid number of operands!");
1131 void addGPR64AsmRegOperands(MCInst &Inst,
unsigned N)
const {
1132 assert(
N == 1 &&
"Invalid number of operands!");
1136 void addAFGR64AsmRegOperands(MCInst &Inst,
unsigned N)
const {
1137 assert(
N == 1 &&
"Invalid number of operands!");
1141 void addStrictlyAFGR64AsmRegOperands(MCInst &Inst,
unsigned N)
const {
1142 assert(
N == 1 &&
"Invalid number of operands!");
1146 void addStrictlyFGR64AsmRegOperands(MCInst &Inst,
unsigned N)
const {
1147 assert(
N == 1 &&
"Invalid number of operands!");
1151 void addFGR64AsmRegOperands(MCInst &Inst,
unsigned N)
const {
1152 assert(
N == 1 &&
"Invalid number of operands!");
1156 void addFGR32AsmRegOperands(MCInst &Inst,
unsigned N)
const {
1157 assert(
N == 1 &&
"Invalid number of operands!");
1161 if (!AsmParser.useOddSPReg() && RegIdx.Index & 1)
1162 AsmParser.getParser().printError(
1163 StartLoc,
"-mno-odd-spreg prohibits the use of odd FPU "
1167 void addStrictlyFGR32AsmRegOperands(MCInst &Inst,
unsigned N)
const {
1168 assert(
N == 1 &&
"Invalid number of operands!");
1171 if (!AsmParser.useOddSPReg() && RegIdx.Index & 1)
1172 AsmParser.Error(StartLoc,
"-mno-odd-spreg prohibits the use of odd FPU "
1176 void addFCCAsmRegOperands(MCInst &Inst,
unsigned N)
const {
1177 assert(
N == 1 &&
"Invalid number of operands!");
1181 void addMSA128AsmRegOperands(MCInst &Inst,
unsigned N)
const {
1182 assert(
N == 1 &&
"Invalid number of operands!");
1186 void addMSACtrlAsmRegOperands(MCInst &Inst,
unsigned N)
const {
1187 assert(
N == 1 &&
"Invalid number of operands!");
1191 void addCOP0AsmRegOperands(MCInst &Inst,
unsigned N)
const {
1192 assert(
N == 1 &&
"Invalid number of operands!");
1196 void addCOP2AsmRegOperands(MCInst &Inst,
unsigned N)
const {
1197 assert(
N == 1 &&
"Invalid number of operands!");
1201 void addCOP3AsmRegOperands(MCInst &Inst,
unsigned N)
const {
1202 assert(
N == 1 &&
"Invalid number of operands!");
1206 void addACC64DSPAsmRegOperands(MCInst &Inst,
unsigned N)
const {
1207 assert(
N == 1 &&
"Invalid number of operands!");
1211 void addHI32DSPAsmRegOperands(MCInst &Inst,
unsigned N)
const {
1212 assert(
N == 1 &&
"Invalid number of operands!");
1216 void addLO32DSPAsmRegOperands(MCInst &Inst,
unsigned N)
const {
1217 assert(
N == 1 &&
"Invalid number of operands!");
1221 void addCCRAsmRegOperands(MCInst &Inst,
unsigned N)
const {
1222 assert(
N == 1 &&
"Invalid number of operands!");
1226 void addHWRegsAsmRegOperands(MCInst &Inst,
unsigned N)
const {
1227 assert(
N == 1 &&
"Invalid number of operands!");
1231 template <
unsigned Bits,
int Offset = 0,
int AdjustOffset = 0>
1232 void addConstantUImmOperands(MCInst &Inst,
unsigned N)
const {
1233 assert(
N == 1 &&
"Invalid number of operands!");
1237 Imm += AdjustOffset;
1241 template <
unsigned Bits>
1242 void addSImmOperands(MCInst &Inst,
unsigned N)
const {
1243 if (isImm() && !isConstantImm()) {
1247 addConstantSImmOperands<Bits, 0, 0>(Inst,
N);
1250 template <
unsigned Bits>
1251 void addUImmOperands(MCInst &Inst,
unsigned N)
const {
1252 if (isImm() && !isConstantImm()) {
1256 addConstantUImmOperands<Bits, 0, 0>(Inst,
N);
1259 template <
unsigned Bits,
int Offset = 0,
int AdjustOffset = 0>
1260 void addConstantSImmOperands(MCInst &Inst,
unsigned N)
const {
1261 assert(
N == 1 &&
"Invalid number of operands!");
1262 int64_t
Imm = getConstantImm() -
Offset;
1265 Imm += AdjustOffset;
1269 void addImmOperands(MCInst &Inst,
unsigned N)
const {
1270 assert(
N == 1 &&
"Invalid number of operands!");
1271 const MCExpr *Expr =
getImm();
1272 addExpr(Inst, Expr);
1275 void addPtrRegOperands(MCInst &Inst,
unsigned N)
const {
1276 assert(
N == 1 &&
"Invalid number of operands!");
1278 AsmParser.getABI().ArePtrs64bit() ? getGPR64Reg() : getGPR32Reg()));
1281 void addMemOperands(MCInst &Inst,
unsigned N)
const {
1282 assert(
N == 2 &&
"Invalid number of operands!");
1283 getMemBase()->addPtrRegOperands(Inst, 1);
1284 addExpr(Inst, getMemOff());
1287 bool isSPAsmReg()
const {
return isGPRAsmReg() && RegIdx.Index == 29; }
1288 bool isGPAsmReg()
const {
return isGPRAsmReg() && RegIdx.Index == 28; }
1290 bool isSImmPtr()
const {
1291 return AsmParser.getABI().ArePtrs64bit() ? isScaledSImm<64, 0>()
1292 : isScaledSImm<32, 0>();
1295 void addRegListOperands(MCInst &Inst,
unsigned N)
const {
1296 assert(
N == 1 &&
"Invalid number of operands!");
1298 for (
auto RegNo : getRegList())
1302 bool isReg()
const override {
1305 return isGPRAsmReg() && RegIdx.Index == 0;
1308 bool isRegIdx()
const {
return Kind == k_RegisterIndex; }
1310 bool isNumericReg()
const {
1311 return isRegIdx() && RegIdx.Kind == RegKind_Numeric && RegIdx.Index < 32;
1314 unsigned getNumericRegIndex()
const {
1315 assert(isNumericReg() &&
"Invalid numeric register");
1316 return RegIdx.Index;
1319 bool isImm()
const override {
return Kind == k_Immediate; }
1321 bool isConstantImm()
const {
1323 return isImm() &&
getImm()->evaluateAsAbsolute(Res);
1326 bool isConstantImmz()
const {
1327 return isConstantImm() && getConstantImm() == 0;
1330 template <
unsigned Bits,
int Offset = 0>
bool isConstantUImm()
const {
1334 template <
unsigned Bits>
bool isSImm()
const {
1338 if (
getImm()->evaluateAsAbsolute(Res))
1344 template <
unsigned Bits>
bool isUImm()
const {
1348 if (
getImm()->evaluateAsAbsolute(Res))
1354 template <
unsigned Bits>
bool isAnyImm()
const {
1355 return isConstantImm() ? (
isInt<Bits>(getConstantImm()) ||
1360 template <
unsigned Bits,
int Offset = 0>
bool isConstantSImm()
const {
1364 template <
unsigned Bottom,
unsigned Top>
bool isConstantUImmRange()
const {
1365 return isConstantImm() && getConstantImm() >= Bottom &&
1366 getConstantImm() <= Top;
1369 bool isToken()
const override {
1372 return Kind == k_Token;
1375 bool isMem()
const override {
return Kind == k_Memory; }
1380 template <
unsigned Bits,
unsigned ShiftLeftAmount,
int Bias = 0>
1381 bool isScaledUImm()
const {
1383 uint64_t(getConstantImm()) - Bias);
1386 template <
unsigned Bits,
unsigned ShiftLeftAmount>
1387 bool isScaledSImm()
const {
1388 if (isConstantImm() &&
1393 if (Kind != k_Immediate)
1398 bool Success =
getImm()->evaluateAsRelocatable(Res,
nullptr);
1402 bool isRegList16()
const {
1406 int Size = RegList.List->size();
1410 MCRegister R0 = RegList.List->front();
1411 MCRegister R1 = RegList.List->back();
1412 if (!((R0 == Mips::R16 && R1 ==
Mips::RA) ||
1416 MCRegister PrevReg = RegList.List->front();
1417 for (
int i = 1; i <
Size - 1; i++) {
1418 MCRegister
Reg = (*(RegList.List))[i];
1419 if (
Reg != PrevReg + 1)
1427 bool isInvNum()
const {
return Kind == k_Immediate; }
1429 bool isLSAImm()
const {
1430 if (!isConstantImm())
1432 int64_t Val = getConstantImm();
1433 return 1 <= Val && Val <= 4;
1436 bool isRegList()
const {
return Kind == k_RegList; }
1439 assert(Kind == k_Token &&
"Invalid access!");
1440 return StringRef(Tok.Data, Tok.Length);
1443 MCRegister
getReg()
const override {
1446 if (Kind == k_RegisterIndex && RegIdx.Index == 0 &&
1447 RegIdx.Kind & RegKind_GPR)
1448 return getGPR32Reg();
1454 const MCExpr *
getImm()
const {
1455 assert((Kind == k_Immediate) &&
"Invalid access!");
1459 int64_t getConstantImm()
const {
1460 const MCExpr *Val =
getImm();
1462 (void)Val->evaluateAsAbsolute(
Value);
1466 MipsOperand *getMemBase()
const {
1467 assert((Kind == k_Memory) &&
"Invalid access!");
1471 const MCExpr *getMemOff()
const {
1472 assert((Kind == k_Memory) &&
"Invalid access!");
1476 const SmallVectorImpl<MCRegister> &getRegList()
const {
1477 assert((Kind == k_RegList) &&
"Invalid access!");
1478 return *(RegList.List);
1481 static std::unique_ptr<MipsOperand> CreateToken(StringRef Str, SMLoc S,
1482 MipsAsmParser &Parser) {
1483 auto Op = std::make_unique<MipsOperand>(k_Token, Parser);
1484 Op->Tok.Data = Str.data();
1485 Op->Tok.Length = Str.size();
1493 static std::unique_ptr<MipsOperand>
1494 createNumericReg(
unsigned Index, StringRef Str,
const MCRegisterInfo *RegInfo,
1495 SMLoc S, SMLoc
E, MipsAsmParser &Parser) {
1496 LLVM_DEBUG(
dbgs() <<
"createNumericReg(" << Index <<
", ...)\n");
1497 return CreateReg(Index, Str, RegKind_Numeric, RegInfo, S,
E, Parser);
1502 static std::unique_ptr<MipsOperand>
1503 createGPRReg(
unsigned Index, StringRef Str,
const MCRegisterInfo *RegInfo,
1504 SMLoc S, SMLoc
E, MipsAsmParser &Parser) {
1505 return CreateReg(Index, Str, RegKind_GPR, RegInfo, S,
E, Parser);
1510 static std::unique_ptr<MipsOperand>
1511 createFGRReg(
unsigned Index, StringRef Str,
const MCRegisterInfo *RegInfo,
1512 SMLoc S, SMLoc
E, MipsAsmParser &Parser) {
1513 return CreateReg(Index, Str, RegKind_FGR, RegInfo, S,
E, Parser);
1516 static std::unique_ptr<MipsOperand>
1517 createCOP0Reg(
unsigned Encoding, StringRef Str,
const MCRegisterInfo *RegInfo,
1518 SMLoc S, SMLoc
E, MipsAsmParser &Parser) {
1521 "Invalid COP0 register encoding");
1522 return CreateReg(Encoding, Str, RegKind_COP0, RegInfo, S,
E, Parser);
1527 static std::unique_ptr<MipsOperand>
1528 createHWRegsReg(
unsigned Index, StringRef Str,
const MCRegisterInfo *RegInfo,
1529 SMLoc S, SMLoc
E, MipsAsmParser &Parser) {
1530 return CreateReg(Index, Str, RegKind_HWRegs, RegInfo, S,
E, Parser);
1535 static std::unique_ptr<MipsOperand>
1536 createFCCReg(
unsigned Index, StringRef Str,
const MCRegisterInfo *RegInfo,
1537 SMLoc S, SMLoc
E, MipsAsmParser &Parser) {
1538 return CreateReg(Index, Str, RegKind_FCC, RegInfo, S,
E, Parser);
1543 static std::unique_ptr<MipsOperand>
1544 createACCReg(
unsigned Index, StringRef Str,
const MCRegisterInfo *RegInfo,
1545 SMLoc S, SMLoc
E, MipsAsmParser &Parser) {
1546 return CreateReg(Index, Str, RegKind_ACC, RegInfo, S,
E, Parser);
1551 static std::unique_ptr<MipsOperand>
1552 createMSA128Reg(
unsigned Index, StringRef Str,
const MCRegisterInfo *RegInfo,
1553 SMLoc S, SMLoc
E, MipsAsmParser &Parser) {
1554 return CreateReg(Index, Str, RegKind_MSA128, RegInfo, S,
E, Parser);
1559 static std::unique_ptr<MipsOperand>
1560 createMSACtrlReg(
unsigned Index, StringRef Str,
const MCRegisterInfo *RegInfo,
1561 SMLoc S, SMLoc
E, MipsAsmParser &Parser) {
1562 return CreateReg(Index, Str, RegKind_MSACtrl, RegInfo, S,
E, Parser);
1565 static std::unique_ptr<MipsOperand>
1566 CreateImm(
const MCExpr *Val, SMLoc S, SMLoc
E, MipsAsmParser &Parser) {
1567 auto Op = std::make_unique<MipsOperand>(k_Immediate, Parser);
1574 static std::unique_ptr<MipsOperand>
1575 CreateMem(std::unique_ptr<MipsOperand>
Base,
const MCExpr *
Off, SMLoc S,
1576 SMLoc
E, MipsAsmParser &Parser) {
1577 auto Op = std::make_unique<MipsOperand>(k_Memory, Parser);
1578 Op->Mem.Base =
Base.release();
1585 static std::unique_ptr<MipsOperand>
1586 CreateRegList(SmallVectorImpl<MCRegister> &Regs, SMLoc StartLoc, SMLoc EndLoc,
1587 MipsAsmParser &Parser) {
1588 assert(!Regs.
empty() &&
"Empty list not allowed");
1590 auto Op = std::make_unique<MipsOperand>(k_RegList, Parser);
1593 Op->StartLoc = StartLoc;
1594 Op->EndLoc = EndLoc;
1598 bool isGPRZeroAsmReg()
const {
1599 return isRegIdx() && RegIdx.Kind & RegKind_GPR && RegIdx.Index == 0;
1602 bool isGPRNonZeroAsmReg()
const {
1603 return isRegIdx() && RegIdx.Kind & RegKind_GPR && RegIdx.Index > 0 &&
1607 bool isGPRAsmReg()
const {
1608 return isRegIdx() && RegIdx.Kind & RegKind_GPR && RegIdx.Index <= 31;
1611 bool isMM16AsmReg()
const {
1614 return ((RegIdx.Index >= 2 && RegIdx.Index <= 7)
1615 || RegIdx.Index == 16 || RegIdx.Index == 17);
1618 bool isMM16AsmRegZero()
const {
1621 return (RegIdx.Index == 0 ||
1622 (RegIdx.Index >= 2 && RegIdx.Index <= 7) ||
1623 RegIdx.Index == 17);
1626 bool isMM16AsmRegMoveP()
const {
1627 if (!(isRegIdx() && RegIdx.Kind))
1629 return (RegIdx.Index == 0 || (RegIdx.Index >= 2 && RegIdx.Index <= 3) ||
1630 (RegIdx.Index >= 16 && RegIdx.Index <= 20));
1633 bool isMM16AsmRegMovePPairFirst()
const {
1634 if (!(isRegIdx() && RegIdx.Kind))
1636 return RegIdx.Index >= 4 && RegIdx.Index <= 6;
1639 bool isMM16AsmRegMovePPairSecond()
const {
1640 if (!(isRegIdx() && RegIdx.Kind))
1642 return (RegIdx.Index == 21 || RegIdx.Index == 22 ||
1643 (RegIdx.Index >= 5 && RegIdx.Index <= 7));
1646 bool isFGRAsmReg()
const {
1648 return isRegIdx() && RegIdx.Kind & RegKind_FGR && RegIdx.Index <= 31;
1651 bool isStrictlyFGRAsmReg()
const {
1653 return isRegIdx() && RegIdx.Kind == RegKind_FGR && RegIdx.Index <= 31;
1656 bool isHWRegsAsmReg()
const {
1657 return isRegIdx() && RegIdx.Kind & RegKind_HWRegs && RegIdx.Index <= 31;
1660 bool isCCRAsmReg()
const {
1661 return isRegIdx() && RegIdx.Kind & RegKind_CCR && RegIdx.Index <= 31;
1664 bool isFCCAsmReg()
const {
1665 if (!(isRegIdx() && RegIdx.Kind & RegKind_FCC))
1667 return RegIdx.Index <= 7;
1670 bool isACCAsmReg()
const {
1671 return isRegIdx() && RegIdx.Kind & RegKind_ACC && RegIdx.Index <= 3;
1674 bool isCOP0AsmReg()
const {
1675 return isRegIdx() && RegIdx.Kind == RegKind_COP0;
1678 unsigned getCOP0Encoding()
const {
1679 assert(isCOP0AsmReg() &&
"Invalid COP0 register");
1680 return RegIdx.Index;
1683 bool isCOP2AsmReg()
const {
1684 return isRegIdx() && RegIdx.Kind & RegKind_COP2 && RegIdx.Index <= 31;
1687 bool isCOP3AsmReg()
const {
1688 return isRegIdx() && RegIdx.Kind & RegKind_COP3 && RegIdx.Index <= 31;
1691 bool isMSA128AsmReg()
const {
1692 return isRegIdx() && RegIdx.Kind & RegKind_MSA128 && RegIdx.Index <= 31;
1695 bool isMSACtrlAsmReg()
const {
1696 return isRegIdx() && RegIdx.Kind & RegKind_MSACtrl && RegIdx.Index <= 7;
1699 bool isNM16AsmReg()
const {
1700 if (!(isRegIdx() && RegIdx.Kind))
1702 return ((RegIdx.Index >= 4 && RegIdx.Index <= 7) ||
1703 (RegIdx.Index >= 16 && RegIdx.Index <= 19));
1706 bool isNM16ZeroAsmReg()
const {
1707 if (!(isRegIdx() && RegIdx.Kind))
1709 return ((RegIdx.Index == 0) || (RegIdx.Index >= 4 && RegIdx.Index <= 7) ||
1710 (RegIdx.Index >= 17 && RegIdx.Index <= 19));
1713 bool isNM4AsmReg()
const {
1714 if (!(isRegIdx() && RegIdx.Kind))
1716 return ((RegIdx.Index >= 4 && RegIdx.Index <= 11) ||
1717 (RegIdx.Index >= 16 && RegIdx.Index <= 23));
1720 bool isNM4ZeroAsmReg()
const {
1721 if (!(isRegIdx() && RegIdx.Kind))
1723 return ((RegIdx.Index == 0) || (RegIdx.Index >= 4 && RegIdx.Index <= 10) ||
1724 (RegIdx.Index >= 16 && RegIdx.Index <= 23));
1727 bool isNM2R1AsmReg()
const {
1728 if (!(isRegIdx() && RegIdx.Kind))
1730 return RegIdx.Index >= 4 && RegIdx.Index <= 7;
1733 bool isNM2R2AsmReg()
const {
1734 if (!(isRegIdx() && RegIdx.Kind))
1736 return RegIdx.Index >= 5 && RegIdx.Index <= 8;
1739 bool isNM1R1AsmReg()
const {
1740 if (!(isRegIdx() && RegIdx.Kind))
1742 return RegIdx.Index == 4 || RegIdx.Index == 5;
1745 template <
unsigned RegClassID = Mips::GPR32RegClassID>
1746 bool isGPRNMAsmReg()
const {
1747 if (!(isRegIdx() && RegIdx.Kind))
1749 switch (RegClassID) {
1750 case Mips::GP32RegClassID:
1751 return (RegIdx.Index == 28);
1752 case Mips::SP32RegClassID:
1753 return (RegIdx.Index == 29);
1754 case Mips::GPRNMRARegClassID:
1755 return (RegIdx.Index == 31);
1756 case Mips::GPR32NONZERORegClassID:
1757 return (RegIdx.Index > 0 && RegIdx.Index < 32);
1758 case Mips::GPRNM3RegClassID:
1759 return isNM16AsmReg();
1760 case Mips::GPRNM3ZRegClassID:
1761 return isNM16ZeroAsmReg();
1762 case Mips::GPRNM4RegClassID:
1763 return isNM4AsmReg();
1764 case Mips::GPRNM4ZRegClassID:
1765 return isNM4ZeroAsmReg();
1766 case Mips::GPRNM2R1RegClassID:
1767 return isNM2R1AsmReg();
1768 case Mips::GPRNM2R2RegClassID:
1769 return isNM2R2AsmReg();
1770 case Mips::GPRNM1R1RegClassID:
1771 return isNM1R1AsmReg();
1773 return RegIdx.Index < 32;
1778 SMLoc getStartLoc()
const override {
return StartLoc; }
1780 SMLoc getEndLoc()
const override {
return EndLoc; }
1782 void print(raw_ostream &OS,
const MCAsmInfo &MAI)
const override {
1791 Mem.Base->print(OS, MAI);
1796 case k_RegisterIndex:
1797 OS <<
"RegIdx<" << RegIdx.Index <<
":" << RegIdx.Kind <<
", "
1798 << StringRef(RegIdx.Tok.Data, RegIdx.Tok.Length) <<
">";
1805 for (
auto Reg : (*RegList.List))
1806 OS <<
Reg.
id() <<
" ";
1812 bool isValidForTie(
const MipsOperand &
Other)
const {
1813 if (Kind !=
Other.Kind)
1820 case k_RegisterIndex: {
1821 StringRef Token(RegIdx.Tok.Data, RegIdx.Tok.Length);
1822 StringRef OtherToken(
Other.RegIdx.Tok.Data,
Other.RegIdx.Tok.Length);
1823 return Token == OtherToken;
1839 case Mips::JRC16_MM:
1841 case Mips::JALRS_MM:
1842 case Mips::JALRS16_MM:
1843 case Mips::BGEZALS_MM:
1844 case Mips::BLTZALS_MM:
1855 return &SRExpr->getSymbol();
1914 unsigned NumOp =
MCID.getNumOperands();
1915 if (NumOp != 3 && NumOp != 4)
1945bool MipsAsmParser::processInstruction(
MCInst &Inst,
SMLoc IDLoc,
1948 MipsTargetStreamer &TOut = getTargetStreamer();
1949 const unsigned Opcode = Inst.
getOpcode();
1950 const MCInstrDesc &MCID = MII.get(Opcode);
1951 bool ExpandedJalSym =
false;
1969 assert(hasCnMips() &&
"instruction only valid for octeon cpus");
1980 if (!
isIntN(inMicroMipsMode() ? 17 : 18,
Offset.getImm()))
1981 return Error(IDLoc,
"branch target out of range");
1984 return Error(IDLoc,
"branch to misaligned address");
1998 case Mips::BGEZAL_MM:
1999 case Mips::BLTZAL_MM:
2002 case Mips::BC1EQZC_MMR6:
2003 case Mips::BC1NEZC_MMR6:
2004 case Mips::BC2EQZC_MMR6:
2005 case Mips::BC2NEZC_MMR6:
2010 if (!
isIntN(inMicroMipsMode() ? 17 : 18,
Offset.getImm()))
2011 return Error(IDLoc,
"branch target out of range");
2014 return Error(IDLoc,
"branch to misaligned address");
2016 case Mips::BGEC:
case Mips::BGEC_MMR6:
2017 case Mips::BLTC:
case Mips::BLTC_MMR6:
2018 case Mips::BGEUC:
case Mips::BGEUC_MMR6:
2019 case Mips::BLTUC:
case Mips::BLTUC_MMR6:
2020 case Mips::BEQC:
case Mips::BEQC_MMR6:
2021 case Mips::BNEC:
case Mips::BNEC_MMR6:
2027 return Error(IDLoc,
"branch target out of range");
2029 return Error(IDLoc,
"branch to misaligned address");
2031 case Mips::BLEZC:
case Mips::BLEZC_MMR6:
2032 case Mips::BGEZC:
case Mips::BGEZC_MMR6:
2033 case Mips::BGTZC:
case Mips::BGTZC_MMR6:
2034 case Mips::BLTZC:
case Mips::BLTZC_MMR6:
2040 return Error(IDLoc,
"branch target out of range");
2042 return Error(IDLoc,
"branch to misaligned address");
2044 case Mips::BEQZC:
case Mips::BEQZC_MMR6:
2045 case Mips::BNEZC:
case Mips::BNEZC_MMR6:
2051 return Error(IDLoc,
"branch target out of range");
2053 return Error(IDLoc,
"branch to misaligned address");
2055 case Mips::BEQZ16_MM:
2056 case Mips::BEQZC16_MMR6:
2057 case Mips::BNEZ16_MM:
2058 case Mips::BNEZC16_MMR6:
2064 return Error(IDLoc,
"branch target out of range");
2066 return Error(IDLoc,
"branch to misaligned address");
2073 if (hasMips32r6() && Opcode == Mips::SSNOP) {
2074 std::string
ISA = hasMips64r6() ?
"MIPS64r6" :
"MIPS32r6";
2075 Warning(IDLoc,
"ssnop is deprecated for " + ISA +
" and is equivalent to a "
2095 return Error(IDLoc,
"expected immediate operand kind");
2098 Opcode == Mips::BBIT1 ? 63 : 31))
2099 return Error(IDLoc,
"immediate operand value out of range");
2101 Inst.
setOpcode(Opcode == Mips::BBIT0 ? Mips::BBIT032
2112 return Error(IDLoc,
"expected immediate operand kind");
2115 return Error(IDLoc,
"immediate operand value out of range");
2127 unsigned FirstOp = 1;
2128 unsigned SecondOp = 2;
2132 case Mips::SDivIMacro:
2133 case Mips::UDivIMacro:
2134 case Mips::DSDivIMacro:
2135 case Mips::DUDivIMacro:
2137 return Error(IDLoc,
"expected immediate operand kind");
2141 Warning(IDLoc,
"dividing zero by zero");
2143 Warning(IDLoc,
"division by zero");
2155 case Mips::SDivMacro:
2156 case Mips::DSDivMacro:
2157 case Mips::UDivMacro:
2158 case Mips::DUDivMacro:
2163 case Mips::DIVU_MMR6:
2164 case Mips::DIV_MMR6:
2169 Warning(IDLoc,
"dividing zero by zero");
2171 Warning(IDLoc,
"division by zero");
2177 if ((Opcode == Mips::J || Opcode == Mips::J_MM) && inPicMode()) {
2179 BInst.
setOpcode(inMicroMipsMode() ? Mips::BEQ_MM : Mips::BEQ);
2188 if ((Opcode == Mips::JAL || Opcode == Mips::JAL_MM) && inPicMode()) {
2189 warnIfNoMacro(IDLoc);
2192 return Error(IDLoc,
"unsupported constant in relocation");
2200 return Error(IDLoc,
"jal doesn't support multiple symbols in PIC mode");
2206 if (expandLoadAddress(
getABI().getTempReg(9), MCRegister(),
2207 Inst.
getOperand(0), !isGP64bit(), IDLoc, Out, STI))
2211 if (inMicroMipsMode())
2212 JalrInst.
setOpcode(IsCpRestoreSet ? Mips::JALRS_MM : Mips::JALR_MM);
2220 emitHazardNopsBefore(JalrInst, *STI);
2222 if (isJalrRelocAvailable(JalExpr)) {
2228 const MCExpr *RelocJalrExpr =
2232 *TmpExpr, inMicroMipsMode() ?
"R_MICROMIPS_JALR" :
"R_MIPS_JALR",
2238 ExpandedJalSym =
true;
2247 expandMem9Inst(Inst, IDLoc, Out, STI, MCID.
mayLoad());
2250 expandMem16Inst(Inst, IDLoc, Out, STI, MCID.
mayLoad());
2253 return getParser().hasPendingError();
2257 if (inMicroMipsMode()) {
2258 if (Opcode == Mips::LW_MM || Opcode == Mips::LW_MMR6) {
2261 const MCOperandInfo &OpInfo = MCID.
operands()[i];
2266 int MemOffset =
Op.getImm();
2269 if (
isInt<9>(MemOffset) && (MemOffset % 4 == 0) &&
2292 case Mips::ADDIUSP_MM:
2295 return Error(IDLoc,
"expected immediate operand kind");
2299 return Error(IDLoc,
"immediate operand value out of range");
2301 case Mips::SLL16_MM:
2302 case Mips::SRL16_MM:
2305 return Error(IDLoc,
"expected immediate operand kind");
2308 return Error(IDLoc,
"immediate operand value out of range");
2313 return Error(IDLoc,
"expected immediate operand kind");
2316 return Error(IDLoc,
"immediate operand value out of range");
2318 case Mips::ADDIUR2_MM:
2321 return Error(IDLoc,
"expected immediate operand kind");
2323 if (!(
Imm == 1 ||
Imm == -1 ||
2325 return Error(IDLoc,
"immediate operand value out of range");
2327 case Mips::ANDI16_MM:
2330 return Error(IDLoc,
"expected immediate operand kind");
2334 Imm == 64 ||
Imm == 255 ||
Imm == 32768 ||
Imm == 65535))
2335 return Error(IDLoc,
"immediate operand value out of range");
2337 case Mips::LBU16_MM:
2340 return Error(IDLoc,
"expected immediate operand kind");
2343 return Error(IDLoc,
"immediate operand value out of range");
2346 case Mips::SB16_MMR6:
2349 return Error(IDLoc,
"expected immediate operand kind");
2352 return Error(IDLoc,
"immediate operand value out of range");
2354 case Mips::LHU16_MM:
2356 case Mips::SH16_MMR6:
2359 return Error(IDLoc,
"expected immediate operand kind");
2362 return Error(IDLoc,
"immediate operand value out of range");
2366 case Mips::SW16_MMR6:
2369 return Error(IDLoc,
"expected immediate operand kind");
2372 return Error(IDLoc,
"immediate operand value out of range");
2374 case Mips::ADDIUPC_MM:
2377 return Error(IDLoc,
"expected immediate operand kind");
2380 return Error(IDLoc,
"immediate operand value out of range");
2385 return Error(IDLoc,
"invalid operand for instruction");
2387 case Mips::MOVEP_MM:
2388 case Mips::MOVEP_MMR6: {
2391 bool RegPair = ((R0 == Mips::R5 && R1 == Mips::R6) ||
2392 (R0 == Mips::R5 && R1 == Mips::R7) ||
2393 (R0 == Mips::R6 && R1 == Mips::R7) ||
2394 (R0 == Mips::R4 && R1 == Mips::R21) ||
2395 (R0 == Mips::R4 && R1 == Mips::R22) ||
2396 (R0 == Mips::R4 && R1 == Mips::R5) ||
2397 (R0 == Mips::R4 && R1 == Mips::R6) ||
2398 (R0 == Mips::R4 && R1 == Mips::R7));
2400 return Error(IDLoc,
"invalid operand for instruction");
2406 bool FillDelaySlot =
2411 bool PrevForbiddenSlotAttr = CurForbiddenSlotAttr;
2414 bool SetReorderAfterNop =
false;
2419 if (PrevForbiddenSlotAttr && !SafeInForbiddenSlot(MCID)) {
2429 if (AssemblerOptions.
back()->isReorder() && !FillDelaySlot) {
2430 SetReorderAfterNop =
true;
2439 CurForbiddenSlotAttr =
2440 hasForbiddenSlot(MCID) && AssemblerOptions.
back()->isReorder();
2442 if (FillDelaySlot || CurForbiddenSlotAttr)
2445 MacroExpanderResultTy ExpandResult =
2446 tryExpandInstruction(Inst, IDLoc, Out, STI);
2447 switch (ExpandResult) {
2463 if (PrevForbiddenSlotAttr && !SetReorderAfterNop && !FillDelaySlot &&
2464 AssemblerOptions.
back()->isReorder()) {
2470 if (inMicroMipsMode()) {
2485 if (FillDelaySlot) {
2490 if ((Opcode == Mips::JalOneReg || Opcode == Mips::JalTwoReg ||
2492 isPicAndNotNxxAbi()) {
2493 if (IsCpRestoreSet) {
2497 if (!AssemblerOptions.
back()->isReorder())
2504 Warning(IDLoc,
"no .cprestore used in PIC mode");
2510void MipsAsmParser::onEndOfFile() {
2511 MipsTargetStreamer &TOut = getTargetStreamer();
2512 SMLoc IDLoc = SMLoc();
2514 if (CurForbiddenSlotAttr) {
2516 if (AssemblerOptions.
back()->isReorder())
2522 if (AssemblerOptions.
back()->isReorder())
2523 emitPendingHazardNops();
2535 return MRI.getRegClass(Mips::GPR32RegClassID).contains(
Reg) ||
2536 MRI.getRegClass(Mips::GPR64RegClassID).contains(
Reg);
2540 return MRI.getRegClass(Mips::FGR32RegClassID).contains(
Reg) ||
2541 MRI.getRegClass(Mips::AFGR64RegClassID).contains(
Reg) ||
2542 MRI.getRegClass(Mips::FGR64RegClassID).contains(
Reg);
2546 return MRI.getRegClass(Mips::FCCRegClassID).contains(
Reg);
2552 return MRI.getRegClass(Mips::CCRRegClassID).contains(
Reg) ||
2553 MRI.getRegClass(Mips::COP0RegClassID).contains(
Reg) ||
2554 MRI.getRegClass(Mips::COP2RegClassID).contains(
Reg) ||
2555 MRI.getRegClass(Mips::COP3RegClassID).contains(
Reg);
2560 return Desc.mayLoad() && !
Desc.isPseudo() &&
Desc.getNumDefs() != 0;
2566 if (Inst.
getOpcode() != Mips::PseudoGOTLoadGlobal)
2576 [&](
MCRegister R) { return MRI.regsOverlap(R, Reg); });
2582 [&](
MCRegister R) { return MRI.regsOverlap(R, Reg); });
2591 InstRegs(
const MCInst &Inst,
const MCInstrDesc &
Desc) {
2596 if (
I <
Desc.getNumDefs()) {
2603 if (
Desc.mayLoad() &&
I <
Desc.getNumOperands() &&
2616unsigned MipsAsmParser::getInstsBetween(
const MCInst &
First,
2617 const MCInst *Second) {
2618 const MCRegisterInfo &
MRI = *
getContext().getRegisterInfo();
2619 const MCInstrDesc &Desc1 = MII.get(
First.getOpcode());
2620 const MCInstrDesc *Desc2 = Second ? &MII.get(Second->
getOpcode()) :
nullptr;
2621 InstRegs Regs1(
First, Desc1);
2622 std::optional<InstRegs> Regs2;
2624 Regs2.emplace(*Second, *Desc2);
2626 auto SecondReads = [&](
auto Pred) {
2629 auto SecondWrites = [&](MCRegister
Reg) {
2632 bool SecondReadsCC =
2633 SecondReads([&](MCRegister R) {
return isFCCReg(R,
MRI); });
2636 bool SecondAccessesCopReg =
2638 return MO.isReg() && isCopReg(MO.getReg(), MRI);
2643 if (!hasMips32() && !getSTI().
hasFeature(Mips::FeatureR5900) &&
2644 ((
readsReg(Desc1, Mips::LO0,
MRI) && SecondWrites(Mips::LO0)) ||
2645 (
readsReg(Desc1, Mips::HI0,
MRI) && SecondWrites(Mips::HI0))))
2648 bool CopDelays = !hasMips4() && !hasMips32();
2653 Dst =
First.getOperand(0).getReg();
2654 bool DstIsGPR = Dst &&
isGPR(Dst,
MRI);
2659 (CopDelays && IsCopMove && DstIsGPR)) {
2660 if (Dst != Mips::R0 && Dst != Mips::R0_64 &&
2661 SecondReads([&](MCRegister R) {
return MRI.regsOverlap(R, Dst); }))
2670 if ((CopDelays && IsCopMove && !DstIsGPR) ||
2671 (!hasMips2() &&
Load && !DstIsGPR)) {
2673 copy_if(Regs1.Defs, std::back_inserter(FPRDefs),
2674 [&](MCRegister R) { return isFPUReg(R, MRI); });
2675 if (!FPRDefs.
empty()) {
2676 if (SecondReads([&](MCRegister R) {
2678 [&](MCRegister
D) {
return MRI.regsOverlap(R,
D); });
2689 if (SecondAccessesCopReg)
2696 any_of(Regs1.Defs, [&](MCRegister R) { return isFCCReg(R, MRI); }) &&
2705unsigned MipsAsmParser::getHazardNops(
const MCInst *
Next,
unsigned Window) {
2706 auto It = RecentInsts.
find(getStreamer().getCurrentSectionOnly());
2707 if (It == RecentInsts.
end())
2709 const SmallVectorImpl<MCInst> &Recent = It->second;
2713 for (
unsigned Distance = 0,
E = std::min<unsigned>(Window, Recent.
size());
2714 Distance <
E; ++Distance) {
2716 getInstsBetween(Recent[Recent.
size() - 1 - Distance],
Next);
2717 if (Between > Distance)
2718 Nops = std::max(Nops, Between - Distance);
2723void MipsAsmParser::emitHazardNops(
unsigned Count,
const MCSubtargetInfo &STI) {
2729 for (
unsigned I = 0;
I !=
Count; ++
I)
2733void MipsAsmParser::emitHazardNopsBefore(
const MCInst &Inst,
2734 const MCSubtargetInfo &STI) {
2739 if (AssemblerOptions.
back()->isReorder())
2740 emitHazardNops(getHazardNops(&Inst), STI);
2741 else if (InMacroExpansion)
2742 emitHazardNops(getHazardNops(&Inst, MacroInsts), STI);
2745void MipsAsmParser::emitPendingHazardNops() {
2747 emitHazardNops(getHazardNops(
nullptr), getSTI());
2754 Mips::FeatureMips32, Mips::FeatureR5900,
2755 Mips::FeatureMicroMips, Mips::FeatureMips16});
2758void MipsAsmParser::emitHazardNopsForISAChange(
2759 const FeatureBitset &OldFeatures) {
2760 if (RecentInsts.
empty() || !AssemblerOptions.
back()->isReorder())
2762 FeatureBitset NewFeatures = getSTI().getFeatureBits();
2767 MCSubtargetInfo &STI = copySTI();
2769 emitPendingHazardNops();
2773void MipsAsmParser::emitInstruction(
const MCInst &Inst,
2774 const MCSubtargetInfo &STI) {
2775 MCStreamer &
Out = getStreamer();
2776 emitHazardNopsBefore(Inst, STI);
2777 Out.emitInstruction(Inst, STI);
2778 if (InMacroExpansion)
2782 if (Recent.
size() == 2)
2787MipsAsmParser::MacroExpanderResultTy
2788MipsAsmParser::tryExpandInstruction(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
2789 const MCSubtargetInfo *STI) {
2792 return MER_NotAMacro;
2793 case Mips::LoadImm32:
2794 return expandLoadImm(Inst,
true, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2795 case Mips::LoadImm64:
2796 return expandLoadImm(Inst,
false, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2797 case Mips::LoadAddrImm32:
2798 case Mips::LoadAddrImm64:
2801 "expected immediate operand kind");
2803 return expandLoadAddress(
2805 Inst.
getOpcode() == Mips::LoadAddrImm32, IDLoc, Out, STI)
2808 case Mips::LoadAddrReg32:
2809 case Mips::LoadAddrReg64:
2813 "expected immediate operand kind");
2817 Inst.
getOpcode() == Mips::LoadAddrReg32, IDLoc,
2821 case Mips::B_MM_Pseudo:
2822 case Mips::B_MMR6_Pseudo:
2823 return expandUncondBranchMMPseudo(Inst, IDLoc, Out, STI) ? MER_Fail
2827 return expandLoadStoreMultiple(Inst, IDLoc, Out, STI) ? MER_Fail
2829 case Mips::JalOneReg:
2830 case Mips::JalTwoReg:
2831 return expandJalWithRegs(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2834 case Mips::BEQLImmMacro:
2835 case Mips::BNELImmMacro:
2836 return expandBranchImm(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2853 case Mips::BLTImmMacro:
2854 case Mips::BLEImmMacro:
2855 case Mips::BGEImmMacro:
2856 case Mips::BGTImmMacro:
2857 case Mips::BLTUImmMacro:
2858 case Mips::BLEUImmMacro:
2859 case Mips::BGEUImmMacro:
2860 case Mips::BGTUImmMacro:
2861 case Mips::BLTLImmMacro:
2862 case Mips::BLELImmMacro:
2863 case Mips::BGELImmMacro:
2864 case Mips::BGTLImmMacro:
2865 case Mips::BLTULImmMacro:
2866 case Mips::BLEULImmMacro:
2867 case Mips::BGEULImmMacro:
2868 case Mips::BGTULImmMacro:
2869 return expandCondBranches(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2870 case Mips::SDivMacro:
2871 case Mips::SDivIMacro:
2872 case Mips::SRemMacro:
2873 case Mips::SRemIMacro:
2874 return expandDivRem(Inst, IDLoc, Out, STI,
false,
true) ? MER_Fail
2876 case Mips::DSDivMacro:
2877 case Mips::DSDivIMacro:
2878 case Mips::DSRemMacro:
2879 case Mips::DSRemIMacro:
2880 return expandDivRem(Inst, IDLoc, Out, STI,
true,
true) ? MER_Fail
2882 case Mips::UDivMacro:
2883 case Mips::UDivIMacro:
2884 case Mips::URemMacro:
2885 case Mips::URemIMacro:
2886 return expandDivRem(Inst, IDLoc, Out, STI,
false,
false) ? MER_Fail
2888 case Mips::DUDivMacro:
2889 case Mips::DUDivIMacro:
2890 case Mips::DURemMacro:
2891 case Mips::DURemIMacro:
2892 return expandDivRem(Inst, IDLoc, Out, STI,
true,
false) ? MER_Fail
2894 case Mips::PseudoTRUNC_W_S:
2895 return expandTrunc(Inst,
false,
false, IDLoc, Out, STI) ? MER_Fail
2897 case Mips::PseudoTRUNC_W_D32:
2898 return expandTrunc(Inst,
true,
false, IDLoc, Out, STI) ? MER_Fail
2900 case Mips::PseudoTRUNC_W_D:
2901 return expandTrunc(Inst,
true,
true, IDLoc, Out, STI) ? MER_Fail
2904 case Mips::LoadImmSingleGPR:
2905 return expandLoadSingleImmToGPR(Inst, IDLoc, Out, STI) ? MER_Fail
2907 case Mips::LoadImmSingleFGR:
2908 return expandLoadSingleImmToFPR(Inst, IDLoc, Out, STI) ? MER_Fail
2910 case Mips::LoadImmDoubleGPR:
2911 return expandLoadDoubleImmToGPR(Inst, IDLoc, Out, STI) ? MER_Fail
2913 case Mips::LoadImmDoubleFGR:
2914 return expandLoadDoubleImmToFPR(Inst,
true, IDLoc, Out, STI) ? MER_Fail
2916 case Mips::LoadImmDoubleFGR_32:
2917 return expandLoadDoubleImmToFPR(Inst,
false, IDLoc, Out, STI) ? MER_Fail
2921 return expandUlh(Inst,
true, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2923 return expandUlh(Inst,
false, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2925 return expandUsh(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2928 return expandUxw(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2930 case Mips::NORImm64:
2931 return expandAliasImmediate(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2934 return expandSge(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2937 case Mips::SGEImm64:
2938 case Mips::SGEUImm64:
2939 return expandSgeImm(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2942 case Mips::SGTImm64:
2943 case Mips::SGTUImm64:
2944 return expandSgtImm(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2947 return expandSle(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2950 case Mips::SLEImm64:
2951 case Mips::SLEUImm64:
2952 return expandSleImm(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2953 case Mips::SLTImm64:
2956 return MER_NotAMacro;
2958 return expandAliasImmediate(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2959 case Mips::SLTUImm64:
2962 return MER_NotAMacro;
2964 return expandAliasImmediate(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2965 case Mips::ADDi:
case Mips::ADDi_MM:
2966 case Mips::ADDiu:
case Mips::ADDiu_MM:
2967 case Mips::SLTi:
case Mips::SLTi_MM:
2968 case Mips::SLTiu:
case Mips::SLTiu_MM:
2973 return MER_NotAMacro;
2974 return expandAliasImmediate(Inst, IDLoc, Out, STI) ? MER_Fail
2977 return MER_NotAMacro;
2978 case Mips::ANDi:
case Mips::ANDi_MM:
case Mips::ANDi64:
2979 case Mips::ORi:
case Mips::ORi_MM:
case Mips::ORi64:
2980 case Mips::XORi:
case Mips::XORi_MM:
case Mips::XORi64:
2985 return MER_NotAMacro;
2986 return expandAliasImmediate(Inst, IDLoc, Out, STI) ? MER_Fail
2989 return MER_NotAMacro;
2992 return expandRotation(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2995 return expandRotationImm(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
2998 return expandDRotation(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
3001 return expandDRotationImm(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
3002 case Mips::ABSMacro:
3003 return expandAbs(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
3004 case Mips::MULImmMacro:
3005 case Mips::DMULImmMacro:
3006 return expandMulImm(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
3007 case Mips::MULOMacro:
3008 case Mips::DMULOMacro:
3009 return expandMulO(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
3010 case Mips::MULOUMacro:
3011 case Mips::DMULOUMacro:
3012 return expandMulOU(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
3013 case Mips::MULMacro:
3014 case Mips::DMULMacro:
3015 return expandMULMacro(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
3018 return expandLoadStoreDMacro(Inst, IDLoc, Out, STI,
3024 return expandLoadStoreDM1Macro(Inst, IDLoc, Out, STI,
3028 case Mips::SEQMacro:
3029 return expandSeq(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
3030 case Mips::SEQIMacro:
3031 return expandSeqI(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
3032 case Mips::SNEMacro:
3033 return expandSne(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
3034 case Mips::SNEIMacro:
3035 return expandSneI(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
3036 case Mips::MFTGPR:
case Mips::MTTGPR:
3037 case Mips::MFTLO:
case Mips::MTTLO:
3038 case Mips::MFTHI:
case Mips::MTTHI:
3039 case Mips::MFTACX:
case Mips::MTTACX:
3040 case Mips::MFTDSP:
case Mips::MTTDSP:
3041 case Mips::MFTC1:
case Mips::MTTC1:
3042 case Mips::MFTHC1:
case Mips::MTTHC1:
3043 case Mips::CFTC1:
case Mips::CTTC1:
3044 return expandMXTRAlias(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
3046 case Mips::SaadAddr:
3047 return expandSaaAddr(Inst, IDLoc, Out, STI) ? MER_Fail : MER_Success;
3051bool MipsAsmParser::expandJalWithRegs(MCInst &Inst, SMLoc IDLoc,
3053 const MCSubtargetInfo *STI) {
3054 MipsTargetStreamer &TOut = getTargetStreamer();
3059 const MCOperand FirstRegOp = Inst.
getOperand(0);
3060 const unsigned Opcode = Inst.
getOpcode();
3062 if (Opcode == Mips::JalOneReg) {
3064 if (IsCpRestoreSet && inMicroMipsMode()) {
3067 }
else if (inMicroMipsMode()) {
3068 JalrInst.
setOpcode(hasMips32r6() ? Mips::JALRC16_MMR6 : Mips::JALR16_MM);
3075 }
else if (Opcode == Mips::JalTwoReg) {
3077 if (IsCpRestoreSet && inMicroMipsMode())
3080 JalrInst.
setOpcode(inMicroMipsMode() ? Mips::JALR_MM : Mips::JALR);
3082 const MCOperand SecondRegOp = Inst.
getOperand(1);
3089 const MCInstrDesc &MCID = MII.get(JalrInst.
getOpcode());
3112bool MipsAsmParser::loadImmediate(int64_t ImmValue, MCRegister DstReg,
3113 MCRegister SrcReg,
bool Is32BitImm,
3114 bool IsAddress, SMLoc IDLoc, MCStreamer &Out,
3115 const MCSubtargetInfo *STI) {
3116 MipsTargetStreamer &TOut = getTargetStreamer();
3118 if (!Is32BitImm && !isGP64bit()) {
3119 Error(IDLoc,
"instruction requires a 64-bit architecture");
3130 Error(IDLoc,
"instruction requires a 32-bit immediate");
3135 MCRegister ZeroReg = IsAddress ?
ABI.GetNullPtr() :
ABI.GetZeroReg();
3136 unsigned AdduOp = !Is32BitImm ? Mips::DADDu : Mips::ADDu;
3138 bool UseSrcReg =
false;
3142 MCRegister TmpReg = DstReg;
3144 getContext().getRegisterInfo()->isSuperOrSubRegisterEq(DstReg, SrcReg)) {
3147 MCRegister ATReg = getATReg(IDLoc);
3160 if (IsAddress && !Is32BitImm) {
3161 TOut.
emitRRI(Mips::DADDiu, DstReg, SrcReg, ImmValue, IDLoc, STI);
3165 TOut.
emitRRI(Mips::ADDiu, DstReg, SrcReg, ImmValue, IDLoc, STI);
3170 MCRegister TmpReg = DstReg;
3171 if (SrcReg == DstReg) {
3172 TmpReg = getATReg(IDLoc);
3177 TOut.
emitRRI(Mips::ORi, TmpReg, ZeroReg, ImmValue, IDLoc, STI);
3179 TOut.
emitRRR(
ABI.GetPtrAdduOp(), DstReg, TmpReg, SrcReg, IDLoc, STI);
3184 warnIfNoMacro(IDLoc);
3186 uint16_t Bits31To16 = (ImmValue >> 16) & 0xffff;
3187 uint16_t Bits15To0 = ImmValue & 0xffff;
3188 if (!Is32BitImm && !
isInt<32>(ImmValue)) {
3191 if (ImmValue == 0xffffffff) {
3192 TOut.
emitRI(Mips::LUi, TmpReg, 0xffff, IDLoc, STI);
3193 TOut.
emitRRI(Mips::DSRL32, TmpReg, TmpReg, 0, IDLoc, STI);
3195 TOut.
emitRRR(AdduOp, DstReg, TmpReg, SrcReg, IDLoc, STI);
3201 TOut.
emitRRI(Mips::ORi, TmpReg, ZeroReg, Bits31To16, IDLoc, STI);
3202 TOut.
emitRRI(Mips::DSLL, TmpReg, TmpReg, 16, IDLoc, STI);
3204 TOut.
emitRRI(Mips::ORi, TmpReg, TmpReg, Bits15To0, IDLoc, STI);
3206 TOut.
emitRRR(AdduOp, DstReg, TmpReg, SrcReg, IDLoc, STI);
3210 TOut.
emitRI(Mips::LUi, TmpReg, Bits31To16, IDLoc, STI);
3212 TOut.
emitRRI(Mips::ORi, TmpReg, TmpReg, Bits15To0, IDLoc, STI);
3214 TOut.
emitRRR(AdduOp, DstReg, TmpReg, SrcReg, IDLoc, STI);
3220 Error(IDLoc,
"instruction requires a 32-bit immediate");
3227 assert(
BitWidth >= 17 &&
"ImmValue must be at least 17-bit wide");
3231 unsigned ShiftAmount =
BitWidth - 16;
3232 uint16_t
Bits = (ImmValue >> ShiftAmount) & 0xffff;
3233 TOut.
emitRRI(Mips::ORi, TmpReg, ZeroReg, Bits, IDLoc, STI);
3234 TOut.
emitRRI(Mips::DSLL, TmpReg, TmpReg, ShiftAmount, IDLoc, STI);
3237 TOut.
emitRRR(AdduOp, DstReg, TmpReg, SrcReg, IDLoc, STI);
3242 warnIfNoMacro(IDLoc);
3249 if (loadImmediate(ImmValue >> 32, TmpReg, MCRegister(),
true,
false, IDLoc,
3255 unsigned ShiftCarriedForwards = 16;
3256 for (
int BitNum = 16; BitNum >= 0; BitNum -= 16) {
3257 uint16_t ImmChunk = (ImmValue >> BitNum) & 0xffff;
3259 if (ImmChunk != 0) {
3260 TOut.
emitDSLL(TmpReg, TmpReg, ShiftCarriedForwards, IDLoc, STI);
3261 TOut.
emitRRI(Mips::ORi, TmpReg, TmpReg, ImmChunk, IDLoc, STI);
3262 ShiftCarriedForwards = 0;
3265 ShiftCarriedForwards += 16;
3267 ShiftCarriedForwards -= 16;
3270 if (ShiftCarriedForwards)
3271 TOut.
emitDSLL(TmpReg, TmpReg, ShiftCarriedForwards, IDLoc, STI);
3274 TOut.
emitRRR(AdduOp, DstReg, TmpReg, SrcReg, IDLoc, STI);
3279bool MipsAsmParser::expandLoadImm(MCInst &Inst,
bool Is32BitImm, SMLoc IDLoc,
3280 MCStreamer &Out,
const MCSubtargetInfo *STI) {
3282 assert(ImmOp.
isImm() &&
"expected immediate operand kind");
3283 const MCOperand &DstRegOp = Inst.
getOperand(0);
3284 assert(DstRegOp.
isReg() &&
"expected register operand kind");
3286 if (loadImmediate(ImmOp.
getImm(), DstRegOp.
getReg(), MCRegister(), Is32BitImm,
3287 false, IDLoc, Out, STI))
3293bool MipsAsmParser::expandLoadAddress(MCRegister DstReg, MCRegister BaseReg,
3295 bool Is32BitAddress, SMLoc IDLoc,
3297 const MCSubtargetInfo *STI) {
3299 if (Is32BitAddress &&
ABI.ArePtrs64bit()) {
3300 Warning(IDLoc,
"la used to load 64-bit address");
3302 Is32BitAddress =
false;
3306 if (!Is32BitAddress && !hasMips3()) {
3307 Error(IDLoc,
"instruction requires a 64-bit architecture");
3312 return loadAndAddSymbolAddress(
Offset.getExpr(), DstReg, BaseReg,
3313 Is32BitAddress, IDLoc, Out, STI);
3315 if (!
ABI.ArePtrs64bit()) {
3317 Is32BitAddress =
true;
3320 return loadImmediate(
Offset.getImm(), DstReg, BaseReg, Is32BitAddress,
true,
3329bool MipsAsmParser::canDeferGOTLoad(
const MCSymbol *Sym) {
3331 static_cast<const MCSymbolELF *
>(Sym)->isBindingSet())
3336 MCAssembler *
Asm = getStreamer().getAssemblerPtr();
3337 return Asm && !
Asm->getRelaxAll() && !
Asm->isBundlingEnabled();
3340bool MipsAsmParser::loadAndAddSymbolAddress(
const MCExpr *SymExpr,
3342 MCRegister SrcReg,
bool Is32BitSym,
3343 SMLoc IDLoc, MCStreamer &Out,
3344 const MCSubtargetInfo *STI) {
3345 MipsTargetStreamer &TOut = getTargetStreamer();
3347 SrcReg.
isValid() && SrcReg != Mips::R0 && SrcReg != Mips::R0_64;
3348 warnIfNoMacro(IDLoc);
3353 Error(IDLoc,
"expected relocatable expression");
3357 Error(IDLoc,
"expected relocatable expression with only one symbol");
3361 bool IsPtr64 =
ABI.ArePtrs64bit();
3364 ?
static_cast<const MCSymbolELF *
>(Res.
getAddSym())
3372 bool UseXGOT = STI->
hasFeature(Mips::FeatureXGOT) && !IsLocalSym;
3380 !IsLocalSym && !UseXGOT && canDeferGOTLoad(Res.
getAddSym());
3381 auto EmitDeferredGOTLoad = [&](MCRegister
Reg,
unsigned Flags) {
3383 Inst.
setOpcode(Mips::PseudoGOTLoadGlobal);
3396 if ((DstReg ==
getABI().getTempReg(9,
false) ||
3397 DstReg ==
getABI().getTempReg(9,
true)) &&
3398 !UseSrcReg && Res.
getConstant() == 0 && !IsLocalSym) {
3400 const MCExpr *CallHiExpr =
3402 const MCExpr *CallLoExpr =
3406 TOut.
emitRRR(IsPtr64 ? Mips::DADDu : Mips::ADDu, DstReg, DstReg, GPReg,
3408 TOut.
emitRRX(IsPtr64 ? Mips::LD : Mips::LW, DstReg, DstReg,
3410 }
else if (DeferLocal) {
3412 if (
ABI.IsN32() ||
ABI.IsN64())
3416 EmitDeferredGOTLoad(DstReg, Flags);
3418 const MCExpr *CallExpr =
3420 TOut.
emitRRX(IsPtr64 ? Mips::LD : Mips::LW, DstReg, GPReg,
3426 MCRegister TmpReg = DstReg;
3428 getContext().getRegisterInfo()->isSuperOrSubRegisterEq(DstReg,
3432 MCRegister ATReg = getATReg(IDLoc);
3440 if (DeferLocal &&
ABI.IsO32()) {
3441 EmitDeferredGOTLoad(TmpReg, 0);
3443 TOut.
emitRRR(Mips::ADDu, DstReg, TmpReg, SrcReg, IDLoc, STI);
3460 const MCExpr *CallHiExpr =
3467 TOut.
emitRRR(IsPtr64 ? Mips::DADDu : Mips::ADDu, TmpReg, TmpReg, GPReg,
3469 TOut.
emitRRX(IsPtr64 ? Mips::LD : Mips::LW, TmpReg, TmpReg,
3473 TOut.
emitRRX(IsPtr64 ? Mips::DADDiu : Mips::ADDiu, TmpReg, TmpReg,
3479 TOut.
emitRRR(IsPtr64 ? Mips::DADDu : Mips::ADDu, DstReg, TmpReg, SrcReg,
3484 const MCSpecifierExpr *GotExpr =
nullptr;
3485 const MCExpr *LoExpr =
nullptr;
3486 if (
ABI.IsN32() ||
ABI.IsN64()) {
3505 Error(IDLoc,
"macro instruction uses large offset, which is not "
3506 "currently supported");
3535 TOut.
emitRRX(IsPtr64 ? Mips::LD : Mips::LW, TmpReg, GPReg,
3539 TOut.
emitRRX(IsPtr64 ? Mips::DADDiu : Mips::ADDiu, TmpReg, TmpReg,
3543 TOut.
emitRRR(IsPtr64 ? Mips::DADDu : Mips::ADDu, DstReg, TmpReg, SrcReg,
3549 const auto *HiExpr =
3551 const auto *LoExpr =
3555 if (
ABI.ArePtrs64bit() && isGP64bit()) {
3563 const auto *HighestExpr =
3565 const auto *HigherExpr =
3570 getContext().getRegisterInfo()->isSuperOrSubRegisterEq(DstReg, SrcReg);
3572 if (canUseATReg() && UseSrcReg && RdRegIsRsReg) {
3573 MCRegister ATReg = getATReg(IDLoc);
3585 TOut.
emitRRX(Mips::DADDiu, ATReg, ATReg,
3587 TOut.
emitRRI(Mips::DSLL, ATReg, ATReg, 16, IDLoc, STI);
3590 TOut.
emitRRI(Mips::DSLL, ATReg, ATReg, 16, IDLoc, STI);
3593 TOut.
emitRRR(Mips::DADDu, DstReg, ATReg, SrcReg, IDLoc, STI);
3596 }
else if (canUseATReg() && !RdRegIsRsReg && DstReg != getATReg(IDLoc)) {
3597 MCRegister ATReg = getATReg(IDLoc);
3613 TOut.
emitRRX(Mips::DADDiu, DstReg, DstReg,
3617 TOut.
emitRRI(Mips::DSLL32, DstReg, DstReg, 0, IDLoc, STI);
3618 TOut.
emitRRR(Mips::DADDu, DstReg, DstReg, ATReg, IDLoc, STI);
3620 TOut.
emitRRR(Mips::DADDu, DstReg, DstReg, SrcReg, IDLoc, STI);
3623 }
else if ((!canUseATReg() && !RdRegIsRsReg) ||
3624 (canUseATReg() && DstReg == getATReg(IDLoc))) {
3635 TOut.
emitRRX(Mips::DADDiu, DstReg, DstReg,
3637 TOut.
emitRRI(Mips::DSLL, DstReg, DstReg, 16, IDLoc, STI);
3638 TOut.
emitRRX(Mips::DADDiu, DstReg, DstReg,
3640 TOut.
emitRRI(Mips::DSLL, DstReg, DstReg, 16, IDLoc, STI);
3641 TOut.
emitRRX(Mips::DADDiu, DstReg, DstReg,
3644 TOut.
emitRRR(Mips::DADDu, DstReg, DstReg, SrcReg, IDLoc, STI);
3650 assert(SrcReg == DstReg && !canUseATReg() &&
3651 "Could have expanded dla but didn't?");
3652 reportParseError(IDLoc,
3653 "pseudo-instruction requires $at, which is not available");
3667 MCRegister TmpReg = DstReg;
3669 getContext().getRegisterInfo()->isSuperOrSubRegisterEq(DstReg, SrcReg)) {
3672 MCRegister ATReg = getATReg(IDLoc);
3683 TOut.
emitRRR(Mips::ADDu, DstReg, TmpReg, SrcReg, IDLoc, STI);
3686 getContext().getRegisterInfo()->isSuperOrSubRegisterEq(DstReg, TmpReg));
3695 if (getMipsMCRegisterClass(Mips::FGR32RegClassID).
contains(
Reg))
3696 return Reg == (
unsigned)Mips::F31 ? (
unsigned)Mips::F0 :
Reg + 1;
3698 default:
llvm_unreachable(
"Unknown register in assembly macro expansion!");
3763 case Mips::D0:
return Mips::F1;
3764 case Mips::D1:
return Mips::F3;
3765 case Mips::D2:
return Mips::F5;
3766 case Mips::D3:
return Mips::F7;
3767 case Mips::D4:
return Mips::F9;
3768 case Mips::D5:
return Mips::F11;
3769 case Mips::D6:
return Mips::F13;
3770 case Mips::D7:
return Mips::F15;
3771 case Mips::D8:
return Mips::F17;
3772 case Mips::D9:
return Mips::F19;
3794bool MipsAsmParser::emitPartialAddress(MipsTargetStreamer &TOut, SMLoc IDLoc,
3796 MCRegister ATReg = getATReg(IDLoc);
3802 const auto *GotExpr =
3805 if(isABI_O32() || isABI_N32()) {
3814 const auto *HiExpr =
3823 if(isABI_O32() || isABI_N32()) {
3827 const auto *HighestExpr =
3830 const auto *HigherExpr =
3835 TOut.
emitRRX(Mips::DADDiu, ATReg, ATReg,
3837 TOut.
emitRRI(Mips::DSLL, ATReg, ATReg, 16, IDLoc, STI);
3840 TOut.
emitRRI(Mips::DSLL, ATReg, ATReg, 16, IDLoc, STI);
3849 if ((
Hi_32(ImmOp64) & 0x7ff00000) == 0) {
3860 float TmpFloat =
static_cast<float>(DoubleImm);
3864bool MipsAsmParser::expandLoadSingleImmToGPR(MCInst &Inst, SMLoc IDLoc,
3866 const MCSubtargetInfo *STI) {
3869 "Invalid instruction operand.");
3876 return loadImmediate(ImmOp32, FirstReg, MCRegister(),
true,
false, IDLoc, Out,
3880bool MipsAsmParser::expandLoadSingleImmToFPR(MCInst &Inst, SMLoc IDLoc,
3882 const MCSubtargetInfo *STI) {
3883 MipsTargetStreamer &TOut = getTargetStreamer();
3886 "Invalid instruction operand.");
3895 MCRegister TmpReg = Mips::R0;
3897 TmpReg = getATReg(IDLoc);
3902 if (
Lo_32(ImmOp64) == 0) {
3903 if (TmpReg != Mips::R0 && loadImmediate(ImmOp32, TmpReg, MCRegister(),
true,
3904 false, IDLoc, Out, STI))
3906 TOut.
emitRR(Mips::MTC1, FirstReg, TmpReg, IDLoc, STI);
3910 MCSection *CS = getStreamer().getCurrentSectionOnly();
3913 MCSection *ReadOnlySection =
3920 getStreamer().switchSection(ReadOnlySection);
3921 getStreamer().emitLabel(Sym, IDLoc);
3922 getStreamer().emitInt32(ImmOp32);
3923 getStreamer().switchSection(CS);
3925 if (emitPartialAddress(TOut, IDLoc, Sym))
3932bool MipsAsmParser::expandLoadDoubleImmToGPR(MCInst &Inst, SMLoc IDLoc,
3934 const MCSubtargetInfo *STI) {
3935 MipsTargetStreamer &TOut = getTargetStreamer();
3938 "Invalid instruction operand.");
3945 if (
Lo_32(ImmOp64) == 0) {
3947 if (loadImmediate(ImmOp64, FirstReg, MCRegister(),
false,
false, IDLoc,
3951 if (loadImmediate(
Hi_32(ImmOp64), FirstReg, MCRegister(),
true,
false,
3955 if (loadImmediate(0,
nextReg(FirstReg), MCRegister(),
true,
false, IDLoc,
3962 MCSection *CS = getStreamer().getCurrentSectionOnly();
3963 MCSection *ReadOnlySection =
3970 getStreamer().switchSection(ReadOnlySection);
3971 getStreamer().emitValueToAlignment(
Align(8));
3972 getStreamer().emitLabel(Sym, IDLoc);
3973 getStreamer().emitIntValue(ImmOp64, 8);
3974 getStreamer().switchSection(CS);
3976 MCRegister TmpReg = getATReg(IDLoc);
3980 if (emitPartialAddress(TOut, IDLoc, Sym))
3983 TOut.
emitRRX(isABI_N64() ? Mips::DADDiu : Mips::ADDiu, TmpReg, TmpReg,
3987 TOut.
emitRRI(Mips::LD, FirstReg, TmpReg, 0, IDLoc, STI);
3989 TOut.
emitRRI(Mips::LW, FirstReg, TmpReg, 0, IDLoc, STI);
3990 TOut.
emitRRI(Mips::LW,
nextReg(FirstReg), TmpReg, 4, IDLoc, STI);
3995bool MipsAsmParser::expandLoadDoubleImmToFPR(MCInst &Inst,
bool Is64FPU,
3996 SMLoc IDLoc, MCStreamer &Out,
3997 const MCSubtargetInfo *STI) {
3998 MipsTargetStreamer &TOut = getTargetStreamer();
4001 "Invalid instruction operand.");
4008 MCRegister TmpReg = Mips::R0;
4010 TmpReg = getATReg(IDLoc);
4015 if ((
Lo_32(ImmOp64) == 0) &&
4016 !((
Hi_32(ImmOp64) & 0xffff0000) && (
Hi_32(ImmOp64) & 0x0000ffff))) {
4018 if (TmpReg != Mips::R0 && loadImmediate(ImmOp64, TmpReg, MCRegister(),
4019 false,
false, IDLoc, Out, STI))
4021 TOut.
emitRR(Mips::DMTC1, FirstReg, TmpReg, IDLoc, STI);
4025 if (TmpReg != Mips::R0 &&
4026 loadImmediate(
Hi_32(ImmOp64), TmpReg, MCRegister(),
true,
false, IDLoc,
4030 if (hasMips32r2()) {
4031 TOut.
emitRR(Mips::MTC1, FirstReg, Mips::R0, IDLoc, STI);
4032 TOut.
emitRRR(Mips::MTHC1_D32, FirstReg, FirstReg, TmpReg, IDLoc, STI);
4034 TOut.
emitRR(Mips::MTC1,
nextReg(FirstReg), TmpReg, IDLoc, STI);
4035 TOut.
emitRR(Mips::MTC1, FirstReg, Mips::R0, IDLoc, STI);
4040 MCSection *CS = getStreamer().getCurrentSectionOnly();
4043 MCSection *ReadOnlySection =
4050 getStreamer().switchSection(ReadOnlySection);
4051 getStreamer().emitValueToAlignment(
Align(8));
4052 getStreamer().emitLabel(Sym, IDLoc);
4053 getStreamer().emitIntValue(ImmOp64, 8);
4054 getStreamer().switchSection(CS);
4056 if (emitPartialAddress(TOut, IDLoc, Sym))
4060 if (!Is64FPU && !hasMips2()) {
4061 MCRegister FirstWordReg = FirstReg;
4062 MCRegister SecondWordReg =
nextReg(FirstReg);
4063 if (!IsLittleEndian)
4068 const auto *SecondWordExpr =
4070 TOut.
emitRRX(Mips::LWC1, FirstWordReg, TmpReg,
4072 TOut.
emitRRX(Mips::LWC1, SecondWordReg, TmpReg,
4077 TOut.
emitRRX(Is64FPU ? Mips::LDC164 : Mips::LDC1, FirstReg, TmpReg,
4083bool MipsAsmParser::expandUncondBranchMMPseudo(MCInst &Inst, SMLoc IDLoc,
4085 const MCSubtargetInfo *STI) {
4086 MipsTargetStreamer &TOut = getTargetStreamer();
4089 "unexpected number of operands");
4099 assert(
Offset.isImm() &&
"expected immediate operand kind");
4103 if (inMicroMipsMode())
4104 Inst.
setOpcode(hasMips32r6() ? Mips::BC16_MMR6 : Mips::B16_MM);
4107 return Error(IDLoc,
"branch target out of range");
4109 return Error(IDLoc,
"branch to misaligned address");
4121 const MCInstrDesc &MCID = MII.get(Inst.
getOpcode());
4128bool MipsAsmParser::expandBranchImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
4129 const MCSubtargetInfo *STI) {
4130 MipsTargetStreamer &TOut = getTargetStreamer();
4131 const MCOperand &DstRegOp = Inst.
getOperand(0);
4132 assert(DstRegOp.
isReg() &&
"expected register operand kind");
4135 assert(ImmOp.
isImm() &&
"expected immediate operand kind");
4137 const MCOperand &MemOffsetOp = Inst.
getOperand(2);
4139 "expected immediate or expression operand");
4141 bool IsLikely =
false;
4151 case Mips::BEQLImmMacro:
4155 case Mips::BNELImmMacro:
4164 int64_t ImmValue = ImmOp.
getImm();
4165 if (ImmValue == 0) {
4169 TOut.
emitRRI(Mips::SLL, Mips::R0, Mips::R0, 0, IDLoc, STI);
4171 TOut.
emitRRX(OpCode, DstRegOp.
getReg(), Mips::R0, MemOffsetOp, IDLoc,
4174 warnIfNoMacro(IDLoc);
4176 MCRegister ATReg = getATReg(IDLoc);
4180 if (loadImmediate(ImmValue, ATReg, MCRegister(), !isGP64bit(),
true, IDLoc,
4184 if (IsLikely && MemOffsetOp.
isExpr()) {
4187 TOut.
emitRRI(Mips::SLL, Mips::R0, Mips::R0, 0, IDLoc, STI);
4189 TOut.
emitRRX(OpCode, DstRegOp.
getReg(), ATReg, MemOffsetOp, IDLoc, STI);
4194void MipsAsmParser::expandMem16Inst(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
4195 const MCSubtargetInfo *STI,
bool IsLoad) {
4197 assert((NumOp == 3 || NumOp == 4) &&
"unexpected operands number");
4198 unsigned StartOp = NumOp == 3 ? 0 : 1;
4200 const MCOperand &DstRegOp = Inst.
getOperand(StartOp);
4201 assert(DstRegOp.
isReg() &&
"expected register operand kind");
4202 const MCOperand &BaseRegOp = Inst.
getOperand(StartOp + 1);
4203 assert(BaseRegOp.
isReg() &&
"expected register operand kind");
4206 MipsTargetStreamer &TOut = getTargetStreamer();
4208 MCRegister DstReg = DstRegOp.
getReg();
4210 MCRegister TmpReg = DstReg;
4212 const MCInstrDesc &
Desc = MII.get(OpCode);
4213 int16_t DstRegClass =
4214 MII.getOpRegClassID(
Desc.operands()[StartOp],
4216 unsigned DstRegClassID =
4217 getContext().getRegisterInfo()->getRegClass(DstRegClass).getID();
4218 bool IsGPR = (DstRegClassID == Mips::GPR32RegClassID) ||
4219 (DstRegClassID == Mips::GPR64RegClassID);
4221 if (!IsLoad || !IsGPR || (BaseReg == DstReg)) {
4224 TmpReg = getATReg(IDLoc);
4229 auto emitInstWithOffset = [&](
const MCOperand &
Off) {
4231 TOut.
emitRRX(OpCode, DstReg, TmpReg,
Off, IDLoc, STI);
4233 TOut.
emitRRRX(OpCode, DstReg, DstReg, TmpReg,
Off, IDLoc, STI);
4237 int64_t LoOffset =
OffsetOp.getImm() & 0xffff;
4238 int64_t HiOffset =
OffsetOp.getImm() & ~0xffff;
4242 if (LoOffset & 0x8000)
4243 HiOffset += 0x10000;
4245 bool IsLargeOffset = HiOffset != 0;
4247 if (IsLargeOffset) {
4249 if (loadImmediate(HiOffset, TmpReg, MCRegister(), Is32BitImm,
true, IDLoc,
4254 if (BaseReg != Mips::R0 && BaseReg != Mips::R0_64)
4255 TOut.
emitRRR(
ABI.ArePtrs64bit() ? Mips::DADDu : Mips::ADDu, TmpReg,
4256 TmpReg, BaseReg, IDLoc, STI);
4270 if (!
OffsetOp.getExpr()->evaluateAsRelocatable(Res,
nullptr)) {
4271 Error(IDLoc,
"expected relocatable expression");
4275 Error(IDLoc,
"expected relocatable expression with only one symbol");
4279 loadAndAddSymbolAddress(
4281 BaseReg, !
ABI.ArePtrs64bit(), IDLoc, Out, STI);
4289 const MCExpr *OffExpr =
OffsetOp.getExpr();
4301 TOut.
emitRX(Mips::LUi, TmpReg, HighestOperand, IDLoc, STI);
4302 TOut.
emitRRX(Mips::DADDiu, TmpReg, TmpReg, HigherOperand, IDLoc, STI);
4303 TOut.
emitRRI(Mips::DSLL, TmpReg, TmpReg, 16, IDLoc, STI);
4304 TOut.
emitRRX(Mips::DADDiu, TmpReg, TmpReg, HiOperand, IDLoc, STI);
4305 TOut.
emitRRI(Mips::DSLL, TmpReg, TmpReg, 16, IDLoc, STI);
4306 if (BaseReg != Mips::R0 && BaseReg != Mips::R0_64)
4307 TOut.
emitRRR(Mips::DADDu, TmpReg, TmpReg, BaseReg, IDLoc, STI);
4308 emitInstWithOffset(LoOperand);
4311 TOut.
emitRX(Mips::LUi, TmpReg, HiOperand, IDLoc, STI);
4312 if (BaseReg != Mips::R0)
4313 TOut.
emitRRR(Mips::ADDu, TmpReg, TmpReg, BaseReg, IDLoc, STI);
4315 emitInstWithOffset(LoOperand);
4324void MipsAsmParser::expandMem9Inst(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
4325 const MCSubtargetInfo *STI,
bool IsLoad) {
4327 assert((NumOp == 3 || NumOp == 4) &&
"unexpected operands number");
4328 unsigned StartOp = NumOp == 3 ? 0 : 1;
4330 const MCOperand &DstRegOp = Inst.
getOperand(StartOp);
4331 assert(DstRegOp.
isReg() &&
"expected register operand kind");
4332 const MCOperand &BaseRegOp = Inst.
getOperand(StartOp + 1);
4333 assert(BaseRegOp.
isReg() &&
"expected register operand kind");
4336 MipsTargetStreamer &TOut = getTargetStreamer();
4338 MCRegister DstReg = DstRegOp.
getReg();
4340 MCRegister TmpReg = DstReg;
4342 const MCInstrDesc &
Desc = MII.get(OpCode);
4343 int16_t DstRegClass =
4344 MII.getOpRegClassID(
Desc.operands()[StartOp],
4347 unsigned DstRegClassID =
4348 getContext().getRegisterInfo()->getRegClass(DstRegClass).getID();
4349 bool IsGPR = (DstRegClassID == Mips::GPR32RegClassID) ||
4350 (DstRegClassID == Mips::GPR64RegClassID);
4352 if (!IsLoad || !IsGPR || (BaseReg == DstReg)) {
4355 TmpReg = getATReg(IDLoc);
4360 auto emitInst = [&]() {
4369 loadImmediate(
OffsetOp.getImm(), TmpReg, BaseReg, !
ABI.ArePtrs64bit(),
true,
4376 loadAndAddSymbolAddress(
OffsetOp.getExpr(), TmpReg, BaseReg,
4377 !
ABI.ArePtrs64bit(), IDLoc, Out, STI);
4385bool MipsAsmParser::expandLoadStoreMultiple(MCInst &Inst, SMLoc IDLoc,
4387 const MCSubtargetInfo *STI) {
4390 unsigned NewOpcode = Opcode == Mips::SWM_MM ? Mips::SWM32_MM : Mips::LWM32_MM;
4394 Inst.
getOperand(OpNum - 3).
isReg() &&
"Invalid instruction operand.");
4403 if (inMicroMipsMode() && hasMips32r6())
4404 NewOpcode = Opcode == Mips::SWM_MM ? Mips::SWM16_MMR6 : Mips::LWM16_MMR6;
4406 NewOpcode = Opcode == Mips::SWM_MM ? Mips::SWM16_MM : Mips::LWM16_MM;
4414bool MipsAsmParser::expandCondBranches(MCInst &Inst, SMLoc IDLoc,
4416 const MCSubtargetInfo *STI) {
4417 MipsTargetStreamer &TOut = getTargetStreamer();
4418 bool EmittedNoMacroWarning =
false;
4419 unsigned PseudoOpcode = Inst.
getOpcode();
4424 unsigned ZeroSrcOpcode, ZeroTrgOpcode;
4425 bool ReverseOrderSLT, IsUnsigned, IsLikely, AcceptsEquality;
4430 else if (TrgOp.
isImm()) {
4431 warnIfNoMacro(IDLoc);
4432 EmittedNoMacroWarning =
true;
4434 TrgReg = getATReg(IDLoc);
4438 switch(PseudoOpcode) {
4441 case Mips::BLTImmMacro:
4442 PseudoOpcode = Mips::BLT;
4444 case Mips::BLEImmMacro:
4445 PseudoOpcode = Mips::BLE;
4447 case Mips::BGEImmMacro:
4448 PseudoOpcode = Mips::BGE;
4450 case Mips::BGTImmMacro:
4451 PseudoOpcode = Mips::BGT;
4453 case Mips::BLTUImmMacro:
4454 PseudoOpcode = Mips::BLTU;
4456 case Mips::BLEUImmMacro:
4457 PseudoOpcode = Mips::BLEU;
4459 case Mips::BGEUImmMacro:
4460 PseudoOpcode = Mips::BGEU;
4462 case Mips::BGTUImmMacro:
4463 PseudoOpcode = Mips::BGTU;
4465 case Mips::BLTLImmMacro:
4466 PseudoOpcode = Mips::BLTL;
4468 case Mips::BLELImmMacro:
4469 PseudoOpcode = Mips::BLEL;
4471 case Mips::BGELImmMacro:
4472 PseudoOpcode = Mips::BGEL;
4474 case Mips::BGTLImmMacro:
4475 PseudoOpcode = Mips::BGTL;
4477 case Mips::BLTULImmMacro:
4478 PseudoOpcode = Mips::BLTUL;
4480 case Mips::BLEULImmMacro:
4481 PseudoOpcode = Mips::BLEUL;
4483 case Mips::BGEULImmMacro:
4484 PseudoOpcode = Mips::BGEUL;
4486 case Mips::BGTULImmMacro:
4487 PseudoOpcode = Mips::BGTUL;
4491 if (loadImmediate(TrgOp.
getImm(), TrgReg, MCRegister(), !isGP64bit(),
false,
4496 switch (PseudoOpcode) {
4501 AcceptsEquality =
false;
4502 ReverseOrderSLT =
false;
4504 ((PseudoOpcode == Mips::BLTU) || (PseudoOpcode == Mips::BLTUL));
4505 IsLikely = ((PseudoOpcode == Mips::BLTL) || (PseudoOpcode == Mips::BLTUL));
4506 ZeroSrcOpcode = Mips::BGTZ;
4507 ZeroTrgOpcode = Mips::BLTZ;
4513 AcceptsEquality =
true;
4514 ReverseOrderSLT =
true;
4516 ((PseudoOpcode == Mips::BLEU) || (PseudoOpcode == Mips::BLEUL));
4517 IsLikely = ((PseudoOpcode == Mips::BLEL) || (PseudoOpcode == Mips::BLEUL));
4518 ZeroSrcOpcode = Mips::BGEZ;
4519 ZeroTrgOpcode = Mips::BLEZ;
4525 AcceptsEquality =
true;
4526 ReverseOrderSLT =
false;
4528 ((PseudoOpcode == Mips::BGEU) || (PseudoOpcode == Mips::BGEUL));
4529 IsLikely = ((PseudoOpcode == Mips::BGEL) || (PseudoOpcode == Mips::BGEUL));
4530 ZeroSrcOpcode = Mips::BLEZ;
4531 ZeroTrgOpcode = Mips::BGEZ;
4537 AcceptsEquality =
false;
4538 ReverseOrderSLT =
true;
4540 ((PseudoOpcode == Mips::BGTU) || (PseudoOpcode == Mips::BGTUL));
4541 IsLikely = ((PseudoOpcode == Mips::BGTL) || (PseudoOpcode == Mips::BGTUL));
4542 ZeroSrcOpcode = Mips::BLTZ;
4543 ZeroTrgOpcode = Mips::BGTZ;
4549 bool IsTrgRegZero = (TrgReg == Mips::R0);
4550 bool IsSrcRegZero = (SrcReg == Mips::R0);
4551 if (IsSrcRegZero && IsTrgRegZero) {
4555 if (PseudoOpcode == Mips::BLT) {
4560 if (PseudoOpcode == Mips::BLE) {
4563 Warning(IDLoc,
"branch is always taken");
4566 if (PseudoOpcode == Mips::BGE) {
4569 Warning(IDLoc,
"branch is always taken");
4572 if (PseudoOpcode == Mips::BGT) {
4577 if (PseudoOpcode == Mips::BGTU) {
4578 TOut.
emitRRX(Mips::BNE, Mips::R0, Mips::R0,
4582 if (AcceptsEquality) {
4585 TOut.
emitRRX(Mips::BEQ, Mips::R0, Mips::R0,
4587 Warning(IDLoc,
"branch is always taken");
4594 if (IsSrcRegZero || IsTrgRegZero) {
4595 if ((IsSrcRegZero && PseudoOpcode == Mips::BGTU) ||
4596 (IsTrgRegZero && PseudoOpcode == Mips::BLTU)) {
4603 if ((IsSrcRegZero && PseudoOpcode == Mips::BLEU) ||
4604 (IsTrgRegZero && PseudoOpcode == Mips::BGEU)) {
4610 TOut.
emitRRX(Mips::BEQ, Mips::R0, Mips::R0,
4612 Warning(IDLoc,
"branch is always taken");
4628 TOut.
emitRRX(AcceptsEquality ? Mips::BEQ : Mips::BNE,
4629 IsSrcRegZero ? TrgReg : SrcReg, Mips::R0,
4636 TOut.
emitRX(IsSrcRegZero ? ZeroSrcOpcode : ZeroTrgOpcode,
4637 IsSrcRegZero ? TrgReg : SrcReg,
4644 MCRegister ATRegNum = getATReg(IDLoc);
4648 if (!EmittedNoMacroWarning)
4649 warnIfNoMacro(IDLoc);
4666 TOut.
emitRRR(IsUnsigned ? Mips::SLTu : Mips::SLT, ATRegNum,
4667 ReverseOrderSLT ? TrgReg : SrcReg,
4668 ReverseOrderSLT ? SrcReg : TrgReg, IDLoc, STI);
4670 TOut.
emitRRX(IsLikely ? (AcceptsEquality ? Mips::BEQL : Mips::BNEL)
4671 : (AcceptsEquality ? Mips::BEQ : Mips::BNE),
4685bool MipsAsmParser::expandDivRem(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
4686 const MCSubtargetInfo *STI,
4687 const bool IsMips64,
const bool Signed) {
4688 MipsTargetStreamer &TOut = getTargetStreamer();
4690 warnIfNoMacro(IDLoc);
4692 const MCOperand &RdRegOp = Inst.
getOperand(0);
4693 assert(RdRegOp.
isReg() &&
"expected register operand kind");
4694 MCRegister RdReg = RdRegOp.
getReg();
4696 const MCOperand &RsRegOp = Inst.
getOperand(1);
4697 assert(RsRegOp.
isReg() &&
"expected register operand kind");
4698 MCRegister RsReg = RsRegOp.
getReg();
4705 "expected register or immediate operand kind");
4709 ImmValue = RtOp.
getImm();
4716 DivOp =
Signed ? Mips::DSDIV : Mips::DUDIV;
4717 ZeroReg = Mips::R0_64;
4720 DivOp =
Signed ? Mips::SDIV : Mips::UDIV;
4725 bool UseTraps = useTraps();
4728 bool isDiv = Opcode == Mips::SDivMacro || Opcode == Mips::SDivIMacro ||
4729 Opcode == Mips::UDivMacro || Opcode == Mips::UDivIMacro ||
4730 Opcode == Mips::DSDivMacro || Opcode == Mips::DSDivIMacro ||
4731 Opcode == Mips::DUDivMacro || Opcode == Mips::DUDivIMacro;
4733 bool isRem = Opcode == Mips::SRemMacro || Opcode == Mips::SRemIMacro ||
4734 Opcode == Mips::URemMacro || Opcode == Mips::URemIMacro ||
4735 Opcode == Mips::DSRemMacro || Opcode == Mips::DSRemIMacro ||
4736 Opcode == Mips::DURemMacro || Opcode == Mips::DURemIMacro;
4739 MCRegister ATReg = getATReg(IDLoc);
4743 if (!CLOpts.mno_check_zero_division && ImmValue == 0) {
4745 TOut.
emitRRI(Mips::TEQ, ZeroReg, ZeroReg, 0x7, IDLoc, STI);
4747 TOut.
emitII(Mips::BREAK, 0x7, 0, IDLoc, STI);
4751 if (isRem && (ImmValue == 1 || (
Signed && (ImmValue == -1)))) {
4752 TOut.
emitRRR(Mips::OR, RdReg, ZeroReg, ZeroReg, IDLoc, STI);
4754 }
else if (isDiv && ImmValue == 1) {
4755 TOut.
emitRRR(Mips::OR, RdReg, RsReg, Mips::R0, IDLoc, STI);
4757 }
else if (isDiv &&
Signed && ImmValue == -1) {
4758 TOut.
emitRRR(SubOp, RdReg, ZeroReg, RsReg, IDLoc, STI);
4761 if (loadImmediate(ImmValue, ATReg, MCRegister(),
isInt<32>(ImmValue),
4762 false, Inst.
getLoc(), Out, STI))
4764 TOut.
emitRR(DivOp, RsReg, ATReg, IDLoc, STI);
4765 TOut.
emitR(isDiv ? Mips::MFLO : Mips::MFHI, RdReg, IDLoc, STI);
4775 if (!CLOpts.mno_check_zero_division &&
4776 (RtReg == Mips::R0 || RtReg == Mips::R0_64)) {
4778 TOut.
emitRRI(Mips::TEQ, ZeroReg, ZeroReg, 0x7, IDLoc, STI);
4781 TOut.
emitII(Mips::BREAK, 0x7, 0, IDLoc, STI);
4787 if (isRem && (RdReg == Mips::R0 || RdReg == Mips::R0_64)) {
4788 TOut.
emitRR(DivOp, RsReg, RtReg, IDLoc, STI);
4797 TOut.
emitRR(DivOp, RsReg, RtReg, IDLoc, STI);
4798 if (!CLOpts.mno_check_zero_division) {
4800 TOut.
emitRRI(Mips::TEQ, RtReg, ZeroReg, 0x7, IDLoc, STI);
4803 BrTarget =
Context.createTempSymbol();
4806 TOut.
emitRRX(Mips::BNE, RtReg, ZeroReg, LabelOp, IDLoc, STI);
4811 TOut.
emitII(Mips::BREAK, 0x7, 0, IDLoc, STI);
4817 TOut.
emitR(isDiv ? Mips::MFLO : Mips::MFHI, RdReg, IDLoc, STI);
4821bool MipsAsmParser::expandTrunc(MCInst &Inst,
bool IsDouble,
bool Is64FPU,
4822 SMLoc IDLoc, MCStreamer &Out,
4823 const MCSubtargetInfo *STI) {
4824 MipsTargetStreamer &TOut = getTargetStreamer();
4834 if (hasMips1() && !hasMips2()) {
4835 MCRegister ATReg = getATReg(IDLoc);
4838 TOut.
emitRR(Mips::CFC1, ThirdReg, Mips::FCR31, IDLoc, STI);
4839 TOut.
emitRR(Mips::CFC1, ThirdReg, Mips::FCR31, IDLoc, STI);
4841 TOut.
emitRRI(Mips::ORi, ATReg, ThirdReg, 0x3, IDLoc, STI);
4842 TOut.
emitRRI(Mips::XORi, ATReg, ATReg, 0x2, IDLoc, STI);
4843 TOut.
emitRR(Mips::CTC1, Mips::FCR31, ATReg, IDLoc, STI);
4845 TOut.
emitRR(IsDouble ? (Is64FPU ? Mips::CVT_W_D64 : Mips::CVT_W_D32)
4847 FirstReg, SecondReg, IDLoc, STI);
4848 TOut.
emitRR(Mips::CTC1, Mips::FCR31, ThirdReg, IDLoc, STI);
4853 TOut.
emitRR(IsDouble ? (Is64FPU ? Mips::TRUNC_W_D64 : Mips::TRUNC_W_D32)
4855 FirstReg, SecondReg, IDLoc, STI);
4860bool MipsAsmParser::expandUlh(MCInst &Inst,
bool Signed, SMLoc IDLoc,
4861 MCStreamer &Out,
const MCSubtargetInfo *STI) {
4862 if (hasMips32r6() || hasMips64r6()) {
4863 return Error(IDLoc,
"instruction not supported on mips32r6 or mips64r6");
4866 const MCOperand &DstRegOp = Inst.
getOperand(0);
4867 assert(DstRegOp.
isReg() &&
"expected register operand kind");
4868 const MCOperand &SrcRegOp = Inst.
getOperand(1);
4869 assert(SrcRegOp.
isReg() &&
"expected register operand kind");
4870 const MCOperand &OffsetImmOp = Inst.
getOperand(2);
4871 assert(OffsetImmOp.
isImm() &&
"expected immediate operand kind");
4873 MipsTargetStreamer &TOut = getTargetStreamer();
4874 MCRegister DstReg = DstRegOp.
getReg();
4875 MCRegister SrcReg = SrcRegOp.
getReg();
4876 int64_t OffsetValue = OffsetImmOp.
getImm();
4880 warnIfNoMacro(IDLoc);
4881 MCRegister ATReg = getATReg(IDLoc);
4886 if (IsLargeOffset) {
4887 if (loadImmediate(OffsetValue, ATReg, SrcReg, !
ABI.ArePtrs64bit(),
true,
4892 int64_t FirstOffset = IsLargeOffset ? 0 : OffsetValue;
4893 int64_t SecondOffset = IsLargeOffset ? 1 : (OffsetValue + 1);
4897 MCRegister FirstLbuDstReg = IsLargeOffset ? DstReg : ATReg;
4898 MCRegister SecondLbuDstReg = IsLargeOffset ? ATReg : DstReg;
4900 MCRegister LbuSrcReg = IsLargeOffset ? ATReg : SrcReg;
4901 MCRegister SllReg = IsLargeOffset ? DstReg : ATReg;
4903 TOut.
emitRRI(
Signed ? Mips::LB : Mips::LBu, FirstLbuDstReg, LbuSrcReg,
4904 FirstOffset, IDLoc, STI);
4905 TOut.
emitRRI(Mips::LBu, SecondLbuDstReg, LbuSrcReg, SecondOffset, IDLoc, STI);
4906 TOut.
emitRRI(Mips::SLL, SllReg, SllReg, 8, IDLoc, STI);
4907 TOut.
emitRRR(Mips::OR, DstReg, DstReg, ATReg, IDLoc, STI);
4912bool MipsAsmParser::expandUsh(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
4913 const MCSubtargetInfo *STI) {
4914 if (hasMips32r6() || hasMips64r6()) {
4915 return Error(IDLoc,
"instruction not supported on mips32r6 or mips64r6");
4918 const MCOperand &DstRegOp = Inst.
getOperand(0);
4919 assert(DstRegOp.
isReg() &&
"expected register operand kind");
4920 const MCOperand &SrcRegOp = Inst.
getOperand(1);
4921 assert(SrcRegOp.
isReg() &&
"expected register operand kind");
4922 const MCOperand &OffsetImmOp = Inst.
getOperand(2);
4923 assert(OffsetImmOp.
isImm() &&
"expected immediate operand kind");
4925 MipsTargetStreamer &TOut = getTargetStreamer();
4926 MCRegister DstReg = DstRegOp.
getReg();
4927 MCRegister SrcReg = SrcRegOp.
getReg();
4928 int64_t OffsetValue = OffsetImmOp.
getImm();
4930 warnIfNoMacro(IDLoc);
4931 MCRegister ATReg = getATReg(IDLoc);
4936 if (IsLargeOffset) {
4937 if (loadImmediate(OffsetValue, ATReg, SrcReg, !
ABI.ArePtrs64bit(),
true,
4942 int64_t FirstOffset = IsLargeOffset ? 1 : (OffsetValue + 1);
4943 int64_t SecondOffset = IsLargeOffset ? 0 : OffsetValue;
4947 if (IsLargeOffset) {
4948 TOut.
emitRRI(Mips::SB, DstReg, ATReg, FirstOffset, IDLoc, STI);
4949 TOut.
emitRRI(Mips::SRL, DstReg, DstReg, 8, IDLoc, STI);
4950 TOut.
emitRRI(Mips::SB, DstReg, ATReg, SecondOffset, IDLoc, STI);
4951 TOut.
emitRRI(Mips::LBu, ATReg, ATReg, 0, IDLoc, STI);
4952 TOut.
emitRRI(Mips::SLL, DstReg, DstReg, 8, IDLoc, STI);
4953 TOut.
emitRRR(Mips::OR, DstReg, DstReg, ATReg, IDLoc, STI);
4955 TOut.
emitRRI(Mips::SB, DstReg, SrcReg, FirstOffset, IDLoc, STI);
4956 TOut.
emitRRI(Mips::SRL, ATReg, DstReg, 8, IDLoc, STI);
4957 TOut.
emitRRI(Mips::SB, ATReg, SrcReg, SecondOffset, IDLoc, STI);
4963bool MipsAsmParser::expandUxw(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
4964 const MCSubtargetInfo *STI) {
4965 if (hasMips32r6() || hasMips64r6()) {
4966 return Error(IDLoc,
"instruction not supported on mips32r6 or mips64r6");
4969 const MCOperand &DstRegOp = Inst.
getOperand(0);
4970 assert(DstRegOp.
isReg() &&
"expected register operand kind");
4971 const MCOperand &SrcRegOp = Inst.
getOperand(1);
4972 assert(SrcRegOp.
isReg() &&
"expected register operand kind");
4973 const MCOperand &OffsetImmOp = Inst.
getOperand(2);
4974 assert(OffsetImmOp.
isImm() &&
"expected immediate operand kind");
4976 MipsTargetStreamer &TOut = getTargetStreamer();
4977 MCRegister DstReg = DstRegOp.
getReg();
4978 MCRegister SrcReg = SrcRegOp.
getReg();
4979 int64_t OffsetValue = OffsetImmOp.
getImm();
4983 int64_t LxlOffset = IsLargeOffset ? 0 : OffsetValue;
4984 int64_t LxrOffset = IsLargeOffset ? 3 : (OffsetValue + 3);
4988 bool IsLoadInst = (Inst.
getOpcode() == Mips::Ulw);
4989 bool DoMove = IsLoadInst && (SrcReg == DstReg) && !IsLargeOffset;
4990 MCRegister TmpReg = SrcReg;
4991 if (IsLargeOffset || DoMove) {
4992 warnIfNoMacro(IDLoc);
4993 TmpReg = getATReg(IDLoc);
4998 if (IsLargeOffset) {
4999 if (loadImmediate(OffsetValue, TmpReg, SrcReg, !
ABI.ArePtrs64bit(),
true,
5007 unsigned XWL = IsLoadInst ? Mips::LWL : Mips::SWL;
5008 unsigned XWR = IsLoadInst ? Mips::LWR : Mips::SWR;
5009 TOut.
emitRRI(XWL, DstReg, TmpReg, LxlOffset, IDLoc, STI);
5010 TOut.
emitRRI(XWR, DstReg, TmpReg, LxrOffset, IDLoc, STI);
5013 TOut.
emitRRR(Mips::OR, TmpReg, DstReg, Mips::R0, IDLoc, STI);
5018bool MipsAsmParser::expandSge(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5019 const MCSubtargetInfo *STI) {
5020 MipsTargetStreamer &TOut = getTargetStreamer();
5032 warnIfNoMacro(IDLoc);
5046 TOut.
emitRRR(OpCode, DstReg, SrcReg, OpReg, IDLoc, STI);
5047 TOut.
emitRRI(Mips::XORi, DstReg, DstReg, 1, IDLoc, STI);
5052bool MipsAsmParser::expandSgeImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5053 const MCSubtargetInfo *STI) {
5054 MipsTargetStreamer &TOut = getTargetStreamer();
5064 unsigned OpRegCode, OpImmCode;
5066 warnIfNoMacro(IDLoc);
5070 case Mips::SGEImm64:
5071 OpRegCode = Mips::SLT;
5072 OpImmCode = Mips::SLTi;
5075 case Mips::SGEUImm64:
5076 OpRegCode = Mips::SLTu;
5077 OpImmCode = Mips::SLTiu;
5086 TOut.
emitRRI(OpImmCode, DstReg, SrcReg, ImmValue, IDLoc, STI);
5087 TOut.
emitRRI(Mips::XORi, DstReg, DstReg, 1, IDLoc, STI);
5089 MCRegister ImmReg = DstReg;
5090 if (DstReg == SrcReg) {
5091 MCRegister ATReg = getATReg(Inst.
getLoc());
5097 if (loadImmediate(ImmValue, ImmReg, MCRegister(),
isInt<32>(ImmValue),
5098 false, IDLoc, Out, STI))
5101 TOut.
emitRRR(OpRegCode, DstReg, SrcReg, ImmReg, IDLoc, STI);
5102 TOut.
emitRRI(Mips::XORi, DstReg, DstReg, 1, IDLoc, STI);
5108bool MipsAsmParser::expandSgtImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5109 const MCSubtargetInfo *STI) {
5110 MipsTargetStreamer &TOut = getTargetStreamer();
5119 MCRegister ImmReg = DstReg;
5123 warnIfNoMacro(IDLoc);
5127 case Mips::SGTImm64:
5131 case Mips::SGTUImm64:
5138 if (DstReg == SrcReg) {
5139 MCRegister ATReg = getATReg(Inst.
getLoc());
5145 if (loadImmediate(ImmValue, ImmReg, MCRegister(),
isInt<32>(ImmValue),
false,
5150 TOut.
emitRRR(OpCode, DstReg, ImmReg, SrcReg, IDLoc, STI);
5155bool MipsAsmParser::expandSle(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5156 const MCSubtargetInfo *STI) {
5157 MipsTargetStreamer &TOut = getTargetStreamer();
5169 warnIfNoMacro(IDLoc);
5183 TOut.
emitRRR(OpCode, DstReg, OpReg, SrcReg, IDLoc, STI);
5184 TOut.
emitRRI(Mips::XORi, DstReg, DstReg, 1, IDLoc, STI);
5189bool MipsAsmParser::expandSleImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5190 const MCSubtargetInfo *STI) {
5191 MipsTargetStreamer &TOut = getTargetStreamer();
5203 warnIfNoMacro(IDLoc);
5207 case Mips::SLEImm64:
5208 OpRegCode = Mips::SLT;
5211 case Mips::SLEUImm64:
5212 OpRegCode = Mips::SLTu;
5219 MCRegister ImmReg = DstReg;
5220 if (DstReg == SrcReg) {
5221 MCRegister ATReg = getATReg(Inst.
getLoc());
5227 if (loadImmediate(ImmValue, ImmReg, MCRegister(),
isInt<32>(ImmValue),
false,
5231 TOut.
emitRRR(OpRegCode, DstReg, ImmReg, SrcReg, IDLoc, STI);
5232 TOut.
emitRRI(Mips::XORi, DstReg, DstReg, 1, IDLoc, STI);
5237bool MipsAsmParser::expandAliasImmediate(MCInst &Inst, SMLoc IDLoc,
5239 const MCSubtargetInfo *STI) {
5240 MipsTargetStreamer &TOut = getTargetStreamer();
5248 MCRegister FinalDstReg;
5255 unsigned FinalOpcode = Inst.
getOpcode();
5257 if (DstReg == SrcReg) {
5258 ATReg = getATReg(Inst.
getLoc());
5261 FinalDstReg = DstReg;
5265 if (!loadImmediate(ImmValue, DstReg, MCRegister(), Is32Bit,
false,
5266 Inst.
getLoc(), Out, STI)) {
5267 switch (FinalOpcode) {
5271 FinalOpcode = Mips::ADD;
5274 FinalOpcode = Mips::ADDu;
5277 FinalOpcode = Mips::AND;
5280 FinalOpcode = Mips::NOR;
5283 FinalOpcode = Mips::OR;
5286 FinalOpcode = Mips::SLT;
5289 FinalOpcode = Mips::SLTu;
5292 FinalOpcode = Mips::XOR;
5295 FinalOpcode = Mips::ADD_MM;
5297 case Mips::ADDiu_MM:
5298 FinalOpcode = Mips::ADDu_MM;
5301 FinalOpcode = Mips::AND_MM;
5304 FinalOpcode = Mips::OR_MM;
5307 FinalOpcode = Mips::SLT_MM;
5309 case Mips::SLTiu_MM:
5310 FinalOpcode = Mips::SLTu_MM;
5313 FinalOpcode = Mips::XOR_MM;
5316 FinalOpcode = Mips::AND64;
5318 case Mips::NORImm64:
5319 FinalOpcode = Mips::NOR64;
5322 FinalOpcode = Mips::OR64;
5324 case Mips::SLTImm64:
5325 FinalOpcode = Mips::SLT64;
5327 case Mips::SLTUImm64:
5328 FinalOpcode = Mips::SLTu64;
5331 FinalOpcode = Mips::XOR64;
5336 TOut.
emitRRR(FinalOpcode, DstReg, DstReg, SrcReg, IDLoc, STI);
5338 TOut.
emitRRR(FinalOpcode, FinalDstReg, FinalDstReg, DstReg, IDLoc, STI);
5344bool MipsAsmParser::expandRotation(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5345 const MCSubtargetInfo *STI) {
5346 MipsTargetStreamer &TOut = getTargetStreamer();
5351 MCRegister TmpReg =
DReg;
5353 unsigned FirstShift = Mips::NOP;
5354 unsigned SecondShift = Mips::NOP;
5356 if (hasMips32r2()) {
5358 TmpReg = getATReg(Inst.
getLoc());
5364 TOut.
emitRRR(Mips::SUBu, TmpReg, Mips::R0, TReg, Inst.
getLoc(), STI);
5365 TOut.
emitRRR(Mips::ROTRV, DReg, SReg, TmpReg, Inst.
getLoc(), STI);
5370 TOut.
emitRRR(Mips::ROTRV, DReg, SReg, TReg, Inst.
getLoc(), STI);
5382 FirstShift = Mips::SRLV;
5383 SecondShift = Mips::SLLV;
5386 FirstShift = Mips::SLLV;
5387 SecondShift = Mips::SRLV;
5391 ATReg = getATReg(Inst.
getLoc());
5395 TOut.
emitRRR(Mips::SUBu, ATReg, Mips::R0, TReg, Inst.
getLoc(), STI);
5396 TOut.
emitRRR(FirstShift, ATReg, SReg, ATReg, Inst.
getLoc(), STI);
5397 TOut.
emitRRR(SecondShift, DReg, SReg, TReg, Inst.
getLoc(), STI);
5398 TOut.
emitRRR(Mips::OR, DReg, DReg, ATReg, Inst.
getLoc(), STI);
5406bool MipsAsmParser::expandRotationImm(MCInst &Inst, SMLoc IDLoc,
5408 const MCSubtargetInfo *STI) {
5409 MipsTargetStreamer &TOut = getTargetStreamer();
5415 unsigned FirstShift = Mips::NOP;
5416 unsigned SecondShift = Mips::NOP;
5418 if (hasMips32r2()) {
5423 ShiftValue = MaxShift - ImmValue;
5424 TOut.
emitRRI(Mips::ROTR, DReg, SReg, ShiftValue, Inst.
getLoc(), STI);
5429 TOut.
emitRRI(Mips::ROTR, DReg, SReg, ImmValue, Inst.
getLoc(), STI);
5437 if (ImmValue == 0) {
5446 FirstShift = Mips::SLL;
5447 SecondShift = Mips::SRL;
5450 FirstShift = Mips::SRL;
5451 SecondShift = Mips::SLL;
5455 ATReg = getATReg(Inst.
getLoc());
5459 TOut.
emitRRI(FirstShift, ATReg, SReg, ImmValue, Inst.
getLoc(), STI);
5460 TOut.
emitRRI(SecondShift, DReg, SReg, 32 - ImmValue, Inst.
getLoc(), STI);
5461 TOut.
emitRRR(Mips::OR, DReg, DReg, ATReg, Inst.
getLoc(), STI);
5469bool MipsAsmParser::expandDRotation(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5470 const MCSubtargetInfo *STI) {
5471 MipsTargetStreamer &TOut = getTargetStreamer();
5476 MCRegister TmpReg =
DReg;
5478 unsigned FirstShift = Mips::NOP;
5479 unsigned SecondShift = Mips::NOP;
5481 if (hasMips64r2()) {
5482 if (TmpReg == SReg) {
5483 TmpReg = getATReg(Inst.
getLoc());
5489 TOut.
emitRRR(Mips::DSUBu, TmpReg, Mips::R0, TReg, Inst.
getLoc(), STI);
5490 TOut.
emitRRR(Mips::DROTRV, DReg, SReg, TmpReg, Inst.
getLoc(), STI);
5495 TOut.
emitRRR(Mips::DROTRV, DReg, SReg, TReg, Inst.
getLoc(), STI);
5507 FirstShift = Mips::DSRLV;
5508 SecondShift = Mips::DSLLV;
5511 FirstShift = Mips::DSLLV;
5512 SecondShift = Mips::DSRLV;
5516 ATReg = getATReg(Inst.
getLoc());
5520 TOut.
emitRRR(Mips::DSUBu, ATReg, Mips::R0, TReg, Inst.
getLoc(), STI);
5521 TOut.
emitRRR(FirstShift, ATReg, SReg, ATReg, Inst.
getLoc(), STI);
5522 TOut.
emitRRR(SecondShift, DReg, SReg, TReg, Inst.
getLoc(), STI);
5523 TOut.
emitRRR(Mips::OR, DReg, DReg, ATReg, Inst.
getLoc(), STI);
5531bool MipsAsmParser::expandDRotationImm(MCInst &Inst, SMLoc IDLoc,
5533 const MCSubtargetInfo *STI) {
5534 MipsTargetStreamer &TOut = getTargetStreamer();
5540 unsigned FirstShift = Mips::NOP;
5541 unsigned SecondShift = Mips::NOP;
5543 if (hasMips64r2()) {
5544 unsigned FinalOpcode = Mips::NOP;
5546 FinalOpcode = Mips::DROTR;
5547 else if (ImmValue % 32 == 0)
5548 FinalOpcode = Mips::DROTR32;
5549 else if ((ImmValue >= 1) && (ImmValue <= 32)) {
5551 FinalOpcode = Mips::DROTR32;
5553 FinalOpcode = Mips::DROTR;
5554 }
else if (ImmValue >= 33) {
5556 FinalOpcode = Mips::DROTR;
5558 FinalOpcode = Mips::DROTR32;
5561 uint64_t ShiftValue = ImmValue % 32;
5563 ShiftValue = (32 - ImmValue % 32) % 32;
5565 TOut.
emitRRI(FinalOpcode, DReg, SReg, ShiftValue, Inst.
getLoc(), STI);
5571 if (ImmValue == 0) {
5572 TOut.
emitRRI(Mips::DSRL, DReg, SReg, 0, Inst.
getLoc(), STI);
5580 if ((ImmValue >= 1) && (ImmValue <= 31)) {
5581 FirstShift = Mips::DSLL;
5582 SecondShift = Mips::DSRL32;
5584 if (ImmValue == 32) {
5585 FirstShift = Mips::DSLL32;
5586 SecondShift = Mips::DSRL32;
5588 if ((ImmValue >= 33) && (ImmValue <= 63)) {
5589 FirstShift = Mips::DSLL32;
5590 SecondShift = Mips::DSRL;
5594 if ((ImmValue >= 1) && (ImmValue <= 31)) {
5595 FirstShift = Mips::DSRL;
5596 SecondShift = Mips::DSLL32;
5598 if (ImmValue == 32) {
5599 FirstShift = Mips::DSRL32;
5600 SecondShift = Mips::DSLL32;
5602 if ((ImmValue >= 33) && (ImmValue <= 63)) {
5603 FirstShift = Mips::DSRL32;
5604 SecondShift = Mips::DSLL;
5609 ATReg = getATReg(Inst.
getLoc());
5613 TOut.
emitRRI(FirstShift, ATReg, SReg, ImmValue % 32, Inst.
getLoc(), STI);
5614 TOut.
emitRRI(SecondShift, DReg, SReg, (32 - ImmValue % 32) % 32,
5616 TOut.
emitRRR(Mips::OR, DReg, DReg, ATReg, Inst.
getLoc(), STI);
5624bool MipsAsmParser::expandAbs(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5625 const MCSubtargetInfo *STI) {
5626 MipsTargetStreamer &TOut = getTargetStreamer();
5630 TOut.
emitRI(Mips::BGEZ, SecondRegOp, 8, IDLoc, STI);
5631 if (FirstRegOp != SecondRegOp)
5632 TOut.
emitRRR(Mips::ADDu, FirstRegOp, SecondRegOp, Mips::R0, IDLoc, STI);
5635 TOut.
emitRRR(Mips::SUB, FirstRegOp, Mips::R0, SecondRegOp, IDLoc, STI);
5640bool MipsAsmParser::expandMulImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5641 const MCSubtargetInfo *STI) {
5642 MipsTargetStreamer &TOut = getTargetStreamer();
5648 ATReg = getATReg(IDLoc);
5652 loadImmediate(ImmValue, ATReg, MCRegister(),
true,
false, IDLoc, Out, STI);
5654 TOut.
emitRR(Inst.
getOpcode() == Mips::MULImmMacro ? Mips::MULT : Mips::DMULT,
5655 SrcReg, ATReg, IDLoc, STI);
5657 TOut.
emitR(Mips::MFLO, DstReg, IDLoc, STI);
5662bool MipsAsmParser::expandMulO(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5663 const MCSubtargetInfo *STI) {
5664 MipsTargetStreamer &TOut = getTargetStreamer();
5670 ATReg = getATReg(Inst.
getLoc());
5674 TOut.
emitRR(Inst.
getOpcode() == Mips::MULOMacro ? Mips::MULT : Mips::DMULT,
5675 SrcReg, TmpReg, IDLoc, STI);
5677 TOut.
emitR(Mips::MFLO, DstReg, IDLoc, STI);
5679 TOut.
emitRRI(Inst.
getOpcode() == Mips::MULOMacro ? Mips::SRA : Mips::DSRA32,
5680 DstReg, DstReg, 0x1F, IDLoc, STI);
5682 TOut.
emitR(Mips::MFHI, ATReg, IDLoc, STI);
5685 TOut.
emitRRI(Mips::TNE, DstReg, ATReg, 6, IDLoc, STI);
5692 TOut.
emitRRX(Mips::BEQ, DstReg, ATReg, LabelOp, IDLoc, STI);
5693 if (AssemblerOptions.
back()->isReorder())
5695 TOut.
emitII(Mips::BREAK, 6, 0, IDLoc, STI);
5699 TOut.
emitR(Mips::MFLO, DstReg, IDLoc, STI);
5704bool MipsAsmParser::expandMulOU(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5705 const MCSubtargetInfo *STI) {
5706 MipsTargetStreamer &TOut = getTargetStreamer();
5712 ATReg = getATReg(IDLoc);
5716 TOut.
emitRR(Inst.
getOpcode() == Mips::MULOUMacro ? Mips::MULTu : Mips::DMULTu,
5717 SrcReg, TmpReg, IDLoc, STI);
5719 TOut.
emitR(Mips::MFHI, ATReg, IDLoc, STI);
5720 TOut.
emitR(Mips::MFLO, DstReg, IDLoc, STI);
5722 TOut.
emitRRI(Mips::TNE, ATReg, Mips::R0, 6, IDLoc, STI);
5729 TOut.
emitRRX(Mips::BEQ, ATReg, Mips::R0, LabelOp, IDLoc, STI);
5730 if (AssemblerOptions.
back()->isReorder())
5732 TOut.
emitII(Mips::BREAK, 6, 0, IDLoc, STI);
5740bool MipsAsmParser::expandMULMacro(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5741 const MCSubtargetInfo *STI) {
5742 MipsTargetStreamer &TOut = getTargetStreamer();
5747 TOut.
emitRR(Inst.
getOpcode() == Mips::MULMacro ? Mips::MULTu : Mips::DMULTu,
5748 SrcReg, TmpReg, IDLoc, STI);
5749 TOut.
emitR(Mips::MFLO, DstReg, IDLoc, STI);
5759bool MipsAsmParser::expandLoadStoreDMacro(MCInst &Inst, SMLoc IDLoc,
5761 const MCSubtargetInfo *STI,
5766 warnIfNoMacro(IDLoc);
5768 MipsTargetStreamer &TOut = getTargetStreamer();
5769 unsigned Opcode = IsLoad ? Mips::LW : Mips::SW;
5771 MCRegister SecondReg =
nextReg(FirstReg);
5776 warnIfRegIndexIsAT(FirstReg, IDLoc);
5779 "Offset for load macro is not immediate!");
5782 signed NextOffset = FirstOffset.
getImm() + 4;
5790 if (FirstReg != BaseReg || !IsLoad) {
5791 TOut.
emitRRX(Opcode, FirstReg, BaseReg, FirstOffset, IDLoc, STI);
5792 TOut.
emitRRX(Opcode, SecondReg, BaseReg, SecondOffset, IDLoc, STI);
5794 TOut.
emitRRX(Opcode, SecondReg, BaseReg, SecondOffset, IDLoc, STI);
5795 TOut.
emitRRX(Opcode, FirstReg, BaseReg, FirstOffset, IDLoc, STI);
5807bool MipsAsmParser::expandLoadStoreDM1Macro(MCInst &Inst, SMLoc IDLoc,
5809 const MCSubtargetInfo *STI,
5814 warnIfNoMacro(IDLoc);
5816 MipsTargetStreamer &TOut = getTargetStreamer();
5817 unsigned Opcode = IsLoad ? Mips::LWC1 : Mips::SWC1;
5819 MCRegister SecondReg =
nextReg(FirstReg);
5824 warnIfRegIndexIsAT(FirstReg, IDLoc);
5827 "Offset for macro is not immediate!");
5830 signed NextOffset = FirstOffset.
getImm() + 4;
5836 if (!IsLittleEndian)
5839 TOut.
emitRRX(Opcode, FirstReg, BaseReg, FirstOffset, IDLoc, STI);
5840 TOut.
emitRRX(Opcode, SecondReg, BaseReg, SecondOffset, IDLoc, STI);
5845bool MipsAsmParser::expandSeq(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5846 const MCSubtargetInfo *STI) {
5847 MipsTargetStreamer &TOut = getTargetStreamer();
5858 warnIfNoMacro(IDLoc);
5860 if (SrcReg != Mips::R0 && OpReg != Mips::R0) {
5861 TOut.
emitRRR(Mips::XOR, DstReg, SrcReg, OpReg, IDLoc, STI);
5862 TOut.
emitRRI(Mips::SLTiu, DstReg, DstReg, 1, IDLoc, STI);
5866 MCRegister
Reg = SrcReg == Mips::R0 ? OpReg : SrcReg;
5867 TOut.
emitRRI(Mips::SLTiu, DstReg,
Reg, 1, IDLoc, STI);
5871bool MipsAsmParser::expandSeqI(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5872 const MCSubtargetInfo *STI) {
5873 MipsTargetStreamer &TOut = getTargetStreamer();
5884 warnIfNoMacro(IDLoc);
5887 TOut.
emitRRI(Mips::SLTiu, DstReg, SrcReg, 1, IDLoc, STI);
5891 if (SrcReg == Mips::R0) {
5892 Warning(IDLoc,
"comparison is always false");
5893 TOut.
emitRRR(isGP64bit() ? Mips::DADDu : Mips::ADDu,
5894 DstReg, SrcReg, SrcReg, IDLoc, STI);
5899 if (
Imm > -0x8000 &&
Imm < 0) {
5901 Opc = isGP64bit() ? Mips::DADDiu : Mips::ADDiu;
5907 MCRegister ATReg = getATReg(IDLoc);
5911 if (loadImmediate(
Imm, ATReg, MCRegister(),
true, isGP64bit(), IDLoc, Out,
5915 TOut.
emitRRR(Mips::XOR, DstReg, SrcReg, ATReg, IDLoc, STI);
5916 TOut.
emitRRI(Mips::SLTiu, DstReg, DstReg, 1, IDLoc, STI);
5921 TOut.
emitRRI(Mips::SLTiu, DstReg, DstReg, 1, IDLoc, STI);
5925bool MipsAsmParser::expandSne(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5926 const MCSubtargetInfo *STI) {
5928 MipsTargetStreamer &TOut = getTargetStreamer();
5939 warnIfNoMacro(IDLoc);
5941 if (SrcReg != Mips::R0 && OpReg != Mips::R0) {
5942 TOut.
emitRRR(Mips::XOR, DstReg, SrcReg, OpReg, IDLoc, STI);
5943 TOut.
emitRRR(Mips::SLTu, DstReg, Mips::R0, DstReg, IDLoc, STI);
5947 MCRegister
Reg = SrcReg == Mips::R0 ? OpReg : SrcReg;
5948 TOut.
emitRRR(Mips::SLTu, DstReg, Mips::R0,
Reg, IDLoc, STI);
5952bool MipsAsmParser::expandSneI(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
5953 const MCSubtargetInfo *STI) {
5954 MipsTargetStreamer &TOut = getTargetStreamer();
5965 warnIfNoMacro(IDLoc);
5967 if (ImmValue == 0) {
5968 TOut.
emitRRR(Mips::SLTu, DstReg, Mips::R0, SrcReg, IDLoc, STI);
5972 if (SrcReg == Mips::R0) {
5973 Warning(IDLoc,
"comparison is always true");
5974 if (loadImmediate(1, DstReg, MCRegister(),
true,
false, IDLoc, Out, STI))
5980 if (ImmValue > -0x8000 && ImmValue < 0) {
5981 ImmValue = -ImmValue;
5982 Opc = isGP64bit() ? Mips::DADDiu : Mips::ADDiu;
5988 TOut.
emitRRI(
Opc, DstReg, SrcReg, ImmValue, IDLoc, STI);
5989 TOut.
emitRRR(Mips::SLTu, DstReg, Mips::R0, DstReg, IDLoc, STI);
5993 MCRegister ATReg = getATReg(IDLoc);
5997 if (loadImmediate(ImmValue, ATReg, MCRegister(),
isInt<32>(ImmValue),
false,
6001 TOut.
emitRRR(Mips::XOR, DstReg, SrcReg, ATReg, IDLoc, STI);
6002 TOut.
emitRRR(Mips::SLTu, DstReg, Mips::R0, DstReg, IDLoc, STI);
6136bool MipsAsmParser::expandMXTRAlias(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
6137 const MCSubtargetInfo *STI) {
6138 MipsTargetStreamer &TOut = getTargetStreamer();
6142 bool IsMFTR =
false;
6188 IsMFTR ? MCRegister(rd)
6190 : Inst.getOperand(0).
getReg());
6192 TOut.
emitRRIII(IsMFTR ? Mips::MFTR : Mips::MTTR, Op0, Op1, 1, sel, h, IDLoc,
6197bool MipsAsmParser::expandSaaAddr(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
6198 const MCSubtargetInfo *STI) {
6203 warnIfNoMacro(IDLoc);
6205 MipsTargetStreamer &TOut = getTargetStreamer();
6206 unsigned Opcode = Inst.
getOpcode() == Mips::SaaAddr ? Mips::SAA : Mips::SAAD;
6209 const MCOperand &BaseOp = Inst.
getOperand(2);
6211 if (BaseOp.
isImm()) {
6212 int64_t ImmValue = BaseOp.
getImm();
6213 if (ImmValue == 0) {
6214 TOut.
emitRR(Opcode, RtReg, BaseReg, IDLoc, STI);
6219 MCRegister ATReg = getATReg(IDLoc);
6223 if (expandLoadAddress(ATReg, BaseReg, BaseOp, !isGP64bit(), IDLoc, Out, STI))
6226 TOut.
emitRR(Opcode, RtReg, ATReg, IDLoc, STI);
6231MipsAsmParser::checkEarlyTargetMatchPredicate(MCInst &Inst,
6235 return Match_Success;
6238 if (
static_cast<MipsOperand &
>(*
Operands[1])
6239 .isValidForTie(
static_cast<MipsOperand &
>(*
Operands[2])))
6240 return Match_Success;
6241 return Match_RequiresSameSrcAndDst;
6245unsigned MipsAsmParser::checkTargetMatchPredicate(MCInst &Inst) {
6252 return Match_RequiresNoZeroRegister;
6253 return Match_Success;
6259 case Mips::JALR_HB64:
6260 case Mips::JALRC_HB_MMR6:
6261 case Mips::JALRC_MMR6:
6263 return Match_RequiresDifferentSrcAndDst;
6264 return Match_Success;
6267 return Match_RequiresDifferentSrcAndDst;
6268 return Match_Success;
6271 return Match_NonZeroOperandForSync;
6272 return Match_Success;
6276 return Match_NonZeroOperandForMTCX;
6277 return Match_Success;
6290 case Mips::BLEZC:
case Mips::BLEZC_MMR6:
6291 case Mips::BGEZC:
case Mips::BGEZC_MMR6:
6292 case Mips::BGTZC:
case Mips::BGTZC_MMR6:
6293 case Mips::BLTZC:
case Mips::BLTZC_MMR6:
6294 case Mips::BEQZC:
case Mips::BEQZC_MMR6:
6295 case Mips::BNEZC:
case Mips::BNEZC_MMR6:
6304 return Match_RequiresNoZeroRegister;
6305 return Match_Success;
6306 case Mips::BGEC:
case Mips::BGEC_MMR6:
6307 case Mips::BLTC:
case Mips::BLTC_MMR6:
6308 case Mips::BGEUC:
case Mips::BGEUC_MMR6:
6309 case Mips::BLTUC:
case Mips::BLTUC_MMR6:
6310 case Mips::BEQC:
case Mips::BEQC_MMR6:
6311 case Mips::BNEC:
case Mips::BNEC_MMR6:
6320 return Match_RequiresNoZeroRegister;
6323 return Match_RequiresNoZeroRegister;
6325 return Match_RequiresDifferentOperands;
6326 return Match_Success;
6329 "Operands must be immediates for dins!");
6332 if ((0 > (Pos +
Size)) || ((Pos +
Size) > 32))
6333 return Match_RequiresPosSizeRange0_32;
6334 return Match_Success;
6339 "Operands must be immediates for dinsm/dinsu!");
6342 if ((32 >= (Pos +
Size)) || ((Pos +
Size) > 64))
6343 return Match_RequiresPosSizeRange33_64;
6344 return Match_Success;
6348 "Operands must be immediates for DEXTM!");
6351 if ((1 > (Pos +
Size)) || ((Pos +
Size) > 63))
6352 return Match_RequiresPosSizeUImm6;
6353 return Match_Success;
6358 "Operands must be immediates for dextm/dextu!");
6361 if ((32 > (Pos +
Size)) || ((Pos +
Size) > 64))
6362 return Match_RequiresPosSizeRange33_64;
6363 return Match_Success;
6365 case Mips::CRC32B:
case Mips::CRC32CB:
6366 case Mips::CRC32H:
case Mips::CRC32CH:
6367 case Mips::CRC32W:
case Mips::CRC32CW:
6368 case Mips::CRC32D:
case Mips::CRC32CD:
6370 return Match_RequiresSameSrcAndDst;
6371 return Match_Success;
6377 return Match_NoFCCRegisterForCurrentISA;
6379 return Match_Success;
6387 if (ErrorLoc ==
SMLoc())
6394bool MipsAsmParser::matchAndEmitInstruction(SMLoc IDLoc,
unsigned &Opcode,
6398 bool MatchingInlineAsm) {
6400 unsigned MatchResult =
6401 MatchInstructionImpl(
Operands, Inst, ErrorInfo, MatchingInlineAsm);
6403 switch (MatchResult) {
6405 if (processInstruction(Inst, IDLoc, Out, STI))
6408 case Match_MissingFeature:
6409 Error(IDLoc,
"instruction requires a CPU feature not currently enabled");
6411 case Match_InvalidTiedOperand:
6412 Error(IDLoc,
"operand must match destination register");
6414 case Match_InvalidOperand: {
6415 SMLoc ErrorLoc = IDLoc;
6416 if (ErrorInfo != ~0ULL) {
6418 return Error(IDLoc,
"too few operands for instruction");
6420 ErrorLoc =
Operands[ErrorInfo]->getStartLoc();
6422 ErrorLoc =
static_cast<MipsOperand &
>(*
Operands[ErrorInfo])
6425 if (ErrorLoc == SMLoc())
6429 return Error(ErrorLoc,
"invalid operand for instruction");
6431 case Match_NonZeroOperandForSync:
6433 "s-type must be zero or unspecified for pre-MIPS32 ISAs");
6434 case Match_NonZeroOperandForMTCX:
6435 return Error(IDLoc,
"selector must be zero for pre-MIPS32 ISAs");
6436 case Match_MnemonicFail:
6437 return Error(IDLoc,
"invalid instruction");
6438 case Match_RequiresDifferentSrcAndDst:
6439 return Error(IDLoc,
"source and destination must be different");
6440 case Match_RequiresDifferentOperands:
6441 return Error(IDLoc,
"registers must be different");
6442 case Match_RequiresNoZeroRegister:
6443 return Error(IDLoc,
"invalid operand ($zero) for instruction");
6444 case Match_RequiresSameSrcAndDst:
6445 return Error(IDLoc,
"source and destination must match");
6446 case Match_NoFCCRegisterForCurrentISA:
6448 "non-zero fcc register doesn't exist in current ISA level");
6453 "expected 1-bit unsigned immediate");
6456 "expected 2-bit unsigned immediate");
6459 "expected immediate in range 1 .. 4");
6462 "expected 3-bit unsigned immediate");
6465 "expected 4-bit unsigned immediate");
6468 "expected 4-bit signed immediate");
6471 "expected 5-bit unsigned immediate");
6474 "expected 5-bit signed immediate");
6477 "expected immediate in range 1 .. 32");
6478 case Match_UImm5_32:
6480 "expected immediate in range 32 .. 63");
6481 case Match_UImm5_33:
6483 "expected immediate in range 33 .. 64");
6484 case Match_UImm5_0_Report_UImm6:
6488 "expected 6-bit unsigned immediate");
6489 case Match_ConstantMemOffset:
6491 !
static_cast<MipsOperand &
>(*
Operands[ErrorInfo]).isConstantImm())
6493 "expected immediate operand kind");
6495 "immediate operand value out of range");
6496 case Match_UImm5_Lsl2:
6498 "expected both 7-bit unsigned immediate and multiple of 4");
6499 case Match_UImmRange2_64:
6501 "expected immediate in range 2 .. 64");
6504 "expected 6-bit unsigned immediate");
6505 case Match_UImm6_Lsl2:
6507 "expected both 8-bit unsigned immediate and multiple of 4");
6510 "expected 6-bit signed immediate");
6513 "expected 7-bit unsigned immediate");
6514 case Match_UImm7_N1:
6516 "expected immediate in range -1 .. 126");
6517 case Match_SImm7_Lsl2:
6519 "expected both 9-bit signed immediate and multiple of 4");
6522 "expected 8-bit unsigned immediate");
6523 case Match_UImm10_0:
6525 "expected 10-bit unsigned immediate");
6526 case Match_SImm10_0:
6528 "expected 10-bit signed immediate");
6529 case Match_SImm11_0:
6531 "expected 11-bit signed immediate");
6533 case Match_UImm16_Relaxed:
6534 case Match_UImm16_AltRelaxed:
6536 "expected 16-bit unsigned immediate");
6538 case Match_SImm16_Relaxed:
6540 "expected 16-bit signed immediate");
6541 case Match_SImm18_Lsl3:
6543 "expected both 18-bit signed immediate and multiple of 8");
6544 case Match_SImm19_Lsl2:
6546 "expected both 19-bit signed immediate and multiple of 4");
6547 case Match_UImm20_0:
6549 "expected 20-bit unsigned immediate");
6550 case Match_UImm26_0:
6552 "expected 26-bit unsigned immediate");
6554 case Match_SImm32_Relaxed:
6556 "expected 32-bit signed immediate");
6557 case Match_UImm32_Coerced:
6559 "expected 32-bit immediate");
6560 case Match_MemSImm9:
6562 "expected memory with 9-bit signed offset");
6563 case Match_MemSImm10:
6565 "expected memory with 10-bit signed offset");
6566 case Match_MemSImm10Lsl1:
6568 "expected memory with 11-bit signed offset and multiple of 2");
6569 case Match_MemSImm10Lsl2:
6571 "expected memory with 12-bit signed offset and multiple of 4");
6572 case Match_MemSImm10Lsl3:
6574 "expected memory with 13-bit signed offset and multiple of 8");
6575 case Match_MemSImm11:
6577 "expected memory with 11-bit signed offset");
6578 case Match_MemSImm12:
6580 "expected memory with 12-bit signed offset");
6581 case Match_MemSImm16:
6583 "expected memory with 16-bit signed offset");
6584 case Match_MemSImmPtr:
6586 "expected memory with 32-bit signed offset");
6587 case Match_RequiresPosSizeRange0_32: {
6588 SMLoc ErrorStart =
Operands[3]->getStartLoc();
6589 SMLoc ErrorEnd =
Operands[4]->getEndLoc();
6590 return Error(ErrorStart,
"size plus position are not in the range 0 .. 32",
6591 SMRange(ErrorStart, ErrorEnd));
6593 case Match_RequiresPosSizeUImm6: {
6594 SMLoc ErrorStart =
Operands[3]->getStartLoc();
6595 SMLoc ErrorEnd =
Operands[4]->getEndLoc();
6596 return Error(ErrorStart,
"size plus position are not in the range 1 .. 63",
6597 SMRange(ErrorStart, ErrorEnd));
6599 case Match_RequiresPosSizeRange33_64: {
6600 SMLoc ErrorStart =
Operands[3]->getStartLoc();
6601 SMLoc ErrorEnd =
Operands[4]->getEndLoc();
6602 return Error(ErrorStart,
"size plus position are not in the range 33 .. 64",
6603 SMRange(ErrorStart, ErrorEnd));
6610void MipsAsmParser::warnIfRegIndexIsAT(MCRegister RegIndex, SMLoc Loc) {
6611 if (RegIndex && AssemblerOptions.
back()->getATRegIndex() == RegIndex)
6612 Warning(Loc,
"used $at (currently $" + Twine(RegIndex.
id()) +
6613 ") without \".set noat\"");
6616void MipsAsmParser::warnIfNoMacro(SMLoc Loc) {
6617 if (!AssemblerOptions.
back()->isMacro())
6618 Warning(Loc,
"macro instruction expanded into multiple instructions");
6621void MipsAsmParser::ConvertXWPOperands(MCInst &Inst,
6625 "Unexpected instruction!");
6626 ((MipsOperand &)*
Operands[1]).addGPR32ZeroAsmRegOperands(Inst, 1);
6627 MCRegister NextReg =
nextReg(((MipsOperand &)*
Operands[1]).getGPR32Reg());
6629 static_cast<MipsOperand &
>(*
Operands[4]).addPtrRegOperands(Inst, 1);
6630 static_cast<MipsOperand &
>(*
Operands[2]).addImmOperands(Inst, 1);
6633template <
unsigned Opcode,
bool IsMFTR>
6634void MipsAsmParser::ConvertMTTransferCOP0Operands(
6636 MCRegister GPR =
static_cast<const MipsOperand &
>(*
Operands[1]).getGPR32Reg();
6638 static_cast<const MipsOperand &
>(*
Operands[2]).getCOP0Encoding();
6642 ->getRegClass(Mips::GPR32RegClassID)
6653MipsAsmParser::printWarningWithFixIt(
const Twine &
Msg,
const Twine &FixMsg,
6654 SMRange
Range,
bool ShowColors) {
6660int MipsAsmParser::matchCPURegisterName(StringRef Name) {
6661 const MCRegisterInfo &
MRI = *
getContext().getRegisterInfo();
6667 AsmToken RegTok = getLexer().peekTok();
6668 StringRef FixedName =
6670 printWarningWithFixIt(
"register names $t4-$t7 are only available in O32.",
6671 "Did you mean $" + FixedName +
"?",
6677int MipsAsmParser::matchHWRegsRegisterName(StringRef Name) {
6678 const MCRegisterInfo &
MRI = *
getContext().getRegisterInfo();
6680 Mips::RegAliasName);
6681 return Reg ?
MRI.getEncodingValue(
Reg) : -1;
6684int MipsAsmParser::matchFPURegisterName(StringRef Name) {
6685 if (Name[0] ==
'f') {
6686 StringRef NumString =
Name.substr(1);
6697int MipsAsmParser::matchFCCRegisterName(StringRef Name) {
6698 if (
Name.starts_with(
"fcc")) {
6699 StringRef NumString =
Name.substr(3);
6710int MipsAsmParser::matchACRegisterName(StringRef Name) {
6711 if (
Name.starts_with(
"ac")) {
6712 StringRef NumString =
Name.substr(2);
6723int MipsAsmParser::matchMSA128RegisterName(StringRef Name) {
6726 if (
Name.front() !=
'w' ||
Name.drop_front(1).getAsInteger(10, IntVal))
6735int MipsAsmParser::matchMSA128CtrlRegisterName(StringRef Name) {
6736 const MCRegisterInfo &
MRI = *
getContext().getRegisterInfo();
6738 Name,
MRI, Mips::MSACtrlRegClassID, Mips::RegAliasName);
6739 return Reg ?
MRI.getEncodingValue(
Reg) : -1;
6742bool MipsAsmParser::canUseATReg() {
6743 return AssemblerOptions.
back()->getATRegIndex() != 0;
6746MCRegister MipsAsmParser::getATReg(SMLoc Loc) {
6747 unsigned ATIndex = AssemblerOptions.
back()->getATRegIndex();
6749 reportParseError(Loc,
6750 "pseudo-instruction requires $at, which is not available");
6754 (isGP64bit()) ? Mips::GPR64RegClassID : Mips::GPR32RegClassID, ATIndex);
6758MCRegister MipsAsmParser::getReg(
int RC,
int RegNo) {
6759 return getContext().getRegisterInfo()->getRegClass(RC).getRegister(RegNo);
6764bool MipsAsmParser::parsePrimaryExpr(
const MCExpr *&Res, SMLoc &EndLoc) {
6766 return getParser().parsePrimaryExpr(Res, EndLoc);
6767 Res = parseRelocExpr();
6768 EndLoc = getLexer().getLoc();
6774const MCExpr *MipsAsmParser::parseRelocExpr() {
6775 auto getOp = [](StringRef
Op) {
6776 return StringSwitch<Mips::Specifier>(
Op)
6804 MCAsmParser &Parser = getParser();
6806 const MCExpr *Res =
nullptr;
6812 auto Op = getOp(Name);
6821 while (
Ops.size()) {
6830 MCAsmParser &Parser = getParser();
6840 ParseStatus Res = MatchOperandParserImpl(
Operands, Mnemonic,
true);
6851 switch (getLexer().getKind()) {
6861 if (!parseAnyRegister(
Operands).isNoMatch())
6874 Operands.push_back(MipsOperand::CreateImm(SymRef, S,
E, *
this));
6879 const MCExpr *Expr = parseRelocExpr();
6883 Operands.push_back(MipsOperand::CreateImm(Expr, S,
E, *
this));
6890bool MipsAsmParser::parseRegister(MCRegister &
Reg, SMLoc &StartLoc,
6892 return !tryParseRegister(
Reg, StartLoc, EndLoc).isSuccess();
6895ParseStatus MipsAsmParser::tryParseRegister(MCRegister &
Reg, SMLoc &StartLoc,
6898 ParseStatus Res = parseAnyRegister(
Operands);
6901 MipsOperand &Operand =
static_cast<MipsOperand &
>(*
Operands.front());
6902 StartLoc = Operand.getStartLoc();
6903 EndLoc = Operand.getEndLoc();
6909 if (Operand.isGPRAsmReg()) {
6911 Reg = isGP64bit() ? Operand.getGPR64Reg() : Operand.getGPR32Reg();
6921const MCExpr *MipsAsmParser::parseMemOffset() {
6928 if (getParser().parseExpression(
Offset))
6937 SMLoc S = getLexer().getLoc();
6938 const MCExpr *
Offset = parseMemOffset();
6942 SMLoc
E = getLexer().getLoc();
6954 Operands.push_back(MipsOperand::CreateToken(
"(",
E, *
this));
6955 Operands.push_back(MipsOperand::createGPRReg(
6957 Operands.push_back(MipsOperand::CreateToken(
")",
E, *
this));
6962 MCAsmParser &Parser = getParser();
6964 const MCExpr *
Address = parseMemOffset();
6981 std::unique_ptr<MipsOperand>
Base(
6982 static_cast<MipsOperand *
>(
Operands.back().release()));
6984 E =
Base->getEndLoc();
6986 MipsOperand::CreateMem(std::move(
Base),
Address, S,
E, *
this));
6991 MCAsmParser &Parser = getParser();
7000 const MCSymbolRefExpr *
Ref =
static_cast<const MCSymbolRefExpr *
>(Expr);
7001 StringRef DefSymbol =
Ref->getSymbol().getName();
7004 matchAnyRegisterNameWithoutDollar(
Operands, DefSymbol.
substr(1), S);
7018 if (Entry != RegisterSets.
end()) {
7020 matchAnyRegisterWithoutDollar(
Operands,
Entry->getValue(), S);
7031ParseStatus MipsAsmParser::matchAnyRegisterNameWithoutDollar(
7033 int Index = matchCPURegisterName(Identifier);
7035 Operands.push_back(MipsOperand::createGPRReg(
7036 Index, Identifier,
getContext().getRegisterInfo(), S,
7037 getLexer().getLoc(), *
this));
7041 Index = matchHWRegsRegisterName(Identifier);
7043 Operands.push_back(MipsOperand::createHWRegsReg(
7044 Index, Identifier,
getContext().getRegisterInfo(), S,
7045 getLexer().getLoc(), *
this));
7049 const MCRegisterInfo &
MRI = *
getContext().getRegisterInfo();
7051 Identifier,
MRI, Mips::COP0RegClassID, Mips::RegAliasName)) {
7052 Operands.push_back(MipsOperand::createCOP0Reg(
MRI.getEncodingValue(
Reg),
7053 Identifier, &
MRI, S,
7054 getLexer().getLoc(), *
this));
7058 Index = matchFPURegisterName(Identifier);
7060 Operands.push_back(MipsOperand::createFGRReg(
7061 Index, Identifier,
getContext().getRegisterInfo(), S,
7062 getLexer().getLoc(), *
this));
7066 Index = matchFCCRegisterName(Identifier);
7068 Operands.push_back(MipsOperand::createFCCReg(
7069 Index, Identifier,
getContext().getRegisterInfo(), S,
7070 getLexer().getLoc(), *
this));
7074 Index = matchACRegisterName(Identifier);
7076 Operands.push_back(MipsOperand::createACCReg(
7077 Index, Identifier,
getContext().getRegisterInfo(), S,
7078 getLexer().getLoc(), *
this));
7082 Index = matchMSA128RegisterName(Identifier);
7084 Operands.push_back(MipsOperand::createMSA128Reg(
7085 Index, Identifier,
getContext().getRegisterInfo(), S,
7086 getLexer().getLoc(), *
this));
7090 Index = matchMSA128CtrlRegisterName(Identifier);
7092 Operands.push_back(MipsOperand::createMSACtrlReg(
7093 Index, Identifier,
getContext().getRegisterInfo(), S,
7094 getLexer().getLoc(), *
this));
7103 const AsmToken &Token, SMLoc S) {
7107 return matchAnyRegisterNameWithoutDollar(
Operands, Identifier, S);
7112 if (RegNum < 0 || RegNum > 31) {
7116 Error(getLexer().getLoc(),
"invalid register number");
7118 Operands.push_back(MipsOperand::createNumericReg(
7131 auto Token = getLexer().peekTok(
false);
7132 return matchAnyRegisterWithoutDollar(
Operands, Token, S);
7136 SMLoc S = getLexer().getLoc();
7138 ParseStatus Res = parseAnyRegister(RegOperands);
7141 const auto &
Op =
static_cast<const MipsOperand &
>(*RegOperands.
back());
7143 if (
Op.isCOP0AsmReg()) {
7144 Encoding =
Op.getCOP0Encoding();
7146 return Error(getLexer().getLoc(),
7147 "explicit selector is not allowed for named COP0 register");
7148 }
else if (
Op.isNumericReg()) {
7152 SMLoc SelLoc = getLexer().getLoc();
7154 if (getParser().parseExpression(Expr))
7156 if (!Expr->evaluateAsAbsolute(Sel) || !
isUInt<3>(Sel))
7157 return Error(SelLoc,
"expected 3-bit unsigned immediate");
7161 return Error(S,
"invalid operand for instruction");
7164 return Error(S,
"selector must be zero for pre-MIPS32 ISAs");
7166 const MCRegisterInfo &
MRI = *
getContext().getRegisterInfo();
7167 Operands.push_back(MipsOperand::createCOP0Reg(Encoding,
"", &
MRI, S,
7168 getLexer().getLoc(), *
this));
7173 MCAsmParser &Parser = getParser();
7176 auto Token = Parser.
getTok();
7178 SMLoc S = Token.
getLoc();
7191 ParseStatus Res = matchAnyRegisterWithoutDollar(
Operands, S);
7200 MCAsmParser &Parser = getParser();
7203 SMLoc S = getLexer().getLoc();
7206 ParseStatus Res = parseAnyRegister(
Operands);
7211 const MCExpr *Expr =
nullptr;
7217 MipsOperand::CreateImm(Expr, S, getLexer().getLoc(), *
this));
7222 MCAsmParser &Parser = getParser();
7223 const MCExpr *IdVal;
7234 if (getParser().parseExpression(IdVal))
7241 Operands.push_back(MipsOperand::CreateImm(
7247 MCAsmParser &Parser = getParser();
7251 bool RegRange =
false;
7258 while (parseAnyRegister(TmpOperands).isSuccess()) {
7259 SMLoc
E = getLexer().getLoc();
7260 MipsOperand &RegOpnd =
static_cast<MipsOperand &
>(*TmpOperands.
back());
7261 Reg = isGP64bit() ? RegOpnd.getGPR64Reg() : RegOpnd.getGPR32Reg();
7269 MCRegister TmpReg = PrevReg + 1;
7270 while (TmpReg <=
Reg) {
7271 if ((((TmpReg < Mips::R16) || (TmpReg > Mips::R23)) &&
7273 (((TmpReg < Mips::R16_64) || (TmpReg > Mips::R23_64)) &&
7275 return Error(
E,
"invalid register operand");
7279 TmpReg = TmpReg.
id() + 1;
7288 return Error(
E,
"$16 or $31 expected");
7290 (
Reg >= Mips::R16 &&
Reg <= Mips::R23)) &&
7293 (
Reg >= Mips::R16_64 &&
Reg <= Mips::R23_64)) &&
7295 return Error(
E,
"invalid register operand");
7296 if (PrevReg.
isValid() && (
Reg != PrevReg + 1) &&
7299 return Error(
E,
"consecutive register numbers expected");
7309 return Error(
E,
"',' or '-' expected");
7319 Operands.push_back(MipsOperand::CreateRegList(Regs, S,
E, *
this));
7320 return parseMemOffsetOperand(
Operands);
7329 MCAsmParser &Parser = getParser();
7332 MipsOperand::CreateToken(
"(", getLexer().getLoc(), *
this));
7334 if (parseOperand(
Operands, Name)) {
7335 SMLoc Loc = getLexer().getLoc();
7336 return Error(Loc,
"unexpected token in argument list");
7339 SMLoc Loc = getLexer().getLoc();
7340 return Error(Loc,
"unexpected token, expected ')'");
7343 MipsOperand::CreateToken(
")", getLexer().getLoc(), *
this));
7355bool MipsAsmParser::parseBracketSuffix(StringRef Name,
7357 MCAsmParser &Parser = getParser();
7360 MipsOperand::CreateToken(
"[", getLexer().getLoc(), *
this));
7362 if (parseOperand(
Operands, Name)) {
7363 SMLoc Loc = getLexer().getLoc();
7364 return Error(Loc,
"unexpected token in argument list");
7367 SMLoc Loc = getLexer().getLoc();
7368 return Error(Loc,
"unexpected token, expected ']'");
7371 MipsOperand::CreateToken(
"]", getLexer().getLoc(), *
this));
7378 unsigned VariantID = 0);
7393bool MipsAsmParser::parseInstruction(ParseInstructionInfo &Info, StringRef Name,
7395 MCAsmParser &Parser = getParser();
7399 getTargetStreamer().forbidModuleDirective();
7402 if (!mnemonicIsValid(Name, 0)) {
7403 FeatureBitset FBS = ComputeAvailableFeatures(getSTI().getFeatureBits());
7405 return Error(NameLoc,
"unknown instruction" + Suggestion);
7408 Operands.push_back(MipsOperand::CreateToken(Name, NameLoc, *
this));
7413 bool IsFirstOperand =
Operands.size() == 1;
7415 if (parseOperand(
Operands, Name)) {
7416 SMLoc Loc = getLexer().getLoc();
7417 return Error(Loc,
"unexpected token in argument list");
7422 if (parseBracketSuffix(Name,
Operands))
7430 SMLoc Loc = getLexer().getLoc();
7431 return Error(Loc,
"unexpected token in argument list");
7439bool MipsAsmParser::reportParseError(
const Twine &ErrorMsg) {
7440 SMLoc Loc = getLexer().getLoc();
7441 return Error(Loc, ErrorMsg);
7444bool MipsAsmParser::reportParseError(SMLoc Loc,
const Twine &ErrorMsg) {
7445 return Error(Loc, ErrorMsg);
7448bool MipsAsmParser::parseSetNoAtDirective() {
7449 MCAsmParser &Parser = getParser();
7453 AssemblerOptions.
back()->setATRegIndex(0);
7459 reportParseError(
"unexpected token, expected end of statement");
7463 getTargetStreamer().emitDirectiveSetNoAt();
7468bool MipsAsmParser::parseSetAtDirective() {
7471 MCAsmParser &Parser = getParser();
7476 AssemblerOptions.
back()->setATRegIndex(1);
7478 getTargetStreamer().emitDirectiveSetAt();
7484 reportParseError(
"unexpected token, expected equals sign");
7491 reportParseError(
"no register specified");
7494 reportParseError(
"unexpected token, expected dollar sign '$'");
7504 AtRegNo = matchCPURegisterName(
Reg.getIdentifier());
7506 AtRegNo =
Reg.getIntVal();
7508 reportParseError(
"unexpected token, expected identifier or integer");
7513 if (!AssemblerOptions.
back()->setATRegIndex(AtRegNo)) {
7514 reportParseError(
"invalid register");
7521 reportParseError(
"unexpected token, expected end of statement");
7525 getTargetStreamer().emitDirectiveSetAtWithArg(AtRegNo);
7531bool MipsAsmParser::parseSetReorderDirective() {
7532 MCAsmParser &Parser = getParser();
7536 reportParseError(
"unexpected token, expected end of statement");
7539 AssemblerOptions.
back()->setReorder();
7540 getTargetStreamer().emitDirectiveSetReorder();
7545bool MipsAsmParser::parseSetNoReorderDirective() {
7546 MCAsmParser &Parser = getParser();
7550 reportParseError(
"unexpected token, expected end of statement");
7554 if (AssemblerOptions.
back()->isReorder())
7555 emitPendingHazardNops();
7556 AssemblerOptions.
back()->setNoReorder();
7557 getTargetStreamer().emitDirectiveSetNoReorder();
7562bool MipsAsmParser::parseSetMacroDirective() {
7563 MCAsmParser &Parser = getParser();
7567 reportParseError(
"unexpected token, expected end of statement");
7570 AssemblerOptions.
back()->setMacro();
7571 getTargetStreamer().emitDirectiveSetMacro();
7576bool MipsAsmParser::parseSetNoMacroDirective() {
7577 MCAsmParser &Parser = getParser();
7581 reportParseError(
"unexpected token, expected end of statement");
7584 if (AssemblerOptions.
back()->isReorder()) {
7585 reportParseError(
"`noreorder' must be set before `nomacro'");
7588 AssemblerOptions.
back()->setNoMacro();
7589 getTargetStreamer().emitDirectiveSetNoMacro();
7594bool MipsAsmParser::parseSetMsaDirective() {
7595 MCAsmParser &Parser = getParser();
7600 return reportParseError(
"unexpected token, expected end of statement");
7602 setFeatureBits(Mips::FeatureMSA,
"msa");
7603 getTargetStreamer().emitDirectiveSetMsa();
7607bool MipsAsmParser::parseSetNoMsaDirective() {
7608 MCAsmParser &Parser = getParser();
7613 return reportParseError(
"unexpected token, expected end of statement");
7615 clearFeatureBits(Mips::FeatureMSA,
"msa");
7616 getTargetStreamer().emitDirectiveSetNoMsa();
7620bool MipsAsmParser::parseSetNoDspDirective() {
7621 MCAsmParser &Parser = getParser();
7626 reportParseError(
"unexpected token, expected end of statement");
7630 clearFeatureBits(Mips::FeatureDSP,
"dsp");
7631 getTargetStreamer().emitDirectiveSetNoDsp();
7635bool MipsAsmParser::parseSetNoMips3DDirective() {
7636 MCAsmParser &Parser = getParser();
7641 reportParseError(
"unexpected token, expected end of statement");
7645 clearFeatureBits(Mips::FeatureMips3D,
"mips3d");
7646 getTargetStreamer().emitDirectiveSetNoMips3D();
7650bool MipsAsmParser::parseSetMips16Directive() {
7651 MCAsmParser &Parser = getParser();
7656 reportParseError(
"unexpected token, expected end of statement");
7660 clearFeatureBits(Mips::FeatureMicroMips,
"micromips");
7661 setFeatureBits(Mips::FeatureMips16,
"mips16");
7662 getTargetStreamer().emitDirectiveSetMips16();
7667bool MipsAsmParser::parseSetNoMips16Directive() {
7668 MCAsmParser &Parser = getParser();
7673 reportParseError(
"unexpected token, expected end of statement");
7677 clearFeatureBits(Mips::FeatureMips16,
"mips16");
7678 getTargetStreamer().emitDirectiveSetNoMips16();
7683bool MipsAsmParser::parseSetFpDirective() {
7684 MCAsmParser &Parser = getParser();
7690 AsmToken Tok = Parser.
getTok();
7692 reportParseError(
"unexpected token, expected equals sign '='");
7698 if (!parseFpABIValue(FpAbiVal,
".set"))
7702 reportParseError(
"unexpected token, expected end of statement");
7705 getTargetStreamer().emitDirectiveSetFp(FpAbiVal);
7710bool MipsAsmParser::parseSetOddSPRegDirective() {
7711 MCAsmParser &Parser = getParser();
7715 reportParseError(
"unexpected token, expected end of statement");
7719 clearFeatureBits(Mips::FeatureNoOddSPReg,
"nooddspreg");
7720 getTargetStreamer().emitDirectiveSetOddSPReg();
7724bool MipsAsmParser::parseSetNoOddSPRegDirective() {
7725 MCAsmParser &Parser = getParser();
7729 reportParseError(
"unexpected token, expected end of statement");
7733 setFeatureBits(Mips::FeatureNoOddSPReg,
"nooddspreg");
7734 getTargetStreamer().emitDirectiveSetNoOddSPReg();
7738bool MipsAsmParser::parseSetMtDirective() {
7739 MCAsmParser &Parser = getParser();
7744 reportParseError(
"unexpected token, expected end of statement");
7748 setFeatureBits(Mips::FeatureMT,
"mt");
7749 getTargetStreamer().emitDirectiveSetMt();
7754bool MipsAsmParser::parseSetNoMtDirective() {
7755 MCAsmParser &Parser = getParser();
7760 reportParseError(
"unexpected token, expected end of statement");
7764 clearFeatureBits(Mips::FeatureMT,
"mt");
7766 getTargetStreamer().emitDirectiveSetNoMt();
7771bool MipsAsmParser::parseSetNoCRCDirective() {
7772 MCAsmParser &Parser = getParser();
7777 reportParseError(
"unexpected token, expected end of statement");
7781 clearFeatureBits(Mips::FeatureCRC,
"crc");
7783 getTargetStreamer().emitDirectiveSetNoCRC();
7788bool MipsAsmParser::parseSetNoVirtDirective() {
7789 MCAsmParser &Parser = getParser();
7794 reportParseError(
"unexpected token, expected end of statement");
7798 clearFeatureBits(Mips::FeatureVirt,
"virt");
7800 getTargetStreamer().emitDirectiveSetNoVirt();
7805bool MipsAsmParser::parseSetNoGINVDirective() {
7806 MCAsmParser &Parser = getParser();
7811 reportParseError(
"unexpected token, expected end of statement");
7815 clearFeatureBits(Mips::FeatureGINV,
"ginv");
7817 getTargetStreamer().emitDirectiveSetNoGINV();
7822bool MipsAsmParser::parseSetNoEVADirective() {
7823 MCAsmParser &Parser = getParser();
7828 reportParseError(
"unexpected token, expected end of statement");
7832 clearFeatureBits(Mips::FeatureEVA,
"eva");
7834 getTargetStreamer().emitDirectiveSetNoEVA();
7839bool MipsAsmParser::parseSetPopDirective() {
7840 MCAsmParser &Parser = getParser();
7841 SMLoc Loc = getLexer().getLoc();
7845 return reportParseError(
"unexpected token, expected end of statement");
7849 if (AssemblerOptions.
size() == 2)
7850 return reportParseError(Loc,
".set pop with no .set push");
7853 if (AssemblerOptions.
back()->isReorder() &&
7854 !AssemblerOptions[AssemblerOptions.
size() - 2]->isReorder())
7855 emitPendingHazardNops();
7857 FeatureBitset OldFeatures = getSTI().getFeatureBits();
7858 MCSubtargetInfo &STI = copySTI();
7860 setAvailableFeatures(
7861 ComputeAvailableFeatures(AssemblerOptions.
back()->getFeatures()));
7863 emitHazardNopsForISAChange(OldFeatures);
7865 getTargetStreamer().emitDirectiveSetPop();
7869bool MipsAsmParser::parseSetPushDirective() {
7870 MCAsmParser &Parser = getParser();
7873 return reportParseError(
"unexpected token, expected end of statement");
7877 std::make_unique<MipsAssemblerOptions>(AssemblerOptions.
back().get()));
7879 getTargetStreamer().emitDirectiveSetPush();
7883bool MipsAsmParser::parseSetSoftFloatDirective() {
7884 MCAsmParser &Parser = getParser();
7887 return reportParseError(
"unexpected token, expected end of statement");
7889 setFeatureBits(Mips::FeatureSoftFloat,
"soft-float");
7890 getTargetStreamer().emitDirectiveSetSoftFloat();
7894bool MipsAsmParser::parseSetHardFloatDirective() {
7895 MCAsmParser &Parser = getParser();
7898 return reportParseError(
"unexpected token, expected end of statement");
7900 clearFeatureBits(Mips::FeatureSoftFloat,
"soft-float");
7901 getTargetStreamer().emitDirectiveSetHardFloat();
7905bool MipsAsmParser::parseSetAssignment() {
7907 MCAsmParser &Parser = getParser();
7910 return reportParseError(
"expected identifier after .set");
7913 return reportParseError(
"unexpected token, expected comma");
7928 const MCExpr *
Value;
7930 Parser, Sym,
Value))
7932 getStreamer().emitAssignment(Sym,
Value);
7937bool MipsAsmParser::parseSetMips0Directive() {
7938 MCAsmParser &Parser = getParser();
7941 return reportParseError(
"unexpected token, expected end of statement");
7944 FeatureBitset OldFeatures = getSTI().getFeatureBits();
7945 MCSubtargetInfo &STI = copySTI();
7946 setAvailableFeatures(
7947 ComputeAvailableFeatures(AssemblerOptions.
front()->getFeatures()));
7949 AssemblerOptions.
back()->setFeatures(AssemblerOptions.
front()->getFeatures());
7950 emitHazardNopsForISAChange(OldFeatures);
7952 getTargetStreamer().emitDirectiveSetMips0();
7956bool MipsAsmParser::parseSetArchDirective() {
7957 MCAsmParser &Parser = getParser();
7960 return reportParseError(
"unexpected token, expected equals sign");
7963 StringRef Arch = getParser().parseStringToEndOfStatement().trim();
7965 return reportParseError(
"expected arch identifier");
7967 StringRef ArchFeatureName =
7968 StringSwitch<StringRef>(Arch)
7969 .Case(
"mips1",
"mips1")
7970 .Case(
"mips2",
"mips2")
7971 .Case(
"mips3",
"mips3")
7972 .Case(
"mips4",
"mips4")
7973 .Case(
"mips5",
"mips5")
7974 .Case(
"mips32",
"mips32")
7975 .Case(
"mips32r2",
"mips32r2")
7976 .Case(
"mips32r3",
"mips32r3")
7977 .Case(
"mips32r5",
"mips32r5")
7978 .Case(
"mips32r6",
"mips32r6")
7979 .Case(
"mips64",
"mips64")
7980 .Case(
"mips64r2",
"mips64r2")
7981 .Case(
"mips64r3",
"mips64r3")
7982 .Case(
"mips64r5",
"mips64r5")
7983 .Case(
"mips64r6",
"mips64r6")
7984 .Case(
"octeon",
"cnmips")
7985 .Case(
"octeon+",
"cnmipsp")
7986 .Case(
"r4000",
"mips3")
7989 if (ArchFeatureName.
empty())
7990 return reportParseError(
"unsupported architecture");
7992 if (ArchFeatureName ==
"mips64r6" && inMicroMipsMode())
7993 return reportParseError(
"mips64r6 does not support microMIPS");
7995 selectArch(ArchFeatureName);
7996 getTargetStreamer().emitDirectiveSetArch(Arch);
8000bool MipsAsmParser::parseSetFeature(
uint64_t Feature) {
8001 MCAsmParser &Parser = getParser();
8004 return reportParseError(
"unexpected token, expected end of statement");
8009 case Mips::FeatureMips3D:
8010 setFeatureBits(Mips::FeatureMips3D,
"mips3d");
8011 getTargetStreamer().emitDirectiveSetMips3D();
8013 case Mips::FeatureDSP:
8014 setFeatureBits(Mips::FeatureDSP,
"dsp");
8015 getTargetStreamer().emitDirectiveSetDsp();
8017 case Mips::FeatureDSPR2:
8018 setFeatureBits(Mips::FeatureDSPR2,
"dspr2");
8019 getTargetStreamer().emitDirectiveSetDspr2();
8021 case Mips::FeatureMicroMips:
8022 clearFeatureBits(Mips::FeatureMips16,
"mips16");
8023 setFeatureBits(Mips::FeatureMicroMips,
"micromips");
8024 getTargetStreamer().emitDirectiveSetMicroMips();
8026 case Mips::FeatureMips1:
8027 selectArch(
"mips1");
8028 getTargetStreamer().emitDirectiveSetMips1();
8030 case Mips::FeatureMips2:
8031 selectArch(
"mips2");
8032 getTargetStreamer().emitDirectiveSetMips2();
8034 case Mips::FeatureMips3:
8035 selectArch(
"mips3");
8036 getTargetStreamer().emitDirectiveSetMips3();
8038 case Mips::FeatureMips4:
8039 selectArch(
"mips4");
8040 getTargetStreamer().emitDirectiveSetMips4();
8042 case Mips::FeatureMips5:
8043 selectArch(
"mips5");
8044 getTargetStreamer().emitDirectiveSetMips5();
8046 case Mips::FeatureMips32:
8047 selectArch(
"mips32");
8048 getTargetStreamer().emitDirectiveSetMips32();
8050 case Mips::FeatureMips32r2:
8051 selectArch(
"mips32r2");
8052 getTargetStreamer().emitDirectiveSetMips32R2();
8054 case Mips::FeatureMips32r3:
8055 selectArch(
"mips32r3");
8056 getTargetStreamer().emitDirectiveSetMips32R3();
8058 case Mips::FeatureMips32r5:
8059 selectArch(
"mips32r5");
8060 getTargetStreamer().emitDirectiveSetMips32R5();
8062 case Mips::FeatureMips32r6:
8063 selectArch(
"mips32r6");
8064 getTargetStreamer().emitDirectiveSetMips32R6();
8066 case Mips::FeatureMips64:
8067 selectArch(
"mips64");
8068 getTargetStreamer().emitDirectiveSetMips64();
8070 case Mips::FeatureMips64r2:
8071 selectArch(
"mips64r2");
8072 getTargetStreamer().emitDirectiveSetMips64R2();
8074 case Mips::FeatureMips64r3:
8075 selectArch(
"mips64r3");
8076 getTargetStreamer().emitDirectiveSetMips64R3();
8078 case Mips::FeatureMips64r5:
8079 selectArch(
"mips64r5");
8080 getTargetStreamer().emitDirectiveSetMips64R5();
8082 case Mips::FeatureMips64r6:
8083 selectArch(
"mips64r6");
8084 getTargetStreamer().emitDirectiveSetMips64R6();
8086 case Mips::FeatureCRC:
8087 setFeatureBits(Mips::FeatureCRC,
"crc");
8088 getTargetStreamer().emitDirectiveSetCRC();
8090 case Mips::FeatureVirt:
8091 setFeatureBits(Mips::FeatureVirt,
"virt");
8092 getTargetStreamer().emitDirectiveSetVirt();
8094 case Mips::FeatureGINV:
8095 setFeatureBits(Mips::FeatureGINV,
"ginv");
8096 getTargetStreamer().emitDirectiveSetGINV();
8098 case Mips::FeatureEVA:
8099 setFeatureBits(Mips::FeatureEVA,
"eva");
8100 getTargetStreamer().emitDirectiveSetEVA();
8106bool MipsAsmParser::eatComma(StringRef ErrorStr) {
8107 MCAsmParser &Parser = getParser();
8109 SMLoc Loc = getLexer().getLoc();
8110 return Error(Loc, ErrorStr);
8121bool MipsAsmParser::isPicAndNotNxxAbi() {
8122 return inPicMode() && !(isABI_N32() || isABI_N64());
8125bool MipsAsmParser::parseDirectiveCpAdd(SMLoc Loc) {
8127 ParseStatus Res = parseAnyRegister(
Reg);
8129 reportParseError(
"expected register");
8133 MipsOperand &RegOpnd =
static_cast<MipsOperand &
>(*
Reg[0]);
8134 if (!RegOpnd.isGPRAsmReg()) {
8135 reportParseError(RegOpnd.getStartLoc(),
"invalid register");
8141 reportParseError(
"unexpected token, expected end of statement");
8146 getTargetStreamer().emitDirectiveCpAdd(RegOpnd.getGPR32Reg());
8150bool MipsAsmParser::parseDirectiveCpLoad(SMLoc Loc) {
8151 if (AssemblerOptions.
back()->isReorder())
8152 Warning(Loc,
".cpload should be inside a noreorder section");
8154 if (inMips16Mode()) {
8155 reportParseError(
".cpload is not supported in Mips16 mode");
8160 ParseStatus Res = parseAnyRegister(
Reg);
8162 reportParseError(
"expected register containing function address");
8166 MipsOperand &RegOpnd =
static_cast<MipsOperand &
>(*
Reg[0]);
8167 if (!RegOpnd.isGPRAsmReg()) {
8168 reportParseError(RegOpnd.getStartLoc(),
"invalid register");
8174 reportParseError(
"unexpected token, expected end of statement");
8178 getTargetStreamer().emitDirectiveCpLoad(RegOpnd.getGPR32Reg());
8182bool MipsAsmParser::parseDirectiveCpLocal(SMLoc Loc) {
8183 if (!isABI_N32() && !isABI_N64()) {
8184 reportParseError(
".cplocal is allowed only in N32 or N64 mode");
8189 ParseStatus Res = parseAnyRegister(
Reg);
8191 reportParseError(
"expected register containing global pointer");
8195 MipsOperand &RegOpnd =
static_cast<MipsOperand &
>(*
Reg[0]);
8196 if (!RegOpnd.isGPRAsmReg()) {
8197 reportParseError(RegOpnd.getStartLoc(),
"invalid register");
8203 reportParseError(
"unexpected token, expected end of statement");
8208 MCRegister NewReg = RegOpnd.getGPR32Reg();
8212 getTargetStreamer().emitDirectiveCpLocal(NewReg);
8216bool MipsAsmParser::parseDirectiveCpRestore(SMLoc Loc) {
8217 MCAsmParser &Parser = getParser();
8222 if (inMips16Mode()) {
8223 reportParseError(
".cprestore is not supported in Mips16 mode");
8228 const MCExpr *StackOffset;
8229 int64_t StackOffsetVal;
8231 reportParseError(
"expected stack offset value");
8235 if (!StackOffset->evaluateAsAbsolute(StackOffsetVal)) {
8236 reportParseError(
"stack offset is not an absolute expression");
8240 if (StackOffsetVal < 0) {
8241 Warning(Loc,
".cprestore with negative stack offset has no effect");
8242 IsCpRestoreSet =
false;
8244 IsCpRestoreSet =
true;
8245 CpRestoreOffset = StackOffsetVal;
8250 reportParseError(
"unexpected token, expected end of statement");
8254 if (!getTargetStreamer().emitDirectiveCpRestore(
8255 CpRestoreOffset, [&]() {
return getATReg(Loc); }, Loc, STI))
8261bool MipsAsmParser::parseDirectiveCPSetup() {
8262 MCAsmParser &Parser = getParser();
8264 bool SaveIsReg =
true;
8267 ParseStatus Res = parseAnyRegister(TmpReg);
8269 reportParseError(
"expected register containing function address");
8273 MipsOperand &FuncRegOpnd =
static_cast<MipsOperand &
>(*TmpReg[0]);
8274 if (!FuncRegOpnd.isGPRAsmReg()) {
8275 reportParseError(FuncRegOpnd.getStartLoc(),
"invalid register");
8279 MCRegister FuncReg = FuncRegOpnd.getGPR32Reg();
8282 if (!eatComma(
"unexpected token, expected comma"))
8285 Res = parseAnyRegister(TmpReg);
8287 const MCExpr *OffsetExpr;
8289 SMLoc ExprLoc = getLexer().
getLoc();
8292 !OffsetExpr->evaluateAsAbsolute(OffsetVal)) {
8293 reportParseError(ExprLoc,
"expected save register or stack offset");
8300 MipsOperand &SaveOpnd =
static_cast<MipsOperand &
>(*TmpReg[0]);
8301 if (!SaveOpnd.isGPRAsmReg()) {
8302 reportParseError(SaveOpnd.getStartLoc(),
"invalid register");
8305 Save = SaveOpnd.getGPR32Reg().id();
8308 if (!eatComma(
"unexpected token, expected comma"))
8313 reportParseError(
"expected expression");
8318 reportParseError(
"expected symbol");
8321 const MCSymbolRefExpr *
Ref =
static_cast<const MCSymbolRefExpr *
>(Expr);
8323 CpSaveLocation = Save;
8324 CpSaveLocationIsRegister = SaveIsReg;
8326 getTargetStreamer().emitDirectiveCpsetup(FuncReg, Save,
Ref->getSymbol(),
8331bool MipsAsmParser::parseDirectiveCPReturn() {
8332 getTargetStreamer().emitDirectiveCpreturn(CpSaveLocation,
8333 CpSaveLocationIsRegister);
8337bool MipsAsmParser::parseDirectiveNaN() {
8338 MCAsmParser &Parser = getParser();
8340 const AsmToken &Tok = Parser.
getTok();
8344 getTargetStreamer().emitDirectiveNaN2008();
8346 }
else if (Tok.
getString() ==
"legacy") {
8348 getTargetStreamer().emitDirectiveNaNLegacy();
8354 reportParseError(
"invalid option in .nan directive");
8358bool MipsAsmParser::parseDirectiveSet() {
8359 const AsmToken &Tok = getParser().getTok();
8361 SMLoc Loc = Tok.
getLoc();
8363 if (IdVal ==
"noat")
8364 return parseSetNoAtDirective();
8366 return parseSetAtDirective();
8367 if (IdVal ==
"arch")
8368 return parseSetArchDirective();
8369 if (IdVal ==
"bopt") {
8370 Warning(Loc,
"'bopt' feature is unsupported");
8374 if (IdVal ==
"nobopt") {
8380 return parseSetFpDirective();
8381 if (IdVal ==
"oddspreg")
8382 return parseSetOddSPRegDirective();
8383 if (IdVal ==
"nooddspreg")
8384 return parseSetNoOddSPRegDirective();
8386 return parseSetPopDirective();
8387 if (IdVal ==
"push")
8388 return parseSetPushDirective();
8389 if (IdVal ==
"reorder")
8390 return parseSetReorderDirective();
8391 if (IdVal ==
"noreorder")
8392 return parseSetNoReorderDirective();
8393 if (IdVal ==
"macro")
8394 return parseSetMacroDirective();
8395 if (IdVal ==
"nomacro")
8396 return parseSetNoMacroDirective();
8397 if (IdVal ==
"mips16")
8398 return parseSetMips16Directive();
8399 if (IdVal ==
"nomips16")
8400 return parseSetNoMips16Directive();
8401 if (IdVal ==
"nomicromips") {
8402 clearFeatureBits(Mips::FeatureMicroMips,
"micromips");
8403 getTargetStreamer().emitDirectiveSetNoMicroMips();
8404 getParser().eatToEndOfStatement();
8407 if (IdVal ==
"micromips") {
8408 if (hasMips64r6()) {
8409 Error(Loc,
".set micromips directive is not supported with MIPS64R6");
8412 return parseSetFeature(Mips::FeatureMicroMips);
8414 if (IdVal ==
"mips0")
8415 return parseSetMips0Directive();
8416 if (IdVal ==
"mips1")
8417 return parseSetFeature(Mips::FeatureMips1);
8418 if (IdVal ==
"mips2")
8419 return parseSetFeature(Mips::FeatureMips2);
8420 if (IdVal ==
"mips3")
8421 return parseSetFeature(Mips::FeatureMips3);
8422 if (IdVal ==
"mips4")
8423 return parseSetFeature(Mips::FeatureMips4);
8424 if (IdVal ==
"mips5")
8425 return parseSetFeature(Mips::FeatureMips5);
8426 if (IdVal ==
"mips32")
8427 return parseSetFeature(Mips::FeatureMips32);
8428 if (IdVal ==
"mips32r2")
8429 return parseSetFeature(Mips::FeatureMips32r2);
8430 if (IdVal ==
"mips32r3")
8431 return parseSetFeature(Mips::FeatureMips32r3);
8432 if (IdVal ==
"mips32r5")
8433 return parseSetFeature(Mips::FeatureMips32r5);
8434 if (IdVal ==
"mips32r6")
8435 return parseSetFeature(Mips::FeatureMips32r6);
8436 if (IdVal ==
"mips64")
8437 return parseSetFeature(Mips::FeatureMips64);
8438 if (IdVal ==
"mips64r2")
8439 return parseSetFeature(Mips::FeatureMips64r2);
8440 if (IdVal ==
"mips64r3")
8441 return parseSetFeature(Mips::FeatureMips64r3);
8442 if (IdVal ==
"mips64r5")
8443 return parseSetFeature(Mips::FeatureMips64r5);
8444 if (IdVal ==
"mips64r6") {
8445 if (inMicroMipsMode()) {
8446 Error(Loc,
"MIPS64R6 is not supported with microMIPS");
8449 return parseSetFeature(Mips::FeatureMips64r6);
8452 return parseSetFeature(Mips::FeatureDSP);
8453 if (IdVal ==
"dspr2")
8454 return parseSetFeature(Mips::FeatureDSPR2);
8455 if (IdVal ==
"nodsp")
8456 return parseSetNoDspDirective();
8457 if (IdVal ==
"mips3d")
8458 return parseSetFeature(Mips::FeatureMips3D);
8459 if (IdVal ==
"nomips3d")
8460 return parseSetNoMips3DDirective();
8462 return parseSetMsaDirective();
8463 if (IdVal ==
"nomsa")
8464 return parseSetNoMsaDirective();
8466 return parseSetMtDirective();
8467 if (IdVal ==
"nomt")
8468 return parseSetNoMtDirective();
8469 if (IdVal ==
"softfloat")
8470 return parseSetSoftFloatDirective();
8471 if (IdVal ==
"hardfloat")
8472 return parseSetHardFloatDirective();
8474 return parseSetFeature(Mips::FeatureCRC);
8475 if (IdVal ==
"nocrc")
8476 return parseSetNoCRCDirective();
8477 if (IdVal ==
"virt")
8478 return parseSetFeature(Mips::FeatureVirt);
8479 if (IdVal ==
"novirt")
8480 return parseSetNoVirtDirective();
8481 if (IdVal ==
"ginv")
8482 return parseSetFeature(Mips::FeatureGINV);
8483 if (IdVal ==
"noginv")
8484 return parseSetNoGINVDirective();
8486 return parseSetFeature(Mips::FeatureEVA);
8487 if (IdVal ==
"noeva")
8488 return parseSetNoEVADirective();
8491 return parseSetAssignment();
8496bool MipsAsmParser::parseDirectiveGpWord() {
8497 const MCExpr *
Value;
8498 if (getParser().parseExpression(
Value))
8500 getTargetStreamer().emitGPRel32Value(
Value);
8506bool MipsAsmParser::parseDirectiveGpDWord() {
8507 const MCExpr *
Value;
8508 if (getParser().parseExpression(
Value))
8510 getTargetStreamer().emitGPRel64Value(
Value);
8516bool MipsAsmParser::parseDirectiveDtpRelWord() {
8517 const MCExpr *
Value;
8518 if (getParser().parseExpression(
Value))
8520 getTargetStreamer().emitDTPRel32Value(
Value);
8526bool MipsAsmParser::parseDirectiveDtpRelDWord() {
8527 const MCExpr *
Value;
8528 if (getParser().parseExpression(
Value))
8530 getTargetStreamer().emitDTPRel64Value(
Value);
8536bool MipsAsmParser::parseDirectiveTpRelWord() {
8537 const MCExpr *
Value;
8538 if (getParser().parseExpression(
Value))
8540 getTargetStreamer().emitTPRel32Value(
Value);
8546bool MipsAsmParser::parseDirectiveTpRelDWord() {
8547 const MCExpr *
Value;
8548 if (getParser().parseExpression(
Value))
8550 getTargetStreamer().emitTPRel64Value(
Value);
8554bool MipsAsmParser::parseDirectiveOption() {
8555 MCAsmParser &Parser = getParser();
8557 AsmToken Tok = Parser.
getTok();
8561 "unexpected token, expected identifier");
8566 if (Option ==
"pic0") {
8568 IsPicEnabled =
false;
8570 getTargetStreamer().emitDirectiveOptionPic0();
8574 "unexpected token, expected end of statement");
8579 if (Option ==
"pic2") {
8581 IsPicEnabled =
true;
8583 getTargetStreamer().emitDirectiveOptionPic2();
8587 "unexpected token, expected end of statement");
8594 "unknown option, expected 'pic0' or 'pic2'");
8601bool MipsAsmParser::parseInsnDirective() {
8604 reportParseError(
"unexpected token, expected end of statement");
8610 getTargetStreamer().emitDirectiveInsn();
8618bool MipsAsmParser::parseRSectionDirective(StringRef Section) {
8621 reportParseError(
"unexpected token, expected end of statement");
8625 MCSection *ELFSection =
getContext().getELFSection(
8627 getParser().getStreamer().switchSection(ELFSection);
8636bool MipsAsmParser::parseSSectionDirective(StringRef Section,
unsigned Type) {
8639 reportParseError(
"unexpected token, expected end of statement");
8643 MCSection *ELFSection =
getContext().getELFSection(
8645 getParser().getStreamer().switchSection(ELFSection);
8664bool MipsAsmParser::parseDirectiveModule() {
8665 MCAsmParser &Parser = getParser();
8666 AsmLexer &Lexer = getLexer();
8669 if (!getTargetStreamer().isModuleDirectiveAllowed()) {
8671 reportParseError(
".module directive must appear before any code");
8677 reportParseError(
"expected .module option identifier");
8681 if (Option ==
"oddspreg") {
8682 clearModuleFeatureBits(Mips::FeatureNoOddSPReg,
"nooddspreg");
8686 getTargetStreamer().updateABIInfo(*
this);
8691 getTargetStreamer().emitDirectiveModuleOddSPReg();
8695 reportParseError(
"unexpected token, expected end of statement");
8700 }
else if (Option ==
"nooddspreg") {
8702 return Error(L,
"'.module nooddspreg' requires the O32 ABI");
8705 setModuleFeatureBits(Mips::FeatureNoOddSPReg,
"nooddspreg");
8709 getTargetStreamer().updateABIInfo(*
this);
8714 getTargetStreamer().emitDirectiveModuleOddSPReg();
8718 reportParseError(
"unexpected token, expected end of statement");
8723 }
else if (Option ==
"fp") {
8724 return parseDirectiveModuleFP();
8725 }
else if (Option ==
"softfloat") {
8726 setModuleFeatureBits(Mips::FeatureSoftFloat,
"soft-float");
8730 getTargetStreamer().updateABIInfo(*
this);
8735 getTargetStreamer().emitDirectiveModuleSoftFloat();
8739 reportParseError(
"unexpected token, expected end of statement");
8744 }
else if (Option ==
"hardfloat") {
8745 clearModuleFeatureBits(Mips::FeatureSoftFloat,
"soft-float");
8749 getTargetStreamer().updateABIInfo(*
this);
8754 getTargetStreamer().emitDirectiveModuleHardFloat();
8758 reportParseError(
"unexpected token, expected end of statement");
8763 }
else if (Option ==
"mt") {
8764 setModuleFeatureBits(Mips::FeatureMT,
"mt");
8768 getTargetStreamer().updateABIInfo(*
this);
8773 getTargetStreamer().emitDirectiveModuleMT();
8777 reportParseError(
"unexpected token, expected end of statement");
8782 }
else if (Option ==
"crc") {
8783 setModuleFeatureBits(Mips::FeatureCRC,
"crc");
8787 getTargetStreamer().updateABIInfo(*
this);
8792 getTargetStreamer().emitDirectiveModuleCRC();
8796 reportParseError(
"unexpected token, expected end of statement");
8801 }
else if (Option ==
"nocrc") {
8802 clearModuleFeatureBits(Mips::FeatureCRC,
"crc");
8806 getTargetStreamer().updateABIInfo(*
this);
8811 getTargetStreamer().emitDirectiveModuleNoCRC();
8815 reportParseError(
"unexpected token, expected end of statement");
8820 }
else if (Option ==
"virt") {
8821 setModuleFeatureBits(Mips::FeatureVirt,
"virt");
8825 getTargetStreamer().updateABIInfo(*
this);
8830 getTargetStreamer().emitDirectiveModuleVirt();
8834 reportParseError(
"unexpected token, expected end of statement");
8839 }
else if (Option ==
"novirt") {
8840 clearModuleFeatureBits(Mips::FeatureVirt,
"virt");
8844 getTargetStreamer().updateABIInfo(*
this);
8849 getTargetStreamer().emitDirectiveModuleNoVirt();
8853 reportParseError(
"unexpected token, expected end of statement");
8858 }
else if (Option ==
"ginv") {
8859 setModuleFeatureBits(Mips::FeatureGINV,
"ginv");
8863 getTargetStreamer().updateABIInfo(*
this);
8868 getTargetStreamer().emitDirectiveModuleGINV();
8872 reportParseError(
"unexpected token, expected end of statement");
8877 }
else if (Option ==
"noginv") {
8878 clearModuleFeatureBits(Mips::FeatureGINV,
"ginv");
8882 getTargetStreamer().updateABIInfo(*
this);
8887 getTargetStreamer().emitDirectiveModuleNoGINV();
8891 reportParseError(
"unexpected token, expected end of statement");
8897 return Error(L,
"'" + Twine(Option) +
"' is not a valid .module option.");
8905bool MipsAsmParser::parseDirectiveModuleFP() {
8906 MCAsmParser &Parser = getParser();
8907 AsmLexer &Lexer = getLexer();
8910 reportParseError(
"unexpected token, expected equals sign '='");
8916 if (!parseFpABIValue(FpABI,
".module"))
8920 reportParseError(
"unexpected token, expected end of statement");
8926 getTargetStreamer().updateABIInfo(*
this);
8931 getTargetStreamer().emitDirectiveModuleFP();
8938 StringRef Directive) {
8939 MCAsmParser &Parser = getParser();
8940 AsmLexer &Lexer = getLexer();
8941 bool ModuleLevelOptions = Directive ==
".module";
8947 if (
Value !=
"xx") {
8948 reportParseError(
"unsupported value, expected 'xx', '32' or '64'");
8953 reportParseError(
"'" + Directive +
" fp=xx' requires the O32 ABI");
8957 FpABI = MipsABIFlagsSection::FpABIKind::XX;
8958 if (ModuleLevelOptions) {
8959 setModuleFeatureBits(Mips::FeatureFPXX,
"fpxx");
8960 clearModuleFeatureBits(Mips::FeatureFP64Bit,
"fp64");
8962 setFeatureBits(Mips::FeatureFPXX,
"fpxx");
8963 clearFeatureBits(Mips::FeatureFP64Bit,
"fp64");
8973 reportParseError(
"unsupported value, expected 'xx', '32' or '64'");
8979 reportParseError(
"'" + Directive +
" fp=32' requires the O32 ABI");
8983 FpABI = MipsABIFlagsSection::FpABIKind::S32;
8984 if (ModuleLevelOptions) {
8985 clearModuleFeatureBits(Mips::FeatureFPXX,
"fpxx");
8986 clearModuleFeatureBits(Mips::FeatureFP64Bit,
"fp64");
8988 clearFeatureBits(Mips::FeatureFPXX,
"fpxx");
8989 clearFeatureBits(Mips::FeatureFP64Bit,
"fp64");
8992 FpABI = MipsABIFlagsSection::FpABIKind::S64;
8993 if (ModuleLevelOptions) {
8994 clearModuleFeatureBits(Mips::FeatureFPXX,
"fpxx");
8995 setModuleFeatureBits(Mips::FeatureFP64Bit,
"fp64");
8997 clearFeatureBits(Mips::FeatureFPXX,
"fpxx");
8998 setFeatureBits(Mips::FeatureFP64Bit,
"fp64");
9008bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) {
9014 MCAsmParser &Parser = getParser();
9015 StringRef IDVal = DirectiveID.
getString();
9017 if (IDVal ==
".cpadd") {
9018 parseDirectiveCpAdd(DirectiveID.
getLoc());
9021 if (IDVal ==
".cpload") {
9022 parseDirectiveCpLoad(DirectiveID.
getLoc());
9025 if (IDVal ==
".cprestore") {
9026 parseDirectiveCpRestore(DirectiveID.
getLoc());
9029 if (IDVal ==
".cplocal") {
9030 parseDirectiveCpLocal(DirectiveID.
getLoc());
9033 if (IDVal ==
".ent") {
9037 reportParseError(
"expected identifier after .ent");
9051 reportParseError(
"unexpected token, expected end of statement");
9055 const MCExpr *DummyNumber;
9056 int64_t DummyNumberVal;
9060 reportParseError(
"expected number after comma");
9063 if (!DummyNumber->evaluateAsAbsolute(DummyNumberVal)) {
9064 reportParseError(
"expected an absolute expression after comma");
9071 reportParseError(
"unexpected token, expected end of statement");
9077 getTargetStreamer().emitDirectiveEnt(*Sym);
9079 IsCpRestoreSet =
false;
9083 if (IDVal ==
".end") {
9087 reportParseError(
"expected identifier after .end");
9092 reportParseError(
"unexpected token, expected end of statement");
9096 if (CurrentFn ==
nullptr) {
9097 reportParseError(
".end used without .ent");
9101 if ((SymbolName != CurrentFn->
getName())) {
9102 reportParseError(
".end symbol does not match .ent symbol");
9106 getTargetStreamer().emitDirectiveEnd(SymbolName);
9107 CurrentFn =
nullptr;
9108 IsCpRestoreSet =
false;
9112 if (IDVal ==
".frame") {
9115 ParseStatus Res = parseAnyRegister(TmpReg);
9117 reportParseError(
"expected stack register");
9121 MipsOperand &StackRegOpnd =
static_cast<MipsOperand &
>(*TmpReg[0]);
9122 if (!StackRegOpnd.isGPRAsmReg()) {
9123 reportParseError(StackRegOpnd.getStartLoc(),
9124 "expected general purpose register");
9127 MCRegister StackReg = StackRegOpnd.getGPR32Reg();
9132 reportParseError(
"unexpected token, expected comma");
9137 const MCExpr *FrameSize;
9138 int64_t FrameSizeVal;
9141 reportParseError(
"expected frame size value");
9145 if (!FrameSize->evaluateAsAbsolute(FrameSizeVal)) {
9146 reportParseError(
"frame size not an absolute expression");
9153 reportParseError(
"unexpected token, expected comma");
9159 Res = parseAnyRegister(TmpReg);
9161 reportParseError(
"expected return register");
9165 MipsOperand &ReturnRegOpnd =
static_cast<MipsOperand &
>(*TmpReg[0]);
9166 if (!ReturnRegOpnd.isGPRAsmReg()) {
9167 reportParseError(ReturnRegOpnd.getStartLoc(),
9168 "expected general purpose register");
9174 reportParseError(
"unexpected token, expected end of statement");
9178 getTargetStreamer().emitFrame(StackReg, FrameSizeVal,
9179 ReturnRegOpnd.getGPR32Reg());
9180 IsCpRestoreSet =
false;
9184 if (IDVal ==
".set") {
9185 parseDirectiveSet();
9189 if (IDVal ==
".mask" || IDVal ==
".fmask") {
9200 const MCExpr *BitMask;
9204 reportParseError(
"expected bitmask value");
9208 if (!BitMask->evaluateAsAbsolute(BitMaskVal)) {
9209 reportParseError(
"bitmask not an absolute expression");
9216 reportParseError(
"unexpected token, expected comma");
9221 const MCExpr *FrameOffset;
9222 int64_t FrameOffsetVal;
9225 reportParseError(
"expected frame offset value");
9229 if (!FrameOffset->evaluateAsAbsolute(FrameOffsetVal)) {
9230 reportParseError(
"frame offset not an absolute expression");
9236 reportParseError(
"unexpected token, expected end of statement");
9240 if (IDVal ==
".mask")
9241 getTargetStreamer().emitMask(BitMaskVal, FrameOffsetVal);
9243 getTargetStreamer().emitFMask(BitMaskVal, FrameOffsetVal);
9247 if (IDVal ==
".nan")
9248 return parseDirectiveNaN();
9250 if (IDVal ==
".gpword") {
9251 parseDirectiveGpWord();
9255 if (IDVal ==
".gpdword") {
9256 parseDirectiveGpDWord();
9260 if (IDVal ==
".dtprelword") {
9261 parseDirectiveDtpRelWord();
9265 if (IDVal ==
".dtpreldword") {
9266 parseDirectiveDtpRelDWord();
9270 if (IDVal ==
".tprelword") {
9271 parseDirectiveTpRelWord();
9275 if (IDVal ==
".tpreldword") {
9276 parseDirectiveTpRelDWord();
9280 if (IDVal ==
".option") {
9281 parseDirectiveOption();
9285 if (IDVal ==
".abicalls") {
9286 getTargetStreamer().emitDirectiveAbiCalls();
9289 "unexpected token, expected end of statement");
9294 if (IDVal ==
".cpsetup") {
9295 parseDirectiveCPSetup();
9298 if (IDVal ==
".cpreturn") {
9299 parseDirectiveCPReturn();
9302 if (IDVal ==
".module") {
9303 parseDirectiveModule();
9306 if (IDVal ==
".llvm_internal_mips_reallow_module_directive") {
9307 parseInternalDirectiveReallowModule();
9310 if (IDVal ==
".insn") {
9311 parseInsnDirective();
9314 if (IDVal ==
".rdata") {
9315 parseRSectionDirective(
".rodata");
9318 if (IDVal ==
".sbss") {
9322 if (IDVal ==
".sdata") {
9330bool MipsAsmParser::parseInternalDirectiveReallowModule() {
9333 reportParseError(
"unexpected token, expected end of statement");
9337 getTargetStreamer().reallowModuleDirective();
9351#define GET_REGISTER_MATCHER
9352#define GET_MATCHER_IMPLEMENTATION
9353#define GET_MNEMONIC_SPELL_CHECKER
9354#include "MipsGenAsmMatcher.inc"
9356bool MipsAsmParser::mnemonicIsValid(
StringRef Mnemonic,
unsigned VariantID) {
9358 const MatchEntry *Start, *
End;
9359 switch (VariantID) {
9361 case 0: Start = std::begin(MatchTable0);
End = std::end(MatchTable0);
break;
9364 auto MnemonicRange = std::equal_range(Start,
End, Mnemonic, LessOpcode());
9365 return MnemonicRange.first != MnemonicRange.second;
static const TargetRegisterClass * getRegClass(const MachineInstr &MI, Register Reg)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool isNot(const MachineRegisterInfo &MRI, const MachineInstr &MI)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static bool isLoad(int Opcode)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_EXTERNAL_VISIBILITY
static Value * expandAbs(CallInst *Orig)
This file defines the DenseMap class.
std::pair< Instruction::BinaryOps, Value * > OffsetOp
Find all possible pairs (BinOp, RHS) that BinOp V, RHS can be simplified.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static FeatureBitset getFeatures(MCSubtargetInfo &STI, StringRef CPU, StringRef TuneCPU, StringRef FS, StringTable ProcNames, ArrayRef< SubtargetSubTypeKV > ProcDesc, ArrayRef< SubtargetFeatureKV > ProcFeatures)
static bool hasFeature(StringRef Feature, const FeatureBitset &FeatureBits, ArrayRef< SubtargetFeatureKV > ProcFeatures)
static bool writesReg(const MCInstrDesc &Desc, MCRegister Reg, const MCRegisterInfo &MRI)
static bool readsReg(const MCInstrDesc &Desc, MCRegister Reg, const MCRegisterInfo &MRI)
static unsigned countMCSymbolRefExpr(const MCExpr *Expr)
static std::string MipsMnemonicSpellCheck(StringRef S, const FeatureBitset &FBS, unsigned VariantID=0)
static uint64_t convertIntToDoubleImm(uint64_t ImmOp64)
static uint32_t covertDoubleImmToSingleImm(uint64_t ImmOp64)
static bool isCopReg(MCRegister Reg, const MCRegisterInfo &MRI)
static unsigned getRegisterForMxtrDSP(MCInst &Inst, bool IsMFDSP)
static bool isGPR(MCRegister Reg, const MCRegisterInfo &MRI)
static bool hasShortDelaySlot(MCInst &Inst)
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsAsmParser()
static bool needsExpandMemInst(MCInst &Inst, const MCInstrDesc &MCID)
static bool isFCCReg(MCRegister Reg, const MCRegisterInfo &MRI)
static bool isGOTLoad(const MCInst &Inst)
static bool isShiftedUIntAtAnyPosition(uint64_t x)
Can the value be represented by a unsigned N-bit value and a shift left?
static bool isEvaluated(const MCExpr *Expr)
static FeatureBitset getHazardFeatures(const FeatureBitset &Features)
static const MCSymbol * getSingleMCSymbol(const MCExpr *Expr)
static MCRegister nextReg(MCRegister Reg)
static unsigned getRegisterForMxtrFP(MCInst &Inst, bool IsMFTC1)
static bool isFPUReg(MCRegister Reg, const MCRegisterInfo &MRI)
static SMLoc RefineErrorLoc(const SMLoc Loc, const OperandVector &Operands, uint64_t ErrorInfo)
static MCRegister getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
static bool isReg(const MCInst &MI, unsigned OpNo)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
MachineRegisterInfo & MRI
Remove Loads Into Fake Uses
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file provides utility classes that use RAII to save and restore values.
This file defines the SmallVector class.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static bool isMemOperand(const MCInst &MI, unsigned Op, unsigned RegClassID)
static constexpr const fltSemantics & IEEEdouble()
APInt bitcastToAPInt() const
uint64_t getZExtValue() const
Get zero extended value.
SMLoc getLoc() const
Get the current source location.
const AsmToken peekTok(bool ShouldSkipSpace=true)
Look ahead at the next token to be lexed.
bool is(AsmToken::TokenKind K) const
Check if the current token has kind K.
bool isNot(AsmToken::TokenKind K) const
Check if the current token has kind K.
Target independent representation for an assembler token.
LLVM_ABI SMLoc getLoc() const
int64_t getIntVal() const
bool isNot(TokenKind K) const
StringRef getString() const
Get the string for the current token, this includes all characters (for example, the quotes on string...
bool is(TokenKind K) const
TokenKind getKind() const
LLVM_ABI SMRange getLocRange() const
StringRef getIdentifier() const
Get the identifier string for the current token, which should be an identifier or a string.
iterator find(const_arg_type_t< KeyT > Val)
Base class for user error types.
Container class for subtarget features.
void printExpr(raw_ostream &, const MCExpr &) const
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser.
virtual void eatToEndOfStatement()=0
Skip to the end of the current statement, for error recovery.
bool parseToken(AsmToken::TokenKind T, const Twine &Msg="unexpected token")
virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc)=0
Parse an arbitrary expression.
const AsmToken & getTok() const
Get the current AsmToken from the stream.
virtual bool parseIdentifier(StringRef &Res)=0
Parse an identifier or string (as a quoted identifier) and set Res to the identifier contents.
virtual const AsmToken & Lex()=0
Get the next AsmToken in the stream, possibly handling file inclusion first.
virtual void addAliasForDirective(StringRef Directive, StringRef Alias)=0
Binary assembler expressions.
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Base class for the full range of assembler expressions which are needed for parsing.
LLVM_ABI bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm) const
Try to evaluate the expression to a relocatable value, i.e.
@ Unary
Unary expressions.
@ Constant
Constant expressions.
@ SymbolRef
References to labels and assigned expressions.
@ Target
Target specific expression.
@ Specifier
Expression with a relocation specifier.
@ Binary
Binary expressions.
Instances of this class represent a single low-level machine instruction.
unsigned getNumOperands() const
unsigned getOpcode() const
ArrayRef< MCOperand > getOperands() const
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
const MCOperand & getOperand(unsigned i) const
Describe properties that are true of each instruction in the target description file.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
ArrayRef< MCOperandInfo > operands() const
bool mayStore() const
Return true if this instruction could possibly modify memory.
bool mayLoad() const
Return true if this instruction could possibly read memory.
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
bool isBranch() const
Returns true if this is a conditional, unconditional, or indirect branch.
bool isCall() const
Return true if the instruction is a call.
bool hasDelaySlot() const
Returns true if the specified instruction has a delay slot which must be filled by the code generator...
Interface to description of machine instruction set.
This holds information about one operand of a machine instruction, indicating the register class for ...
uint8_t OperandType
Information about the type of the operand.
Instances of this class represent operands of the MCInst class.
static MCOperand createExpr(const MCExpr *Val)
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
MCRegister getReg() const
Returns the register number.
const MCExpr * getExpr() const
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand.
virtual bool isReg() const =0
isReg - Is this a register operand?
virtual MCRegister getReg() const =0
MCRegister getRegister(unsigned i) const
getRegister - Return the specified register in the class.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers and target specific virtual registers.
constexpr bool isValid() const
constexpr unsigned id() const
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Streaming machine code generation interface.
virtual void emitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr, SMLoc Loc={})
Record a relocation described by the .reloc directive.
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
void setFeatureBits(const FeatureBitset &FeatureBits_)
const Triple & getTargetTriple() const
const FeatureBitset & getFeatureBits() const
const FeatureBitset & ToggleFeature(uint64_t FB)
Toggle a feature and return the re-computed feature bits.
virtual unsigned getHwMode(enum HwModeType type=HwMode_Default) const
HwMode ID corresponding to the 'type' parameter is retrieved from the HwMode bit set of the current s...
Represent a reference to a symbol from inside an expression.
uint16_t getSpecifier() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute).
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
StringRef getName() const
getName - Get the symbol name.
bool isVariable() const
isVariable - Check if this is a variable symbol.
const MCExpr * getVariableValue() const
Get the expression of the variable symbol.
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
MCTargetAsmParser - Generic interface to target specific assembly parsers.
MCStreamer & getStreamer()
Unary assembler expressions.
const MCSymbol * getAddSym() const
int64_t getConstant() const
const MCSymbol * getSubSym() const
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
Emits the instructions that MipsTargetStreamer creates for the assembler.
static const char * getRegisterName(MCRegister Reg, unsigned AltIdx=Mips::NoRegAltName)
void emitRRX(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, MCOperand Op2, SMLoc IDLoc, const MCSubtargetInfo *STI)
virtual void emitDirectiveSetReorder()
void emitRRRX(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, MCRegister Reg2, MCOperand Op3, SMLoc IDLoc, const MCSubtargetInfo *STI)
void emitRX(unsigned Opcode, MCRegister Reg0, MCOperand Op1, SMLoc IDLoc, const MCSubtargetInfo *STI)
void emitR(unsigned Opcode, MCRegister Reg0, SMLoc IDLoc, const MCSubtargetInfo *STI)
virtual void setUsesMicroMips()
void emitRRI(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, int16_t Imm, SMLoc IDLoc, const MCSubtargetInfo *STI)
void emitEmptyDelaySlot(bool hasShortDelaySlot, SMLoc IDLoc, const MCSubtargetInfo *STI)
void emitRI(unsigned Opcode, MCRegister Reg0, int32_t Imm, SMLoc IDLoc, const MCSubtargetInfo *STI)
void emitII(unsigned Opcode, int16_t Imm1, int16_t Imm2, SMLoc IDLoc, const MCSubtargetInfo *STI)
void emitRR(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, SMLoc IDLoc, const MCSubtargetInfo *STI)
void updateABIInfo(const PredicateLibrary &P)
void emitRRIII(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, int16_t Imm0, int16_t Imm1, int16_t Imm2, SMLoc IDLoc, const MCSubtargetInfo *STI)
void emitDSLL(MCRegister DstReg, MCRegister SrcReg, int16_t ShiftAmount, SMLoc IDLoc, const MCSubtargetInfo *STI)
void emitGPRestore(int Offset, SMLoc IDLoc, const MCSubtargetInfo *STI)
Emit the $gp restore operation for .cprestore.
void emitNop(SMLoc IDLoc, const MCSubtargetInfo *STI)
void emitRRR(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, MCRegister Reg2, SMLoc IDLoc, const MCSubtargetInfo *STI)
virtual void emitDirectiveSetNoReorder()
Ternary parse status returned by various parse* methods.
constexpr bool isFailure() const
static constexpr StatusTy Failure
constexpr bool isSuccess() const
static constexpr StatusTy Success
static constexpr StatusTy NoMatch
constexpr bool isNoMatch() const
constexpr unsigned id() const
Represents a location in source code.
static SMLoc getFromPointer(const char *Ptr)
constexpr const char * getPointer() const
iterator erase(const_iterator CI)
void push_back(const T &Elt)
LLVM_NO_SANITIZE_CFI_UNRELATED_CAST iterator begin()
iterator find(StringRef Key)
Represent a constant reference to a string, i.e.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
Check if the string is empty.
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const AArch64MCOptions & getCLOpts(const MCTargetOptions &Options)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
LLVM_ABI LLVM_READONLY ARMABI computeTargetABI(const Triple &TT, StringRef ABIName="")
LLVM_ABI bool parseAssignmentExpression(StringRef Name, bool allow_redef, MCAsmParser &Parser, MCSymbol *&Symbol, const MCExpr *&Value)
Parse a value expression and return whether it can be assigned to a symbol with the given name.
constexpr unsigned encodeCOP0Register(unsigned Reg, unsigned Sel)
COP0 hardware encodings reserve five bits each for REG and SEL.
MCRegister getCOP0Register(const MCRegisterInfo &MRI, unsigned Encoding)
MCRegister matchRegisterName(StringRef Name, const MCRegisterInfo &MRI, unsigned RegClassID, unsigned AltIdx)
Match a symbolic name in RegClassID, or return an invalid register.
constexpr unsigned getCOP0RegNum(unsigned Encoding)
int getCPURegisterIndex(StringRef Name, const MCRegisterInfo &MRI, unsigned AltIdx, bool *IsDeprecated=nullptr)
Return a GPR name's hardware index, or -1 if unknown.
constexpr unsigned getCOP0Sel(unsigned Encoding)
constexpr MCPhysReg FP_64
constexpr MCPhysReg GP_64
constexpr MCPhysReg RA_64
constexpr MCPhysReg SP_64
WebAssemblyABI getABI(StringRef Name)
Parse an ABI name into the corresponding enum.
@ CE
Windows NT (Windows on ARM)
void emitInstruction(MCObjectStreamer &, const MCInst &Inst, const MCSubtargetInfo &STI)
LLVM_ABI TargetOptions getTargetOptions(const cl::LibraryOptionsContext &LibraryOptions, const llvm::Triple &TheTriple)
Common utility function tightly tied to the options listed here.
LLVM_ABI StringRef getABIName(const cl::LibraryOptionsContext &C)
BaseReg
Stack frame base register. Bit 0 of FREInfo.Info.
unsigned getOpcode(const VPValue *V)
Return the instruction opcode for the recipe defining V or 0 for unsupported recipes and VPValues not...
This is an optimization pass for GlobalISel generic memory operations.
SaveAndRestore(T &) -> SaveAndRestore< T >
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
Target & getTheMips64Target()
static bool isMem(const MachineInstr &MI, unsigned Op)
LLVM_ABI std::pair< StringRef, StringRef > getToken(StringRef Source, StringRef Delimiters=" \t\n\v\f\r")
getToken - This function extracts one token from source, ignoring any leading characters that appear ...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
@ Load
The value being inserted comes from a load (InsertElement only).
static StringRef getCPU(StringRef CPU)
Processes a CPU name.
int bit_width(T Value)
Returns the number of bits needed to represent Value if Value is nonzero.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
OutputIt copy_if(R &&Range, OutputIt Out, UnaryPredicate P)
Provide wrappers to std::copy_if which take ranges instead of having to pass begin/end explicitly.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
SmallVectorImpl< std::unique_ptr< MCParsedAsmOperand > > OperandVector
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
@ Off
Use window algorithm after SMS algorithm fails.
constexpr uint32_t Hi_32(uint64_t Value)
Return the high 32 bits of a 64 bit value.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
constexpr uint32_t Lo_32(uint64_t Value)
Return the low 32 bits of a 64 bit value.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Success
The lock was released successfully.
Target & getTheMips64elTarget()
uint64_t offsetToAlignment(uint64_t Value, Align Alignment)
Returns the offset to the next integer (mod 2**64) that is greater than or equal to Value and is a mu...
@ Ref
The access may reference the value stored in memory.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
To bit_cast(const From &from) noexcept
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
Target & getTheMipselTarget()
DWARFExpression::Operation Op
constexpr bool isShiftedInt(int64_t x)
Checks if a signed integer is an N bit number shifted left by S.
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
static uint16_t getSpecifier(const MCSymbolRefExpr *SRE)
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
Target & getTheMipsTarget()
@ End
Run the machine verifier once, at the end of the pipeline.
constexpr bool isShiftedUInt(uint64_t x)
Checks if a unsigned integer is an N bit number shifted left by S.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
RegisterMCAsmParser - Helper template for registering a target specific assembly parser,...