LLVM 24.0.0git
MipsTargetStreamer.cpp
Go to the documentation of this file.
1//===-- MipsTargetStreamer.cpp - Mips Target Streamer Methods -------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file provides Mips specific target streamer methods.
10//
11//===----------------------------------------------------------------------===//
12
13#include "MipsTargetStreamer.h"
16#include "MipsBaseInfo.h"
17#include "MipsELFStreamer.h"
18#include "MipsInstPrinter.h"
19#include "MipsMCTargetDesc.h"
21#include "llvm/MC/MCAsmInfo.h"
22#include "llvm/MC/MCAssembler.h"
23#include "llvm/MC/MCContext.h"
28#include "llvm/MC/MCSymbolELF.h"
31
32using namespace llvm;
33
34static bool isMicroMips(const MCSubtargetInfo *STI) {
35 return STI->hasFeature(Mips::FeatureMicroMips);
36}
37
38static bool isMips32r6(const MCSubtargetInfo *STI) {
39 return STI->hasFeature(Mips::FeatureMips32r6);
40}
41
46
87void MipsTargetStreamer::emitFrame(MCRegister StackReg, unsigned StackSize,
89void MipsTargetStreamer::emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) {}
90void MipsTargetStreamer::emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) {
91}
127 // .cplocal $reg
128 // This directive forces to use the alternate register for context pointer.
129 // For example
130 // .cplocal $4
131 // jal foo
132 // expands to
133 // ld $25, %call16(foo)($4)
134 // jalr $25
135
136 if (!getABI().IsN32() && !getABI().IsN64())
137 return;
138
139 GPReg = Reg;
140
142}
144 int Offset, function_ref<MCRegister()> GetATReg, SMLoc IDLoc,
145 const MCSubtargetInfo *STI) {
147 return true;
148}
150 const MCSymbol &Sym, bool IsReg) {
151}
153 bool SaveLocationIsRegister) {}
154
156
158 if (!ABIFlagsSection.OddSPReg && !ABIFlagsSection.Is32BitABI)
159 report_fatal_error("+nooddspreg is only valid for O32");
160}
178
180
182 const MCSubtargetInfo &STI) {
183 if (InstEmitter)
184 InstEmitter->emitInstruction(Inst, STI);
185 else
186 getStreamer().emitInstruction(Inst, STI);
187}
188
189void MipsTargetStreamer::emitR(unsigned Opcode, MCRegister Reg0, SMLoc IDLoc,
190 const MCSubtargetInfo *STI) {
191 MCInst TmpInst;
192 TmpInst.setOpcode(Opcode);
193 TmpInst.addOperand(MCOperand::createReg(Reg0));
194 TmpInst.setLoc(IDLoc);
195 emitInst(TmpInst, *STI);
196}
197
198void MipsTargetStreamer::emitRX(unsigned Opcode, MCRegister Reg0, MCOperand Op1,
199 SMLoc IDLoc, const MCSubtargetInfo *STI) {
200 MCInst TmpInst;
201 TmpInst.setOpcode(Opcode);
202 TmpInst.addOperand(MCOperand::createReg(Reg0));
203 TmpInst.addOperand(Op1);
204 TmpInst.setLoc(IDLoc);
205 emitInst(TmpInst, *STI);
206}
207
208void MipsTargetStreamer::emitRI(unsigned Opcode, MCRegister Reg0, int32_t Imm,
209 SMLoc IDLoc, const MCSubtargetInfo *STI) {
210 emitRX(Opcode, Reg0, MCOperand::createImm(Imm), IDLoc, STI);
211}
212
213void MipsTargetStreamer::emitRR(unsigned Opcode, MCRegister Reg0,
214 MCRegister Reg1, SMLoc IDLoc,
215 const MCSubtargetInfo *STI) {
216 emitRX(Opcode, Reg0, MCOperand::createReg(Reg1), IDLoc, STI);
217}
218
219void MipsTargetStreamer::emitII(unsigned Opcode, int16_t Imm1, int16_t Imm2,
220 SMLoc IDLoc, const MCSubtargetInfo *STI) {
221 MCInst TmpInst;
222 TmpInst.setOpcode(Opcode);
223 TmpInst.addOperand(MCOperand::createImm(Imm1));
224 TmpInst.addOperand(MCOperand::createImm(Imm2));
225 TmpInst.setLoc(IDLoc);
226 emitInst(TmpInst, *STI);
227}
228
229void MipsTargetStreamer::emitRRX(unsigned Opcode, MCRegister Reg0,
230 MCRegister Reg1, MCOperand Op2, SMLoc IDLoc,
231 const MCSubtargetInfo *STI) {
232 MCInst TmpInst;
233 TmpInst.setOpcode(Opcode);
234 TmpInst.addOperand(MCOperand::createReg(Reg0));
235 TmpInst.addOperand(MCOperand::createReg(Reg1));
236 TmpInst.addOperand(Op2);
237 TmpInst.setLoc(IDLoc);
238 emitInst(TmpInst, *STI);
239}
240
241void MipsTargetStreamer::emitRRR(unsigned Opcode, MCRegister Reg0,
242 MCRegister Reg1, MCRegister Reg2, SMLoc IDLoc,
243 const MCSubtargetInfo *STI) {
244 emitRRX(Opcode, Reg0, Reg1, MCOperand::createReg(Reg2), IDLoc, STI);
245}
246
247void MipsTargetStreamer::emitRRRX(unsigned Opcode, MCRegister Reg0,
248 MCRegister Reg1, MCRegister Reg2,
249 MCOperand Op3, SMLoc IDLoc,
250 const MCSubtargetInfo *STI) {
251 MCInst TmpInst;
252 TmpInst.setOpcode(Opcode);
253 TmpInst.addOperand(MCOperand::createReg(Reg0));
254 TmpInst.addOperand(MCOperand::createReg(Reg1));
255 TmpInst.addOperand(MCOperand::createReg(Reg2));
256 TmpInst.addOperand(Op3);
257 TmpInst.setLoc(IDLoc);
258 emitInst(TmpInst, *STI);
259}
260
261void MipsTargetStreamer::emitRRI(unsigned Opcode, MCRegister Reg0,
262 MCRegister Reg1, int16_t Imm, SMLoc IDLoc,
263 const MCSubtargetInfo *STI) {
264 emitRRX(Opcode, Reg0, Reg1, MCOperand::createImm(Imm), IDLoc, STI);
265}
266
267void MipsTargetStreamer::emitRRIII(unsigned Opcode, MCRegister Reg0,
268 MCRegister Reg1, int16_t Imm0, int16_t Imm1,
269 int16_t Imm2, SMLoc IDLoc,
270 const MCSubtargetInfo *STI) {
271 MCInst TmpInst;
272 TmpInst.setOpcode(Opcode);
273 TmpInst.addOperand(MCOperand::createReg(Reg0));
274 TmpInst.addOperand(MCOperand::createReg(Reg1));
275 TmpInst.addOperand(MCOperand::createImm(Imm0));
276 TmpInst.addOperand(MCOperand::createImm(Imm1));
277 TmpInst.addOperand(MCOperand::createImm(Imm2));
278 TmpInst.setLoc(IDLoc);
279 emitInst(TmpInst, *STI);
280}
281
283 MCRegister TrgReg, bool Is64Bit,
284 const MCSubtargetInfo *STI) {
285 emitRRR(Is64Bit ? Mips::DADDu : Mips::ADDu, DstReg, SrcReg, TrgReg, SMLoc(),
286 STI);
287}
288
290 int16_t ShiftAmount, SMLoc IDLoc,
291 const MCSubtargetInfo *STI) {
292 if (ShiftAmount >= 32) {
293 emitRRI(Mips::DSLL32, DstReg, SrcReg, ShiftAmount - 32, IDLoc, STI);
294 return;
295 }
296
297 emitRRI(Mips::DSLL, DstReg, SrcReg, ShiftAmount, IDLoc, STI);
298}
299
301 const MCSubtargetInfo *STI) {
302 // The default case of `nop` is `sll $zero, $zero, 0`.
303 unsigned Opc = Mips::SLL;
304 if (isMicroMips(STI) && hasShortDelaySlot) {
305 Opc = isMips32r6(STI) ? Mips::MOVE16_MMR6 : Mips::MOVE16_MM;
306 emitRR(Opc, Mips::R0, Mips::R0, IDLoc, STI);
307 return;
308 }
309
310 if (isMicroMips(STI))
311 Opc = isMips32r6(STI) ? Mips::SLL_MMR6 : Mips::SLL_MM;
312
313 emitRRI(Opc, Mips::R0, Mips::R0, 0, IDLoc, STI);
314}
315
317 if (isMicroMips(STI))
318 emitRR(Mips::MOVE16_MM, Mips::R0, Mips::R0, IDLoc, STI);
319 else
320 emitRRI(Mips::SLL, Mips::R0, Mips::R0, 0, IDLoc, STI);
321}
322
323/// Emit the $gp restore operation for .cprestore.
325 const MCSubtargetInfo *STI) {
326 emitLoadWithImmOffset(Mips::LW, GPReg, Mips::SP, Offset, GPReg, IDLoc, STI);
327}
328
329/// Emit a store instruction with an immediate offset.
331 unsigned Opcode, MCRegister SrcReg, MCRegister BaseReg, int64_t Offset,
332 function_ref<MCRegister()> GetATReg, SMLoc IDLoc,
333 const MCSubtargetInfo *STI) {
334 if (isInt<16>(Offset)) {
335 emitRRI(Opcode, SrcReg, BaseReg, Offset, IDLoc, STI);
336 return;
337 }
338
339 // sw $8, offset($8) => lui $at, %hi(offset)
340 // add $at, $at, $8
341 // sw $8, %lo(offset)($at)
342
343 MCRegister ATReg = GetATReg();
344 if (!ATReg)
345 return;
346
347 unsigned LoOffset = Offset & 0x0000ffff;
348 unsigned HiOffset = (Offset & 0xffff0000) >> 16;
349
350 // If msb of LoOffset is 1(negative number) we must increment HiOffset
351 // to account for the sign-extension of the low part.
352 if (LoOffset & 0x8000)
353 HiOffset++;
354
355 // Generate the base address in ATReg.
356 emitRI(Mips::LUi, ATReg, HiOffset, IDLoc, STI);
357 if (BaseReg != Mips::R0)
358 emitRRR(Mips::ADDu, ATReg, ATReg, BaseReg, IDLoc, STI);
359 // Emit the store with the adjusted base and offset.
360 emitRRI(Opcode, SrcReg, ATReg, LoOffset, IDLoc, STI);
361}
362
363/// Emit a load instruction with an immediate offset. DstReg and TmpReg are
364/// permitted to be the same register iff DstReg is distinct from BaseReg and
365/// DstReg is a GPR. It is the callers responsibility to identify such cases
366/// and pass the appropriate register in TmpReg.
368 unsigned Opcode, MCRegister DstReg, MCRegister BaseReg, int64_t Offset,
369 MCRegister TmpReg, SMLoc IDLoc, const MCSubtargetInfo *STI) {
370 if (isInt<16>(Offset)) {
371 emitRRI(Opcode, DstReg, BaseReg, Offset, IDLoc, STI);
372 return;
373 }
374
375 // 1) lw $8, offset($9) => lui $8, %hi(offset)
376 // add $8, $8, $9
377 // lw $8, %lo(offset)($9)
378 // 2) lw $8, offset($8) => lui $at, %hi(offset)
379 // add $at, $at, $8
380 // lw $8, %lo(offset)($at)
381
382 unsigned LoOffset = Offset & 0x0000ffff;
383 unsigned HiOffset = (Offset & 0xffff0000) >> 16;
384
385 // If msb of LoOffset is 1(negative number) we must increment HiOffset
386 // to account for the sign-extension of the low part.
387 if (LoOffset & 0x8000)
388 HiOffset++;
389
390 // Generate the base address in TmpReg.
391 emitRI(Mips::LUi, TmpReg, HiOffset, IDLoc, STI);
392 if (BaseReg != Mips::R0)
393 emitRRR(Mips::ADDu, TmpReg, TmpReg, BaseReg, IDLoc, STI);
394 // Emit the load with the adjusted base and offset.
395 emitRRI(Opcode, DstReg, TmpReg, LoOffset, IDLoc, STI);
396}
397
401
403 auto &MAI = getStreamer().getContext().getAsmInfo();
404 OS << "\t.dtprelword\t";
405 MAI.printExpr(OS, *Value);
406 OS << '\n';
407}
408
410 auto &MAI = getStreamer().getContext().getAsmInfo();
411 OS << "\t.dtpreldword\t";
412 MAI.printExpr(OS, *Value);
413 OS << '\n';
414}
415
417 auto &MAI = getStreamer().getContext().getAsmInfo();
418 OS << "\t.tprelword\t";
419 MAI.printExpr(OS, *Value);
420 OS << '\n';
421}
422
424 auto &MAI = getStreamer().getContext().getAsmInfo();
425 OS << "\t.tpreldword\t";
426 MAI.printExpr(OS, *Value);
427 OS << '\n';
428}
429
431 auto &MAI = getStreamer().getContext().getAsmInfo();
432 OS << "\t.gpword\t";
433 MAI.printExpr(OS, *Value);
434 OS << '\n';
435}
436
438 auto &MAI = getStreamer().getContext().getAsmInfo();
439 OS << "\t.gpdword\t";
440 MAI.printExpr(OS, *Value);
441 OS << '\n';
442}
443
445 OS << "\t.set\tmicromips\n";
447}
448
450 OS << "\t.set\tnomicromips\n";
452}
453
455 OS << "\t.set\tmips16\n";
457}
458
463
468
470 OS << "\t.set\tnoreorder\n";
472}
473
478
483
488
493
498
503
508
513
518
523
528
533
538
543
548
550 OS << "\t.set\tat=$" << Twine(RegNo) << "\n";
552}
553
558
560 OS << "\t.end\t" << Name << '\n';
561}
562
564 OS << "\t.ent\t" << Symbol.getName() << '\n';
565}
566
567void MipsTargetAsmStreamer::emitDirectiveAbiCalls() { OS << "\t.abicalls\n"; }
568
569void MipsTargetAsmStreamer::emitDirectiveNaN2008() { OS << "\t.nan\t2008\n"; }
570
572 OS << "\t.nan\tlegacy\n";
573}
574
576 OS << "\t.option\tpic0\n";
577}
578
580 OS << "\t.option\tpic2\n";
581}
582
587
588void MipsTargetAsmStreamer::emitFrame(MCRegister StackReg, unsigned StackSize,
590 OS << "\t.frame\t$"
592 << StackSize << ",$"
594}
595
597 OS << "\t.set arch=" << Arch << "\n";
599}
600
605
610
615
620
625
630
635
640
645
650
655
660
665
670
675
680
685
690
695
700
705
710
715
720
725
726// Print a 32 bit hex number with all numbers.
727static void printHex32(unsigned Value, raw_ostream &OS) {
728 OS << "0x";
729 for (int i = 7; i >= 0; i--)
730 OS.write_hex((Value & (0xF << (i * 4))) >> (i * 4));
731}
732
733void MipsTargetAsmStreamer::emitMask(unsigned CPUBitmask,
734 int CPUTopSavedRegOff) {
735 OS << "\t.mask \t";
736 printHex32(CPUBitmask, OS);
737 OS << ',' << CPUTopSavedRegOff << '\n';
738}
739
740void MipsTargetAsmStreamer::emitFMask(unsigned FPUBitmask,
741 int FPUTopSavedRegOff) {
742 OS << "\t.fmask\t";
743 printHex32(FPUBitmask, OS);
744 OS << "," << FPUTopSavedRegOff << '\n';
745}
746
752
758
764
766 int Offset, function_ref<MCRegister()> GetATReg, SMLoc IDLoc,
767 const MCSubtargetInfo *STI) {
769 OS << "\t.cprestore\t" << Offset << "\n";
770 return true;
771}
772
774 int RegOrOffset,
775 const MCSymbol &Sym,
776 bool IsReg) {
777 OS << "\t.cpsetup\t$"
779
780 if (IsReg)
781 OS << "$"
783 else
784 OS << RegOrOffset;
785
786 OS << ", ";
787
788 OS << Sym.getName();
790}
791
793 bool SaveLocationIsRegister) {
794 OS << "\t.cpreturn";
796}
797
801 OS << "\t.module\tsoftfloat\n";
802 else
803 OS << "\t.module\tfp=" << ABIFlagsSection.getFpABIString(FpABI) << "\n";
804}
805
813
816
817 OS << "\t.module\t" << (ABIFlagsSection.OddSPReg ? "" : "no") << "oddspreg\n";
818}
819
824
829
831 OS << "\t.module\tsoftfloat\n";
832}
833
835 OS << "\t.module\thardfloat\n";
836}
837
839 OS << "\t.module\tmt\n";
840}
841
843 OS << "\t.module\tcrc\n";
844}
845
847 OS << "\t.module\tnocrc\n";
848}
849
851 OS << "\t.module\tvirt\n";
852}
853
855 OS << "\t.module\tnovirt\n";
856}
857
859 OS << "\t.module\tginv\n";
860}
861
863 OS << "\t.module\tnoginv\n";
864}
865
866// This part is for ELF object output.
867MipsTargetELFStreamer::ISAMode
868MipsTargetELFStreamer::getISAMode(const MCSubtargetInfo &STI) {
869 if (STI.hasFeature(Mips::FeatureMips16))
870 return ISAMode::Mips16;
871 if (STI.hasFeature(Mips::FeatureMicroMips))
872 return ISAMode::MicroMips;
873 if (STI.hasFeature(Mips::FeatureNanoMips))
874 return ISAMode::NanoMips;
875 return ISAMode::Standard;
876}
877
879 const MCSubtargetInfo &STI)
881 CLOpts(MIPS_MC::getCLOpts(S.getContext().getTargetOptions())),
882 Mode(getISAMode(STI)), STI(STI) {
885
886 // It's possible that MCObjectFileInfo isn't fully initialized at this point
887 // due to an initialization order problem where CodeGenTargetMachineImpl
888 // creates the target streamer before TargetLoweringObjectFile calls
889 // InitializeMCObjectFileInfo. There doesn't seem to be a single place that
890 // covers all cases so this statement covers most cases and direct object
891 // emission must call setPic() once MCObjectFileInfo has been initialized. The
892 // cases we don't handle here are covered by MipsAsmPrinter.
894
895 const FeatureBitset &Features = STI.getFeatureBits();
896
897 // Set the header flags that we can in the constructor.
898 // FIXME: This is a fairly terrible hack. We set the rest
899 // of these in the destructor. The problem here is two-fold:
900 //
901 // a: Some of the eflags can be set/reset by directives.
902 // b: There aren't any usage paths that initialize the ABI
903 // pointer until after we initialize either an assembler
904 // or the target machine.
905 // We can fix this by making the target streamer construct
906 // the ABI, but this is fraught with wide ranging dependency
907 // issues as well.
908 unsigned EFlags = W.getELFHeaderEFlags();
909
910 // FIXME: Fix a dependency issue by instantiating the ABI object to some
911 // default based off the triple. The triple doesn't describe the target
912 // fully, but any external user of the API that uses the MCTargetStreamer
913 // would otherwise crash on assertion failure.
914
915 ABI = MipsABIInfo(STI.getTargetTriple().isNanoMips() ? MipsABIInfo::P32()
916 : STI.getTargetTriple().isMIPS32() ? MipsABIInfo::O32()
917 : MipsABIInfo::N64());
918
919 // Architecture
920 if (Features[Mips::FeatureMips64r6])
921 EFlags |= ELF::EF_MIPS_ARCH_64R6;
922 else if (Features[Mips::FeatureMips64r2] ||
923 Features[Mips::FeatureMips64r3] ||
924 Features[Mips::FeatureMips64r5])
925 EFlags |= ELF::EF_MIPS_ARCH_64R2;
926 else if (Features[Mips::FeatureMips64])
927 EFlags |= ELF::EF_MIPS_ARCH_64;
928 else if (Features[Mips::FeatureMips5])
929 EFlags |= ELF::EF_MIPS_ARCH_5;
930 else if (Features[Mips::FeatureMips4])
931 EFlags |= ELF::EF_MIPS_ARCH_4;
932 else if (Features[Mips::FeatureMips3])
933 EFlags |= ELF::EF_MIPS_ARCH_3;
934 else if (Features[Mips::FeatureMips32r6])
935 EFlags |= ELF::EF_MIPS_ARCH_32R6;
936 else if (Features[Mips::FeatureMips32r2] ||
937 Features[Mips::FeatureMips32r3] ||
938 Features[Mips::FeatureMips32r5])
939 EFlags |= ELF::EF_MIPS_ARCH_32R2;
940 else if (Features[Mips::FeatureMips32])
941 EFlags |= ELF::EF_MIPS_ARCH_32;
942 else if (Features[Mips::FeatureMips2])
943 EFlags |= ELF::EF_MIPS_ARCH_2;
944 else
945 EFlags |= ELF::EF_MIPS_ARCH_1;
946
947 // Machine
948 if (Features[Mips::FeatureCnMips])
949 EFlags |= ELF::EF_MIPS_MACH_OCTEON;
950 else if (Features[Mips::FeatureR5900])
951 EFlags |= ELF::EF_MIPS_MACH_5900;
952
953 // Other options.
954 if (isMips16Enabled())
956 if (Features[Mips::FeatureNaN2008])
957 EFlags |= ELF::EF_MIPS_NAN2008;
958
959 if (STI.getTargetTriple().isNanoMips()) {
960 Mode = ISAMode::NanoMips;
961 Pic = false; // PIC not supported yet on nanoMIPS
962 }
963
964 W.setELFHeaderEFlags(EFlags);
965}
966
968 auto *Symbol = static_cast<MCSymbolELF *>(S);
970 uint8_t Type = Symbol->getType();
971 if (Type != ELF::STT_FUNC)
972 return;
973
974 if (isMicroMipsEnabled())
975 Symbol->setOther(ELF::STO_MIPS_MICROMIPS);
976 else if (isMips16Enabled())
977 Symbol->setOther(ELF::STO_MIPS_MIPS16);
978}
979
983 const MCObjectFileInfo &OFI = *MCA.getContext().getObjectFileInfo();
985
986 // .bss, .text and .data are always at least 16-byte aligned.
987 MCSection &TextSection = *OFI.getTextSection();
988 S.switchSection(&TextSection);
989 MCSection &DataSection = *OFI.getDataSection();
990 S.switchSection(&DataSection);
991 MCSection &BSSSection = *OFI.getBSSSection();
992 S.switchSection(&BSSSection);
993
994 TextSection.ensureMinAlignment(Align(16));
995 DataSection.ensureMinAlignment(Align(16));
996 BSSSection.ensureMinAlignment(Align(16));
997
998 if (CLOpts.round_section_sizes) {
999 // Make sections sizes a multiple of the alignment. This is useful for
1000 // verifying the output of IAS against the output of other assemblers but
1001 // it's not necessary to produce a correct object and increases section
1002 // size.
1003 for (MCSection &Sec : MCA) {
1004 MCSectionELF &Section = static_cast<MCSectionELF &>(Sec);
1005
1006 Align Alignment = Section.getAlign();
1007 S.switchSection(&Section);
1008 if (Section.isText())
1009 S.emitCodeAlignment(Alignment, STI, Alignment.value());
1010 else
1011 S.emitValueToAlignment(Alignment, 0, 1, Alignment.value());
1012 }
1013 }
1014
1015 const FeatureBitset &Features = STI.getFeatureBits();
1016
1017 // Update e_header flags. See the FIXME and comment above in
1018 // the constructor for a full rundown on this.
1019 unsigned EFlags = W.getELFHeaderEFlags();
1020
1021 // ABI
1022 // N64 does not require any ABI bits.
1023 if (getABI().IsO32())
1024 EFlags |= ELF::EF_MIPS_ABI_O32;
1025 else if (getABI().IsN32())
1026 EFlags |= ELF::EF_MIPS_ABI2;
1027 else if (getABI().IsP32())
1028 EFlags |= ELF::EF_NANOMIPS_ABI_P32;
1029
1030 if (Features[Mips::FeatureGP64Bit]) {
1031 if (getABI().IsO32())
1032 EFlags |= ELF::EF_MIPS_32BITMODE; /* Compatibility Mode */
1033 } else if (Features[Mips::FeatureMips64r2] || Features[Mips::FeatureMips64])
1034 EFlags |= ELF::EF_MIPS_32BITMODE;
1035
1036 if (!isNanoMipsEnabled()) {
1037 // -mplt is not implemented but we should act as if it was
1038 // given.
1039 if (!Features[Mips::FeatureNoABICalls])
1040 EFlags |= ELF::EF_MIPS_CPIC;
1041 if (Pic)
1043 } else {
1044 if (Pic)
1045 EFlags |= ELF::EF_NANOMIPS_PIC;
1046 }
1047
1048 W.setELFHeaderEFlags(EFlags);
1049
1050 if (!isNanoMipsEnabled()) {
1051 // Emit all the option records.
1052 // At the moment we are only emitting .Mips.options (ODK_REGINFO) and
1053 // .reginfo.
1054 MipsELFStreamer &MEF = static_cast<MipsELFStreamer &>(Streamer);
1056 }
1057
1059}
1060
1062 auto *Symbol = static_cast<MCSymbolELF *>(S);
1063 // Propagate the ISA mode of a symbol to its alias.
1064 if (Value->getKind() != MCExpr::SymbolRef)
1065 return;
1066 auto &RhsSym = static_cast<const MCSymbolELF &>(
1067 static_cast<const MCSymbolRefExpr *>(Value)->getSymbol());
1068
1069 // Copy the target-specific flags directly; visibility is stored separately.
1070 Symbol->setOther(RhsSym.getOther());
1071}
1072
1076
1078 auto &S = getStreamer();
1079 S.ensureHeadroom(4);
1080 S.addFixup(Value, Mips::fixup_Mips_GPREL32);
1081 S.appendContents(4, 0);
1082}
1083
1085 auto &S = getStreamer();
1086 S.ensureHeadroom(8);
1087 // fixup_Mips_GPREL32 desginates R_MIPS_GPREL32+R_MIPS_64 on MIPS64.
1088 S.addFixup(Value, Mips::fixup_Mips_GPREL32);
1089 S.appendContents(8, 0);
1090}
1091
1093 auto &S = getStreamer();
1094 S.ensureHeadroom(4);
1095 S.addFixup(Value, Mips::fixup_Mips_DTPREL32);
1096 S.appendContents(4, 0);
1097}
1098
1100 auto &S = getStreamer();
1101 S.ensureHeadroom(8);
1102 S.addFixup(Value, Mips::fixup_Mips_DTPREL64);
1103 S.appendContents(8, 0);
1104}
1105
1107 auto &S = getStreamer();
1108 S.ensureHeadroom(4);
1109 S.addFixup(Value, Mips::fixup_Mips_TPREL32);
1110 S.appendContents(4, 0);
1111}
1112
1114 auto &S = getStreamer();
1115 S.ensureHeadroom(8);
1116 S.addFixup(Value, Mips::fixup_Mips_TPREL64);
1117 S.appendContents(8, 0);
1118}
1119
1121 Mode = ISAMode::MicroMips;
1123}
1124
1126 if (isMicroMipsEnabled())
1127 Mode = ISAMode::Standard;
1129}
1130
1135
1137 assert(!ModeStack.empty() && "unmatched .set pop");
1138 Mode = ModeStack.pop_back_val();
1140}
1141
1146
1149 unsigned Flags = W.getELFHeaderEFlags();
1150 Flags |= ELF::EF_MIPS_MICROMIPS;
1151 W.setELFHeaderEFlags(Flags);
1152}
1153
1155 Mode = ISAMode::Mips16;
1157 unsigned Flags = W.getELFHeaderEFlags();
1159 W.setELFHeaderEFlags(Flags);
1161}
1162
1168
1171 unsigned Flags = W.getELFHeaderEFlags();
1172 Flags |= ELF::EF_MIPS_NOREORDER;
1173 W.setELFHeaderEFlags(Flags);
1175}
1176
1179 MCContext &Context = MCA.getContext();
1180 MCStreamer &OS = getStreamer();
1181
1182 MCSymbol *Sym = Context.getOrCreateSymbol(Name);
1183 const auto *ExprRef = MCSymbolRefExpr::create(Sym, Context);
1184
1185 if (!isNanoMipsEnabled()) {
1186 OS.pushSection();
1187 MCSectionELF *Sec = Context.getELFSection(".pdr", ELF::SHT_PROGBITS, 0);
1188 OS.switchSection(Sec);
1189 Sec->setAlignment(Align(4));
1190
1191 OS.emitValueImpl(ExprRef, 4);
1192
1193 OS.emitIntValue(GPRInfoSet ? GPRBitMask : 0, 4); // reg_mask
1194 OS.emitIntValue(GPRInfoSet ? GPROffset : 0, 4); // reg_offset
1195
1196 OS.emitIntValue(FPRInfoSet ? FPRBitMask : 0, 4); // fpreg_mask
1197 OS.emitIntValue(FPRInfoSet ? FPROffset : 0, 4); // fpreg_offset
1198
1199 OS.emitIntValue(FrameInfoSet ? FrameOffset : 0, 4); // frame_offset
1200 OS.emitIntValue(FrameInfoSet ? FrameReg : 0, 4); // frame_reg
1201 OS.emitIntValue(FrameInfoSet ? ReturnReg : 0, 4); // return_reg
1202
1203 OS.popSection();
1204 }
1205
1206 // The .end directive marks the end of a procedure. Invalidate
1207 // the information gathered up until this point.
1209
1210 // .end also implicitly sets the size.
1211 MCSymbol *CurPCSym = Context.createTempSymbol();
1212 OS.emitLabel(CurPCSym);
1214 MCSymbolRefExpr::create(CurPCSym, Context), ExprRef, Context);
1215
1216 // The ELFObjectWriter can determine the absolute size as it has access to
1217 // the layout information of the assembly file, so a size expression rather
1218 // than an absolute value is ok here.
1219 static_cast<MCSymbolELF *>(Sym)->setSize(Size);
1220}
1221
1224
1225 // .ent also acts like an implicit '.type symbol, STT_FUNC'
1226 static_cast<const MCSymbolELF &>(Symbol).setType(ELF::STT_FUNC);
1227}
1228
1231 unsigned Flags = W.getELFHeaderEFlags();
1233 W.setELFHeaderEFlags(Flags);
1234}
1235
1238 unsigned Flags = W.getELFHeaderEFlags();
1239 Flags |= ELF::EF_MIPS_NAN2008;
1240 W.setELFHeaderEFlags(Flags);
1241}
1242
1245 unsigned Flags = W.getELFHeaderEFlags();
1246 Flags &= ~ELF::EF_MIPS_NAN2008;
1247 W.setELFHeaderEFlags(Flags);
1248}
1249
1252 unsigned Flags = W.getELFHeaderEFlags();
1253 // This option overrides other PIC options like -KPIC.
1254 Pic = false;
1255 Flags &= ~ELF::EF_MIPS_PIC;
1256 W.setELFHeaderEFlags(Flags);
1257}
1258
1261 unsigned Flags = W.getELFHeaderEFlags();
1262 Pic = true;
1263 // NOTE: We are following the GAS behaviour here which means the directive
1264 // 'pic2' also sets the CPIC bit in the ELF header. This is different from
1265 // what is stated in the SYSV ABI which consider the bits EF_MIPS_PIC and
1266 // EF_MIPS_CPIC to be mutually exclusive.
1268 W.setELFHeaderEFlags(Flags);
1269}
1270
1276
1277void MipsTargetELFStreamer::emitFrame(MCRegister StackReg, unsigned StackSize,
1278 MCRegister ReturnReg_) {
1280 const MCRegisterInfo *RegInfo = Context.getRegisterInfo();
1281
1282 FrameInfoSet = true;
1283 FrameReg = RegInfo->getEncodingValue(StackReg);
1284 FrameOffset = StackSize;
1285 ReturnReg = RegInfo->getEncodingValue(ReturnReg_);
1286}
1287
1288void MipsTargetELFStreamer::emitMask(unsigned CPUBitmask,
1289 int CPUTopSavedRegOff) {
1290 GPRInfoSet = true;
1291 GPRBitMask = CPUBitmask;
1292 GPROffset = CPUTopSavedRegOff;
1293}
1294
1295void MipsTargetELFStreamer::emitFMask(unsigned FPUBitmask,
1296 int FPUTopSavedRegOff) {
1297 FPRInfoSet = true;
1298 FPRBitMask = FPUBitmask;
1299 FPROffset = FPUTopSavedRegOff;
1300}
1301
1303 // .cpadd $reg
1304 // This directive inserts code to add $gp to the argument's register
1305 // when support for position independent code is enabled.
1306 if (!Pic)
1307 return;
1308
1309 emitAddu(Reg, Reg, GPReg, getABI().IsN64(), &STI);
1311}
1312
1314 // .cpload $reg
1315 // This directive expands to:
1316 // lui $gp, %hi(_gp_disp)
1317 // addui $gp, $gp, %lo(_gp_disp)
1318 // addu $gp, $gp, $reg
1319 // when support for position independent code is enabled.
1320 if (!Pic || (getABI().IsN32() || getABI().IsN64()))
1321 return;
1322
1323 // There's a GNU extension controlled by -mno-shared that allows
1324 // locally-binding symbols to be accessed using absolute addresses.
1325 // This is currently not supported. When supported -mno-shared makes
1326 // .cpload expand to:
1327 // lui $gp, %hi(__gnu_local_gp)
1328 // addiu $gp, $gp, %lo(__gnu_local_gp)
1329
1330 StringRef SymName("_gp_disp");
1332 MCSymbol *GP_Disp = MCA.getContext().getOrCreateSymbol(SymName);
1333 MCA.registerSymbol(*GP_Disp);
1334
1335 MCInst TmpInst;
1336 TmpInst.setOpcode(Mips::LUi);
1338 auto *HiSym = MCSpecifierExpr::create(GP_Disp, Mips::S_HI, MCA.getContext());
1339 TmpInst.addOperand(MCOperand::createExpr(HiSym));
1340 emitInst(TmpInst, STI);
1341
1342 TmpInst.clear();
1343
1344 TmpInst.setOpcode(Mips::ADDiu);
1347 auto *LoSym = MCSpecifierExpr::create(GP_Disp, Mips::S_LO, MCA.getContext());
1348 TmpInst.addOperand(MCOperand::createExpr(LoSym));
1349 emitInst(TmpInst, STI);
1350
1351 TmpInst.clear();
1352
1353 TmpInst.setOpcode(Mips::ADDu);
1356 TmpInst.addOperand(MCOperand::createReg(Reg));
1357 emitInst(TmpInst, STI);
1358
1360}
1361
1366
1368 int Offset, function_ref<MCRegister()> GetATReg, SMLoc IDLoc,
1369 const MCSubtargetInfo *STI) {
1371 // .cprestore offset
1372 // When PIC mode is enabled and the O32 ABI is used, this directive expands
1373 // to:
1374 // sw $gp, offset($sp)
1375 // and adds a corresponding LW after every JAL.
1376
1377 // Note that .cprestore is ignored if used with the N32 and N64 ABIs or if it
1378 // is used in non-PIC mode.
1379 if (!Pic || (getABI().IsN32() || getABI().IsN64()))
1380 return true;
1381
1382 // Store the $gp on the stack.
1383 emitStoreWithImmOffset(Mips::SW, GPReg, Mips::SP, Offset, GetATReg, IDLoc,
1384 STI);
1385 return true;
1386}
1387
1389 int RegOrOffset,
1390 const MCSymbol &Sym,
1391 bool IsReg) {
1392 // Only N32 and N64 emit anything for .cpsetup iff PIC is set.
1393 if (!Pic || !(getABI().IsN32() || getABI().IsN64()))
1394 return;
1395
1397
1399
1400 // Either store the old $gp in a register or on the stack
1401 if (IsReg) {
1402 // move $save, $gpreg
1403 emitRRR(Mips::OR64, RegOrOffset, GPReg, Mips::R0, SMLoc(), &STI);
1404 } else {
1405 // sd $gpreg, offset($sp)
1406 emitRRI(Mips::SD, GPReg, Mips::SP, RegOrOffset, SMLoc(), &STI);
1407 }
1408
1409 auto *HiExpr =
1411 Mips::S_HI, MCA.getContext());
1412 auto *LoExpr =
1414 Mips::S_LO, MCA.getContext());
1415
1416 // lui $gp, %hi(%neg(%gp_rel(funcSym)))
1417 emitRX(Mips::LUi, GPReg, MCOperand::createExpr(HiExpr), SMLoc(), &STI);
1418
1419 // addiu $gp, $gp, %lo(%neg(%gp_rel(funcSym)))
1420 emitRRX(Mips::ADDiu, GPReg, GPReg, MCOperand::createExpr(LoExpr), SMLoc(),
1421 &STI);
1422
1423 // (d)addu $gp, $gp, $funcreg
1424 if (getABI().IsN32())
1425 emitRRR(Mips::ADDu, GPReg, GPReg, Reg, SMLoc(), &STI);
1426 else
1427 emitRRR(Mips::DADDu, GPReg, GPReg, Reg, SMLoc(), &STI);
1428}
1429
1431 bool SaveLocationIsRegister) {
1432 // Only N32 and N64 emit anything for .cpreturn iff PIC is set.
1433 if (!Pic || !(getABI().IsN32() || getABI().IsN64()))
1434 return;
1435
1436 MCInst Inst;
1437 // Either restore the old $gp from a register or on the stack
1438 if (SaveLocationIsRegister) {
1439 Inst.setOpcode(Mips::OR);
1441 Inst.addOperand(MCOperand::createReg(SaveLocation));
1442 Inst.addOperand(MCOperand::createReg(Mips::R0));
1443 } else {
1444 Inst.setOpcode(Mips::LD);
1447 Inst.addOperand(MCOperand::createImm(SaveLocation));
1448 }
1449 emitInst(Inst, STI);
1450
1452}
1453
1456 MCContext &Context = MCA.getContext();
1457 MCStreamer &OS = getStreamer();
1458 MCSectionELF *Sec = Context.getELFSection(
1459 ".MIPS.abiflags", ELF::SHT_MIPS_ABIFLAGS, ELF::SHF_ALLOC, 24);
1460 OS.switchSection(Sec);
1461 Sec->setAlignment(Align(8));
1462
1463 OS << ABIFlagsSection;
1464}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t Imm
unsigned Opc
static bool hasShortDelaySlot(MCInst &Inst)
static bool isMicroMips(const MCSubtargetInfo *STI)
static void printHex32(unsigned Value, raw_ostream &OS)
static bool isMips32r6(const MCSubtargetInfo *STI)
Container class for subtarget features.
void printExpr(raw_ostream &, const MCExpr &) const
MCContext & getContext() const
LLVM_ABI bool registerSymbol(const MCSymbol &Symbol)
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition MCExpr.h:424
Context object for machine code objects.
Definition MCContext.h:84
const MCObjectFileInfo * getObjectFileInfo() const
Definition MCContext.h:413
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
const MCAsmInfo & getAsmInfo() const
Definition MCContext.h:409
ELFObjectWriter & getWriter()
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:31
@ SymbolRef
References to labels and assigned expressions.
Definition MCExpr.h:40
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:187
void setLoc(SMLoc loc)
Definition MCInst.h:206
void addOperand(const MCOperand Op)
Definition MCInst.h:214
void setOpcode(unsigned Op)
Definition MCInst.h:200
void clear()
Definition MCInst.h:222
MCSection * getBSSSection() const
bool isPositionIndependent() const
MCSection * getTextSection() const
MCSection * getDataSection() const
void emitValueToAlignment(Align Alignment, int64_t Fill=0, uint8_t FillLen=1, unsigned MaxBytesToEmit=0) override
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
MCAssembler & getAssembler()
void emitCodeAlignment(Align ByteAlignment, const MCSubtargetInfo &STI, unsigned MaxBytesToEmit=0) override
Emit nops until the byte alignment ByteAlignment is reached.
Instances of this class represent operands of the MCInst class.
Definition MCInst.h:39
static MCOperand createExpr(const MCExpr *Val)
Definition MCInst.h:165
static MCOperand createReg(MCRegister Reg)
Definition MCInst.h:137
static MCOperand createImm(int64_t Val)
Definition MCInst.h:144
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers and target specific virtual registers.
Definition MCRegister.h:42
This represents a section on linux, lots of unix variants and some bare metal systems.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:577
void setAlignment(Align Value)
Definition MCSection.h:662
void ensureMinAlignment(Align MinAlignment)
Makes sure that Alignment is at least MinAlignment.
Definition MCSection.h:665
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.cpp:743
Streaming machine code generation interface.
Definition MCStreamer.h:221
virtual bool popSection()
Restore the current and previous section from the section stack.
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
MCContext & getContext() const
Definition MCStreamer.h:325
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
virtual void emitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers.
void pushSection()
Save the current and previous section on the section stack.
Definition MCStreamer.h:459
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
virtual void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
LLVM_ABI void setOther(unsigned Other)
Represent a reference to a symbol from inside an expression.
Definition MCExpr.h:187
const MCSymbol & getSymbol() const
Definition MCExpr.h:223
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:210
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
StringRef getName() const
getName - Get the symbol name.
Definition MCSymbol.h:188
MCStreamer & getStreamer()
Definition MCStreamer.h:102
MCContext & getContext()
MCStreamer & Streamer
Definition MCStreamer.h:96
MCTargetStreamer(MCStreamer &S)
static MipsABIInfo O32()
Definition MipsABIInfo.h:32
static MipsABIInfo P32()
Definition MipsABIInfo.h:35
static MipsABIInfo N64()
Definition MipsABIInfo.h:34
void EmitMipsOptionRecords()
Emits all the option records stored up until the point it's called.
void createPendingLabelRelocs()
Mark labels as microMIPS, if necessary for the subtarget.
virtual ~MipsInstEmitter()
static const char * getRegisterName(MCRegister Reg, unsigned AltIdx=Mips::NoRegAltName)
void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value) override
void emitDirectiveSetArch(StringRef Arch) override
void emitDirectiveCpsetup(MCRegister Reg, int RegOrOffset, const MCSymbol &Sym, bool IsReg) override
MipsTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS)
void emitDirectiveCpLocal(MCRegister Reg) override
void emitDirectiveEnt(const MCSymbol &Symbol) override
void emitDTPRel64Value(const MCExpr *) override
void emitTPRel64Value(const MCExpr *) override
bool emitDirectiveCpRestore(int Offset, function_ref< MCRegister()> GetATReg, SMLoc IDLoc, const MCSubtargetInfo *STI) override
Emit a .cprestore directive.
void emitDirectiveCpAdd(MCRegister Reg) override
void emitDirectiveCpLoad(MCRegister Reg) override
void emitFrame(MCRegister StackReg, unsigned StackSize, MCRegister ReturnReg) override
void emitDirectiveEnd(StringRef Name) override
void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override
void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override
void emitDirectiveCpreturn(unsigned SaveLocation, bool SaveLocationIsRegister) override
void emitDTPRel32Value(const MCExpr *) override
void emitTPRel32Value(const MCExpr *) override
void emitDirectiveSetAtWithArg(unsigned RegNo) override
void emitGPRel64Value(const MCExpr *) override
void emitGPRel32Value(const MCExpr *) override
bool emitDirectiveCpRestore(int Offset, function_ref< MCRegister()> GetATReg, SMLoc IDLoc, const MCSubtargetInfo *STI) override
void emitDTPRel32Value(const MCExpr *) override
MipsTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
void emitGPRel64Value(const MCExpr *) override
void emitGPRel32Value(const MCExpr *) override
void emitDirectiveEnd(StringRef Name) override
void emitFrame(MCRegister StackReg, unsigned StackSize, MCRegister ReturnReg) override
void emitDirectiveCpsetup(MCRegister Reg, int RegOrOffset, const MCSymbol &Sym, bool IsReg) override
void emitDirectiveCpAdd(MCRegister Reg) override
void emitDirectiveCpLocal(MCRegister Reg) override
void emitTPRel64Value(const MCExpr *) override
void emitLabel(MCSymbol *Symbol) override
void emitTPRel32Value(const MCExpr *) override
void emitDTPRel64Value(const MCExpr *) override
void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override
void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override
void emitDirectiveCpLoad(MCRegister Reg) override
void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override
void emitDirectiveCpreturn(unsigned SaveLocation, bool SaveLocationIsRegister) override
void emitDirectiveEnt(const MCSymbol &Symbol) override
std::optional< MipsABIInfo > ABI
void emitRRX(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, MCOperand Op2, SMLoc IDLoc, const MCSubtargetInfo *STI)
virtual void emitFrame(MCRegister StackReg, unsigned StackSize, MCRegister ReturnReg)
void emitRRRX(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, MCRegister Reg2, MCOperand Op3, SMLoc IDLoc, const MCSubtargetInfo *STI)
virtual void emitDirectiveCpLoad(MCRegister Reg)
virtual void emitDirectiveCpreturn(unsigned SaveLocation, bool SaveLocationIsRegister)
virtual void emitGPRel32Value(const MCExpr *)
virtual void emitDirectiveSetNoMicroMips()
void emitRX(unsigned Opcode, MCRegister Reg0, MCOperand Op1, SMLoc IDLoc, const MCSubtargetInfo *STI)
virtual void emitDirectiveEnd(StringRef Name)
virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value)
virtual void emitTPRel64Value(const MCExpr *)
void emitR(unsigned Opcode, MCRegister Reg0, SMLoc IDLoc, const MCSubtargetInfo *STI)
void emitRRI(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, int16_t Imm, SMLoc IDLoc, const MCSubtargetInfo *STI)
virtual void emitDirectiveEnt(const MCSymbol &Symbol)
void emitLoadWithImmOffset(unsigned Opcode, MCRegister DstReg, MCRegister BaseReg, int64_t Offset, MCRegister TmpReg, SMLoc IDLoc, const MCSubtargetInfo *STI)
Emit a load instruction with an immediate offset.
void emitEmptyDelaySlot(bool hasShortDelaySlot, SMLoc IDLoc, const MCSubtargetInfo *STI)
void emitAddu(MCRegister DstReg, MCRegister SrcReg, MCRegister TrgReg, bool Is64Bit, const MCSubtargetInfo *STI)
void emitRI(unsigned Opcode, MCRegister Reg0, int32_t Imm, SMLoc IDLoc, const MCSubtargetInfo *STI)
virtual void emitTPRel32Value(const MCExpr *)
virtual void emitDirectiveSetNoMips16()
virtual void emitDirectiveSetNoOddSPReg()
virtual void emitGPRel64Value(const MCExpr *)
void emitII(unsigned Opcode, int16_t Imm1, int16_t Imm2, SMLoc IDLoc, const MCSubtargetInfo *STI)
void emitRR(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, SMLoc IDLoc, const MCSubtargetInfo *STI)
virtual bool emitDirectiveCpRestore(int Offset, function_ref< MCRegister()> GetATReg, SMLoc IDLoc, const MCSubtargetInfo *STI)
virtual void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff)
virtual void emitDirectiveCpsetup(MCRegister Reg, int RegOrOffset, const MCSymbol &Sym, bool IsReg)
void emitRRIII(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, int16_t Imm0, int16_t Imm1, int16_t Imm2, SMLoc IDLoc, const MCSubtargetInfo *STI)
virtual void emitDirectiveSetMicroMips()
virtual void emitDTPRel64Value(const MCExpr *)
virtual void emitDirectiveModuleSoftFloat()
virtual void emitDirectiveSetArch(StringRef Arch)
virtual void emitDTPRel32Value(const MCExpr *)
virtual void emitDirectiveCpAdd(MCRegister Reg)
virtual void emitDirectiveSetAtWithArg(unsigned RegNo)
void emitDSLL(MCRegister DstReg, MCRegister SrcReg, int16_t ShiftAmount, SMLoc IDLoc, const MCSubtargetInfo *STI)
const MipsABIInfo & getABI() const
virtual void emitDirectiveModuleOddSPReg()
void emitInst(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit an instruction through the emitter, if one is set.
void emitGPRestore(int Offset, SMLoc IDLoc, const MCSubtargetInfo *STI)
Emit the $gp restore operation for .cprestore.
virtual void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff)
void emitNop(SMLoc IDLoc, const MCSubtargetInfo *STI)
void emitRRR(unsigned Opcode, MCRegister Reg0, MCRegister Reg1, MCRegister Reg2, SMLoc IDLoc, const MCSubtargetInfo *STI)
virtual void emitDirectiveSetNoReorder()
void emitStoreWithImmOffset(unsigned Opcode, MCRegister SrcReg, MCRegister BaseReg, int64_t Offset, function_ref< MCRegister()> GetATReg, SMLoc IDLoc, const MCSubtargetInfo *STI)
Emit a store instruction with an offset.
virtual void emitDirectiveModuleHardFloat()
virtual void emitDirectiveCpLocal(MCRegister Reg)
MipsABIFlagsSection ABIFlagsSection
Represents a location in source code.
Definition SMLoc.h:22
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
LLVM_ABI std::string lower() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM Value Representation.
Definition Value.h:75
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
@ STT_FUNC
Definition ELF.h:1274
@ STO_MIPS_MICROMIPS
Definition ELF.h:410
@ STO_MIPS_MIPS16
Definition ELF.h:411
@ EF_MIPS_MACH_5900
Definition ELF.h:362
@ EF_MIPS_MICROMIPS
Definition ELF.h:371
@ EF_MIPS_ARCH_32R6
Definition ELF.h:386
@ EF_MIPS_ABI_O32
Definition ELF.h:342
@ EF_MIPS_ARCH_64
Definition ELF.h:383
@ EF_MIPS_ARCH_32
Definition ELF.h:382
@ EF_MIPS_MACH_OCTEON
Definition ELF.h:357
@ EF_MIPS_ARCH_4
Definition ELF.h:380
@ EF_MIPS_ARCH_5
Definition ELF.h:381
@ EF_MIPS_NAN2008
Definition ELF.h:339
@ EF_MIPS_PIC
Definition ELF.h:332
@ EF_MIPS_ARCH_2
Definition ELF.h:378
@ EF_MIPS_32BITMODE
Definition ELF.h:335
@ EF_MIPS_ARCH_32R2
Definition ELF.h:384
@ EF_MIPS_ARCH_64R2
Definition ELF.h:385
@ EF_MIPS_ARCH_ASE_M16
Definition ELF.h:372
@ EF_MIPS_NOREORDER
Definition ELF.h:331
@ EF_MIPS_ARCH_1
Definition ELF.h:377
@ EF_MIPS_CPIC
Definition ELF.h:333
@ EF_MIPS_ARCH_64R6
Definition ELF.h:387
@ EF_MIPS_ABI2
Definition ELF.h:334
@ EF_MIPS_ARCH_3
Definition ELF.h:379
@ SHF_ALLOC
Definition ELF.h:1098
@ EF_NANOMIPS_ABI_P32
Definition ELF.h:936
@ EF_NANOMIPS_PIC
Definition ELF.h:921
@ SHT_PROGBITS
Definition ELF.h:996
@ SHT_MIPS_ABIFLAGS
Definition ELF.h:1077
const MCSpecifierExpr * createGpOff(const MCExpr *Expr, Specifier S, MCContext &Ctx)
constexpr MCPhysReg SP
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
Definition MathExtras.h:166
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:163
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39