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
179void MipsTargetStreamer::emitR(unsigned Opcode, MCRegister Reg0, SMLoc IDLoc,
180 const MCSubtargetInfo *STI) {
181 MCInst TmpInst;
182 TmpInst.setOpcode(Opcode);
183 TmpInst.addOperand(MCOperand::createReg(Reg0));
184 TmpInst.setLoc(IDLoc);
185 getStreamer().emitInstruction(TmpInst, *STI);
186}
187
188void MipsTargetStreamer::emitRX(unsigned Opcode, MCRegister Reg0, MCOperand Op1,
189 SMLoc IDLoc, const MCSubtargetInfo *STI) {
190 MCInst TmpInst;
191 TmpInst.setOpcode(Opcode);
192 TmpInst.addOperand(MCOperand::createReg(Reg0));
193 TmpInst.addOperand(Op1);
194 TmpInst.setLoc(IDLoc);
195 getStreamer().emitInstruction(TmpInst, *STI);
196}
197
198void MipsTargetStreamer::emitRI(unsigned Opcode, MCRegister Reg0, int32_t Imm,
199 SMLoc IDLoc, const MCSubtargetInfo *STI) {
200 emitRX(Opcode, Reg0, MCOperand::createImm(Imm), IDLoc, STI);
201}
202
203void MipsTargetStreamer::emitRR(unsigned Opcode, MCRegister Reg0,
204 MCRegister Reg1, SMLoc IDLoc,
205 const MCSubtargetInfo *STI) {
206 emitRX(Opcode, Reg0, MCOperand::createReg(Reg1), IDLoc, STI);
207}
208
209void MipsTargetStreamer::emitII(unsigned Opcode, int16_t Imm1, int16_t Imm2,
210 SMLoc IDLoc, const MCSubtargetInfo *STI) {
211 MCInst TmpInst;
212 TmpInst.setOpcode(Opcode);
213 TmpInst.addOperand(MCOperand::createImm(Imm1));
214 TmpInst.addOperand(MCOperand::createImm(Imm2));
215 TmpInst.setLoc(IDLoc);
216 getStreamer().emitInstruction(TmpInst, *STI);
217}
218
219void MipsTargetStreamer::emitRRX(unsigned Opcode, MCRegister Reg0,
220 MCRegister Reg1, MCOperand Op2, SMLoc IDLoc,
221 const MCSubtargetInfo *STI) {
222 MCInst TmpInst;
223 TmpInst.setOpcode(Opcode);
224 TmpInst.addOperand(MCOperand::createReg(Reg0));
225 TmpInst.addOperand(MCOperand::createReg(Reg1));
226 TmpInst.addOperand(Op2);
227 TmpInst.setLoc(IDLoc);
228 getStreamer().emitInstruction(TmpInst, *STI);
229}
230
231void MipsTargetStreamer::emitRRR(unsigned Opcode, MCRegister Reg0,
232 MCRegister Reg1, MCRegister Reg2, SMLoc IDLoc,
233 const MCSubtargetInfo *STI) {
234 emitRRX(Opcode, Reg0, Reg1, MCOperand::createReg(Reg2), IDLoc, STI);
235}
236
237void MipsTargetStreamer::emitRRRX(unsigned Opcode, MCRegister Reg0,
238 MCRegister Reg1, MCRegister Reg2,
239 MCOperand Op3, SMLoc IDLoc,
240 const MCSubtargetInfo *STI) {
241 MCInst TmpInst;
242 TmpInst.setOpcode(Opcode);
243 TmpInst.addOperand(MCOperand::createReg(Reg0));
244 TmpInst.addOperand(MCOperand::createReg(Reg1));
245 TmpInst.addOperand(MCOperand::createReg(Reg2));
246 TmpInst.addOperand(Op3);
247 TmpInst.setLoc(IDLoc);
248 getStreamer().emitInstruction(TmpInst, *STI);
249}
250
251void MipsTargetStreamer::emitRRI(unsigned Opcode, MCRegister Reg0,
252 MCRegister Reg1, int16_t Imm, SMLoc IDLoc,
253 const MCSubtargetInfo *STI) {
254 emitRRX(Opcode, Reg0, Reg1, MCOperand::createImm(Imm), IDLoc, STI);
255}
256
257void MipsTargetStreamer::emitRRIII(unsigned Opcode, MCRegister Reg0,
258 MCRegister Reg1, int16_t Imm0, int16_t Imm1,
259 int16_t Imm2, SMLoc IDLoc,
260 const MCSubtargetInfo *STI) {
261 MCInst TmpInst;
262 TmpInst.setOpcode(Opcode);
263 TmpInst.addOperand(MCOperand::createReg(Reg0));
264 TmpInst.addOperand(MCOperand::createReg(Reg1));
265 TmpInst.addOperand(MCOperand::createImm(Imm0));
266 TmpInst.addOperand(MCOperand::createImm(Imm1));
267 TmpInst.addOperand(MCOperand::createImm(Imm2));
268 TmpInst.setLoc(IDLoc);
269 getStreamer().emitInstruction(TmpInst, *STI);
270}
271
273 MCRegister TrgReg, bool Is64Bit,
274 const MCSubtargetInfo *STI) {
275 emitRRR(Is64Bit ? Mips::DADDu : Mips::ADDu, DstReg, SrcReg, TrgReg, SMLoc(),
276 STI);
277}
278
280 int16_t ShiftAmount, SMLoc IDLoc,
281 const MCSubtargetInfo *STI) {
282 if (ShiftAmount >= 32) {
283 emitRRI(Mips::DSLL32, DstReg, SrcReg, ShiftAmount - 32, IDLoc, STI);
284 return;
285 }
286
287 emitRRI(Mips::DSLL, DstReg, SrcReg, ShiftAmount, IDLoc, STI);
288}
289
291 const MCSubtargetInfo *STI) {
292 // The default case of `nop` is `sll $zero, $zero, 0`.
293 unsigned Opc = Mips::SLL;
294 if (isMicroMips(STI) && hasShortDelaySlot) {
295 Opc = isMips32r6(STI) ? Mips::MOVE16_MMR6 : Mips::MOVE16_MM;
296 emitRR(Opc, Mips::R0, Mips::R0, IDLoc, STI);
297 return;
298 }
299
300 if (isMicroMips(STI))
301 Opc = isMips32r6(STI) ? Mips::SLL_MMR6 : Mips::SLL_MM;
302
303 emitRRI(Opc, Mips::R0, Mips::R0, 0, IDLoc, STI);
304}
305
307 if (isMicroMips(STI))
308 emitRR(Mips::MOVE16_MM, Mips::R0, Mips::R0, IDLoc, STI);
309 else
310 emitRRI(Mips::SLL, Mips::R0, Mips::R0, 0, IDLoc, STI);
311}
312
313/// Emit the $gp restore operation for .cprestore.
315 const MCSubtargetInfo *STI) {
316 emitLoadWithImmOffset(Mips::LW, GPReg, Mips::SP, Offset, GPReg, IDLoc, STI);
317}
318
319/// Emit a store instruction with an immediate offset.
321 unsigned Opcode, MCRegister SrcReg, MCRegister BaseReg, int64_t Offset,
322 function_ref<MCRegister()> GetATReg, SMLoc IDLoc,
323 const MCSubtargetInfo *STI) {
324 if (isInt<16>(Offset)) {
325 emitRRI(Opcode, SrcReg, BaseReg, Offset, IDLoc, STI);
326 return;
327 }
328
329 // sw $8, offset($8) => lui $at, %hi(offset)
330 // add $at, $at, $8
331 // sw $8, %lo(offset)($at)
332
333 MCRegister ATReg = GetATReg();
334 if (!ATReg)
335 return;
336
337 unsigned LoOffset = Offset & 0x0000ffff;
338 unsigned HiOffset = (Offset & 0xffff0000) >> 16;
339
340 // If msb of LoOffset is 1(negative number) we must increment HiOffset
341 // to account for the sign-extension of the low part.
342 if (LoOffset & 0x8000)
343 HiOffset++;
344
345 // Generate the base address in ATReg.
346 emitRI(Mips::LUi, ATReg, HiOffset, IDLoc, STI);
347 if (BaseReg != Mips::R0)
348 emitRRR(Mips::ADDu, ATReg, ATReg, BaseReg, IDLoc, STI);
349 // Emit the store with the adjusted base and offset.
350 emitRRI(Opcode, SrcReg, ATReg, LoOffset, IDLoc, STI);
351}
352
353/// Emit a load instruction with an immediate offset. DstReg and TmpReg are
354/// permitted to be the same register iff DstReg is distinct from BaseReg and
355/// DstReg is a GPR. It is the callers responsibility to identify such cases
356/// and pass the appropriate register in TmpReg.
358 unsigned Opcode, MCRegister DstReg, MCRegister BaseReg, int64_t Offset,
359 MCRegister TmpReg, SMLoc IDLoc, const MCSubtargetInfo *STI) {
360 if (isInt<16>(Offset)) {
361 emitRRI(Opcode, DstReg, BaseReg, Offset, IDLoc, STI);
362 return;
363 }
364
365 // 1) lw $8, offset($9) => lui $8, %hi(offset)
366 // add $8, $8, $9
367 // lw $8, %lo(offset)($9)
368 // 2) lw $8, offset($8) => lui $at, %hi(offset)
369 // add $at, $at, $8
370 // lw $8, %lo(offset)($at)
371
372 unsigned LoOffset = Offset & 0x0000ffff;
373 unsigned HiOffset = (Offset & 0xffff0000) >> 16;
374
375 // If msb of LoOffset is 1(negative number) we must increment HiOffset
376 // to account for the sign-extension of the low part.
377 if (LoOffset & 0x8000)
378 HiOffset++;
379
380 // Generate the base address in TmpReg.
381 emitRI(Mips::LUi, TmpReg, HiOffset, IDLoc, STI);
382 if (BaseReg != Mips::R0)
383 emitRRR(Mips::ADDu, TmpReg, TmpReg, BaseReg, IDLoc, STI);
384 // Emit the load with the adjusted base and offset.
385 emitRRI(Opcode, DstReg, TmpReg, LoOffset, IDLoc, STI);
386}
387
391
393 auto &MAI = getStreamer().getContext().getAsmInfo();
394 OS << "\t.dtprelword\t";
395 MAI.printExpr(OS, *Value);
396 OS << '\n';
397}
398
400 auto &MAI = getStreamer().getContext().getAsmInfo();
401 OS << "\t.dtpreldword\t";
402 MAI.printExpr(OS, *Value);
403 OS << '\n';
404}
405
407 auto &MAI = getStreamer().getContext().getAsmInfo();
408 OS << "\t.tprelword\t";
409 MAI.printExpr(OS, *Value);
410 OS << '\n';
411}
412
414 auto &MAI = getStreamer().getContext().getAsmInfo();
415 OS << "\t.tpreldword\t";
416 MAI.printExpr(OS, *Value);
417 OS << '\n';
418}
419
421 auto &MAI = getStreamer().getContext().getAsmInfo();
422 OS << "\t.gpword\t";
423 MAI.printExpr(OS, *Value);
424 OS << '\n';
425}
426
428 auto &MAI = getStreamer().getContext().getAsmInfo();
429 OS << "\t.gpdword\t";
430 MAI.printExpr(OS, *Value);
431 OS << '\n';
432}
433
435 OS << "\t.set\tmicromips\n";
437}
438
440 OS << "\t.set\tnomicromips\n";
442}
443
445 OS << "\t.set\tmips16\n";
447}
448
453
458
460 OS << "\t.set\tnoreorder\n";
462}
463
468
473
478
483
488
493
498
503
508
513
518
523
528
533
538
540 OS << "\t.set\tat=$" << Twine(RegNo) << "\n";
542}
543
548
550 OS << "\t.end\t" << Name << '\n';
551}
552
554 OS << "\t.ent\t" << Symbol.getName() << '\n';
555}
556
557void MipsTargetAsmStreamer::emitDirectiveAbiCalls() { OS << "\t.abicalls\n"; }
558
559void MipsTargetAsmStreamer::emitDirectiveNaN2008() { OS << "\t.nan\t2008\n"; }
560
562 OS << "\t.nan\tlegacy\n";
563}
564
566 OS << "\t.option\tpic0\n";
567}
568
570 OS << "\t.option\tpic2\n";
571}
572
577
578void MipsTargetAsmStreamer::emitFrame(MCRegister StackReg, unsigned StackSize,
580 OS << "\t.frame\t$"
582 << StackSize << ",$"
584}
585
587 OS << "\t.set arch=" << Arch << "\n";
589}
590
595
600
605
610
615
620
625
630
635
640
645
650
655
660
665
670
675
680
685
690
695
700
705
710
715
716// Print a 32 bit hex number with all numbers.
717static void printHex32(unsigned Value, raw_ostream &OS) {
718 OS << "0x";
719 for (int i = 7; i >= 0; i--)
720 OS.write_hex((Value & (0xF << (i * 4))) >> (i * 4));
721}
722
723void MipsTargetAsmStreamer::emitMask(unsigned CPUBitmask,
724 int CPUTopSavedRegOff) {
725 OS << "\t.mask \t";
726 printHex32(CPUBitmask, OS);
727 OS << ',' << CPUTopSavedRegOff << '\n';
728}
729
730void MipsTargetAsmStreamer::emitFMask(unsigned FPUBitmask,
731 int FPUTopSavedRegOff) {
732 OS << "\t.fmask\t";
733 printHex32(FPUBitmask, OS);
734 OS << "," << FPUTopSavedRegOff << '\n';
735}
736
742
748
754
756 int Offset, function_ref<MCRegister()> GetATReg, SMLoc IDLoc,
757 const MCSubtargetInfo *STI) {
759 OS << "\t.cprestore\t" << Offset << "\n";
760 return true;
761}
762
764 int RegOrOffset,
765 const MCSymbol &Sym,
766 bool IsReg) {
767 OS << "\t.cpsetup\t$"
769
770 if (IsReg)
771 OS << "$"
773 else
774 OS << RegOrOffset;
775
776 OS << ", ";
777
778 OS << Sym.getName();
780}
781
783 bool SaveLocationIsRegister) {
784 OS << "\t.cpreturn";
786}
787
791 OS << "\t.module\tsoftfloat\n";
792 else
793 OS << "\t.module\tfp=" << ABIFlagsSection.getFpABIString(FpABI) << "\n";
794}
795
803
806
807 OS << "\t.module\t" << (ABIFlagsSection.OddSPReg ? "" : "no") << "oddspreg\n";
808}
809
814
819
821 OS << "\t.module\tsoftfloat\n";
822}
823
825 OS << "\t.module\thardfloat\n";
826}
827
829 OS << "\t.module\tmt\n";
830}
831
833 OS << "\t.module\tcrc\n";
834}
835
837 OS << "\t.module\tnocrc\n";
838}
839
841 OS << "\t.module\tvirt\n";
842}
843
845 OS << "\t.module\tnovirt\n";
846}
847
849 OS << "\t.module\tginv\n";
850}
851
853 OS << "\t.module\tnoginv\n";
854}
855
856// This part is for ELF object output.
857MipsTargetELFStreamer::ISAMode
858MipsTargetELFStreamer::getISAMode(const MCSubtargetInfo &STI) {
859 if (STI.hasFeature(Mips::FeatureMips16))
860 return ISAMode::Mips16;
861 if (STI.hasFeature(Mips::FeatureMicroMips))
862 return ISAMode::MicroMips;
863 if (STI.hasFeature(Mips::FeatureNanoMips))
864 return ISAMode::NanoMips;
865 return ISAMode::Standard;
866}
867
869 const MCSubtargetInfo &STI)
871 CLOpts(MIPS_MC::getCLOpts(S.getContext().getTargetOptions())),
872 Mode(getISAMode(STI)), STI(STI) {
875
876 // It's possible that MCObjectFileInfo isn't fully initialized at this point
877 // due to an initialization order problem where CodeGenTargetMachineImpl
878 // creates the target streamer before TargetLoweringObjectFile calls
879 // InitializeMCObjectFileInfo. There doesn't seem to be a single place that
880 // covers all cases so this statement covers most cases and direct object
881 // emission must call setPic() once MCObjectFileInfo has been initialized. The
882 // cases we don't handle here are covered by MipsAsmPrinter.
884
885 const FeatureBitset &Features = STI.getFeatureBits();
886
887 // Set the header flags that we can in the constructor.
888 // FIXME: This is a fairly terrible hack. We set the rest
889 // of these in the destructor. The problem here is two-fold:
890 //
891 // a: Some of the eflags can be set/reset by directives.
892 // b: There aren't any usage paths that initialize the ABI
893 // pointer until after we initialize either an assembler
894 // or the target machine.
895 // We can fix this by making the target streamer construct
896 // the ABI, but this is fraught with wide ranging dependency
897 // issues as well.
898 unsigned EFlags = W.getELFHeaderEFlags();
899
900 // FIXME: Fix a dependency issue by instantiating the ABI object to some
901 // default based off the triple. The triple doesn't describe the target
902 // fully, but any external user of the API that uses the MCTargetStreamer
903 // would otherwise crash on assertion failure.
904
905 ABI = MipsABIInfo(STI.getTargetTriple().isNanoMips() ? MipsABIInfo::P32()
906 : STI.getTargetTriple().isMIPS32() ? MipsABIInfo::O32()
907 : MipsABIInfo::N64());
908
909 // Architecture
910 if (Features[Mips::FeatureMips64r6])
911 EFlags |= ELF::EF_MIPS_ARCH_64R6;
912 else if (Features[Mips::FeatureMips64r2] ||
913 Features[Mips::FeatureMips64r3] ||
914 Features[Mips::FeatureMips64r5])
915 EFlags |= ELF::EF_MIPS_ARCH_64R2;
916 else if (Features[Mips::FeatureMips64])
917 EFlags |= ELF::EF_MIPS_ARCH_64;
918 else if (Features[Mips::FeatureMips5])
919 EFlags |= ELF::EF_MIPS_ARCH_5;
920 else if (Features[Mips::FeatureMips4])
921 EFlags |= ELF::EF_MIPS_ARCH_4;
922 else if (Features[Mips::FeatureMips3])
923 EFlags |= ELF::EF_MIPS_ARCH_3;
924 else if (Features[Mips::FeatureMips32r6])
925 EFlags |= ELF::EF_MIPS_ARCH_32R6;
926 else if (Features[Mips::FeatureMips32r2] ||
927 Features[Mips::FeatureMips32r3] ||
928 Features[Mips::FeatureMips32r5])
929 EFlags |= ELF::EF_MIPS_ARCH_32R2;
930 else if (Features[Mips::FeatureMips32])
931 EFlags |= ELF::EF_MIPS_ARCH_32;
932 else if (Features[Mips::FeatureMips2])
933 EFlags |= ELF::EF_MIPS_ARCH_2;
934 else
935 EFlags |= ELF::EF_MIPS_ARCH_1;
936
937 // Machine
938 if (Features[Mips::FeatureCnMips])
939 EFlags |= ELF::EF_MIPS_MACH_OCTEON;
940 else if (Features[Mips::FeatureR5900])
941 EFlags |= ELF::EF_MIPS_MACH_5900;
942
943 // Other options.
944 if (isMips16Enabled())
946 if (Features[Mips::FeatureNaN2008])
947 EFlags |= ELF::EF_MIPS_NAN2008;
948
949 if (STI.getTargetTriple().isNanoMips()) {
950 Mode = ISAMode::NanoMips;
951 Pic = false; // PIC not supported yet on nanoMIPS
952 }
953
954 W.setELFHeaderEFlags(EFlags);
955}
956
958 auto *Symbol = static_cast<MCSymbolELF *>(S);
960 uint8_t Type = Symbol->getType();
961 if (Type != ELF::STT_FUNC)
962 return;
963
964 if (isMicroMipsEnabled())
965 Symbol->setOther(ELF::STO_MIPS_MICROMIPS);
966 else if (isMips16Enabled())
967 Symbol->setOther(ELF::STO_MIPS_MIPS16);
968}
969
973 const MCObjectFileInfo &OFI = *MCA.getContext().getObjectFileInfo();
975
976 // .bss, .text and .data are always at least 16-byte aligned.
977 MCSection &TextSection = *OFI.getTextSection();
978 S.switchSection(&TextSection);
979 MCSection &DataSection = *OFI.getDataSection();
980 S.switchSection(&DataSection);
981 MCSection &BSSSection = *OFI.getBSSSection();
982 S.switchSection(&BSSSection);
983
984 TextSection.ensureMinAlignment(Align(16));
985 DataSection.ensureMinAlignment(Align(16));
986 BSSSection.ensureMinAlignment(Align(16));
987
988 if (CLOpts.round_section_sizes) {
989 // Make sections sizes a multiple of the alignment. This is useful for
990 // verifying the output of IAS against the output of other assemblers but
991 // it's not necessary to produce a correct object and increases section
992 // size.
993 for (MCSection &Sec : MCA) {
994 MCSectionELF &Section = static_cast<MCSectionELF &>(Sec);
995
996 Align Alignment = Section.getAlign();
997 S.switchSection(&Section);
998 if (getContext().getAsmInfo().useCodeAlign(Section))
999 S.emitCodeAlignment(Alignment, STI, Alignment.value());
1000 else
1001 S.emitValueToAlignment(Alignment, 0, 1, Alignment.value());
1002 }
1003 }
1004
1005 const FeatureBitset &Features = STI.getFeatureBits();
1006
1007 // Update e_header flags. See the FIXME and comment above in
1008 // the constructor for a full rundown on this.
1009 unsigned EFlags = W.getELFHeaderEFlags();
1010
1011 // ABI
1012 // N64 does not require any ABI bits.
1013 if (getABI().IsO32())
1014 EFlags |= ELF::EF_MIPS_ABI_O32;
1015 else if (getABI().IsN32())
1016 EFlags |= ELF::EF_MIPS_ABI2;
1017 else if (getABI().IsP32())
1018 EFlags |= ELF::EF_NANOMIPS_ABI_P32;
1019
1020 if (Features[Mips::FeatureGP64Bit]) {
1021 if (getABI().IsO32())
1022 EFlags |= ELF::EF_MIPS_32BITMODE; /* Compatibility Mode */
1023 } else if (Features[Mips::FeatureMips64r2] || Features[Mips::FeatureMips64])
1024 EFlags |= ELF::EF_MIPS_32BITMODE;
1025
1026 if (!isNanoMipsEnabled()) {
1027 // -mplt is not implemented but we should act as if it was
1028 // given.
1029 if (!Features[Mips::FeatureNoABICalls])
1030 EFlags |= ELF::EF_MIPS_CPIC;
1031 if (Pic)
1033 } else {
1034 if (Pic)
1035 EFlags |= ELF::EF_NANOMIPS_PIC;
1036 }
1037
1038 W.setELFHeaderEFlags(EFlags);
1039
1040 if (!isNanoMipsEnabled()) {
1041 // Emit all the option records.
1042 // At the moment we are only emitting .Mips.options (ODK_REGINFO) and
1043 // .reginfo.
1044 MipsELFStreamer &MEF = static_cast<MipsELFStreamer &>(Streamer);
1046 }
1047
1049}
1050
1052 auto *Symbol = static_cast<MCSymbolELF *>(S);
1053 // Propagate the ISA mode of a symbol to its alias.
1054 if (Value->getKind() != MCExpr::SymbolRef)
1055 return;
1056 auto &RhsSym = static_cast<const MCSymbolELF &>(
1057 static_cast<const MCSymbolRefExpr *>(Value)->getSymbol());
1058
1059 // Copy the target-specific flags directly; visibility is stored separately.
1060 Symbol->setOther(RhsSym.getOther());
1061}
1062
1066
1068 auto &S = getStreamer();
1069 S.ensureHeadroom(4);
1070 S.addFixup(Value, Mips::fixup_Mips_GPREL32);
1071 S.appendContents(4, 0);
1072}
1073
1075 auto &S = getStreamer();
1076 S.ensureHeadroom(8);
1077 // fixup_Mips_GPREL32 desginates R_MIPS_GPREL32+R_MIPS_64 on MIPS64.
1078 S.addFixup(Value, Mips::fixup_Mips_GPREL32);
1079 S.appendContents(8, 0);
1080}
1081
1083 auto &S = getStreamer();
1084 S.ensureHeadroom(4);
1085 S.addFixup(Value, Mips::fixup_Mips_DTPREL32);
1086 S.appendContents(4, 0);
1087}
1088
1090 auto &S = getStreamer();
1091 S.ensureHeadroom(8);
1092 S.addFixup(Value, Mips::fixup_Mips_DTPREL64);
1093 S.appendContents(8, 0);
1094}
1095
1097 auto &S = getStreamer();
1098 S.ensureHeadroom(4);
1099 S.addFixup(Value, Mips::fixup_Mips_TPREL32);
1100 S.appendContents(4, 0);
1101}
1102
1104 auto &S = getStreamer();
1105 S.ensureHeadroom(8);
1106 S.addFixup(Value, Mips::fixup_Mips_TPREL64);
1107 S.appendContents(8, 0);
1108}
1109
1111 Mode = ISAMode::MicroMips;
1113}
1114
1116 if (isMicroMipsEnabled())
1117 Mode = ISAMode::Standard;
1119}
1120
1125
1127 assert(!ModeStack.empty() && "unmatched .set pop");
1128 Mode = ModeStack.pop_back_val();
1130}
1131
1136
1139 unsigned Flags = W.getELFHeaderEFlags();
1140 Flags |= ELF::EF_MIPS_MICROMIPS;
1141 W.setELFHeaderEFlags(Flags);
1142}
1143
1145 Mode = ISAMode::Mips16;
1147 unsigned Flags = W.getELFHeaderEFlags();
1149 W.setELFHeaderEFlags(Flags);
1151}
1152
1158
1161 unsigned Flags = W.getELFHeaderEFlags();
1162 Flags |= ELF::EF_MIPS_NOREORDER;
1163 W.setELFHeaderEFlags(Flags);
1165}
1166
1169 MCContext &Context = MCA.getContext();
1170 MCStreamer &OS = getStreamer();
1171
1172 MCSymbol *Sym = Context.getOrCreateSymbol(Name);
1173 const auto *ExprRef = MCSymbolRefExpr::create(Sym, Context);
1174
1175 if (!isNanoMipsEnabled()) {
1176 OS.pushSection();
1177 MCSectionELF *Sec = Context.getELFSection(".pdr", ELF::SHT_PROGBITS, 0);
1178 OS.switchSection(Sec);
1179 Sec->setAlignment(Align(4));
1180
1181 OS.emitValueImpl(ExprRef, 4);
1182
1183 OS.emitIntValue(GPRInfoSet ? GPRBitMask : 0, 4); // reg_mask
1184 OS.emitIntValue(GPRInfoSet ? GPROffset : 0, 4); // reg_offset
1185
1186 OS.emitIntValue(FPRInfoSet ? FPRBitMask : 0, 4); // fpreg_mask
1187 OS.emitIntValue(FPRInfoSet ? FPROffset : 0, 4); // fpreg_offset
1188
1189 OS.emitIntValue(FrameInfoSet ? FrameOffset : 0, 4); // frame_offset
1190 OS.emitIntValue(FrameInfoSet ? FrameReg : 0, 4); // frame_reg
1191 OS.emitIntValue(FrameInfoSet ? ReturnReg : 0, 4); // return_reg
1192
1193 OS.popSection();
1194 }
1195
1196 // The .end directive marks the end of a procedure. Invalidate
1197 // the information gathered up until this point.
1199
1200 // .end also implicitly sets the size.
1201 MCSymbol *CurPCSym = Context.createTempSymbol();
1202 OS.emitLabel(CurPCSym);
1204 MCSymbolRefExpr::create(CurPCSym, Context), ExprRef, Context);
1205
1206 // The ELFObjectWriter can determine the absolute size as it has access to
1207 // the layout information of the assembly file, so a size expression rather
1208 // than an absolute value is ok here.
1209 static_cast<MCSymbolELF *>(Sym)->setSize(Size);
1210}
1211
1214
1215 // .ent also acts like an implicit '.type symbol, STT_FUNC'
1216 static_cast<const MCSymbolELF &>(Symbol).setType(ELF::STT_FUNC);
1217}
1218
1221 unsigned Flags = W.getELFHeaderEFlags();
1223 W.setELFHeaderEFlags(Flags);
1224}
1225
1228 unsigned Flags = W.getELFHeaderEFlags();
1229 Flags |= ELF::EF_MIPS_NAN2008;
1230 W.setELFHeaderEFlags(Flags);
1231}
1232
1235 unsigned Flags = W.getELFHeaderEFlags();
1236 Flags &= ~ELF::EF_MIPS_NAN2008;
1237 W.setELFHeaderEFlags(Flags);
1238}
1239
1242 unsigned Flags = W.getELFHeaderEFlags();
1243 // This option overrides other PIC options like -KPIC.
1244 Pic = false;
1245 Flags &= ~ELF::EF_MIPS_PIC;
1246 W.setELFHeaderEFlags(Flags);
1247}
1248
1251 unsigned Flags = W.getELFHeaderEFlags();
1252 Pic = true;
1253 // NOTE: We are following the GAS behaviour here which means the directive
1254 // 'pic2' also sets the CPIC bit in the ELF header. This is different from
1255 // what is stated in the SYSV ABI which consider the bits EF_MIPS_PIC and
1256 // EF_MIPS_CPIC to be mutually exclusive.
1258 W.setELFHeaderEFlags(Flags);
1259}
1260
1266
1267void MipsTargetELFStreamer::emitFrame(MCRegister StackReg, unsigned StackSize,
1268 MCRegister ReturnReg_) {
1270 const MCRegisterInfo *RegInfo = Context.getRegisterInfo();
1271
1272 FrameInfoSet = true;
1273 FrameReg = RegInfo->getEncodingValue(StackReg);
1274 FrameOffset = StackSize;
1275 ReturnReg = RegInfo->getEncodingValue(ReturnReg_);
1276}
1277
1278void MipsTargetELFStreamer::emitMask(unsigned CPUBitmask,
1279 int CPUTopSavedRegOff) {
1280 GPRInfoSet = true;
1281 GPRBitMask = CPUBitmask;
1282 GPROffset = CPUTopSavedRegOff;
1283}
1284
1285void MipsTargetELFStreamer::emitFMask(unsigned FPUBitmask,
1286 int FPUTopSavedRegOff) {
1287 FPRInfoSet = true;
1288 FPRBitMask = FPUBitmask;
1289 FPROffset = FPUTopSavedRegOff;
1290}
1291
1293 // .cpadd $reg
1294 // This directive inserts code to add $gp to the argument's register
1295 // when support for position independent code is enabled.
1296 if (!Pic)
1297 return;
1298
1299 emitAddu(Reg, Reg, GPReg, getABI().IsN64(), &STI);
1301}
1302
1304 // .cpload $reg
1305 // This directive expands to:
1306 // lui $gp, %hi(_gp_disp)
1307 // addui $gp, $gp, %lo(_gp_disp)
1308 // addu $gp, $gp, $reg
1309 // when support for position independent code is enabled.
1310 if (!Pic || (getABI().IsN32() || getABI().IsN64()))
1311 return;
1312
1313 // There's a GNU extension controlled by -mno-shared that allows
1314 // locally-binding symbols to be accessed using absolute addresses.
1315 // This is currently not supported. When supported -mno-shared makes
1316 // .cpload expand to:
1317 // lui $gp, %hi(__gnu_local_gp)
1318 // addiu $gp, $gp, %lo(__gnu_local_gp)
1319
1320 StringRef SymName("_gp_disp");
1322 MCSymbol *GP_Disp = MCA.getContext().getOrCreateSymbol(SymName);
1323 MCA.registerSymbol(*GP_Disp);
1324
1325 MCInst TmpInst;
1326 TmpInst.setOpcode(Mips::LUi);
1328 auto *HiSym = MCSpecifierExpr::create(GP_Disp, Mips::S_HI, MCA.getContext());
1329 TmpInst.addOperand(MCOperand::createExpr(HiSym));
1330 getStreamer().emitInstruction(TmpInst, STI);
1331
1332 TmpInst.clear();
1333
1334 TmpInst.setOpcode(Mips::ADDiu);
1337 auto *LoSym = MCSpecifierExpr::create(GP_Disp, Mips::S_LO, MCA.getContext());
1338 TmpInst.addOperand(MCOperand::createExpr(LoSym));
1339 getStreamer().emitInstruction(TmpInst, STI);
1340
1341 TmpInst.clear();
1342
1343 TmpInst.setOpcode(Mips::ADDu);
1346 TmpInst.addOperand(MCOperand::createReg(Reg));
1347 getStreamer().emitInstruction(TmpInst, STI);
1348
1350}
1351
1356
1358 int Offset, function_ref<MCRegister()> GetATReg, SMLoc IDLoc,
1359 const MCSubtargetInfo *STI) {
1361 // .cprestore offset
1362 // When PIC mode is enabled and the O32 ABI is used, this directive expands
1363 // to:
1364 // sw $gp, offset($sp)
1365 // and adds a corresponding LW after every JAL.
1366
1367 // Note that .cprestore is ignored if used with the N32 and N64 ABIs or if it
1368 // is used in non-PIC mode.
1369 if (!Pic || (getABI().IsN32() || getABI().IsN64()))
1370 return true;
1371
1372 // Store the $gp on the stack.
1373 emitStoreWithImmOffset(Mips::SW, GPReg, Mips::SP, Offset, GetATReg, IDLoc,
1374 STI);
1375 return true;
1376}
1377
1379 int RegOrOffset,
1380 const MCSymbol &Sym,
1381 bool IsReg) {
1382 // Only N32 and N64 emit anything for .cpsetup iff PIC is set.
1383 if (!Pic || !(getABI().IsN32() || getABI().IsN64()))
1384 return;
1385
1387
1389
1390 // Either store the old $gp in a register or on the stack
1391 if (IsReg) {
1392 // move $save, $gpreg
1393 emitRRR(Mips::OR64, RegOrOffset, GPReg, Mips::R0, SMLoc(), &STI);
1394 } else {
1395 // sd $gpreg, offset($sp)
1396 emitRRI(Mips::SD, GPReg, Mips::SP, RegOrOffset, SMLoc(), &STI);
1397 }
1398
1399 auto *HiExpr =
1401 Mips::S_HI, MCA.getContext());
1402 auto *LoExpr =
1404 Mips::S_LO, MCA.getContext());
1405
1406 // lui $gp, %hi(%neg(%gp_rel(funcSym)))
1407 emitRX(Mips::LUi, GPReg, MCOperand::createExpr(HiExpr), SMLoc(), &STI);
1408
1409 // addiu $gp, $gp, %lo(%neg(%gp_rel(funcSym)))
1410 emitRRX(Mips::ADDiu, GPReg, GPReg, MCOperand::createExpr(LoExpr), SMLoc(),
1411 &STI);
1412
1413 // (d)addu $gp, $gp, $funcreg
1414 if (getABI().IsN32())
1415 emitRRR(Mips::ADDu, GPReg, GPReg, Reg, SMLoc(), &STI);
1416 else
1417 emitRRR(Mips::DADDu, GPReg, GPReg, Reg, SMLoc(), &STI);
1418}
1419
1421 bool SaveLocationIsRegister) {
1422 // Only N32 and N64 emit anything for .cpreturn iff PIC is set.
1423 if (!Pic || !(getABI().IsN32() || getABI().IsN64()))
1424 return;
1425
1426 MCInst Inst;
1427 // Either restore the old $gp from a register or on the stack
1428 if (SaveLocationIsRegister) {
1429 Inst.setOpcode(Mips::OR);
1431 Inst.addOperand(MCOperand::createReg(SaveLocation));
1432 Inst.addOperand(MCOperand::createReg(Mips::R0));
1433 } else {
1434 Inst.setOpcode(Mips::LD);
1437 Inst.addOperand(MCOperand::createImm(SaveLocation));
1438 }
1439 getStreamer().emitInstruction(Inst, STI);
1440
1442}
1443
1446 MCContext &Context = MCA.getContext();
1447 MCStreamer &OS = getStreamer();
1448 MCSectionELF *Sec = Context.getELFSection(
1449 ".MIPS.abiflags", ELF::SHT_MIPS_ABIFLAGS, ELF::SHF_ALLOC, 24);
1450 OS.switchSection(Sec);
1451 Sec->setAlignment(Align(8));
1452
1453 OS << ABIFlagsSection;
1454}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t Imm
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:427
Context object for machine code objects.
Definition MCContext.h:83
const MCObjectFileInfo * getObjectFileInfo() const
Definition MCContext.h:411
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
const MCAsmInfo & getAsmInfo() const
Definition MCContext.h:407
ELFObjectWriter & getWriter()
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
@ SymbolRef
References to labels and assigned expressions.
Definition MCExpr.h:43
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
void setLoc(SMLoc loc)
Definition MCInst.h:207
void addOperand(const MCOperand Op)
Definition MCInst.h:215
void setOpcode(unsigned Op)
Definition MCInst.h:201
void clear()
Definition MCInst.h:223
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.
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
Instances of this class represent operands of the MCInst class.
Definition MCInst.h:40
static MCOperand createExpr(const MCExpr *Val)
Definition MCInst.h:166
static MCOperand createReg(MCRegister Reg)
Definition MCInst.h:138
static MCOperand createImm(int64_t Val)
Definition MCInst.h:145
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
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:580
void setAlignment(Align Value)
Definition MCSection.h:665
void ensureMinAlignment(Align MinAlignment)
Makes sure that Alignment is at least MinAlignment.
Definition MCSection.h:668
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:222
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:326
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:460
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:190
const MCSymbol & getSymbol() const
Definition MCExpr.h:226
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:213
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:103
MCContext & getContext()
MCStreamer & Streamer
Definition MCStreamer.h:97
MCTargetStreamer(MCStreamer &S)
static MipsABIInfo O32()
Definition MipsABIInfo.h:33
static MipsABIInfo P32()
Definition MipsABIInfo.h:36
static MipsABIInfo N64()
Definition MipsABIInfo.h:35
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.
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 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