41#define DEBUG_TYPE "mccodeemitter"
43STATISTIC(MCNumEmitted,
"Number of MC instructions emitted.");
44STATISTIC(MCNumCPRelocations,
"Number of constant pool relocations created.");
55 : MCII(mcii), CTX(ctx), IsLittleEndian(IsLittle) {
57 ARMMCCodeEmitter(
const ARMMCCodeEmitter &) =
delete;
58 ARMMCCodeEmitter &operator=(
const ARMMCCodeEmitter &) =
delete;
59 ~ARMMCCodeEmitter()
override =
default;
61 bool isThumb(
const MCSubtargetInfo &STI)
const {
65 bool isThumb2(
const MCSubtargetInfo &STI)
const {
69 bool isTargetMachO(
const MCSubtargetInfo &STI)
const {
71 return TT.isOSBinFormatMachO();
74 unsigned getMachineSoImmOpValue(
unsigned SoImm)
const;
78 uint64_t getBinaryCodeForInstr(
const MCInst &
MI,
79 SmallVectorImpl<MCFixup> &Fixups,
80 const MCSubtargetInfo &STI)
const;
84 unsigned getMachineOpValue(
const MCInst &
MI,
const MCOperand &MO,
85 SmallVectorImpl<MCFixup> &Fixups,
86 const MCSubtargetInfo &STI)
const;
92 uint32_t getHiLoImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
93 SmallVectorImpl<MCFixup> &Fixups,
94 const MCSubtargetInfo &STI)
const;
96 bool EncodeAddrModeOpValues(
const MCInst &
MI,
unsigned OpIdx,
97 unsigned &
Reg,
unsigned &Imm,
98 SmallVectorImpl<MCFixup> &Fixups,
99 const MCSubtargetInfo &STI)
const;
103 uint32_t getThumbBLTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
104 SmallVectorImpl<MCFixup> &Fixups,
105 const MCSubtargetInfo &STI)
const;
109 uint32_t getThumbBLXTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
110 SmallVectorImpl<MCFixup> &Fixups,
111 const MCSubtargetInfo &STI)
const;
114 uint32_t getThumbBRTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
115 SmallVectorImpl<MCFixup> &Fixups,
116 const MCSubtargetInfo &STI)
const;
119 uint32_t getThumbBCCTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
120 SmallVectorImpl<MCFixup> &Fixups,
121 const MCSubtargetInfo &STI)
const;
124 uint32_t getThumbCBTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
125 SmallVectorImpl<MCFixup> &Fixups,
126 const MCSubtargetInfo &STI)
const;
131 SmallVectorImpl<MCFixup> &Fixups,
132 const MCSubtargetInfo &STI)
const;
136 uint32_t getThumbBranchTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
137 SmallVectorImpl<MCFixup> &Fixups,
138 const MCSubtargetInfo &STI)
const;
142 uint32_t getARMBranchTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
143 SmallVectorImpl<MCFixup> &Fixups,
144 const MCSubtargetInfo &STI)
const;
145 uint32_t getARMBLTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
146 SmallVectorImpl<MCFixup> &Fixups,
147 const MCSubtargetInfo &STI)
const;
148 uint32_t getARMBLXTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
149 SmallVectorImpl<MCFixup> &Fixups,
150 const MCSubtargetInfo &STI)
const;
154 uint32_t getAdrLabelOpValue(
const MCInst &
MI,
unsigned OpIdx,
155 SmallVectorImpl<MCFixup> &Fixups,
156 const MCSubtargetInfo &STI)
const;
157 uint32_t getThumbAdrLabelOpValue(
const MCInst &
MI,
unsigned OpIdx,
158 SmallVectorImpl<MCFixup> &Fixups,
159 const MCSubtargetInfo &STI)
const;
160 uint32_t getT2AdrLabelOpValue(
const MCInst &
MI,
unsigned OpIdx,
161 SmallVectorImpl<MCFixup> &Fixups,
162 const MCSubtargetInfo &STI)
const;
164 uint32_t getITMaskOpValue(
const MCInst &
MI,
unsigned OpIdx,
165 SmallVectorImpl<MCFixup> &Fixups,
166 const MCSubtargetInfo &STI)
const;
170 uint32_t getMVEShiftImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
171 SmallVectorImpl<MCFixup> &Fixups,
172 const MCSubtargetInfo &STI)
const;
176 uint32_t getAddrModeImm12OpValue(
const MCInst &
MI,
unsigned OpIdx,
177 SmallVectorImpl<MCFixup> &Fixups,
178 const MCSubtargetInfo &STI)
const;
181 uint32_t getThumbAddrModeRegRegOpValue(
const MCInst &
MI,
unsigned OpIdx,
182 SmallVectorImpl<MCFixup> &Fixups,
183 const MCSubtargetInfo &STI)
const;
187 uint32_t getT2AddrModeImm8s4OpValue(
const MCInst &
MI,
unsigned OpIdx,
188 SmallVectorImpl<MCFixup> &Fixups,
189 const MCSubtargetInfo &STI)
const;
193 uint32_t getT2AddrModeImm7s4OpValue(
const MCInst &
MI,
unsigned OpIdx,
194 SmallVectorImpl<MCFixup> &Fixups,
195 const MCSubtargetInfo &STI)
const;
199 uint32_t getT2AddrModeImm0_1020s4OpValue(
const MCInst &
MI,
unsigned OpIdx,
200 SmallVectorImpl<MCFixup> &Fixups,
201 const MCSubtargetInfo &STI)
const;
205 template<
unsigned Bits,
unsigned Shift>
206 uint32_t getT2ScaledImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
207 SmallVectorImpl<MCFixup> &Fixups,
208 const MCSubtargetInfo &STI)
const;
212 uint32_t getMveAddrModeRQOpValue(
const MCInst &
MI,
unsigned OpIdx,
213 SmallVectorImpl<MCFixup> &Fixups,
214 const MCSubtargetInfo &STI)
const;
219 uint32_t getMveAddrModeQOpValue(
const MCInst &
MI,
unsigned OpIdx,
220 SmallVectorImpl<MCFixup> &Fixups,
221 const MCSubtargetInfo &STI)
const;
225 uint32_t getLdStSORegOpValue(
const MCInst &
MI,
unsigned OpIdx,
226 SmallVectorImpl<MCFixup> &Fixups,
227 const MCSubtargetInfo &STI)
const;
230 uint32_t getLdStmModeOpValue(
const MCInst &
MI,
unsigned OpIdx,
231 SmallVectorImpl<MCFixup> &Fixups,
232 const MCSubtargetInfo &STI)
const {
259 uint32_t getAddrMode2OffsetOpValue(
const MCInst &
MI,
unsigned OpIdx,
260 SmallVectorImpl<MCFixup> &Fixups,
261 const MCSubtargetInfo &STI)
const;
264 uint32_t getPostIdxRegOpValue(
const MCInst &
MI,
unsigned OpIdx,
265 SmallVectorImpl<MCFixup> &Fixups,
266 const MCSubtargetInfo &STI)
const;
269 uint32_t getAddrMode3OffsetOpValue(
const MCInst &
MI,
unsigned OpIdx,
270 SmallVectorImpl<MCFixup> &Fixups,
271 const MCSubtargetInfo &STI)
const;
274 uint32_t getAddrMode3OpValue(
const MCInst &
MI,
unsigned OpIdx,
275 SmallVectorImpl<MCFixup> &Fixups,
276 const MCSubtargetInfo &STI)
const;
280 uint32_t getAddrModeThumbSPOpValue(
const MCInst &
MI,
unsigned OpIdx,
281 SmallVectorImpl<MCFixup> &Fixups,
282 const MCSubtargetInfo &STI)
const;
285 uint32_t getAddrModeISOpValue(
const MCInst &
MI,
unsigned OpIdx,
286 SmallVectorImpl<MCFixup> &Fixups,
287 const MCSubtargetInfo &STI)
const;
290 uint32_t getAddrModePCOpValue(
const MCInst &
MI,
unsigned OpIdx,
291 SmallVectorImpl<MCFixup> &Fixups,
292 const MCSubtargetInfo &STI)
const;
295 uint32_t getAddrMode5OpValue(
const MCInst &
MI,
unsigned OpIdx,
296 SmallVectorImpl<MCFixup> &Fixups,
297 const MCSubtargetInfo &STI)
const;
300 uint32_t getAddrMode5FP16OpValue(
const MCInst &
MI,
unsigned OpIdx,
301 SmallVectorImpl<MCFixup> &Fixups,
302 const MCSubtargetInfo &STI)
const;
305 unsigned getCCOutOpValue(
const MCInst &
MI,
unsigned Op,
306 SmallVectorImpl<MCFixup> &Fixups,
307 const MCSubtargetInfo &STI)
const {
310 return MI.getOperand(
Op).getReg() == ARM::CPSR;
313 unsigned getModImmOpValue(
const MCInst &
MI,
unsigned Op,
314 SmallVectorImpl<MCFixup> &Fixups,
315 const MCSubtargetInfo &ST)
const;
318 unsigned getT2SOImmOpValue(
const MCInst &
MI,
unsigned Op,
319 SmallVectorImpl<MCFixup> &Fixups,
320 const MCSubtargetInfo &STI)
const;
322 unsigned getT2AddrModeSORegOpValue(
const MCInst &
MI,
unsigned OpNum,
323 SmallVectorImpl<MCFixup> &Fixups,
324 const MCSubtargetInfo &STI)
const;
325 template<
unsigned Bits,
unsigned Shift>
326 unsigned getT2AddrModeImmOpValue(
const MCInst &
MI,
unsigned OpNum,
327 SmallVectorImpl<MCFixup> &Fixups,
328 const MCSubtargetInfo &STI)
const;
329 unsigned getT2AddrModeImm8OffsetOpValue(
const MCInst &
MI,
unsigned OpNum,
330 SmallVectorImpl<MCFixup> &Fixups,
331 const MCSubtargetInfo &STI)
const;
334 unsigned getSORegRegOpValue(
const MCInst &
MI,
unsigned Op,
335 SmallVectorImpl<MCFixup> &Fixups,
336 const MCSubtargetInfo &STI)
const;
337 unsigned getSORegImmOpValue(
const MCInst &
MI,
unsigned Op,
338 SmallVectorImpl<MCFixup> &Fixups,
339 const MCSubtargetInfo &STI)
const;
340 unsigned getT2SORegOpValue(
const MCInst &
MI,
unsigned Op,
341 SmallVectorImpl<MCFixup> &Fixups,
342 const MCSubtargetInfo &STI)
const;
344 unsigned getNEONVcvtImm32OpValue(
const MCInst &
MI,
unsigned Op,
345 SmallVectorImpl<MCFixup> &Fixups,
346 const MCSubtargetInfo &STI)
const {
347 return 64 -
MI.getOperand(
Op).getImm();
350 unsigned getBitfieldInvertedMaskOpValue(
const MCInst &
MI,
unsigned Op,
351 SmallVectorImpl<MCFixup> &Fixups,
352 const MCSubtargetInfo &STI)
const;
354 unsigned getRegisterListOpValue(
const MCInst &
MI,
unsigned Op,
355 SmallVectorImpl<MCFixup> &Fixups,
356 const MCSubtargetInfo &STI)
const;
357 unsigned getAddrMode6AddressOpValue(
const MCInst &
MI,
unsigned Op,
358 SmallVectorImpl<MCFixup> &Fixups,
359 const MCSubtargetInfo &STI)
const;
360 unsigned getAddrMode6OneLane32AddressOpValue(
const MCInst &
MI,
unsigned Op,
361 SmallVectorImpl<MCFixup> &Fixups,
362 const MCSubtargetInfo &STI)
const;
363 unsigned getAddrMode6DupAddressOpValue(
const MCInst &
MI,
unsigned Op,
364 SmallVectorImpl<MCFixup> &Fixups,
365 const MCSubtargetInfo &STI)
const;
366 unsigned getAddrMode6OffsetOpValue(
const MCInst &
MI,
unsigned Op,
367 SmallVectorImpl<MCFixup> &Fixups,
368 const MCSubtargetInfo &STI)
const;
370 unsigned getShiftRight8Imm(
const MCInst &
MI,
unsigned Op,
371 SmallVectorImpl<MCFixup> &Fixups,
372 const MCSubtargetInfo &STI)
const;
373 unsigned getShiftRight16Imm(
const MCInst &
MI,
unsigned Op,
374 SmallVectorImpl<MCFixup> &Fixups,
375 const MCSubtargetInfo &STI)
const;
376 unsigned getShiftRight32Imm(
const MCInst &
MI,
unsigned Op,
377 SmallVectorImpl<MCFixup> &Fixups,
378 const MCSubtargetInfo &STI)
const;
379 unsigned getShiftRight64Imm(
const MCInst &
MI,
unsigned Op,
380 SmallVectorImpl<MCFixup> &Fixups,
381 const MCSubtargetInfo &STI)
const;
383 unsigned getThumbSRImmOpValue(
const MCInst &
MI,
unsigned Op,
384 SmallVectorImpl<MCFixup> &Fixups,
385 const MCSubtargetInfo &STI)
const;
387 unsigned NEONThumb2DataIPostEncoder(
const MCInst &
MI,
388 unsigned EncodedValue,
389 const MCSubtargetInfo &STI)
const;
390 unsigned NEONThumb2LoadStorePostEncoder(
const MCInst &
MI,
391 unsigned EncodedValue,
392 const MCSubtargetInfo &STI)
const;
393 unsigned NEONThumb2DupPostEncoder(
const MCInst &
MI,
394 unsigned EncodedValue,
395 const MCSubtargetInfo &STI)
const;
396 unsigned NEONThumb2V8PostEncoder(
const MCInst &
MI,
397 unsigned EncodedValue,
398 const MCSubtargetInfo &STI)
const;
400 unsigned VFPThumb2PostEncoder(
const MCInst &
MI,
401 unsigned EncodedValue,
402 const MCSubtargetInfo &STI)
const;
404 uint32_t getPowerTwoOpValue(
const MCInst &
MI,
unsigned OpIdx,
405 SmallVectorImpl<MCFixup> &Fixups,
406 const MCSubtargetInfo &STI)
const;
408 void encodeInstruction(
const MCInst &
MI, SmallVectorImpl<char> &CB,
409 SmallVectorImpl<MCFixup> &Fixups,
410 const MCSubtargetInfo &STI)
const override;
412 template <
bool isNeg, ARM::Fixups fixup>
413 uint32_t getBFTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
414 SmallVectorImpl<MCFixup> &Fixups,
415 const MCSubtargetInfo &STI)
const;
417 uint32_t getBFAfterTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
418 SmallVectorImpl<MCFixup> &Fixups,
419 const MCSubtargetInfo &STI)
const;
421 uint32_t getVPTMaskOpValue(
const MCInst &
MI,
unsigned OpIdx,
422 SmallVectorImpl<MCFixup> &Fixups,
423 const MCSubtargetInfo &STI)
const;
424 uint32_t getRestrictedCondCodeOpValue(
const MCInst &
MI,
unsigned OpIdx,
425 SmallVectorImpl<MCFixup> &Fixups,
426 const MCSubtargetInfo &STI)
const;
427 template <
unsigned size>
428 uint32_t getMVEPairVectorIndexOpValue(
const MCInst &
MI,
unsigned OpIdx,
429 SmallVectorImpl<MCFixup> &Fixups,
430 const MCSubtargetInfo &STI)
const;
476unsigned ARMMCCodeEmitter::NEONThumb2DataIPostEncoder(
const MCInst &
MI,
477 unsigned EncodedValue,
483 unsigned Bit24 = EncodedValue & 0x01000000;
484 unsigned Bit28 = Bit24 << 4;
485 EncodedValue &= 0xEFFFFFFF;
486 EncodedValue |= Bit28;
487 EncodedValue |= 0x0F000000;
496unsigned ARMMCCodeEmitter::NEONThumb2LoadStorePostEncoder(
const MCInst &
MI,
497 unsigned EncodedValue,
498 const MCSubtargetInfo &STI)
const {
500 EncodedValue &= 0xF0FFFFFF;
501 EncodedValue |= 0x09000000;
510unsigned ARMMCCodeEmitter::NEONThumb2DupPostEncoder(
const MCInst &
MI,
511 unsigned EncodedValue,
512 const MCSubtargetInfo &STI)
const {
514 EncodedValue &= 0x00FFFFFF;
515 EncodedValue |= 0xEE000000;
523unsigned ARMMCCodeEmitter::NEONThumb2V8PostEncoder(
const MCInst &
MI,
524 unsigned EncodedValue,
525 const MCSubtargetInfo &STI)
const {
527 EncodedValue |= 0xC000000;
535unsigned ARMMCCodeEmitter::
536VFPThumb2PostEncoder(
const MCInst &
MI,
unsigned EncodedValue,
537 const MCSubtargetInfo &STI)
const {
539 EncodedValue &= 0x0FFFFFFF;
540 EncodedValue |= 0xE0000000;
547unsigned ARMMCCodeEmitter::
548getMachineOpValue(
const MCInst &
MI,
const MCOperand &MO,
549 SmallVectorImpl<MCFixup> &Fixups,
550 const MCSubtargetInfo &STI)
const {
567 case ARM::Q0:
case ARM::Q1:
case ARM::Q2:
case ARM::Q3:
568 case ARM::Q4:
case ARM::Q5:
case ARM::Q6:
case ARM::Q7:
569 case ARM::Q8:
case ARM::Q9:
case ARM::Q10:
case ARM::Q11:
570 case ARM::Q12:
case ARM::Q13:
case ARM::Q14:
case ARM::Q15:
573 }
else if (MO.
isImm()) {
574 return static_cast<unsigned>(MO.
getImm());
586bool ARMMCCodeEmitter::
587EncodeAddrModeOpValues(
const MCInst &
MI,
unsigned OpIdx,
unsigned &
Reg,
588 unsigned &Imm, SmallVectorImpl<MCFixup> &Fixups,
589 const MCSubtargetInfo &STI)
const {
590 const MCOperand &MO =
MI.getOperand(
OpIdx);
591 const MCOperand &MO1 =
MI.getOperand(
OpIdx + 1);
595 int32_t SImm = MO1.
getImm();
599 if (SImm == INT32_MIN) {
624 assert(MO.
isExpr() &&
"Unexpected branch target type!");
637 uint32_t S = (offset & 0x800000) >> 23;
638 uint32_t J1 = (offset & 0x400000) >> 22;
639 uint32_t J2 = (offset & 0x200000) >> 21;
653uint32_t ARMMCCodeEmitter::
654getThumbBLTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
655 SmallVectorImpl<MCFixup> &Fixups,
656 const MCSubtargetInfo &STI)
const {
657 const MCOperand MO =
MI.getOperand(
OpIdx);
666uint32_t ARMMCCodeEmitter::
667getThumbBLXTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
668 SmallVectorImpl<MCFixup> &Fixups,
669 const MCSubtargetInfo &STI)
const {
670 const MCOperand MO =
MI.getOperand(
OpIdx);
678uint32_t ARMMCCodeEmitter::
679getThumbBRTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
680 SmallVectorImpl<MCFixup> &Fixups,
681 const MCSubtargetInfo &STI)
const {
682 const MCOperand MO =
MI.getOperand(
OpIdx);
686 return (MO.
getImm() >> 1);
690uint32_t ARMMCCodeEmitter::
691getThumbBCCTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
692 SmallVectorImpl<MCFixup> &Fixups,
693 const MCSubtargetInfo &STI)
const {
694 const MCOperand MO =
MI.getOperand(
OpIdx);
698 return (MO.
getImm() >> 1);
702uint32_t ARMMCCodeEmitter::
703getThumbCBTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
704 SmallVectorImpl<MCFixup> &Fixups,
705 const MCSubtargetInfo &STI)
const {
706 const MCOperand MO =
MI.getOperand(
OpIdx);
709 return (MO.
getImm() >> 1);
714 int NumOp =
MI.getNumOperands();
716 for (
int i = 0; i < NumOp-1; ++i) {
731uint32_t ARMMCCodeEmitter::
732getBranchTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
733 SmallVectorImpl<MCFixup> &Fixups,
734 const MCSubtargetInfo &STI)
const {
740 return getARMBranchTargetOpValue(
MI,
OpIdx, Fixups, STI);
745uint32_t ARMMCCodeEmitter::
746getARMBranchTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
747 SmallVectorImpl<MCFixup> &Fixups,
748 const MCSubtargetInfo &STI)
const {
749 const MCOperand MO =
MI.getOperand(
OpIdx);
752 return ::getBranchTargetOpValue(
MI,
OpIdx,
754 return ::getBranchTargetOpValue(
MI,
OpIdx,
761uint32_t ARMMCCodeEmitter::
762getARMBLTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
763 SmallVectorImpl<MCFixup> &Fixups,
764 const MCSubtargetInfo &STI)
const {
765 const MCOperand MO =
MI.getOperand(
OpIdx);
768 return ::getBranchTargetOpValue(
MI,
OpIdx,
776uint32_t ARMMCCodeEmitter::
777getARMBLXTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
778 SmallVectorImpl<MCFixup> &Fixups,
779 const MCSubtargetInfo &STI)
const {
780 const MCOperand MO =
MI.getOperand(
OpIdx);
789uint32_t ARMMCCodeEmitter::getThumbBranchTargetOpValue(
790 const MCInst &
MI,
unsigned OpIdx, SmallVectorImpl<MCFixup> &Fixups,
791 const MCSubtargetInfo &STI)
const {
793 const MCOperand MO =
MI.getOperand(
OpIdx);
800 bool I = (Val & 0x800000);
801 bool J1 = (Val & 0x400000);
802 bool J2 = (Val & 0x200000);
818uint32_t ARMMCCodeEmitter::
819getAdrLabelOpValue(
const MCInst &
MI,
unsigned OpIdx,
820 SmallVectorImpl<MCFixup> &Fixups,
821 const MCSubtargetInfo &STI)
const {
822 const MCOperand MO =
MI.getOperand(
OpIdx);
826 int64_t offset = MO.
getImm();
827 uint32_t Val = 0x2000;
830 if (offset == INT32_MIN) {
833 }
else if (offset < 0) {
851 assert(SoImmVal != -1 &&
"Not a valid so_imm value!");
859uint32_t ARMMCCodeEmitter::
860getT2AdrLabelOpValue(
const MCInst &
MI,
unsigned OpIdx,
861 SmallVectorImpl<MCFixup> &Fixups,
862 const MCSubtargetInfo &STI)
const {
863 const MCOperand MO =
MI.getOperand(
OpIdx);
867 int32_t Val = MO.
getImm();
868 if (Val == INT32_MIN)
879uint32_t ARMMCCodeEmitter::
880getITMaskOpValue(
const MCInst &
MI,
unsigned OpIdx,
881 SmallVectorImpl<MCFixup> &Fixups,
882 const MCSubtargetInfo &STI)
const {
883 const MCOperand MaskMO =
MI.getOperand(
OpIdx);
884 assert(MaskMO.
isImm() &&
"Unexpected operand type!");
893 const MCOperand CondMO =
MI.getOperand(
OpIdx-1);
894 assert(CondMO.
isImm() &&
"Unexpected operand type!");
895 if (CondMO.
getImm() & 1) {
897 unsigned BitsAboveLowBit = 0xF & (-LowBit << 1);
898 Mask ^= BitsAboveLowBit;
906uint32_t ARMMCCodeEmitter::
907getThumbAdrLabelOpValue(
const MCInst &
MI,
unsigned OpIdx,
908 SmallVectorImpl<MCFixup> &Fixups,
909 const MCSubtargetInfo &STI)
const {
910 const MCOperand MO =
MI.getOperand(
OpIdx);
919uint32_t ARMMCCodeEmitter::
920getThumbAddrModeRegRegOpValue(
const MCInst &
MI,
unsigned OpIdx,
921 SmallVectorImpl<MCFixup> &,
922 const MCSubtargetInfo &STI)
const {
926 const MCOperand &MO1 =
MI.getOperand(
OpIdx);
927 const MCOperand &MO2 =
MI.getOperand(
OpIdx + 1);
930 return (Rm << 3) | Rn;
936ARMMCCodeEmitter::getMVEShiftImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
937 SmallVectorImpl<MCFixup> &Fixups,
938 const MCSubtargetInfo &STI)
const {
947 unsigned Size, ShiftImm;
948 switch(
MI.getOpcode()) {
949 case ARM::MVE_VSHLL_imms16bh:
950 case ARM::MVE_VSHLL_imms16th:
951 case ARM::MVE_VSHLL_immu16bh:
952 case ARM::MVE_VSHLL_immu16th:
955 case ARM::MVE_VSHLL_imms8bh:
956 case ARM::MVE_VSHLL_imms8th:
957 case ARM::MVE_VSHLL_immu8bh:
958 case ARM::MVE_VSHLL_immu8th:
964 ShiftImm =
MI.getOperand(
OpIdx).getImm();
965 return Size + ShiftImm;
969uint32_t ARMMCCodeEmitter::
970getAddrModeImm12OpValue(
const MCInst &
MI,
unsigned OpIdx,
971 SmallVectorImpl<MCFixup> &Fixups,
972 const MCSubtargetInfo &STI)
const {
976 unsigned Reg = 0, Imm12 = 0;
979 const MCOperand &MO =
MI.getOperand(
OpIdx);
981 const MCOperand &MO1 =
MI.getOperand(
OpIdx + 1);
983 isAdd = EncodeAddrModeOpValues(
MI,
OpIdx,
Reg, Imm12, Fixups, STI);
984 }
else if (MO1.
isExpr()) {
986 "Thumb mode requires different encoding");
1002 ++MCNumCPRelocations;
1006 if (
Offset == INT32_MIN) {
1015 uint32_t
Binary = Imm12 & 0xfff;
1023template<
unsigned Bits,
unsigned Shift>
1024uint32_t ARMMCCodeEmitter::
1025getT2ScaledImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
1026 SmallVectorImpl<MCFixup> &Fixups,
1027 const MCSubtargetInfo &STI)
const {
1038 bool isAdd =
Imm >= 0;
1042 Imm = -(uint32_t)Imm;
1055uint32_t ARMMCCodeEmitter::
1056getMveAddrModeRQOpValue(
const MCInst &
MI,
unsigned OpIdx,
1057 SmallVectorImpl<MCFixup> &Fixups,
1058 const MCSubtargetInfo &STI)
const {
1061 const MCOperand &
M0 =
MI.getOperand(
OpIdx);
1062 const MCOperand &
M1 =
MI.getOperand(
OpIdx + 1);
1067 assert(Qm < 8 &&
"Qm is supposed to be encodable in 3 bits");
1069 return (Rn << 3) | Qm;
1075uint32_t ARMMCCodeEmitter::
1076getMveAddrModeQOpValue(
const MCInst &
MI,
unsigned OpIdx,
1077 SmallVectorImpl<MCFixup> &Fixups,
1078 const MCSubtargetInfo &STI)
const {
1081 const MCOperand &
M0 =
MI.getOperand(
OpIdx);
1082 const MCOperand &
M1 =
MI.getOperand(
OpIdx + 1);
1085 int32_t
Imm =
M1.getImm();
1087 bool isAdd =
Imm >= 0;
1092 Imm = -(uint32_t)Imm;
1099 assert(Qm < 8 &&
"Qm is supposed to be encodable in 3 bits");
1101 return (Qm << 8) |
Imm;
1106uint32_t ARMMCCodeEmitter::
1107getT2AddrModeImm8s4OpValue(
const MCInst &
MI,
unsigned OpIdx,
1108 SmallVectorImpl<MCFixup> &Fixups,
1109 const MCSubtargetInfo &STI)
const {
1116 const MCOperand &MO =
MI.getOperand(
OpIdx);
1122 assert(MO.
isExpr() &&
"Unexpected machine operand type!");
1123 const MCExpr *Expr = MO.
getExpr();
1127 ++MCNumCPRelocations;
1129 isAdd = EncodeAddrModeOpValues(
MI,
OpIdx,
Reg, Imm8, Fixups, STI);
1137 assert(((Imm8 & 0x3) == 0) &&
"Not a valid immediate!");
1149ARMMCCodeEmitter::getT2AddrModeImm7s4OpValue(
const MCInst &
MI,
unsigned OpIdx,
1150 SmallVectorImpl<MCFixup> &Fixups,
1151 const MCSubtargetInfo &STI)
const {
1157 bool isAdd = EncodeAddrModeOpValues(
MI,
OpIdx,
Reg, Imm7, Fixups, STI);
1165 uint32_t
Binary = (Imm7 >> 2) & 0xff;
1175uint32_t ARMMCCodeEmitter::
1176getT2AddrModeImm0_1020s4OpValue(
const MCInst &
MI,
unsigned OpIdx,
1177 SmallVectorImpl<MCFixup> &Fixups,
1178 const MCSubtargetInfo &STI)
const {
1181 const MCOperand &MO =
MI.getOperand(
OpIdx);
1182 const MCOperand &MO1 =
MI.getOperand(
OpIdx + 1);
1188uint32_t ARMMCCodeEmitter::getHiLoImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
1189 SmallVectorImpl<MCFixup> &Fixups,
1190 const MCSubtargetInfo &STI)
const {
1193 const MCOperand &MO =
MI.getOperand(
OpIdx);
1196 return static_cast<unsigned>(MO.
getImm());
1204 E = ARM16Expr->getSubExpr();
1207 const int64_t
Value = MCE->getValue();
1208 if (
Value > UINT32_MAX)
1211 switch (ARM16Expr->getSpecifier()) {
1213 return (int32_t(
Value) & 0xffff0000) >> 16;
1215 return (int32_t(
Value) & 0x0000ffff);
1218 return (int32_t(
Value) & 0xff000000) >> 24;
1220 return (int32_t(
Value) & 0x00ff0000) >> 16;
1222 return (int32_t(
Value) & 0x0000ff00) >> 8;
1224 return (int32_t(
Value) & 0x000000ff);
1230 switch (ARM16Expr->getSpecifier()) {
1272 ":upper0_7:, lower8_15: or :lower0_7:");
1275uint32_t ARMMCCodeEmitter::
1276getLdStSORegOpValue(
const MCInst &
MI,
unsigned OpIdx,
1277 SmallVectorImpl<MCFixup> &Fixups,
1278 const MCSubtargetInfo &STI)
const {
1279 const MCOperand &MO =
MI.getOperand(
OpIdx);
1280 const MCOperand &MO1 =
MI.getOperand(
OpIdx+1);
1281 const MCOperand &MO2 =
MI.getOperand(
OpIdx+2);
1287 unsigned SBits = getShiftOp(ShOp);
1291 assert((ShImm & ~0x1f) == 0 &&
"Out of range shift amount");
1309uint32_t ARMMCCodeEmitter::
1310getAddrMode2OffsetOpValue(
const MCInst &
MI,
unsigned OpIdx,
1311 SmallVectorImpl<MCFixup> &Fixups,
1312 const MCSubtargetInfo &STI)
const {
1316 const MCOperand &MO =
MI.getOperand(
OpIdx);
1317 const MCOperand &MO1 =
MI.getOperand(
OpIdx+1);
1326 Binary |= getShiftOp(ShOp) << 5;
1332uint32_t ARMMCCodeEmitter::
1333getPostIdxRegOpValue(
const MCInst &
MI,
unsigned OpIdx,
1334 SmallVectorImpl<MCFixup> &Fixups,
1335 const MCSubtargetInfo &STI)
const {
1338 const MCOperand &MO =
MI.getOperand(
OpIdx);
1339 const MCOperand &MO1 =
MI.getOperand(
OpIdx+1);
1340 bool isAdd = MO1.
getImm() != 0;
1344uint32_t ARMMCCodeEmitter::
1345getAddrMode3OffsetOpValue(
const MCInst &
MI,
unsigned OpIdx,
1346 SmallVectorImpl<MCFixup> &Fixups,
1347 const MCSubtargetInfo &STI)
const {
1352 const MCOperand &MO =
MI.getOperand(
OpIdx);
1353 const MCOperand &MO1 =
MI.getOperand(
OpIdx+1);
1361 return Imm8 | (isAdd << 8) | (isImm << 9);
1364uint32_t ARMMCCodeEmitter::
1365getAddrMode3OpValue(
const MCInst &
MI,
unsigned OpIdx,
1366 SmallVectorImpl<MCFixup> &Fixups,
1367 const MCSubtargetInfo &STI)
const {
1373 const MCOperand &MO =
MI.getOperand(
OpIdx);
1374 const MCOperand &MO1 =
MI.getOperand(
OpIdx+1);
1375 const MCOperand &MO2 =
MI.getOperand(
OpIdx+2);
1381 assert(MO.
isExpr() &&
"Unexpected machine operand type!");
1382 const MCExpr *Expr = MO.
getExpr();
1386 ++MCNumCPRelocations;
1387 return (Rn << 9) | (1 << 13);
1397 return (Rn << 9) |
Imm8 | (isAdd << 8) | (isImm << 13);
1401uint32_t ARMMCCodeEmitter::
1402getAddrModeThumbSPOpValue(
const MCInst &
MI,
unsigned OpIdx,
1403 SmallVectorImpl<MCFixup> &Fixups,
1404 const MCSubtargetInfo &STI)
const {
1407 const MCOperand &MO1 =
MI.getOperand(
OpIdx + 1);
1409 "Unexpected base register!");
1413 return MO1.
getImm() & 0xff;
1417uint32_t ARMMCCodeEmitter::
1418getAddrModeISOpValue(
const MCInst &
MI,
unsigned OpIdx,
1419 SmallVectorImpl<MCFixup> &Fixups,
1420 const MCSubtargetInfo &STI)
const {
1424 const MCOperand &MO =
MI.getOperand(
OpIdx);
1425 const MCOperand &MO1 =
MI.getOperand(
OpIdx + 1);
1427 unsigned Imm5 = MO1.
getImm();
1428 return ((Imm5 & 0x1f) << 3) | Rn;
1432uint32_t ARMMCCodeEmitter::
1433getAddrModePCOpValue(
const MCInst &
MI,
unsigned OpIdx,
1434 SmallVectorImpl<MCFixup> &Fixups,
1435 const MCSubtargetInfo &STI)
const {
1436 const MCOperand MO =
MI.getOperand(
OpIdx);
1439 return (MO.
getImm() >> 2);
1443uint32_t ARMMCCodeEmitter::
1444getAddrMode5OpValue(
const MCInst &
MI,
unsigned OpIdx,
1445 SmallVectorImpl<MCFixup> &Fixups,
1446 const MCSubtargetInfo &STI)
const {
1453 const MCOperand &MO =
MI.getOperand(
OpIdx);
1459 assert(MO.
isExpr() &&
"Unexpected machine operand type!");
1460 const MCExpr *Expr = MO.
getExpr();
1468 ++MCNumCPRelocations;
1470 EncodeAddrModeOpValues(
MI,
OpIdx,
Reg, Imm8, Fixups, STI);
1483uint32_t ARMMCCodeEmitter::
1484getAddrMode5FP16OpValue(
const MCInst &
MI,
unsigned OpIdx,
1485 SmallVectorImpl<MCFixup> &Fixups,
1486 const MCSubtargetInfo &STI)
const {
1493 const MCOperand &MO =
MI.getOperand(
OpIdx);
1499 assert(MO.
isExpr() &&
"Unexpected machine operand type!");
1500 const MCExpr *Expr = MO.
getExpr();
1508 ++MCNumCPRelocations;
1510 EncodeAddrModeOpValues(
MI,
OpIdx,
Reg, Imm8, Fixups, STI);
1522unsigned ARMMCCodeEmitter::getModImmOpValue(
const MCInst &
MI,
unsigned Op,
1523 SmallVectorImpl<MCFixup> &Fixups,
1524 const MCSubtargetInfo &ST)
const {
1525 const MCOperand &MO =
MI.getOperand(
Op);
1529 const MCExpr *Expr = MO.
getExpr();
1540unsigned ARMMCCodeEmitter::getT2SOImmOpValue(
const MCInst &
MI,
unsigned Op,
1541 SmallVectorImpl<MCFixup> &Fixups,
1542 const MCSubtargetInfo &STI)
const {
1543 const MCOperand &MO =
MI.getOperand(
Op);
1547 const MCExpr *Expr = MO.
getExpr();
1553 unsigned SoImm = MO.
getImm();
1555 assert(Encoded != ~0U &&
"Not a Thumb2 so_imm value?");
1559unsigned ARMMCCodeEmitter::
1560getSORegRegOpValue(
const MCInst &
MI,
unsigned OpIdx,
1561 SmallVectorImpl<MCFixup> &Fixups,
1562 const MCSubtargetInfo &STI)
const {
1573 const MCOperand &MO =
MI.getOperand(
OpIdx);
1574 const MCOperand &MO1 =
MI.getOperand(
OpIdx + 1);
1575 const MCOperand &MO2 =
MI.getOperand(
OpIdx + 2);
1583 MCRegister Rs = MO1.
getReg();
1607unsigned ARMMCCodeEmitter::
1608getSORegImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
1609 SmallVectorImpl<MCFixup> &Fixups,
1610 const MCSubtargetInfo &STI)
const {
1619 const MCOperand &MO =
MI.getOperand(
OpIdx);
1620 const MCOperand &MO1 =
MI.getOperand(
OpIdx + 1);
1649 assert(
Offset < 32 &&
"Offset must be in range 0-31!");
1654unsigned ARMMCCodeEmitter::
1655getT2AddrModeSORegOpValue(
const MCInst &
MI,
unsigned OpNum,
1656 SmallVectorImpl<MCFixup> &Fixups,
1657 const MCSubtargetInfo &STI)
const {
1658 const MCOperand &MO1 =
MI.getOperand(OpNum);
1659 const MCOperand &MO2 =
MI.getOperand(OpNum+1);
1660 const MCOperand &MO3 =
MI.getOperand(OpNum+2);
1673template<
unsigned Bits,
unsigned Shift>
1674unsigned ARMMCCodeEmitter::
1675getT2AddrModeImmOpValue(
const MCInst &
MI,
unsigned OpNum,
1676 SmallVectorImpl<MCFixup> &Fixups,
1677 const MCSubtargetInfo &STI)
const {
1678 const MCOperand &MO1 =
MI.getOperand(OpNum);
1679 const MCOperand &MO2 =
MI.getOperand(OpNum+1);
1687 int32_t tmp = (int32_t)MO2.
getImm();
1688 if (tmp == INT32_MIN) {
1690 }
else if (tmp < 0) {
1695 Value |= (tmp >> Shift) & ((1U << Bits) - 1);
1699unsigned ARMMCCodeEmitter::
1700getT2AddrModeImm8OffsetOpValue(
const MCInst &
MI,
unsigned OpNum,
1701 SmallVectorImpl<MCFixup> &Fixups,
1702 const MCSubtargetInfo &STI)
const {
1703 const MCOperand &MO1 =
MI.getOperand(OpNum);
1707 auto tmp =
static_cast<uint32_t
>(MO1.
getImm());
1708 if (
static_cast<int32_t
>(tmp) < 0)
1716unsigned ARMMCCodeEmitter::
1717getT2SORegOpValue(
const MCInst &
MI,
unsigned OpIdx,
1718 SmallVectorImpl<MCFixup> &Fixups,
1719 const MCSubtargetInfo &STI)
const {
1728 const MCOperand &MO =
MI.getOperand(
OpIdx);
1729 const MCOperand &MO1 =
MI.getOperand(
OpIdx + 1);
1759unsigned ARMMCCodeEmitter::
1760getBitfieldInvertedMaskOpValue(
const MCInst &
MI,
unsigned Op,
1761 SmallVectorImpl<MCFixup> &Fixups,
1762 const MCSubtargetInfo &STI)
const {
1765 const MCOperand &MO =
MI.getOperand(
Op);
1766 uint32_t
v = ~MO.getImm();
1769 assert(v != 0 && lsb < 32 && msb < 32 &&
"Illegal bitfield mask!");
1770 return lsb | (msb << 5);
1773unsigned ARMMCCodeEmitter::
1774getRegisterListOpValue(
const MCInst &
MI,
unsigned Op,
1775 SmallVectorImpl<MCFixup> &Fixups,
1776 const MCSubtargetInfo &STI)
const {
1783 MCRegister
Reg =
MI.getOperand(
Op).getReg();
1784 bool SPRRegs = ARMMCRegisterClasses[ARM::SPRRegClassID].contains(
Reg);
1785 bool DPRRegs = ARMMCRegisterClasses[ARM::DPRRegClassID].contains(
Reg);
1789 if (SPRRegs || DPRRegs ||
Reg == ARM::VPR) {
1792 unsigned NumRegs = (
MI.getNumOperands() -
Op) & 0xff;
1793 Binary |= (RegNo & 0x1f) << 8;
1795 if (
MI.getOpcode() == ARM::VSCCLRMD)
1798 else if (
MI.getOpcode() == ARM::VSCCLRMS) {
1803 for (
unsigned I =
Op,
E =
MI.getNumOperands();
I <
E; ++
I) {
1804 Reg =
MI.getOperand(
I).getReg();
1805 if (ARMMCRegisterClasses[ARM::SPRRegClassID].
contains(
Reg))
1807 else if (ARMMCRegisterClasses[ARM::DPRRegClassID].
contains(
Reg))
1818 [&](
const MCOperand &
LHS,
const MCOperand &
RHS) {
1819 return MRI.getEncodingValue(
LHS.getReg()) <
1820 MRI.getEncodingValue(
RHS.getReg());
1822 for (
unsigned I =
Op,
E =
MI.getNumOperands();
I <
E; ++
I) {
1823 unsigned RegNo =
MRI.getEncodingValue(
MI.getOperand(
I).getReg());
1833unsigned ARMMCCodeEmitter::
1834getAddrMode6AddressOpValue(
const MCInst &
MI,
unsigned Op,
1835 SmallVectorImpl<MCFixup> &Fixups,
1836 const MCSubtargetInfo &STI)
const {
1837 const MCOperand &
Reg =
MI.getOperand(
Op);
1838 const MCOperand &
Imm =
MI.getOperand(
Op + 1);
1843 switch (
Imm.getImm()) {
1847 case 8:
Align = 0x01;
break;
1848 case 16:
Align = 0x02;
break;
1849 case 32:
Align = 0x03;
break;
1852 return RegNo | (
Align << 4);
1857unsigned ARMMCCodeEmitter::
1858getAddrMode6OneLane32AddressOpValue(
const MCInst &
MI,
unsigned Op,
1859 SmallVectorImpl<MCFixup> &Fixups,
1860 const MCSubtargetInfo &STI)
const {
1861 const MCOperand &
Reg =
MI.getOperand(
Op);
1862 const MCOperand &
Imm =
MI.getOperand(
Op + 1);
1867 switch (
Imm.getImm()) {
1872 case 2:
Align = 0x00;
break;
1873 case 4:
Align = 0x03;
break;
1876 return RegNo | (
Align << 4);
1884unsigned ARMMCCodeEmitter::
1885getAddrMode6DupAddressOpValue(
const MCInst &
MI,
unsigned Op,
1886 SmallVectorImpl<MCFixup> &Fixups,
1887 const MCSubtargetInfo &STI)
const {
1888 const MCOperand &
Reg =
MI.getOperand(
Op);
1889 const MCOperand &
Imm =
MI.getOperand(
Op + 1);
1894 switch (
Imm.getImm()) {
1898 case 8:
Align = 0x01;
break;
1899 case 16:
Align = 0x03;
break;
1902 return RegNo | (
Align << 4);
1905unsigned ARMMCCodeEmitter::
1906getAddrMode6OffsetOpValue(
const MCInst &
MI,
unsigned Op,
1907 SmallVectorImpl<MCFixup> &Fixups,
1908 const MCSubtargetInfo &STI)
const {
1909 const MCOperand &MO =
MI.getOperand(
Op);
1915unsigned ARMMCCodeEmitter::
1916getShiftRight8Imm(
const MCInst &
MI,
unsigned Op,
1917 SmallVectorImpl<MCFixup> &Fixups,
1918 const MCSubtargetInfo &STI)
const {
1919 return 8 -
MI.getOperand(
Op).getImm();
1922unsigned ARMMCCodeEmitter::
1923getShiftRight16Imm(
const MCInst &
MI,
unsigned Op,
1924 SmallVectorImpl<MCFixup> &Fixups,
1925 const MCSubtargetInfo &STI)
const {
1926 return 16 -
MI.getOperand(
Op).getImm();
1929unsigned ARMMCCodeEmitter::
1930getShiftRight32Imm(
const MCInst &
MI,
unsigned Op,
1931 SmallVectorImpl<MCFixup> &Fixups,
1932 const MCSubtargetInfo &STI)
const {
1933 return 32 -
MI.getOperand(
Op).getImm();
1936unsigned ARMMCCodeEmitter::
1937getShiftRight64Imm(
const MCInst &
MI,
unsigned Op,
1938 SmallVectorImpl<MCFixup> &Fixups,
1939 const MCSubtargetInfo &STI)
const {
1940 return 64 -
MI.getOperand(
Op).getImm();
1943void ARMMCCodeEmitter::encodeInstruction(
const MCInst &
MI,
1944 SmallVectorImpl<char> &CB,
1945 SmallVectorImpl<MCFixup> &Fixups,
1946 const MCSubtargetInfo &STI)
const {
1948 const MCInstrDesc &
Desc = MCII.
get(
MI.getOpcode());
1949 uint64_t TSFlags =
Desc.TSFlags;
1954 if (
Desc.getSize() == 2 ||
Desc.getSize() == 4)
1961 uint32_t
Binary = getBinaryCodeForInstr(
MI, Fixups, STI);
1975template <
bool isNeg, ARM::Fixups fixup>
1977ARMMCCodeEmitter::getBFTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
1978 SmallVectorImpl<MCFixup> &Fixups,
1979 const MCSubtargetInfo &STI)
const {
1980 const MCOperand MO =
MI.getOperand(
OpIdx);
1982 return ::getBranchTargetOpValue(
MI,
OpIdx, fixup, Fixups, STI);
1987ARMMCCodeEmitter::getBFAfterTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
1988 SmallVectorImpl<MCFixup> &Fixups,
1989 const MCSubtargetInfo &STI)
const {
1990 const MCOperand MO =
MI.getOperand(
OpIdx);
1991 const MCOperand BranchMO =
MI.getOperand(0);
1998 addFixup(Fixups, 0, DiffExpr, Kind);
2004 assert(Diff == 4 || Diff == 2);
2009uint32_t ARMMCCodeEmitter::getVPTMaskOpValue(
const MCInst &
MI,
unsigned OpIdx,
2010 SmallVectorImpl<MCFixup> &Fixups,
2011 const MCSubtargetInfo &STI)
const {
2012 const MCOperand MO =
MI.getOperand(
OpIdx);
2020 unsigned PrevBit = 0;
2021 for (
int i = 3; i >= 0; --i) {
2025 if ((
Value & ~(~0U << i)) == 0) {
2040uint32_t ARMMCCodeEmitter::getRestrictedCondCodeOpValue(
2041 const MCInst &
MI,
unsigned OpIdx, SmallVectorImpl<MCFixup> &Fixups,
2042 const MCSubtargetInfo &STI)
const {
2044 const MCOperand MO =
MI.getOperand(
OpIdx);
2049 assert(0 &&
"Unexpected Condition!");
2068uint32_t ARMMCCodeEmitter::
2069getPowerTwoOpValue(
const MCInst &
MI,
unsigned OpIdx,
2070 SmallVectorImpl<MCFixup> &Fixups,
2071 const MCSubtargetInfo &STI)
const {
2072 const MCOperand &MO =
MI.getOperand(
OpIdx);
2077template <
unsigned start>
2078uint32_t ARMMCCodeEmitter::
2079getMVEPairVectorIndexOpValue(
const MCInst &
MI,
unsigned OpIdx,
2080 SmallVectorImpl<MCFixup> &Fixups,
2081 const MCSubtargetInfo &STI)
const {
2082 const MCOperand MO =
MI.getOperand(
OpIdx);
2086 return Value - start;
2089#include "ARMGenMCCodeEmitter.inc"
2093 return new ARMMCCodeEmitter(MCII, Ctx,
true);
2098 return new ARMMCCodeEmitter(MCII, Ctx,
false);
unsigned const MachineRegisterInfo * MRI
static void addFixup(SmallVectorImpl< MCFixup > &Fixups, uint32_t Offset, const MCExpr *Value, uint16_t Kind, bool PCRel=false)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
static bool isThumb(const MCSubtargetInfo &STI)
static bool HasConditionalBranch(const MCInst &MI)
Return true if this branch has a non-always predication.
static void addFixup(SmallVectorImpl< MCFixup > &Fixups, uint32_t Offset, const MCExpr *Value, uint16_t Kind)
static int32_t encodeThumbBLOffset(int32_t offset)
static uint32_t getBranchTargetOpValue(const MCInst &MI, unsigned OpIdx, unsigned FixupKind, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI)
getBranchTargetOpValue - Helper function to get the branch target operand, which is either an immedia...
Function Alias Analysis false
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool isNeg(Value *V)
Returns true if the operation is a negation of V, and it works for both integers and floats.
static bool isReg(const MCInst &MI, unsigned OpNo)
MachineInstr unsigned OpIdx
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
MCCodeEmitter - Generic instruction encoding interface.
Context object for machine code objects.
const MCRegisterInfo * getRegisterInfo() const
Base class for the full range of assembler expressions which are needed for parsing.
@ Specifier
Expression with a relocation specifier.
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, bool PCRel=false)
Consider bit fields if we need more flags.
Instances of this class represent a single low-level machine instruction.
Interface to description of machine instruction set.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
Instances of this class represent operands of the MCInst class.
MCRegister getReg() const
Returns the register number.
const MCExpr * getExpr() const
uint64_t getDFPImm() const
uint16_t getEncodingValue(MCRegister Reg) const
Returns the encoding for Reg.
constexpr bool isValid() const
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
const Triple & getTargetTriple() const
constexpr unsigned id() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
unsigned char getAM3Offset(unsigned AM3Opc)
unsigned getSORegOffset(unsigned Op)
int getSOImmVal(unsigned Arg)
getSOImmVal - Given a 32-bit immediate, if it is something that can fit into an shifter_operand immed...
ShiftOpc getAM2ShiftOpc(unsigned AM2Opc)
unsigned getAM2Offset(unsigned AM2Opc)
int getT2SOImmVal(unsigned Arg)
getT2SOImmVal - Given a 32-bit immediate, if it is something that can fit into a Thumb-2 shifter_oper...
ShiftOpc getSORegShOp(unsigned Op)
AddrOpc getAM5Op(unsigned AM5Opc)
unsigned char getAM5Offset(unsigned AM5Opc)
AddrOpc getAM2Op(unsigned AM2Opc)
AddrOpc getAM3Op(unsigned AM3Opc)
@ fixup_thumb_adr_pcrel_10
@ fixup_arm_thumb_upper_8_15
@ fixup_arm_thumb_lower_0_7
@ fixup_arm_pcrel_10_unscaled
@ fixup_arm_thumb_upper_0_7
@ fixup_bfcsel_else_target
@ fixup_arm_ldst_pcrel_12
@ fixup_arm_thumb_lower_8_15
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
FunctionAddr VTableAddr Value
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
APFloat abs(APFloat X)
Returns the absolute value of the argument.
MCCodeEmitter * createARMLEMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
unsigned M1(unsigned Val)
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
uint16_t MCFixupKind
Extensible enumeration to represent the type of a fixup.
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
static Lanai::Fixups FixupKind(const MCExpr *Expr)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
To bit_cast(const From &from) noexcept
DWARFExpression::Operation Op
unsigned M0(unsigned Val)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
MCCodeEmitter * createARMBEMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)