#include "MCTargetDesc/MipsABIFlagsSection.h"
#include "MCTargetDesc/MipsABIInfo.h"
#include "MCTargetDesc/MipsBaseInfo.h"
#include "MCTargetDesc/MipsMCExpr.h"
#include "MCTargetDesc/MipsMCTargetDesc.h"
#include "MipsTargetStreamer.h"
#include "TargetInfo/MipsTargetInfo.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCParser/MCAsmLexer.h"
#include "llvm/MC/MCParser/MCAsmParser.h"
#include "llvm/MC/MCParser/MCAsmParserExtension.h"
#include "llvm/MC/MCParser/MCAsmParserUtils.h"
#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
#include "llvm/MC/MCParser/MCTargetAsmParser.h"
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCSymbolELF.h"
#include "llvm/MC/MCValue.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/SMLoc.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/SubtargetFeature.h"
#include "llvm/TargetParser/Triple.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <memory>
#include <string>
#include <utility>
usingnamespacellvm;
#define DEBUG_TYPE …
namespace llvm {
class MCInstrInfo;
}
extern cl::opt<bool> EmitJalrReloc;
namespace {
class MipsAssemblerOptions { … };
}
const FeatureBitset MipsAssemblerOptions::AllArchRelatedMask = …;
namespace {
class MipsAsmParser : public MCTargetAsmParser { … };
class MipsOperand : public MCParsedAsmOperand { … };
}
static bool hasShortDelaySlot(MCInst &Inst) { … }
static const MCSymbol *getSingleMCSymbol(const MCExpr *Expr) { … }
static unsigned countMCSymbolRefExpr(const MCExpr *Expr) { … }
static bool isEvaluated(const MCExpr *Expr) { … }
static bool needsExpandMemInst(MCInst &Inst, const MCInstrDesc &MCID) { … }
bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
void MipsAsmParser::onEndOfFile() { … }
MipsAsmParser::MacroExpanderResultTy
MipsAsmParser::tryExpandInstruction(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandJalWithRegs(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
template <unsigned N> static bool isShiftedUIntAtAnyPosition(uint64_t x) { … }
bool MipsAsmParser::loadImmediate(int64_t ImmValue, unsigned DstReg,
unsigned SrcReg, bool Is32BitImm,
bool IsAddress, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandLoadImm(MCInst &Inst, bool Is32BitImm, SMLoc IDLoc,
MCStreamer &Out, const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandLoadAddress(unsigned DstReg, unsigned BaseReg,
const MCOperand &Offset,
bool Is32BitAddress, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
unsigned DstReg, unsigned SrcReg,
bool Is32BitSym, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
static unsigned nextReg(unsigned Reg) { … }
bool MipsAsmParser::emitPartialAddress(MipsTargetStreamer &TOut, SMLoc IDLoc,
MCSymbol *Sym) { … }
static uint64_t convertIntToDoubleImm(uint64_t ImmOp64) { … }
static uint32_t covertDoubleImmToSingleImm(uint64_t ImmOp64) { … }
bool MipsAsmParser::expandLoadSingleImmToGPR(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandLoadSingleImmToFPR(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandLoadDoubleImmToGPR(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandLoadDoubleImmToFPR(MCInst &Inst, bool Is64FPU,
SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandUncondBranchMMPseudo(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandBranchImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
void MipsAsmParser::expandMem16Inst(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI, bool IsLoad) { … }
void MipsAsmParser::expandMem9Inst(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI, bool IsLoad) { … }
bool MipsAsmParser::expandLoadStoreMultiple(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandCondBranches(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandDivRem(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI,
const bool IsMips64, const bool Signed) { … }
bool MipsAsmParser::expandTrunc(MCInst &Inst, bool IsDouble, bool Is64FPU,
SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandUlh(MCInst &Inst, bool Signed, SMLoc IDLoc,
MCStreamer &Out, const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandUsh(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandUxw(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandSge(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandSgeImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandSgtImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandSle(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandSleImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandAliasImmediate(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandRotation(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandRotationImm(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandDRotation(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandDRotationImm(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandAbs(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandMulImm(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandMulO(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandMulOU(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandDMULMacro(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandLoadStoreDMacro(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI,
bool IsLoad) { … }
bool MipsAsmParser::expandStoreDM1Macro(MCInst &Inst, SMLoc IDLoc,
MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandSeq(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandSeqI(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandSne(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandSneI(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
static unsigned getRegisterForMxtrDSP(MCInst &Inst, bool IsMFDSP) { … }
static unsigned getRegisterForMxtrFP(MCInst &Inst, bool IsMFTC1) { … }
static unsigned getRegisterForMxtrC0(MCInst &Inst, bool IsMFTC0) { … }
bool MipsAsmParser::expandMXTRAlias(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
bool MipsAsmParser::expandSaaAddr(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
const MCSubtargetInfo *STI) { … }
unsigned
MipsAsmParser::checkEarlyTargetMatchPredicate(MCInst &Inst,
const OperandVector &Operands) { … }
unsigned MipsAsmParser::checkTargetMatchPredicate(MCInst &Inst) { … }
static SMLoc RefineErrorLoc(const SMLoc Loc, const OperandVector &Operands,
uint64_t ErrorInfo) { … }
bool MipsAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
OperandVector &Operands,
MCStreamer &Out,
uint64_t &ErrorInfo,
bool MatchingInlineAsm) { … }
void MipsAsmParser::warnIfRegIndexIsAT(unsigned RegIndex, SMLoc Loc) { … }
void MipsAsmParser::warnIfNoMacro(SMLoc Loc) { … }
void MipsAsmParser::ConvertXWPOperands(MCInst &Inst,
const OperandVector &Operands) { … }
void
MipsAsmParser::printWarningWithFixIt(const Twine &Msg, const Twine &FixMsg,
SMRange Range, bool ShowColors) { … }
int MipsAsmParser::matchCPURegisterName(StringRef Name) { … }
int MipsAsmParser::matchHWRegsRegisterName(StringRef Name) { … }
int MipsAsmParser::matchFPURegisterName(StringRef Name) { … }
int MipsAsmParser::matchFCCRegisterName(StringRef Name) { … }
int MipsAsmParser::matchACRegisterName(StringRef Name) { … }
int MipsAsmParser::matchMSA128RegisterName(StringRef Name) { … }
int MipsAsmParser::matchMSA128CtrlRegisterName(StringRef Name) { … }
bool MipsAsmParser::canUseATReg() { … }
unsigned MipsAsmParser::getATReg(SMLoc Loc) { … }
unsigned MipsAsmParser::getReg(int RC, int RegNo) { … }
bool MipsAsmParser::parseOperand(OperandVector &Operands, StringRef Mnemonic) { … }
bool MipsAsmParser::parseRegister(MCRegister &Reg, SMLoc &StartLoc,
SMLoc &EndLoc) { … }
ParseStatus MipsAsmParser::tryParseRegister(MCRegister &Reg, SMLoc &StartLoc,
SMLoc &EndLoc) { … }
bool MipsAsmParser::parseMemOffset(const MCExpr *&Res, bool isParenExpr) { … }
ParseStatus MipsAsmParser::parseMemOperand(OperandVector &Operands) { … }
bool MipsAsmParser::searchSymbolAlias(OperandVector &Operands) { … }
ParseStatus MipsAsmParser::matchAnyRegisterNameWithoutDollar(
OperandVector &Operands, StringRef Identifier, SMLoc S) { … }
ParseStatus
MipsAsmParser::matchAnyRegisterWithoutDollar(OperandVector &Operands,
const AsmToken &Token, SMLoc S) { … }
ParseStatus
MipsAsmParser::matchAnyRegisterWithoutDollar(OperandVector &Operands, SMLoc S) { … }
ParseStatus MipsAsmParser::parseAnyRegister(OperandVector &Operands) { … }
ParseStatus MipsAsmParser::parseJumpTarget(OperandVector &Operands) { … }
ParseStatus MipsAsmParser::parseInvNum(OperandVector &Operands) { … }
ParseStatus MipsAsmParser::parseRegisterList(OperandVector &Operands) { … }
bool MipsAsmParser::parseParenSuffix(StringRef Name, OperandVector &Operands) { … }
bool MipsAsmParser::parseBracketSuffix(StringRef Name,
OperandVector &Operands) { … }
static std::string MipsMnemonicSpellCheck(StringRef S, const FeatureBitset &FBS,
unsigned VariantID = 0);
bool MipsAsmParser::areEqualRegs(const MCParsedAsmOperand &Op1,
const MCParsedAsmOperand &Op2) const { … }
bool MipsAsmParser::parseInstruction(ParseInstructionInfo &Info, StringRef Name,
SMLoc NameLoc, OperandVector &Operands) { … }
bool MipsAsmParser::reportParseError(const Twine &ErrorMsg) { … }
bool MipsAsmParser::reportParseError(SMLoc Loc, const Twine &ErrorMsg) { … }
bool MipsAsmParser::parseSetNoAtDirective() { … }
bool MipsAsmParser::parseSetAtDirective() { … }
bool MipsAsmParser::parseSetReorderDirective() { … }
bool MipsAsmParser::parseSetNoReorderDirective() { … }
bool MipsAsmParser::parseSetMacroDirective() { … }
bool MipsAsmParser::parseSetNoMacroDirective() { … }
bool MipsAsmParser::parseSetMsaDirective() { … }
bool MipsAsmParser::parseSetNoMsaDirective() { … }
bool MipsAsmParser::parseSetNoDspDirective() { … }
bool MipsAsmParser::parseSetNoMips3DDirective() { … }
bool MipsAsmParser::parseSetMips16Directive() { … }
bool MipsAsmParser::parseSetNoMips16Directive() { … }
bool MipsAsmParser::parseSetFpDirective() { … }
bool MipsAsmParser::parseSetOddSPRegDirective() { … }
bool MipsAsmParser::parseSetNoOddSPRegDirective() { … }
bool MipsAsmParser::parseSetMtDirective() { … }
bool MipsAsmParser::parseSetNoMtDirective() { … }
bool MipsAsmParser::parseSetNoCRCDirective() { … }
bool MipsAsmParser::parseSetNoVirtDirective() { … }
bool MipsAsmParser::parseSetNoGINVDirective() { … }
bool MipsAsmParser::parseSetPopDirective() { … }
bool MipsAsmParser::parseSetPushDirective() { … }
bool MipsAsmParser::parseSetSoftFloatDirective() { … }
bool MipsAsmParser::parseSetHardFloatDirective() { … }
bool MipsAsmParser::parseSetAssignment() { … }
bool MipsAsmParser::parseSetMips0Directive() { … }
bool MipsAsmParser::parseSetArchDirective() { … }
bool MipsAsmParser::parseSetFeature(uint64_t Feature) { … }
bool MipsAsmParser::eatComma(StringRef ErrorStr) { … }
bool MipsAsmParser::isPicAndNotNxxAbi() { … }
bool MipsAsmParser::parseDirectiveCpAdd(SMLoc Loc) { … }
bool MipsAsmParser::parseDirectiveCpLoad(SMLoc Loc) { … }
bool MipsAsmParser::parseDirectiveCpLocal(SMLoc Loc) { … }
bool MipsAsmParser::parseDirectiveCpRestore(SMLoc Loc) { … }
bool MipsAsmParser::parseDirectiveCPSetup() { … }
bool MipsAsmParser::parseDirectiveCPReturn() { … }
bool MipsAsmParser::parseDirectiveNaN() { … }
bool MipsAsmParser::parseDirectiveSet() { … }
bool MipsAsmParser::parseDirectiveGpWord() { … }
bool MipsAsmParser::parseDirectiveGpDWord() { … }
bool MipsAsmParser::parseDirectiveDtpRelWord() { … }
bool MipsAsmParser::parseDirectiveDtpRelDWord() { … }
bool MipsAsmParser::parseDirectiveTpRelWord() { … }
bool MipsAsmParser::parseDirectiveTpRelDWord() { … }
bool MipsAsmParser::parseDirectiveOption() { … }
bool MipsAsmParser::parseInsnDirective() { … }
bool MipsAsmParser::parseRSectionDirective(StringRef Section) { … }
bool MipsAsmParser::parseSSectionDirective(StringRef Section, unsigned Type) { … }
bool MipsAsmParser::parseDirectiveModule() { … }
bool MipsAsmParser::parseDirectiveModuleFP() { … }
bool MipsAsmParser::parseFpABIValue(MipsABIFlagsSection::FpABIKind &FpABI,
StringRef Directive) { … }
bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) { … }
bool MipsAsmParser::parseInternalDirectiveReallowModule() { … }
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsAsmParser() { … }
#define GET_REGISTER_MATCHER
#define GET_MATCHER_IMPLEMENTATION
#define GET_MNEMONIC_SPELL_CHECKER
#include "MipsGenAsmMatcher.inc"
bool MipsAsmParser::mnemonicIsValid(StringRef Mnemonic, unsigned VariantID) { … }