From 6ccf1d23d7a503e1b50a8acb5aa5403a311d3446 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 19 Nov 2022 15:00:19 -0800 Subject: [PATCH] [SelectionDAG] Teach getRegistersForValue to return std::optional (NFC) This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716/11 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index fe7d6b3..bfdc2ec 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -100,6 +100,7 @@ #include #include #include +#include #include using namespace llvm; @@ -8599,7 +8600,7 @@ static SDValue getAddressForMemoryInput(SDValue Chain, const SDLoc &Location, /// /// OpInfo describes the operand /// RefOpInfo describes the matching operand if any, the operand otherwise -static llvm::Optional +static std::optional getRegistersForValue(SelectionDAG &DAG, const SDLoc &DL, SDISelAsmOperandInfo &OpInfo, SDISelAsmOperandInfo &RefOpInfo) { @@ -8613,7 +8614,7 @@ getRegistersForValue(SelectionDAG &DAG, const SDLoc &DL, // No work to do for memory/address operands. if (OpInfo.ConstraintType == TargetLowering::C_Memory || OpInfo.ConstraintType == TargetLowering::C_Address) - return None; + return std::nullopt; // If this is a constraint for a single physreg, or a constraint for a // register class, find it. @@ -8623,7 +8624,7 @@ getRegistersForValue(SelectionDAG &DAG, const SDLoc &DL, &TRI, RefOpInfo.ConstraintCode, RefOpInfo.ConstraintVT); // RC is unset only on failure. Return immediately. if (!RC) - return None; + return std::nullopt; // Get the actual register value type. This is important, because the user // may have asked for (e.g.) the AX register in i32 type. We need to @@ -8668,7 +8669,7 @@ getRegistersForValue(SelectionDAG &DAG, const SDLoc &DL, // No need to allocate a matching input constraint since the constraint it's // matching to has already been allocated. if (OpInfo.isMatchingInputConstraint()) - return None; + return std::nullopt; EVT ValueVT = OpInfo.ConstraintVT; if (OpInfo.ConstraintVT == MVT::Other) @@ -8706,7 +8707,7 @@ getRegistersForValue(SelectionDAG &DAG, const SDLoc &DL, } OpInfo.AssignedRegs = RegsForValue(Regs, RegVT, ValueVT); - return None; + return std::nullopt; } static unsigned -- 2.7.4