@@ -51,8 +51,8 @@ using namespace llvm;
5151
5252ARMAsmPrinter::ARMAsmPrinter (TargetMachine &TM,
5353 std::unique_ptr<MCStreamer> Streamer)
54- : AsmPrinter(TM, std::move(Streamer), ID), Subtarget (nullptr ), AFI (nullptr ),
55- MCP( nullptr ), InConstantPool(false ), OptimizationGoals(-1 ) {}
54+ : AsmPrinter(TM, std::move(Streamer), ID), AFI (nullptr ), MCP (nullptr ),
55+ InConstantPool(false ), OptimizationGoals(-1 ) {}
5656
5757const ARMBaseTargetMachine &ARMAsmPrinter::getTM () const {
5858 return static_cast <const ARMBaseTargetMachine &>(TM);
@@ -116,7 +116,6 @@ void ARMAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
116116bool ARMAsmPrinter::runOnMachineFunction (MachineFunction &MF) {
117117 AFI = MF.getInfo <ARMFunctionInfo>();
118118 MCP = MF.getConstantPool ();
119- Subtarget = &MF.getSubtarget <ARMSubtarget>();
120119
121120 SetupMachineFunction (MF);
122121 const Function &F = MF.getFunction ();
@@ -154,7 +153,7 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
154153 else if (OptimizationGoals != (int )OptimizationGoal) // conflicting goals
155154 OptimizationGoals = 0 ;
156155
157- if (Subtarget-> isTargetCOFF ()) {
156+ if (TM. getTargetTriple (). isOSBinFormatCOFF ()) {
158157 bool Local = F.hasLocalLinkage ();
159158 COFF::SymbolStorageClass Scl =
160159 Local ? COFF::IMAGE_SYM_CLASS_STATIC : COFF::IMAGE_SYM_CLASS_EXTERNAL;
@@ -260,8 +259,8 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
260259 break ;
261260 }
262261 case MachineOperand::MO_ConstantPoolIndex:
263- if (Subtarget-> genExecuteOnly ())
264- llvm_unreachable ( " execute-only should not generate constant pools" );
262+ assert (!MF-> getSubtarget <ARMSubtarget>(). genExecuteOnly () &&
263+ " execute-only should not generate constant pools" );
265264 GetCPISymbol (MO.getIndex ())->print (O, MAI);
266265 break ;
267266 }
@@ -1048,7 +1047,8 @@ void ARMAsmPrinter::emitJumpTableAddrs(const MachineInstr *MI) {
10481047 // .word (LBB1 - LJTI_0_0)
10491048 const MCExpr *Expr = MCSymbolRefExpr::create (MBB->getSymbol (), OutContext);
10501049
1051- if (isPositionIndependent () || Subtarget->isROPI ())
1050+ const ARMSubtarget &STI = MF->getSubtarget <ARMSubtarget>();
1051+ if (isPositionIndependent () || STI.isROPI ())
10521052 Expr = MCBinaryExpr::createSub (Expr, MCSymbolRefExpr::create (JTISymbol,
10531053 OutContext),
10541054 OutContext);
@@ -1097,7 +1097,8 @@ void ARMAsmPrinter::emitJumpTableTBInst(const MachineInstr *MI,
10971097 const MachineOperand &MO1 = MI->getOperand (1 );
10981098 unsigned JTI = MO1.getIndex ();
10991099
1100- if (Subtarget->isThumb1Only ())
1100+ const ARMSubtarget &STI = MF->getSubtarget <ARMSubtarget>();
1101+ if (STI.isThumb1Only ())
11011102 emitAlignment (Align (4 ));
11021103
11031104 MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel (JTI);
@@ -1905,6 +1906,7 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
19051906 ARM_MC::verifyInstructionPredicates (MI->getOpcode (),
19061907 getSubtargetInfo ().getFeatureBits ());
19071908
1909+ const ARMSubtarget &STI = MF->getSubtarget <ARMSubtarget>();
19081910 const DataLayout &DL = getDataLayout ();
19091911 MCTargetStreamer &TS = *OutStreamer->getTargetStreamer ();
19101912 ARMTargetStreamer &ATS = static_cast <ARMTargetStreamer &>(TS);
@@ -1916,8 +1918,8 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
19161918 }
19171919
19181920 // Emit unwinding stuff for frame-related instructions
1919- if (Subtarget-> isTargetEHABICompatible () &&
1920- MI->getFlag (MachineInstr::FrameSetup))
1921+ if (TM. getTargetTriple (). isTargetEHABICompatible () &&
1922+ MI->getFlag (MachineInstr::FrameSetup))
19211923 EmitUnwindingInstruction (MI);
19221924
19231925 // Do any auto-generated pseudo lowerings.
@@ -1983,14 +1985,13 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
19831985 // Add 's' bit operand (always reg0 for this)
19841986 .addReg (0 ));
19851987
1986- assert (Subtarget-> hasV4TOps ());
1987- EmitToStreamer (*OutStreamer, MCInstBuilder (ARM::BX)
1988- .addReg (MI->getOperand (0 ).getReg ()));
1988+ assert (STI. hasV4TOps () && " Expected V4TOps for BX call " );
1989+ EmitToStreamer (*OutStreamer,
1990+ MCInstBuilder (ARM::BX) .addReg (MI->getOperand (0 ).getReg ()));
19891991 return ;
19901992 }
19911993 case ARM::tBX_CALL: {
1992- if (Subtarget->hasV5TOps ())
1993- llvm_unreachable (" Expected BLX to be selected for v5t+" );
1994+ assert (!STI.hasV5TOps () && " Expected BLX to be selected for v5t+" );
19941995
19951996 // On ARM v4t, when doing a call from thumb mode, we need to ensure
19961997 // that the saved lr has its LSB set correctly (the arch doesn't
@@ -2279,8 +2280,8 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
22792280 return ;
22802281 }
22812282 case ARM::CONSTPOOL_ENTRY: {
2282- if (Subtarget-> genExecuteOnly ())
2283- llvm_unreachable ( " execute-only should not generate constant pools" );
2283+ assert (!STI. genExecuteOnly () &&
2284+ " execute-only should not generate constant pools" );
22842285
22852286 // / CONSTPOOL_ENTRY - This instruction represents a floating constant pool
22862287 // / in the function. The first operand is the ID# for this instruction, the
@@ -2486,7 +2487,7 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
24862487 case ARM::TRAP: {
24872488 // Non-Darwin binutils don't yet support the "trap" mnemonic.
24882489 // FIXME: Remove this special case when they do.
2489- if (!Subtarget-> isTargetMachO ()) {
2490+ if (!TM. getTargetTriple (). isOSBinFormatMachO ()) {
24902491 uint32_t Val = 0xe7ffdefeUL ;
24912492 OutStreamer->AddComment (" trap" );
24922493 ATS.emitInst (Val);
@@ -2497,7 +2498,7 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
24972498 case ARM::tTRAP: {
24982499 // Non-Darwin binutils don't yet support the "trap" mnemonic.
24992500 // FIXME: Remove this special case when they do.
2500- if (!Subtarget-> isTargetMachO ()) {
2501+ if (!TM. getTargetTriple (). isOSBinFormatMachO ()) {
25012502 uint16_t Val = 0xdefe ;
25022503 OutStreamer->AddComment (" trap" );
25032504 ATS.emitInst (Val, ' n' );
@@ -2657,9 +2658,6 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
26572658 .addImm (ARMCC::AL)
26582659 .addReg (0 ));
26592660
2660- const MachineFunction &MF = *MI->getParent ()->getParent ();
2661- const ARMSubtarget &STI = MF.getSubtarget <ARMSubtarget>();
2662-
26632661 if (STI.isTargetDarwin () || STI.isTargetWindows ()) {
26642662 // These platforms always use the same frame register
26652663 EmitToStreamer (*OutStreamer, MCInstBuilder (ARM::LDRi12)
@@ -2688,7 +2686,7 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
26882686 .addReg (0 ));
26892687 }
26902688
2691- assert (Subtarget-> hasV4TOps ());
2689+ assert (STI. hasV4TOps ());
26922690 EmitToStreamer (*OutStreamer, MCInstBuilder (ARM::BX)
26932691 .addReg (ScratchReg)
26942692 // Predicate.
@@ -2705,9 +2703,6 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
27052703 Register SrcReg = MI->getOperand (0 ).getReg ();
27062704 Register ScratchReg = MI->getOperand (1 ).getReg ();
27072705
2708- const MachineFunction &MF = *MI->getParent ()->getParent ();
2709- const ARMSubtarget &STI = MF.getSubtarget <ARMSubtarget>();
2710-
27112706 EmitToStreamer (*OutStreamer, MCInstBuilder (ARM::tLDRi)
27122707 .addReg (ScratchReg)
27132708 .addReg (SrcReg)
0 commit comments