diff --git a/llvm/include/llvm/Support/Yk.h b/llvm/include/llvm/Support/Yk.h new file mode 100644 index 00000000000000..9057ee5a208a76 --- /dev/null +++ b/llvm/include/llvm/Support/Yk.h @@ -0,0 +1,8 @@ +#ifndef __LLVM_SUPPORT_YK_H +#define __LLVM_SUPPORT_YK_H + +namespace llvm { +void initYkOptions(void); +} // namespace llvm + +#endif diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 66632504d6fb61..26a412e2b9de9a 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -40,6 +40,7 @@ #include "llvm/Support/Process.h" #include "llvm/Support/StringSaver.h" #include "llvm/Support/VirtualFileSystem.h" +#include "llvm/Support/Yk.h" #include "llvm/Support/raw_ostream.h" #include #include @@ -2672,6 +2673,7 @@ static void initCommonOptions() { initWithColorOptions(); initDebugOptions(); initRandomSeedOptions(); + initYkOptions(); } OptionCategory &cl::getGeneralCategory() { diff --git a/llvm/lib/Support/Yk.cpp b/llvm/lib/Support/Yk.cpp index cf8180c589d082..e19d05d14cfd02 100644 --- a/llvm/lib/Support/Yk.cpp +++ b/llvm/lib/Support/Yk.cpp @@ -1,41 +1,106 @@ +#include "llvm/Support/Yk.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ManagedStatic.h" using namespace llvm; bool YkAllocLLVMBCSection; -static cl::opt YkAllocLLVMBCSectionParser( - "yk-alloc-llvmbc-section", cl::desc("Make the `.llvmbc` section loadable"), - cl::NotHidden, cl::location(YkAllocLLVMBCSection)); +namespace { +struct CreateYkAllocLLVMBCSectionParser { + static void *call() { + return new cl::opt( + "yk-alloc-llvmbc-section", + cl::desc("Make the `.llvmbc` section loadable"), cl::NotHidden, + cl::location(YkAllocLLVMBCSection)); + } +}; +} // namespace +static ManagedStatic, CreateYkAllocLLVMBCSectionParser> + YkAllocLLVMBCSectionParser; bool YkAllocLLVMBBAddrMapSection; -static cl::opt YkAllocLLVMBBAddrMapSectionParser( - "yk-alloc-llvmbbaddrmap-section", - cl::desc("Make the `.llvmbbaddrmap` section loadable"), cl::NotHidden, - cl::location(YkAllocLLVMBBAddrMapSection)); +namespace { +struct CreateYkAllocLLVMBBAddrMapSectionParser { + static void *call() { + return new cl::opt( + "yk-alloc-llvmbbaddrmap-section", + cl::desc("Make the `.llvmbbaddrmap` section loadable"), cl::NotHidden, + cl::location(YkAllocLLVMBBAddrMapSection)); + } +}; +} // namespace +static ManagedStatic, + CreateYkAllocLLVMBBAddrMapSectionParser> + YkAllocLLVMBBAddrMapSectionParser; bool YkExtendedLLVMBBAddrMapSection; -static cl::opt YkExtendedLLVMBBAddrMapSectionParser( - "yk-extended-llvmbbaddrmap-section", - cl::desc("Use the extended Yk `.llvmbbaddrmap` section format"), - cl::NotHidden, cl::location(YkExtendedLLVMBBAddrMapSection)); +namespace { +struct CreateYkExtendedLLVMBBAddrMapSectionParser { + static void *call() { + return new cl::opt( + "yk-extended-llvmbbaddrmap-section", + cl::desc("Use the extended Yk `.llvmbbaddrmap` section format"), + cl::NotHidden, cl::location(YkExtendedLLVMBBAddrMapSection)); + } +}; +} // namespace +static ManagedStatic, + CreateYkExtendedLLVMBBAddrMapSectionParser> + YkExtendedLLVMBBAddrMapSectionParser; bool YkStackMapOffsetFix; -static cl::opt YkStackMapOffsetFixParser( - "yk-stackmap-offset-fix", - cl::desc("Apply a fix to stackmaps that corrects the reported instruction " - "offset in the presence of calls. (deprecated by " - "yk-stackmap-spillreloads-fix)"), - cl::NotHidden, cl::location(YkStackMapOffsetFix)); +namespace { +struct CreateYkStackMapOffsetFixParser { + static void *call() { + return new cl::opt( + "yk-stackmap-offset-fix", + cl::desc( + "Apply a fix to stackmaps that corrects the reported instruction " + "offset in the presence of calls. (deprecated by " + "yk-stackmap-spillreloads-fix)"), + cl::NotHidden, cl::location(YkStackMapOffsetFix)); + } +}; +} // namespace +static ManagedStatic, CreateYkStackMapOffsetFixParser> + YkStackMapOffsetFixParser; bool YkStackMapAdditionalLocs; -static cl::opt YkStackMapAdditionalLocsParser( - "yk-stackmap-add-locs", - cl::desc("Encode additional locations for registers into stackmaps."), - cl::NotHidden, cl::location(YkStackMapAdditionalLocs)); +namespace { +struct CreateYkStackMapAdditionalLocsParser { + static void *call() { + return new cl::opt( + "yk-stackmap-add-locs", + cl::desc("Encode additional locations for registers into stackmaps."), + cl::NotHidden, cl::location(YkStackMapAdditionalLocs)); + } +}; +} // namespace +static ManagedStatic, CreateYkStackMapAdditionalLocsParser> + YkStackMapAdditionalLocsParser; bool YkStackmapsSpillReloadsFix; -static cl::opt YkStackMapSpillFixParser( - "yk-stackmap-spillreloads-fix", - cl::desc("Revert stackmaps and its operands after the register allocator " - "has emitted spill reloads."), - cl::NotHidden, cl::location(YkStackmapsSpillReloadsFix)); +namespace { +struct CreateYkStackmapsSpillReloadsFixParser { + static void *call() { + return new cl::opt( + "yk-stackmap-spillreloads-fix", + cl::desc( + "Revert stackmaps and its operands after the register allocator " + "has emitted spill reloads."), + cl::NotHidden, cl::location(YkStackmapsSpillReloadsFix)); + } +}; +} // namespace +static ManagedStatic, + CreateYkStackmapsSpillReloadsFixParser> + YkStackmapsSpillFixParser; + +void llvm::initYkOptions() { + *YkAllocLLVMBCSectionParser; + *YkAllocLLVMBBAddrMapSectionParser; + *YkExtendedLLVMBBAddrMapSectionParser; + *YkStackMapOffsetFixParser; + *YkStackMapAdditionalLocsParser; + *YkStackmapsSpillFixParser; +}