45 int64_t Res = cast<MCConstantExpr>(
E)->getValue();
46 return Res < 0 ? -1 : Res;
53 if (Name ==
"lt")
return 0;
54 if (Name ==
"gt")
return 1;
55 if (Name ==
"eq")
return 2;
56 if (Name ==
"so")
return 3;
57 if (Name ==
"un")
return 3;
59 if (Name ==
"cr0")
return 0;
60 if (Name ==
"cr1")
return 1;
61 if (Name ==
"cr2")
return 2;
62 if (Name ==
"cr3")
return 3;
63 if (Name ==
"cr4")
return 4;
64 if (Name ==
"cr5")
return 5;
65 if (Name ==
"cr6")
return 6;
66 if (Name ==
"cr7")
return 7;
80 if (LHSVal < 0 || RHSVal < 0)
89 return Res < 0 ? -1 : Res;
106 bool isPPC64()
const {
return IsPPC64; }
107 bool isDarwin()
const {
return IsDarwin; }
111 bool ParseRegister(
unsigned &RegNo,
SMLoc &StartLoc,
SMLoc &EndLoc)
override;
116 bool ParseExpression(
const MCExpr *&EVal);
117 bool ParseDarwinExpression(
const MCExpr *&EVal);
122 bool ParseDirectiveTC(
unsigned Size,
AsmToken ID);
123 bool ParseDirectiveMachine(
SMLoc L);
124 bool ParseDarwinDirectiveMachine(
SMLoc L);
125 bool ParseDirectiveAbiVersion(
SMLoc L);
126 bool ParseDirectiveLocalEntry(
SMLoc L);
128 bool MatchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
131 bool MatchingInlineAsm)
override;
138 #define GET_ASSEMBLER_HEADER 139 #include "PPCGenAsmMatcher.inc" 154 setAvailableFeatures(ComputeAvailableFeatures(STI.
getFeatureBits()));
160 bool ParseDirective(
AsmToken DirectiveID)
override;
163 unsigned Kind)
override;
181 SMLoc StartLoc, EndLoc;
206 struct TLSRegOp TLSReg;
213 StartLoc = o.StartLoc;
221 case ContextImmediate:
235 void operator delete(
void *p) { ::operator
delete(p); }
238 SMLoc getStartLoc()
const override {
return StartLoc; }
241 SMLoc getEndLoc()
const override {
return EndLoc; }
248 bool isPPC64()
const {
return IsPPC64; }
250 int64_t getImm()
const {
251 assert(Kind == Immediate &&
"Invalid access!");
254 int64_t getImmS16Context()
const {
255 assert((Kind == Immediate || Kind == ContextImmediate) &&
257 if (Kind == Immediate)
259 return static_cast<int16_t
>(Imm.Val);
261 int64_t getImmU16Context()
const {
262 assert((Kind == Immediate || Kind == ContextImmediate) &&
268 assert(Kind == Expression &&
"Invalid access!");
272 int64_t getExprCRVal()
const {
273 assert(Kind == Expression &&
"Invalid access!");
277 const MCExpr *getTLSReg()
const {
278 assert(Kind == TLSRegister &&
"Invalid access!");
282 unsigned getReg()
const override {
283 assert(isRegNumber() &&
"Invalid access!");
284 return (
unsigned) Imm.Val;
287 unsigned getVSReg()
const {
288 assert(isVSRegNumber() &&
"Invalid access!");
289 return (
unsigned) Imm.Val;
292 unsigned getCCReg()
const {
293 assert(isCCRegNumber() &&
"Invalid access!");
294 return (
unsigned) (Kind == Immediate ? Imm.Val : Expr.CRVal);
297 unsigned getCRBit()
const {
298 assert(isCRBitNumber() &&
"Invalid access!");
299 return (
unsigned) (Kind == Immediate ? Imm.Val : Expr.CRVal);
302 unsigned getCRBitMask()
const {
303 assert(isCRBitMask() &&
"Invalid access!");
304 return 7 - countTrailingZeros<uint64_t>(Imm.Val);
307 bool isToken()
const override {
return Kind == Token; }
308 bool isImm()
const override {
309 return Kind == Immediate || Kind == Expression;
311 bool isU1Imm()
const {
return Kind == Immediate && isUInt<1>(getImm()); }
312 bool isU2Imm()
const {
return Kind == Immediate && isUInt<2>(getImm()); }
313 bool isU3Imm()
const {
return Kind == Immediate && isUInt<3>(getImm()); }
314 bool isU4Imm()
const {
return Kind == Immediate && isUInt<4>(getImm()); }
315 bool isU5Imm()
const {
return Kind == Immediate && isUInt<5>(getImm()); }
316 bool isS5Imm()
const {
return Kind == Immediate && isInt<5>(getImm()); }
317 bool isU6Imm()
const {
return Kind == Immediate && isUInt<6>(getImm()); }
318 bool isU6ImmX2()
const {
return Kind == Immediate &&
319 isUInt<6>(getImm()) &&
320 (getImm() & 1) == 0; }
321 bool isU7Imm()
const {
return Kind == Immediate && isUInt<7>(getImm()); }
322 bool isU7ImmX4()
const {
return Kind == Immediate &&
323 isUInt<7>(getImm()) &&
324 (getImm() & 3) == 0; }
325 bool isU8Imm()
const {
return Kind == Immediate &&
isUInt<8>(getImm()); }
326 bool isU8ImmX8()
const {
return Kind == Immediate &&
328 (getImm() & 7) == 0; }
330 bool isU10Imm()
const {
return Kind == Immediate && isUInt<10>(getImm()); }
331 bool isU12Imm()
const {
return Kind == Immediate && isUInt<12>(getImm()); }
332 bool isU16Imm()
const {
337 case ContextImmediate:
343 bool isS16Imm()
const {
348 case ContextImmediate:
354 bool isS16ImmX4()
const {
return Kind == Expression ||
355 (Kind == Immediate &&
isInt<16>(getImm()) &&
356 (getImm() & 3) == 0); }
357 bool isS16ImmX16()
const {
return Kind == Expression ||
358 (Kind == Immediate &&
isInt<16>(getImm()) &&
359 (getImm() & 15) == 0); }
360 bool isS17Imm()
const {
365 case ContextImmediate:
366 return isInt<17>(getImmS16Context());
371 bool isTLSReg()
const {
return Kind == TLSRegister; }
372 bool isDirectBr()
const {
373 if (Kind == Expression)
375 if (Kind != Immediate)
378 if ((getImm() & 3) != 0)
380 if (isInt<26>(getImm()))
384 if (
isUInt<32>(getImm()) && isInt<26>(static_cast<int32_t>(getImm())))
389 bool isCondBr()
const {
return Kind == Expression ||
390 (Kind == Immediate &&
isInt<16>(getImm()) &&
391 (getImm() & 3) == 0); }
392 bool isRegNumber()
const {
return Kind == Immediate && isUInt<5>(getImm()); }
393 bool isVSRegNumber()
const {
394 return Kind == Immediate && isUInt<6>(getImm());
396 bool isCCRegNumber()
const {
return (Kind == Expression
397 && isUInt<3>(getExprCRVal())) ||
399 && isUInt<3>(getImm())); }
400 bool isCRBitNumber()
const {
return (Kind == Expression
401 && isUInt<5>(getExprCRVal())) ||
403 && isUInt<5>(getImm())); }
404 bool isCRBitMask()
const {
return Kind == Immediate &&
isUInt<8>(getImm()) &&
406 bool isATBitsAsHint()
const {
return false; }
407 bool isMem()
const override {
return false; }
408 bool isReg()
const override {
return false; }
410 void addRegOperands(
MCInst &Inst,
unsigned N)
const {
414 void addRegGPRCOperands(
MCInst &Inst,
unsigned N)
const {
415 assert(N == 1 &&
"Invalid number of operands!");
419 void addRegGPRCNoR0Operands(
MCInst &Inst,
unsigned N)
const {
420 assert(N == 1 &&
"Invalid number of operands!");
424 void addRegG8RCOperands(
MCInst &Inst,
unsigned N)
const {
425 assert(N == 1 &&
"Invalid number of operands!");
429 void addRegG8RCNoX0Operands(
MCInst &Inst,
unsigned N)
const {
430 assert(N == 1 &&
"Invalid number of operands!");
434 void addRegGxRCOperands(
MCInst &Inst,
unsigned N)
const {
436 addRegG8RCOperands(Inst, N);
438 addRegGPRCOperands(Inst, N);
441 void addRegGxRCNoR0Operands(
MCInst &Inst,
unsigned N)
const {
443 addRegG8RCNoX0Operands(Inst, N);
445 addRegGPRCNoR0Operands(Inst, N);
448 void addRegF4RCOperands(
MCInst &Inst,
unsigned N)
const {
449 assert(N == 1 &&
"Invalid number of operands!");
453 void addRegF8RCOperands(
MCInst &Inst,
unsigned N)
const {
454 assert(N == 1 &&
"Invalid number of operands!");
458 void addRegVFRCOperands(
MCInst &Inst,
unsigned N)
const {
459 assert(N == 1 &&
"Invalid number of operands!");
463 void addRegVRRCOperands(
MCInst &Inst,
unsigned N)
const {
464 assert(N == 1 &&
"Invalid number of operands!");
468 void addRegVSRCOperands(
MCInst &Inst,
unsigned N)
const {
469 assert(N == 1 &&
"Invalid number of operands!");
473 void addRegVSFRCOperands(
MCInst &Inst,
unsigned N)
const {
474 assert(N == 1 &&
"Invalid number of operands!");
478 void addRegVSSRCOperands(
MCInst &Inst,
unsigned N)
const {
479 assert(N == 1 &&
"Invalid number of operands!");
483 void addRegQFRCOperands(
MCInst &Inst,
unsigned N)
const {
484 assert(N == 1 &&
"Invalid number of operands!");
488 void addRegQSRCOperands(
MCInst &Inst,
unsigned N)
const {
489 assert(N == 1 &&
"Invalid number of operands!");
493 void addRegQBRCOperands(
MCInst &Inst,
unsigned N)
const {
494 assert(N == 1 &&
"Invalid number of operands!");
498 void addRegSPE4RCOperands(
MCInst &Inst,
unsigned N)
const {
499 assert(N == 1 &&
"Invalid number of operands!");
503 void addRegSPERCOperands(
MCInst &Inst,
unsigned N)
const {
504 assert(N == 1 &&
"Invalid number of operands!");
508 void addRegCRBITRCOperands(
MCInst &Inst,
unsigned N)
const {
509 assert(N == 1 &&
"Invalid number of operands!");
513 void addRegCRRCOperands(
MCInst &Inst,
unsigned N)
const {
514 assert(N == 1 &&
"Invalid number of operands!");
518 void addCRBitMaskOperands(
MCInst &Inst,
unsigned N)
const {
519 assert(N == 1 &&
"Invalid number of operands!");
523 void addImmOperands(
MCInst &Inst,
unsigned N)
const {
524 assert(N == 1 &&
"Invalid number of operands!");
525 if (Kind == Immediate)
531 void addS16ImmOperands(
MCInst &Inst,
unsigned N)
const {
532 assert(N == 1 &&
"Invalid number of operands!");
537 case ContextImmediate:
546 void addU16ImmOperands(
MCInst &Inst,
unsigned N)
const {
547 assert(N == 1 &&
"Invalid number of operands!");
552 case ContextImmediate:
561 void addBranchTargetOperands(
MCInst &Inst,
unsigned N)
const {
562 assert(N == 1 &&
"Invalid number of operands!");
563 if (Kind == Immediate)
569 void addTLSRegOperands(
MCInst &Inst,
unsigned N)
const {
570 assert(N == 1 &&
"Invalid number of operands!");
575 assert(Kind == Token &&
"Invalid access!");
581 static std::unique_ptr<PPCOperand> CreateToken(
StringRef Str,
SMLoc S,
583 auto Op = make_unique<PPCOperand>(Token);
584 Op->Tok.Data = Str.
data();
585 Op->Tok.Length = Str.
size();
588 Op->IsPPC64 = IsPPC64;
592 static std::unique_ptr<PPCOperand>
599 void *Mem = ::operator
new(
sizeof(PPCOperand) + Str.
size());
600 std::unique_ptr<PPCOperand>
Op(
new (Mem) PPCOperand(Token));
601 Op->Tok.Data =
reinterpret_cast<const char *
>(Op.get() + 1);
602 Op->Tok.Length = Str.
size();
606 Op->IsPPC64 = IsPPC64;
610 static std::unique_ptr<PPCOperand> CreateImm(int64_t Val,
SMLoc S,
SMLoc E,
612 auto Op = make_unique<PPCOperand>(Immediate);
616 Op->IsPPC64 = IsPPC64;
620 static std::unique_ptr<PPCOperand> CreateExpr(
const MCExpr *Val,
SMLoc S,
621 SMLoc E,
bool IsPPC64) {
622 auto Op = make_unique<PPCOperand>(Expression);
627 Op->IsPPC64 = IsPPC64;
631 static std::unique_ptr<PPCOperand>
633 auto Op = make_unique<PPCOperand>(TLSRegister);
634 Op->TLSReg.Sym = Sym;
637 Op->IsPPC64 = IsPPC64;
641 static std::unique_ptr<PPCOperand>
642 CreateContextImm(int64_t Val,
SMLoc S,
SMLoc E,
bool IsPPC64) {
643 auto Op = make_unique<PPCOperand>(ContextImmediate);
647 Op->IsPPC64 = IsPPC64;
651 static std::unique_ptr<PPCOperand>
654 return CreateImm(CE->getValue(), S,
E, IsPPC64);
658 return CreateTLSReg(SRE, S, E, IsPPC64);
660 if (
const PPCMCExpr *TE = dyn_cast<PPCMCExpr>(Val)) {
662 if (TE->evaluateAsConstant(Res))
663 return CreateContextImm(Res, S, E, IsPPC64);
666 return CreateExpr(Val, S, E, IsPPC64);
678 case ContextImmediate:
697 if (
const MCUnaryExpr *UnExpr = dyn_cast<MCUnaryExpr>(Expr)) {
702 }
else if (
const MCBinaryExpr *BinExpr = dyn_cast<MCBinaryExpr>(Expr)) {
705 BinExpr->getLHS(), Ctx);
713 void PPCAsmParser::ProcessInstruction(
MCInst &Inst,
722 TmpInst.
setOpcode((Opcode == PPC::DCBTx || Opcode == PPC::DCBTT) ?
723 PPC::DCBT : PPC::DCBTST);
725 (Opcode == PPC::DCBTx || Opcode == PPC::DCBTSTx) ? 0 : 16));
742 case PPC::DCBTSTDS: {
755 if (Opcode == PPC::DCBFL)
757 else if (Opcode == PPC::DCBFLP)
818 TmpInst.
setOpcode(Opcode == PPC::EXTLWI? PPC::RLWINM : PPC::RLWINMo);
832 TmpInst.
setOpcode(Opcode == PPC::EXTRWI? PPC::RLWINM : PPC::RLWINMo);
846 TmpInst.
setOpcode(Opcode == PPC::INSLWI? PPC::RLWIMI : PPC::RLWIMIo);
861 TmpInst.
setOpcode(Opcode == PPC::INSRWI? PPC::RLWIMI : PPC::RLWIMIo);
875 TmpInst.
setOpcode(Opcode == PPC::ROTRWI? PPC::RLWINM : PPC::RLWINMo);
888 TmpInst.
setOpcode(Opcode == PPC::SLWI? PPC::RLWINM : PPC::RLWINMo);
901 TmpInst.
setOpcode(Opcode == PPC::SRWI? PPC::RLWINM : PPC::RLWINMo);
914 TmpInst.
setOpcode(Opcode == PPC::CLRRWI? PPC::RLWINM : PPC::RLWINMo);
924 case PPC::CLRLSLWIo: {
928 TmpInst.
setOpcode(Opcode == PPC::CLRLSLWI? PPC::RLWINM : PPC::RLWINMo);
942 TmpInst.
setOpcode(Opcode == PPC::EXTLDI? PPC::RLDICR : PPC::RLDICRo);
955 TmpInst.
setOpcode(Opcode == PPC::EXTRDI? PPC::RLDICL : PPC::RLDICLo);
968 TmpInst.
setOpcode(Opcode == PPC::INSRDI? PPC::RLDIMI : PPC::RLDIMIo);
981 TmpInst.
setOpcode(Opcode == PPC::ROTRDI? PPC::RLDICL : PPC::RLDICLo);
993 TmpInst.
setOpcode(Opcode == PPC::SLDI? PPC::RLDICR : PPC::RLDICRo);
1001 case PPC::SUBPCIS: {
1014 TmpInst.
setOpcode(Opcode == PPC::SRDI? PPC::RLDICL : PPC::RLDICLo);
1023 case PPC::CLRRDIo: {
1026 TmpInst.
setOpcode(Opcode == PPC::CLRRDI? PPC::RLDICR : PPC::RLDICRo);
1035 case PPC::CLRLSLDIo: {
1039 TmpInst.
setOpcode(Opcode == PPC::CLRLSLDI? PPC::RLDIC : PPC::RLDICo);
1048 case PPC::RLWINMobm: {
1055 TmpInst.
setOpcode(Opcode == PPC::RLWINMbm ? PPC::RLWINM : PPC::RLWINMo);
1065 case PPC::RLWIMIobm: {
1072 TmpInst.
setOpcode(Opcode == PPC::RLWIMIbm ? PPC::RLWIMI : PPC::RLWIMIo);
1083 case PPC::RLWNMobm: {
1090 TmpInst.
setOpcode(Opcode == PPC::RLWNMbm ? PPC::RLWNM : PPC::RLWNMo);
1100 if (getSTI().getFeatureBits()[PPC::FeatureMFTB]) {
1107 case PPC::CP_COPY_FIRST: {
1117 case PPC::CP_PASTEx :
1118 case PPC::CP_PASTE_LAST: {
1120 TmpInst.
setOpcode(Opcode == PPC::CP_PASTEx ?
1121 PPC::CP_PASTE : PPC::CP_PASTEo);
1133 unsigned VariantID = 0);
1135 bool PPCAsmParser::MatchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
1138 bool MatchingInlineAsm) {
1141 switch (MatchInstructionImpl(Operands, Inst,
ErrorInfo, MatchingInlineAsm)) {
1144 ProcessInstruction(Inst, Operands);
1148 case Match_MissingFeature:
1149 return Error(IDLoc,
"instruction use requires an option to be enabled");
1150 case Match_MnemonicFail: {
1151 uint64_t FBS = ComputeAvailableFeatures(getSTI().getFeatureBits());
1153 ((PPCOperand &)*Operands[0]).
getToken(), FBS);
1154 return Error(IDLoc,
"invalid instruction" + Suggestion,
1155 ((PPCOperand &)*Operands[0]).getLocRange());
1157 case Match_InvalidOperand: {
1158 SMLoc ErrorLoc = IDLoc;
1161 return Error(IDLoc,
"too few operands for instruction");
1163 ErrorLoc = ((PPCOperand &)*Operands[
ErrorInfo]).getStartLoc();
1164 if (ErrorLoc ==
SMLoc()) ErrorLoc = IDLoc;
1167 return Error(ErrorLoc,
"invalid operand for instruction");
1178 RegNo = isPPC64()? PPC::LR8 : PPC::LR;
1181 RegNo = isPPC64()? PPC::CTR8 : PPC::CTR;
1184 RegNo = PPC::VRSAVE;
1213 ParseRegister(
unsigned &RegNo,
SMLoc &StartLoc,
SMLoc &EndLoc) {
1214 const AsmToken &Tok = getParser().getTok();
1220 return TokError(
"invalid register name");
1230 const MCExpr *PPCAsmParser::
1231 ExtractModifierFromExpr(
const MCExpr *
E,
1290 const MCExpr *LHS = ExtractModifierFromExpr(BE->
getLHS(), LHSVariant);
1291 const MCExpr *RHS = ExtractModifierFromExpr(BE->
getRHS(), RHSVariant);
1296 if (!LHS) LHS = BE->
getLHS();
1297 if (!RHS) RHS = BE->
getRHS();
1300 Variant = RHSVariant;
1302 Variant = LHSVariant;
1303 else if (LHSVariant == RHSVariant)
1304 Variant = LHSVariant;
1319 const MCExpr *PPCAsmParser::
1320 FixupVariantKind(
const MCExpr *E) {
1369 ParseExpression(
const MCExpr *&EVal) {
1372 return ParseDarwinExpression(EVal);
1376 if (getParser().parseExpression(EVal))
1379 EVal = FixupVariantKind(EVal);
1382 const MCExpr *E = ExtractModifierFromExpr(EVal, Variant);
1396 ParseDarwinExpression(
const MCExpr *&EVal) {
1399 switch (getLexer().getKind()) {
1424 if (getParser().parseExpression(EVal))
1446 switch (getLexer().getKind()) {
1454 return Error(S,
"invalid register name");
1456 Operands.
push_back(PPCOperand::CreateImm(IntVal, S, E, isPPC64()));
1476 Operands.
push_back(PPCOperand::CreateImm(IntVal, S, E, isPPC64()));
1482 if (!ParseExpression(EVal))
1487 return Error(S,
"unknown operand");
1491 Operands.
push_back(PPCOperand::CreateFromMCExpr(EVal, S, E, isPPC64()));
1494 bool TLSCall =
false;
1496 TLSCall =
Ref->getSymbol().getName() ==
"__tls_get_addr";
1503 if (ParseExpression(TLSSym))
1504 return Error(S,
"invalid TLS call expression");
1510 Operands.
push_back(PPCOperand::CreateFromMCExpr(TLSSym, S, E, isPPC64()));
1519 switch (getLexer().getKind()) {
1524 return Error(S,
"invalid register name");
1529 return Error(S,
"unexpected integer value");
1530 else if (getParser().parseAbsoluteExpression(IntVal) || IntVal < 0 ||
1532 return Error(S,
"invalid register number");
1544 return Error(S,
"invalid memory operand");
1550 Operands.
push_back(PPCOperand::CreateImm(IntVal, S, E, isPPC64()));
1562 std::string NewOpcode;
1575 size_t Dot = Name.
find(
'.');
1577 if (!NewOpcode.empty())
1579 PPCOperand::CreateTokenWithStringCopy(Mnemonic, NameLoc, isPPC64()));
1581 Operands.
push_back(PPCOperand::CreateToken(Mnemonic, NameLoc, isPPC64()));
1585 if (!NewOpcode.empty())
1587 PPCOperand::CreateTokenWithStringCopy(DotStr, DotLoc, isPPC64()));
1589 Operands.
push_back(PPCOperand::CreateToken(DotStr, DotLoc, isPPC64()));
1597 if (ParseOperand(Operands))
1613 if (getSTI().getFeatureBits()[PPC::FeatureBookE] &&
1614 Operands.
size() == 4 &&
1615 (Name ==
"dcbt" || Name ==
"dcbtst")) {
1624 bool PPCAsmParser::ParseDirective(
AsmToken DirectiveID) {
1627 if (IDVal ==
".machine")
1628 ParseDarwinDirectiveMachine(DirectiveID.
getLoc());
1631 }
else if (IDVal ==
".word")
1632 ParseDirectiveWord(2, DirectiveID);
1633 else if (IDVal ==
".llong")
1634 ParseDirectiveWord(8, DirectiveID);
1635 else if (IDVal ==
".tc")
1636 ParseDirectiveTC(isPPC64() ? 8 : 4, DirectiveID);
1637 else if (IDVal ==
".machine")
1638 ParseDirectiveMachine(DirectiveID.
getLoc());
1639 else if (IDVal ==
".abiversion")
1640 ParseDirectiveAbiVersion(DirectiveID.
getLoc());
1641 else if (IDVal ==
".localentry")
1642 ParseDirectiveLocalEntry(DirectiveID.
getLoc());
1650 bool PPCAsmParser::ParseDirectiveWord(
unsigned Size,
AsmToken ID) {
1651 auto parseOp = [&]() ->
bool {
1653 SMLoc ExprLoc = getParser().getTok().getLoc();
1654 if (getParser().parseExpression(Value))
1656 if (
const auto *MCE = dyn_cast<MCConstantExpr>(Value)) {
1657 assert(Size <= 8 &&
"Invalid size");
1658 uint64_t IntValue = MCE->getValue();
1659 if (!
isUIntN(8 * Size, IntValue) && !
isIntN(8 * Size, IntValue))
1660 return Error(ExprLoc,
"literal value out of range for '" +
1662 getStreamer().EmitIntValue(IntValue, Size);
1664 getStreamer().EmitValue(Value, Size, ExprLoc);
1668 if (parseMany(parseOp))
1669 return addErrorSuffix(
" in '" + ID.
getIdentifier() +
"' directive");
1675 bool PPCAsmParser::ParseDirectiveTC(
unsigned Size,
AsmToken ID) {
1682 return addErrorSuffix(
" in '.tc' directive");
1685 getParser().getStreamer().EmitValueToAlignment(Size);
1688 return ParseDirectiveWord(Size, ID);
1693 bool PPCAsmParser::ParseDirectiveMachine(
SMLoc L) {
1697 return Error(L,
"unexpected token in '.machine' directive");
1706 if (CPU !=
"any" && CPU !=
"push" && CPU !=
"pop")
1707 return TokError(
"unrecognized machine type");
1712 return addErrorSuffix(
" in '.machine' directive");
1716 getParser().getStreamer().getTargetStreamer());
1724 bool PPCAsmParser::ParseDarwinDirectiveMachine(
SMLoc L) {
1728 return Error(L,
"unexpected token in directive");
1736 if (check(CPU !=
"ppc7400" && CPU !=
"ppc" && CPU !=
"ppc64", L,
1737 "unrecognized cpu type") ||
1738 check(isPPC64() && (CPU ==
"ppc7400" || CPU ==
"ppc"), L,
1739 "wrong cpu type specified for 64bit") ||
1740 check(!isPPC64() && CPU ==
"ppc64", L,
1741 "wrong cpu type specified for 32bit") ||
1743 return addErrorSuffix(
" in '.machine' directive");
1749 bool PPCAsmParser::ParseDirectiveAbiVersion(
SMLoc L) {
1751 if (check(getParser().parseAbsoluteExpression(AbiVersion), L,
1752 "expected constant expression") ||
1754 return addErrorSuffix(
" in '.abiversion' directive");
1758 getParser().getStreamer().getTargetStreamer());
1766 bool PPCAsmParser::ParseDirectiveLocalEntry(
SMLoc L) {
1768 if (getParser().parseIdentifier(Name))
1769 return Error(L,
"expected identifier in '.localentry' directive");
1771 MCSymbolELF *Sym = cast<MCSymbolELF>(getContext().getOrCreateSymbol(Name));
1775 check(getParser().parseExpression(Expr), L,
"expected expression") ||
1777 return addErrorSuffix(
" in '.localentry' directive");
1781 getParser().getStreamer().getTargetStreamer());
1796 #define GET_REGISTER_MATCHER 1797 #define GET_MATCHER_IMPLEMENTATION 1798 #define GET_MNEMONIC_SPELL_CHECKER 1799 #include "PPCGenAsmMatcher.inc" 1810 case MCK_0: ImmVal = 0;
break;
1811 case MCK_1: ImmVal = 1;
break;
1812 case MCK_2: ImmVal = 2;
break;
1813 case MCK_3: ImmVal = 3;
break;
1814 case MCK_4: ImmVal = 4;
break;
1815 case MCK_5: ImmVal = 5;
break;
1816 case MCK_6: ImmVal = 6;
break;
1817 case MCK_7: ImmVal = 7;
break;
1818 default:
return Match_InvalidOperand;
1821 PPCOperand &
Op =
static_cast<PPCOperand &
>(AsmOp);
1822 if (Op.isImm() && Op.getImm() == ImmVal)
1823 return Match_Success;
1825 return Match_InvalidOperand;
1829 PPCAsmParser::applyModifierToExpr(
const MCExpr *E,
static bool isReg(const MCInst &MI, unsigned OpNo)
constexpr bool isUInt< 32 >(uint64_t x)
Represents a range in source code.
static int64_t EvaluateCRExpr(const MCExpr *E)
LLVM_NODISCARD bool startswith_lower(StringRef Prefix) const
Check if this string starts with the given Prefix, ignoring case.
StringRef getString() const
Get the string for the current token, this includes all characters (for example, the quotes on string...
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
This class represents lattice values for constants.
static unsigned MatchRegisterName(StringRef Name)
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
VariantKind getKind() const
LLVM_NODISCARD bool equals_lower(StringRef RHS) const
equals_lower - Check for string equality, ignoring case.
Generic assembler parser interface, for use by target specific assembly parsers.
static const PPCMCExpr * create(VariantKind Kind, const MCExpr *Expr, bool isDarwin, MCContext &Ctx)
static MCOperand createExpr(const MCExpr *Val)
MCTargetAsmParser - Generic interface to target specific assembly parsers.
void push_back(const T &Elt)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Target & getThePPC32Target()
bool isNot(TokenKind K) const
Opcode getOpcode() const
Get the kind of this unary expression.
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
virtual const AsmToken & Lex()=0
Get the next AsmToken in the stream, possibly handling file inclusion first.
constexpr bool isInt< 16 >(int64_t x)
const AsmToken & getTok() const
Get the current AsmToken from the stream.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, bool PrintSchedInfo=false)
Emit the given Instruction into the current section.
const Triple & getTargetTriple() const
StringRef getIdentifier() const
Get the identifier string for the current token, which should be an identifier or a string...
amdgpu Simplify well known AMD library false Value Value const Twine & Name
static MCOperand createReg(unsigned Reg)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const FeatureBitset & getFeatureBits() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Base class for the full range of assembler expressions which are needed for parsing.
The access may reference the value stored in memory.
Target independent representation for an assembler token.
Represent a reference to a symbol from inside an expression.
static bool isMem(const MachineInstr &MI, unsigned Op)
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand...
Context object for machine code objects.
std::pair< StringRef, StringRef > getToken(StringRef Source, StringRef Delimiters=" \\\)
getToken - This function extracts one token from source, ignoring any leading characters that appear ...
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
RegisterMCAsmParser - Helper template for registering a target specific assembly parser, for use in the target machine initialization function.
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Unary assembler expressions.
virtual void emitLocalEntry(MCSymbolELF *S, const MCExpr *LocalOffset)=0
const MCExpr * getExpr() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Target & getThePPC64Target()
Analysis containing CSE Info
Instances of this class represent a single low-level machine instruction.
static const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
const char * getPointer() const
Streaming machine code generation interface.
static const MCUnaryExpr * create(Opcode Op, const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
constexpr bool isUInt< 8 >(uint64_t x)
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
virtual void emitAbiVersion(int AbiVersion)=0
Interface to description of machine instruction set.
static bool isDarwin(object::Archive::Kind Kind)
void LLVMInitializePowerPCAsmParser()
Force static initialization.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
unsigned getNumOperands() const
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
Binary assembler expressions.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static void addNegOperand(MCInst &Inst, MCOperand &Op, MCContext &Ctx)
Triple - Helper class for working with autoconf configuration names.
static const MCUnaryExpr * createMinus(const MCExpr *Expr, MCContext &Ctx, SMLoc Loc=SMLoc())
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
void setOpcode(unsigned Op)
const MCSymbol & getSymbol() const
const MCOperand & getOperand(unsigned i) const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Target & getThePPC64LETarget()
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
Base class for user error types.
static SMLoc getFromPointer(const char *Ptr)
MCExpr const & getExpr(MCExpr const &Expr)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Generic base class for all target subtargets.
References to labels and assigned expressions.
constexpr bool isUInt< 16 >(uint64_t x)
Opcode getOpcode() const
Get the kind of this binary expression.
StringRef getName() const
getName - Get the symbol name.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isRunOfOnes(unsigned Val, unsigned &MB, unsigned &ME)
Returns true iff Val consists of one contiguous run of 1s with any number of 0s on either side...
const MCExpr * getSubExpr() const
Get the child of this unary expression.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream...
void addOperand(const MCOperand &Op)
StringRef - Represent a constant reference to a string, i.e.
Target specific expression.
virtual void emitMachine(StringRef CPU)=0
Represents a location in source code.
unsigned getOpcode() const
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Instances of this class represent operands of the MCInst class.
static MCOperand createImm(int64_t Val)
static std::string PPCMnemonicSpellCheck(StringRef S, uint64_t FBS, unsigned VariantID=0)