@@ -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 }
@@ -680,14 +679,14 @@ void ARMAsmPrinter::emitAttributes() {
680679 if (isPositionIndependent ()) {
681680 ATS.emitAttribute (ARMBuildAttrs::ABI_PCS_RW_data,
682681 ARMBuildAttrs::AddressRWPCRel);
683- } else if (STI .isRWPI ()) {
682+ } else if (getTM () .isRWPI ()) {
684683 // RWPI specific attributes.
685684 ATS.emitAttribute (ARMBuildAttrs::ABI_PCS_RW_data,
686685 ARMBuildAttrs::AddressRWSBRel);
687686 }
688687
689688 // RO data addressing.
690- if (isPositionIndependent () || STI .isROPI ()) {
689+ if (isPositionIndependent () || getTM () .isROPI ()) {
691690 ATS.emitAttribute (ARMBuildAttrs::ABI_PCS_RO_data,
692691 ARMBuildAttrs::AddressROPCRel);
693692 }
@@ -833,7 +832,7 @@ void ARMAsmPrinter::emitAttributes() {
833832 }
834833
835834 // We currently do not support using R9 as the TLS pointer.
836- if (STI .isRWPI ())
835+ if (getTM () .isRWPI ())
837836 ATS.emitAttribute (ARMBuildAttrs::ABI_PCS_R9_use,
838837 ARMBuildAttrs::R9IsSB);
839838 else if (STI.isR9Reserved ())
@@ -1048,7 +1047,7 @@ 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+ if (isPositionIndependent () || getTM (). isROPI ())
10521051 Expr = MCBinaryExpr::createSub (Expr, MCSymbolRefExpr::create (JTISymbol,
10531052 OutContext),
10541053 OutContext);
@@ -1097,7 +1096,8 @@ void ARMAsmPrinter::emitJumpTableTBInst(const MachineInstr *MI,
10971096 const MachineOperand &MO1 = MI->getOperand (1 );
10981097 unsigned JTI = MO1.getIndex ();
10991098
1100- if (Subtarget->isThumb1Only ())
1099+ const ARMSubtarget &STI = MF->getSubtarget <ARMSubtarget>();
1100+ if (STI.isThumb1Only ())
11011101 emitAlignment (Align (4 ));
11021102
11031103 MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel (JTI);
@@ -1905,6 +1905,7 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
19051905 ARM_MC::verifyInstructionPredicates (MI->getOpcode (),
19061906 getSubtargetInfo ().getFeatureBits ());
19071907
1908+ const ARMSubtarget &STI = MF->getSubtarget <ARMSubtarget>();
19081909 const DataLayout &DL = getDataLayout ();
19091910 MCTargetStreamer &TS = *OutStreamer->getTargetStreamer ();
19101911 ARMTargetStreamer &ATS = static_cast <ARMTargetStreamer &>(TS);
@@ -1916,8 +1917,8 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
19161917 }
19171918
19181919 // Emit unwinding stuff for frame-related instructions
1919- if (Subtarget-> isTargetEHABICompatible () &&
1920- MI->getFlag (MachineInstr::FrameSetup))
1920+ if (TM. getTargetTriple (). isTargetEHABICompatible () &&
1921+ MI->getFlag (MachineInstr::FrameSetup))
19211922 EmitUnwindingInstruction (MI);
19221923
19231924 // Do any auto-generated pseudo lowerings.
@@ -1983,14 +1984,13 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
19831984 // Add 's' bit operand (always reg0 for this)
19841985 .addReg (0 ));
19851986
1986- assert (Subtarget-> hasV4TOps ());
1987- EmitToStreamer (*OutStreamer, MCInstBuilder (ARM::BX)
1988- .addReg (MI->getOperand (0 ).getReg ()));
1987+ assert (STI. hasV4TOps () && " Expected V4TOps for BX call " );
1988+ EmitToStreamer (*OutStreamer,
1989+ MCInstBuilder (ARM::BX) .addReg (MI->getOperand (0 ).getReg ()));
19891990 return ;
19901991 }
19911992 case ARM::tBX_CALL: {
1992- if (Subtarget->hasV5TOps ())
1993- llvm_unreachable (" Expected BLX to be selected for v5t+" );
1993+ assert (!STI.hasV5TOps () && " Expected BLX to be selected for v5t+" );
19941994
19951995 // On ARM v4t, when doing a call from thumb mode, we need to ensure
19961996 // that the saved lr has its LSB set correctly (the arch doesn't
@@ -2279,8 +2279,8 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
22792279 return ;
22802280 }
22812281 case ARM::CONSTPOOL_ENTRY: {
2282- if (Subtarget-> genExecuteOnly ())
2283- llvm_unreachable ( " execute-only should not generate constant pools" );
2282+ assert (!STI. genExecuteOnly () &&
2283+ " execute-only should not generate constant pools" );
22842284
22852285 // / CONSTPOOL_ENTRY - This instruction represents a floating constant pool
22862286 // / in the function. The first operand is the ID# for this instruction, the
@@ -2486,7 +2486,7 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
24862486 case ARM::TRAP: {
24872487 // Non-Darwin binutils don't yet support the "trap" mnemonic.
24882488 // FIXME: Remove this special case when they do.
2489- if (!Subtarget-> isTargetMachO ()) {
2489+ if (!TM. getTargetTriple (). isOSBinFormatMachO ()) {
24902490 uint32_t Val = 0xe7ffdefeUL ;
24912491 OutStreamer->AddComment (" trap" );
24922492 ATS.emitInst (Val);
@@ -2497,7 +2497,7 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
24972497 case ARM::tTRAP: {
24982498 // Non-Darwin binutils don't yet support the "trap" mnemonic.
24992499 // FIXME: Remove this special case when they do.
2500- if (!Subtarget-> isTargetMachO ()) {
2500+ if (!TM. getTargetTriple (). isOSBinFormatMachO ()) {
25012501 uint16_t Val = 0xdefe ;
25022502 OutStreamer->AddComment (" trap" );
25032503 ATS.emitInst (Val, ' n' );
@@ -2657,9 +2657,6 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
26572657 .addImm (ARMCC::AL)
26582658 .addReg (0 ));
26592659
2660- const MachineFunction &MF = *MI->getParent ()->getParent ();
2661- const ARMSubtarget &STI = MF.getSubtarget <ARMSubtarget>();
2662-
26632660 if (STI.isTargetDarwin () || STI.isTargetWindows ()) {
26642661 // These platforms always use the same frame register
26652662 EmitToStreamer (*OutStreamer, MCInstBuilder (ARM::LDRi12)
@@ -2688,7 +2685,7 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
26882685 .addReg (0 ));
26892686 }
26902687
2691- assert (Subtarget-> hasV4TOps ());
2688+ assert (STI. hasV4TOps ());
26922689 EmitToStreamer (*OutStreamer, MCInstBuilder (ARM::BX)
26932690 .addReg (ScratchReg)
26942691 // Predicate.
@@ -2705,9 +2702,6 @@ void ARMAsmPrinter::emitInstruction(const MachineInstr *MI) {
27052702 Register SrcReg = MI->getOperand (0 ).getReg ();
27062703 Register ScratchReg = MI->getOperand (1 ).getReg ();
27072704
2708- const MachineFunction &MF = *MI->getParent ()->getParent ();
2709- const ARMSubtarget &STI = MF.getSubtarget <ARMSubtarget>();
2710-
27112705 EmitToStreamer (*OutStreamer, MCInstBuilder (ARM::tLDRi)
27122706 .addReg (ScratchReg)
27132707 .addReg (SrcReg)
0 commit comments