@@ -1153,19 +1153,18 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr *MI) {
1153
1153
// storage allocated in the TOC which contains the address of 'MOSymbol'.
1154
1154
// If the toc-data attribute is used, the TOC entry contains the data
1155
1155
// rather than the address of the MOSymbol.
1156
- auto isSymbolTD = [](const MachineOperand &MO) {
1157
- if (!MO.isGlobal ())
1158
- return false ;
1156
+ if (! [](const MachineOperand &MO) {
1157
+ if (!MO.isGlobal ())
1158
+ return false ;
1159
1159
1160
- const GlobalVariable *GV = dyn_cast<GlobalVariable>(MO.getGlobal ());
1161
- if (!GV)
1162
- return false ;
1160
+ const GlobalVariable *GV = dyn_cast<GlobalVariable>(MO.getGlobal ());
1161
+ if (!GV)
1162
+ return false ;
1163
1163
1164
- return GV->hasAttribute (" toc-data" );
1165
- };
1166
-
1167
- if (!isSymbolTD (MO))
1164
+ return GV->hasAttribute (" toc-data" );
1165
+ }(MO)) {
1168
1166
MOSymbol = lookUpOrCreateTOCEntry (MOSymbol, getTOCEntryTypeForMO (MO), VK);
1167
+ }
1169
1168
1170
1169
const MCExpr *Exp = MCSymbolRefExpr::create (
1171
1170
MOSymbol, MCSymbolRefExpr::VK_PPC_U, OutContext);
@@ -1285,49 +1284,33 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr *MI) {
1285
1284
EmitToStreamer (*OutStreamer, TmpInst);
1286
1285
return ;
1287
1286
}
1288
- case PPC::ADDItocL: {
1287
+ case PPC::ADDItocL:
1288
+ case PPC::ADDItocL8: {
1289
1289
// Transform %xd = ADDItocL %xs, @sym
1290
1290
LowerPPCMachineInstrToMCInst (MI, TmpInst, *this );
1291
1291
1292
- // Change the opcode to load address.
1293
- TmpInst.setOpcode (PPC::LA);
1292
+ unsigned Op = MI->getOpcode ();
1294
1293
1295
- const MachineOperand &MO = MI-> getOperand ( 2 );
1296
- assert (MO. isGlobal () && " Invalid operand for ADDItocL. " );
1294
+ // Change the opcode to load address for tocdata
1295
+ TmpInst. setOpcode (Op == PPC::ADDItocL8 ? PPC::ADDI8 : PPC::LA );
1297
1296
1298
- LLVM_DEBUG (assert (
1299
- !(MO.isGlobal () && Subtarget->isGVIndirectSymbol (MO.getGlobal ())) &&
1300
- " Interposable definitions must use indirect accesses." ));
1297
+ const MachineOperand &MO = MI->getOperand (2 );
1298
+ if (Op == PPC::ADDItocL8)
1299
+ assert ((MO.isGlobal () || MO.isCPI ()) && " Invalid operand for ADDItocL8." );
1300
+ else
1301
+ assert (MO.isGlobal () && " Invalid operand for ADDItocL." );
1302
+ assert (!(MO.isGlobal () && Subtarget->isGVIndirectSymbol (MO.getGlobal ())) &&
1303
+ " Interposable definitions must use indirect accesses." );
1301
1304
1302
1305
// Map the operand to its corresponding MCSymbol.
1303
1306
const MCSymbol *const MOSymbol = getMCSymbolForTOCPseudoMO (MO, *this );
1304
1307
1305
1308
const MCExpr *Exp = MCSymbolRefExpr::create (
1306
- MOSymbol, MCSymbolRefExpr::VK_PPC_L, OutContext);
1307
-
1308
- TmpInst.getOperand (2 ) = MCOperand::createExpr (Exp);
1309
- EmitToStreamer (*OutStreamer, TmpInst);
1310
- return ;
1311
- }
1312
- case PPC::ADDItocL8: {
1313
- // Transform %xd = ADDItocL8 %xs, @sym
1314
- LowerPPCMachineInstrToMCInst (MI, TmpInst, *this );
1315
-
1316
- // Change the opcode to ADDI8. If the global address is external, then
1317
- // generate a TOC entry and reference that. Otherwise, reference the
1318
- // symbol directly.
1319
- TmpInst.setOpcode (PPC::ADDI8);
1320
-
1321
- const MachineOperand &MO = MI->getOperand (2 );
1322
- assert ((MO.isGlobal () || MO.isCPI ()) && " Invalid operand for ADDItocL8." );
1323
-
1324
- LLVM_DEBUG (assert (
1325
- !(MO.isGlobal () && Subtarget->isGVIndirectSymbol (MO.getGlobal ())) &&
1326
- " Interposable definitions must use indirect accesses." ));
1309
+ MOSymbol,
1310
+ Op == PPC::ADDItocL8 ? MCSymbolRefExpr::VK_PPC_TOC_LO
1311
+ : MCSymbolRefExpr::VK_PPC_L,
1312
+ OutContext);
1327
1313
1328
- const MCExpr *Exp =
1329
- MCSymbolRefExpr::create (getMCSymbolForTOCPseudoMO (MO, *this ),
1330
- MCSymbolRefExpr::VK_PPC_TOC_LO, OutContext);
1331
1314
TmpInst.getOperand (2 ) = MCOperand::createExpr (Exp);
1332
1315
EmitToStreamer (*OutStreamer, TmpInst);
1333
1316
return ;
0 commit comments