90 if (&Subtarget == &NewSubtarget)
93 Names2InstrOpCodes.
clear();
95 Names2RegMasks.
clear();
96 Names2SubRegIndices.
clear();
97 Names2TargetIndices.
clear();
98 Names2DirectTargetFlags.
clear();
99 Names2BitmaskTargetFlags.
clear();
100 Names2MMOTargetFlags.
clear();
102 initNames2RegClasses();
103 initNames2RegBanks();
106 void PerTargetMIParsingState::initNames2Regs() {
107 if (!Names2Regs.
empty())
111 Names2Regs.
insert(std::make_pair(
"noreg", 0));
113 assert(
TRI &&
"Expected target register info");
115 for (
unsigned I = 0,
E =
TRI->getNumRegs();
I <
E; ++
I) {
120 assert(WasInserted &&
"Expected registers to be unique case-insensitively");
127 auto RegInfo = Names2Regs.
find(RegName);
128 if (RegInfo == Names2Regs.
end())
130 Reg = RegInfo->getValue();
134 void PerTargetMIParsingState::initNames2InstrOpCodes() {
135 if (!Names2InstrOpCodes.
empty())
138 assert(
TII &&
"Expected target instruction info");
139 for (
unsigned I = 0,
E =
TII->getNumOpcodes();
I <
E; ++
I)
145 initNames2InstrOpCodes();
146 auto InstrInfo = Names2InstrOpCodes.
find(InstrName);
147 if (InstrInfo == Names2InstrOpCodes.
end())
149 OpCode = InstrInfo->getValue();
153 void PerTargetMIParsingState::initNames2RegMasks() {
154 if (!Names2RegMasks.
empty())
157 assert(
TRI &&
"Expected target register info");
161 for (
size_t I = 0,
E = RegMasks.
size();
I <
E; ++
I)
163 std::make_pair(
StringRef(RegMaskNames[
I]).lower(), RegMasks[I]));
167 initNames2RegMasks();
168 auto RegMaskInfo = Names2RegMasks.
find(Identifier);
169 if (RegMaskInfo == Names2RegMasks.
end())
171 return RegMaskInfo->getValue();
174 void PerTargetMIParsingState::initNames2SubRegIndices() {
175 if (!Names2SubRegIndices.
empty())
179 Names2SubRegIndices.
insert(
184 initNames2SubRegIndices();
185 auto SubRegInfo = Names2SubRegIndices.
find(Name);
186 if (SubRegInfo == Names2SubRegIndices.
end())
188 return SubRegInfo->getValue();
191 void PerTargetMIParsingState::initNames2TargetIndices() {
192 if (!Names2TargetIndices.
empty())
195 assert(
TII &&
"Expected target instruction info");
196 auto Indices =
TII->getSerializableTargetIndices();
197 for (
const auto &
I : Indices)
202 initNames2TargetIndices();
203 auto IndexInfo = Names2TargetIndices.
find(Name);
204 if (IndexInfo == Names2TargetIndices.
end())
206 Index = IndexInfo->second;
210 void PerTargetMIParsingState::initNames2DirectTargetFlags() {
211 if (!Names2DirectTargetFlags.
empty())
215 assert(
TII &&
"Expected target instruction info");
217 for (
const auto &
I : Flags)
218 Names2DirectTargetFlags.
insert(
224 initNames2DirectTargetFlags();
225 auto FlagInfo = Names2DirectTargetFlags.
find(Name);
226 if (FlagInfo == Names2DirectTargetFlags.
end())
228 Flag = FlagInfo->second;
232 void PerTargetMIParsingState::initNames2BitmaskTargetFlags() {
233 if (!Names2BitmaskTargetFlags.
empty())
237 assert(
TII &&
"Expected target instruction info");
239 for (
const auto &
I : Flags)
240 Names2BitmaskTargetFlags.
insert(
246 initNames2BitmaskTargetFlags();
247 auto FlagInfo = Names2BitmaskTargetFlags.
find(Name);
248 if (FlagInfo == Names2BitmaskTargetFlags.
end())
250 Flag = FlagInfo->second;
254 void PerTargetMIParsingState::initNames2MMOTargetFlags() {
255 if (!Names2MMOTargetFlags.
empty())
259 assert(
TII &&
"Expected target instruction info");
260 auto Flags =
TII->getSerializableMachineMemOperandTargetFlags();
261 for (
const auto &
I : Flags)
267 initNames2MMOTargetFlags();
268 auto FlagInfo = Names2MMOTargetFlags.
find(Name);
269 if (FlagInfo == Names2MMOTargetFlags.
end())
271 Flag = FlagInfo->second;
275 void PerTargetMIParsingState::initNames2RegClasses() {
276 if (!Names2RegClasses.
empty())
287 void PerTargetMIParsingState::initNames2RegBanks() {
288 if (!Names2RegBanks.
empty())
300 std::make_pair(
StringRef(RegBank.getName()).lower(), &RegBank));
306 auto RegClassInfo = Names2RegClasses.
find(Name);
307 if (RegClassInfo == Names2RegClasses.
end())
309 return RegClassInfo->getValue();
313 auto RegBankInfo = Names2RegBanks.
find(Name);
314 if (RegBankInfo == Names2RegBanks.
end())
316 return RegBankInfo->getValue();
321 : MF(MF), SM(&SM), IRSlots(IRSlots),
Target(T) {
325 auto I =
VRegInfos.insert(std::make_pair(Num,
nullptr));
330 I.first->second =
Info;
332 return *
I.first->second;
336 assert(RegName !=
"" &&
"Expected named reg.");
342 I.first->second =
Info;
344 return *
I.first->second;
352 Slots2Values.
insert(std::make_pair(
unsigned(Slot), V));
360 for (
const auto &
Arg : F.
args())
362 for (
const auto &BB : F) {
364 for (
const auto &
I : BB)
382 struct ParsedMachineOperand {
390 : Operand(Operand), Begin(Begin), End(End), TiedDefIdx(TiedDefIdx) {
393 "Only used register operands can be tied");
412 void lex(
unsigned SkipChar = 0);
426 bool parseBasicBlocks();
429 bool parseStandaloneNamedRegister(
unsigned &
Reg);
431 bool parseStandaloneRegister(
unsigned &Reg);
432 bool parseStandaloneStackObject(
int &FI);
433 bool parseStandaloneMDNode(
MDNode *&Node);
442 bool parseNamedRegister(
unsigned &Reg);
443 bool parseVirtualRegister(
VRegInfo *&Info);
444 bool parseNamedVirtualRegister(
VRegInfo *&Info);
446 bool parseRegisterFlag(
unsigned &Flags);
447 bool parseRegisterClassOrBank(VRegInfo &RegInfo);
448 bool parseSubRegisterIndex(
unsigned &
SubReg);
449 bool parseRegisterTiedDefIndex(
unsigned &TiedDefIdx);
461 bool parseStackFrameIndex(
int &FI);
463 bool parseFixedStackFrameIndex(
int &FI);
473 bool parseDIExpression(
MDNode *&Expr);
474 bool parseDILocation(
MDNode *&Expr);
476 bool parseCFIOffset(
int &
Offset);
477 bool parseCFIRegister(
unsigned &Reg);
478 bool parseCFIEscapeValues(std::string& Values);
488 bool parseMachineOperand(
const unsigned OpCode,
const unsigned OpIdx,
491 bool parseMachineOperandAndTargetFlags(
const unsigned OpCode,
492 const unsigned OpIdx,
495 bool parseOffset(int64_t &Offset);
496 bool parseAlignment(
unsigned &Alignment);
497 bool parseAddrspace(
unsigned &Addrspace);
507 bool parseHeapAllocMarker(
MDNode *&Node);
509 bool parseTargetImmMnemonic(
const unsigned OpCode,
const unsigned OpIdx,
521 bool getUint64(uint64_t &Result);
537 bool parseInstruction(
unsigned &OpCode,
unsigned &Flags);
553 bool parseStringConstant(std::string &Result);
560 :
MF(PFS.
MF),
Error(Error),
Source(Source), CurrentSource(Source), PFS(PFS)
563 void MIParser::lex(
unsigned SkipChar) {
565 CurrentSource.data() + SkipChar, Token,
604 return "<unknown token>";
609 if (Token.isNot(TokenKind))
616 if (Token.isNot(TokenKind))
622 bool MIParser::parseBasicBlockDefinition(
628 auto Loc = Token.location();
629 auto Name = Token.stringValue();
631 bool HasAddressTaken =
false;
632 bool IsLandingPad =
false;
633 unsigned Alignment = 0;
638 switch (Token.kind()) {
640 HasAddressTaken =
true;
648 if (parseAlignment(Alignment))
668 BB = dyn_cast_or_null<BasicBlock>(
672 "' is not defined in the function '" +
677 bool WasInserted = MBBSlots.
insert(std::make_pair(ID, MBB)).second;
679 return error(Loc,
Twine(
"redefinition of machine basic block with id #") +
682 MBB->setAlignment(
Align(Alignment));
684 MBB->setHasAddressTaken();
685 MBB->setIsEHPad(IsLandingPad);
689 bool MIParser::parseBasicBlockDefinitions(
695 if (Token.isErrorOrEOF())
696 return Token.isError();
698 return error(
"expected a basic block definition before instructions");
699 unsigned BraceDepth = 0;
701 if (parseBasicBlockDefinition(MBBSlots))
703 bool IsAfterNewline =
false;
707 Token.isErrorOrEOF())
710 return error(
"basic block definition should be located at the start of " 713 IsAfterNewline =
true;
716 IsAfterNewline =
false;
721 return error(
"extraneous closing brace ('}')");
727 if (!Token.isError() && BraceDepth)
728 return error(
"expected '}'");
729 }
while (!Token.isErrorOrEOF());
730 return Token.isError();
738 if (Token.isNewlineOrEOF())
742 return error(
"expected a named register");
744 if (parseNamedRegister(Reg))
752 return error(
"expected a lane mask");
754 "Use correct get-function for lane mask");
757 return error(
"invalid lane mask value");
771 if (Token.isNewlineOrEOF())
775 return error(
"expected a machine basic block reference");
784 return error(
"expected an integer literal after '('");
818 bool ExplicitSuccessors =
false;
821 if (parseBasicBlockSuccessors(MBB))
823 ExplicitSuccessors =
true;
825 if (parseBasicBlockLiveins(MBB))
831 if (!Token.isNewlineOrEOF())
832 return error(
"expected line break at the end of a list");
837 bool IsInBundle =
false;
861 return error(
"nested instruction bundles are not allowed");
870 assert(Token.isNewlineOrEOF() &&
"MI is not fully parsed");
875 if (!ExplicitSuccessors) {
883 AddFalthroughFrom = &MBB;
892 bool MIParser::parseBasicBlocks() {
897 if (Token.isErrorOrEOF())
898 return Token.isError();
907 if (AddFalthroughFrom) {
908 if (!AddFalthroughFrom->isSuccessor(MBB))
910 AddFalthroughFrom->normalizeSuccProbs();
911 AddFalthroughFrom =
nullptr;
913 if (parseBasicBlock(*MBB, AddFalthroughFrom))
926 while (Token.isRegister() || Token.isRegisterFlag()) {
927 auto Loc = Token.location();
929 if (parseRegisterOperand(MO, TiedDefIdx,
true))
932 ParsedMachineOperand(MO, Loc, Token.location(), TiedDefIdx));
940 unsigned OpCode, Flags = 0;
941 if (Token.isError() || parseInstruction(OpCode, Flags))
950 auto Loc = Token.location();
952 if (parseMachineOperandAndTargetFlags(OpCode, Operands.
size(), MO, TiedDefIdx))
954 if (OpCode == TargetOpcode::DBG_VALUE && MO.
isReg())
957 ParsedMachineOperand(MO, Loc, Token.location(), TiedDefIdx));
962 return error(
"expected ',' before the next machine operand");
968 if (parsePreOrPostInstrSymbol(PreInstrSymbol))
970 MCSymbol *PostInstrSymbol =
nullptr;
972 if (parsePreOrPostInstrSymbol(PostInstrSymbol))
974 MDNode *HeapAllocMarker =
nullptr;
976 if (parseHeapAllocMarker(HeapAllocMarker))
987 if (parseDILocation(Node))
990 return error(
"expected a metadata node after 'debug-location'");
991 if (!isa<DILocation>(Node))
992 return error(
"referenced metadata is not a DILocation");
1000 while (!Token.isNewlineOrEOF()) {
1002 if (parseMachineMemoryOperand(MemOp))
1005 if (Token.isNewlineOrEOF())
1008 return error(
"expected ',' before the next machine memory operand");
1014 if (!MCID.isVariadic()) {
1016 if (verifyImplicitOperands(Operands, MCID))
1023 for (
const auto &Operand : Operands)
1025 if (assignRegisterTies(*MI, Operands))
1029 if (PostInstrSymbol)
1031 if (HeapAllocMarker)
1033 if (!MemOperands.
empty())
1041 return error(
"expected a machine basic block reference");
1047 "expected end of string after the machine basic block reference");
1051 bool MIParser::parseStandaloneNamedRegister(
unsigned &
Reg) {
1054 return error(
"expected a named register");
1055 if (parseNamedRegister(Reg))
1059 return error(
"expected end of string after the register reference");
1063 bool MIParser::parseStandaloneVirtualRegister(
VRegInfo *&
Info) {
1066 return error(
"expected a virtual register");
1067 if (parseVirtualRegister(Info))
1071 return error(
"expected end of string after the register reference");
1075 bool MIParser::parseStandaloneRegister(
unsigned &Reg) {
1079 return error(
"expected either a named or virtual register");
1082 if (parseRegister(Reg, Info))
1087 return error(
"expected end of string after the register reference");
1091 bool MIParser::parseStandaloneStackObject(
int &FI) {
1094 return error(
"expected a stack object");
1095 if (parseStackFrameIndex(FI))
1098 return error(
"expected end of string after the stack object reference");
1102 bool MIParser::parseStandaloneMDNode(
MDNode *&Node) {
1108 if (parseDIExpression(Node))
1111 if (parseDILocation(Node))
1114 return error(
"expected a metadata node");
1116 return error(
"expected end of string after the metadata node");
1122 return MO.
isDef() ?
"implicit-def" :
"implicit";
1134 for (
const auto &
I : Operands) {
1160 assert(
TRI &&
"Expected target register info");
1161 for (
const auto &
I : ImplicitOperands) {
1164 return error(Operands.
empty() ? Token.location() : Operands.
back().End,
1165 Twine(
"missing implicit register operand '") +
1172 bool MIParser::parseInstruction(
unsigned &OpCode,
unsigned &Flags) {
1218 return error(
"expected a machine instruction");
1219 StringRef InstrName = Token.stringValue();
1221 return error(
Twine(
"unknown machine instruction name '") + InstrName +
"'");
1226 bool MIParser::parseNamedRegister(
unsigned &Reg) {
1230 return error(
Twine(
"unknown register name '") + Name +
"'");
1234 bool MIParser::parseNamedVirtualRegister(
VRegInfo *&Info) {
1243 bool MIParser::parseVirtualRegister(
VRegInfo *&Info) {
1245 return parseNamedVirtualRegister(Info);
1254 bool MIParser::parseRegister(
unsigned &Reg,
VRegInfo *&Info) {
1255 switch (Token.kind()) {
1260 return parseNamedRegister(Reg);
1263 if (parseVirtualRegister(Info))
1273 bool MIParser::parseRegisterClassOrBank(
VRegInfo &RegInfo) {
1275 return error(
"expected '_', register class, or register bank name");
1284 switch (RegInfo.
Kind) {
1290 return error(Loc,
Twine(
"conflicting register classes, previously: ") +
1299 return error(Loc,
"register class specification on generic register");
1309 return error(Loc,
"expected '_', register class, or register bank name");
1314 switch (RegInfo.
Kind) {
1320 return error(Loc,
"conflicting generic register banks");
1326 return error(Loc,
"register bank specification on normal register");
1331 bool MIParser::parseRegisterFlag(
unsigned &Flags) {
1332 const unsigned OldFlags = Flags;
1333 switch (Token.kind()) {
1367 if (OldFlags == Flags)
1370 return error(
"duplicate '" + Token.stringValue() +
"' register flag");
1375 bool MIParser::parseSubRegisterIndex(
unsigned &
SubReg) {
1379 return error(
"expected a subregister index after '.'");
1380 auto Name = Token.stringValue();
1383 return error(
Twine(
"use of unknown subregister index '") +
Name +
"'");
1388 bool MIParser::parseRegisterTiedDefIndex(
unsigned &TiedDefIdx) {
1392 return error(
"expected an integer literal after 'tied-def'");
1404 for (
unsigned I = 0,
E = Operands.
size();
I !=
E; ++
I) {
1405 if (!Operands[
I].TiedDefIdx)
1409 unsigned DefIdx = Operands[
I].TiedDefIdx.getValue();
1411 return error(Operands[
I].Begin,
1412 Twine(
"use of invalid tied-def operand index '" +
1413 Twine(DefIdx) +
"'; instruction has only ") +
1415 const auto &DefOperand = Operands[DefIdx].Operand;
1416 if (!DefOperand.isReg() || !DefOperand.isDef())
1418 return error(Operands[
I].Begin,
1419 Twine(
"use of invalid tied-def operand index '") +
1420 Twine(DefIdx) +
"'; the operand #" +
Twine(DefIdx) +
1421 " isn't a defined register");
1423 for (
const auto &TiedPair : TiedRegisterPairs) {
1424 if (TiedPair.first == DefIdx)
1425 return error(Operands[
I].Begin,
1426 Twine(
"the tied-def operand #") +
Twine(DefIdx) +
1427 " is already tied with another register operand");
1429 TiedRegisterPairs.push_back(std::make_pair(DefIdx,
I));
1433 for (
const auto &TiedPair : TiedRegisterPairs)
1442 while (Token.isRegisterFlag()) {
1443 if (parseRegisterFlag(Flags))
1446 if (!Token.isRegister())
1447 return error(
"expected a register after register flags");
1450 if (parseRegister(Reg, RegInfo))
1453 unsigned SubReg = 0;
1455 if (parseSubRegisterIndex(SubReg))
1458 return error(
"subregister index expects a virtual register");
1462 return error(
"register class specification expects a virtual register");
1464 if (parseRegisterClassOrBank(*RegInfo))
1471 if (!parseRegisterTiedDefIndex(Idx))
1476 if (parseLowLevelType(Token.location(), Ty))
1477 return error(
"expected tied-def or low-level type after '('");
1483 return error(
"inconsistent type for generic virtual register");
1492 return error(
"unexpected type on physical register");
1495 if (parseLowLevelType(Token.location(), Ty))
1502 return error(
"inconsistent type for generic virtual register");
1512 return error(
"generic virtual registers must have a type");
1525 const APSInt &Int = Token.integerValue();
1526 if (Int.getMinSignedBits() > 64)
1527 return error(
"integer literal is too large to be an immediate operand");
1533 bool MIParser::parseTargetImmMnemonic(
const unsigned OpCode,
1534 const unsigned OpIdx,
1538 auto Loc = Token.location();
1544 Len += Token.range().size();
1553 Src =
StringRef(Loc, Len + Token.stringValue().size());
1558 ->
bool { return error(Loc, Msg); }))
1570 auto Source = StringValue.
str();
1582 Loc, StringValue, PFS, C,
1584 return error(Loc, Msg);
1605 return isUInt<24>(AddrSpace);
1609 if (Token.range().front() ==
's' || Token.range().front() ==
'p') {
1612 return error(
"expected integers after 's'/'p' type character");
1615 if (Token.range().front() ==
's') {
1616 auto ScalarSize =
APSInt(Token.range().drop_front()).getZExtValue();
1618 return error(
"invalid size for scalar type");
1623 }
else if (Token.range().front() ==
'p') {
1625 uint64_t AS =
APSInt(Token.range().drop_front()).getZExtValue();
1627 return error(
"invalid address space number");
1637 "expected sN, pA, <M x sN>, or <M x pA> for GlobalISel type");
1641 return error(Loc,
"expected <M x sN> or <M x pA> for vector type");
1642 uint64_t NumElements = Token.integerValue().getZExtValue();
1644 return error(
"invalid number of vector elements");
1649 return error(Loc,
"expected <M x sN> or <M x pA> for vector type");
1652 if (Token.range().front() !=
's' && Token.range().front() !=
'p')
1653 return error(Loc,
"expected <M x sN> or <M x pA> for vector type");
1656 return error(
"expected integers after 's'/'p' type character");
1658 if (Token.range().front() ==
's') {
1659 auto ScalarSize =
APSInt(Token.range().drop_front()).getZExtValue();
1661 return error(
"invalid size for scalar type");
1663 }
else if (Token.range().front() ==
'p') {
1665 uint64_t AS =
APSInt(Token.range().drop_front()).getZExtValue();
1667 return error(
"invalid address space number");
1671 return error(Loc,
"expected <M x sN> or <M x pA> for vector type");
1675 return error(Loc,
"expected <M x sN> or <M x pA> for vector type");
1682 bool MIParser::parseTypedImmediateOperand(
MachineOperand &Dest) {
1685 if (TypeStr.front() !=
'i' && TypeStr.front() !=
's' &&
1686 TypeStr.front() !=
'p')
1688 "a typed immediate operand should start with one of 'i', 's', or 'p'");
1691 return error(
"expected integers after 'i'/'s'/'p' type character");
1693 auto Loc = Token.location();
1697 !(Token.range() ==
"true" || Token.range() ==
"false"))
1698 return error(
"expected an integer literal");
1708 auto Loc = Token.location();
1712 return error(
"expected a floating point literal");
1723 assert(S[0] ==
'0' && tolower(S[1]) ==
'x');
1725 if (!isxdigit(S[2]))
1732 unsigned NumBits = (A == 0) ? 32 : A.getActiveBits();
1743 return ErrCB(Token.
location(),
"expected 32-bit integer (too large)");
1752 return ErrCB(Token.
location(),
"expected 32-bit integer (too large)");
1762 return error(Loc, Msg);
1772 auto MBBInfo = PFS.
MBBSlots.find(Number);
1774 return error(
Twine(
"use of undefined machine basic block #") +
1776 MBB = MBBInfo->second;
1779 if (!Token.stringValue().empty() && Token.stringValue() != MBB->
getName())
1780 return error(
Twine(
"the name of machine basic block #") +
Twine(Number) +
1781 " isn't '" + Token.stringValue() +
"'");
1794 bool MIParser::parseStackFrameIndex(
int &FI) {
1801 return error(
Twine(
"use of undefined stack object '%stack.") +
Twine(ID) +
1804 if (
const auto *Alloca =
1805 MF.getFrameInfo().getObjectAllocation(ObjectInfo->second))
1806 Name = Alloca->getName();
1807 if (!Token.stringValue().empty() && Token.stringValue() !=
Name)
1808 return error(
Twine(
"the name of the stack object '%stack.") +
Twine(ID) +
1809 "' isn't '" + Token.stringValue() +
"'");
1811 FI = ObjectInfo->second;
1817 if (parseStackFrameIndex(FI))
1823 bool MIParser::parseFixedStackFrameIndex(
int &FI) {
1830 return error(
Twine(
"use of undefined fixed stack object '%fixed-stack.") +
1833 FI = ObjectInfo->second;
1837 bool MIParser::parseFixedStackObjectOperand(
MachineOperand &Dest) {
1839 if (parseFixedStackFrameIndex(FI))
1848 switch (Token.
kind()) {
1853 return ErrCB(Token.
location(),
Twine(
"use of undefined global value '") +
1854 Token.
range() +
"'");
1862 return ErrCB(Token.
location(),
Twine(
"use of undefined global value '@") +
1863 Twine(GVIdx) +
"'");
1877 return error(Loc, Msg);
1887 if (parseOperandsOffset(Dest))
1892 bool MIParser::parseConstantPoolIndexOperand(
MachineOperand &Dest) {
1899 return error(
"use of undefined constant '%const." +
Twine(ID) +
"'");
1902 if (parseOperandsOffset(Dest))
1907 bool MIParser::parseJumpTableIndexOperand(
MachineOperand &Dest) {
1914 return error(
"use of undefined jump table '%jump-table." +
Twine(ID) +
"'");
1920 bool MIParser::parseExternalSymbolOperand(
MachineOperand &Dest) {
1922 const char *
Symbol = MF.createExternalSymbolName(Token.stringValue());
1925 if (parseOperandsOffset(Dest))
1935 if (parseOperandsOffset(Dest))
1940 bool MIParser::parseSubRegisterIndexOperand(
MachineOperand &Dest) {
1944 if (SubRegIndex == 0)
1945 return error(
Twine(
"unknown subregister index '") + Name +
"'");
1954 auto Loc = Token.location();
1957 return error(
"expected metadata id after '!'");
1963 return error(Loc,
"use of undefined metadata '!" +
Twine(ID) +
"'");
1965 Node = NodeInfo->second.
get();
1969 bool MIParser::parseDIExpression(
MDNode *&Expr) {
1992 return error(
Twine(
"invalid DWARF op '") + Token.stringValue() +
"'");
1996 Token.integerValue().isSigned())
1997 return error(
"expected unsigned integer");
1999 auto &U = Token.integerValue();
2015 bool MIParser::parseDILocation(
MDNode *&Loc) {
2019 bool HaveLine =
false;
2021 unsigned Column = 0;
2023 MDNode *InlinedAt =
nullptr;
2024 bool ImplicitCode =
false;
2032 if (Token.stringValue() ==
"line") {
2037 Token.integerValue().isSigned())
2038 return error(
"expected unsigned integer");
2039 Line = Token.integerValue().getZExtValue();
2044 if (Token.stringValue() ==
"column") {
2049 Token.integerValue().isSigned())
2050 return error(
"expected unsigned integer");
2051 Column = Token.integerValue().getZExtValue();
2055 if (Token.stringValue() ==
"scope") {
2060 return error(
"expected metadata node");
2061 if (!isa<DIScope>(Scope))
2062 return error(
"expected DIScope node");
2065 if (Token.stringValue() ==
"inlinedAt") {
2073 if (parseDILocation(InlinedAt))
2076 return error(
"expected metadata node");
2077 if (!isa<DILocation>(InlinedAt))
2078 return error(
"expected DILocation node");
2081 if (Token.stringValue() ==
"isImplicitCode") {
2086 return error(
"expected true/false");
2090 if (Token.stringValue() ==
"true")
2091 ImplicitCode =
true;
2092 else if (Token.stringValue() ==
"false")
2093 ImplicitCode =
false;
2095 return error(
"expected true/false");
2100 return error(
Twine(
"invalid DILocation argument '") +
2101 Token.stringValue() +
"'");
2109 return error(
"DILocation requires line number");
2111 return error(
"DILocation requires a scope");
2114 InlinedAt, ImplicitCode);
2124 if (parseDIExpression(Node))
2131 bool MIParser::parseCFIOffset(
int &
Offset) {
2133 return error(
"expected a cfi offset");
2134 if (Token.integerValue().getMinSignedBits() > 32)
2135 return error(
"expected a 32 bit integer (the cfi offset is too large)");
2136 Offset = (int)Token.integerValue().getExtValue();
2141 bool MIParser::parseCFIRegister(
unsigned &Reg) {
2143 return error(
"expected a cfi register");
2145 if (parseNamedRegister(LLVMReg))
2147 const auto *
TRI = MF.getSubtarget().getRegisterInfo();
2148 assert(
TRI &&
"Expected target register info");
2149 int DwarfReg =
TRI->getDwarfRegNum(LLVMReg,
true);
2151 return error(
"invalid DWARF register");
2157 bool MIParser::parseCFIEscapeValues(std::string &Values) {
2160 return error(
"expected a hexadecimal literal");
2164 if (Value > UINT8_MAX)
2165 return error(
"expected a 8-bit integer (too large)");
2166 Values.push_back(static_cast<uint8_t>(Value));
2173 auto Kind = Token.kind();
2180 if (parseCFIRegister(Reg))
2186 parseCFIOffset(Offset))
2193 parseCFIOffset(Offset))
2195 CFIIndex = MF.addFrameInst(
2199 if (parseCFIRegister(Reg))
2205 if (parseCFIOffset(Offset))
2208 CFIIndex = MF.addFrameInst(
2212 if (parseCFIOffset(Offset))
2214 CFIIndex = MF.addFrameInst(
2219 parseCFIOffset(Offset))
2229 if (parseCFIRegister(Reg))
2237 if (parseCFIRegister(Reg))
2244 parseCFIRegister(Reg2))
2259 if (parseCFIEscapeValues(Values))
2273 switch (Token.kind()) {
2275 BB = dyn_cast_or_null<BasicBlock>(
2278 return error(
Twine(
"use of undefined IR block '") + Token.range() +
"'");
2282 unsigned SlotNumber = 0;
2285 BB =
const_cast<BasicBlock *
>(getIRBlock(SlotNumber, F));
2287 return error(
Twine(
"use of undefined IR block '%ir-block.") +
2288 Twine(SlotNumber) +
"'");
2304 return error(
"expected a global value");
2310 return error(
"expected an IR function reference");
2316 return error(
"expected an IR block reference");
2317 if (parseIRBlock(BB, *F))
2323 if (parseOperandsOffset(Dest))
2332 return error(
"expected syntax intrinsic(@llvm.whatever)");
2335 return error(
"expected syntax intrinsic(@llvm.whatever)");
2337 std::string
Name = Token.stringValue();
2341 return error(
"expected ')' to terminate intrinsic name");
2351 return error(
"unknown intrinsic name");
2363 return error(
"expected syntax intpred(whatever) or floatpred(whatever");
2366 return error(
"whatever");
2389 return error(
"invalid floating-point predicate");
2404 return error(
"invalid integer predicate");
2410 return error(
"predicate should be terminated by ')'.");
2420 return error(
"expected syntax shufflemask(<integer or undef>, ...)");
2427 const APSInt &Int = Token.integerValue();
2430 return error(
"expected integer constant");
2436 return error(
"shufflemask should be terminated by ')'.");
2449 return error(
"expected the name of the target index");
2452 return error(
"use of undefined target index '" + Token.stringValue() +
"'");
2457 if (parseOperandsOffset(Dest))
2462 bool MIParser::parseCustomRegisterMaskOperand(
MachineOperand &Dest) {
2463 assert(Token.stringValue() ==
"CustomRegMask" &&
"Expected a custom RegMask");
2471 return error(
"expected a named register");
2473 if (parseNamedRegister(Reg))
2476 Mask[Reg / 32] |= 1U << (Reg % 32);
2489 bool MIParser::parseLiveoutRegisterMaskOperand(
MachineOperand &Dest) {
2497 return error(
"expected a named register");
2499 if (parseNamedRegister(Reg))
2502 Mask[Reg / 32] |= 1U << (Reg % 32);
2514 bool MIParser::parseMachineOperand(
const unsigned OpCode,
const unsigned OpIdx,
2517 switch (Token.kind()) {
2532 return parseRegisterOperand(Dest, TiedDefIdx);
2534 return parseImmediateOperand(Dest);
2541 return parseFPImmediateOperand(Dest);
2543 return parseMBBOperand(Dest);
2545 return parseStackObjectOperand(Dest);
2547 return parseFixedStackObjectOperand(Dest);
2550 return parseGlobalAddressOperand(Dest);
2552 return parseConstantPoolIndexOperand(Dest);
2554 return parseJumpTableIndexOperand(Dest);
2556 return parseExternalSymbolOperand(Dest);
2558 return parseMCSymbolOperand(Dest);
2560 return parseSubRegisterIndexOperand(Dest);
2563 return parseMetadataOperand(Dest);
2579 return parseCFIOperand(Dest);
2581 return parseBlockAddressOperand(Dest);
2583 return parseIntrinsicOperand(Dest);
2585 return parseTargetIndexOperand(Dest);
2587 return parseLiveoutRegisterMaskOperand(Dest);
2590 return parsePredicateOperand(Dest);
2592 return parseShuffleMaskOperand(Dest);
2600 }
else if (Token.stringValue() ==
"CustomRegMask") {
2601 return parseCustomRegisterMaskOperand(Dest);
2603 return parseTypedImmediateOperand(Dest);
2605 const auto *
TII = MF.getSubtarget().getInstrInfo();
2606 if (
const auto *Formatter =
TII->getMIRFormatter()) {
2607 return parseTargetImmMnemonic(OpCode, OpIdx, Dest, *Formatter);
2613 return error(
"expected a machine operand");
2618 bool MIParser::parseMachineOperandAndTargetFlags(
2619 const unsigned OpCode,
const unsigned OpIdx,
MachineOperand &Dest,
2622 bool HasTargetFlags =
false;
2624 HasTargetFlags =
true;
2629 return error(
"expected the name of the target flag");
2632 return error(
"use of undefined target flag '" + Token.stringValue() +
2639 return error(
"expected the name of the target flag");
2640 unsigned BitFlag = 0;
2642 return error(
"use of undefined target flag '" + Token.stringValue() +
2651 auto Loc = Token.location();
2652 if (parseMachineOperand(OpCode, OpIdx, Dest, TiedDefIdx))
2654 if (!HasTargetFlags)
2657 return error(Loc,
"register operands can't have target flags");
2662 bool MIParser::parseOffset(int64_t &
Offset) {
2669 return error(
"expected an integer literal after '" + Sign +
"'");
2670 if (Token.integerValue().getMinSignedBits() > 64)
2671 return error(
"expected 64-bit integer (too large)");
2672 Offset = Token.integerValue().getExtValue();
2679 bool MIParser::parseAlignment(
unsigned &Alignment) {
2683 return error(
"expected an integer literal after 'align'");
2689 return error(
"expected a power-of-2 literal after 'align'");
2694 bool MIParser::parseAddrspace(
unsigned &Addrspace) {
2698 return error(
"expected an integer literal after 'addrspace'");
2707 if (parseOffset(Offset))
2715 switch (Token.
kind()) {
2721 unsigned SlotNumber = 0;
2746 return ErrCB(Token.
location(),
Twine(
"use of undefined IR value '") + Token.
range() +
"'");
2753 return error(Loc, Msg);
2757 bool MIParser::getUint64(uint64_t &Result) {
2758 if (Token.hasIntegerValue()) {
2759 if (Token.integerValue().getActiveBits() > 64)
2760 return error(
"expected 64-bit integer (too large)");
2761 Result = Token.integerValue().getZExtValue();
2769 return error(
"expected 64-bit integer (too large)");
2781 const auto OldFlags = Flags;
2782 switch (Token.kind()) {
2798 return error(
"use of undefined target MMO flag '" + Token.stringValue() +
2806 if (OldFlags == Flags)
2809 return error(
"duplicate '" + Token.stringValue() +
"' memory operand flag");
2815 switch (Token.kind()) {
2817 PSV = MF.getPSVManager().getStack();
2820 PSV = MF.getPSVManager().getGOT();
2823 PSV = MF.getPSVManager().getJumpTable();
2826 PSV = MF.getPSVManager().getConstantPool();
2830 if (parseFixedStackFrameIndex(FI))
2832 PSV = MF.getPSVManager().getFixedStack(FI);
2838 if (parseStackFrameIndex(FI))
2840 PSV = MF.getPSVManager().getFixedStack(FI);
2846 switch (Token.kind()) {
2852 PSV = MF.getPSVManager().getGlobalValueCallEntry(GV);
2856 PSV = MF.getPSVManager().getExternalSymbolCallEntry(
2857 MF.createExternalSymbolName(Token.stringValue()));
2861 "expected a global value or an external symbol after 'call-entry'");
2866 const auto *
TII = MF.getSubtarget().getInstrInfo();
2867 if (
const auto *Formatter =
TII->getMIRFormatter()) {
2868 if (Formatter->parseCustomPseudoSourceValue(
2869 Token.stringValue(),
MF, PFS, PSV,
2871 return error(Loc, Msg);
2875 return error(
"unable to parse target custom pseudo source value");
2891 if (parseMemoryPseudoSourceValue(PSV))
2894 if (parseOffset(Offset))
2903 return error(
"expected an IR value reference");
2904 const Value *V =
nullptr;
2908 return error(
"expected a pointer IR value");
2911 if (parseOffset(Offset))
2923 return error(
"expected '(' in syncscope");
2926 if (parseStringConstant(SSN))
2931 return error(
"expected ')' in syncscope");
2937 bool MIParser::parseOptionalAtomicOrdering(
AtomicOrdering &Order) {
2956 return error(
"expected an atomic scope, ordering or a size specification");
2963 while (Token.isMemoryOperandFlag()) {
2964 if (parseMemoryOperandFlag(Flags))
2968 (Token.stringValue() !=
"load" && Token.stringValue() !=
"store"))
2969 return error(
"expected 'load' or 'store' memory operation");
2970 if (Token.stringValue() ==
"load")
2984 if (parseOptionalScope(MF.getFunction().getContext(), SSID))
2989 if (parseOptionalAtomicOrdering(Order))
2992 if (parseOptionalAtomicOrdering(FailureOrder))
2997 return error(
"expected the size integer literal or 'unknown-size' after " 2998 "memory operation");
3001 if (getUint64(Size))
3015 if (Token.stringValue() !=
Word)
3016 return error(
Twine(
"expected '") + Word +
"'");
3019 if (parseMachinePointerInfo(Ptr))
3026 switch (Token.kind()) {
3028 if (parseAlignment(BaseAlignment))
3057 return error(
"expected 'align' or '!tbaa' or '!alias.scope' or " 3058 "'!noalias' or '!range'");
3063 Dest = MF.getMachineMemOperand(Ptr, Flags, Size, BaseAlignment, AAInfo, Range,
3064 SSID, Order, FailureOrder);
3071 "Invalid token for a pre- post-instruction symbol!");
3074 return error(
"expected a symbol after 'pre-instr-symbol'");
3075 Symbol = getOrCreateMCSymbol(Token.stringValue());
3081 return error(
"expected ',' before the next machine operand");
3086 bool MIParser::parseHeapAllocMarker(
MDNode *&Node) {
3088 "Invalid token for a heap alloc marker!");
3092 return error(
"expected a MDNode after 'heap-alloc-marker'");
3097 return error(
"expected ',' before the next machine operand");
3107 for (
auto &BB : F) {
3110 int Slot = MST.getLocalSlot(&BB);
3113 Slots2BasicBlocks.
insert(std::make_pair(
unsigned(Slot), &BB));
3120 auto BlockInfo = Slots2BasicBlocks.
find(Slot);
3121 if (BlockInfo == Slots2BasicBlocks.
end())
3123 return BlockInfo->second;
3126 const BasicBlock *MIParser::getIRBlock(
unsigned Slot) {
3127 if (Slots2BasicBlocks.empty())
3133 if (&F == &MF.getFunction())
3134 return getIRBlock(Slot);
3146 return MF.getContext().getOrCreateSymbol(Name);
3149 bool MIParser::parseStringConstant(std::string &Result) {
3151 return error(
"expected string constant");
3152 Result = Token.stringValue();
3160 return MIParser(PFS, Error, Src).parseBasicBlockDefinitions(PFS.
MBBSlots);
3165 return MIParser(PFS, Error, Src).parseBasicBlocks();
3171 return MIParser(PFS, Error, Src).parseStandaloneMBB(MBB);
3177 return MIParser(PFS, Error, Src).parseStandaloneRegister(Reg);
3183 return MIParser(PFS, Error, Src).parseStandaloneNamedRegister(Reg);
3189 return MIParser(PFS, Error, Src).parseStandaloneVirtualRegister(Info);
3195 return MIParser(PFS, Error, Src).parseStandaloneStackObject(FI);
3200 return MIParser(PFS, Error, Src).parseStandaloneMDNode(Node);
3208 ErrorCallback(Loc, Msg);
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface ...
bool isFPPredicate() const
StringRef stringValue() const
Return the token's string value.
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
Return an array that contains the direct target flag values and their names.
virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
bool parseMachineBasicBlockDefinitions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine basic block definitions, and skip the machine instructions.
static void initSlots2BasicBlocks(const Function &F, DenseMap< unsigned, const BasicBlock *> &Slots2BasicBlocks)
A common definition of LaneBitmask for use in TableGen and CodeGen.
bool getTargetIndex(StringRef Name, int &Index)
Try to convert a name of target index to the corresponding target index.
static LLT pointer(unsigned AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space.
bool is(TokenKind K) const
uint64_t getZExtValue() const
Get zero extended value.
static MachineOperand CreateCImm(const ConstantInt *CI)
DenseMap< unsigned, unsigned > JumpTableSlots
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
const T & back() const
back - Get the last element.
MDNode * Scope
The tag for alias scope specification (used with noalias).
function_ref< bool(StringRef::iterator Loc, const Twine &)> ErrorCallbackType
Atomic ordering constants.
DenseMap< unsigned, unsigned > ConstantPoolSlots
This class represents lattice values for constants.
MDNode * TBAA
The tag for type-based alias analysis.
Constant * parseConstantValue(StringRef Asm, SMDiagnostic &Err, const Module &M, const SlotMapping *Slots=nullptr)
Parse a type and a constant value in the given string.
void setTargetFlags(unsigned F)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
static bool parseGlobalValue(const MIToken &Token, PerFunctionMIParsingState &PFS, GlobalValue *&GV, ErrorCallbackType ErrCB)
A Module instance is used to store all the information related to an LLVM module. ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
static BranchProbability getRaw(uint32_t N)
void setHeapAllocMarker(MachineFunction &MF, MDNode *MD)
Set a marker on instructions that denotes where we should create and emit heap alloc site labels...
static MCCFIInstruction createRememberState(MCSymbol *L)
.cfi_remember_state Save all current rules for all registers.
void push_back(const T &Elt)
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
const MCPhysReg * getImplicitUses() const
Return a list of registers that are potentially read by any instance of this machine instruction...
Describe properties that are true of each instruction in the target description file.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
SyncScope::ID getOrInsertSyncScopeID(StringRef SSN)
getOrInsertSyncScopeID - Maps synchronization scope name to synchronization scope ID...
unsigned getNumRegBanks() const
Get the total number of register banks.
int getLocalSlot(const Value *V)
Return the slot number of the specified local value.
bool getMMOTargetFlag(StringRef Name, MachineMemOperand::Flags &Flag)
Try to convert a name of a MachineMemOperand target flag to the corresponding target flag...
An efficient, type-erasing, non-owning reference to a callable.
static bool verifyScalarSize(uint64_t Size)
static bool verifyVectorElementCount(uint64_t NumElts)
0 1 0 0 True if ordered and less than
ArrayRef< std::pair< unsigned, const char * > > getSerializableBitmaskMachineOperandTargetFlags() const override
Return an array that contains the bitmask target flag values and their names.
iterator find(StringRef Key)
DenseMap< unsigned, int > StackObjectSlots
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
1 1 1 0 True if unordered or not equal
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
virtual const RegisterBankInfo * getRegBankInfo() const
If the information for the register banks is available, return it.
unsigned const TargetRegisterInfo * TRI
Manage lifetime of a slot tracker for printing IR.
bool parseMBBReference(PerFunctionMIParsingState &PFS, MachineBasicBlock *&MBB, StringRef Src, SMDiagnostic &Error)
static bool getUnsigned(const MIToken &Token, unsigned &Result, ErrorCallbackType ErrCB)
const TargetRegisterClass * RC
void setTarget(const TargetSubtargetInfo &NewSubtarget)
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, const DebugLoc &DL, bool NoImp=false)
CreateMachineInstr - Allocate a new MachineInstr.
StringRef lexMIToken(StringRef Source, MIToken &Token, function_ref< void(StringRef::iterator, const Twine &)> ErrorCallback)
Consume a single machine instruction token in the given source and return the remaining source string...
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment)
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
StringSwitch & Case(StringLiteral S, T Value)
static MachineOperand CreateIntrinsicID(Intrinsic::ID ID)
const TargetRegisterClass * getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
unsigned getBitWidth() const
Return the number of bits in the APInt.
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register)
.cfi_undefined From now on the previous value of Register can't be restored anymore.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
const char * getRegClassName(const TargetRegisterClass *Class) const
Returns the name of the register class.
1 0 0 1 True if unordered or equal
Holds all the information related to register banks.
void guessSuccessors(const MachineBasicBlock &MBB, SmallVectorImpl< MachineBasicBlock *> &Result, bool &IsFallthrough)
Determine a possible list of successors of a basic block based on the basic block machine operand bei...
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
std::map< unsigned, TrackingMDNodeRef > MetadataNodes
A description of a memory reference used in the backend.
std::string toString(Error E)
Write all error messages (if any) in E to a string.
StringMap< VRegInfo * > VRegInfosNamed
static bool parseIRConstant(StringRef::iterator Loc, StringRef StringValue, PerFunctionMIParsingState &PFS, const Constant *&C, ErrorCallbackType ErrCB)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const HexagonInstrInfo * TII
static const BasicBlock * getIRBlockFromSlot(unsigned Slot, const DenseMap< unsigned, const BasicBlock *> &Slots2BasicBlocks)
static MachineOperand CreateGA(const GlobalValue *GV, int64_t Offset, unsigned TargetFlags=0)
LLVM_NODISCARD StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
VRegInfo & getVRegInfoNamed(StringRef RegName)
static bool verifyAddrSpace(uint64_t AddrSpace)
support::ulittle32_t Word
LLVM_NODISCARD R Default(T Value)
static constexpr LaneBitmask getAll()
0 1 0 1 True if ordered and less than or equal
The memory access is dereferenceable (i.e., doesn't trap).
static MachineOperand CreateRegMask(const uint32_t *Mask)
CreateRegMask - Creates a register mask operand referencing Mask.
static MachineOperand CreateRegLiveOut(const uint32_t *Mask)
mir Rename Register Operands
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
static MachineOperand CreateTargetIndex(unsigned Idx, int64_t Offset, unsigned TargetFlags=0)
This file implements a class to represent arbitrary precision integral constant values and operations...
AtomicOrdering
Atomic ordering for LLVM's memory model.
unsigned getNumRegClasses() const
DenseMap< unsigned, int > FixedStackObjectSlots
static std::string getRegisterName(const TargetRegisterInfo *TRI, unsigned Reg)
const MemoryBuffer * getMemoryBuffer(unsigned i) const
Type * getType() const
All values are typed, get the type of this value.
virtual unsigned lookupName(const char *Name, unsigned Len) const =0
Look up target intrinsic by name.
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type. ...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
LLVM_NODISCARD size_t size() const
size - Get the string size.
const char * getSubRegIndexName(unsigned SubIdx) const
Return the human-readable symbolic target-specific name for the specified SubRegIndex.
void setPostInstrSymbol(MachineFunction &MF, MCSymbol *Symbol)
Set a symbol that will be emitted just after the instruction itself.
virtual const TargetInstrInfo * getInstrInfo() const
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
bool parseVirtualRegisterReference(PerFunctionMIParsingState &PFS, VRegInfo *&Info, StringRef Src, SMDiagnostic &Error)
static MachineOperand CreatePredicate(unsigned Pred)
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
union llvm::VRegInfo::@178 D
Analysis containing CSE Info
void normalizeSuccProbs()
Normalize probabilities of all successors so that the sum of them becomes one.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
const Value * getIRValue(unsigned Slot)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Flag
These should be considered private to the implementation of the MCInstrDesc class.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
iterator find(const_arg_type_t< KeyT > Val)
unsigned getMainFileID() const
bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
bool getDirectTargetFlag(StringRef Name, unsigned &Flag)
Try to convert a name of a direct target flag to the corresponding target flag.
The memory access is volatile.
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register)
.cfi_same_value Current value of Register is the same as in the previous frame.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
A switch()-like statement whose cases are string literals.
bool parseStackObjectReference(PerFunctionMIParsingState &PFS, int &FI, StringRef Src, SMDiagnostic &Error)
static MCCFIInstruction createNegateRAState(MCSymbol *L)
.cfi_negate_ra_state AArch64 negate RA state.
const MCPhysReg * getImplicitDefs() const
Return a list of registers that are potentially written by any instance of this machine instruction...
const uint32_t * getRegMask(StringRef Identifier)
Check if the given identifier is a name of a register mask.
unsigned const MachineRegisterInfo * MRI
StringRef getName() const
Return the name of the corresponding LLVM basic block, or an empty string.
static const char * printImplicitRegisterFlag(const MachineOperand &MO)
static MCCFIInstruction createDefCfa(MCSymbol *L, unsigned Register, int Offset)
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it...
bool getBitmaskTargetFlag(StringRef Name, unsigned &Flag)
Try to convert a name of a bitmask target flag to the corresponding target flag.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
static Intrinsic::ID lookupIntrinsicID(StringRef Name)
This does the actual lookup of an intrinsic ID which matches the given function name.
LLVM Basic Block Representation.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This is an important class for using LLVM in a threaded context.
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
static MachineOperand CreateJTI(unsigned Idx, unsigned TargetFlags=0)
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
static MachineOperand CreateFPImm(const ConstantFP *CFP)
size_t size() const
size - Get the array size.
static MCCFIInstruction createWindowSave(MCSymbol *L)
.cfi_window_save SPARC register window is saved.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
const TargetRegisterClass * getRegClass(StringRef Name)
Check if the given identifier is a name of a register class.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isPointerTy() const
True if this is an instance of PointerType.
unsigned getOperationEncoding(StringRef OperationEncodingString)
const MCPhysReg * ImplicitDefs
void setType(unsigned VReg, LLT Ty)
Set the low-level type of VReg to Ty.
static MachineOperand CreateCPI(unsigned Idx, int Offset, unsigned TargetFlags=0)
BumpPtrAllocator Allocator
bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, unsigned &Reg, StringRef Src, SMDiagnostic &Error)
void setFlag(MIFlag Flag)
Set a MI flag.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register...
bool getRegisterByName(StringRef RegName, unsigned &Reg)
Try to convert a register name to a register number.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register)
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...
0 1 1 1 True if ordered (no nans)
The memory access is non-temporal.
std::vector< GlobalValue * > GlobalValues
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
void setOffset(int64_t Offset)
1 1 1 1 Always true (always folded)
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
void incorporateFunction(const Function &F)
Incorporate the given function.
const SlotMapping & IRSlots
const APSInt & integerValue() const
static MCCFIInstruction createRestoreState(MCSymbol *L)
.cfi_restore_state Restore the previously saved state.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This class contains a discriminated union of information about pointers in memory operands...
1 1 0 1 True if unordered, less than, or equal
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None) const
Return an SMDiagnostic at the specified location with the specified string.
Synchronized with respect to all concurrently executing threads.
static MachineOperand CreateES(const char *SymName, unsigned TargetFlags=0)
bool parseMachineInstructions(PerFunctionMIParsingState &PFS, StringRef Src, SMDiagnostic &Error)
Parse the machine instructions.
TargetIntrinsicInfo - Interface to description of machine instruction set.
Struct that holds a reference to a particular GUID in a global value summary.
The memory access writes data.
int64_t getExtValue() const
Get the correctly-extended int64_t value.
0 0 1 0 True if ordered and greater than
const RegisterBank * getRegBank(StringRef Name)
Check if the given identifier is a name of a register bank.
unsigned createIncompleteVirtualRegister(StringRef Name="")
Creates a new virtual register that has no register class, register bank or size assigned yet...
static MachineOperand CreateMetadata(const MDNode *Meta)
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
static bool parseIRValue(const MIToken &Token, PerFunctionMIParsingState &PFS, const Value *&V, ErrorCallbackType ErrCB)
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
bool hasIntegerValue() const
Align max(MaybeAlign Lhs, Align Rhs)
void setFlags(unsigned flags)
RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
enum llvm::VRegInfo::uint8_t Kind
MachineOperand class - Representation of each machine instruction operand.
1 1 0 0 True if unordered or less than
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
static bool isImplicitOperandIn(const MachineOperand &ImplicitOperand, ArrayRef< ParsedMachineOperand > Operands)
Return true if the parsed machine operands contain a given machine operand.
StringRef getMessage() const
DenseMap< unsigned, const Value * > Slots2Values
Maps from slot numbers to function's unnamed values.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
MDNode * NoAlias
The tag specifying the noalias scope.
This class implements the register bank concept.
bool parseInstrName(StringRef InstrName, unsigned &OpCode)
Try to convert an instruction name to an opcode.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
ValueSymbolTable * getValueSymbolTable()
getSymbolTable() - Return the symbol table if any, otherwise nullptr.
StringRef::iterator location() const
bool isIntPredicate() const
Target - Wrapper for Target specific information.
Class for arbitrary precision integers.
Special value supplied for machine level alias analysis.
const char * getName(MCRegister RegNo) const
Return the human-readable symbolic target-specific name for the specified physical register...
This struct contains the mappings from the slot numbers to unnamed metadata nodes, global values and types.
bool parseMDNode(PerFunctionMIParsingState &PFS, MDNode *&Node, StringRef Src, SMDiagnostic &Error)
static SMLoc getFromPointer(const char *Ptr)
Flags
Flags values. These may be or'd together.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
TargetSubtargetInfo - Generic base class for all target subtargets.
unsigned getSubRegIndex(StringRef Name)
Check if the given identifier is a name of a subregister index.
bool Explicit
VReg was explicitly specified in the .mir file.
Representation of each machine instruction.
const char * getBufferEnd() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
void setPreInstrSymbol(MachineFunction &MF, MCSymbol *Symbol)
Set a symbol that will be emitted just prior to the instruction itself.
LLVM_NODISCARD bool empty() const
unsigned greater or equal
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value...
This file provides utility analysis objects describing memory locations.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
static MachineOperand CreateCFIIndex(unsigned CFIIndex)
static MachineOperand CreateImm(int64_t Val)
VRegInfo & getVRegInfo(unsigned Num)
The memory access always returns the same value (or traps).
bool isCall() const
Return true if the instruction is a call.
0 1 1 0 True if ordered and operands are unequal
DenseMap< unsigned, MachineBasicBlock * > MBBSlots
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static MachineOperand CreateShuffleMask(ArrayRef< int > Mask)
unsigned getNumSubRegIndices() const
Return the number of sub-register indices understood by the target.
1 0 1 0 True if unordered or greater than
constexpr bool isUInt< 16 >(uint64_t x)
const char * getBufferStart() const
Value * lookup(StringRef Name) const
This method finds the value with the given Name in the the symbol table.
std::string str() const
Return the twine contents as a std::string.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void insert(iterator MBBI, MachineBasicBlock *MBB)
void setMemRefs(MachineFunction &MF, ArrayRef< MachineMemOperand *> MemRefs)
Assign this MachineInstr's memory reference descriptor list.
PerFunctionMIParsingState(MachineFunction &MF, SourceMgr &SM, const SlotMapping &IRSlots, PerTargetMIParsingState &Target)
0 0 0 1 True if ordered and equal
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
static MachineOperand CreateMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0)
A token produced by the machine instruction lexer.
1 0 1 1 True if unordered, greater than, or equal
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Lightweight error class with error context and mandatory checking.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
unsigned getAttributeEncoding(StringRef EncodingString)
static MachineOperand CreateBA(const BlockAddress *BA, int64_t Offset, unsigned TargetFlags=0)
StringRef - Represent a constant reference to a string, i.e.
static bool getHexUint(const MIToken &Token, APInt &Result)
static LLT vector(uint16_t NumElements, unsigned ScalarSizeInBits)
Get a low-level vector of some number of elements and element width.
const RegisterBank * RegBank
static llvm::Error parse(DataExtractor &Data, uint64_t BaseAddr, LineEntryCallback const &Callback)
void setRegClassOrRegBank(unsigned Reg, const RegClassOrRegBank &RCOrRB)
Represents a location in source code.
PerTargetMIParsingState & Target
void setIsDebug(bool Val=true)
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals)
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
DenseMap< unsigned, VRegInfo * > VRegInfos
bool parseRegisterReference(PerFunctionMIParsingState &PFS, unsigned &Reg, StringRef Src, SMDiagnostic &Error)
0 0 1 1 True if ordered and greater than or equal
static void mapValueToSlot(const Value *V, ModuleSlotTracker &MST, DenseMap< unsigned, const Value *> &Slots2Values)
static void initSlots2Values(const Function &F, DenseMap< unsigned, const Value *> &Slots2Values)
Creates the mapping from slot numbers to function's unnamed IR values.
static MachineOperand CreateFI(int Idx)
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2)
.cfi_register Previous value of Register1 is saved in register Register2.
iterator_range< arg_iterator > args()
0 0 0 0 Always false (always folded)
bool empty() const
empty - Check if the array is empty.
const MCPhysReg * ImplicitUses
static MachineOperand CreateMCSymbol(MCSymbol *Sym, unsigned TargetFlags=0)
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.