LLVM  3.7.0
MipsTargetStreamer.cpp
Go to the documentation of this file.
1 //===-- MipsTargetStreamer.cpp - Mips Target Streamer Methods -------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file provides Mips specific target streamer methods.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "MipsELFStreamer.h"
16 #include "MipsMCTargetDesc.h"
17 #include "MipsTargetObjectFile.h"
18 #include "MipsTargetStreamer.h"
19 #include "llvm/MC/MCContext.h"
20 #include "llvm/MC/MCSectionELF.h"
22 #include "llvm/MC/MCSymbolELF.h"
24 #include "llvm/Support/ELF.h"
27 
28 using namespace llvm;
29 
31  : MCTargetStreamer(S), ModuleDirectiveAllowed(true) {
33 }
47 }
57 void MipsTargetStreamer::emitFrame(unsigned StackReg, unsigned StackSize,
58  unsigned ReturnReg) {}
59 void MipsTargetStreamer::emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) {}
60 void MipsTargetStreamer::emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) {
61 }
64 }
85 }
88 }
92 void MipsTargetStreamer::emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
93  const MCSymbol &Sym, bool IsReg) {
94 }
95 
97 
100  report_fatal_error("+nooddspreg is only valid for O32");
101 }
107 }
111 }
112 
115  : MipsTargetStreamer(S), OS(OS) {}
116 
118  OS << "\t.set\tmicromips\n";
120 }
121 
123  OS << "\t.set\tnomicromips\n";
125 }
126 
128  OS << "\t.set\tmips16\n";
130 }
131 
133  OS << "\t.set\tnomips16\n";
135 }
136 
138  OS << "\t.set\treorder\n";
140 }
141 
143  OS << "\t.set\tnoreorder\n";
145 }
146 
148  OS << "\t.set\tmacro\n";
150 }
151 
153  OS << "\t.set\tnomacro\n";
155 }
156 
158  OS << "\t.set\tmsa\n";
160 }
161 
163  OS << "\t.set\tnomsa\n";
165 }
166 
168  OS << "\t.set\tat\n";
170 }
171 
173  OS << "\t.set\tat=$" << Twine(RegNo) << "\n";
175 }
176 
178  OS << "\t.set\tnoat\n";
180 }
181 
183  OS << "\t.end\t" << Name << '\n';
184 }
185 
187  OS << "\t.ent\t" << Symbol.getName() << '\n';
188 }
189 
190 void MipsTargetAsmStreamer::emitDirectiveAbiCalls() { OS << "\t.abicalls\n"; }
191 
192 void MipsTargetAsmStreamer::emitDirectiveNaN2008() { OS << "\t.nan\t2008\n"; }
193 
195  OS << "\t.nan\tlegacy\n";
196 }
197 
199  OS << "\t.option\tpic0\n";
200 }
201 
203  OS << "\t.option\tpic2\n";
204 }
205 
208  OS << "\t.insn\n";
209 }
210 
211 void MipsTargetAsmStreamer::emitFrame(unsigned StackReg, unsigned StackSize,
212  unsigned ReturnReg) {
213  OS << "\t.frame\t$"
214  << StringRef(MipsInstPrinter::getRegisterName(StackReg)).lower() << ","
215  << StackSize << ",$"
216  << StringRef(MipsInstPrinter::getRegisterName(ReturnReg)).lower() << '\n';
217 }
218 
220  OS << "\t.set arch=" << Arch << "\n";
222 }
223 
225  OS << "\t.set\tmips0\n";
227 }
228 
230  OS << "\t.set\tmips1\n";
232 }
233 
235  OS << "\t.set\tmips2\n";
237 }
238 
240  OS << "\t.set\tmips3\n";
242 }
243 
245  OS << "\t.set\tmips4\n";
247 }
248 
250  OS << "\t.set\tmips5\n";
252 }
253 
255  OS << "\t.set\tmips32\n";
257 }
258 
260  OS << "\t.set\tmips32r2\n";
262 }
263 
265  OS << "\t.set\tmips32r3\n";
267 }
268 
270  OS << "\t.set\tmips32r5\n";
272 }
273 
275  OS << "\t.set\tmips32r6\n";
277 }
278 
280  OS << "\t.set\tmips64\n";
282 }
283 
285  OS << "\t.set\tmips64r2\n";
287 }
288 
290  OS << "\t.set\tmips64r3\n";
292 }
293 
295  OS << "\t.set\tmips64r5\n";
297 }
298 
300  OS << "\t.set\tmips64r6\n";
302 }
303 
305  OS << "\t.set\tdsp\n";
307 }
308 
310  OS << "\t.set\tnodsp\n";
312 }
313 
315  OS << "\t.set\tpop\n";
317 }
318 
320  OS << "\t.set\tpush\n";
322 }
323 
325  OS << "\t.set\tsoftfloat\n";
327 }
328 
330  OS << "\t.set\thardfloat\n";
332 }
333 
334 // Print a 32 bit hex number with all numbers.
335 static void printHex32(unsigned Value, raw_ostream &OS) {
336  OS << "0x";
337  for (int i = 7; i >= 0; i--)
338  OS.write_hex((Value & (0xF << (i * 4))) >> (i * 4));
339 }
340 
341 void MipsTargetAsmStreamer::emitMask(unsigned CPUBitmask,
342  int CPUTopSavedRegOff) {
343  OS << "\t.mask \t";
344  printHex32(CPUBitmask, OS);
345  OS << ',' << CPUTopSavedRegOff << '\n';
346 }
347 
348 void MipsTargetAsmStreamer::emitFMask(unsigned FPUBitmask,
349  int FPUTopSavedRegOff) {
350  OS << "\t.fmask\t";
351  printHex32(FPUBitmask, OS);
352  OS << "," << FPUTopSavedRegOff << '\n';
353 }
354 
356  OS << "\t.cpload\t$"
357  << StringRef(MipsInstPrinter::getRegisterName(RegNo)).lower() << "\n";
359 }
360 
362  int RegOrOffset,
363  const MCSymbol &Sym,
364  bool IsReg) {
365  OS << "\t.cpsetup\t$"
366  << StringRef(MipsInstPrinter::getRegisterName(RegNo)).lower() << ", ";
367 
368  if (IsReg)
369  OS << "$"
371  else
372  OS << RegOrOffset;
373 
374  OS << ", ";
375 
376  OS << Sym.getName() << "\n";
378 }
379 
381  OS << "\t.module\tfp=";
383 }
384 
388 
389  OS << "\t.set\tfp=";
390  OS << ABIFlagsSection.getFpABIString(Value) << "\n";
391 }
392 
395 
396  OS << "\t.module\t" << (ABIFlagsSection.OddSPReg ? "" : "no") << "oddspreg\n";
397 }
398 
401  OS << "\t.set\toddspreg\n";
402 }
403 
406  OS << "\t.set\tnooddspreg\n";
407 }
408 
410  OS << "\t.module\tsoftfloat\n";
411 }
412 
414  OS << "\t.module\thardfloat\n";
415 }
416 
417 // This part is for ELF object output.
419  const MCSubtargetInfo &STI)
420  : MipsTargetStreamer(S), MicroMipsEnabled(false), STI(STI) {
423 
424  const FeatureBitset &Features = STI.getFeatureBits();
425 
426  // Set the header flags that we can in the constructor.
427  // FIXME: This is a fairly terrible hack. We set the rest
428  // of these in the destructor. The problem here is two-fold:
429  //
430  // a: Some of the eflags can be set/reset by directives.
431  // b: There aren't any usage paths that initialize the ABI
432  // pointer until after we initialize either an assembler
433  // or the target machine.
434  // We can fix this by making the target streamer construct
435  // the ABI, but this is fraught with wide ranging dependency
436  // issues as well.
437  unsigned EFlags = MCA.getELFHeaderEFlags();
438 
439  // Architecture
440  if (Features[Mips::FeatureMips64r6])
441  EFlags |= ELF::EF_MIPS_ARCH_64R6;
442  else if (Features[Mips::FeatureMips64r2] ||
443  Features[Mips::FeatureMips64r3] ||
444  Features[Mips::FeatureMips64r5])
445  EFlags |= ELF::EF_MIPS_ARCH_64R2;
446  else if (Features[Mips::FeatureMips64])
447  EFlags |= ELF::EF_MIPS_ARCH_64;
448  else if (Features[Mips::FeatureMips5])
449  EFlags |= ELF::EF_MIPS_ARCH_5;
450  else if (Features[Mips::FeatureMips4])
451  EFlags |= ELF::EF_MIPS_ARCH_4;
452  else if (Features[Mips::FeatureMips3])
453  EFlags |= ELF::EF_MIPS_ARCH_3;
454  else if (Features[Mips::FeatureMips32r6])
455  EFlags |= ELF::EF_MIPS_ARCH_32R6;
456  else if (Features[Mips::FeatureMips32r2] ||
457  Features[Mips::FeatureMips32r3] ||
458  Features[Mips::FeatureMips32r5])
459  EFlags |= ELF::EF_MIPS_ARCH_32R2;
460  else if (Features[Mips::FeatureMips32])
461  EFlags |= ELF::EF_MIPS_ARCH_32;
462  else if (Features[Mips::FeatureMips2])
463  EFlags |= ELF::EF_MIPS_ARCH_2;
464  else
465  EFlags |= ELF::EF_MIPS_ARCH_1;
466 
467  // Other options.
468  if (Features[Mips::FeatureNaN2008])
469  EFlags |= ELF::EF_MIPS_NAN2008;
470 
471  // -mabicalls and -mplt are not implemented but we should act as if they were
472  // given.
473  EFlags |= ELF::EF_MIPS_CPIC;
474 
475  MCA.setELFHeaderEFlags(EFlags);
476 }
477 
479  auto *Symbol = cast<MCSymbolELF>(S);
480  if (!isMicroMipsEnabled())
481  return;
483  uint8_t Type = Symbol->getType();
484  if (Type != ELF::STT_FUNC)
485  return;
486 
487  Symbol->setOther(ELF::STO_MIPS_MICROMIPS);
488 }
489 
492  const MCObjectFileInfo &OFI = *MCA.getContext().getObjectFileInfo();
493 
494  // .bss, .text and .data are always at least 16-byte aligned.
495  MCSection &TextSection = *OFI.getTextSection();
496  MCA.registerSection(TextSection);
497  MCSection &DataSection = *OFI.getDataSection();
498  MCA.registerSection(DataSection);
499  MCSection &BSSSection = *OFI.getBSSSection();
500  MCA.registerSection(BSSSection);
501 
502  TextSection.setAlignment(std::max(16u, TextSection.getAlignment()));
503  DataSection.setAlignment(std::max(16u, DataSection.getAlignment()));
504  BSSSection.setAlignment(std::max(16u, BSSSection.getAlignment()));
505 
506  const FeatureBitset &Features = STI.getFeatureBits();
507 
508  // Update e_header flags. See the FIXME and comment above in
509  // the constructor for a full rundown on this.
510  unsigned EFlags = MCA.getELFHeaderEFlags();
511 
512  // ABI
513  // N64 does not require any ABI bits.
514  if (getABI().IsO32())
515  EFlags |= ELF::EF_MIPS_ABI_O32;
516  else if (getABI().IsN32())
517  EFlags |= ELF::EF_MIPS_ABI2;
518 
519  if (Features[Mips::FeatureGP64Bit]) {
520  if (getABI().IsO32())
521  EFlags |= ELF::EF_MIPS_32BITMODE; /* Compatibility Mode */
522  } else if (Features[Mips::FeatureMips64r2] || Features[Mips::FeatureMips64])
523  EFlags |= ELF::EF_MIPS_32BITMODE;
524 
525  // If we've set the cpic eflag and we're n64, go ahead and set the pic
526  // one as well.
527  if (EFlags & ELF::EF_MIPS_CPIC && getABI().IsN64())
528  EFlags |= ELF::EF_MIPS_PIC;
529 
530  MCA.setELFHeaderEFlags(EFlags);
531 
532  // Emit all the option records.
533  // At the moment we are only emitting .Mips.options (ODK_REGINFO) and
534  // .reginfo.
535  MipsELFStreamer &MEF = static_cast<MipsELFStreamer &>(Streamer);
536  MEF.EmitMipsOptionRecords();
537 
539 }
540 
542  auto *Symbol = cast<MCSymbolELF>(S);
543  // If on rhs is micromips symbol then mark Symbol as microMips.
544  if (Value->getKind() != MCExpr::SymbolRef)
545  return;
546  const auto &RhsSym = cast<MCSymbolELF>(
547  static_cast<const MCSymbolRefExpr *>(Value)->getSymbol());
548 
549  if (!(RhsSym.getOther() & ELF::STO_MIPS_MICROMIPS))
550  return;
551 
552  Symbol->setOther(ELF::STO_MIPS_MICROMIPS);
553 }
554 
556  return static_cast<MCELFStreamer &>(Streamer);
557 }
558 
560  MicroMipsEnabled = true;
561 
563  unsigned Flags = MCA.getELFHeaderEFlags();
564  Flags |= ELF::EF_MIPS_MICROMIPS;
565  MCA.setELFHeaderEFlags(Flags);
567 }
568 
570  MicroMipsEnabled = false;
572 }
573 
576  unsigned Flags = MCA.getELFHeaderEFlags();
577  Flags |= ELF::EF_MIPS_ARCH_ASE_M16;
578  MCA.setELFHeaderEFlags(Flags);
580 }
581 
584  unsigned Flags = MCA.getELFHeaderEFlags();
585  Flags |= ELF::EF_MIPS_NOREORDER;
586  MCA.setELFHeaderEFlags(Flags);
588 }
589 
592  MCContext &Context = MCA.getContext();
593  MCStreamer &OS = getStreamer();
594 
595  MCSectionELF *Sec = Context.getELFSection(".pdr", ELF::SHT_PROGBITS,
597 
598  const MCSymbolRefExpr *ExprRef =
600 
601  MCA.registerSection(*Sec);
602  Sec->setAlignment(4);
603 
604  OS.PushSection();
605 
606  OS.SwitchSection(Sec);
607 
608  OS.EmitValueImpl(ExprRef, 4);
609 
610  OS.EmitIntValue(GPRInfoSet ? GPRBitMask : 0, 4); // reg_mask
611  OS.EmitIntValue(GPRInfoSet ? GPROffset : 0, 4); // reg_offset
612 
613  OS.EmitIntValue(FPRInfoSet ? FPRBitMask : 0, 4); // fpreg_mask
614  OS.EmitIntValue(FPRInfoSet ? FPROffset : 0, 4); // fpreg_offset
615 
616  OS.EmitIntValue(FrameInfoSet ? FrameOffset : 0, 4); // frame_offset
617  OS.EmitIntValue(FrameInfoSet ? FrameReg : 0, 4); // frame_reg
618  OS.EmitIntValue(FrameInfoSet ? ReturnReg : 0, 4); // return_reg
619 
620  // The .end directive marks the end of a procedure. Invalidate
621  // the information gathered up until this point.
622  GPRInfoSet = FPRInfoSet = FrameInfoSet = false;
623 
624  OS.PopSection();
625 }
626 
628  GPRInfoSet = FPRInfoSet = FrameInfoSet = false;
629 }
630 
633  unsigned Flags = MCA.getELFHeaderEFlags();
635  MCA.setELFHeaderEFlags(Flags);
636 }
637 
640  unsigned Flags = MCA.getELFHeaderEFlags();
641  Flags |= ELF::EF_MIPS_NAN2008;
642  MCA.setELFHeaderEFlags(Flags);
643 }
644 
647  unsigned Flags = MCA.getELFHeaderEFlags();
648  Flags &= ~ELF::EF_MIPS_NAN2008;
649  MCA.setELFHeaderEFlags(Flags);
650 }
651 
654  unsigned Flags = MCA.getELFHeaderEFlags();
655  // This option overrides other PIC options like -KPIC.
656  Pic = false;
657  Flags &= ~ELF::EF_MIPS_PIC;
658  MCA.setELFHeaderEFlags(Flags);
659 }
660 
663  unsigned Flags = MCA.getELFHeaderEFlags();
664  Pic = true;
665  // NOTE: We are following the GAS behaviour here which means the directive
666  // 'pic2' also sets the CPIC bit in the ELF header. This is different from
667  // what is stated in the SYSV ABI which consider the bits EF_MIPS_PIC and
668  // EF_MIPS_CPIC to be mutually exclusive.
670  MCA.setELFHeaderEFlags(Flags);
671 }
672 
675  MipsELFStreamer &MEF = static_cast<MipsELFStreamer &>(Streamer);
677 }
678 
679 void MipsTargetELFStreamer::emitFrame(unsigned StackReg, unsigned StackSize,
680  unsigned ReturnReg_) {
681  MCContext &Context = getStreamer().getAssembler().getContext();
682  const MCRegisterInfo *RegInfo = Context.getRegisterInfo();
683 
684  FrameInfoSet = true;
685  FrameReg = RegInfo->getEncodingValue(StackReg);
686  FrameOffset = StackSize;
687  ReturnReg = RegInfo->getEncodingValue(ReturnReg_);
688 }
689 
690 void MipsTargetELFStreamer::emitMask(unsigned CPUBitmask,
691  int CPUTopSavedRegOff) {
692  GPRInfoSet = true;
693  GPRBitMask = CPUBitmask;
694  GPROffset = CPUTopSavedRegOff;
695 }
696 
697 void MipsTargetELFStreamer::emitFMask(unsigned FPUBitmask,
698  int FPUTopSavedRegOff) {
699  FPRInfoSet = true;
700  FPRBitMask = FPUBitmask;
701  FPROffset = FPUTopSavedRegOff;
702 }
703 
705  // .cpload $reg
706  // This directive expands to:
707  // lui $gp, %hi(_gp_disp)
708  // addui $gp, $gp, %lo(_gp_disp)
709  // addu $gp, $gp, $reg
710  // when support for position independent code is enabled.
711  if (!Pic || (getABI().IsN32() || getABI().IsN64()))
712  return;
713 
714  // There's a GNU extension controlled by -mno-shared that allows
715  // locally-binding symbols to be accessed using absolute addresses.
716  // This is currently not supported. When supported -mno-shared makes
717  // .cpload expand to:
718  // lui $gp, %hi(__gnu_local_gp)
719  // addiu $gp, $gp, %lo(__gnu_local_gp)
720 
721  StringRef SymName("_gp_disp");
723  MCSymbol *GP_Disp = MCA.getContext().getOrCreateSymbol(SymName);
724  MCA.registerSymbol(*GP_Disp);
725 
726  MCInst TmpInst;
727  TmpInst.setOpcode(Mips::LUi);
728  TmpInst.addOperand(MCOperand::createReg(Mips::GP));
730  "_gp_disp", MCSymbolRefExpr::VK_Mips_ABS_HI, MCA.getContext());
731  TmpInst.addOperand(MCOperand::createExpr(HiSym));
732  getStreamer().EmitInstruction(TmpInst, STI);
733 
734  TmpInst.clear();
735 
736  TmpInst.setOpcode(Mips::ADDiu);
737  TmpInst.addOperand(MCOperand::createReg(Mips::GP));
738  TmpInst.addOperand(MCOperand::createReg(Mips::GP));
740  "_gp_disp", MCSymbolRefExpr::VK_Mips_ABS_LO, MCA.getContext());
741  TmpInst.addOperand(MCOperand::createExpr(LoSym));
742  getStreamer().EmitInstruction(TmpInst, STI);
743 
744  TmpInst.clear();
745 
746  TmpInst.setOpcode(Mips::ADDu);
747  TmpInst.addOperand(MCOperand::createReg(Mips::GP));
748  TmpInst.addOperand(MCOperand::createReg(Mips::GP));
749  TmpInst.addOperand(MCOperand::createReg(RegNo));
750  getStreamer().EmitInstruction(TmpInst, STI);
751 
753 }
754 
756  int RegOrOffset,
757  const MCSymbol &Sym,
758  bool IsReg) {
759  // Only N32 and N64 emit anything for .cpsetup iff PIC is set.
760  if (!Pic || !(getABI().IsN32() || getABI().IsN64()))
761  return;
762 
764  MCInst Inst;
765 
766  // Either store the old $gp in a register or on the stack
767  if (IsReg) {
768  // move $save, $gpreg
769  Inst.setOpcode(Mips::DADDu);
770  Inst.addOperand(MCOperand::createReg(RegOrOffset));
771  Inst.addOperand(MCOperand::createReg(Mips::GP));
772  Inst.addOperand(MCOperand::createReg(Mips::ZERO));
773  } else {
774  // sd $gpreg, offset($sp)
775  Inst.setOpcode(Mips::SD);
776  Inst.addOperand(MCOperand::createReg(Mips::GP));
777  Inst.addOperand(MCOperand::createReg(Mips::SP));
778  Inst.addOperand(MCOperand::createImm(RegOrOffset));
779  }
780  getStreamer().EmitInstruction(Inst, STI);
781  Inst.clear();
782 
787 
788  // lui $gp, %hi(%neg(%gp_rel(funcSym)))
789  Inst.setOpcode(Mips::LUi);
790  Inst.addOperand(MCOperand::createReg(Mips::GP));
791  Inst.addOperand(MCOperand::createExpr(HiExpr));
792  getStreamer().EmitInstruction(Inst, STI);
793  Inst.clear();
794 
795  // addiu $gp, $gp, %lo(%neg(%gp_rel(funcSym)))
796  Inst.setOpcode(Mips::ADDiu);
797  Inst.addOperand(MCOperand::createReg(Mips::GP));
798  Inst.addOperand(MCOperand::createReg(Mips::GP));
799  Inst.addOperand(MCOperand::createExpr(LoExpr));
800  getStreamer().EmitInstruction(Inst, STI);
801  Inst.clear();
802 
803  // daddu $gp, $gp, $funcreg
804  Inst.setOpcode(Mips::DADDu);
805  Inst.addOperand(MCOperand::createReg(Mips::GP));
806  Inst.addOperand(MCOperand::createReg(Mips::GP));
807  Inst.addOperand(MCOperand::createReg(RegNo));
808  getStreamer().EmitInstruction(Inst, STI);
809 
811 }
812 
815  MCContext &Context = MCA.getContext();
816  MCStreamer &OS = getStreamer();
817  MCSectionELF *Sec = Context.getELFSection(
818  ".MIPS.abiflags", ELF::SHT_MIPS_ABIFLAGS, ELF::SHF_ALLOC, 24, "");
819  MCA.registerSection(*Sec);
820  Sec->setAlignment(8);
821  OS.SwitchSection(Sec);
822 
823  OS << ABIFlagsSection;
824 }
void emitDirectiveEnd(StringRef Name) override
virtual void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff)
void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override
void setELFHeaderEFlags(unsigned Flags)
Definition: MCAssembler.h:701
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:48
void emitDirectiveModuleSoftFloat() override
void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, const MCSymbol &Sym, bool IsReg) override
void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff) override
virtual void emitDirectiveOptionPic2()
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:315
void clear()
Definition: MCInst.h:172
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
void emitDirectiveSetNoMicroMips() override
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
static MCOperand createExpr(const MCExpr *Val)
Definition: MCInst.h:129
MCSectionELF * getELFSection(StringRef Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:311
Target specific streamer interface.
Definition: MCStreamer.h:73
void setAlignment(unsigned Value)
Definition: MCSection.h:125
ExprKind getKind() const
Definition: MCExpr.h:69
const FeatureBitset Features
virtual void emitDirectiveSetNoReorder()
virtual void emitDirectiveModuleHardFloat()
void registerSymbol(const MCSymbol &Symbol, bool *Created=nullptr)
void PushSection()
Save the current and previous section on the section stack.
Definition: MCStreamer.h:301
MCSection * getDataSection() const
void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value) override
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, const SMLoc &Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
Definition: MCStreamer.cpp:682
bool registerSection(MCSection &Section)
Definition: MCAssembler.h:859
unsigned getELFHeaderEFlags() const
ELF e_header flags.
Definition: MCAssembler.h:700
unsigned getAlignment() const
Definition: MCSection.h:124
MCContext & getContext() const
Definition: MCAssembler.h:731
MipsTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS)
void emitDirectiveCpLoad(unsigned RegNo) override
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
virtual void emitDirectiveSetMips32R3()
virtual void emitDirectiveSetMicroMips()
virtual void emitDirectiveSetMips3()
void emitFrame(unsigned StackReg, unsigned StackSize, unsigned ReturnReg) override
static MCOperand createReg(unsigned Reg)
Definition: MCInst.h:111
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
virtual void emitFrame(unsigned StackReg, unsigned StackSize, unsigned ReturnReg)
virtual void emitDirectiveSetMips0()
virtual void emitDirectiveSetSoftFloat()
virtual void emitDirectiveSetNoMacro()
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:33
virtual void emitDirectiveEnd(StringRef Name)
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:159
virtual void emitDirectiveSetMips32R6()
#define false
Definition: ConvertUTF.c:65
void createPendingLabelRelocs()
Mark labels as microMIPS, if necessary for the subtarget.
void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override
virtual void emitDirectiveSetMips1()
virtual void emitDirectiveModuleOddSPReg()
Context object for machine code objects.
Definition: MCContext.h:48
virtual void emitDirectiveModuleSoftFloat()
MCSection * getBSSSection() const
MipsABIFlagsSection ABIFlagsSection
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
virtual void emitDirectiveModuleFP()
void emitLabel(MCSymbol *Symbol) override
virtual void emitDirectiveSetOddSPReg()
virtual void emitDirectiveSetMips64R2()
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...
Definition: MCStreamer.cpp:79
virtual void emitDirectiveSetNoOddSPReg()
void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, const MCSymbol &Sym, bool IsReg) override
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:150
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
#define true
Definition: ConvertUTF.c:66
Streaming machine code generation interface.
Definition: MCStreamer.h:157
virtual void emitDirectiveSetMips4()
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
virtual void emitDirectiveSetNoMicroMips()
virtual void emitDirectiveSetNoDsp()
StringRef getFpABIString(FpABIKind Value)
virtual void emitDirectiveSetMips16()
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
Definition: MCStreamer.cpp:701
MCAssembler & getAssembler()
virtual void emitDirectiveSetMacro()
virtual void emitDirectiveCpLoad(unsigned RegNo)
virtual void emitDirectiveSetArch(StringRef Arch)
virtual void emitMask(unsigned CPUBitmask, int CPUTopSavedRegOff)
MCSection * getTextSection() const
virtual void emitDirectiveSetMips32R5()
virtual void emitDirectiveSetMips32R2()
virtual void emitDirectiveSetFp(MipsABIFlagsSection::FpABIKind Value)
virtual void emitDirectiveAbiCalls()
void emitFMask(unsigned FPUBitmask, int FPUTopSavedRegOff) override
virtual void emitDirectiveSetMips64R6()
void emitDirectiveEnt(const MCSymbol &Symbol) override
void emitDirectiveEnt(const MCSymbol &Symbol) override
void setOpcode(unsigned Op)
Definition: MCInst.h:158
virtual void emitDirectiveOptionPic0()
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override
const MipsABIInfo & getABI() const
MCStreamer & Streamer
Definition: MCStreamer.h:75
virtual void emitDirectiveSetNoMips16()
void emitDirectiveSetNoOddSPReg() override
const FeatureBitset & getFeatureBits() const
getFeatureBits - Return the feature bits.
void emitDirectiveSetAtWithArg(unsigned RegNo) override
void emitDirectiveEnd(StringRef Name) override
MipsTargetELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
void EmitMipsOptionRecords()
Emits all the option records stored up until the point it's called.
virtual void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, const MCSymbol &Sym, bool IsReg)
virtual void emitDirectiveSetMips64R3()
virtual void emitDirectiveSetMips64R5()
const MCRegisterInfo * getRegisterInfo() const
Definition: MCContext.h:227
void emitDirectiveCpLoad(unsigned RegNo) override
virtual void emitDirectiveEnt(const MCSymbol &Symbol)
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:205
virtual void emitDirectiveSetHardFloat()
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:111
virtual void emitDirectiveSetMips64()
virtual void emitDirectiveSetMips5()
virtual void emitDirectiveSetMips2()
MCSubtargetInfo - Generic base class for all target subtargets.
MCSectionELF - This represents a section on linux, lots of unix variants and some bare metal systems...
Definition: MCSectionELF.h:30
References to labels and assigned expressions.
Definition: MCExpr.h:38
void emitDirectiveSetNoMicroMips() override
void emitFrame(unsigned StackReg, unsigned StackSize, unsigned ReturnReg) override
void emitDirectiveSetArch(StringRef Arch) override
void emitDirectiveModuleOddSPReg() override
Reloc::Model getRelocM() const
bool PopSection()
Restore the current and previous section from the section stack.
Definition: MCStreamer.h:310
virtual void emitDirectiveSetReorder()
static const char * getRegisterName(unsigned RegNo)
uint16_t getEncodingValue(unsigned RegNo) const
Returns the encoding for RegNo.
LLVM Value Representation.
Definition: Value.h:69
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:229
virtual void emitDirectiveNaNLegacy()
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
virtual void emitDirectiveSetMips32()
virtual void emitDirectiveSetNoMsa()
void addOperand(const MCOperand &Op)
Definition: MCInst.h:168
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
static void printHex32(unsigned Value, raw_ostream &OS)
virtual void emitDirectiveSetAtWithArg(unsigned RegNo)
static MCOperand createImm(int64_t Val)
Definition: MCInst.h:117
std::string lower() const
Definition: StringRef.cpp:117
void emitDirectiveModuleHardFloat() override