Skip to content

Commit 67819a7

Browse files
committed
[CodeGen] llvm::Optional => std::optional
1 parent 48e6ff9 commit 67819a7

File tree

87 files changed

+666
-668
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+666
-668
lines changed

llvm/include/llvm/CodeGen/CodeGenPassBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ template <typename DerivedT> class CodeGenPassBuilder {
189189
// This special-casing introduces less adaptor passes. If we have the need
190190
// of adding module passes after function passes, we could change the
191191
// implementation to accommodate that.
192-
Optional<bool> AddingFunctionPasses;
192+
std::optional<bool> AddingFunctionPasses;
193193
};
194194

195195
// Function object to maintain state while adding codegen machine passes.

llvm/include/llvm/CodeGen/CommandFlags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ bool getEnableMachineFunctionSplitter();
133133
bool getEnableDebugEntryValues();
134134

135135
bool getValueTrackingVariableLocations();
136-
Optional<bool> getExplicitValueTrackingVariableLocations();
136+
std::optional<bool> getExplicitValueTrackingVariableLocations();
137137

138138
bool getForceDwarfFrameSection();
139139

llvm/include/llvm/CodeGen/DebugHandlerBase.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
#ifndef LLVM_CODEGEN_DEBUGHANDLERBASE_H
1515
#define LLVM_CODEGEN_DEBUGHANDLERBASE_H
1616

17-
#include "llvm/ADT/Optional.h"
1817
#include "llvm/CodeGen/AsmPrinterHandler.h"
1918
#include "llvm/CodeGen/DbgEntityHistoryCalculator.h"
2019
#include "llvm/CodeGen/LexicalScopes.h"
2120
#include "llvm/IR/DebugInfoMetadata.h"
2221
#include "llvm/IR/DebugLoc.h"
22+
#include <optional>
2323

