35 PPC::R0, PPC::R1,
PPC::R2, PPC::R3,
37 PPC::R8, PPC::R9, PPC::R10, PPC::R11,
38 PPC::R12, PPC::R13, PPC::R14, PPC::R15,
39 PPC::R16, PPC::R17, PPC::R18, PPC::R19,
40 PPC::R20, PPC::R21, PPC::R22, PPC::R23,
41 PPC::R24, PPC::R25, PPC::R26, PPC::R27,
42 PPC::R28, PPC::R29, PPC::R30, PPC::R31
48 PPC::R8, PPC::R9, PPC::R10, PPC::R11,
49 PPC::R12, PPC::R13, PPC::R14, PPC::R15,
50 PPC::R16, PPC::R17, PPC::R18, PPC::R19,
51 PPC::R20, PPC::R21, PPC::R22, PPC::R23,
52 PPC::R24, PPC::R25, PPC::R26, PPC::R27,
53 PPC::R28, PPC::R29, PPC::R30, PPC::R31
56 PPC::X0, PPC::X1, PPC::X2, PPC::X3,
57 PPC::X4, PPC::X5, PPC::X6, PPC::X7,
58 PPC::X8, PPC::X9, PPC::X10, PPC::X11,
59 PPC::X12, PPC::X13, PPC::X14, PPC::X15,
60 PPC::X16, PPC::X17, PPC::X18, PPC::X19,
61 PPC::X20, PPC::X21, PPC::X22, PPC::X23,
62 PPC::X24, PPC::X25, PPC::X26, PPC::X27,
63 PPC::X28, PPC::X29, PPC::X30, PPC::X31
67 PPC::X1, PPC::X2, PPC::X3,
68 PPC::X4, PPC::X5, PPC::X6, PPC::X7,
69 PPC::X8, PPC::X9, PPC::X10, PPC::X11,
70 PPC::X12, PPC::X13, PPC::X14, PPC::X15,
71 PPC::X16, PPC::X17, PPC::X18, PPC::X19,
72 PPC::X20, PPC::X21, PPC::X22, PPC::X23,
73 PPC::X24, PPC::X25, PPC::X26, PPC::X27,
74 PPC::X28, PPC::X29, PPC::X30, PPC::X31
77 PPC::F0, PPC::F1, PPC::F2, PPC::F3,
78 PPC::F4, PPC::F5, PPC::F6, PPC::F7,
79 PPC::F8, PPC::F9, PPC::F10, PPC::F11,
80 PPC::F12, PPC::F13, PPC::F14, PPC::F15,
81 PPC::F16, PPC::F17, PPC::F18, PPC::F19,
82 PPC::F20, PPC::F21, PPC::F22, PPC::F23,
83 PPC::F24, PPC::F25, PPC::F26, PPC::F27,
84 PPC::F28, PPC::F29, PPC::F30, PPC::F31
87 PPC::S0, PPC::S1, PPC::S2, PPC::S3,
88 PPC::S4, PPC::S5, PPC::S6, PPC::S7,
89 PPC::S8, PPC::S9, PPC::S10, PPC::S11,
90 PPC::S12, PPC::S13, PPC::S14, PPC::S15,
91 PPC::S16, PPC::S17, PPC::S18, PPC::S19,
92 PPC::S20, PPC::S21, PPC::S22, PPC::S23,
93 PPC::S24, PPC::S25, PPC::S26, PPC::S27,
94 PPC::S28, PPC::S29, PPC::S30, PPC::S31
97 PPC::VF0, PPC::VF1, PPC::VF2, PPC::VF3,
98 PPC::VF4, PPC::VF5, PPC::VF6, PPC::VF7,
99 PPC::VF8, PPC::VF9, PPC::VF10, PPC::VF11,
100 PPC::VF12, PPC::VF13, PPC::VF14, PPC::VF15,
101 PPC::VF16, PPC::VF17, PPC::VF18, PPC::VF19,
102 PPC::VF20, PPC::VF21, PPC::VF22, PPC::VF23,
103 PPC::VF24, PPC::VF25, PPC::VF26, PPC::VF27,
104 PPC::VF28, PPC::VF29, PPC::VF30, PPC::VF31
107 PPC::V0, PPC::V1,
PPC::V2, PPC::V3,
108 PPC::V4, PPC::V5, PPC::V6, PPC::V7,
109 PPC::V8, PPC::V9, PPC::V10, PPC::V11,
110 PPC::V12, PPC::V13, PPC::V14, PPC::V15,
111 PPC::V16, PPC::V17, PPC::V18, PPC::V19,
112 PPC::V20, PPC::V21, PPC::V22, PPC::V23,
113 PPC::V24, PPC::V25, PPC::V26, PPC::V27,
114 PPC::V28, PPC::V29, PPC::V30, PPC::V31
117 PPC::VSL0, PPC::VSL1, PPC::VSL2, PPC::VSL3,
118 PPC::VSL4, PPC::VSL5, PPC::VSL6, PPC::VSL7,
119 PPC::VSL8, PPC::VSL9, PPC::VSL10, PPC::VSL11,
120 PPC::VSL12, PPC::VSL13, PPC::VSL14, PPC::VSL15,
121 PPC::VSL16, PPC::VSL17, PPC::VSL18, PPC::VSL19,
122 PPC::VSL20, PPC::VSL21, PPC::VSL22, PPC::VSL23,
123 PPC::VSL24, PPC::VSL25, PPC::VSL26, PPC::VSL27,
124 PPC::VSL28, PPC::VSL29, PPC::VSL30, PPC::VSL31,
126 PPC::V0, PPC::V1,
PPC::V2, PPC::V3,
127 PPC::V4, PPC::V5, PPC::V6, PPC::V7,
128 PPC::V8, PPC::V9, PPC::V10, PPC::V11,
129 PPC::V12, PPC::V13, PPC::V14, PPC::V15,
130 PPC::V16, PPC::V17, PPC::V18, PPC::V19,
131 PPC::V20, PPC::V21, PPC::V22, PPC::V23,
132 PPC::V24, PPC::V25, PPC::V26, PPC::V27,
133 PPC::V28, PPC::V29, PPC::V30, PPC::V31
136 PPC::F0, PPC::F1, PPC::F2, PPC::F3,
137 PPC::F4, PPC::F5, PPC::F6, PPC::F7,
138 PPC::F8, PPC::F9, PPC::F10, PPC::F11,
139 PPC::F12, PPC::F13, PPC::F14, PPC::F15,
140 PPC::F16, PPC::F17, PPC::F18, PPC::F19,
141 PPC::F20, PPC::F21, PPC::F22, PPC::F23,
142 PPC::F24, PPC::F25, PPC::F26, PPC::F27,
143 PPC::F28, PPC::F29, PPC::F30, PPC::F31,
145 PPC::VF0, PPC::VF1, PPC::VF2, PPC::VF3,
146 PPC::VF4, PPC::VF5, PPC::VF6, PPC::VF7,
147 PPC::VF8, PPC::VF9, PPC::VF10, PPC::VF11,
148 PPC::VF12, PPC::VF13, PPC::VF14, PPC::VF15,
149 PPC::VF16, PPC::VF17, PPC::VF18, PPC::VF19,
150 PPC::VF20, PPC::VF21, PPC::VF22, PPC::VF23,
151 PPC::VF24, PPC::VF25, PPC::VF26, PPC::VF27,
152 PPC::VF28, PPC::VF29, PPC::VF30, PPC::VF31
155 PPC::F0, PPC::F1, PPC::F2, PPC::F3,
156 PPC::F4, PPC::F5, PPC::F6, PPC::F7,
157 PPC::F8, PPC::F9, PPC::F10, PPC::F11,
158 PPC::F12, PPC::F13, PPC::F14, PPC::F15,
159 PPC::F16, PPC::F17, PPC::F18, PPC::F19,
160 PPC::F20, PPC::F21, PPC::F22, PPC::F23,
161 PPC::F24, PPC::F25, PPC::F26, PPC::F27,
162 PPC::F28, PPC::F29, PPC::F30, PPC::F31,
164 PPC::VF0, PPC::VF1, PPC::VF2, PPC::VF3,
165 PPC::VF4, PPC::VF5, PPC::VF6, PPC::VF7,
166 PPC::VF8, PPC::VF9, PPC::VF10, PPC::VF11,
167 PPC::VF12, PPC::VF13, PPC::VF14, PPC::VF15,
168 PPC::VF16, PPC::VF17, PPC::VF18, PPC::VF19,
169 PPC::VF20, PPC::VF21, PPC::VF22, PPC::VF23,
170 PPC::VF24, PPC::VF25, PPC::VF26, PPC::VF27,
171 PPC::VF28, PPC::VF29, PPC::VF30, PPC::VF31
174 PPC::QF0, PPC::QF1, PPC::QF2, PPC::QF3,
175 PPC::QF4, PPC::QF5, PPC::QF6, PPC::QF7,
176 PPC::QF8, PPC::QF9, PPC::QF10, PPC::QF11,
177 PPC::QF12, PPC::QF13, PPC::QF14, PPC::QF15,
178 PPC::QF16, PPC::QF17, PPC::QF18, PPC::QF19,
179 PPC::QF20, PPC::QF21, PPC::QF22, PPC::QF23,
180 PPC::QF24, PPC::QF25, PPC::QF26, PPC::QF27,
181 PPC::QF28, PPC::QF29, PPC::QF30, PPC::QF31
184 PPC::CR0LT, PPC::CR0GT, PPC::CR0EQ, PPC::CR0UN,
185 PPC::CR1LT, PPC::CR1GT, PPC::CR1EQ, PPC::CR1UN,
186 PPC::CR2LT, PPC::CR2GT, PPC::CR2EQ, PPC::CR2UN,
187 PPC::CR3LT, PPC::CR3GT, PPC::CR3EQ, PPC::CR3UN,
188 PPC::CR4LT, PPC::CR4GT, PPC::CR4EQ, PPC::CR4UN,
189 PPC::CR5LT, PPC::CR5GT, PPC::CR5EQ, PPC::CR5UN,
190 PPC::CR6LT, PPC::CR6GT, PPC::CR6EQ, PPC::CR6UN,
191 PPC::CR7LT, PPC::CR7GT, PPC::CR7EQ, PPC::CR7UN
194 PPC::CR0, PPC::CR1, PPC::CR2, PPC::CR3,
195 PPC::CR4, PPC::CR5, PPC::CR6, PPC::CR7
208 int64_t Res = cast<MCConstantExpr>(
E)->getValue();
209 return Res < 0 ? -1 : Res;
216 if (Name ==
"lt")
return 0;
217 if (Name ==
"gt")
return 1;
218 if (Name ==
"eq")
return 2;
219 if (Name ==
"so")
return 3;
220 if (Name ==
"un")
return 3;
222 if (Name ==
"cr0")
return 0;
223 if (Name ==
"cr1")
return 1;
224 if (Name ==
"cr2")
return 2;
225 if (Name ==
"cr3")
return 3;
226 if (Name ==
"cr4")
return 4;
227 if (Name ==
"cr5")
return 5;
228 if (Name ==
"cr6")
return 6;
229 if (Name ==
"cr7")
return 7;
243 if (LHSVal < 0 || RHSVal < 0)
252 return Res < 0 ? -1 : Res;
269 bool isPPC64()
const {
return IsPPC64; }
270 bool isDarwin()
const {
return IsDarwin; }
274 bool ParseRegister(
unsigned &RegNo,
SMLoc &StartLoc,
SMLoc &EndLoc)
override;
279 bool ParseExpression(
const MCExpr *&EVal);
280 bool ParseDarwinExpression(
const MCExpr *&EVal);
285 bool ParseDirectiveTC(
unsigned Size,
AsmToken ID);
286 bool ParseDirectiveMachine(
SMLoc L);
287 bool ParseDarwinDirectiveMachine(
SMLoc L);
288 bool ParseDirectiveAbiVersion(
SMLoc L);
289 bool ParseDirectiveLocalEntry(
SMLoc L);
291 bool MatchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
294 bool MatchingInlineAsm)
override;
301 #define GET_ASSEMBLER_HEADER 302 #include "PPCGenAsmMatcher.inc" 317 setAvailableFeatures(ComputeAvailableFeatures(STI.
getFeatureBits()));
323 bool ParseDirective(
AsmToken DirectiveID)
override;
326 unsigned Kind)
override;
344 SMLoc StartLoc, EndLoc;
369 struct TLSRegOp TLSReg;
376 StartLoc = o.StartLoc;
384 case ContextImmediate:
398 void operator delete(
void *p) { ::operator
delete(p); }
401 SMLoc getStartLoc()
const override {
return StartLoc; }
404 SMLoc getEndLoc()
const override {
return EndLoc; }
411 bool isPPC64()
const {
return IsPPC64; }
413 int64_t getImm()
const {
414 assert(Kind == Immediate &&
"Invalid access!");
417 int64_t getImmS16Context()
const {
418 assert((Kind == Immediate || Kind == ContextImmediate) &&
420 if (Kind == Immediate)
422 return static_cast<int16_t
>(Imm.Val);
424 int64_t getImmU16Context()
const {
425 assert((Kind == Immediate || Kind == ContextImmediate) &&
431 assert(Kind == Expression &&
"Invalid access!");
435 int64_t getExprCRVal()
const {
436 assert(Kind == Expression &&
"Invalid access!");
440 const MCExpr *getTLSReg()
const {
441 assert(Kind == TLSRegister &&
"Invalid access!");
445 unsigned getReg()
const override {
446 assert(isRegNumber() &&
"Invalid access!");
447 return (
unsigned) Imm.Val;
450 unsigned getVSReg()
const {
451 assert(isVSRegNumber() &&
"Invalid access!");
452 return (
unsigned) Imm.Val;
455 unsigned getCCReg()
const {
456 assert(isCCRegNumber() &&
"Invalid access!");
457 return (
unsigned) (Kind == Immediate ? Imm.Val : Expr.CRVal);
460 unsigned getCRBit()
const {
461 assert(isCRBitNumber() &&
"Invalid access!");
462 return (
unsigned) (Kind == Immediate ? Imm.Val : Expr.CRVal);
465 unsigned getCRBitMask()
const {
466 assert(isCRBitMask() &&
"Invalid access!");
467 return 7 - countTrailingZeros<uint64_t>(Imm.Val);
470 bool isToken()
const override {
return Kind == Token; }
471 bool isImm()
const override {
472 return Kind == Immediate || Kind == Expression;
474 bool isU1Imm()
const {
return Kind == Immediate && isUInt<1>(getImm()); }
475 bool isU2Imm()
const {
return Kind == Immediate && isUInt<2>(getImm()); }
476 bool isU3Imm()
const {
return Kind == Immediate && isUInt<3>(getImm()); }
477 bool isU4Imm()
const {
return Kind == Immediate && isUInt<4>(getImm()); }
478 bool isU5Imm()
const {
return Kind == Immediate && isUInt<5>(getImm()); }
479 bool isS5Imm()
const {
return Kind == Immediate && isInt<5>(getImm()); }
480 bool isU6Imm()
const {
return Kind == Immediate && isUInt<6>(getImm()); }
481 bool isU6ImmX2()
const {
return Kind == Immediate &&
482 isUInt<6>(getImm()) &&
483 (getImm() & 1) == 0; }
484 bool isU7Imm()
const {
return Kind == Immediate && isUInt<7>(getImm()); }
485 bool isU7ImmX4()
const {
return Kind == Immediate &&
486 isUInt<7>(getImm()) &&
487 (getImm() & 3) == 0; }
488 bool isU8Imm()
const {
return Kind == Immediate &&
isUInt<8>(getImm()); }
489 bool isU8ImmX8()
const {
return Kind == Immediate &&
491 (getImm() & 7) == 0; }
493 bool isU10Imm()
const {
return Kind == Immediate && isUInt<10>(getImm()); }
494 bool isU12Imm()
const {
return Kind == Immediate && isUInt<12>(getImm()); }
495 bool isU16Imm()
const {
500 case ContextImmediate:
506 bool isS16Imm()
const {
511 case ContextImmediate:
517 bool isS16ImmX4()
const {
return Kind == Expression ||
518 (Kind == Immediate &&
isInt<16>(getImm()) &&
519 (getImm() & 3) == 0); }
520 bool isS16ImmX16()
const {
return Kind == Expression ||
521 (Kind == Immediate &&
isInt<16>(getImm()) &&
522 (getImm() & 15) == 0); }
523 bool isS17Imm()
const {
528 case ContextImmediate:
529 return isInt<17>(getImmS16Context());
534 bool isTLSReg()
const {
return Kind == TLSRegister; }
535 bool isDirectBr()
const {
536 if (Kind == Expression)
538 if (Kind != Immediate)
541 if ((getImm() & 3) != 0)
543 if (isInt<26>(getImm()))
547 if (
isUInt<32>(getImm()) && isInt<26>(static_cast<int32_t>(getImm())))
552 bool isCondBr()
const {
return Kind == Expression ||
553 (Kind == Immediate &&
isInt<16>(getImm()) &&
554 (getImm() & 3) == 0); }
555 bool isRegNumber()
const {
return Kind == Immediate && isUInt<5>(getImm()); }
556 bool isVSRegNumber()
const {
557 return Kind == Immediate && isUInt<6>(getImm());
559 bool isCCRegNumber()
const {
return (Kind == Expression
560 && isUInt<3>(getExprCRVal())) ||
562 && isUInt<3>(getImm())); }
563 bool isCRBitNumber()
const {
return (Kind == Expression
564 && isUInt<5>(getExprCRVal())) ||
566 && isUInt<5>(getImm())); }
567 bool isCRBitMask()
const {
return Kind == Immediate &&
isUInt<8>(getImm()) &&
569 bool isATBitsAsHint()
const {
return false; }
570 bool isMem()
const override {
return false; }
571 bool isReg()
const override {
return false; }
573 void addRegOperands(
MCInst &Inst,
unsigned N)
const {
577 void addRegGPRCOperands(
MCInst &Inst,
unsigned N)
const {
578 assert(N == 1 &&
"Invalid number of operands!");
582 void addRegGPRCNoR0Operands(
MCInst &Inst,
unsigned N)
const {
583 assert(N == 1 &&
"Invalid number of operands!");
587 void addRegG8RCOperands(
MCInst &Inst,
unsigned N)
const {
588 assert(N == 1 &&
"Invalid number of operands!");
592 void addRegG8RCNoX0Operands(
MCInst &Inst,
unsigned N)
const {
593 assert(N == 1 &&
"Invalid number of operands!");
597 void addRegGxRCOperands(
MCInst &Inst,
unsigned N)
const {
599 addRegG8RCOperands(Inst, N);
601 addRegGPRCOperands(Inst, N);
604 void addRegGxRCNoR0Operands(
MCInst &Inst,
unsigned N)
const {
606 addRegG8RCNoX0Operands(Inst, N);
608 addRegGPRCNoR0Operands(Inst, N);
611 void addRegF4RCOperands(
MCInst &Inst,
unsigned N)
const {
612 assert(N == 1 &&
"Invalid number of operands!");
616 void addRegF8RCOperands(
MCInst &Inst,
unsigned N)
const {
617 assert(N == 1 &&
"Invalid number of operands!");
621 void addRegVFRCOperands(
MCInst &Inst,
unsigned N)
const {
622 assert(N == 1 &&
"Invalid number of operands!");
626 void addRegVRRCOperands(
MCInst &Inst,
unsigned N)
const {
627 assert(N == 1 &&
"Invalid number of operands!");
631 void addRegVSRCOperands(
MCInst &Inst,
unsigned N)
const {
632 assert(N == 1 &&
"Invalid number of operands!");
636 void addRegVSFRCOperands(
MCInst &Inst,
unsigned N)
const {
637 assert(N == 1 &&
"Invalid number of operands!");
641 void addRegVSSRCOperands(
MCInst &Inst,
unsigned N)
const {
642 assert(N == 1 &&
"Invalid number of operands!");
646 void addRegQFRCOperands(
MCInst &Inst,
unsigned N)
const {
647 assert(N == 1 &&
"Invalid number of operands!");
651 void addRegQSRCOperands(
MCInst &Inst,
unsigned N)
const {
652 assert(N == 1 &&
"Invalid number of operands!");
656 void addRegQBRCOperands(
MCInst &Inst,
unsigned N)
const {
657 assert(N == 1 &&
"Invalid number of operands!");
661 void addRegSPE4RCOperands(
MCInst &Inst,
unsigned N)
const {
662 assert(N == 1 &&
"Invalid number of operands!");
666 void addRegSPERCOperands(
MCInst &Inst,
unsigned N)
const {
667 assert(N == 1 &&
"Invalid number of operands!");
671 void addRegCRBITRCOperands(
MCInst &Inst,
unsigned N)
const {
672 assert(N == 1 &&
"Invalid number of operands!");
676 void addRegCRRCOperands(
MCInst &Inst,
unsigned N)
const {
677 assert(N == 1 &&
"Invalid number of operands!");
681 void addCRBitMaskOperands(
MCInst &Inst,
unsigned N)
const {
682 assert(N == 1 &&
"Invalid number of operands!");
686 void addImmOperands(
MCInst &Inst,
unsigned N)
const {
687 assert(N == 1 &&
"Invalid number of operands!");
688 if (Kind == Immediate)
694 void addS16ImmOperands(
MCInst &Inst,
unsigned N)
const {
695 assert(N == 1 &&
"Invalid number of operands!");
700 case ContextImmediate:
709 void addU16ImmOperands(
MCInst &Inst,
unsigned N)
const {
710 assert(N == 1 &&
"Invalid number of operands!");
715 case ContextImmediate:
724 void addBranchTargetOperands(
MCInst &Inst,
unsigned N)
const {
725 assert(N == 1 &&
"Invalid number of operands!");
726 if (Kind == Immediate)
732 void addTLSRegOperands(
MCInst &Inst,
unsigned N)
const {
733 assert(N == 1 &&
"Invalid number of operands!");
738 assert(Kind == Token &&
"Invalid access!");
744 static std::unique_ptr<PPCOperand> CreateToken(
StringRef Str,
SMLoc S,
746 auto Op = make_unique<PPCOperand>(Token);
747 Op->Tok.Data = Str.
data();
748 Op->Tok.Length = Str.
size();
751 Op->IsPPC64 = IsPPC64;
755 static std::unique_ptr<PPCOperand>
762 void *Mem = ::operator
new(
sizeof(PPCOperand) + Str.
size());
763 std::unique_ptr<PPCOperand>
Op(
new (Mem) PPCOperand(Token));
764 Op->Tok.Data =
reinterpret_cast<const char *
>(Op.get() + 1);
765 Op->Tok.Length = Str.
size();
766 std::memcpy(const_cast<char *>(Op->Tok.Data), Str.
data(), Str.
size());
769 Op->IsPPC64 = IsPPC64;
773 static std::unique_ptr<PPCOperand> CreateImm(int64_t Val,
SMLoc S,
SMLoc E,
775 auto Op = make_unique<PPCOperand>(Immediate);
779 Op->IsPPC64 = IsPPC64;
783 static std::unique_ptr<PPCOperand> CreateExpr(
const MCExpr *Val,
SMLoc S,
784 SMLoc E,
bool IsPPC64) {
785 auto Op = make_unique<PPCOperand>(Expression);
790 Op->IsPPC64 = IsPPC64;
794 static std::unique_ptr<PPCOperand>
796 auto Op = make_unique<PPCOperand>(TLSRegister);
797 Op->TLSReg.Sym = Sym;
800 Op->IsPPC64 = IsPPC64;
804 static std::unique_ptr<PPCOperand>
805 CreateContextImm(int64_t Val,
SMLoc S,
SMLoc E,
bool IsPPC64) {
806 auto Op = make_unique<PPCOperand>(ContextImmediate);
810 Op->IsPPC64 = IsPPC64;
814 static std::unique_ptr<PPCOperand>
817 return CreateImm(CE->getValue(), S,
E, IsPPC64);
821 return CreateTLSReg(SRE, S, E, IsPPC64);
823 if (
const PPCMCExpr *TE = dyn_cast<PPCMCExpr>(Val)) {
825 if (TE->evaluateAsConstant(Res))
826 return CreateContextImm(Res, S, E, IsPPC64);
829 return CreateExpr(Val, S, E, IsPPC64);
841 case ContextImmediate:
860 if (
const MCUnaryExpr *UnExpr = dyn_cast<MCUnaryExpr>(Expr)) {
865 }
else if (
const MCBinaryExpr *BinExpr = dyn_cast<MCBinaryExpr>(Expr)) {
868 BinExpr->getLHS(), Ctx);
876 void PPCAsmParser::ProcessInstruction(
MCInst &Inst,
885 TmpInst.
setOpcode((Opcode == PPC::DCBTx || Opcode == PPC::DCBTT) ?
886 PPC::DCBT : PPC::DCBTST);
888 (Opcode == PPC::DCBTx || Opcode == PPC::DCBTSTx) ? 0 : 16));
905 case PPC::DCBTSTDS: {
918 if (Opcode == PPC::DCBFL)
920 else if (Opcode == PPC::DCBFLP)
981 TmpInst.
setOpcode(Opcode == PPC::EXTLWI? PPC::RLWINM : PPC::RLWINMo);
995 TmpInst.
setOpcode(Opcode == PPC::EXTRWI? PPC::RLWINM : PPC::RLWINMo);
1005 case PPC::INSLWIo: {
1009 TmpInst.
setOpcode(Opcode == PPC::INSLWI? PPC::RLWIMI : PPC::RLWIMIo);
1020 case PPC::INSRWIo: {
1024 TmpInst.
setOpcode(Opcode == PPC::INSRWI? PPC::RLWIMI : PPC::RLWIMIo);
1035 case PPC::ROTRWIo: {
1038 TmpInst.
setOpcode(Opcode == PPC::ROTRWI? PPC::RLWINM : PPC::RLWINMo);
1051 TmpInst.
setOpcode(Opcode == PPC::SLWI? PPC::RLWINM : PPC::RLWINMo);
1064 TmpInst.
setOpcode(Opcode == PPC::SRWI? PPC::RLWINM : PPC::RLWINMo);
1074 case PPC::CLRRWIo: {
1077 TmpInst.
setOpcode(Opcode == PPC::CLRRWI? PPC::RLWINM : PPC::RLWINMo);
1087 case PPC::CLRLSLWIo: {
1091 TmpInst.
setOpcode(Opcode == PPC::CLRLSLWI? PPC::RLWINM : PPC::RLWINMo);
1101 case PPC::EXTLDIo: {
1105 TmpInst.
setOpcode(Opcode == PPC::EXTLDI? PPC::RLDICR : PPC::RLDICRo);
1114 case PPC::EXTRDIo: {
1118 TmpInst.
setOpcode(Opcode == PPC::EXTRDI? PPC::RLDICL : PPC::RLDICLo);
1127 case PPC::INSRDIo: {
1131 TmpInst.
setOpcode(Opcode == PPC::INSRDI? PPC::RLDIMI : PPC::RLDIMIo);
1141 case PPC::ROTRDIo: {
1144 TmpInst.
setOpcode(Opcode == PPC::ROTRDI? PPC::RLDICL : PPC::RLDICLo);
1156 TmpInst.
setOpcode(Opcode == PPC::SLDI? PPC::RLDICR : PPC::RLDICRo);
1164 case PPC::SUBPCIS: {
1177 TmpInst.
setOpcode(Opcode == PPC::SRDI? PPC::RLDICL : PPC::RLDICLo);
1186 case PPC::CLRRDIo: {
1189 TmpInst.
setOpcode(Opcode == PPC::CLRRDI? PPC::RLDICR : PPC::RLDICRo);
1198 case PPC::CLRLSLDIo: {
1202 TmpInst.
setOpcode(Opcode == PPC::CLRLSLDI? PPC::RLDIC : PPC::RLDICo);
1211 case PPC::RLWINMobm: {
1218 TmpInst.
setOpcode(Opcode == PPC::RLWINMbm ? PPC::RLWINM : PPC::RLWINMo);
1228 case PPC::RLWIMIobm: {
1235 TmpInst.
setOpcode(Opcode == PPC::RLWIMIbm ? PPC::RLWIMI : PPC::RLWIMIo);
1246 case PPC::RLWNMobm: {
1253 TmpInst.
setOpcode(Opcode == PPC::RLWNMbm ? PPC::RLWNM : PPC::RLWNMo);
1263 if (getSTI().getFeatureBits()[PPC::FeatureMFTB]) {
1270 case PPC::CP_COPY_FIRST: {
1280 case PPC::CP_PASTEx :
1281 case PPC::CP_PASTE_LAST: {
1283 TmpInst.
setOpcode(Opcode == PPC::CP_PASTEx ?
1284 PPC::CP_PASTE : PPC::CP_PASTEo);
1296 unsigned VariantID = 0);
1298 bool PPCAsmParser::MatchAndEmitInstruction(
SMLoc IDLoc,
unsigned &Opcode,
1301 bool MatchingInlineAsm) {
1304 switch (MatchInstructionImpl(Operands, Inst,
ErrorInfo, MatchingInlineAsm)) {
1307 ProcessInstruction(Inst, Operands);
1311 case Match_MissingFeature:
1312 return Error(IDLoc,
"instruction use requires an option to be enabled");
1313 case Match_MnemonicFail: {
1314 uint64_t FBS = ComputeAvailableFeatures(getSTI().getFeatureBits());
1316 ((PPCOperand &)*Operands[0]).
getToken(), FBS);
1317 return Error(IDLoc,
"invalid instruction" + Suggestion,
1318 ((PPCOperand &)*Operands[0]).getLocRange());
1320 case Match_InvalidOperand: {
1321 SMLoc ErrorLoc = IDLoc;
1324 return Error(IDLoc,
"too few operands for instruction");
1326 ErrorLoc = ((PPCOperand &)*Operands[
ErrorInfo]).getStartLoc();
1327 if (ErrorLoc ==
SMLoc()) ErrorLoc = IDLoc;
1330 return Error(ErrorLoc,
"invalid operand for instruction");
1341 RegNo = isPPC64()? PPC::LR8 : PPC::LR;
1344 RegNo = isPPC64()? PPC::CTR8 : PPC::CTR;
1347 RegNo = PPC::VRSAVE;
1376 ParseRegister(
unsigned &RegNo,
SMLoc &StartLoc,
SMLoc &EndLoc) {
1377 const AsmToken &Tok = getParser().getTok();
1383 return TokError(
"invalid register name");
1393 const MCExpr *PPCAsmParser::
1394 ExtractModifierFromExpr(
const MCExpr *
E,
1453 const MCExpr *LHS = ExtractModifierFromExpr(BE->
getLHS(), LHSVariant);
1454 const MCExpr *RHS = ExtractModifierFromExpr(BE->
getRHS(), RHSVariant);
1459 if (!LHS) LHS = BE->
getLHS();
1460 if (!RHS) RHS = BE->
getRHS();
1463 Variant = RHSVariant;
1465 Variant = LHSVariant;
1466 else if (LHSVariant == RHSVariant)
1467 Variant = LHSVariant;
1482 const MCExpr *PPCAsmParser::
1483 FixupVariantKind(
const MCExpr *E) {
1532 ParseExpression(
const MCExpr *&EVal) {
1535 return ParseDarwinExpression(EVal);
1539 if (getParser().parseExpression(EVal))
1542 EVal = FixupVariantKind(EVal);
1545 const MCExpr *E = ExtractModifierFromExpr(EVal, Variant);
1559 ParseDarwinExpression(
const MCExpr *&EVal) {
1562 switch (getLexer().getKind()) {
1587 if (getParser().parseExpression(EVal))
1609 switch (getLexer().getKind()) {
1617 return Error(S,
"invalid register name");
1619 Operands.
push_back(PPCOperand::CreateImm(IntVal, S, E, isPPC64()));
1639 Operands.
push_back(PPCOperand::CreateImm(IntVal, S, E, isPPC64()));
1645 if (!ParseExpression(EVal))
1650 return Error(S,
"unknown operand");
1654 Operands.
push_back(PPCOperand::CreateFromMCExpr(EVal, S, E, isPPC64()));
1657 bool TLSCall =
false;
1659 TLSCall =
Ref->getSymbol().getName() ==
"__tls_get_addr";
1666 if (ParseExpression(TLSSym))
1667 return Error(S,
"invalid TLS call expression");
1673 Operands.
push_back(PPCOperand::CreateFromMCExpr(TLSSym, S, E, isPPC64()));
1682 switch (getLexer().getKind()) {
1687 return Error(S,
"invalid register name");
1692 return Error(S,
"unexpected integer value");
1693 else if (getParser().parseAbsoluteExpression(IntVal) || IntVal < 0 ||
1695 return Error(S,
"invalid register number");
1707 return Error(S,
"invalid memory operand");
1713 Operands.
push_back(PPCOperand::CreateImm(IntVal, S, E, isPPC64()));
1725 std::string NewOpcode;
1738 size_t Dot = Name.
find(
'.');
1740 if (!NewOpcode.empty())
1742 PPCOperand::CreateTokenWithStringCopy(Mnemonic, NameLoc, isPPC64()));
1744 Operands.
push_back(PPCOperand::CreateToken(Mnemonic, NameLoc, isPPC64()));
1748 if (!NewOpcode.empty())
1750 PPCOperand::CreateTokenWithStringCopy(DotStr, DotLoc, isPPC64()));
1752 Operands.
push_back(PPCOperand::CreateToken(DotStr, DotLoc, isPPC64()));
1760 if (ParseOperand(Operands))
1776 if (getSTI().getFeatureBits()[PPC::FeatureBookE] &&
1777 Operands.
size() == 4 &&
1778 (Name ==
"dcbt" || Name ==
"dcbtst")) {
1787 bool PPCAsmParser::ParseDirective(
AsmToken DirectiveID) {
1790 if (IDVal ==
".machine")
1791 ParseDarwinDirectiveMachine(DirectiveID.
getLoc());
1794 }
else if (IDVal ==
".word")
1795 ParseDirectiveWord(2, DirectiveID);
1796 else if (IDVal ==
".llong")
1797 ParseDirectiveWord(8, DirectiveID);
1798 else if (IDVal ==
".tc")
1799 ParseDirectiveTC(isPPC64() ? 8 : 4, DirectiveID);
1800 else if (IDVal ==
".machine")
1801 ParseDirectiveMachine(DirectiveID.
getLoc());
1802 else if (IDVal ==
".abiversion")
1803 ParseDirectiveAbiVersion(DirectiveID.
getLoc());
1804 else if (IDVal ==
".localentry")
1805 ParseDirectiveLocalEntry(DirectiveID.
getLoc());
1813 bool PPCAsmParser::ParseDirectiveWord(
unsigned Size,
AsmToken ID) {
1814 auto parseOp = [&]() ->
bool {
1816 SMLoc ExprLoc = getParser().getTok().getLoc();
1817 if (getParser().parseExpression(Value))
1819 if (
const auto *MCE = dyn_cast<MCConstantExpr>(Value)) {
1820 assert(Size <= 8 &&
"Invalid size");
1821 uint64_t IntValue = MCE->getValue();
1822 if (!
isUIntN(8 * Size, IntValue) && !
isIntN(8 * Size, IntValue))
1823 return Error(ExprLoc,
"literal value out of range for '" +
1825 getStreamer().EmitIntValue(IntValue, Size);
1827 getStreamer().EmitValue(Value, Size, ExprLoc);
1831 if (parseMany(parseOp))
1832 return addErrorSuffix(
" in '" + ID.
getIdentifier() +
"' directive");
1838 bool PPCAsmParser::ParseDirectiveTC(
unsigned Size,
AsmToken ID) {
1845 return addErrorSuffix(
" in '.tc' directive");
1848 getParser().getStreamer().EmitValueToAlignment(Size);
1851 return ParseDirectiveWord(Size, ID);
1856 bool PPCAsmParser::ParseDirectiveMachine(
SMLoc L) {
1860 return Error(L,
"unexpected token in '.machine' directive");
1869 if (CPU !=
"any" && CPU !=
"push" && CPU !=
"pop")
1870 return TokError(
"unrecognized machine type");
1875 return addErrorSuffix(
" in '.machine' directive");
1879 getParser().getStreamer().getTargetStreamer());
1887 bool PPCAsmParser::ParseDarwinDirectiveMachine(
SMLoc L) {
1891 return Error(L,
"unexpected token in directive");
1899 if (check(CPU !=
"ppc7400" && CPU !=
"ppc" && CPU !=
"ppc64", L,
1900 "unrecognized cpu type") ||
1901 check(isPPC64() && (CPU ==
"ppc7400" || CPU ==
"ppc"), L,
1902 "wrong cpu type specified for 64bit") ||
1903 check(!isPPC64() && CPU ==
"ppc64", L,
1904 "wrong cpu type specified for 32bit") ||
1906 return addErrorSuffix(
" in '.machine' directive");
1912 bool PPCAsmParser::ParseDirectiveAbiVersion(
SMLoc L) {
1914 if (check(getParser().parseAbsoluteExpression(AbiVersion), L,
1915 "expected constant expression") ||
1917 return addErrorSuffix(
" in '.abiversion' directive");
1921 getParser().getStreamer().getTargetStreamer());
1929 bool PPCAsmParser::ParseDirectiveLocalEntry(
SMLoc L) {
1931 if (getParser().parseIdentifier(Name))
1932 return Error(L,
"expected identifier in '.localentry' directive");
1934 MCSymbolELF *Sym = cast<MCSymbolELF>(getContext().getOrCreateSymbol(Name));
1938 check(getParser().parseExpression(Expr), L,
"expected expression") ||
1940 return addErrorSuffix(
" in '.localentry' directive");
1944 getParser().getStreamer().getTargetStreamer());
1959 #define GET_REGISTER_MATCHER 1960 #define GET_MATCHER_IMPLEMENTATION 1961 #define GET_MNEMONIC_SPELL_CHECKER 1962 #include "PPCGenAsmMatcher.inc" 1973 case MCK_0: ImmVal = 0;
break;
1974 case MCK_1: ImmVal = 1;
break;
1975 case MCK_2: ImmVal = 2;
break;
1976 case MCK_3: ImmVal = 3;
break;
1977 case MCK_4: ImmVal = 4;
break;
1978 case MCK_5: ImmVal = 5;
break;
1979 case MCK_6: ImmVal = 6;
break;
1980 case MCK_7: ImmVal = 7;
break;
1981 default:
return Match_InvalidOperand;
1984 PPCOperand &
Op =
static_cast<PPCOperand &
>(AsmOp);
1985 if (Op.isImm() && Op.getImm() == ImmVal)
1986 return Match_Success;
1988 return Match_InvalidOperand;
1992 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 const MCPhysReg XRegsNoX0[32]
void push_back(const T &Elt)
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)
static const MCPhysReg SPERegs[32]
Compute iterated dominance frontiers using a linear time algorithm.
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 MCPhysReg VFRegs[32]
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.
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.
static const MCPhysReg VRegs[32]
static const MCPhysReg CRBITRegs[32]
virtual const AsmToken & Lex()=0
Get the next AsmToken in the stream, possibly handling file inclusion first.
static const MCPhysReg FRegs[32]
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...
static MCOperand createReg(unsigned Reg)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const FeatureBitset & getFeatureBits() const
static const MCPhysReg VSSRegs[64]
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 const MCPhysReg CRRegs[8]
static bool isMem(const MachineInstr &MI, unsigned Op)
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand...
static const MCPhysReg XRegs[32]
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 unsigned QFRegs[32]
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()
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())
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
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.
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)
static const MCPhysReg VSRegs[64]
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)
static const MCPhysReg RRegs[32]
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static const MCPhysReg VSFRegs[64]
static unsigned MatchRegisterName(StringRef Name)
Maps from the set of all register names to a register number.
This class implements an extremely fast bulk output stream that can only output to a stream...
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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)
static const MCPhysReg RRegsNoR0[32]