LLVM 24.0.0git
llvm::codegen Namespace Reference

Enumerations

enum  SaveStatsMode { None , Cwd , Obj }

Functions

LLVM_ABI std::string getMArch (const cl::LibraryOptionsContext &C)
LLVM_ABI std::string getMCPU (const cl::LibraryOptionsContext &C)
LLVM_ABI std::string getMTune (const cl::LibraryOptionsContext &C)
LLVM_ABI std::vector< std::string > getMAttrs (const cl::LibraryOptionsContext &C)
LLVM_ABI std::optional< Reloc::Model > getExplicitRelocModel (const cl::LibraryOptionsContext &C)
LLVM_ABI std::optional< CodeModel::Model > getExplicitCodeModel (const cl::LibraryOptionsContext &C)
LLVM_ABI std::optional< uint64_t > getExplicitLargeDataThreshold (const cl::LibraryOptionsContext &C)
LLVM_ABI std::optional< CodeGenFileType > getExplicitFileType (const cl::LibraryOptionsContext &C)
LLVM_ABI CodeGenFileType getFileType (const cl::LibraryOptionsContext &C)
LLVM_ABI llvm::FloatABI::ABIType getFloatABIForCalls (const cl::LibraryOptionsContext &C)
LLVM_ABI std::optional< bool > getExplicitDataSections (const cl::LibraryOptionsContext &C)
LLVM_ABI std::optional< bool > getExplicitFunctionSections (const cl::LibraryOptionsContext &C)
LLVM_ABI std::optional< bool > getExplicitEmulatedTLS (const cl::LibraryOptionsContext &C)
LLVM_ABI SaveStatsMode getSaveStats (const cl::LibraryOptionsContext &C)
LLVM_ABI ArrayRef< const cl::LibraryOptions * > getToolOptions ()
 The options that a tool reading getTargetOptions passes to cl::parseCommandLineOptions.
LLVM_ABI TargetOptions getTargetOptions (const cl::LibraryOptionsContext &LibraryOptions, const llvm::Triple &TheTriple)
 Common utility function tightly tied to the options listed here.
LLVM_ABI std::string getCPUStr (const cl::LibraryOptionsContext &C)
LLVM_ABI std::string getTuneCPUStr (const cl::LibraryOptionsContext &C)
LLVM_ABI std::string getFeaturesStr (const cl::LibraryOptionsContext &C)
LLVM_ABI std::vector< std::string > getFeatureList (const cl::LibraryOptionsContext &C)
LLVM_ABI void renderBoolStringAttr (AttrBuilder &B, StringRef Name, bool Val)
LLVM_ABI void setFunctionAttributes (Function &F, StringRef CPU, StringRef Features, StringRef TuneCPU="")
 Set function attributes of function F based on CPU, TuneCPU, Features, and command line flags.
LLVM_ABI void setFunctionAttributes (Module &M, StringRef CPU, StringRef Features, StringRef TuneCPU="")
 Set function attributes of functions in Module M based on CPU, TuneCPU, Features, and command line flags.
LLVM_ABI Expected< std::unique_ptr< TargetMachine > > createTargetMachineForTriple (const cl::LibraryOptionsContext &LibraryOptions, const Triple &TargetTriple, CodeGenOptLevel OptLevel=CodeGenOptLevel::Default)
 Creates a TargetMachine instance with the options defined on the command line.
LLVM_ABI void maybeEnableStatistics (const cl::LibraryOptionsContext &C)
 Conditionally enables the collection of LLVM statistics during the tool run, based on the value of the flag.
LLVM_ABI int maybeSaveStatistics (const cl::LibraryOptionsContext &C, StringRef OutputFilename, StringRef ToolName)
 Conditionally saves the collected LLVM statistics to the received output file, based on the value of the flag.

Enumeration Type Documentation

◆ SaveStatsMode

Enumerator
None 
Cwd 
Obj 

Definition at line 74 of file CommandFlags.h.

Function Documentation

◆ createTargetMachineForTriple()

Expected< std::unique_ptr< TargetMachine > > llvm::codegen::createTargetMachineForTriple ( const cl::LibraryOptionsContext & LibraryOptions,
const Triple & TargetTriple,
CodeGenOptLevel OptLevel = CodeGenOptLevel::Default )

