return static_cast<llvm::CodeModel::Model>(CodeModel);
}
-static TargetMachine::CodeGenFileType getCodeGenFileType(BackendAction Action) {
+static CodeGenFileType getCodeGenFileType(BackendAction Action) {
if (Action == Backend_EmitObj)
- return TargetMachine::CGFT_ObjectFile;
+ return CGFT_ObjectFile;
else if (Action == Backend_EmitMCNull)
- return TargetMachine::CGFT_Null;
+ return CGFT_Null;
else {
assert(Action == Backend_EmitAssembly && "Invalid action!");
- return TargetMachine::CGFT_AssemblyFile;
+ return CGFT_AssemblyFile;
}
}
// Normal mode, emit a .s or .o file by running the code generator. Note,
// this also adds codegenerator level optimization passes.
- TargetMachine::CodeGenFileType CGFT = getCodeGenFileType(Action);
+ CodeGenFileType CGFT = getCodeGenFileType(Action);
// Add ObjC ARC final-cleanup optimizations. This is done as part of the
// "codegen" passes so that it isn't run multiple times when there is
.. code-block:: c++
legacy::PassManager pass;
- auto FileType = TargetMachine::CGFT_ObjectFile;
+ auto FileType = CGFT_ObjectFile;
if (TargetMachine->addPassesToEmitFile(pass, dest, nullptr, FileType)) {
errs() << "TargetMachine can't emit a file of this type";
}
legacy::PassManager pass;
- auto FileType = TargetMachine::CGFT_ObjectFile;
+ auto FileType = CGFT_ObjectFile;
if (TheTargetMachine->addPassesToEmitFile(pass, dest, nullptr, FileType)) {
errs() << "TheTargetMachine can't emit a file of this type";
clEnumValN(ExceptionHandling::Wasm, "wasm",
"WebAssembly exception handling")));
-static cl::opt<TargetMachine::CodeGenFileType> FileType(
- "filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
+static cl::opt<CodeGenFileType> FileType(
+ "filetype", cl::init(CGFT_AssemblyFile),
cl::desc(
"Choose a file type (not all types are supported by all targets):"),
- cl::values(clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm",
+ cl::values(clEnumValN(CGFT_AssemblyFile, "asm",
"Emit an assembly ('.s') file"),
- clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
+ clEnumValN(CGFT_ObjectFile, "obj",
"Emit a native object ('.o') file"),
- clEnumValN(TargetMachine::CGFT_Null, "null",
+ clEnumValN(CGFT_Null, "null",
"Emit nothing, for performance testing")));
static cl::opt<llvm::FramePointer::FP> FramePointerUsage(
splitCodeGen(std::unique_ptr<Module> M, ArrayRef<raw_pwrite_stream *> OSs,
ArrayRef<llvm::raw_pwrite_stream *> BCOSs,
const std::function<std::unique_ptr<TargetMachine>()> &TMFactory,
- TargetMachine::CodeGenFileType FileType = TargetMachine::CGFT_ObjectFile,
+ CodeGenFileType FileType = CGFT_ObjectFile,
bool PreserveLocals = false);
} // namespace llvm
#define LLVM_LTO_CONFIG_H
#include "llvm/IR/DiagnosticInfo.h"
+#include "llvm/IR/LLVMContext.h"
#include "llvm/Support/CodeGen.h"
-#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include <functional>
Optional<Reloc::Model> RelocModel = Reloc::PIC_;
Optional<CodeModel::Model> CodeModel = None;
CodeGenOpt::Level CGOptLevel = CodeGenOpt::Default;
- TargetMachine::CodeGenFileType CGFileType = TargetMachine::CGFT_ObjectFile;
+ CodeGenFileType CGFileType = CGFT_ObjectFile;
unsigned OptLevel = 2;
bool DisableVerify = false;
void setCodePICModel(Optional<Reloc::Model> Model) { RelocModel = Model; }
/// Set the file type to be emitted (assembly or object code).
- /// The default is TargetMachine::CGFT_ObjectFile.
- void setFileType(TargetMachine::CodeGenFileType FT) { FileType = FT; }
+ /// The default is CGFT_ObjectFile.
+ void setFileType(CodeGenFileType FT) { FileType = FT; }
void setCpu(StringRef MCpu) { this->MCpu = MCpu; }
void setAttr(StringRef MAttr) { this->MAttr = MAttr; }
bool ShouldInternalize = EnableLTOInternalization;
bool ShouldEmbedUselists = false;
bool ShouldRestoreGlobalsLinkage = false;
- TargetMachine::CodeGenFileType FileType = TargetMachine::CGFT_ObjectFile;
+ CodeGenFileType FileType = CGFT_ObjectFile;
std::unique_ptr<ToolOutputFile> DiagnosticOutputFile;
bool Freestanding = false;
std::unique_ptr<ToolOutputFile> StatsFile = nullptr;
};
}
+ /// These enums are meant to be passed into addPassesToEmitFile to indicate
+ /// what type of file to emit, and returned by it to indicate what type of
+ /// file could actually be made.
+ enum CodeGenFileType {
+ CGFT_AssemblyFile,
+ CGFT_ObjectFile,
+ CGFT_Null // Do not emit any output.
+ };
+
// Specify effect of frame pointer elimination optimization.
namespace FramePointer {
enum FP {All, NonLeaf, None};
/// PassManagerBuilder::addExtension.
virtual void adjustPassManager(PassManagerBuilder &) {}
- /// These enums are meant to be passed into addPassesToEmitFile to indicate
- /// what type of file to emit, and returned by it to indicate what type of
- /// file could actually be made.
- enum CodeGenFileType {
- CGFT_AssemblyFile,
- CGFT_ObjectFile,
- CGFT_Null // Do not emit any output.
- };
-
/// Add passes to the specified pass manager to get the specified file
/// emitted. Typically this will involve several steps of code generation.
/// This method should return true if emission of this file type is not
static void codegen(Module *M, llvm::raw_pwrite_stream &OS,
function_ref<std::unique_ptr<TargetMachine>()> TMFactory,
- TargetMachine::CodeGenFileType FileType) {
+ CodeGenFileType FileType) {
std::unique_ptr<TargetMachine> TM = TMFactory();
legacy::PassManager CodeGenPasses;
if (TM->addPassesToEmitFile(CodeGenPasses, OS, nullptr, FileType))
std::unique_ptr<Module> M, ArrayRef<llvm::raw_pwrite_stream *> OSs,
ArrayRef<llvm::raw_pwrite_stream *> BCOSs,
const std::function<std::unique_ptr<TargetMachine>()> &TMFactory,
- TargetMachine::CodeGenFileType FileType, bool PreserveLocals) {
+ CodeGenFileType FileType, bool PreserveLocals) {
assert(BCOSs.empty() || BCOSs.size() == OSs.size());
if (OSs.size() == 1) {
int FD;
StringRef Extension
- (FileType == TargetMachine::CGFT_AssemblyFile ? "s" : "o");
+ (FileType == CGFT_AssemblyFile ? "s" : "o");
std::error_code EC =
sys::fs::createTemporaryFile("lto-llvm", Extension, FD, Filename);
PM.add(createObjCARCContractPass());
// Setup the codegen now.
- if (TM.addPassesToEmitFile(PM, OS, nullptr, TargetMachine::CGFT_ObjectFile,
+ if (TM.addPassesToEmitFile(PM, OS, nullptr, CGFT_ObjectFile,
/* DisableVerify */ true))
report_fatal_error("Failed to setup codegen");
Mod->setDataLayout(TM->createDataLayout());
- TargetMachine::CodeGenFileType ft;
+ CodeGenFileType ft;
switch (codegen) {
case LLVMAssemblyFile:
- ft = TargetMachine::CGFT_AssemblyFile;
+ ft = CGFT_AssemblyFile;
break;
default:
- ft = TargetMachine::CGFT_ObjectFile;
+ ft = CGFT_ObjectFile;
break;
}
if (TM->addPassesToEmitFile(pass, OS, nullptr, ft)) {
/* UseInputModulePath */ true));
break;
case options::OT_ASM_ONLY:
- Conf.CGFileType = TargetMachine::CGFT_AssemblyFile;
+ Conf.CGFileType = CGFT_AssemblyFile;
break;
}
OutputFilename = IFN;
switch (FileType) {
- case TargetMachine::CGFT_AssemblyFile:
+ case CGFT_AssemblyFile:
if (TargetName[0] == 'c') {
if (TargetName[1] == 0)
OutputFilename += ".cbe.c";
} else
OutputFilename += ".s";
break;
- case TargetMachine::CGFT_ObjectFile:
+ case CGFT_ObjectFile:
if (OS == Triple::Win32)
OutputFilename += ".obj";
else
OutputFilename += ".o";
break;
- case TargetMachine::CGFT_Null:
+ case CGFT_Null:
OutputFilename += ".null";
break;
}
// Decide if we need "binary" output.
bool Binary = false;
switch (FileType) {
- case TargetMachine::CGFT_AssemblyFile:
+ case CGFT_AssemblyFile:
break;
- case TargetMachine::CGFT_ObjectFile:
- case TargetMachine::CGFT_Null:
+ case CGFT_ObjectFile:
+ case CGFT_Null:
Binary = true;
break;
}
setFunctionAttributes(CPUStr, FeaturesStr, *M);
if (RelaxAll.getNumOccurrences() > 0 &&
- FileType != TargetMachine::CGFT_ObjectFile)
+ FileType != CGFT_ObjectFile)
WithColor::warning(errs(), argv[0])
<< ": warning: ignoring -mc-relax-all because filetype != obj";
// so we can memcmp the contents in CompileTwice mode
SmallVector<char, 0> Buffer;
std::unique_ptr<raw_svector_ostream> BOS;
- if ((FileType != TargetMachine::CGFT_AssemblyFile &&
+ if ((FileType != CGFT_AssemblyFile &&
!Out->os().supportsSeeking()) ||
CompileTwice) {
BOS = std::make_unique<raw_svector_ostream>(Buffer);
TPC->setInitialized();
// AsmPrinter is responsible for generating the assembly into AsmBuffer.
- if (TM->addAsmPrinter(PM, AsmStream, nullptr, TargetMachine::CGFT_ObjectFile,
+ if (TM->addAsmPrinter(PM, AsmStream, nullptr, CGFT_ObjectFile,
MCContext))
report_fatal_error("Cannot add AsmPrinter passes");
TargetLibraryInfoImpl TLII(TM->getTargetTriple());
PM.add(new TargetLibraryInfoWrapperPass(TLII));
raw_null_ostream OS;
- TM->addPassesToEmitFile(PM, OS, nullptr, TargetMachine::CGFT_Null);
+ TM->addPassesToEmitFile(PM, OS, nullptr, CGFT_Null);
PM.run(*M);
return 0;
PM.add(createTargetTransformInfoWrapperPass(TargetM->getTargetIRAnalysis()));
- if (TargetM->addPassesToEmitFile(PM, ASMStream, nullptr,
- TargetMachine::CGFT_AssemblyFile,
+ if (TargetM->addPassesToEmitFile(PM, ASMStream, nullptr, CGFT_AssemblyFile,
true /* verify */)) {
errs() << "The target does not support generation of this file type!\n";
return "";