61#define DEBUG_TYPE "mcasmparser" 
   66    "mwarn-missing-parenthesis",
 
   67    cl::desc(
"Warn for missing parenthesis around predicate registers"),
 
   70    "merror-missing-parenthesis",
 
   71    cl::desc(
"Error for missing parenthesis around predicate registers"),
 
   74    "mwarn-sign-mismatch",
 
   75    cl::desc(
"Warn for mismatching a signed and unsigned value"),
 
   78    "mwarn-noncontigious-register",
 
   81    "merror-noncontigious-register",
 
   82    cl::desc(
"Error for register names that aren't contigious"),
 
  100  MCAsmParser &getParser()
 const { 
return Parser; }
 
  101  MCAssembler *getAssembler()
 const {
 
  102    MCAssembler *Assembler = 
nullptr;
 
  104    if (!Parser.getStreamer().hasRawTextSupport()) {
 
  105      MCELFStreamer *MES = 
static_cast<MCELFStreamer *
>(&Parser.getStreamer());
 
  111  AsmLexer &getLexer()
 const { 
return Parser.getLexer(); }
 
  113  bool equalIsAsmAssignment()
 override { 
return false; }
 
  114  bool isLabel(AsmToken &Token) 
override;
 
  117  void Warning(SMLoc L, 
const Twine &Msg) { Parser.Warning(L, Msg); }
 
  118  bool Error(SMLoc L, 
const Twine &Msg) { 
return Parser.Error(L, Msg); }
 
  119  bool ParseDirectiveFalign(
unsigned Size, SMLoc L);
 
  121  bool parseRegister(MCRegister &
Reg, SMLoc &StartLoc, SMLoc &EndLoc) 
override;
 
  122  ParseStatus tryParseRegister(MCRegister &
Reg, SMLoc &StartLoc,
 
  123                               SMLoc &EndLoc) 
override;
 
  124  bool ParseDirectiveSubsection(SMLoc L);
 
  125  bool ParseDirectiveComm(
bool IsLocal, SMLoc L);
 
  127  bool parseDirectiveAttribute(SMLoc L);
 
  129  bool RegisterMatchesArch(MCRegister MatchNum) 
const;
 
  131  bool matchBundleOptions();
 
  132  bool handleNoncontigiousRegister(
bool Contigious, SMLoc &Loc);
 
  133  bool finishBundle(SMLoc IDLoc, MCStreamer &Out);
 
  134  void canonicalizeImmediates(MCInst &MCI);
 
  135  bool matchOneInstruction(MCInst &MCB, SMLoc IDLoc,
 
  137                           bool MatchingInlineAsm);
 
  138  void eatToEndOfPacket();
 
  139  bool matchAndEmitInstruction(SMLoc IDLoc, 
unsigned &Opcode,
 
  142                               bool MatchingInlineAsm) 
override;
 
  144  unsigned validateTargetOperandClass(MCParsedAsmOperand &
Op,
 
  145                                      unsigned Kind) 
override;
 
  146  bool OutOfRange(SMLoc IDLoc, 
long long Val, 
long long Max);
 
  147  int processInstruction(MCInst &Inst, 
OperandVector const &Operands,
 
  150  MCRegister matchRegister(StringRef Name);
 
  155#define GET_ASSEMBLER_HEADER 
  156#include "HexagonGenAsmMatcher.inc" 
  166    setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
 
  175      getTargetStreamer().emitTargetAttributes(*STI);
 
  183  bool parseExpression(MCExpr 
const *&Expr);
 
  185  bool parseInstruction(ParseInstructionInfo &
Info, StringRef Name,
 
  190  bool parseInstruction(ParseInstructionInfo &
Info, StringRef Name, AsmToken 
ID,
 
  193  bool ParseDirective(AsmToken DirectiveID) 
override;
 
  199  enum KindTy { Token, Immediate, Register } Kind;
 
  202  SMLoc StartLoc, EndLoc;
 
  223  HexagonOperand(KindTy K, MCContext &Context) : Kind(
K), Context(Context) {}
 
  226  HexagonOperand(
const HexagonOperand &o)
 
  227      : MCParsedAsmOperand(), Context(
o.Context) {
 
  229    StartLoc = 
o.StartLoc;
 
  245  SMLoc getStartLoc()
 const override { 
return StartLoc; }
 
  248  SMLoc getEndLoc()
 const override { 
return EndLoc; }
 
  250  MCRegister 
getReg()
 const override {
 
  251    assert(Kind == Register && 
"Invalid access!");
 
  255  const MCExpr *
getImm()
 const {
 
  256    assert(Kind == Immediate && 
"Invalid access!");
 
  260  bool isToken()
 const override { 
return Kind == Token; }
 
  261  bool isImm()
 const override { 
return Kind == Immediate; }
 
  263  bool isReg()
 const override { 
return Kind == Register; }
 
  265  bool CheckImmRange(
int immBits, 
int zeroBits, 
bool isSigned,
 
  266                     bool isRelocatable, 
bool Extendable)
 const {
 
  267    if (Kind == Immediate) {
 
  272      if (myMCExpr->evaluateAsAbsolute(Res)) {
 
  273        int bits = immBits + zeroBits;
 
  276        if (Res & ((1 << zeroBits) - 1))
 
  279          if (Res < (1LL << (bits - 1)) && Res >= -(1LL << (bits - 1)))
 
  285            return ((uint64_t)Res < (uint64_t)(1ULL << bits));
 
  287            const int64_t high_bit_set = 1ULL << 63;
 
  288            const uint64_t 
mask = (high_bit_set >> (63 - bits));
 
  289            return (((uint64_t)Res & 
mask) == 
mask);
 
  301  bool isa30_2Imm()
 const { 
return CheckImmRange(30, 2, 
true, 
true, 
true); }
 
  302  bool isb30_2Imm()
 const { 
return CheckImmRange(30, 2, 
true, 
true, 
true); }
 
  303  bool isb15_2Imm()
 const { 
return CheckImmRange(15, 2, 
true, 
true, 
false); }
 
  304  bool isb13_2Imm()
 const { 
return CheckImmRange(13, 2, 
true, 
true, 
false); }
 
  306  bool ism32_0Imm()
 const { 
return true; }
 
  308  bool isf32Imm()
 const { 
return false; }
 
  309  bool isf64Imm()
 const { 
return false; }
 
  310  bool iss32_0Imm()
 const { 
return true; }
 
  311  bool iss31_1Imm()
 const { 
return true; }
 
  312  bool iss30_2Imm()
 const { 
return true; }
 
  313  bool iss29_3Imm()
 const { 
return true; }
 
  314  bool iss27_2Imm()
 const { 
return CheckImmRange(27, 2, 
true, 
true, 
false); }
 
  315  bool iss10_0Imm()
 const { 
return CheckImmRange(10, 0, 
true, 
false, 
false); }
 
  316  bool iss10_6Imm()
 const { 
return CheckImmRange(10, 6, 
true, 
false, 
false); }
 
  317  bool iss9_0Imm()
 const { 
return CheckImmRange(9, 0, 
true, 
false, 
false); }
 
  318  bool iss8_0Imm()
 const { 
return CheckImmRange(8, 0, 
true, 
false, 
false); }
 
  319  bool iss8_0Imm64()
 const { 
return CheckImmRange(8, 0, 
true, 
true, 
false); }
 
  320  bool iss7_0Imm()
 const { 
return CheckImmRange(7, 0, 
true, 
false, 
false); }
 
  321  bool iss6_0Imm()
 const { 
return CheckImmRange(6, 0, 
true, 
false, 
false); }
 
  322  bool iss6_3Imm()
 const { 
return CheckImmRange(6, 3, 
true, 
false, 
false); }
 
  323  bool iss4_0Imm()
 const { 
return CheckImmRange(4, 0, 
true, 
false, 
false); }
 
  324  bool iss4_1Imm()
 const { 
return CheckImmRange(4, 1, 
true, 
false, 
false); }
 
  325  bool iss4_2Imm()
 const { 
return CheckImmRange(4, 2, 
true, 
false, 
false); }
 
  326  bool iss4_3Imm()
 const { 
return CheckImmRange(4, 3, 
true, 
false, 
false); }
 
  327  bool iss3_0Imm()
 const { 
return CheckImmRange(3, 0, 
true, 
false, 
false); }
 
  329  bool isu64_0Imm()
 const { 
return CheckImmRange(64, 0, 
false, 
true, 
true); }
 
  330  bool isu32_0Imm()
 const { 
return true; }
 
  331  bool isu31_1Imm()
 const { 
return true; }
 
  332  bool isu30_2Imm()
 const { 
return true; }
 
  333  bool isu29_3Imm()
 const { 
return true; }
 
  334  bool isu26_6Imm()
 const { 
return CheckImmRange(26, 6, 
false, 
true, 
false); }
 
  335  bool isu16_0Imm()
 const { 
return CheckImmRange(16, 0, 
false, 
true, 
false); }
 
  336  bool isu16_1Imm()
 const { 
return CheckImmRange(16, 1, 
false, 
true, 
false); }
 
  337  bool isu16_2Imm()
 const { 
return CheckImmRange(16, 2, 
false, 
true, 
false); }
 
  338  bool isu16_3Imm()
 const { 
return CheckImmRange(16, 3, 
false, 
true, 
false); }
 
  339  bool isu11_3Imm()
 const { 
return CheckImmRange(11, 3, 
false, 
false, 
false); }
 
  340  bool isu10_0Imm()
 const { 
return CheckImmRange(10, 0, 
false, 
false, 
false); }
 
  341  bool isu9_0Imm()
 const { 
return CheckImmRange(9, 0, 
false, 
false, 
false); }
 
  342  bool isu8_0Imm()
 const { 
return CheckImmRange(8, 0, 
false, 
false, 
false); }
 
  343  bool isu7_0Imm()
 const { 
return CheckImmRange(7, 0, 
false, 
false, 
false); }
 
  344  bool isu6_0Imm()
 const { 
return CheckImmRange(6, 0, 
false, 
false, 
false); }
 
  345  bool isu6_1Imm()
 const { 
return CheckImmRange(6, 1, 
false, 
false, 
false); }
 
  346  bool isu6_2Imm()
 const { 
return CheckImmRange(6, 2, 
false, 
false, 
false); }
 
  347  bool isu6_3Imm()
 const { 
return CheckImmRange(6, 3, 
false, 
false, 
false); }
 
  348  bool isu5_0Imm()
 const { 
return CheckImmRange(5, 0, 
false, 
false, 
false); }
 
  349  bool isu5_2Imm()
 const { 
return CheckImmRange(5, 2, 
false, 
false, 
false); }
 
  350  bool isu5_3Imm()
 const { 
return CheckImmRange(5, 3, 
false, 
false, 
false); }
 
  351  bool isu4_0Imm()
 const { 
return CheckImmRange(4, 0, 
false, 
false, 
false); }
 
  352  bool isu4_2Imm()
 const { 
return CheckImmRange(4, 2, 
false, 
false, 
false); }
 
  353  bool isu3_0Imm()
 const { 
return CheckImmRange(3, 0, 
false, 
false, 
false); }
 
  354  bool isu3_1Imm()
 const { 
return CheckImmRange(3, 1, 
false, 
false, 
false); }
 
  355  bool isu2_0Imm()
 const { 
return CheckImmRange(2, 0, 
false, 
false, 
false); }
 
  356  bool isu1_0Imm()
 const { 
return CheckImmRange(1, 0, 
false, 
false, 
false); }
 
  358  bool isn1Const()
 const {
 
  366  bool issgp10Const()
 const {
 
  369    return getReg() == Hexagon::SGP1_0;
 
  371  bool iss11_0Imm()
 const {
 
  372    return CheckImmRange(11 + 26, 0, 
true, 
true, 
true);
 
  374  bool iss11_1Imm()
 const {
 
  375    return CheckImmRange(11 + 26, 1, 
true, 
true, 
true);
 
  377  bool iss11_2Imm()
 const {
 
  378    return CheckImmRange(11 + 26, 2, 
true, 
true, 
true);
 
  380  bool iss11_3Imm()
 const {
 
  381    return CheckImmRange(11 + 26, 3, 
true, 
true, 
true);
 
  383  bool isu32_0MustExt()
 const { 
return isImm(); }
 
  385  void addRegOperands(MCInst &Inst, 
unsigned N)
 const {
 
  386    assert(
N == 1 && 
"Invalid number of operands!");
 
  390  void addImmOperands(MCInst &Inst, 
unsigned N)
 const {
 
  391    assert(
N == 1 && 
"Invalid number of operands!");
 
  395  void addSignedImmOperands(MCInst &Inst, 
unsigned N)
 const {
 
  396    assert(
N == 1 && 
"Invalid number of operands!");
 
  397    HexagonMCExpr *Expr =
 
  407    if ((Extended < 0) != (
Value < 0))
 
  414  void addn1ConstOperands(MCInst &Inst, 
unsigned N)
 const {
 
  415    addImmOperands(Inst, 
N);
 
  417  void addsgp10ConstOperands(MCInst &Inst, 
unsigned N)
 const {
 
  418    addRegOperands(Inst, 
N);
 
  422    assert(Kind == Token && 
"Invalid access!");
 
  423    return StringRef(Tok.Data, Tok.Length);
 
  426  void print(raw_ostream &OS, 
const MCAsmInfo &MAI) 
const override;
 
  428  static std::unique_ptr<HexagonOperand> CreateToken(MCContext &Context,
 
  429                                                     StringRef Str, SMLoc S) {
 
  430    HexagonOperand *
Op = 
new HexagonOperand(Token, Context);
 
  431    Op->Tok.Data = Str.data();
 
  432    Op->Tok.Length = Str.size();
 
  435    return std::unique_ptr<HexagonOperand>(
Op);
 
  438  static std::unique_ptr<HexagonOperand>
 
  439  CreateReg(MCContext &Context, MCRegister 
Reg, SMLoc S, SMLoc 
E) {
 
  440    HexagonOperand *
Op = 
new HexagonOperand(Register, Context);
 
  441    Op->Reg.RegNum = 
Reg;
 
  444    return std::unique_ptr<HexagonOperand>(
Op);
 
  447  static std::unique_ptr<HexagonOperand>
 
  448  CreateImm(MCContext &Context, 
const MCExpr *Val, SMLoc S, SMLoc 
E) {
 
  449    HexagonOperand *
Op = 
new HexagonOperand(Immediate, Context);
 
  453    return std::unique_ptr<HexagonOperand>(
Op);
 
  462    HexagonMCAsmInfo(Triple()).printExpr(OS, *
getImm());
 
  474bool HexagonAsmParser::finishBundle(SMLoc IDLoc, MCStreamer &Out) {
 
  482  const MCRegisterInfo *RI = 
getContext().getRegisterInfo();
 
  483  MCSubtargetInfo 
const &STI = getSTI();
 
  485  MCInst OrigBundle = MCB;
 
  508bool HexagonAsmParser::matchBundleOptions() {
 
  509  MCAsmParser &Parser = getParser();
 
  514    char const *MemNoShuffMsg =
 
  515        "invalid instruction packet: mem_noshuf specifier not " 
  516        "supported with this architecture";
 
  519    if (
Option.compare_insensitive(
"endloop01") == 0) {
 
  522    } 
else if (
Option.compare_insensitive(
"endloop0") == 0) {
 
  524    } 
else if (
Option.compare_insensitive(
"endloop1") == 0) {
 
  526    } 
else if (
Option.compare_insensitive(
"mem_noshuf") == 0) {
 
  527      if (getSTI().hasFeature(Hexagon::FeatureMemNoShuf))
 
  530        return getParser().Error(IDLoc, MemNoShuffMsg);
 
  531    } 
else if (
Option.compare_insensitive(
"mem_no_order") == 0) {
 
  534      return getParser().Error(IDLoc, llvm::Twine(
"'") + Option +
 
  535                                          "' is not a valid bundle option");
 
  543void HexagonAsmParser::canonicalizeImmediates(MCInst &MCI) {
 
  546  for (MCOperand &
I : MCI)
 
  548      int64_t 
Value(
I.getImm());
 
  554        Warning(MCI.getLoc(), 
"Signed/Unsigned mismatch");
 
  560bool HexagonAsmParser::matchOneInstruction(MCInst &MCI, SMLoc IDLoc,
 
  563                                           bool MatchingInlineAsm) {
 
  566      MatchInstructionImpl(InstOperands, MCI, ErrorInfo, MatchingInlineAsm);
 
  567  if (result == Match_Success) {
 
  569    canonicalizeImmediates(MCI);
 
  570    result = processInstruction(MCI, InstOperands, IDLoc);
 
  588  case Match_MissingFeature:
 
  589    return Error(IDLoc, 
"invalid instruction");
 
  590  case Match_MnemonicFail:
 
  591    return Error(IDLoc, 
"unrecognized instruction");
 
  592  case Match_InvalidOperand:
 
  594  case Match_InvalidTiedOperand:
 
  595    SMLoc ErrorLoc = IDLoc;
 
  596    if (ErrorInfo != ~0U) {
 
  597      if (ErrorInfo >= InstOperands.
size())
 
  598        return Error(IDLoc, 
"too few operands for instruction");
 
  600      ErrorLoc = (
static_cast<HexagonOperand *
>(InstOperands[ErrorInfo].get()))
 
  602      if (ErrorLoc == SMLoc())
 
  605    return Error(ErrorLoc, 
"invalid operand for instruction");
 
  610void HexagonAsmParser::eatToEndOfPacket() {
 
  612  AsmLexer &Lexer = getLexer();
 
  619bool HexagonAsmParser::matchAndEmitInstruction(SMLoc IDLoc, 
unsigned &Opcode,
 
  623                                               bool MatchingInlineAsm) {
 
  628  HexagonOperand &FirstOperand = 
static_cast<HexagonOperand &
>(*Operands[0]);
 
  629  if (FirstOperand.isToken() && FirstOperand.getToken() == 
"{") {
 
  630    assert(Operands.
size() == 1 && 
"Brackets should be by themselves");
 
  632      getParser().Error(IDLoc, 
"Already in a packet");
 
  639  if (FirstOperand.isToken() && FirstOperand.getToken() == 
"}") {
 
  640    assert(Operands.
size() == 1 && 
"Brackets should be by themselves");
 
  642      getParser().Error(IDLoc, 
"Not in a packet");
 
  646    if (matchBundleOptions())
 
  648    return finishBundle(IDLoc, Out);
 
  650  MCInst *SubInst = getParser().getContext().createMCInst();
 
  651  if (matchOneInstruction(*SubInst, IDLoc, Operands, ErrorInfo,
 
  652                          MatchingInlineAsm)) {
 
  658      getParser().
getContext(), MII, MCB, *SubInst);
 
  661    return finishBundle(IDLoc, Out);
 
  667bool HexagonAsmParser::parseDirectiveAttribute(SMLoc L) {
 
  668  MCAsmParser &Parser = getParser();
 
  676      return Error(TagLoc, 
"attribute name not recognized: " + Name);
 
  680    const MCExpr *AttrExpr;
 
  687    if (check(!CE, TagLoc, 
"expected numeric constant"))
 
  690    Tag = 
CE->getValue();
 
  697  int64_t IntegerValue = 0;
 
  699  const MCExpr *ValueExpr;
 
  705    return Error(ValueExprLoc, 
"expected numeric constant");
 
  706  IntegerValue = 
CE->getValue();
 
  711  getTargetStreamer().emitAttribute(
Tag, IntegerValue);
 
  716bool HexagonAsmParser::ParseDirective(AsmToken DirectiveID) {
 
  718  if (IDVal.
lower() == 
".falign")
 
  719    return ParseDirectiveFalign(256, DirectiveID.
getLoc());
 
  720  if ((IDVal.
lower() == 
".lcomm") || (IDVal.
lower() == 
".lcommon"))
 
  721    return ParseDirectiveComm(
true, DirectiveID.
getLoc());
 
  722  if ((IDVal.
lower() == 
".comm") || (IDVal.
lower() == 
".common"))
 
  723    return ParseDirectiveComm(
false, DirectiveID.
getLoc());
 
  724  if (IDVal.
lower() == 
".subsection")
 
  725    return ParseDirectiveSubsection(DirectiveID.
getLoc());
 
  726  if (IDVal == 
".attribute")
 
  727    return parseDirectiveAttribute(DirectiveID.
getLoc());
 
  731bool HexagonAsmParser::ParseDirectiveSubsection(SMLoc L) {
 
  732  const MCExpr *Subsection = 
nullptr;
 
  736         "Invalid subsection directive");
 
  737  getParser().parseExpression(Subsection);
 
  739  if (!Subsection->evaluateAsAbsolute(Res))
 
  740    return Error(L, 
"Cannot evaluate subsection number");
 
  743    return TokError(
"unexpected token in directive");
 
  749  if ((Res < 0) && (Res > -8193))
 
  751  getStreamer().switchSection(getStreamer().getCurrentSectionOnly(), Res);
 
  756bool HexagonAsmParser::ParseDirectiveFalign(
unsigned Size, SMLoc L) {
 
  758  int64_t MaxBytesToFill = 15;
 
  766    if (!getParser().parseExpression(
Value)) {
 
  769      uint64_t IntValue = MCE->getValue();
 
  771        return Error(ExprLoc, 
"literal value out of range (256) for falign");
 
  772      MaxBytesToFill = IntValue;
 
  775      return Error(ExprLoc, 
"not a valid expression for falign directive");
 
  779  getTargetStreamer().emitFAlign(16, MaxBytesToFill);
 
  791bool HexagonAsmParser::ParseDirectiveComm(
bool IsLocal, SMLoc Loc) {
 
  794  if (getStreamer().hasRawTextSupport())
 
  798  if (getParser().parseIdentifier(Name))
 
  799    return TokError(
"expected identifier in directive");
 
  804    return TokError(
"unexpected token in directive");
 
  808  SMLoc SizeLoc = getLexer().getLoc();
 
  809  if (getParser().parseAbsoluteExpression(
Size))
 
  813  SMLoc ByteAlignmentLoc;
 
  816    ByteAlignmentLoc = getLexer().getLoc();
 
  817    if (getParser().parseAbsoluteExpression(ByteAlignment))
 
  820      return Error(ByteAlignmentLoc, 
"alignment must be a power of 2");
 
  823  int64_t AccessAlignment = 0;
 
  827    SMLoc AccessAlignmentLoc;
 
  829    AccessAlignmentLoc = getLexer().getLoc();
 
  830    if (getParser().parseAbsoluteExpression(AccessAlignment))
 
  834      return Error(AccessAlignmentLoc, 
"access alignment must be a power of 2");
 
  838    return TokError(
"unexpected token in '.comm' or '.lcomm' directive");
 
  845    return Error(SizeLoc, 
"invalid '.comm' or '.lcomm' directive size, can't " 
  846                          "be less than zero");
 
  851  if (ByteAlignment < 0)
 
  852    return Error(ByteAlignmentLoc, 
"invalid '.comm' or '.lcomm' directive " 
  853                                   "alignment, can't be less than zero");
 
  856    return Error(Loc, 
"invalid symbol redefinition");
 
  858  HexagonMCELFStreamer &HexagonELFStreamer =
 
  859      static_cast<HexagonMCELFStreamer &
>(getStreamer());
 
  862        Sym, 
Size, 
Align(ByteAlignment), AccessAlignment);
 
  872bool HexagonAsmParser::RegisterMatchesArch(MCRegister MatchNum)
 const {
 
  873  if (HexagonMCRegisterClasses[Hexagon::V62RegsRegClassID].
contains(MatchNum))
 
  874    if (!getSTI().hasFeature(Hexagon::ArchV62))
 
  887#define GET_MATCHER_IMPLEMENTATION 
  888#define GET_REGISTER_MATCHER 
  889#include "HexagonGenAsmMatcher.inc" 
  893  if (Index >= Operands.
size())
 
  898  return static_cast<HexagonOperand &
>(Operand).
getToken().equals_insensitive(
 
 
  910bool HexagonAsmParser::splitIdentifier(
OperandVector &Operands) {
 
  911  AsmToken 
const &Token = getParser().getTok();
 
  913  SMLoc Loc = Token.
getLoc();
 
  916    std::pair<StringRef, StringRef> HeadTail = 
String.split(
'.');
 
  917    if (!HeadTail.first.empty())
 
  919          HexagonOperand::CreateToken(
getContext(), HeadTail.first, Loc));
 
  920    if (!HeadTail.second.empty())
 
  921      Operands.
push_back(HexagonOperand::CreateToken(
 
  924  } 
while (!
String.empty());
 
  928bool HexagonAsmParser::parseOperand(
OperandVector &Operands) {
 
  932  AsmLexer &Lexer = getLexer();
 
  933  if (!parseRegister(
Register, Begin, End)) {
 
  944            Warning(Begin, 
"Missing parenthesis around predicate register");
 
  945          static char const *LParen = 
"(";
 
  946          static char const *RParen = 
")";
 
  948              HexagonOperand::CreateToken(
getContext(), LParen, Begin));
 
  951          const AsmToken &MaybeDotNew = Lexer.
getTok();
 
  952          if (MaybeDotNew.
is(AsmToken::TokenKind::Identifier) &&
 
  954            splitIdentifier(Operands);
 
  956              HexagonOperand::CreateToken(
getContext(), RParen, Begin));
 
  962            Warning(Begin, 
"Missing parenthesis around predicate register");
 
  963          static char const *LParen = 
"(";
 
  964          static char const *RParen = 
")";
 
  965          Operands.
insert(Operands.
end() - 1, HexagonOperand::CreateToken(
 
  969          const AsmToken &MaybeDotNew = Lexer.
getTok();
 
  970          if (MaybeDotNew.
is(AsmToken::TokenKind::Identifier) &&
 
  972            splitIdentifier(Operands);
 
  974              HexagonOperand::CreateToken(
getContext(), RParen, Begin));
 
  983  return splitIdentifier(Operands);
 
  986bool HexagonAsmParser::isLabel(AsmToken &Token) {
 
  987  AsmLexer &Lexer = getLexer();
 
  988  AsmToken 
const &Second = Lexer.
getTok();
 
  989  AsmToken Third = Lexer.
peekTok();
 
  991  if (Token.
is(AsmToken::TokenKind::LCurly) ||
 
  992      Token.
is(AsmToken::TokenKind::RCurly))
 
  998  if (!Token.
is(AsmToken::TokenKind::Identifier))
 
 1000  if (!matchRegister(
String.lower()))
 
 1005  std::string Collapsed = std::string(Raw);
 
 1007  StringRef Whole = Collapsed;
 
 1008  std::pair<StringRef, StringRef> DotSplit = Whole.
split(
'.');
 
 1009  if (!matchRegister(DotSplit.first.lower()))
 
 1018bool HexagonAsmParser::handleNoncontigiousRegister(
bool Contigious,
 
 1021    Error(Loc, 
"Register name is not contigious");
 
 1025    Warning(Loc, 
"Register name is not contigious");
 
 1029bool HexagonAsmParser::parseRegister(MCRegister &
Reg, SMLoc &StartLoc,
 
 1031  return !tryParseRegister(
Reg, StartLoc, EndLoc).isSuccess();
 
 1034ParseStatus HexagonAsmParser::tryParseRegister(MCRegister &
Reg, SMLoc &StartLoc,
 
 1036  AsmLexer &Lexer = getLexer();
 
 1037  StartLoc = getLexer().getLoc();
 
 1041  bool NeededWorkaround = 
false;
 
 1043    AsmToken 
const &Token = Lexer.
getTok();
 
 1044    RawString = StringRef(RawString.data(), Token.
getString().
data() -
 
 1050                      Lookahead.
back().getString().data() +
 
 1051                          Lookahead.
back().getString().size();
 
 1057    Again = (Contigious && 
Type) || (Workaround && 
Type);
 
 1058    NeededWorkaround = NeededWorkaround || (Again && !(Contigious && 
Type));
 
 1060  std::string Collapsed = std::string(RawString);
 
 1062  StringRef FullString = Collapsed;
 
 1063  std::pair<StringRef, StringRef> DotSplit = FullString.
split(
'.');
 
 1064  MCRegister DotReg = matchRegister(DotSplit.first.lower());
 
 1065  if (DotReg && RegisterMatchesArch(DotReg)) {
 
 1066    if (DotSplit.second.empty()) {
 
 1069      if (handleNoncontigiousRegister(!NeededWorkaround, StartLoc))
 
 1074      size_t First = RawString.find(
'.');
 
 1075      StringRef DotString (RawString.data() + 
First, RawString.size() - 
First);
 
 1078      if (handleNoncontigiousRegister(!NeededWorkaround, StartLoc))
 
 1083  std::pair<StringRef, StringRef> ColonSplit = StringRef(FullString).split(
':');
 
 1084  MCRegister ColonReg = matchRegister(ColonSplit.first.lower());
 
 1085  if (ColonReg && RegisterMatchesArch(DotReg)) {
 
 1091    if (handleNoncontigiousRegister(!NeededWorkaround, StartLoc))
 
 1095  while (!Lookahead.
empty()) {
 
 1101bool HexagonAsmParser::implicitExpressionLocation(
OperandVector &Operands) {
 
 1115bool HexagonAsmParser::parseExpression(MCExpr 
const *&Expr) {
 
 1117  AsmLexer &Lexer = getLexer();
 
 1119  static char const *
Comma = 
",";
 
 1123    switch (Tokens.
back().getKind()) {
 
 1124    case AsmToken::TokenKind::Hash:
 
 1125      if (Tokens.
size() > 1)
 
 1126        if ((Tokens.
end() - 2)->getKind() == AsmToken::TokenKind::Plus) {
 
 1128                        AsmToken(AsmToken::TokenKind::Comma, Comma));
 
 1132    case AsmToken::TokenKind::RCurly:
 
 1133    case AsmToken::TokenKind::EndOfStatement:
 
 1134    case AsmToken::TokenKind::Eof:
 
 1141  while (!Tokens.
empty()) {
 
 1145  SMLoc Loc = Lexer.
getLoc();
 
 1146  return getParser().parseExpression(Expr, Loc);
 
 1149bool HexagonAsmParser::parseExpressionOrOperand(
OperandVector &Operands) {
 
 1150  if (implicitExpressionLocation(Operands)) {
 
 1151    MCAsmParser &Parser = getParser();
 
 1153    MCExpr 
const *Expr = 
nullptr;
 
 1154    bool Error = parseExpression(Expr);
 
 1158          HexagonOperand::CreateImm(
getContext(), Expr, Loc, Loc));
 
 1161  return parseOperand(Operands);
 
 1165bool HexagonAsmParser::parseInstruction(
OperandVector &Operands) {
 
 1166  MCAsmParser &Parser = getParser();
 
 1167  AsmLexer &Lexer = getLexer();
 
 1169    AsmToken 
const &Token = Parser.
getTok();
 
 1177      if (!Operands.
empty())
 
 1179      Operands.
push_back(HexagonOperand::CreateToken(
 
 1185      if (Operands.
empty()) {
 
 1186        Operands.
push_back(HexagonOperand::CreateToken(
 
 1202      Operands.
push_back(HexagonOperand::CreateToken(
 
 1204      Operands.
push_back(HexagonOperand::CreateToken(
 
 1210      bool MustNotExtend = 
false;
 
 1211      bool ImplicitExpression = implicitExpressionLocation(Operands);
 
 1212      SMLoc ExprLoc = Lexer.
getLoc();
 
 1213      if (!ImplicitExpression)
 
 1214        Operands.
push_back(HexagonOperand::CreateToken(
 
 1217      bool MustExtend = 
false;
 
 1218      bool HiOnly = 
false;
 
 1219      bool LoOnly = 
false;
 
 1223      } 
else if (ImplicitExpression)
 
 1224        MustNotExtend = 
true;
 
 1225      AsmToken 
const &Token = Parser.
getTok();
 
 1228        if (
String.lower() == 
"hi") {
 
 1230        } 
else if (
String.lower() == 
"lo") {
 
 1233        if (HiOnly || LoOnly) {
 
 1234          AsmToken LParen = Lexer.
peekTok();
 
 1243      MCExpr 
const *Expr = 
nullptr;
 
 1244      if (parseExpression(Expr))
 
 1249      if (Expr->evaluateAsAbsolute(
Value)) {
 
 1253        if (HiOnly || LoOnly)
 
 1259          if (!
Value.isAbsolute()) {
 
 1264              MustNotExtend = !MustExtend;
 
 1275      std::unique_ptr<HexagonOperand> Operand =
 
 1276          HexagonOperand::CreateImm(
getContext(), Expr, ExprLoc, ExprLoc);
 
 1283    if (parseExpressionOrOperand(Operands))
 
 1288bool HexagonAsmParser::parseInstruction(ParseInstructionInfo &
Info,
 
 1289                                        StringRef Name, AsmToken 
ID,
 
 1291  getLexer().UnLex(
ID);
 
 1292  return parseInstruction(Operands);
 
 1308unsigned HexagonAsmParser::validateTargetOperandClass(MCParsedAsmOperand &AsmOp,
 
 1310  HexagonOperand *
Op = 
static_cast<HexagonOperand *
>(&AsmOp);
 
 1315    return Op->isImm() && 
Op->Imm.Val->evaluateAsAbsolute(
Value) && 
Value == 0
 
 1317               : Match_InvalidOperand;
 
 1321    return Op->isImm() && 
Op->Imm.Val->evaluateAsAbsolute(
Value) && 
Value == 1
 
 1323               : Match_InvalidOperand;
 
 1326  if (
Op->Kind == HexagonOperand::Token && Kind != InvalidMatchClass) {
 
 1327    StringRef myStringRef = StringRef(
Op->Tok.Data, 
Op->Tok.Length);
 
 1328    if (matchTokenString(myStringRef.
lower()) == (MatchClassKind)Kind)
 
 1329      return Match_Success;
 
 1330    if (matchTokenString(myStringRef.
upper()) == (MatchClassKind)Kind)
 
 1331      return Match_Success;
 
 1338  return Match_InvalidOperand;
 
 1342bool HexagonAsmParser::OutOfRange(SMLoc IDLoc, 
long long Val, 
long long Max) {
 
 1344  raw_string_ostream ES(errStr);
 
 1345  ES << 
"value " << Val << 
"(" << 
format_hex(Val, 0) << 
") out of range: ";
 
 1349    ES << 
Max << 
"-" << (-
Max - 1);
 
 1353int HexagonAsmParser::processInstruction(MCInst &Inst,
 
 1356  MCContext &
Context = getParser().getContext();
 
 1357  const MCRegisterInfo *RI = 
getContext().getRegisterInfo();
 
 1358  const std::string r = 
"r";
 
 1359  const std::string Colon = 
":";
 
 1360  using RegPairVals = std::pair<unsigned, unsigned>;
 
 1361  auto GetRegPair = [
this, r](RegPairVals RegPair) {
 
 1362    const std::string R1 = r + 
utostr(RegPair.first);
 
 1363    const std::string 
R2 = r + 
utostr(RegPair.second);
 
 1365    return std::make_pair(matchRegister(R1), matchRegister(
R2));
 
 1367  auto GetScalarRegs = [RI, GetRegPair](MCRegister RegPair) {
 
 1369    const RegPairVals RegPair_ = std::make_pair(
Lower + 1, 
Lower);
 
 1371    return GetRegPair(RegPair_);
 
 1373  auto GetVecRegs = [GetRegPair](MCRegister VecRegPair) {
 
 1374    const RegPairVals RegPair =
 
 1377    return GetRegPair(RegPair);
 
 1380  bool is32bit = 
false; 
 
 1384      SMDiagnostic Diag = getSourceManager().GetMessage(
 
 1386          "Found pseudo instruction with no expansion");
 
 1392  case Hexagon::J2_trap1:
 
 1393    if (!getSTI().hasFeature(Hexagon::ArchV65)) {
 
 1396      if (Rx.
getReg() != Hexagon::R0 || Ry.
getReg() != Hexagon::R0) {
 
 1397        Error(IDLoc, 
"trap1 can only have register r0 as operand");
 
 1398        return Match_InvalidOperand;
 
 1403  case Hexagon::A2_iconst: {
 
 1415  case Hexagon::M4_mpyrr_addr:
 
 1416  case Hexagon::S4_addi_asl_ri:
 
 1417  case Hexagon::S4_addi_lsr_ri:
 
 1418  case Hexagon::S4_andi_asl_ri:
 
 1419  case Hexagon::S4_andi_lsr_ri:
 
 1420  case Hexagon::S4_ori_asl_ri:
 
 1421  case Hexagon::S4_ori_lsr_ri:
 
 1422  case Hexagon::S4_or_andix:
 
 1423  case Hexagon::S4_subi_asl_ri:
 
 1424  case Hexagon::S4_subi_lsr_ri: {
 
 1428      return Match_InvalidOperand;
 
 1432  case Hexagon::C2_cmpgei: {
 
 1442  case Hexagon::C2_cmpgeui: {
 
 1468  case Hexagon::A2_tfrp: {
 
 1470    const std::pair<MCRegister, MCRegister> RegPair =
 
 1471        GetScalarRegs(MO.
getReg());
 
 1472    MO.
setReg(RegPair.first);
 
 1478  case Hexagon::A2_tfrpt:
 
 1479  case Hexagon::A2_tfrpf: {
 
 1481    const std::pair<MCRegister, MCRegister> RegPair =
 
 1482        GetScalarRegs(MO.
getReg());
 
 1483    MO.
setReg(RegPair.first);
 
 1486                       ? Hexagon::C2_ccombinewt
 
 1487                       : Hexagon::C2_ccombinewf);
 
 1490  case Hexagon::A2_tfrptnew:
 
 1491  case Hexagon::A2_tfrpfnew: {
 
 1493    const std::pair<MCRegister, MCRegister> RegPair =
 
 1494        GetScalarRegs(MO.
getReg());
 
 1495    MO.
setReg(RegPair.first);
 
 1498                       ? Hexagon::C2_ccombinewnewt
 
 1499                       : Hexagon::C2_ccombinewnewf);
 
 1504  case Hexagon::V6_vassignp: {
 
 1506    const std::pair<MCRegister, MCRegister> RegPair = GetVecRegs(MO.
getReg());
 
 1507    MO.
setReg(RegPair.first);
 
 1514  case Hexagon::CONST32:
 
 1518  case Hexagon::CONST64:
 
 1521      MCELFStreamer *MES = 
static_cast<MCELFStreamer *
>(&Parser.
getStreamer());
 
 1528      std::string myCharStr;
 
 1529      MCSectionELF *mySection;
 
 1539          myCharStr = StringRef(
".gnu.linkonce.l4.CONST_00000000")
 
 1540                          .drop_back(myImmStr.size())
 
 1545          myCharStr = StringRef(
".gnu.linkonce.l8.CONST_0000000000000000")
 
 1546                          .drop_back(myImmStr.size())
 
 1553      } 
else if (MO_1.
isExpr()) {
 
 1555        myCharStr = 
".lita";
 
 1562      unsigned byteSize = is32bit ? 4 : 8;
 
 1571        Sym = 
getContext().getOrCreateSymbol(StringRef(myCharStr.c_str() + 16));
 
 1573          getStreamer().emitLabel(Sym);
 
 1574          getStreamer().emitSymbolAttribute(Sym, 
MCSA_Global);
 
 1577      } 
else if (MO_1.
isExpr()) {
 
 1578        const char *StringStart = 
nullptr;
 
 1579        const char *StringEnd = 
nullptr;
 
 1580        if (*Operands[4]->getStartLoc().
getPointer() == 
'#') {
 
 1581          StringStart = Operands[5]->getStartLoc().getPointer();
 
 1582          StringEnd = Operands[6]->getStartLoc().getPointer();
 
 1584          StringStart = Operands[4]->getStartLoc().getPointer();
 
 1585          StringEnd = Operands[5]->getStartLoc().getPointer();
 
 1588        unsigned size = StringEnd - StringStart;
 
 1589        std::string DotConst = 
".CONST_";
 
 1590        Sym = 
getContext().getOrCreateSymbol(DotConst +
 
 1591                                             StringRef(StringStart, 
size));
 
 1595          getStreamer().emitLabel(Sym);
 
 1596          getStreamer().emitSymbolAttribute(Sym, 
MCSA_Local);
 
 1597          getStreamer().emitValue(MO_1.
getExpr(), 4);
 
 1607          TmpInst.
setOpcode(Hexagon::L2_loadrigp);
 
 1609          TmpInst.
setOpcode(Hexagon::L2_loadrdgp);
 
 1620  case Hexagon::A2_tfrpi: {
 
 1632  case Hexagon::TFRI64_V4: {
 
 1639        OutOfRange(IDLoc, s8, -128);
 
 1657  case Hexagon::TFRI64_V2_ext: {
 
 1664      if (s8 < -128 || s8 > 127)
 
 1665        OutOfRange(IDLoc, s8, -128);
 
 1672  case Hexagon::A4_combineii: {
 
 1678      if (s8 < -128 || s8 > 127)
 
 1679        OutOfRange(IDLoc, s8, -128);
 
 1686  case Hexagon::S2_tableidxb_goodsyntax:
 
 1690  case Hexagon::S2_tableidxh_goodsyntax: {
 
 1700    TmpInst.
setOpcode(Hexagon::S2_tableidxh);
 
 1710  case Hexagon::S2_tableidxw_goodsyntax: {
 
 1720    TmpInst.
setOpcode(Hexagon::S2_tableidxw);
 
 1730  case Hexagon::S2_tableidxd_goodsyntax: {
 
 1740    TmpInst.
setOpcode(Hexagon::S2_tableidxd);
 
 1750  case Hexagon::M2_mpyui:
 
 1753  case Hexagon::M2_mpysmi: {
 
 1759    MCExpr 
const &Expr = *
Imm.getExpr();
 
 1762      return Match_InvalidOperand;
 
 1765      return Match_InvalidOperand;
 
 1779  case Hexagon::S2_asr_i_r_rnd_goodsyntax: {
 
 1785      return Match_InvalidOperand;
 
 1797      TmpInst.
setOpcode(Hexagon::S2_asr_i_r_rnd);
 
 1808  case Hexagon::S2_asr_i_p_rnd_goodsyntax: {
 
 1815      return Match_InvalidOperand;
 
 1819      std::string R1 = r + 
utostr(RegPairNum + 1);
 
 1821      Rss.
setReg(matchRegister(Reg1));
 
 1823      std::string 
R2 = r + 
utostr(RegPairNum);
 
 1825      TmpInst.
setOpcode(Hexagon::A2_combinew);
 
 1835      Inst.
setOpcode(Hexagon::S2_asr_i_p_rnd);
 
 1840  case Hexagon::A4_boundscheck: {
 
 1844      Inst.
setOpcode(Hexagon::A4_boundscheck_hi);
 
 1846      StringRef RegPair = 
Name;
 
 1847      Rs.
setReg(matchRegister(RegPair));
 
 1849      Inst.
setOpcode(Hexagon::A4_boundscheck_lo);
 
 1851      StringRef RegPair = 
Name;
 
 1852      Rs.
setReg(matchRegister(RegPair));
 
 1857  case Hexagon::A2_addsp: {
 
 1863      StringRef RegPair = 
Name;
 
 1864      Rs.
setReg(matchRegister(RegPair));
 
 1868      StringRef RegPair = 
Name;
 
 1869      Rs.
setReg(matchRegister(RegPair));
 
 1874  case Hexagon::M2_vrcmpys_s1: {
 
 1878      Inst.
setOpcode(Hexagon::M2_vrcmpys_s1_h);
 
 1880      StringRef RegPair = 
Name;
 
 1881      Rt.
setReg(matchRegister(RegPair));
 
 1883      Inst.
setOpcode(Hexagon::M2_vrcmpys_s1_l);
 
 1885      StringRef RegPair = 
Name;
 
 1886      Rt.
setReg(matchRegister(RegPair));
 
 1891  case Hexagon::M2_vrcmpys_acc_s1: {
 
 1898      TmpInst.
setOpcode(Hexagon::M2_vrcmpys_acc_s1_h);
 
 1900      StringRef RegPair = 
Name;
 
 1901      Rt.
setReg(matchRegister(RegPair));
 
 1903      TmpInst.
setOpcode(Hexagon::M2_vrcmpys_acc_s1_l);
 
 1905      StringRef RegPair = 
Name;
 
 1906      Rt.
setReg(matchRegister(RegPair));
 
 1917  case Hexagon::M2_vrcmpys_s1rp: {
 
 1921      Inst.
setOpcode(Hexagon::M2_vrcmpys_s1rp_h);
 
 1923      StringRef RegPair = 
Name;
 
 1924      Rt.
setReg(matchRegister(RegPair));
 
 1926      Inst.
setOpcode(Hexagon::M2_vrcmpys_s1rp_l);
 
 1928      StringRef RegPair = 
Name;
 
 1929      Rt.
setReg(matchRegister(RegPair));
 
 1934  case Hexagon::S5_asrhub_rnd_sat_goodsyntax: {
 
 1939      return Match_InvalidOperand;
 
 1947      Inst.
setOpcode(Hexagon::S5_asrhub_rnd_sat);
 
 1952  case Hexagon::S5_vasrhrnd_goodsyntax: {
 
 1959      return Match_InvalidOperand;
 
 1963      std::string R1 = r + 
utostr(RegPairNum + 1);
 
 1965      Rss.
setReg(matchRegister(Reg1));
 
 1967      std::string 
R2 = r + 
utostr(RegPairNum);
 
 1969      TmpInst.
setOpcode(Hexagon::A2_combinew);
 
 1984  case Hexagon::A2_not: {
 
 1996  case Hexagon::PS_loadrubabs:
 
 2000  case Hexagon::PS_loadrbabs:
 
 2004  case Hexagon::PS_loadruhabs:
 
 2008  case Hexagon::PS_loadrhabs:
 
 2012  case Hexagon::PS_loadriabs:
 
 2016  case Hexagon::PS_loadrdabs:
 
 2020  case Hexagon::PS_storerbabs:
 
 2024  case Hexagon::PS_storerhabs:
 
 2028  case Hexagon::PS_storerfabs:
 
 2032  case Hexagon::PS_storeriabs:
 
 2036  case Hexagon::PS_storerdabs:
 
 2040  case Hexagon::PS_storerbnewabs:
 
 2042      Inst.
setOpcode(Hexagon::S2_storerbnewgp);
 
 2044  case Hexagon::PS_storerhnewabs:
 
 2046      Inst.
setOpcode(Hexagon::S2_storerhnewgp);
 
 2048  case Hexagon::PS_storerinewabs:
 
 2050      Inst.
setOpcode(Hexagon::S2_storerinewgp);
 
 2052  case Hexagon::A2_zxtb: {
 
 2060  return Match_Success;
 
 2063MCRegister HexagonAsmParser::matchRegister(StringRef Name) {
 
static MCRegister MatchRegisterName(StringRef Name)
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
static bool isNot(const MachineRegisterInfo &MRI, const MachineInstr &MI)
 
static MCRegister MatchRegisterAltName(StringRef Name)
Maps from the set of all alternative registernames to a register number.
 
static size_t byteSize(BTF::CommonType *Type)
 
static constexpr unsigned long long mask(BlockVerifier::State S)
 
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
 
Analysis containing CSE Info
 
#define LLVM_EXTERNAL_VISIBILITY
 
static bool isSigned(unsigned int Opcode)
 
static cl::opt< bool > WarnSignedMismatch("mwarn-sign-mismatch", cl::desc("Warn for mismatching a signed and unsigned value"), cl::init(false))
 
static cl::opt< bool > ErrorMissingParenthesis("merror-missing-parenthesis", cl::desc("Error for missing parenthesis around predicate registers"), cl::init(false))
 
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonAsmParser()
Force static initialization.
 
static cl::opt< bool > WarnNoncontigiousRegister("mwarn-noncontigious-register", cl::desc("Warn for register names that aren't contigious"), cl::init(true))
 
static cl::opt< bool > ErrorNoncontigiousRegister("merror-noncontigious-register", cl::desc("Error for register names that aren't contigious"), cl::init(false))
 
static bool previousEqual(OperandVector &Operands, size_t Index, StringRef String)
 
static MCInst makeCombineInst(int opCode, MCOperand &Rdd, MCOperand &MO1, MCOperand &MO2)
 
static bool previousIsLoop(OperandVector &Operands, size_t Index)
 
static cl::opt< bool > WarnMissingParenthesis("mwarn-missing-parenthesis", cl::desc("Warn for missing parenthesis around predicate registers"), cl::init(true))
 
static cl::opt< bool > AddBuildAttributes("hexagon-add-build-attributes")
 
Value * getPointer(Value *Ptr)
 
Promote Memory to Register
 
static unsigned getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
 
static bool isReg(const MCInst &MI, unsigned OpNo)
 
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
 
This file defines the SmallVector class.
 
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
 
SMLoc getLoc() const
Get the current source location.
 
const AsmToken peekTok(bool ShouldSkipSpace=true)
Look ahead at the next token to be lexed.
 
void UnLex(AsmToken const &Token)
 
const AsmToken & getTok() const
Get the current (last) lexed token.
 
bool is(AsmToken::TokenKind K) const
Check if the current token has kind K.
 
const AsmToken & Lex()
Consume the next token from the input stream and return it.
 
LLVM_ABI SMLoc getLoc() 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
 
StringRef getIdentifier() const
Get the identifier string for the current token, which should be an identifier or a string.
 
void HexagonMCEmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment, unsigned AccessSize)
 
void HexagonMCEmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment, unsigned AccessSize)
 
void setMustNotExtend(bool Val=true)
 
bool mustNotExtend() const
 
static HexagonMCExpr * create(MCExpr const *Expr, MCContext &Ctx)
 
void setMustExtend(bool Val=true)
 
void setSignMismatch(bool Val=true)
 
This class is intended to be used as a base class for asm properties and features specific to the tar...
 
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser.
 
Generic assembler parser interface, for use by target specific assembly parsers.
 
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 const AsmToken & Lex()=0
Get the next AsmToken in the stream, possibly handling file inclusion first.
 
virtual void addAliasForDirective(StringRef Directive, StringRef Alias)=0
 
virtual bool printError(SMLoc L, const Twine &Msg, SMRange Range={})=0
Emit an error at the location L, with the message Msg.
 
MCStreamer & getStreamer()
 
static const MCBinaryExpr * createLShr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
 
static const MCBinaryExpr * createAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
 
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
 
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
 
LLVM_ABI bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm) const
Try to evaluate the expression to a relocatable value, i.e.
 
@ Unary
Unary expressions.
 
@ SymbolRef
References to labels and assigned expressions.
 
@ Binary
Binary expressions.
 
LLVM_ABI bool evaluateAsAbsolute(int64_t &Res) const
Try to evaluate the expression to an absolute value.
 
Instances of this class represent a single low-level machine instruction.
 
unsigned getOpcode() const
 
LLVM_ABI void dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer=nullptr, StringRef Separator=" ", const MCContext *Ctx=nullptr) const
Dump the MCInst as prettily as possible using the additional MC structures, if given.
 
void addOperand(const MCOperand Op)
 
void setOpcode(unsigned Op)
 
const MCOperand & getOperand(unsigned i) const
 
Interface to description of machine instruction set.
 
MCAssembler & getAssembler()
 
Instances of this class represent operands of the MCInst class.
 
static MCOperand createExpr(const MCExpr *Val)
 
void setExpr(const MCExpr *Val)
 
static MCOperand createReg(MCRegister Reg)
 
static MCOperand createImm(int64_t Val)
 
void setReg(MCRegister Reg)
Set the register number.
 
MCRegister getReg() const
Returns the register number.
 
const MCExpr * getExpr() const
 
static MCOperand createInst(const MCInst *Val)
 
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand.
 
virtual bool isToken() const =0
isToken - Is this a token operand?
 
uint16_t getEncodingValue(MCRegister Reg) const
Returns the encoding for Reg.
 
virtual bool popSection()
Restore the current and previous section from the section stack.
 
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
 
virtual bool hasRawTextSupport() const
Return true if this asm streamer supports emitting unformatted text to the .s file with EmitRawText.
 
MCTargetStreamer * getTargetStreamer()
 
void pushSection()
Save the current and previous section on the section stack.
 
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
 
Generic base class for all target subtargets.
 
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
 
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
 
MCTargetAsmParser - Generic interface to target specific assembly parsers.
 
Target specific streamer interface.
 
MCStreamer & getStreamer()
 
static constexpr StatusTy Success
 
static constexpr StatusTy NoMatch
 
LLVM_ABI void print(const char *ProgName, raw_ostream &S, bool ShowColors=true, bool ShowKindLabel=true, bool ShowLocation=true) const
 
reference emplace_back(ArgTypes &&... Args)
 
iterator insert(iterator I, T &&Elt)
 
void push_back(const T &Elt)
 
StringRef - Represent a constant reference to a string, i.e.
 
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
 
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
 
LLVM_ABI std::string upper() const
Convert the given ASCII string to uppercase.
 
constexpr size_t size() const
size - Get the string size.
 
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
 
LLVM_ABI std::string lower() const
 
bool equals_insensitive(StringRef RHS) const
Check for string equality, ignoring case.
 
This class implements an extremely fast bulk output stream that can only output to a stream.
 
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
 
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
 
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
 
LLVM_ABI std::optional< unsigned > attrTypeFromString(StringRef tag, TagNameMap tagNameMap)
 
LLVM_ABI const TagNameMap & getHexagonAttributeTags()
 
std::pair< unsigned, unsigned > GetVecRegPairIndices(MCRegister VecRegPair)
Returns an ordered pair of the constituent register ordinals for each of the elements of VecRegPair.
 
void setOuterLoop(MCInst &MCI)
 
bool isOuterLoop(MCInst const &MCI)
 
size_t bundleSize(MCInst const &MCI)
 
void setS27_2_reloc(MCExpr const &Expr, bool Val=true)
 
void setInnerLoop(MCInst &MCI)
 
MCInstrDesc const & getDesc(MCInstrInfo const &MCII, MCInst const &MCI)
 
void setMemReorderDisabled(MCInst &MCI)
 
bool isBundle(MCInst const &MCI)
 
MCExpr const & getExpr(MCExpr const &Expr)
 
bool isInnerLoop(MCInst const &MCI)
 
bool canonicalizePacket(MCInstrInfo const &MCII, MCSubtargetInfo const &STI, MCContext &Context, MCInst &MCB, HexagonMCChecker *Checker, bool AttemptCompatibility=false)
 
void setMustNotExtend(MCExpr const &Expr, bool Val=true)
 
void extendIfNeeded(MCContext &Context, MCInstrInfo const &MCII, MCInst &MCB, MCInst const &MCI)
 
bool mustExtend(MCExpr const &Expr)
 
void setMustExtend(MCExpr const &Expr, bool Val=true)
 
@ CE
Windows NT (Windows on ARM)
 
bool isPseudo(uint64_t TSFlags)
 
initializer< Ty > init(const Ty &Val)
 
Context & getContext() const
 
This is an optimization pass for GlobalISel generic memory operations.
 
FunctionAddr VTableAddr Value
 
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
 
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
 
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
 
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.
 
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
 
std::string utohexstr(uint64_t X, bool LowerCase=false, unsigned Width=0)
 
std::string utostr(uint64_t X, bool isNeg=false)
 
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
 
Target & getTheHexagonTarget()
 
SmallVectorImpl< std::unique_ptr< MCParsedAsmOperand > > OperandVector
 
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
 
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)
 
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.
 
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
 
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
 
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
 
DWARFExpression::Operation Op
 
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
 
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
 
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
 
bool isSpace(char C)
Checks whether character C is whitespace in the "C" locale.
 
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
 
@ MCSA_Global
.type _foo, @gnu_unique_object
 
RegisterMCAsmParser - Helper template for registering a target specific assembly parser,...