2424
namespace llvm {
2525

@@ -37,14 +37,14 @@ struct DbgVariableLocation {
3737
SmallVector<int64_t, 1> LoadChain;
3838

3939
/// Present if the location is part of a larger variable.
40-
llvm::Optional<llvm::DIExpression::FragmentInfo> FragmentInfo;
40+
std::optional<llvm::DIExpression::FragmentInfo> FragmentInfo;
4141

4242
/// Extract a VariableLocation from a MachineInstr.
4343
/// This will only work if Instruction is a debug value instruction
4444
/// and the associated DIExpression is in one of the supported forms.
4545
/// If these requirements are not met, the returned Optional will not
4646
/// have a value.
47-
static Optional<DbgVariableLocation>
47+
static std::optional<DbgVariableLocation>
4848
extractFromMachineInstruction(const MachineInstr &Instruction);
4949
};
5050

llvm/include/llvm/CodeGen/GlobalISel/CSEMIRBuilder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class CSEMIRBuilder : public MachineIRBuilder {
7070
void profileMBBOpcode(GISelInstProfileBuilder &B, unsigned Opc) const;
7171

7272
void profileEverything(unsigned Opc, ArrayRef<DstOp> DstOps,
73-
ArrayRef<SrcOp> SrcOps, Optional<unsigned> Flags,
73+
ArrayRef<SrcOp> SrcOps, std::optional<unsigned> Flags,
7474
GISelInstProfileBuilder &B) const;
7575

7676
// Takes a MachineInstrBuilder and inserts it into the CSEMap using the
@@ -93,7 +93,7 @@ class CSEMIRBuilder : public MachineIRBuilder {
9393
// Unhide buildInstr
9494
MachineInstrBuilder
9595
buildInstr(unsigned Opc, ArrayRef<DstOp> DstOps, ArrayRef<SrcOp> SrcOps,
96-
Optional<unsigned> Flag = std::nullopt) override;
96+
std::optional<unsigned> Flag = std::nullopt) override;
9797
// Bring in the other overload from the base class.
9898
using MachineIRBuilder::buildConstant;
9999

llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,9 @@ class CombinerHelper {
359359

360360
/// Transform fp_instr(cst) to constant result of the fp operation.
361361
bool matchCombineConstantFoldFpUnary(MachineInstr &MI,
362-
Optional<APFloat> &Cst);
362+
std::optional<APFloat> &Cst);
363363
void applyCombineConstantFoldFpUnary(MachineInstr &MI,
364-
Optional<APFloat> &Cst);
364+
std::optional<APFloat> &Cst);
365365

366366
/// Transform IntToPtr(PtrToInt(x)) to x if cast is in the same address space.
367367
bool matchCombineI2PToP2I(MachineInstr &MI, Register &Reg);
@@ -810,7 +810,7 @@ class CombinerHelper {
810810
/// \param [in] Root - The search root.
811811
///
812812
/// \returns The Registers found during the search.
813-
Optional<SmallVector<Register, 8>>
813+
std::optional<SmallVector<Register, 8>>
814814
findCandidatesForLoadOrCombine(const MachineInstr *Root) const;
815815

816816
/// Helper function for matchLoadOrCombine.
@@ -824,7 +824,7 @@ class CombinerHelper {
824824
///
825825
/// \returns On success, a 3-tuple containing lowest-index load found, the
826826
/// lowest index, and the last load in the sequence.
827-
Optional<std::tuple<GZExtLoad *, int64_t, GZExtLoad *>>
827+
std::optional<std::tuple<GZExtLoad *, int64_t, GZExtLoad *>>
828828
findLoadOffsetsForLoadOrCombine(
829829
SmallDenseMap<int64_t, int64_t, 8> &MemOffset2Idx,
830830
const SmallVector<Register, 8> &RegsToVisit,

llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#define LLVM_CODEGEN_GLOBALISEL_INSTRUCTIONSELECTOR_H
1717

1818
#include "llvm/ADT/DenseMap.h"
19-
#include "llvm/ADT/Optional.h"
2019
#include "llvm/ADT/SmallVector.h"
2120
#include "llvm/CodeGen/GlobalISel/Utils.h"
2221
#include "llvm/CodeGen/MachineFunction.h"
@@ -27,6 +26,7 @@
2726
#include <cstdint>
2827
#include <functional>
2928
#include <initializer_list>
29+
#include <optional>
3030
#include <vector>
3131

3232
namespace llvm {
@@ -468,7 +468,7 @@ class InstructionSelector {
468468

469469
protected:
470470
using ComplexRendererFns =
471-
Optional<SmallVector<std::function<void(MachineInstrBuilder &)>, 4>>;
471+
std::optional<SmallVector<std::function<void(MachineInstrBuilder &)>, 4>>;
472472
using RecordedMIVector = SmallVector<MachineInstr *, 4>;
473473
using NewMIVector = SmallVector<MachineInstrBuilder, 4>;
474474

llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ class LegalizationArtifactCombiner {
724724
/// and its callees rely upon.
725725
Register findValueFromDefImpl(Register DefReg, unsigned StartBit,
726726
unsigned Size) {
727-
Optional<DefinitionAndSourceRegister> DefSrcReg =
727+
std::optional<DefinitionAndSourceRegister> DefSrcReg =
728728
getDefSrcRegIgnoringCopies(DefReg, MRI);
729729
MachineInstr *Def = DefSrcReg->MI;
730730
DefReg = DefSrcReg->Reg;

llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,18 @@ inline OneNonDBGUse_match<SubPat> m_OneNonDBGUse(const SubPat &SP) {
6363
}
6464

6565
template <typename ConstT>
66-
inline Optional<ConstT> matchConstant(Register, const MachineRegisterInfo &);
66+
inline std::optional<ConstT> matchConstant(Register,
67+
const MachineRegisterInfo &);
6768

6869
template <>
69-
inline Optional<APInt> matchConstant(Register Reg,
70-
const MachineRegisterInfo &MRI) {
70+
inline std::optional<APInt> matchConstant(Register Reg,
71+
const MachineRegisterInfo &MRI) {
7172
return getIConstantVRegVal(Reg, MRI);
7273
}
7374

7475
template <>
75-
inline Optional<int64_t> matchConstant(Register Reg,
76-
const MachineRegisterInfo &MRI) {
76+
inline std::optional<int64_t> matchConstant(Register Reg,
77+
const MachineRegisterInfo &MRI) {
7778
return getIConstantVRegSExtVal(Reg, MRI);
7879
}
7980

@@ -97,18 +98,18 @@ inline ConstantMatch<int64_t> m_ICst(int64_t &Cst) {
9798
}
9899

99100
template <typename ConstT>
100-
inline Optional<ConstT> matchConstantSplat(Register,
101-
const MachineRegisterInfo &);
101+
inline std::optional<ConstT> matchConstantSplat(Register,
102+
const MachineRegisterInfo &);
102103

103104
template <>
104-
inline Optional<APInt> matchConstantSplat(Register Reg,
105-
const MachineRegisterInfo &MRI) {
105+
inline std::optional<APInt> matchConstantSplat(Register Reg,
106+
const MachineRegisterInfo &MRI) {
106107
return getIConstantSplatVal(Reg, MRI);
107108
}
108109

109110
template <>
110-
inline Optional<int64_t> matchConstantSplat(Register Reg,
111-
const MachineRegisterInfo &MRI) {
111+
inline std::optional<int64_t>
112+
matchConstantSplat(Register Reg, const MachineRegisterInfo &MRI) {
112113
return getIConstantSplatSExtVal(Reg, MRI);
113114
}
114115

@@ -139,34 +140,35 @@ inline ICstOrSplatMatch<int64_t> m_ICstOrSplat(int64_t &Cst) {
139140
}
140141

141142
struct GCstAndRegMatch {
142-
Optional<ValueAndVReg> &ValReg;
143-
GCstAndRegMatch(Optional<ValueAndVReg> &ValReg) : ValReg(ValReg) {}
143+
std::optional<ValueAndVReg> &ValReg;
144+
GCstAndRegMatch(std::optional<ValueAndVReg> &ValReg) : ValReg(ValReg) {}
144145
bool match(const MachineRegisterInfo &MRI, Register Reg) {
145146
ValReg = getIConstantVRegValWithLookThrough(Reg, MRI);
146147
return ValReg ? true : false;
147148
}
148149
};
149150

150-
inline GCstAndRegMatch m_GCst(Optional<ValueAndVReg> &ValReg) {
151+
inline GCstAndRegMatch m_GCst(std::optional<ValueAndVReg> &ValReg) {
151152
return GCstAndRegMatch(ValReg);
152153
}
153154

154155
struct GFCstAndRegMatch {
155-
Optional<FPValueAndVReg> &FPValReg;
156-
GFCstAndRegMatch(Optional<FPValueAndVReg> &FPValReg) : FPValReg(FPValReg) {}
156+
std::optional<FPValueAndVReg> &FPValReg;
157+
GFCstAndRegMatch(std::optional<FPValueAndVReg> &FPValReg)
158+
: FPValReg(FPValReg) {}
157159
bool match(const MachineRegisterInfo &MRI, Register Reg) {
158160
FPValReg = getFConstantVRegValWithLookThrough(Reg, MRI);
159161
return FPValReg ? true : false;
160162
}
161163
};
162164

163-
inline GFCstAndRegMatch m_GFCst(Optional<FPValueAndVReg> &FPValReg) {
165+
inline GFCstAndRegMatch m_GFCst(std::optional<FPValueAndVReg> &FPValReg) {
164166
return GFCstAndRegMatch(FPValReg);
165167
}
166168

167169
struct GFCstOrSplatGFCstMatch {
168-
Optional<FPValueAndVReg> &FPValReg;
169-
GFCstOrSplatGFCstMatch(Optional<FPValueAndVReg> &FPValReg)
170+
std::optional<FPValueAndVReg> &FPValReg;
171+
GFCstOrSplatGFCstMatch(std::optional<FPValueAndVReg> &FPValReg)
170172
: FPValReg(FPValReg) {}
171173
bool match(const MachineRegisterInfo &MRI, Register Reg) {
172174
return (FPValReg = getFConstantSplat(Reg, MRI)) ||
@@ -175,7 +177,7 @@ struct GFCstOrSplatGFCstMatch {
175177
};
176178

177179
inline GFCstOrSplatGFCstMatch
178-
m_GFCstOrSplat(Optional<FPValueAndVReg> &FPValReg) {
180+
m_GFCstOrSplat(std::optional<FPValueAndVReg> &FPValReg) {
179181
return GFCstOrSplatGFCstMatch(FPValReg);
180182
}
181183

0 commit comments

Comments
 (0)