mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-11-03 14:21:30 +00:00 
			
		
		
		
	Remove the MCInstrInfo cached variable as it was only used in a
single place and replace calls to getSubtargetImpl with calls to get the subtarget from the MachineFunction where valid. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229971 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		@@ -46,7 +46,6 @@ class MCCFIInstruction;
 | 
				
			|||||||
class MCContext;
 | 
					class MCContext;
 | 
				
			||||||
class MCExpr;
 | 
					class MCExpr;
 | 
				
			||||||
class MCInst;
 | 
					class MCInst;
 | 
				
			||||||
class MCInstrInfo;
 | 
					 | 
				
			||||||
class MCSection;
 | 
					class MCSection;
 | 
				
			||||||
class MCStreamer;
 | 
					class MCStreamer;
 | 
				
			||||||
class MCSubtargetInfo;
 | 
					class MCSubtargetInfo;
 | 
				
			||||||
@@ -69,7 +68,6 @@ public:
 | 
				
			|||||||
  ///
 | 
					  ///
 | 
				
			||||||
  const MCAsmInfo *MAI;
 | 
					  const MCAsmInfo *MAI;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const MCInstrInfo *MII;
 | 
					 | 
				
			||||||
  /// This is the context for the output file that we are streaming. This owns
 | 
					  /// This is the context for the output file that we are streaming. This owns
 | 
				
			||||||
  /// all of the global MC-related objects for the generated translation unit.
 | 
					  /// all of the global MC-related objects for the generated translation unit.
 | 
				
			||||||
  MCContext &OutContext;
 | 
					  MCContext &OutContext;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -102,7 +102,6 @@ AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer)
 | 
				
			|||||||
    : MachineFunctionPass(ID), TM(tm), MAI(tm.getMCAsmInfo()),
 | 
					    : MachineFunctionPass(ID), TM(tm), MAI(tm.getMCAsmInfo()),
 | 
				
			||||||
      OutContext(Streamer->getContext()), OutStreamer(*Streamer.release()),
 | 
					      OutContext(Streamer->getContext()), OutStreamer(*Streamer.release()),
 | 
				
			||||||
      LastMI(nullptr), LastFn(0), Counter(~0U), SetCounter(0) {
 | 
					      LastMI(nullptr), LastFn(0), Counter(~0U), SetCounter(0) {
 | 
				
			||||||
  MII = nullptr;
 | 
					 | 
				
			||||||
  DD = nullptr;
 | 
					  DD = nullptr;
 | 
				
			||||||
  MMI = nullptr;
 | 
					  MMI = nullptr;
 | 
				
			||||||
  LI = nullptr;
 | 
					  LI = nullptr;
 | 
				
			||||||
@@ -578,7 +577,7 @@ void AsmPrinter::EmitFunctionEntryLabel() {
 | 
				
			|||||||
/// emitComments - Pretty-print comments for instructions.
 | 
					/// emitComments - Pretty-print comments for instructions.
 | 
				
			||||||
static void emitComments(const MachineInstr &MI, raw_ostream &CommentOS) {
 | 
					static void emitComments(const MachineInstr &MI, raw_ostream &CommentOS) {
 | 
				
			||||||
  const MachineFunction *MF = MI.getParent()->getParent();
 | 
					  const MachineFunction *MF = MI.getParent()->getParent();
 | 
				
			||||||
  const TargetMachine &TM = MF->getTarget();
 | 
					  const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Check for spills and reloads
 | 
					  // Check for spills and reloads
 | 
				
			||||||
  int FI;
 | 
					  int FI;
 | 
				
			||||||
@@ -588,24 +587,20 @@ static void emitComments(const MachineInstr &MI, raw_ostream &CommentOS) {
 | 
				
			|||||||
  // We assume a single instruction only has a spill or reload, not
 | 
					  // We assume a single instruction only has a spill or reload, not
 | 
				
			||||||
  // both.
 | 
					  // both.
 | 
				
			||||||
  const MachineMemOperand *MMO;
 | 
					  const MachineMemOperand *MMO;
 | 
				
			||||||
  if (TM.getSubtargetImpl()->getInstrInfo()->isLoadFromStackSlotPostFE(&MI,
 | 
					  if (TII->isLoadFromStackSlotPostFE(&MI, FI)) {
 | 
				
			||||||
                                                                       FI)) {
 | 
					 | 
				
			||||||
    if (FrameInfo->isSpillSlotObjectIndex(FI)) {
 | 
					    if (FrameInfo->isSpillSlotObjectIndex(FI)) {
 | 
				
			||||||
      MMO = *MI.memoperands_begin();
 | 
					      MMO = *MI.memoperands_begin();
 | 
				
			||||||
      CommentOS << MMO->getSize() << "-byte Reload\n";
 | 
					      CommentOS << MMO->getSize() << "-byte Reload\n";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  } else if (TM.getSubtargetImpl()->getInstrInfo()->hasLoadFromStackSlot(
 | 
					  } else if (TII->hasLoadFromStackSlot(&MI, MMO, FI)) {
 | 
				
			||||||
                 &MI, MMO, FI)) {
 | 
					 | 
				
			||||||
    if (FrameInfo->isSpillSlotObjectIndex(FI))
 | 
					    if (FrameInfo->isSpillSlotObjectIndex(FI))
 | 
				
			||||||
      CommentOS << MMO->getSize() << "-byte Folded Reload\n";
 | 
					      CommentOS << MMO->getSize() << "-byte Folded Reload\n";
 | 
				
			||||||
  } else if (TM.getSubtargetImpl()->getInstrInfo()->isStoreToStackSlotPostFE(
 | 
					  } else if (TII->isStoreToStackSlotPostFE(&MI, FI)) {
 | 
				
			||||||
                 &MI, FI)) {
 | 
					 | 
				
			||||||
    if (FrameInfo->isSpillSlotObjectIndex(FI)) {
 | 
					    if (FrameInfo->isSpillSlotObjectIndex(FI)) {
 | 
				
			||||||
      MMO = *MI.memoperands_begin();
 | 
					      MMO = *MI.memoperands_begin();
 | 
				
			||||||
      CommentOS << MMO->getSize() << "-byte Spill\n";
 | 
					      CommentOS << MMO->getSize() << "-byte Spill\n";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  } else if (TM.getSubtargetImpl()->getInstrInfo()->hasStoreToStackSlot(
 | 
					  } else if (TII->hasStoreToStackSlot(&MI, MMO, FI)) {
 | 
				
			||||||
                 &MI, MMO, FI)) {
 | 
					 | 
				
			||||||
    if (FrameInfo->isSpillSlotObjectIndex(FI))
 | 
					    if (FrameInfo->isSpillSlotObjectIndex(FI))
 | 
				
			||||||
      CommentOS << MMO->getSize() << "-byte Folded Spill\n";
 | 
					      CommentOS << MMO->getSize() << "-byte Folded Spill\n";
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -843,7 +838,7 @@ void AsmPrinter::EmitFunctionBody() {
 | 
				
			|||||||
  // labels from collapsing together.  Just emit a noop.
 | 
					  // labels from collapsing together.  Just emit a noop.
 | 
				
			||||||
  if ((MAI->hasSubsectionsViaSymbols() && !HasAnyRealCode)) {
 | 
					  if ((MAI->hasSubsectionsViaSymbols() && !HasAnyRealCode)) {
 | 
				
			||||||
    MCInst Noop;
 | 
					    MCInst Noop;
 | 
				
			||||||
    TM.getSubtargetImpl()->getInstrInfo()->getNoopForMachoTarget(Noop);
 | 
					    MF->getSubtarget().getInstrInfo()->getNoopForMachoTarget(Noop);
 | 
				
			||||||
    OutStreamer.AddComment("avoids zero-length function");
 | 
					    OutStreamer.AddComment("avoids zero-length function");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Targets can opt-out of emitting the noop here by leaving the opcode
 | 
					    // Targets can opt-out of emitting the noop here by leaving the opcode
 | 
				
			||||||
@@ -1065,7 +1060,6 @@ bool AsmPrinter::doFinalization(Module &M) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
 | 
					void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
 | 
				
			||||||
  this->MF = &MF;
 | 
					  this->MF = &MF;
 | 
				
			||||||
  MII = MF.getSubtarget().getInstrInfo();
 | 
					 | 
				
			||||||
  // Get the function symbol.
 | 
					  // Get the function symbol.
 | 
				
			||||||
  CurrentFnSym = getSymbol(MF.getFunction());
 | 
					  CurrentFnSym = getSymbol(MF.getFunction());
 | 
				
			||||||
  CurrentFnSymForSize = CurrentFnSym;
 | 
					  CurrentFnSymForSize = CurrentFnSym;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,6 +32,7 @@
 | 
				
			|||||||
#include "llvm/Support/SourceMgr.h"
 | 
					#include "llvm/Support/SourceMgr.h"
 | 
				
			||||||
#include "llvm/Support/TargetRegistry.h"
 | 
					#include "llvm/Support/TargetRegistry.h"
 | 
				
			||||||
#include "llvm/Support/raw_ostream.h"
 | 
					#include "llvm/Support/raw_ostream.h"
 | 
				
			||||||
 | 
					#include "llvm/Target/TargetInstrInfo.h"
 | 
				
			||||||
#include "llvm/Target/TargetMachine.h"
 | 
					#include "llvm/Target/TargetMachine.h"
 | 
				
			||||||
#include "llvm/Target/TargetRegisterInfo.h"
 | 
					#include "llvm/Target/TargetRegisterInfo.h"
 | 
				
			||||||
#include "llvm/Target/TargetSubtargetInfo.h"
 | 
					#include "llvm/Target/TargetSubtargetInfo.h"
 | 
				
			||||||
@@ -151,10 +152,13 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode,
 | 
				
			|||||||
  // We may create a new MCInstrInfo here since we might be at the module level
 | 
					  // We may create a new MCInstrInfo here since we might be at the module level
 | 
				
			||||||
  // and not have a MachineFunction to initialize the TargetInstrInfo from and
 | 
					  // and not have a MachineFunction to initialize the TargetInstrInfo from and
 | 
				
			||||||
  // we only need MCInstrInfo for asm parsing.
 | 
					  // we only need MCInstrInfo for asm parsing.
 | 
				
			||||||
 | 
					  const MCInstrInfo *MII = MF
 | 
				
			||||||
 | 
					                               ? MII = static_cast<const MCInstrInfo *>(
 | 
				
			||||||
 | 
					                                     MF->getSubtarget().getInstrInfo())
 | 
				
			||||||
 | 
					                               : MII = static_cast<const MCInstrInfo *>(
 | 
				
			||||||
 | 
					                                     TM.getTarget().createMCInstrInfo());
 | 
				
			||||||
  std::unique_ptr<MCTargetAsmParser> TAP(TM.getTarget().createMCAsmParser(
 | 
					  std::unique_ptr<MCTargetAsmParser> TAP(TM.getTarget().createMCAsmParser(
 | 
				
			||||||
      *STI, *Parser, MII ? *MII : *static_cast<const MCInstrInfo *>(
 | 
					      *STI, *Parser, *MII, TM.Options.MCOptions));
 | 
				
			||||||
                                      TM.getTarget().createMCInstrInfo()),
 | 
					 | 
				
			||||||
      TM.Options.MCOptions));
 | 
					 | 
				
			||||||
  if (!TAP)
 | 
					  if (!TAP)
 | 
				
			||||||
    report_fatal_error("Inline asm not supported by this streamer because"
 | 
					    report_fatal_error("Inline asm not supported by this streamer because"
 | 
				
			||||||
                       " we don't have an asm parser for this target\n");
 | 
					                       " we don't have an asm parser for this target\n");
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user