diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 2b241967f5e7bb..cefeb8c2558581 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -92,6 +92,7 @@ #include "llvm/Transforms/Utils/NameAnonGlobals.h" #include "llvm/Transforms/Utils/SymbolRewriter.h" #include +#include using namespace clang; using namespace llvm; @@ -312,7 +313,7 @@ static CodeGenOpt::Level getCGOptLevel(const CodeGenOptions &CodeGenOpts) { } } -static Optional +static std::optional getCodeModel(const CodeGenOptions &CodeGenOpts) { unsigned CodeModel = llvm::StringSwitch(CodeGenOpts.CodeModel) .Case("tiny", llvm::CodeModel::Tiny) @@ -324,7 +325,7 @@ getCodeModel(const CodeGenOptions &CodeGenOpts) { .Default(~0u); assert(CodeModel != ~0u && "invalid code model!"); if (CodeModel == ~1u) - return None; + return std::nullopt; return static_cast(CodeModel); } @@ -572,7 +573,7 @@ void EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { return; } - Optional CM = getCodeModel(CodeGenOpts); + std::optional CM = getCodeModel(CodeGenOpts); std::string FeaturesStr = llvm::join(TargetOpts.Features.begin(), TargetOpts.Features.end(), ","); llvm::Reloc::Model RM = CodeGenOpts.RelocationModel; diff --git a/lld/Common/TargetOptionsCommandFlags.cpp b/lld/Common/TargetOptionsCommandFlags.cpp index 3ab43f423d31bb..26e0fe6ab31c73 100644 --- a/lld/Common/TargetOptionsCommandFlags.cpp +++ b/lld/Common/TargetOptionsCommandFlags.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/Triple.h" #include "llvm/CodeGen/CommandFlags.h" #include "llvm/Target/TargetOptions.h" +#include llvm::TargetOptions lld::initTargetOptionsFromCodeGenFlags() { return llvm::codegen::InitTargetOptionsFromCodeGenFlags(llvm::Triple()); @@ -19,7 +20,7 @@ llvm::Optional lld::getRelocModelFromCMModel() { return llvm::codegen::getExplicitRelocModel(); } -llvm::Optional lld::getCodeModelFromCMModel() { +std::optional lld::getCodeModelFromCMModel() { return llvm::codegen::getExplicitCodeModel(); } diff --git a/lld/include/lld/Common/TargetOptionsCommandFlags.h b/lld/include/lld/Common/TargetOptionsCommandFlags.h index 04428b500abddf..02c7d40980e9a3 100644 --- a/lld/include/lld/Common/TargetOptionsCommandFlags.h +++ b/lld/include/lld/Common/TargetOptionsCommandFlags.h @@ -16,11 +16,12 @@ #include "llvm/ADT/Optional.h" #include "llvm/Support/CodeGen.h" #include "llvm/Target/TargetOptions.h" +#include namespace lld { llvm::TargetOptions initTargetOptionsFromCodeGenFlags(); llvm::Optional getRelocModelFromCMModel(); -llvm::Optional getCodeModelFromCMModel(); +std::optional getCodeModelFromCMModel(); std::string getCPUStr(); std::vector getMAttrs(); } diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h b/llvm/include/llvm/CodeGen/CommandFlags.h index 9281ed723854c4..c592738aff05bf 100644 --- a/llvm/include/llvm/CodeGen/CommandFlags.h +++ b/llvm/include/llvm/CodeGen/CommandFlags.h @@ -18,6 +18,7 @@ #include "llvm/ADT/FloatingPointMode.h" #include "llvm/Support/CodeGen.h" #include "llvm/Target/TargetOptions.h" +#include #include #include @@ -42,7 +43,7 @@ Optional getExplicitRelocModel(); ThreadModel::Model getThreadModel(); CodeModel::Model getCodeModel(); -Optional getExplicitCodeModel(); +std::optional getExplicitCodeModel(); llvm::ExceptionHandling getExceptionModel(); diff --git a/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h b/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h index 43c91fb5f988af..e2c7bb739e9b1e 100644 --- a/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/llvm/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -541,7 +542,7 @@ class EngineBuilder { std::shared_ptr Resolver; TargetOptions Options; Optional RelocModel; - Optional CMModel; + std::optional CMModel; std::string MArch; std::string MCPU; SmallVector MAttrs; diff --git a/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h b/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h index e6a63707653a8c..0c44e4699a8a92 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h @@ -21,6 +21,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include +#include #include #include @@ -92,13 +93,13 @@ class JITTargetMachineBuilder { const Optional &getRelocationModel() const { return RM; } /// Set the code model. - JITTargetMachineBuilder &setCodeModel(Optional CM) { + JITTargetMachineBuilder &setCodeModel(std::optional CM) { this->CM = std::move(CM); return *this; } /// Get the code model. - const Optional &getCodeModel() const { return CM; } + const std::optional &getCodeModel() const { return CM; } /// Set the LLVM CodeGen optimization level. JITTargetMachineBuilder &setCodeGenOptLevel(CodeGenOpt::Level OptLevel) { @@ -151,7 +152,7 @@ class JITTargetMachineBuilder { SubtargetFeatures Features; TargetOptions Options; Optional RM; - Optional CM; + std::optional CM; CodeGenOpt::Level OptLevel = CodeGenOpt::Default; }; diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h index 24da08d70b7268..0dd1b81326a30e 100644 --- a/llvm/include/llvm/IR/Module.h +++ b/llvm/include/llvm/IR/Module.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -863,7 +864,7 @@ class LLVM_EXTERNAL_VISIBILITY Module { /// @{ /// Returns the code model (tiny, small, kernel, medium or large model) - Optional getCodeModel() const; + std::optional getCodeModel() const; /// Set the code model (tiny, small, kernel, medium or large) void setCodeModel(CodeModel::Model CL); diff --git a/llvm/include/llvm/LTO/Config.h b/llvm/include/llvm/LTO/Config.h index 6c0aa74760669c..a709ddb88b0e5c 100644 --- a/llvm/include/llvm/LTO/Config.h +++ b/llvm/include/llvm/LTO/Config.h @@ -25,6 +25,7 @@ #include "llvm/Target/TargetOptions.h" #include +#include namespace llvm { @@ -52,7 +53,7 @@ struct Config { /// For adding passes that run right before codegen. std::function PreCodeGenPassesHook; Optional RelocModel = Reloc::PIC_; - Optional CodeModel = std::nullopt; + std::optional CodeModel = std::nullopt; CodeGenOpt::Level CGOptLevel = CodeGenOpt::Default; CodeGenFileType CGFileType = CGFT_ObjectFile; unsigned OptLevel = 2; diff --git a/llvm/include/llvm/MC/TargetRegistry.h b/llvm/include/llvm/MC/TargetRegistry.h index 46f4a9a4e7cab1..4c98cbce7e8ac6 100644 --- a/llvm/include/llvm/MC/TargetRegistry.h +++ b/llvm/include/llvm/MC/TargetRegistry.h @@ -31,6 +31,7 @@ #include #include #include +#include #include namespace llvm { @@ -167,7 +168,7 @@ class Target { using TargetMachineCtorTy = TargetMachine *(*)(const Target &T, const Triple &TT, StringRef CPU, StringRef Features, const TargetOptions &Options, Optional RM, - Optional CM, CodeGenOpt::Level OL, bool JIT); + std::optional CM, CodeGenOpt::Level OL, bool JIT); // If it weren't for layering issues (this header is in llvm/Support, but // depends on MC?) this should take the Streamer by value rather than rvalue // reference. @@ -481,7 +482,7 @@ class Target { TargetMachine * createTargetMachine(StringRef TT, StringRef CPU, StringRef Features, const TargetOptions &Options, Optional RM, - Optional CM = std::nullopt, + std::optional CM = std::nullopt, CodeGenOpt::Level OL = CodeGenOpt::Default, bool JIT = false) const { if (!TargetMachineCtorFn) @@ -1358,10 +1359,12 @@ template struct RegisterTargetMachine { } private: - static TargetMachine * - Allocator(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, - const TargetOptions &Options, Optional RM, - Optional CM, CodeGenOpt::Level OL, bool JIT) { + static TargetMachine *Allocator(const Target &T, const Triple &TT, + StringRef CPU, StringRef FS, + const TargetOptions &Options, + Optional RM, + std::optional CM, + CodeGenOpt::Level OL, bool JIT) { return new TargetMachineImpl(T, TT, CPU, FS, Options, RM, CM, OL, JIT); } }; diff --git a/llvm/include/llvm/Target/CodeGenCWrappers.h b/llvm/include/llvm/Target/CodeGenCWrappers.h index 792cef2fef3eda..43f488a56bd53a 100644 --- a/llvm/include/llvm/Target/CodeGenCWrappers.h +++ b/llvm/include/llvm/Target/CodeGenCWrappers.h @@ -19,10 +19,11 @@ #include "llvm/ADT/Optional.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/ErrorHandling.h" +#include namespace llvm { -inline Optional unwrap(LLVMCodeModel Model, bool &JIT) { +inline std::optional unwrap(LLVMCodeModel Model, bool &JIT) { JIT = false; switch (Model) { case LLVMCodeModelJITDefault: diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h index 440205d1bae4da..86066288856f65 100644 --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/include/llvm/Target/TargetMachine.h @@ -23,6 +23,7 @@ #include "llvm/Support/PGOOptions.h" #include "llvm/Target/CGPassBuilderOption.h" #include "llvm/Target/TargetOptions.h" +#include #include #include @@ -497,8 +498,9 @@ class LLVMTargetMachine : public TargetMachine { /// CM does not have a value. The tiny and kernel models will produce /// an error, so targets that support them or require more complex codemodel /// selection logic should implement and call their own getEffectiveCodeModel. -inline CodeModel::Model getEffectiveCodeModel(Optional CM, - CodeModel::Model Default) { +inline CodeModel::Model +getEffectiveCodeModel(std::optional CM, + CodeModel::Model Default) { if (CM) { // By default, targets do not support the tiny and kernel models. if (*CM == CodeModel::Tiny) diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp index fd52191882cb60..28b518a887aeaa 100644 --- a/llvm/lib/CodeGen/CommandFlags.cpp +++ b/llvm/lib/CodeGen/CommandFlags.cpp @@ -23,6 +23,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Host.h" #include "llvm/Support/MemoryBuffer.h" +#include using namespace llvm; @@ -50,12 +51,23 @@ using namespace llvm; return None; \ } +// Temporary macro for incremental transition to std::optional. +#define CGSTDOPT_EXP(TY, NAME) \ + CGOPT(TY, NAME) \ + std::optional codegen::getExplicit##NAME() { \ + if (NAME##View->getNumOccurrences()) { \ + TY res = *NAME##View; \ + return res; \ + } \ + return std::nullopt; \ + } + CGOPT(std::string, MArch) CGOPT(std::string, MCPU) CGLIST(std::string, MAttrs) CGOPT_EXP(Reloc::Model, RelocModel) CGOPT(ThreadModel::Model, ThreadModel) -CGOPT_EXP(CodeModel::Model, CodeModel) +CGSTDOPT_EXP(CodeModel::Model, CodeModel) CGOPT(ExceptionHandling, ExceptionModel) CGOPT_EXP(CodeGenFileType, FileType) CGOPT(FramePointerKind, FramePointerUsage) diff --git a/llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp b/llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp index 672fd7b991c25a..dc9a07e3f2123a 100644 --- a/llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp +++ b/llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp @@ -21,6 +21,7 @@ #include "llvm/Target/CodeGenCWrappers.h" #include "llvm/Target/TargetOptions.h" #include +#include using namespace llvm; @@ -199,7 +200,7 @@ LLVMBool LLVMCreateMCJITCompilerForModule( .setOptLevel((CodeGenOpt::Level)options.OptLevel) .setTargetOptions(targetOptions); bool JIT; - if (Optional CM = unwrap(options.CodeModel, JIT)) + if (std::optional CM = unwrap(options.CodeModel, JIT)) builder.setCodeModel(*CM); if (options.MCJMM) builder.setMCJITMemoryManager( diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index a9e80b3d354727..1f2f86fc1e0ce5 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -616,7 +616,7 @@ void Module::setPIELevel(PIELevel::Level PL) { addModuleFlag(ModFlagBehavior::Max, "PIE Level", PL); } -Optional Module::getCodeModel() const { +std::optional Module::getCodeModel() const { auto *Val = cast_or_null(getModuleFlag("Code Model")); if (!Val) diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 9298e45332352a..9762cb4bd37604 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -44,6 +44,7 @@ #include "llvm/Transforms/Scalar/LoopPassManager.h" #include "llvm/Transforms/Utils/FunctionImportUtils.h" #include "llvm/Transforms/Utils/SplitModule.h" +#include using namespace llvm; using namespace lto; @@ -214,7 +215,7 @@ createTargetMachine(const Config &Conf, const Target *TheTarget, Module &M) { RelocModel = M.getPICLevel() == PICLevel::NotPIC ? Reloc::Static : Reloc::PIC_; - Optional CodeModel; + std::optional CodeModel; if (Conf.CodeModel) CodeModel = *Conf.CodeModel; else diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp index b622c93f4017a1..2890f8d972f4a7 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp @@ -288,8 +288,8 @@ static Reloc::Model getEffectiveRelocModel(const Triple &TT, } static CodeModel::Model -getEffectiveAArch64CodeModel(const Triple &TT, Optional CM, - bool JIT) { +getEffectiveAArch64CodeModel(const Triple &TT, + std::optional CM, bool JIT) { if (CM) { if (*CM != CodeModel::Small && *CM != CodeModel::Tiny && *CM != CodeModel::Large) { @@ -316,7 +316,7 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT, bool LittleEndian) : LLVMTargetMachine(T, @@ -455,7 +455,7 @@ void AArch64leTargetMachine::anchor() { } AArch64leTargetMachine::AArch64leTargetMachine( const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, CodeGenOpt::Level OL, bool JIT) + std::optional CM, CodeGenOpt::Level OL, bool JIT) : AArch64TargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, true) {} void AArch64beTargetMachine::anchor() { } @@ -463,7 +463,7 @@ void AArch64beTargetMachine::anchor() { } AArch64beTargetMachine::AArch64beTargetMachine( const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, CodeGenOpt::Level OL, bool JIT) + std::optional CM, CodeGenOpt::Level OL, bool JIT) : AArch64TargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, false) {} namespace { diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.h b/llvm/lib/Target/AArch64/AArch64TargetMachine.h index beb109502ff9e3..e778409e927994 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetMachine.h +++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.h @@ -17,6 +17,7 @@ #include "AArch64Subtarget.h" #include "llvm/IR/DataLayout.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { @@ -28,8 +29,9 @@ class AArch64TargetMachine : public LLVMTargetMachine { public: AArch64TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT, bool IsLittleEndian); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT, bool IsLittleEndian); ~AArch64TargetMachine() override; const AArch64Subtarget *getSubtargetImpl(const Function &F) const override; @@ -69,24 +71,26 @@ class AArch64TargetMachine : public LLVMTargetMachine { // class AArch64leTargetMachine : public AArch64TargetMachine { virtual void anchor(); + public: AArch64leTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, CodeGenOpt::Level OL, - bool JIT); + std::optional CM, + CodeGenOpt::Level OL, bool JIT); }; // AArch64 big endian target machine. // class AArch64beTargetMachine : public AArch64TargetMachine { virtual void anchor(); + public: AArch64beTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, CodeGenOpt::Level OL, - bool JIT); + std::optional CM, + CodeGenOpt::Level OL, bool JIT); }; } // end namespace llvm diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index a801279c44a105..d4dd07f1f4e2bf 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -57,6 +57,7 @@ #include "llvm/Transforms/Utils.h" #include "llvm/Transforms/Utils/SimplifyLibCalls.h" #include "llvm/Transforms/Vectorize.h" +#include using namespace llvm; using namespace llvm::PatternMatch; @@ -531,7 +532,7 @@ AMDGPUTargetMachine::AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OptLevel) : LLVMTargetMachine(T, computeDataLayout(TT), TT, getGPUOrDefault(TT, CPU), FS, Options, getEffectiveRelocModel(RM), @@ -801,7 +802,7 @@ GCNTargetMachine::GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : AMDGPUTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) {} diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h index caa03de1ca0ee9..af6c0f852124a3 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h @@ -17,6 +17,7 @@ #include "GCNSubtarget.h" #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/Target/TargetMachine.h" +#include #include namespace llvm { @@ -39,8 +40,8 @@ class AMDGPUTargetMachine : public LLVMTargetMachine { AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL); + Optional RM, + std::optional CM, CodeGenOpt::Level OL); ~AMDGPUTargetMachine() override; const TargetSubtargetInfo *getSubtargetImpl() const; @@ -77,8 +78,9 @@ class GCNTargetMachine final : public AMDGPUTargetMachine { public: GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); TargetPassConfig *createPassConfig(PassManagerBase &PM) override; diff --git a/llvm/lib/Target/AMDGPU/R600TargetMachine.cpp b/llvm/lib/Target/AMDGPU/R600TargetMachine.cpp index 76bb0f65ef694c..d5aa3402b134f0 100644 --- a/llvm/lib/Target/AMDGPU/R600TargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/R600TargetMachine.cpp @@ -18,6 +18,7 @@ #include "R600MachineScheduler.h" #include "R600TargetTransformInfo.h" #include "llvm/Transforms/Scalar.h" +#include using namespace llvm; @@ -51,7 +52,7 @@ R600TargetMachine::R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : AMDGPUTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) { setRequiresStructuredCFG(true); diff --git a/llvm/lib/Target/AMDGPU/R600TargetMachine.h b/llvm/lib/Target/AMDGPU/R600TargetMachine.h index 8d20841292b9a3..2c1fb033b8c740 100644 --- a/llvm/lib/Target/AMDGPU/R600TargetMachine.h +++ b/llvm/lib/Target/AMDGPU/R600TargetMachine.h @@ -17,6 +17,7 @@ #include "AMDGPUTargetMachine.h" #include "R600Subtarget.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { @@ -31,8 +32,9 @@ class R600TargetMachine final : public AMDGPUTargetMachine { public: R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); TargetPassConfig *createPassConfig(PassManagerBase &PM) override; diff --git a/llvm/lib/Target/ARC/ARCTargetMachine.cpp b/llvm/lib/Target/ARC/ARCTargetMachine.cpp index 21757927d87348..11e9231669ff87 100644 --- a/llvm/lib/Target/ARC/ARCTargetMachine.cpp +++ b/llvm/lib/Target/ARC/ARCTargetMachine.cpp @@ -17,6 +17,7 @@ #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/MC/TargetRegistry.h" +#include using namespace llvm; @@ -29,7 +30,7 @@ ARCTargetMachine::ARCTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine(T, "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-" diff --git a/llvm/lib/Target/ARC/ARCTargetMachine.h b/llvm/lib/Target/ARC/ARCTargetMachine.h index 81ccfc6d5dd066..53a0a0f4acdbbd 100644 --- a/llvm/lib/Target/ARC/ARCTargetMachine.h +++ b/llvm/lib/Target/ARC/ARCTargetMachine.h @@ -15,6 +15,7 @@ #include "ARCSubtarget.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { @@ -27,8 +28,9 @@ class ARCTargetMachine : public LLVMTargetMachine { public: ARCTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); ~ARCTargetMachine() override; const ARCSubtarget *getSubtargetImpl() const { return &Subtarget; } diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.cpp b/llvm/lib/Target/ARM/ARMTargetMachine.cpp index 16489162bb8b7d..4417b51bf01429 100644 --- a/llvm/lib/Target/ARM/ARMTargetMachine.cpp +++ b/llvm/lib/Target/ARM/ARMTargetMachine.cpp @@ -53,6 +53,7 @@ #include "llvm/Transforms/Scalar.h" #include #include +#include #include using namespace llvm; @@ -217,7 +218,7 @@ ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool isLittle) : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options, isLittle), TT, CPU, FS, Options, getEffectiveRelocModel(TT, RM), @@ -317,7 +318,7 @@ ARMLETargetMachine::ARMLETargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : ARMBaseTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, true) {} @@ -325,7 +326,7 @@ ARMBETargetMachine::ARMBETargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : ARMBaseTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, false) {} diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.h b/llvm/lib/Target/ARM/ARMTargetMachine.h index 8d33a038deeb03..cf1112bb6d73a0 100644 --- a/llvm/lib/Target/ARM/ARMTargetMachine.h +++ b/llvm/lib/Target/ARM/ARMTargetMachine.h @@ -21,6 +21,7 @@ #include "llvm/Support/CodeGen.h" #include "llvm/Target/TargetMachine.h" #include +#include namespace llvm { @@ -41,8 +42,9 @@ class ARMBaseTargetMachine : public LLVMTargetMachine { public: ARMBaseTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool isLittle); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool isLittle); ~ARMBaseTargetMachine() override; const ARMSubtarget *getSubtargetImpl(const Function &F) const override; @@ -86,8 +88,9 @@ class ARMLETargetMachine : public ARMBaseTargetMachine { public: ARMLETargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); }; /// ARM/Thumb big endian target machine. @@ -96,8 +99,9 @@ class ARMBETargetMachine : public ARMBaseTargetMachine { public: ARMBETargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); }; } // end namespace llvm diff --git a/llvm/lib/Target/AVR/AVRTargetMachine.cpp b/llvm/lib/Target/AVR/AVRTargetMachine.cpp index b9d77e0d1a5145..b2809648ba3bf8 100644 --- a/llvm/lib/Target/AVR/AVRTargetMachine.cpp +++ b/llvm/lib/Target/AVR/AVRTargetMachine.cpp @@ -23,6 +23,8 @@ #include "MCTargetDesc/AVRMCTargetDesc.h" #include "TargetInfo/AVRTargetInfo.h" +#include + namespace llvm { static const char *AVRDataLayout = @@ -45,7 +47,7 @@ AVRTargetMachine::AVRTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine(T, AVRDataLayout, TT, getCPU(CPU), FS, Options, getEffectiveRelocModel(RM), diff --git a/llvm/lib/Target/AVR/AVRTargetMachine.h b/llvm/lib/Target/AVR/AVRTargetMachine.h index 54669eda060c65..92891069a9654c 100644 --- a/llvm/lib/Target/AVR/AVRTargetMachine.h +++ b/llvm/lib/Target/AVR/AVRTargetMachine.h @@ -22,6 +22,8 @@ #include "AVRSelectionDAGInfo.h" #include "AVRSubtarget.h" +#include + namespace llvm { /// A generic AVR implementation. @@ -29,8 +31,9 @@ class AVRTargetMachine : public LLVMTargetMachine { public: AVRTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); const AVRSubtarget *getSubtargetImpl() const; const AVRSubtarget *getSubtargetImpl(const Function &) const override; diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.cpp b/llvm/lib/Target/BPF/BPFTargetMachine.cpp index 0c22185d48fd12..9bd7871da9e5e9 100644 --- a/llvm/lib/Target/BPF/BPFTargetMachine.cpp +++ b/llvm/lib/Target/BPF/BPFTargetMachine.cpp @@ -27,6 +27,7 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar/SimplifyCFG.h" #include "llvm/Transforms/Utils/SimplifyCFGOptions.h" +#include using namespace llvm; static cl:: @@ -65,7 +66,7 @@ BPFTargetMachine::BPFTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, getEffectiveRelocModel(RM), diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.h b/llvm/lib/Target/BPF/BPFTargetMachine.h index 1a3afb032e916e..90eb7ba07e0bb5 100644 --- a/llvm/lib/Target/BPF/BPFTargetMachine.h +++ b/llvm/lib/Target/BPF/BPFTargetMachine.h @@ -15,6 +15,7 @@ #include "BPFSubtarget.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { class BPFTargetMachine : public LLVMTargetMachine { @@ -24,8 +25,9 @@ class BPFTargetMachine : public LLVMTargetMachine { public: BPFTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); const BPFSubtarget *getSubtargetImpl() const { return &Subtarget; } const BPFSubtarget *getSubtargetImpl(const Function &) const override { diff --git a/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp b/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp index d19f28fddd5310..8586ab60171ba0 100644 --- a/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp +++ b/llvm/lib/Target/CSKY/CSKYTargetMachine.cpp @@ -20,6 +20,7 @@ #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/MC/TargetRegistry.h" +#include using namespace llvm; @@ -49,7 +50,7 @@ CSKYTargetMachine::CSKYTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, RM.value_or(Reloc::Static), diff --git a/llvm/lib/Target/CSKY/CSKYTargetMachine.h b/llvm/lib/Target/CSKY/CSKYTargetMachine.h index ecb9fe95307734..a69dc82d621344 100644 --- a/llvm/lib/Target/CSKY/CSKYTargetMachine.h +++ b/llvm/lib/Target/CSKY/CSKYTargetMachine.h @@ -16,6 +16,7 @@ #include "CSKYSubtarget.h" #include "llvm/IR/DataLayout.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { @@ -26,8 +27,9 @@ class CSKYTargetMachine : public LLVMTargetMachine { public: CSKYTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); TargetPassConfig *createPassConfig(PassManagerBase &PM) override; diff --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp index 7031b66c9668f1..985f73ee032165 100644 --- a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp +++ b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp @@ -32,6 +32,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Target/TargetLoweringObjectFile.h" +#include using namespace llvm; @@ -83,7 +84,7 @@ DirectXTargetMachine::DirectXTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine(T, "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-" diff --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.h b/llvm/lib/Target/DirectX/DirectXTargetMachine.h index 8d0f383fe112ed..396d20495bfd10 100644 --- a/llvm/lib/Target/DirectX/DirectXTargetMachine.h +++ b/llvm/lib/Target/DirectX/DirectXTargetMachine.h @@ -13,6 +13,7 @@ #include "DirectXSubtarget.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { class Function; @@ -23,8 +24,9 @@ class DirectXTargetMachine : public LLVMTargetMachine { public: DirectXTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); ~DirectXTargetMachine() override; diff --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp index 0f4e8666bf5208..92748418f44421 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp +++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp @@ -28,6 +28,7 @@ #include "llvm/Passes/PassBuilder.h" #include "llvm/Support/CommandLine.h" #include "llvm/Transforms/Scalar.h" +#include using namespace llvm; @@ -223,7 +224,7 @@ HexagonTargetMachine::HexagonTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) // Specify the vector alignment explicitly. For v512x1, the calculated // alignment would be 512*alignment(i1), which is 512 bytes, instead of diff --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.h b/llvm/lib/Target/Hexagon/HexagonTargetMachine.h index de2e0b58e99845..a39637beb8cd67 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.h +++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.h @@ -17,6 +17,7 @@ #include "HexagonSubtarget.h" #include "HexagonTargetObjectFile.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { @@ -29,8 +30,9 @@ class HexagonTargetMachine : public LLVMTargetMachine { public: HexagonTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); ~HexagonTargetMachine() override; const HexagonSubtarget *getSubtargetImpl(const Function &F) const override; diff --git a/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp b/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp index 8af40d18d1068d..8ccbf2ae01861e 100644 --- a/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp +++ b/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp @@ -23,6 +23,7 @@ #include "llvm/MC/TargetRegistry.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Target/TargetOptions.h" +#include using namespace llvm; @@ -51,12 +52,11 @@ static Reloc::Model getEffectiveRelocModel(Optional RM) { return RM.value_or(Reloc::PIC_); } -LanaiTargetMachine::LanaiTargetMachine(const Target &T, const Triple &TT, - StringRef Cpu, StringRef FeatureString, - const TargetOptions &Options, - Optional RM, - Optional CodeModel, - CodeGenOpt::Level OptLevel, bool JIT) +LanaiTargetMachine::LanaiTargetMachine( + const Target &T, const Triple &TT, StringRef Cpu, StringRef FeatureString, + const TargetOptions &Options, Optional RM, + std::optional CodeModel, CodeGenOpt::Level OptLevel, + bool JIT) : LLVMTargetMachine(T, computeDataLayout(), TT, Cpu, FeatureString, Options, getEffectiveRelocModel(RM), getEffectiveCodeModel(CodeModel, CodeModel::Medium), diff --git a/llvm/lib/Target/Lanai/LanaiTargetMachine.h b/llvm/lib/Target/Lanai/LanaiTargetMachine.h index 258e58c86253d5..e2ddf09942e1fe 100644 --- a/llvm/lib/Target/Lanai/LanaiTargetMachine.h +++ b/llvm/lib/Target/Lanai/LanaiTargetMachine.h @@ -18,6 +18,7 @@ #include "LanaiSelectionDAGInfo.h" #include "LanaiSubtarget.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { @@ -30,7 +31,7 @@ class LanaiTargetMachine : public LLVMTargetMachine { StringRef Cpu, StringRef FeatureString, const TargetOptions &Options, Optional RelocationModel, - Optional CodeModel, + std::optional CodeModel, CodeGenOpt::Level OptLevel, bool JIT); const LanaiSubtarget * diff --git a/llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp b/llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp index f5862b33940be4..872e935b7d9632 100644 --- a/llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp +++ b/llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp @@ -18,6 +18,7 @@ #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/MC/TargetRegistry.h" +#include using namespace llvm; @@ -46,7 +47,7 @@ static Reloc::Model getEffectiveRelocModel(const Triple &TT, LoongArchTargetMachine::LoongArchTargetMachine( const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, CodeGenOpt::Level OL, bool JIT) + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, getEffectiveRelocModel(TT, RM), getEffectiveCodeModel(CM, CodeModel::Small), OL), diff --git a/llvm/lib/Target/LoongArch/LoongArchTargetMachine.h b/llvm/lib/Target/LoongArch/LoongArchTargetMachine.h index cbd872031a324b..62be57db0cf3a6 100644 --- a/llvm/lib/Target/LoongArch/LoongArchTargetMachine.h +++ b/llvm/lib/Target/LoongArch/LoongArchTargetMachine.h @@ -15,6 +15,7 @@ #include "LoongArchSubtarget.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { @@ -26,8 +27,8 @@ class LoongArchTargetMachine : public LLVMTargetMachine { LoongArchTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, CodeGenOpt::Level OL, - bool JIT); + std::optional CM, + CodeGenOpt::Level OL, bool JIT); ~LoongArchTargetMachine() override; const LoongArchSubtarget *getSubtargetImpl(const Function &F) const override; diff --git a/llvm/lib/Target/M68k/M68kTargetMachine.cpp b/llvm/lib/Target/M68k/M68kTargetMachine.cpp index cf0d296d697115..4e1d4a5ad4f5b6 100644 --- a/llvm/lib/Target/M68k/M68kTargetMachine.cpp +++ b/llvm/lib/Target/M68k/M68kTargetMachine.cpp @@ -27,6 +27,7 @@ #include "llvm/MC/TargetRegistry.h" #include "llvm/PassRegistry.h" #include +#include using namespace llvm; @@ -78,7 +79,7 @@ Reloc::Model getEffectiveRelocModel(const Triple &TT, return *RM; } -CodeModel::Model getEffectiveCodeModel(Optional CM, +CodeModel::Model getEffectiveCodeModel(std::optional CM, bool JIT) { if (!CM) { return CodeModel::Small; @@ -95,7 +96,7 @@ M68kTargetMachine::M68kTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options), TT, CPU, FS, Options, getEffectiveRelocModel(TT, RM), diff --git a/llvm/lib/Target/M68k/M68kTargetMachine.h b/llvm/lib/Target/M68k/M68kTargetMachine.h index 8dda720774e75a..83572b691baafc 100644 --- a/llvm/lib/Target/M68k/M68kTargetMachine.h +++ b/llvm/lib/Target/M68k/M68kTargetMachine.h @@ -22,6 +22,8 @@ #include "llvm/CodeGen/TargetFrameLowering.h" #include "llvm/Target/TargetMachine.h" +#include + namespace llvm { class formatted_raw_ostream; class M68kRegisterInfo; @@ -35,8 +37,9 @@ class M68kTargetMachine : public LLVMTargetMachine { public: M68kTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); ~M68kTargetMachine() override; diff --git a/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp b/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp index 6bba224aab8b2a..7edd7350e315bb 100644 --- a/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp +++ b/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp @@ -19,6 +19,7 @@ #include "llvm/IR/LegacyPassManager.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/TargetRegistry.h" +#include using namespace llvm; extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430Target() { @@ -39,7 +40,7 @@ MSP430TargetMachine::MSP430TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options), TT, CPU, FS, Options, getEffectiveRelocModel(RM), diff --git a/llvm/lib/Target/MSP430/MSP430TargetMachine.h b/llvm/lib/Target/MSP430/MSP430TargetMachine.h index ef757dc7cb78a7..533186b8b4028e 100644 --- a/llvm/lib/Target/MSP430/MSP430TargetMachine.h +++ b/llvm/lib/Target/MSP430/MSP430TargetMachine.h @@ -16,6 +16,7 @@ #include "MSP430Subtarget.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { class StringRef; @@ -24,13 +25,14 @@ class StringRef; /// class MSP430TargetMachine : public LLVMTargetMachine { std::unique_ptr TLOF; - MSP430Subtarget Subtarget; + MSP430Subtarget Subtarget; public: MSP430TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); ~MSP430TargetMachine() override; const MSP430Subtarget *getSubtargetImpl(const Function &F) const override { diff --git a/llvm/lib/Target/Mips/MipsTargetMachine.cpp b/llvm/lib/Target/Mips/MipsTargetMachine.cpp index fa970512eb495f..a2fd27e3420916 100644 --- a/llvm/lib/Target/Mips/MipsTargetMachine.cpp +++ b/llvm/lib/Target/Mips/MipsTargetMachine.cpp @@ -41,6 +41,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetOptions.h" +#include #include using namespace llvm; @@ -120,7 +121,7 @@ MipsTargetMachine::MipsTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT, bool isLittle) : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options, isLittle), TT, @@ -149,7 +150,7 @@ MipsebTargetMachine::MipsebTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : MipsTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, false) {} @@ -159,7 +160,7 @@ MipselTargetMachine::MipselTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : MipsTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, true) {} diff --git a/llvm/lib/Target/Mips/MipsTargetMachine.h b/llvm/lib/Target/Mips/MipsTargetMachine.h index 46ffc11738df8a..3492d0c071e3f0 100644 --- a/llvm/lib/Target/Mips/MipsTargetMachine.h +++ b/llvm/lib/Target/Mips/MipsTargetMachine.h @@ -21,6 +21,7 @@ #include "llvm/Support/CodeGen.h" #include "llvm/Target/TargetMachine.h" #include +#include namespace llvm { @@ -39,8 +40,9 @@ class MipsTargetMachine : public LLVMTargetMachine { public: MipsTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT, bool isLittle); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT, bool isLittle); ~MipsTargetMachine() override; TargetTransformInfo getTargetTransformInfo(const Function &F) const override; @@ -83,8 +85,9 @@ class MipsebTargetMachine : public MipsTargetMachine { public: MipsebTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); }; /// Mips32/64 little endian target machine. @@ -95,8 +98,9 @@ class MipselTargetMachine : public MipsTargetMachine { public: MipselTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); }; } // end namespace llvm diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp index 3a805cdb7245a2..48357bc5c67a94 100644 --- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp @@ -35,6 +35,7 @@ #include "llvm/Transforms/Scalar/GVN.h" #include "llvm/Transforms/Vectorize.h" #include +#include #include using namespace llvm; @@ -112,7 +113,7 @@ NVPTXTargetMachine::NVPTXTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool is64bit) // The pic relocation model is used regardless of what the client has // specified, as it is the only relocation model currently supported. @@ -139,7 +140,7 @@ NVPTXTargetMachine32::NVPTXTargetMachine32(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : NVPTXTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, false) {} @@ -149,7 +150,7 @@ NVPTXTargetMachine64::NVPTXTargetMachine64(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : NVPTXTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, true) {} diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h index 6f1ee9cc8f6b04..4b0db6405ed26e 100644 --- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h +++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.h @@ -16,6 +16,7 @@ #include "ManagedStringPool.h" #include "NVPTXSubtarget.h" #include "llvm/Target/TargetMachine.h" +#include #include namespace llvm { @@ -36,9 +37,9 @@ class NVPTXTargetMachine : public LLVMTargetMachine { public: NVPTXTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OP, bool is64bit); - + Optional RM, + std::optional CM, CodeGenOpt::Level OP, + bool is64bit); ~NVPTXTargetMachine() override; const NVPTXSubtarget *getSubtargetImpl(const Function &) const override { return &Subtarget; @@ -76,20 +77,24 @@ class NVPTXTargetMachine : public LLVMTargetMachine { class NVPTXTargetMachine32 : public NVPTXTargetMachine { virtual void anchor(); + public: NVPTXTargetMachine32(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); }; class NVPTXTargetMachine64 : public NVPTXTargetMachine { virtual void anchor(); + public: NVPTXTargetMachine64(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); }; } // end namespace llvm diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp index 9b28310a362255..f0ae6641a09182 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -46,6 +46,7 @@ #include "llvm/Transforms/Scalar.h" #include #include +#include #include using namespace llvm; @@ -260,9 +261,9 @@ static Reloc::Model getEffectiveRelocModel(const Triple &TT, return Reloc::Static; } -static CodeModel::Model getEffectivePPCCodeModel(const Triple &TT, - Optional CM, - bool JIT) { +static CodeModel::Model +getEffectivePPCCodeModel(const Triple &TT, std::optional CM, + bool JIT) { if (CM) { if (*CM == CodeModel::Tiny) report_fatal_error("Target does not support the tiny CodeModel", false); @@ -325,7 +326,7 @@ PPCTargetMachine::PPCTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine(T, getDataLayoutString(TT), TT, CPU, computeFSAdditions(FS, OL, TT), Options, diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.h b/llvm/lib/Target/PowerPC/PPCTargetMachine.h index bafb79c849429d..b9c56a891a5f0d 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetMachine.h +++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.h @@ -17,6 +17,7 @@ #include "PPCSubtarget.h" #include "llvm/IR/DataLayout.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { @@ -37,8 +38,9 @@ class PPCTargetMachine final : public LLVMTargetMachine { public: PPCTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); ~PPCTargetMachine() override; diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp index d4529442df4eec..fe65d431b927ba 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -35,6 +35,7 @@ #include "llvm/Support/FormattedStream.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Transforms/IPO.h" +#include using namespace llvm; static cl::opt EnableRedundantCopyElimination( @@ -83,7 +84,7 @@ RISCVTargetMachine::RISCVTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, getEffectiveRelocModel(TT, RM), diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.h b/llvm/lib/Target/RISCV/RISCVTargetMachine.h index 4b2a403c5c5b54..bd323213cec5d4 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.h +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.h @@ -18,6 +18,7 @@ #include "llvm/CodeGen/SelectionDAGTargetInfo.h" #include "llvm/IR/DataLayout.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { class RISCVTargetMachine : public LLVMTargetMachine { @@ -27,8 +28,9 @@ class RISCVTargetMachine : public LLVMTargetMachine { public: RISCVTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); const RISCVSubtarget *getSubtargetImpl(const Function &F) const override; // DO NOT IMPLEMENT: There is no such thing as a valid default subtarget, diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp index 3d5d58134c89fd..b3aa534f1fcdf9 100644 --- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp +++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp @@ -30,6 +30,7 @@ #include "llvm/MC/TargetRegistry.h" #include "llvm/Pass.h" #include "llvm/Target/TargetOptions.h" +#include using namespace llvm; @@ -65,7 +66,7 @@ SPIRVTargetMachine::SPIRVTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, getEffectiveRelocModel(RM), diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.h b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.h index f3597971bc955c..f424639d8137fb 100644 --- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.h +++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.h @@ -15,6 +15,7 @@ #include "SPIRVSubtarget.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { class SPIRVTargetMachine : public LLVMTargetMachine { @@ -24,8 +25,9 @@ class SPIRVTargetMachine : public LLVMTargetMachine { public: SPIRVTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); const SPIRVSubtarget *getSubtargetImpl() const { return &Subtarget; } diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp index 8bd51a703d47fe..ed61f502745dff 100644 --- a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp +++ b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp @@ -18,6 +18,7 @@ #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/MC/TargetRegistry.h" +#include using namespace llvm; extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcTarget() { @@ -69,7 +70,7 @@ static Reloc::Model getEffectiveRelocModel(Optional RM) { // // All code models require that the text segment is smaller than 2GB. static CodeModel::Model -getEffectiveSparcCodeModel(Optional CM, Reloc::Model RM, +getEffectiveSparcCodeModel(std::optional CM, Reloc::Model RM, bool Is64Bit, bool JIT) { if (CM) { if (*CM == CodeModel::Tiny) @@ -87,10 +88,13 @@ getEffectiveSparcCodeModel(Optional CM, Reloc::Model RM, } /// Create an ILP32 architecture model -SparcTargetMachine::SparcTargetMachine( - const Target &T, const Triple &TT, StringRef CPU, StringRef FS, - const TargetOptions &Options, Optional RM, - Optional CM, CodeGenOpt::Level OL, bool JIT, bool is64bit) +SparcTargetMachine::SparcTargetMachine(const Target &T, const Triple &TT, + StringRef CPU, StringRef FS, + const TargetOptions &Options, + Optional RM, + std::optional CM, + CodeGenOpt::Level OL, bool JIT, + bool is64bit) : LLVMTargetMachine(T, computeDataLayout(TT, is64bit), TT, CPU, FS, Options, getEffectiveRelocModel(RM), getEffectiveSparcCodeModel( @@ -188,7 +192,7 @@ SparcV8TargetMachine::SparcV8TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, false) {} @@ -198,7 +202,7 @@ SparcV9TargetMachine::SparcV9TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, true) {} @@ -208,6 +212,6 @@ SparcelTargetMachine::SparcelTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, false) {} diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.h b/llvm/lib/Target/Sparc/SparcTargetMachine.h index 4083f61433b167..3f66b47ee5f041 100644 --- a/llvm/lib/Target/Sparc/SparcTargetMachine.h +++ b/llvm/lib/Target/Sparc/SparcTargetMachine.h @@ -16,6 +16,7 @@ #include "SparcInstrInfo.h" #include "SparcSubtarget.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { @@ -24,11 +25,13 @@ class SparcTargetMachine : public LLVMTargetMachine { SparcSubtarget Subtarget; bool is64Bit; mutable StringMap> SubtargetMap; + public: SparcTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT, bool is64bit); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT, bool is64bit); ~SparcTargetMachine() override; const SparcSubtarget *getSubtargetImpl() const { return &Subtarget; } @@ -45,22 +48,26 @@ class SparcTargetMachine : public LLVMTargetMachine { /// class SparcV8TargetMachine : public SparcTargetMachine { virtual void anchor(); + public: SparcV8TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); }; /// Sparc 64-bit target machine /// class SparcV9TargetMachine : public SparcTargetMachine { virtual void anchor(); + public: SparcV9TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); }; class SparcelTargetMachine : public SparcTargetMachine { @@ -69,8 +76,9 @@ class SparcelTargetMachine : public SparcTargetMachine { public: SparcelTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); }; } // end namespace llvm diff --git a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp index 8c1be7d4949da2..0ea6c6d6461aca 100644 --- a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp +++ b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp @@ -25,6 +25,7 @@ #include "llvm/Support/CodeGen.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Transforms/Scalar.h" +#include #include using namespace llvm; @@ -122,8 +123,8 @@ static Reloc::Model getEffectiveRelocModel(Optional RM) { // of copy relocs, so locally-binding data symbols might not be in // the range of LARL. We need the Medium model in that case. static CodeModel::Model -getEffectiveSystemZCodeModel(Optional CM, Reloc::Model RM, - bool JIT) { +getEffectiveSystemZCodeModel(std::optional CM, + Reloc::Model RM, bool JIT) { if (CM) { if (*CM == CodeModel::Tiny) report_fatal_error("Target does not support the tiny CodeModel", false); @@ -140,7 +141,7 @@ SystemZTargetMachine::SystemZTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine( T, computeDataLayout(TT), TT, CPU, FS, Options, diff --git a/llvm/lib/Target/SystemZ/SystemZTargetMachine.h b/llvm/lib/Target/SystemZ/SystemZTargetMachine.h index 2cdb33a5064b8d..d36aeb76925e3d 100644 --- a/llvm/lib/Target/SystemZ/SystemZTargetMachine.h +++ b/llvm/lib/Target/SystemZ/SystemZTargetMachine.h @@ -21,6 +21,7 @@ #include "llvm/Support/CodeGen.h" #include "llvm/Target/TargetMachine.h" #include +#include namespace llvm { @@ -32,8 +33,9 @@ class SystemZTargetMachine : public LLVMTargetMachine { public: SystemZTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); ~SystemZTargetMachine() override; const SystemZSubtarget *getSubtargetImpl(const Function &) const override; diff --git a/llvm/lib/Target/TargetMachineC.cpp b/llvm/lib/Target/TargetMachineC.cpp index b8cefbe5b6b7f5..b6d238e670504a 100644 --- a/llvm/lib/Target/TargetMachineC.cpp +++ b/llvm/lib/Target/TargetMachineC.cpp @@ -24,6 +24,7 @@ #include "llvm/Target/CodeGenCWrappers.h" #include "llvm/Target/TargetMachine.h" #include +#include using namespace llvm; @@ -124,7 +125,7 @@ LLVMTargetMachineRef LLVMCreateTargetMachine(LLVMTargetRef T, } bool JIT; - Optional CM = unwrap(CodeModel, JIT); + std::optional CM = unwrap(CodeModel, JIT); CodeGenOpt::Level OL; switch (Level) { diff --git a/llvm/lib/Target/VE/VETargetMachine.cpp b/llvm/lib/Target/VE/VETargetMachine.cpp index d7c1457fb0a817..d26210c40317bd 100644 --- a/llvm/lib/Target/VE/VETargetMachine.cpp +++ b/llvm/lib/Target/VE/VETargetMachine.cpp @@ -18,6 +18,7 @@ #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/MC/TargetRegistry.h" +#include using namespace llvm; @@ -80,7 +81,7 @@ VETargetMachine::VETargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options, getEffectiveRelocModel(RM), diff --git a/llvm/lib/Target/VE/VETargetMachine.h b/llvm/lib/Target/VE/VETargetMachine.h index 9cf194444aa53f..7428760bb2f348 100644 --- a/llvm/lib/Target/VE/VETargetMachine.h +++ b/llvm/lib/Target/VE/VETargetMachine.h @@ -16,6 +16,7 @@ #include "VEInstrInfo.h" #include "VESubtarget.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { @@ -29,7 +30,7 @@ class VETargetMachine : public LLVMTargetMachine { public: VETargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, + Optional RM, std::optional CM, CodeGenOpt::Level OL, bool JIT); ~VETargetMachine() override; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index 2200586692b3a4..5fa11fada0ce8a 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -32,6 +32,7 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar/LowerAtomicPass.h" #include "llvm/Transforms/Utils.h" +#include using namespace llvm; #define DEBUG_TYPE "wasm" @@ -109,7 +110,7 @@ static Reloc::Model getEffectiveRelocModel(Optional RM, WebAssemblyTargetMachine::WebAssemblyTargetMachine( const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, CodeGenOpt::Level OL, bool JIT) + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine( T, TT.isArch64Bit() diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h index 5d5378f7656770..92f2f3b77b1c84 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h @@ -17,6 +17,7 @@ #include "WebAssemblySubtarget.h" #include "llvm/Target/TargetMachine.h" +#include namespace llvm { @@ -28,8 +29,8 @@ class WebAssemblyTargetMachine final : public LLVMTargetMachine { WebAssemblyTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, CodeGenOpt::Level OL, - bool JIT); + std::optional CM, + CodeGenOpt::Level OL, bool JIT); ~WebAssemblyTargetMachine() override; diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp index 47bad07e122b78..ee33f48f633c12 100644 --- a/llvm/lib/Target/X86/X86TargetMachine.cpp +++ b/llvm/lib/Target/X86/X86TargetMachine.cpp @@ -51,6 +51,7 @@ #include "llvm/Target/TargetOptions.h" #include "llvm/Transforms/CFGuard.h" #include +#include #include using namespace llvm; @@ -204,8 +205,9 @@ static Reloc::Model getEffectiveRelocModel(const Triple &TT, return *RM; } -static CodeModel::Model getEffectiveX86CodeModel(Optional CM, - bool JIT, bool Is64Bit) { +static CodeModel::Model +getEffectiveX86CodeModel(std::optional CM, bool JIT, + bool Is64Bit) { if (CM) { if (*CM == CodeModel::Tiny) report_fatal_error("Target does not support the tiny CodeModel", false); @@ -222,7 +224,7 @@ X86TargetMachine::X86TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine( T, computeDataLayout(TT), TT, CPU, FS, Options, diff --git a/llvm/lib/Target/X86/X86TargetMachine.h b/llvm/lib/Target/X86/X86TargetMachine.h index 70df8da776413a..62a8c8326229be 100644 --- a/llvm/lib/Target/X86/X86TargetMachine.h +++ b/llvm/lib/Target/X86/X86TargetMachine.h @@ -19,6 +19,7 @@ #include "llvm/Support/CodeGen.h" #include "llvm/Target/TargetMachine.h" #include +#include namespace llvm { @@ -34,8 +35,9 @@ class X86TargetMachine final : public LLVMTargetMachine { public: X86TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); ~X86TargetMachine() override; const X86Subtarget *getSubtargetImpl(const Function &F) const override; diff --git a/llvm/lib/Target/XCore/XCoreTargetMachine.cpp b/llvm/lib/Target/XCore/XCoreTargetMachine.cpp index 3c27fcd9ba535d..f56529a2d57a30 100644 --- a/llvm/lib/Target/XCore/XCoreTargetMachine.cpp +++ b/llvm/lib/Target/XCore/XCoreTargetMachine.cpp @@ -22,6 +22,7 @@ #include "llvm/CodeGen/TargetPassConfig.h" #include "llvm/MC/TargetRegistry.h" #include "llvm/Support/CodeGen.h" +#include using namespace llvm; @@ -30,7 +31,7 @@ static Reloc::Model getEffectiveRelocModel(Optional RM) { } static CodeModel::Model -getEffectiveXCoreCodeModel(Optional CM) { +getEffectiveXCoreCodeModel(std::optional CM) { if (CM) { if (*CM != CodeModel::Small && *CM != CodeModel::Large) report_fatal_error("Target only supports CodeModel Small or Large"); @@ -45,7 +46,7 @@ XCoreTargetMachine::XCoreTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Optional RM, - Optional CM, + std::optional CM, CodeGenOpt::Level OL, bool JIT) : LLVMTargetMachine( T, "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32", diff --git a/llvm/lib/Target/XCore/XCoreTargetMachine.h b/llvm/lib/Target/XCore/XCoreTargetMachine.h index a4754fd77e656c..e612795fc94285 100644 --- a/llvm/lib/Target/XCore/XCoreTargetMachine.h +++ b/llvm/lib/Target/XCore/XCoreTargetMachine.h @@ -19,6 +19,7 @@ #include "llvm/Support/CodeGen.h" #include "llvm/Target/TargetMachine.h" #include +#include namespace llvm { class StringRef; @@ -30,8 +31,9 @@ class XCoreTargetMachine : public LLVMTargetMachine { public: XCoreTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, - Optional RM, Optional CM, - CodeGenOpt::Level OL, bool JIT); + Optional RM, + std::optional CM, CodeGenOpt::Level OL, + bool JIT); ~XCoreTargetMachine() override; const XCoreSubtarget *getSubtargetImpl() const { return &Subtarget; } diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp index da4a98c056f5e9..941b5d8e6d8011 100644 --- a/llvm/tools/llc/llc.cpp +++ b/llvm/tools/llc/llc.cpp @@ -56,6 +56,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Transforms/Utils/Cloning.h" #include +#include using namespace llvm; static codegen::RegisterCodeGenFlags CGF; @@ -520,7 +521,7 @@ static int compileModule(char **argv, LLVMContext &Context) { }; Optional RM = codegen::getExplicitRelocModel(); - Optional CM = codegen::getExplicitCodeModel(); + std::optional CM = codegen::getExplicitCodeModel(); const Target *TheTarget = nullptr; std::unique_ptr Target; @@ -574,7 +575,7 @@ static int compileModule(char **argv, LLVMContext &Context) { if (!TargetTriple.empty()) M->setTargetTriple(Triple::normalize(TargetTriple)); - Optional CM_IR = M->getCodeModel(); + std::optional CM_IR = M->getCodeModel(); if (!CM && CM_IR) Target->setCodeModel(CM_IR.value()); } else {