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();
76 uint64_t getBinaryCodeForInstr(
const MCInst &
MI,
77 SmallVectorImpl<MCFixup> &Fixups,
78 const MCSubtargetInfo &STI)
const;
82 unsigned getMachineOpValue(
const MCInst &
MI,
const MCOperand &MO,
83 SmallVectorImpl<MCFixup> &Fixups,
84 const MCSubtargetInfo &STI)
const;
90 uint32_t getHiLoImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
91 SmallVectorImpl<MCFixup> &Fixups,
92 const MCSubtargetInfo &STI)
const;
94 bool EncodeAddrModeOpValues(
const MCInst &
MI,
unsigned OpIdx,
95 unsigned &
Reg,
unsigned &
Imm,
96 SmallVectorImpl<MCFixup> &Fixups,
97 const MCSubtargetInfo &STI)
const;
101 uint32_t getThumbBLTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
102 SmallVectorImpl<MCFixup> &Fixups,
103 const MCSubtargetInfo &STI)
const;
107 uint32_t getThumbBLXTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
108 SmallVectorImpl<MCFixup> &Fixups,
109 const MCSubtargetInfo &STI)
const;
112 uint32_t getThumbBRTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
113 SmallVectorImpl<MCFixup> &Fixups,
114 const MCSubtargetInfo &STI)
const;
117 uint32_t getThumbBCCTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
118 SmallVectorImpl<MCFixup> &Fixups,
119 const MCSubtargetInfo &STI)
const;
122 uint32_t getThumbCBTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
123 SmallVectorImpl<MCFixup> &Fixups,
124 const MCSubtargetInfo &STI)
const;
129 SmallVectorImpl<MCFixup> &Fixups,
130 const MCSubtargetInfo &STI)
const;
134 uint32_t getThumbBranchTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
135 SmallVectorImpl<MCFixup> &Fixups,
136 const MCSubtargetInfo &STI)
const;
140 uint32_t getARMBranchTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
141 SmallVectorImpl<MCFixup> &Fixups,
142 const MCSubtargetInfo &STI)
const;
143 uint32_t getARMBLTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
144 SmallVectorImpl<MCFixup> &Fixups,
145 const MCSubtargetInfo &STI)
const;
146 uint32_t getARMBLXTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
147 SmallVectorImpl<MCFixup> &Fixups,
148 const MCSubtargetInfo &STI)
const;
152 uint32_t getAdrLabelOpValue(
const MCInst &
MI,
unsigned OpIdx,
153 SmallVectorImpl<MCFixup> &Fixups,
154 const MCSubtargetInfo &STI)
const;
155 uint32_t getThumbAdrLabelOpValue(
const MCInst &
MI,
unsigned OpIdx,
156 SmallVectorImpl<MCFixup> &Fixups,
157 const MCSubtargetInfo &STI)
const;
158 uint32_t getT2AdrLabelOpValue(
const MCInst &
MI,
unsigned OpIdx,
159 SmallVectorImpl<MCFixup> &Fixups,
160 const MCSubtargetInfo &STI)
const;
162 uint32_t getITMaskOpValue(
const MCInst &
MI,
unsigned OpIdx,
163 SmallVectorImpl<MCFixup> &Fixups,
164 const MCSubtargetInfo &STI)
const;
168 uint32_t getMVEShiftImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
169 SmallVectorImpl<MCFixup> &Fixups,
170 const MCSubtargetInfo &STI)
const;
174 uint32_t getAddrModeImm12OpValue(
const MCInst &
MI,
unsigned OpIdx,
175 SmallVectorImpl<MCFixup> &Fixups,
176 const MCSubtargetInfo &STI)
const;
179 uint32_t getThumbAddrModeRegRegOpValue(
const MCInst &
MI,
unsigned OpIdx,
180 SmallVectorImpl<MCFixup> &Fixups,
181 const MCSubtargetInfo &STI)
const;
185 uint32_t getT2AddrModeImm8s4OpValue(
const MCInst &
MI,
unsigned OpIdx,
186 SmallVectorImpl<MCFixup> &Fixups,
187 const MCSubtargetInfo &STI)
const;
191 uint32_t getT2AddrModeImm7s4OpValue(
const MCInst &
MI,
unsigned OpIdx,
192 SmallVectorImpl<MCFixup> &Fixups,
193 const MCSubtargetInfo &STI)
const;
197 uint32_t getT2AddrModeImm0_1020s4OpValue(
const MCInst &
MI,
unsigned OpIdx,
198 SmallVectorImpl<MCFixup> &Fixups,
199 const MCSubtargetInfo &STI)
const;
203 template<
unsigned Bits,
unsigned Shift>
204 uint32_t getT2ScaledImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
205 SmallVectorImpl<MCFixup> &Fixups,
206 const MCSubtargetInfo &STI)
const;
210 uint32_t getMveAddrModeRQOpValue(
const MCInst &
MI,
unsigned OpIdx,
211 SmallVectorImpl<MCFixup> &Fixups,
212 const MCSubtargetInfo &STI)
const;
217 uint32_t getMveAddrModeQOpValue(
const MCInst &
MI,
unsigned OpIdx,
218 SmallVectorImpl<MCFixup> &Fixups,
219 const MCSubtargetInfo &STI)
const;
223 uint32_t getLdStSORegOpValue(
const MCInst &
MI,
unsigned OpIdx,
224 SmallVectorImpl<MCFixup> &Fixups,
225 const MCSubtargetInfo &STI)
const;
228 uint32_t getLdStmModeOpValue(
const MCInst &
MI,
unsigned OpIdx,
229 SmallVectorImpl<MCFixup> &Fixups,
230 const MCSubtargetInfo &STI)
const {
257 uint32_t getAddrMode2OffsetOpValue(
const MCInst &
MI,
unsigned OpIdx,
258 SmallVectorImpl<MCFixup> &Fixups,
259 const MCSubtargetInfo &STI)
const;
262 uint32_t getPostIdxRegOpValue(
const MCInst &
MI,
unsigned OpIdx,
263 SmallVectorImpl<MCFixup> &Fixups,
264 const MCSubtargetInfo &STI)
const;
267 uint32_t getAddrMode3OffsetOpValue(
const MCInst &
MI,
unsigned OpIdx,
268 SmallVectorImpl<MCFixup> &Fixups,
269 const MCSubtargetInfo &STI)
const;
272 uint32_t getAddrMode3OpValue(
const MCInst &
MI,
unsigned OpIdx,
273 SmallVectorImpl<MCFixup> &Fixups,
274 const MCSubtargetInfo &STI)
const;
278 uint32_t getAddrModeThumbSPOpValue(
const MCInst &
MI,
unsigned OpIdx,
279 SmallVectorImpl<MCFixup> &Fixups,
280 const MCSubtargetInfo &STI)
const;
283 uint32_t getAddrModeISOpValue(
const MCInst &
MI,
unsigned OpIdx,
284 SmallVectorImpl<MCFixup> &Fixups,
285 const MCSubtargetInfo &STI)
const;
288 uint32_t getAddrModePCOpValue(
const MCInst &
MI,
unsigned OpIdx,
289 SmallVectorImpl<MCFixup> &Fixups,
290 const MCSubtargetInfo &STI)
const;
293 uint32_t getAddrMode5OpValue(
const MCInst &
MI,
unsigned OpIdx,
294 SmallVectorImpl<MCFixup> &Fixups,
295 const MCSubtargetInfo &STI)
const;
298 uint32_t getAddrMode5FP16OpValue(
const MCInst &
MI,
unsigned OpIdx,
299 SmallVectorImpl<MCFixup> &Fixups,
300 const MCSubtargetInfo &STI)
const;
303 unsigned getCCOutOpValue(
const MCInst &
MI,
unsigned Op,
304 SmallVectorImpl<MCFixup> &Fixups,
305 const MCSubtargetInfo &STI)
const {
308 return MI.getOperand(
Op).getReg() == ARM::CPSR;
311 unsigned getModImmOpValue(
const MCInst &
MI,
unsigned Op,
312 SmallVectorImpl<MCFixup> &Fixups,
313 const MCSubtargetInfo &ST)
const;
316 unsigned getT2SOImmOpValue(
const MCInst &
MI,
unsigned Op,
317 SmallVectorImpl<MCFixup> &Fixups,
318 const MCSubtargetInfo &STI)
const;
320 unsigned getT2AddrModeSORegOpValue(
const MCInst &
MI,
unsigned OpNum,
321 SmallVectorImpl<MCFixup> &Fixups,
322 const MCSubtargetInfo &STI)
const;
323 template<
unsigned Bits,
unsigned Shift>
324 unsigned getT2AddrModeImmOpValue(
const MCInst &
MI,
unsigned OpNum,
325 SmallVectorImpl<MCFixup> &Fixups,
326 const MCSubtargetInfo &STI)
const;
327 unsigned getT2AddrModeImm8OffsetOpValue(
const MCInst &
MI,
unsigned OpNum,
328 SmallVectorImpl<MCFixup> &Fixups,
329 const MCSubtargetInfo &STI)
const;
332 unsigned getSORegRegOpValue(
const MCInst &
MI,
unsigned Op,
333 SmallVectorImpl<MCFixup> &Fixups,
334 const MCSubtargetInfo &STI)
const;
335 unsigned getSORegImmOpValue(
const MCInst &
MI,
unsigned Op,
336 SmallVectorImpl<MCFixup> &Fixups,
337 const MCSubtargetInfo &STI)
const;
338 unsigned getT2SORegOpValue(
const MCInst &
MI,
unsigned Op,
339 SmallVectorImpl<MCFixup> &Fixups,
340 const MCSubtargetInfo &STI)
const;
342 unsigned getNEONVcvtImm32OpValue(
const MCInst &
MI,
unsigned Op,
343 SmallVectorImpl<MCFixup> &Fixups,
344 const MCSubtargetInfo &STI)
const {
345 return 64 -
MI.getOperand(
Op).getImm();
348 unsigned getBitfieldInvertedMaskOpValue(
const MCInst &
MI,
unsigned Op,
349 SmallVectorImpl<MCFixup> &Fixups,
350 const MCSubtargetInfo &STI)
const;
352 unsigned getRegisterListOpValue(
const MCInst &
MI,
unsigned Op,
353 SmallVectorImpl<MCFixup> &Fixups,
354 const MCSubtargetInfo &STI)
const;
355 unsigned getAddrMode6AddressOpValue(
const MCInst &
MI,
unsigned Op,
356 SmallVectorImpl<MCFixup> &Fixups,
357 const MCSubtargetInfo &STI)
const;
358 unsigned getAddrMode6OneLane32AddressOpValue(
const MCInst &
MI,
unsigned Op,
359 SmallVectorImpl<MCFixup> &Fixups,
360 const MCSubtargetInfo &STI)
const;
361 unsigned getAddrMode6DupAddressOpValue(
const MCInst &
MI,
unsigned Op,
362 SmallVectorImpl<MCFixup> &Fixups,
363 const MCSubtargetInfo &STI)
const;
364 unsigned getAddrMode6OffsetOpValue(
const MCInst &
MI,
unsigned Op,
365 SmallVectorImpl<MCFixup> &Fixups,
366 const MCSubtargetInfo &STI)
const;
368 unsigned getShiftRight8Imm(
const MCInst &
MI,
unsigned Op,
369 SmallVectorImpl<MCFixup> &Fixups,
370 const MCSubtargetInfo &STI)
const;
371 unsigned getShiftRight16Imm(
const MCInst &
MI,
unsigned Op,
372 SmallVectorImpl<MCFixup> &Fixups,
373 const MCSubtargetInfo &STI)
const;
374 unsigned getShiftRight32Imm(
const MCInst &
MI,
unsigned Op,
375 SmallVectorImpl<MCFixup> &Fixups,
376 const MCSubtargetInfo &STI)
const;
377 unsigned getShiftRight64Imm(
const MCInst &
MI,
unsigned Op,
378 SmallVectorImpl<MCFixup> &Fixups,
379 const MCSubtargetInfo &STI)
const;
381 unsigned NEONThumb2DataIPostEncoder(
const MCInst &
MI,
382 unsigned EncodedValue,
383 const MCSubtargetInfo &STI)
const;
384 unsigned NEONThumb2LoadStorePostEncoder(
const MCInst &
MI,
385 unsigned EncodedValue,
386 const MCSubtargetInfo &STI)
const;
387 unsigned NEONThumb2DupPostEncoder(
const MCInst &
MI,
388 unsigned EncodedValue,
389 const MCSubtargetInfo &STI)
const;
390 unsigned NEONThumb2V8PostEncoder(
const MCInst &
MI,
391 unsigned EncodedValue,
392 const MCSubtargetInfo &STI)
const;
394 unsigned VFPThumb2PostEncoder(
const MCInst &
MI,
395 unsigned EncodedValue,
396 const MCSubtargetInfo &STI)
const;
398 uint32_t getPowerTwoOpValue(
const MCInst &
MI,
unsigned OpIdx,
399 SmallVectorImpl<MCFixup> &Fixups,
400 const MCSubtargetInfo &STI)
const;
402 void encodeInstruction(
const MCInst &
MI, SmallVectorImpl<char> &CB,
403 SmallVectorImpl<MCFixup> &Fixups,
404 const MCSubtargetInfo &STI)
const override;
406 template <
bool isNeg, ARM::Fixups fixup>
407 uint32_t getBFTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
408 SmallVectorImpl<MCFixup> &Fixups,
409 const MCSubtargetInfo &STI)
const;
411 uint32_t getBFAfterTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
412 SmallVectorImpl<MCFixup> &Fixups,
413 const MCSubtargetInfo &STI)
const;
415 uint32_t getVPTMaskOpValue(
const MCInst &
MI,
unsigned OpIdx,
416 SmallVectorImpl<MCFixup> &Fixups,
417 const MCSubtargetInfo &STI)
const;
418 uint32_t getRestrictedCondCodeOpValue(
const MCInst &
MI,
unsigned OpIdx,
419 SmallVectorImpl<MCFixup> &Fixups,
420 const MCSubtargetInfo &STI)
const;
421 template <
unsigned size>
422 uint32_t getMVEPairVectorIndexOpValue(
const MCInst &
MI,
unsigned OpIdx,
423 SmallVectorImpl<MCFixup> &Fixups,
424 const MCSubtargetInfo &STI)
const;
470unsigned ARMMCCodeEmitter::NEONThumb2DataIPostEncoder(
const MCInst &
MI,
471 unsigned EncodedValue,
477 unsigned Bit24 = EncodedValue & 0x01000000;
478 unsigned Bit28 = Bit24 << 4;
479 EncodedValue &= 0xEFFFFFFF;
480 EncodedValue |= Bit28;
481 EncodedValue |= 0x0F000000;
490unsigned ARMMCCodeEmitter::NEONThumb2LoadStorePostEncoder(
const MCInst &
MI,
491 unsigned EncodedValue,
492 const MCSubtargetInfo &STI)
const {
494 EncodedValue &= 0xF0FFFFFF;
495 EncodedValue |= 0x09000000;
504unsigned ARMMCCodeEmitter::NEONThumb2DupPostEncoder(
const MCInst &
MI,
505 unsigned EncodedValue,
506 const MCSubtargetInfo &STI)
const {
508 EncodedValue &= 0x00FFFFFF;
509 EncodedValue |= 0xEE000000;
517unsigned ARMMCCodeEmitter::NEONThumb2V8PostEncoder(
const MCInst &
MI,
518 unsigned EncodedValue,
519 const MCSubtargetInfo &STI)
const {
521 EncodedValue |= 0xC000000;
529unsigned ARMMCCodeEmitter::
530VFPThumb2PostEncoder(
const MCInst &
MI,
unsigned EncodedValue,
531 const MCSubtargetInfo &STI)
const {
533 EncodedValue &= 0x0FFFFFFF;
534 EncodedValue |= 0xE0000000;
541unsigned ARMMCCodeEmitter::
542getMachineOpValue(
const MCInst &
MI,
const MCOperand &MO,
543 SmallVectorImpl<MCFixup> &Fixups,
544 const MCSubtargetInfo &STI)
const {
561 case ARM::Q0:
case ARM::Q1:
case ARM::Q2:
case ARM::Q3:
562 case ARM::Q4:
case ARM::Q5:
case ARM::Q6:
case ARM::Q7:
563 case ARM::Q8:
case ARM::Q9:
case ARM::Q10:
case ARM::Q11:
564 case ARM::Q12:
case ARM::Q13:
case ARM::Q14:
case ARM::Q15:
567 }
else if (MO.
isImm()) {
568 return static_cast<unsigned>(MO.
getImm());
580bool ARMMCCodeEmitter::
581EncodeAddrModeOpValues(
const MCInst &
MI,
unsigned OpIdx,
unsigned &
Reg,
582 unsigned &
Imm, SmallVectorImpl<MCFixup> &Fixups,
583 const MCSubtargetInfo &STI)
const {
584 const MCOperand &MO =
MI.getOperand(OpIdx);
585 const MCOperand &MO1 =
MI.getOperand(OpIdx + 1);
589 int32_t SImm = MO1.
getImm();
593 if (SImm == INT32_MIN) {
618 assert(MO.
isExpr() &&
"Unexpected branch target type!");
631 uint32_t S = (offset & 0x800000) >> 23;
632 uint32_t J1 = (offset & 0x400000) >> 22;
633 uint32_t J2 = (offset & 0x200000) >> 21;
647uint32_t ARMMCCodeEmitter::
648getThumbBLTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
649 SmallVectorImpl<MCFixup> &Fixups,
650 const MCSubtargetInfo &STI)
const {
651 const MCOperand MO =
MI.getOperand(OpIdx);
660uint32_t ARMMCCodeEmitter::
661getThumbBLXTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
662 SmallVectorImpl<MCFixup> &Fixups,
663 const MCSubtargetInfo &STI)
const {
664 const MCOperand MO =
MI.getOperand(OpIdx);
672uint32_t ARMMCCodeEmitter::
673getThumbBRTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
674 SmallVectorImpl<MCFixup> &Fixups,
675 const MCSubtargetInfo &STI)
const {
676 const MCOperand MO =
MI.getOperand(OpIdx);
680 return (MO.
getImm() >> 1);
684uint32_t ARMMCCodeEmitter::
685getThumbBCCTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
686 SmallVectorImpl<MCFixup> &Fixups,
687 const MCSubtargetInfo &STI)
const {
688 const MCOperand MO =
MI.getOperand(OpIdx);
692 return (MO.
getImm() >> 1);
696uint32_t ARMMCCodeEmitter::
697getThumbCBTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
698 SmallVectorImpl<MCFixup> &Fixups,
699 const MCSubtargetInfo &STI)
const {
700 const MCOperand MO =
MI.getOperand(OpIdx);
703 return (MO.
getImm() >> 1);
708 int NumOp =
MI.getNumOperands();
710 for (
int i = 0; i < NumOp-1; ++i) {
725uint32_t ARMMCCodeEmitter::
726getBranchTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
727 SmallVectorImpl<MCFixup> &Fixups,
728 const MCSubtargetInfo &STI)
const {
734 return getARMBranchTargetOpValue(
MI, OpIdx, Fixups, STI);
739uint32_t ARMMCCodeEmitter::
740getARMBranchTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
741 SmallVectorImpl<MCFixup> &Fixups,
742 const MCSubtargetInfo &STI)
const {
743 const MCOperand MO =
MI.getOperand(OpIdx);
746 return ::getBranchTargetOpValue(
MI, OpIdx,
748 return ::getBranchTargetOpValue(
MI, OpIdx,
755uint32_t ARMMCCodeEmitter::
756getARMBLTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
757 SmallVectorImpl<MCFixup> &Fixups,
758 const MCSubtargetInfo &STI)
const {
759 const MCOperand MO =
MI.getOperand(OpIdx);
762 return ::getBranchTargetOpValue(
MI, OpIdx,
770uint32_t ARMMCCodeEmitter::
771getARMBLXTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
772 SmallVectorImpl<MCFixup> &Fixups,
773 const MCSubtargetInfo &STI)
const {
774 const MCOperand MO =
MI.getOperand(OpIdx);
783uint32_t ARMMCCodeEmitter::getThumbBranchTargetOpValue(
784 const MCInst &
MI,
unsigned OpIdx, SmallVectorImpl<MCFixup> &Fixups,
785 const MCSubtargetInfo &STI)
const {
787 const MCOperand MO =
MI.getOperand(OpIdx);
794 bool I = (Val & 0x800000);
795 bool J1 = (Val & 0x400000);
796 bool J2 = (Val & 0x200000);
812uint32_t ARMMCCodeEmitter::
813getAdrLabelOpValue(
const MCInst &
MI,
unsigned OpIdx,
814 SmallVectorImpl<MCFixup> &Fixups,
815 const MCSubtargetInfo &STI)
const {
816 const MCOperand MO =
MI.getOperand(OpIdx);
820 int64_t offset = MO.
getImm();
821 uint32_t Val = 0x2000;
824 if (offset == INT32_MIN) {
827 }
else if (offset < 0) {
845 assert(SoImmVal != -1 &&
"Not a valid so_imm value!");
853uint32_t ARMMCCodeEmitter::
854getT2AdrLabelOpValue(
const MCInst &
MI,
unsigned OpIdx,
855 SmallVectorImpl<MCFixup> &Fixups,
856 const MCSubtargetInfo &STI)
const {
857 const MCOperand MO =
MI.getOperand(OpIdx);
861 int32_t Val = MO.
getImm();
862 if (Val == INT32_MIN)
873uint32_t ARMMCCodeEmitter::
874getITMaskOpValue(
const MCInst &
MI,
unsigned OpIdx,
875 SmallVectorImpl<MCFixup> &Fixups,
876 const MCSubtargetInfo &STI)
const {
877 const MCOperand MaskMO =
MI.getOperand(OpIdx);
878 assert(MaskMO.
isImm() &&
"Unexpected operand type!");
886 assert(OpIdx > 0 &&
"IT mask appears first!");
887 const MCOperand CondMO =
MI.getOperand(OpIdx-1);
888 assert(CondMO.
isImm() &&
"Unexpected operand type!");
889 if (CondMO.
getImm() & 1) {
891 unsigned BitsAboveLowBit = 0xF & (-LowBit << 1);
892 Mask ^= BitsAboveLowBit;
900uint32_t ARMMCCodeEmitter::
901getThumbAdrLabelOpValue(
const MCInst &
MI,
unsigned OpIdx,
902 SmallVectorImpl<MCFixup> &Fixups,
903 const MCSubtargetInfo &STI)
const {
904 const MCOperand MO =
MI.getOperand(OpIdx);
913uint32_t ARMMCCodeEmitter::
914getThumbAddrModeRegRegOpValue(
const MCInst &
MI,
unsigned OpIdx,
915 SmallVectorImpl<MCFixup> &,
916 const MCSubtargetInfo &STI)
const {
920 const MCOperand &MO1 =
MI.getOperand(OpIdx);
921 const MCOperand &MO2 =
MI.getOperand(OpIdx + 1);
924 return (Rm << 3) | Rn;
930ARMMCCodeEmitter::getMVEShiftImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
931 SmallVectorImpl<MCFixup> &Fixups,
932 const MCSubtargetInfo &STI)
const {
941 unsigned Size, ShiftImm;
942 switch(
MI.getOpcode()) {
943 case ARM::MVE_VSHLL_imms16bh:
944 case ARM::MVE_VSHLL_imms16th:
945 case ARM::MVE_VSHLL_immu16bh:
946 case ARM::MVE_VSHLL_immu16th:
949 case ARM::MVE_VSHLL_imms8bh:
950 case ARM::MVE_VSHLL_imms8th:
951 case ARM::MVE_VSHLL_immu8bh:
952 case ARM::MVE_VSHLL_immu8th:
958 ShiftImm =
MI.getOperand(OpIdx).getImm();
959 return Size + ShiftImm;
963uint32_t ARMMCCodeEmitter::
964getAddrModeImm12OpValue(
const MCInst &
MI,
unsigned OpIdx,
965 SmallVectorImpl<MCFixup> &Fixups,
966 const MCSubtargetInfo &STI)
const {
970 unsigned Reg = 0, Imm12 = 0;
973 const MCOperand &MO =
MI.getOperand(OpIdx);
975 const MCOperand &MO1 =
MI.getOperand(OpIdx + 1);
977 isAdd = EncodeAddrModeOpValues(
MI, OpIdx,
Reg, Imm12, Fixups, STI);
978 }
else if (MO1.
isExpr()) {
980 "Thumb mode requires different encoding");
996 ++MCNumCPRelocations;
1000 if (
Offset == INT32_MIN) {
1009 uint32_t
Binary = Imm12 & 0xfff;
1017template<
unsigned Bits,
unsigned Shift>
1018uint32_t ARMMCCodeEmitter::
1019getT2ScaledImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
1020 SmallVectorImpl<MCFixup> &Fixups,
1021 const MCSubtargetInfo &STI)
const {
1031 int32_t
Imm =
MI.getOperand(OpIdx).getImm();
1032 bool isAdd =
Imm >= 0;
1049uint32_t ARMMCCodeEmitter::
1050getMveAddrModeRQOpValue(
const MCInst &
MI,
unsigned OpIdx,
1051 SmallVectorImpl<MCFixup> &Fixups,
1052 const MCSubtargetInfo &STI)
const {
1055 const MCOperand &
M0 =
MI.getOperand(OpIdx);
1056 const MCOperand &
M1 =
MI.getOperand(OpIdx + 1);
1061 assert(Qm < 8 &&
"Qm is supposed to be encodable in 3 bits");
1063 return (Rn << 3) | Qm;
1069uint32_t ARMMCCodeEmitter::
1070getMveAddrModeQOpValue(
const MCInst &
MI,
unsigned OpIdx,
1071 SmallVectorImpl<MCFixup> &Fixups,
1072 const MCSubtargetInfo &STI)
const {
1075 const MCOperand &
M0 =
MI.getOperand(OpIdx);
1076 const MCOperand &
M1 =
MI.getOperand(OpIdx + 1);
1079 int32_t
Imm =
M1.getImm();
1081 bool isAdd =
Imm >= 0;
1093 assert(Qm < 8 &&
"Qm is supposed to be encodable in 3 bits");
1095 return (Qm << 8) |
Imm;
1100uint32_t ARMMCCodeEmitter::
1101getT2AddrModeImm8s4OpValue(
const MCInst &
MI,
unsigned OpIdx,
1102 SmallVectorImpl<MCFixup> &Fixups,
1103 const MCSubtargetInfo &STI)
const {
1110 const MCOperand &MO =
MI.getOperand(OpIdx);
1116 assert(MO.
isExpr() &&
"Unexpected machine operand type!");
1117 const MCExpr *Expr = MO.
getExpr();
1121 ++MCNumCPRelocations;
1123 isAdd = EncodeAddrModeOpValues(
MI, OpIdx,
Reg, Imm8, Fixups, STI);
1131 assert(((Imm8 & 0x3) == 0) &&
"Not a valid immediate!");
1143ARMMCCodeEmitter::getT2AddrModeImm7s4OpValue(
const MCInst &
MI,
unsigned OpIdx,
1144 SmallVectorImpl<MCFixup> &Fixups,
1145 const MCSubtargetInfo &STI)
const {
1151 bool isAdd = EncodeAddrModeOpValues(
MI, OpIdx,
Reg, Imm7, Fixups, STI);
1159 uint32_t
Binary = (Imm7 >> 2) & 0xff;
1169uint32_t ARMMCCodeEmitter::
1170getT2AddrModeImm0_1020s4OpValue(
const MCInst &
MI,
unsigned OpIdx,
1171 SmallVectorImpl<MCFixup> &Fixups,
1172 const MCSubtargetInfo &STI)
const {
1175 const MCOperand &MO =
MI.getOperand(OpIdx);
1176 const MCOperand &MO1 =
MI.getOperand(OpIdx + 1);
1182uint32_t ARMMCCodeEmitter::getHiLoImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
1183 SmallVectorImpl<MCFixup> &Fixups,
1184 const MCSubtargetInfo &STI)
const {
1187 const MCOperand &MO =
MI.getOperand(OpIdx);
1190 return static_cast<unsigned>(MO.
getImm());
1198 E = ARM16Expr->getSubExpr();
1201 const int64_t
Value = MCE->getValue();
1202 if (
Value > UINT32_MAX)
1205 switch (ARM16Expr->getSpecifier()) {
1207 return (int32_t(
Value) & 0xffff0000) >> 16;
1209 return (int32_t(
Value) & 0x0000ffff);
1212 return (int32_t(
Value) & 0xff000000) >> 24;
1214 return (int32_t(
Value) & 0x00ff0000) >> 16;
1216 return (int32_t(
Value) & 0x0000ff00) >> 8;
1218 return (int32_t(
Value) & 0x000000ff);
1224 switch (ARM16Expr->getSpecifier()) {
1266 ":upper0_7:, lower8_15: or :lower0_7:");
1269uint32_t ARMMCCodeEmitter::
1270getLdStSORegOpValue(
const MCInst &
MI,
unsigned OpIdx,
1271 SmallVectorImpl<MCFixup> &Fixups,
1272 const MCSubtargetInfo &STI)
const {
1273 const MCOperand &MO =
MI.getOperand(OpIdx);
1274 const MCOperand &MO1 =
MI.getOperand(OpIdx+1);
1275 const MCOperand &MO2 =
MI.getOperand(OpIdx+2);
1281 unsigned SBits = getShiftOp(ShOp);
1285 assert((ShImm & ~0x1f) == 0 &&
"Out of range shift amount");
1303uint32_t ARMMCCodeEmitter::
1304getAddrMode2OffsetOpValue(
const MCInst &
MI,
unsigned OpIdx,
1305 SmallVectorImpl<MCFixup> &Fixups,
1306 const MCSubtargetInfo &STI)
const {
1310 const MCOperand &MO =
MI.getOperand(OpIdx);
1311 const MCOperand &MO1 =
MI.getOperand(OpIdx+1);
1320 Binary |= getShiftOp(ShOp) << 5;
1326uint32_t ARMMCCodeEmitter::
1327getPostIdxRegOpValue(
const MCInst &
MI,
unsigned OpIdx,
1328 SmallVectorImpl<MCFixup> &Fixups,
1329 const MCSubtargetInfo &STI)
const {
1332 const MCOperand &MO =
MI.getOperand(OpIdx);
1333 const MCOperand &MO1 =
MI.getOperand(OpIdx+1);
1334 bool isAdd = MO1.
getImm() != 0;
1338uint32_t ARMMCCodeEmitter::
1339getAddrMode3OffsetOpValue(
const MCInst &
MI,
unsigned OpIdx,
1340 SmallVectorImpl<MCFixup> &Fixups,
1341 const MCSubtargetInfo &STI)
const {
1346 const MCOperand &MO =
MI.getOperand(OpIdx);
1347 const MCOperand &MO1 =
MI.getOperand(OpIdx+1);
1355 return Imm8 | (isAdd << 8) | (isImm << 9);
1358uint32_t ARMMCCodeEmitter::
1359getAddrMode3OpValue(
const MCInst &
MI,
unsigned OpIdx,
1360 SmallVectorImpl<MCFixup> &Fixups,
1361 const MCSubtargetInfo &STI)
const {
1367 const MCOperand &MO =
MI.getOperand(OpIdx);
1368 const MCOperand &MO1 =
MI.getOperand(OpIdx+1);
1369 const MCOperand &MO2 =
MI.getOperand(OpIdx+2);
1375 assert(MO.
isExpr() &&
"Unexpected machine operand type!");
1376 const MCExpr *Expr = MO.
getExpr();
1380 ++MCNumCPRelocations;
1381 return (Rn << 9) | (1 << 13);
1391 return (Rn << 9) |
Imm8 | (isAdd << 8) | (isImm << 13);
1395uint32_t ARMMCCodeEmitter::
1396getAddrModeThumbSPOpValue(
const MCInst &
MI,
unsigned OpIdx,
1397 SmallVectorImpl<MCFixup> &Fixups,
1398 const MCSubtargetInfo &STI)
const {
1401 const MCOperand &MO1 =
MI.getOperand(OpIdx + 1);
1402 assert(
MI.getOperand(OpIdx).getReg() == ARM::SP &&
1403 "Unexpected base register!");
1407 return MO1.
getImm() & 0xff;
1411uint32_t ARMMCCodeEmitter::
1412getAddrModeISOpValue(
const MCInst &
MI,
unsigned OpIdx,
1413 SmallVectorImpl<MCFixup> &Fixups,
1414 const MCSubtargetInfo &STI)
const {
1418 const MCOperand &MO =
MI.getOperand(OpIdx);
1419 const MCOperand &MO1 =
MI.getOperand(OpIdx + 1);
1421 unsigned Imm5 = MO1.
getImm();
1422 return ((Imm5 & 0x1f) << 3) | Rn;
1426uint32_t ARMMCCodeEmitter::
1427getAddrModePCOpValue(
const MCInst &
MI,
unsigned OpIdx,
1428 SmallVectorImpl<MCFixup> &Fixups,
1429 const MCSubtargetInfo &STI)
const {
1430 const MCOperand MO =
MI.getOperand(OpIdx);
1433 return (MO.
getImm() >> 2);
1437uint32_t ARMMCCodeEmitter::
1438getAddrMode5OpValue(
const MCInst &
MI,
unsigned OpIdx,
1439 SmallVectorImpl<MCFixup> &Fixups,
1440 const MCSubtargetInfo &STI)
const {
1447 const MCOperand &MO =
MI.getOperand(OpIdx);
1453 assert(MO.
isExpr() &&
"Unexpected machine operand type!");
1454 const MCExpr *Expr = MO.
getExpr();
1462 ++MCNumCPRelocations;
1464 EncodeAddrModeOpValues(
MI, OpIdx,
Reg, Imm8, Fixups, STI);
1477uint32_t ARMMCCodeEmitter::
1478getAddrMode5FP16OpValue(
const MCInst &
MI,
unsigned OpIdx,
1479 SmallVectorImpl<MCFixup> &Fixups,
1480 const MCSubtargetInfo &STI)
const {
1487 const MCOperand &MO =
MI.getOperand(OpIdx);
1493 assert(MO.
isExpr() &&
"Unexpected machine operand type!");
1494 const MCExpr *Expr = MO.
getExpr();
1502 ++MCNumCPRelocations;
1504 EncodeAddrModeOpValues(
MI, OpIdx,
Reg, Imm8, Fixups, STI);
1516unsigned ARMMCCodeEmitter::getModImmOpValue(
const MCInst &
MI,
unsigned Op,
1517 SmallVectorImpl<MCFixup> &Fixups,
1518 const MCSubtargetInfo &ST)
const {
1519 const MCOperand &MO =
MI.getOperand(
Op);
1523 const MCExpr *Expr = MO.
getExpr();
1534unsigned ARMMCCodeEmitter::getT2SOImmOpValue(
const MCInst &
MI,
unsigned Op,
1535 SmallVectorImpl<MCFixup> &Fixups,
1536 const MCSubtargetInfo &STI)
const {
1537 const MCOperand &MO =
MI.getOperand(
Op);
1541 const MCExpr *Expr = MO.
getExpr();
1547 unsigned SoImm = MO.
getImm();
1549 assert(Encoded != ~0U &&
"Not a Thumb2 so_imm value?");
1553unsigned ARMMCCodeEmitter::
1554getSORegRegOpValue(
const MCInst &
MI,
unsigned OpIdx,
1555 SmallVectorImpl<MCFixup> &Fixups,
1556 const MCSubtargetInfo &STI)
const {
1567 const MCOperand &MO =
MI.getOperand(OpIdx);
1568 const MCOperand &MO1 =
MI.getOperand(OpIdx + 1);
1569 const MCOperand &MO2 =
MI.getOperand(OpIdx + 2);
1577 MCRegister Rs = MO1.
getReg();
1601unsigned ARMMCCodeEmitter::
1602getSORegImmOpValue(
const MCInst &
MI,
unsigned OpIdx,
1603 SmallVectorImpl<MCFixup> &Fixups,
1604 const MCSubtargetInfo &STI)
const {
1613 const MCOperand &MO =
MI.getOperand(OpIdx);
1614 const MCOperand &MO1 =
MI.getOperand(OpIdx + 1);
1643 assert(
Offset < 32 &&
"Offset must be in range 0-31!");
1648unsigned ARMMCCodeEmitter::
1649getT2AddrModeSORegOpValue(
const MCInst &
MI,
unsigned OpNum,
1650 SmallVectorImpl<MCFixup> &Fixups,
1651 const MCSubtargetInfo &STI)
const {
1652 const MCOperand &MO1 =
MI.getOperand(OpNum);
1653 const MCOperand &MO2 =
MI.getOperand(OpNum+1);
1654 const MCOperand &MO3 =
MI.getOperand(OpNum+2);
1667template<
unsigned Bits,
unsigned Shift>
1668unsigned ARMMCCodeEmitter::
1669getT2AddrModeImmOpValue(
const MCInst &
MI,
unsigned OpNum,
1670 SmallVectorImpl<MCFixup> &Fixups,
1671 const MCSubtargetInfo &STI)
const {
1672 const MCOperand &MO1 =
MI.getOperand(OpNum);
1673 const MCOperand &MO2 =
MI.getOperand(OpNum+1);
1681 int32_t tmp = (int32_t)MO2.
getImm();
1682 if (tmp == INT32_MIN) {
1684 }
else if (tmp < 0) {
1689 Value |= (tmp >> Shift) & ((1U << Bits) - 1);
1693unsigned ARMMCCodeEmitter::
1694getT2AddrModeImm8OffsetOpValue(
const MCInst &
MI,
unsigned OpNum,
1695 SmallVectorImpl<MCFixup> &Fixups,
1696 const MCSubtargetInfo &STI)
const {
1697 const MCOperand &MO1 =
MI.getOperand(OpNum);
1701 auto tmp =
static_cast<uint32_t
>(MO1.
getImm());
1702 if (
static_cast<int32_t
>(tmp) < 0)
1710unsigned ARMMCCodeEmitter::
1711getT2SORegOpValue(
const MCInst &
MI,
unsigned OpIdx,
1712 SmallVectorImpl<MCFixup> &Fixups,
1713 const MCSubtargetInfo &STI)
const {
1722 const MCOperand &MO =
MI.getOperand(OpIdx);
1723 const MCOperand &MO1 =
MI.getOperand(OpIdx + 1);
1753unsigned ARMMCCodeEmitter::
1754getBitfieldInvertedMaskOpValue(
const MCInst &
MI,
unsigned Op,
1755 SmallVectorImpl<MCFixup> &Fixups,
1756 const MCSubtargetInfo &STI)
const {
1759 const MCOperand &MO =
MI.getOperand(
Op);
1760 uint32_t
v = ~MO.getImm();
1763 assert(v != 0 && lsb < 32 && msb < 32 &&
"Illegal bitfield mask!");
1764 return lsb | (msb << 5);
1767unsigned ARMMCCodeEmitter::
1768getRegisterListOpValue(
const MCInst &
MI,
unsigned Op,
1769 SmallVectorImpl<MCFixup> &Fixups,
1770 const MCSubtargetInfo &STI)
const {
1777 MCRegister
Reg =
MI.getOperand(
Op).getReg();
1778 bool SPRRegs = getARMMCRegisterClass(ARM::SPRRegClassID).contains(
Reg);
1779 bool DPRRegs = getARMMCRegisterClass(ARM::DPRRegClassID).contains(
Reg);
1783 if (SPRRegs || DPRRegs ||
Reg == ARM::VPR) {
1786 unsigned NumRegs = (
MI.getNumOperands() -
Op) & 0xff;
1787 Binary |= (RegNo & 0x1f) << 8;
1789 if (
MI.getOpcode() == ARM::VSCCLRMD)
1792 else if (
MI.getOpcode() == ARM::VSCCLRMS) {
1798 Reg =
MI.getOperand(
I).getReg();
1799 if (getARMMCRegisterClass(ARM::SPRRegClassID).
contains(
Reg))
1801 else if (getARMMCRegisterClass(ARM::DPRRegClassID).
contains(
Reg))
1812 [&](
const MCOperand &
LHS,
const MCOperand &
RHS) {
1827unsigned ARMMCCodeEmitter::
1828getAddrMode6AddressOpValue(
const MCInst &
MI,
unsigned Op,
1829 SmallVectorImpl<MCFixup> &Fixups,
1830 const MCSubtargetInfo &STI)
const {
1831 const MCOperand &
Reg =
MI.getOperand(
Op);
1832 const MCOperand &
Imm =
MI.getOperand(
Op + 1);
1837 switch (
Imm.getImm()) {
1841 case 8:
Align = 0x01;
break;
1842 case 16:
Align = 0x02;
break;
1843 case 32:
Align = 0x03;
break;
1846 return RegNo | (
Align << 4);
1851unsigned ARMMCCodeEmitter::
1852getAddrMode6OneLane32AddressOpValue(
const MCInst &
MI,
unsigned Op,
1853 SmallVectorImpl<MCFixup> &Fixups,
1854 const MCSubtargetInfo &STI)
const {
1855 const MCOperand &
Reg =
MI.getOperand(
Op);
1856 const MCOperand &
Imm =
MI.getOperand(
Op + 1);
1861 switch (
Imm.getImm()) {
1866 case 2:
Align = 0x00;
break;
1867 case 4:
Align = 0x03;
break;
1870 return RegNo | (
Align << 4);
1878unsigned ARMMCCodeEmitter::
1879getAddrMode6DupAddressOpValue(
const MCInst &
MI,
unsigned Op,
1880 SmallVectorImpl<MCFixup> &Fixups,
1881 const MCSubtargetInfo &STI)
const {
1882 const MCOperand &
Reg =
MI.getOperand(
Op);
1883 const MCOperand &
Imm =
MI.getOperand(
Op + 1);
1888 switch (
Imm.getImm()) {
1892 case 8:
Align = 0x01;
break;
1893 case 16:
Align = 0x03;
break;
1896 return RegNo | (
Align << 4);
1899unsigned ARMMCCodeEmitter::
1900getAddrMode6OffsetOpValue(
const MCInst &
MI,
unsigned Op,
1901 SmallVectorImpl<MCFixup> &Fixups,
1902 const MCSubtargetInfo &STI)
const {
1903 const MCOperand &MO =
MI.getOperand(
Op);
1909unsigned ARMMCCodeEmitter::
1910getShiftRight8Imm(
const MCInst &
MI,
unsigned Op,
1911 SmallVectorImpl<MCFixup> &Fixups,
1912 const MCSubtargetInfo &STI)
const {
1913 return 8 -
MI.getOperand(
Op).getImm();
1916unsigned ARMMCCodeEmitter::
1917getShiftRight16Imm(
const MCInst &
MI,
unsigned Op,
1918 SmallVectorImpl<MCFixup> &Fixups,
1919 const MCSubtargetInfo &STI)
const {
1920 return 16 -
MI.getOperand(
Op).getImm();
1923unsigned ARMMCCodeEmitter::
1924getShiftRight32Imm(
const MCInst &
MI,
unsigned Op,
1925 SmallVectorImpl<MCFixup> &Fixups,
1926 const MCSubtargetInfo &STI)
const {
1927 return 32 -
MI.getOperand(
Op).getImm();
1930unsigned ARMMCCodeEmitter::
1931getShiftRight64Imm(
const MCInst &
MI,
unsigned Op,
1932 SmallVectorImpl<MCFixup> &Fixups,
1933 const MCSubtargetInfo &STI)
const {
1934 return 64 -
MI.getOperand(
Op).getImm();
1937void ARMMCCodeEmitter::encodeInstruction(
const MCInst &
MI,
1938 SmallVectorImpl<char> &CB,
1939 SmallVectorImpl<MCFixup> &Fixups,
1940 const MCSubtargetInfo &STI)
const {
1942 const MCInstrDesc &
Desc = MCII.
get(
MI.getOpcode());
1948 if (
Desc.getSize() == 2 ||
Desc.getSize() == 4)
1955 uint32_t
Binary = getBinaryCodeForInstr(
MI, Fixups, STI);
1969template <
bool isNeg, ARM::Fixups fixup>
1971ARMMCCodeEmitter::getBFTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
1972 SmallVectorImpl<MCFixup> &Fixups,
1973 const MCSubtargetInfo &STI)
const {
1974 const MCOperand MO =
MI.getOperand(OpIdx);
1976 return ::getBranchTargetOpValue(
MI, OpIdx, fixup, Fixups, STI);
1981ARMMCCodeEmitter::getBFAfterTargetOpValue(
const MCInst &
MI,
unsigned OpIdx,
1982 SmallVectorImpl<MCFixup> &Fixups,
1983 const MCSubtargetInfo &STI)
const {
1984 const MCOperand MO =
MI.getOperand(OpIdx);
1985 const MCOperand BranchMO =
MI.getOperand(0);
1992 addFixup(Fixups, 0, DiffExpr, Kind);
1998 assert(Diff == 4 || Diff == 2);
2003uint32_t ARMMCCodeEmitter::getVPTMaskOpValue(
const MCInst &
MI,
unsigned OpIdx,
2004 SmallVectorImpl<MCFixup> &Fixups,
2005 const MCSubtargetInfo &STI)
const {
2006 const MCOperand MO =
MI.getOperand(OpIdx);
2014 unsigned PrevBit = 0;
2015 for (
int i = 3; i >= 0; --i) {
2019 if ((
Value & ~(~0U << i)) == 0) {
2034uint32_t ARMMCCodeEmitter::getRestrictedCondCodeOpValue(
2035 const MCInst &
MI,
unsigned OpIdx, SmallVectorImpl<MCFixup> &Fixups,
2036 const MCSubtargetInfo &STI)
const {
2038 const MCOperand MO =
MI.getOperand(OpIdx);
2043 assert(0 &&
"Unexpected Condition!");
2062uint32_t ARMMCCodeEmitter::
2063getPowerTwoOpValue(
const MCInst &
MI,
unsigned OpIdx,
2064 SmallVectorImpl<MCFixup> &Fixups,
2065 const MCSubtargetInfo &STI)
const {
2066 const MCOperand &MO =
MI.getOperand(OpIdx);
2071template <
unsigned start>
2072uint32_t ARMMCCodeEmitter::
2073getMVEPairVectorIndexOpValue(
const MCInst &
MI,
unsigned OpIdx,
2074 SmallVectorImpl<MCFixup> &Fixups,
2075 const MCSubtargetInfo &STI)
const {
2076 const MCOperand MO =
MI.getOperand(OpIdx);
2080 return Value - start;
2083#include "ARMGenMCCodeEmitter.inc"
2087 return new ARMMCCodeEmitter(MCII, Ctx,
true);
2092 return new ARMMCCodeEmitter(MCII, Ctx,
false);
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)
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)
uint64_t getNumOperands() const
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.
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)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
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)