◆ getCPUStr()

std::string llvm::codegen::getCPUStr ( const cl::LibraryOptionsContext & C)

Definition at line 196 of file CommandFlags.cpp.

References C(), getCPUStr(), llvm::sys::getHostCPUName(), and getMCPU().

Referenced by createTargetMachineForTriple(), and getCPUStr().

◆ getExplicitCodeModel()

std::optional< CodeModel::Model > llvm::codegen::getExplicitCodeModel ( const cl::LibraryOptionsContext & C)

Definition at line 75 of file CommandFlags.cpp.

References C(), and getExplicitCodeModel().

Referenced by createTargetMachineForTriple(), and getExplicitCodeModel().

◆ getExplicitDataSections()

std::optional< bool > llvm::codegen::getExplicitDataSections ( const cl::LibraryOptionsContext & C)

Definition at line 99 of file CommandFlags.cpp.

References C(), getExplicitDataSections(), and llvm::toOptional().

Referenced by getExplicitDataSections(), and initTMBuilder().

◆ getExplicitEmulatedTLS()

std::optional< bool > llvm::codegen::getExplicitEmulatedTLS ( const cl::LibraryOptionsContext & C)

Definition at line 109 of file CommandFlags.cpp.

References C(), getExplicitEmulatedTLS(), and llvm::toOptional().

Referenced by getExplicitEmulatedTLS().

◆ getExplicitFileType()

std::optional< CodeGenFileType > llvm::codegen::getExplicitFileType ( const cl::LibraryOptionsContext & C)

Definition at line 85 of file CommandFlags.cpp.

References C(), and getExplicitFileType().

Referenced by getExplicitFileType(), and getFileType().

◆ getExplicitFunctionSections()

std::optional< bool > llvm::codegen::getExplicitFunctionSections ( const cl::LibraryOptionsContext & C)

Definition at line 104 of file CommandFlags.cpp.

References C(), getExplicitFunctionSections(), and llvm::toOptional().

Referenced by getExplicitFunctionSections().

◆ getExplicitLargeDataThreshold()

std::optional< uint64_t > llvm::codegen::getExplicitLargeDataThreshold ( const cl::LibraryOptionsContext & C)

Definition at line 80 of file CommandFlags.cpp.

References C(), and getExplicitLargeDataThreshold().

Referenced by getExplicitLargeDataThreshold().

◆ getExplicitRelocModel()

std::optional< Reloc::Model > llvm::codegen::getExplicitRelocModel ( const cl::LibraryOptionsContext & C)

Definition at line 70 of file CommandFlags.cpp.

References C(), and getExplicitRelocModel().

Referenced by createTargetMachineForTriple(), and getExplicitRelocModel().

◆ getFeatureList()

std::vector< std::string > llvm::codegen::getFeatureList ( const cl::LibraryOptionsContext & C)

◆ getFeaturesStr()

◆ getFileType()

CodeGenFileType llvm::codegen::getFileType ( const cl::LibraryOptionsContext & C)

Definition at line 89 of file CommandFlags.cpp.

References llvm::AssemblyFile, C(), getExplicitFileType(), and getFileType().

Referenced by getFileType().

◆ getFloatABIForCalls()

FloatABI::ABIType llvm::codegen::getFloatABIForCalls ( const cl::LibraryOptionsContext & C)

Definition at line 94 of file CommandFlags.cpp.

References C(), and getFloatABIForCalls().

Referenced by getFloatABIForCalls(), and setFunctionAttributes().

◆ getMArch()

std::string llvm::codegen::getMArch ( const cl::LibraryOptionsContext & C)

Definition at line 55 of file CommandFlags.cpp.

References C(), and getMArch().

Referenced by createTargetMachineForTriple(), and getMArch().

◆ getMAttrs()

std::vector< std::string > llvm::codegen::getMAttrs ( const cl::LibraryOptionsContext & C)

◆ getMCPU()

std::string llvm::codegen::getMCPU ( const cl::LibraryOptionsContext & C)

Definition at line 59 of file CommandFlags.cpp.

References C(), and getMCPU().

Referenced by getCPUStr(), getFeatureList(), getFeaturesStr(), and getMCPU().

