@@ -67,8 +67,8 @@ class X86MCInstLower {
67
67
public:
68
68
X86MCInstLower (const MachineFunction &MF, X86AsmPrinter &asmprinter);
69
69
70
- std::optional< MCOperand> LowerMachineOperand (const MachineInstr *MI,
71
- const MachineOperand &MO) const ;
70
+ MCOperand LowerMachineOperand (const MachineInstr *MI,
71
+ const MachineOperand &MO) const ;
72
72
void Lower (const MachineInstr *MI, MCInst &OutMI) const ;
73
73
74
74
MCSymbol *GetSymbolFromOperand (const MachineOperand &MO) const ;
@@ -326,17 +326,16 @@ static unsigned getRetOpcode(const X86Subtarget &Subtarget) {
326
326
return Subtarget.is64Bit () ? X86::RET64 : X86::RET32;
327
327
}
328
328
329
- std::optional<MCOperand>
330
- X86MCInstLower::LowerMachineOperand (const MachineInstr *MI,
331
- const MachineOperand &MO) const {
329
+ MCOperand X86MCInstLower::LowerMachineOperand (const MachineInstr *MI,
330
+ const MachineOperand &MO) const {
332
331
switch (MO.getType ()) {
333
332
default :
334
333
MI->print (errs ());
335
334
llvm_unreachable (" unknown operand type" );
336
335
case MachineOperand::MO_Register:
337
336
// Ignore all implicit register operands.
338
337
if (MO.isImplicit ())
339
- return std::nullopt ;
338
+ return MCOperand () ;
340
339
return MCOperand::createReg (MO.getReg ());
341
340
case MachineOperand::MO_Immediate:
342
341
return MCOperand::createImm (MO.getImm ());
@@ -355,7 +354,7 @@ X86MCInstLower::LowerMachineOperand(const MachineInstr *MI,
355
354
MO, AsmPrinter.GetBlockAddressSymbol (MO.getBlockAddress ()));
356
355
case MachineOperand::MO_RegisterMask:
357
356
// Ignore call clobbers.
358
- return std::nullopt ;
357
+ return MCOperand () ;
359
358
}
360
359
}
361
360
@@ -398,8 +397,8 @@ void X86MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
398
397
OutMI.setOpcode (MI->getOpcode ());
399
398
400
399
for (const MachineOperand &MO : MI->operands ())
401
- if (auto MaybeMCOp = LowerMachineOperand (MI, MO))
402
- OutMI.addOperand (*MaybeMCOp );
400
+ if (auto Op = LowerMachineOperand (MI, MO); Op. isValid ( ))
401
+ OutMI.addOperand (Op );
403
402
404
403
bool In64BitMode = AsmPrinter.getSubtarget ().is64Bit ();
405
404
if (X86::optimizeInstFromVEX3ToVEX2 (OutMI, MI->getDesc ()) ||
@@ -867,8 +866,8 @@ void X86AsmPrinter::LowerFAULTING_OP(const MachineInstr &FaultingMI,
867
866
868
867
for (const MachineOperand &MO :
869
868
llvm::drop_begin (FaultingMI.operands (), OperandsBeginIdx))
870
- if (auto MaybeOperand = MCIL.LowerMachineOperand (&FaultingMI, MO))
871
- MI.addOperand (*MaybeOperand );
869
+ if (auto Op = MCIL.LowerMachineOperand (&FaultingMI, MO); Op. isValid ( ))
870
+ MI.addOperand (Op );
872
871
873
872
OutStreamer->AddComment (" on-fault: " + HandlerLabel->getName ());
874
873
OutStreamer->emitInstruction (MI, getSubtargetInfo ());
@@ -1139,9 +1138,10 @@ void X86AsmPrinter::LowerPATCHABLE_EVENT_CALL(const MachineInstr &MI,
1139
1138
// emit nops appropriately sized to keep the sled the same size in every
1140
1139
// situation.
1141
1140
for (unsigned I = 0 ; I < MI.getNumOperands (); ++I)
1142
- if (auto Op = MCIL.LowerMachineOperand (&MI, MI.getOperand (I))) {
1143
- assert (Op->isReg () && " Only support arguments in registers" );
1144
- SrcRegs[I] = getX86SubSuperRegister (Op->getReg (), 64 );
1141
+ if (auto Op = MCIL.LowerMachineOperand (&MI, MI.getOperand (I));
1142
+ Op.isValid ()) {
1143
+ assert (Op.isReg () && " Only support arguments in registers" );
1144
+ SrcRegs[I] = getX86SubSuperRegister (Op.getReg (), 64 );
1145
1145
assert (SrcRegs[I].isValid () && " Invalid operand" );
1146
1146
if (SrcRegs[I] != DestRegs[I]) {
1147
1147
UsedMask[I] = true ;
@@ -1237,10 +1237,11 @@ void X86AsmPrinter::LowerPATCHABLE_TYPED_EVENT_CALL(const MachineInstr &MI,
1237
1237
// In case the arguments are already in the correct register, we emit nops
1238
1238
// appropriately sized to keep the sled the same size in every situation.
1239
1239
for (unsigned I = 0 ; I < MI.getNumOperands (); ++I)
1240
- if (auto Op = MCIL.LowerMachineOperand (&MI, MI.getOperand (I))) {
1240
+ if (auto Op = MCIL.LowerMachineOperand (&MI, MI.getOperand (I));
1241
+ Op.isValid ()) {
1241
1242
// TODO: Is register only support adequate?
1242
- assert (Op-> isReg () && " Only supports arguments in registers" );
1243
- SrcRegs[I] = getX86SubSuperRegister (Op-> getReg (), 64 );
1243
+ assert (Op. isReg () && " Only supports arguments in registers" );
1244
+ SrcRegs[I] = getX86SubSuperRegister (Op. getReg (), 64 );
1244
1245
assert (SrcRegs[I].isValid () && " Invalid operand" );
1245
1246
if (SrcRegs[I] != DestRegs[I]) {
1246
1247
UsedMask[I] = true ;
@@ -1354,8 +1355,8 @@ void X86AsmPrinter::LowerPATCHABLE_RET(const MachineInstr &MI,
1354
1355
MCInst Ret;
1355
1356
Ret.setOpcode (OpCode);
1356
1357
for (auto &MO : drop_begin (MI.operands ()))
1357
- if (auto MaybeOperand = MCIL.LowerMachineOperand (&MI, MO))
1358
- Ret.addOperand (*MaybeOperand );
1358
+ if (auto Op = MCIL.LowerMachineOperand (&MI, MO); Op. isValid ( ))
1359
+ Ret.addOperand (Op );
1359
1360
OutStreamer->emitInstruction (Ret, getSubtargetInfo ());
1360
1361
emitX86Nops (*OutStreamer, 10 , Subtarget);
1361
1362
recordSled (CurSled, MI, SledKind::FUNCTION_EXIT, 2 );
@@ -1417,8 +1418,8 @@ void X86AsmPrinter::LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI,
1417
1418
// indeed a tail call.
1418
1419
OutStreamer->AddComment (" TAILCALL" );
1419
1420
for (auto &MO : TCOperands)
1420
- if (auto MaybeOperand = MCIL.LowerMachineOperand (&MI, MO))
1421
- TC.addOperand (*MaybeOperand );
1421
+ if (auto Op = MCIL.LowerMachineOperand (&MI, MO); Op. isValid ( ))
1422
+ TC.addOperand (Op );
1422
1423
OutStreamer->emitInstruction (TC, getSubtargetInfo ());
1423
1424
1424
1425
if (IsConditional)
0 commit comments