@@ -67,8 +67,8 @@ class X86MCInstLower {
6767public:
6868 X86MCInstLower (const MachineFunction &MF, X86AsmPrinter &asmprinter);
6969
70- std::optional< MCOperand> LowerMachineOperand (const MachineInstr *MI,
71- const MachineOperand &MO) const ;
70+ MCOperand LowerMachineOperand (const MachineInstr *MI,
71+ const MachineOperand &MO) const ;
7272 void Lower (const MachineInstr *MI, MCInst &OutMI) const ;
7373
7474 MCSymbol *GetSymbolFromOperand (const MachineOperand &MO) const ;
@@ -326,17 +326,16 @@ static unsigned getRetOpcode(const X86Subtarget &Subtarget) {
326326 return Subtarget.is64Bit () ? X86::RET64 : X86::RET32;
327327}
328328
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 {
332331 switch (MO.getType ()) {
333332 default :
334333 MI->print (errs ());
335334 llvm_unreachable (" unknown operand type" );
336335 case MachineOperand::MO_Register:
337336 // Ignore all implicit register operands.
338337 if (MO.isImplicit ())
339- return std:: nullopt ;
338+ return MCOperand () ;
340339 return MCOperand::createReg (MO.getReg ());
341340 case MachineOperand::MO_Immediate:
342341 return MCOperand::createImm (MO.getImm ());
@@ -355,7 +354,7 @@ X86MCInstLower::LowerMachineOperand(const MachineInstr *MI,
355354 MO, AsmPrinter.GetBlockAddressSymbol (MO.getBlockAddress ()));
356355 case MachineOperand::MO_RegisterMask:
357356 // Ignore call clobbers.
358- return std:: nullopt ;
357+ return MCOperand () ;
359358 }
360359}
361360
@@ -398,8 +397,8 @@ void X86MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
398397 OutMI.setOpcode (MI->getOpcode ());
399398
400399 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 );
403402
404403 bool In64BitMode = AsmPrinter.getSubtarget ().is64Bit ();
405404 if (X86::optimizeInstFromVEX3ToVEX2 (OutMI, MI->getDesc ()) ||
@@ -867,8 +866,8 @@ void X86AsmPrinter::LowerFAULTING_OP(const MachineInstr &FaultingMI,
867866
868867 for (const MachineOperand &MO :
869868 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 );
872871
873872 OutStreamer->AddComment (" on-fault: " + HandlerLabel->getName ());
874873 OutStreamer->emitInstruction (MI, getSubtargetInfo ());
@@ -1139,9 +1138,10 @@ void X86AsmPrinter::LowerPATCHABLE_EVENT_CALL(const MachineInstr &MI,
11391138 // emit nops appropriately sized to keep the sled the same size in every
11401139 // situation.
11411140 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 );
11451145 assert (SrcRegs[I].isValid () && " Invalid operand" );
11461146 if (SrcRegs[I] != DestRegs[I]) {
11471147 UsedMask[I] = true ;
@@ -1237,10 +1237,11 @@ void X86AsmPrinter::LowerPATCHABLE_TYPED_EVENT_CALL(const MachineInstr &MI,
12371237 // In case the arguments are already in the correct register, we emit nops
12381238 // appropriately sized to keep the sled the same size in every situation.
12391239 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 ()) {
12411242 // 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 );
12441245 assert (SrcRegs[I].isValid () && " Invalid operand" );
12451246 if (SrcRegs[I] != DestRegs[I]) {
12461247 UsedMask[I] = true ;
@@ -1354,8 +1355,8 @@ void X86AsmPrinter::LowerPATCHABLE_RET(const MachineInstr &MI,
13541355 MCInst Ret;
13551356 Ret.setOpcode (OpCode);
13561357 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 );
13591360 OutStreamer->emitInstruction (Ret, getSubtargetInfo ());
13601361 emitX86Nops (*OutStreamer, 10 , Subtarget);
13611362 recordSled (CurSled, MI, SledKind::FUNCTION_EXIT, 2 );
@@ -1417,8 +1418,8 @@ void X86AsmPrinter::LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI,
14171418 // indeed a tail call.
14181419 OutStreamer->AddComment (" TAILCALL" );
14191420 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 );
14221423 OutStreamer->emitInstruction (TC, getSubtargetInfo ());
14231424
14241425 if (IsConditional)
0 commit comments