◆ getMTune()

std::string llvm::codegen::getMTune ( const cl::LibraryOptionsContext & C)

Definition at line 113 of file CommandFlags.cpp.

References C(), and getMTune().

Referenced by getMTune(), and getTuneCPUStr().

◆ getSaveStats()

codegen::SaveStatsMode llvm::codegen::getSaveStats ( const cl::LibraryOptionsContext & C)

Definition at line 118 of file CommandFlags.cpp.

References C(), and getSaveStats().

Referenced by getSaveStats(), maybeEnableStatistics(), and maybeSaveStatistics().

◆ getTargetOptions()

TargetOptions llvm::codegen::getTargetOptions ( const cl::LibraryOptionsContext & LibraryOptions,
const llvm::Triple & TheTriple )

Common utility function tightly tied to the options listed here.

Initializes a TargetOptions object with CodeGen options and returns it. TheTriple is used to determine the default value for options if options are not explicitly specified. If those triple dependant options value do not have effect for your component, a default Triple() could be passed in.

Definition at line 153 of file CommandFlags.cpp.

References llvm::cl::LibraryOptionsContext::get(), getBBSectionsMode(), llvm::mc::getMCTargetOptions(), getTargetOptions(), llvm::Triple::hasDefaultDataSections(), llvm::Triple::hasDefaultEmulatedTLS(), llvm::Triple::hasDefaultTLSDESC(), Options, and llvm::valueOr().

Referenced by createTargetMachineForTriple(), and getTargetOptions().

◆ getToolOptions()

ArrayRef< const cl::LibraryOptions * > llvm::codegen::getToolOptions ( )

The options that a tool reading getTargetOptions passes to cl::parseCommandLineOptions.

Definition at line 122 of file CommandFlags.cpp.

References assert(), getToolOptions(), llvm::mc::getToolOptions(), and llvm::size().

Referenced by getToolOptions(), and llvm::LTOCodeGenerator::parseCodeGenDebugOptions().

◆ getTuneCPUStr()

std::string llvm::codegen::getTuneCPUStr ( const cl::LibraryOptionsContext & C)

Definition at line 208 of file CommandFlags.cpp.

References C(), llvm::sys::getHostCPUName(), getMTune(), and getTuneCPUStr().

Referenced by getTuneCPUStr().

◆ maybeEnableStatistics()

void llvm::codegen::maybeEnableStatistics ( const cl::LibraryOptionsContext & C)

Conditionally enables the collection of LLVM statistics during the tool run, based on the value of the flag.

Must be called before the tool run to actually collect data.

Definition at line 407 of file CommandFlags.cpp.

References C(), llvm::EnableStatistics(), getSaveStats(), maybeEnableStatistics(), and None.

Referenced by maybeEnableStatistics().

◆ maybeSaveStatistics()

int llvm::codegen::maybeSaveStatistics ( const cl::LibraryOptionsContext & C,
StringRef OutputFilename,
StringRef ToolName )

Conditionally saves the collected LLVM statistics to the received output file, based on the value of the flag.

Should be called after the tool run, and must follow a call to maybeEnableStatistics() to actually have data to write.

Definition at line 414 of file CommandFlags.cpp.

References llvm::sys::path::append(), assert(), C(), Cwd, llvm::WithColor::error(), llvm::errs(), llvm::sys::path::filename(), getSaveStats(), maybeSaveStatistics(), None, Obj, llvm::sys::fs::OF_TextWithCRLF, OutputFilename, llvm::PrintStatisticsJSON(), llvm::sys::path::remove_filename(), and llvm::sys::path::replace_extension().

Referenced by maybeSaveStatistics().

◆ renderBoolStringAttr()

void llvm::codegen::renderBoolStringAttr ( AttrBuilder & B,
StringRef Name,
bool Val )

Definition at line 255 of file CommandFlags.cpp.

References B(), and renderBoolStringAttr().

Referenced by renderBoolStringAttr().

◆ setFunctionAttributes() [1/2]

◆ setFunctionAttributes() [2/2]

void llvm::codegen::setFunctionAttributes ( Module & M,
StringRef CPU,
StringRef Features,
StringRef TuneCPU = "" )