mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
Kill the Mach-O writer, and temporarily make filetype=obj an error.
The MCStreamer based assemblers will take over for this functionality. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95033 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
54c7788e99
commit
39bdc78e6f
@ -20,18 +20,9 @@ namespace llvm {
|
||||
class ObjectCodeEmitter;
|
||||
class TargetMachine;
|
||||
class raw_ostream;
|
||||
class formatted_raw_ostream;
|
||||
class MachineFunctionPass;
|
||||
class MCAsmInfo;
|
||||
class MCCodeEmitter;
|
||||
|
||||
ObjectCodeEmitter *AddELFWriter(PassManagerBase &FPM, raw_ostream &O,
|
||||
TargetMachine &TM);
|
||||
MachineFunctionPass *createMachOWriter(formatted_raw_ostream &O,
|
||||
TargetMachine &TM,
|
||||
const MCAsmInfo *T,
|
||||
MCCodeEmitter *MCE);
|
||||
|
||||
} // end llvm namespace
|
||||
|
||||
#endif // LLVM_CODEGEN_FILEWRITERS_H
|
||||
|
@ -471,14 +471,6 @@ public:
|
||||
bool addAssemblyEmitter(PassManagerBase &, CodeGenOpt::Level,
|
||||
bool /* VerboseAsmDefault */,
|
||||
formatted_raw_ostream &);
|
||||
|
||||
/// addObjectFileEmitter - Helper function which creates a target specific
|
||||
/// object files emitter, if available. This interface is temporary, for
|
||||
/// bringing up MCAssembler-based object file emitters.
|
||||
///
|
||||
/// \return Returns 'false' on success.
|
||||
bool addObjectFileEmitter(PassManagerBase &, CodeGenOpt::Level,
|
||||
formatted_raw_ostream &);
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -115,10 +115,7 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
||||
return FileModel::Error;
|
||||
return FileModel::AsmFile;
|
||||
case TargetMachine::ObjectFile:
|
||||
if (!addObjectFileEmitter(PM, OptLevel, Out))
|
||||
return FileModel::MachOFile;
|
||||
else if (getELFWriterInfo())
|
||||
return FileModel::ElfFile;
|
||||
return FileModel::Error;
|
||||
}
|
||||
return FileModel::Error;
|
||||
}
|
||||
@ -136,17 +133,6 @@ bool LLVMTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LLVMTargetMachine::addObjectFileEmitter(PassManagerBase &PM,
|
||||
CodeGenOpt::Level OptLevel,
|
||||
formatted_raw_ostream &Out) {
|
||||
MCCodeEmitter *Emitter = getTarget().createCodeEmitter(*this);
|
||||
if (!Emitter)
|
||||
return true;
|
||||
|
||||
PM.add(createMachOWriter(Out, *this, getMCAsmInfo(), Emitter));
|
||||
return false;
|
||||
}
|
||||
|
||||
/// addPassesToEmitFileFinish - If the passes to emit the specified file had to
|
||||
/// be split up (e.g., to add an object writer pass), this method can be used to
|
||||
/// finish up adding passes to emit the file, if necessary.
|
||||
@ -194,8 +180,6 @@ bool LLVMTargetMachine::addPassesToEmitFileFinish(PassManagerBase &PM,
|
||||
// Make sure the code model is set.
|
||||
setCodeModelForStatic();
|
||||
|
||||
if (OCE)
|
||||
addSimpleCodeEmitter(PM, OptLevel, *OCE);
|
||||
if (PrintEmittedAsm)
|
||||
addAssemblyEmitter(PM, OptLevel, true, ferrs());
|
||||
|
||||
|
@ -1,125 +0,0 @@
|
||||
//===-- MachOWriter.cpp - Target-independent Mach-O Writer code -----------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements the target-independent Mach-O writer. This file writes
|
||||
// out the Mach-O file in the following order:
|
||||
//
|
||||
// #1 FatHeader (universal-only)
|
||||
// #2 FatArch (universal-only, 1 per universal arch)
|
||||
// Per arch:
|
||||
// #3 Header
|
||||
// #4 Load Commands
|
||||
// #5 Sections
|
||||
// #6 Relocations
|
||||
// #7 Symbols
|
||||
// #8 Strings
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "MachOWriter.h"
|
||||
#include "llvm/Function.h"
|
||||
#include "llvm/CodeGen/FileWriters.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCCodeEmitter.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Target/Mangler.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetLowering.h"
|
||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||
using namespace llvm;
|
||||
|
||||
namespace llvm {
|
||||
MachineFunctionPass *createMachOWriter(formatted_raw_ostream &O,
|
||||
TargetMachine &TM,
|
||||
const MCAsmInfo *T,
|
||||
MCCodeEmitter *MCE) {
|
||||
return new MachOWriter(O, TM, T, MCE);
|
||||
}
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// MachOWriter Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
char MachOWriter::ID = 0;
|
||||
|
||||
MachOWriter::MachOWriter(formatted_raw_ostream &o, TargetMachine &tm,
|
||||
const MCAsmInfo *T, MCCodeEmitter *MCE)
|
||||
: MachineFunctionPass(&ID), O(o), TM(tm), MAI(T), MCCE(MCE),
|
||||
OutContext(*new MCContext()),
|
||||
OutStreamer(*createMachOStreamer(OutContext, O, MCCE)) {
|
||||
}
|
||||
|
||||
MachOWriter::~MachOWriter() {
|
||||
delete &OutStreamer;
|
||||
delete &OutContext;
|
||||
delete MCCE;
|
||||
}
|
||||
|
||||
bool MachOWriter::doInitialization(Module &M) {
|
||||
// Initialize TargetLoweringObjectFile.
|
||||
TM.getTargetLowering()->getObjFileLowering().Initialize(OutContext, TM);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// doFinalization - Now that the module has been completely processed, emit
|
||||
/// the Mach-O file to 'O'.
|
||||
bool MachOWriter::doFinalization(Module &M) {
|
||||
OutStreamer.Finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MachOWriter::runOnMachineFunction(MachineFunction &MF) {
|
||||
const Function *F = MF.getFunction();
|
||||
TargetLoweringObjectFile &TLOF = TM.getTargetLowering()->getObjFileLowering();
|
||||
const MCSection *S = TLOF.SectionForGlobal(F, Mang, TM);
|
||||
OutStreamer.SwitchSection(S);
|
||||
|
||||
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
||||
I != E; ++I) {
|
||||
// Print a label for the basic block.
|
||||
for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
|
||||
II != IE; ++II) {
|
||||
const MachineInstr *MI = II;
|
||||
MCInst OutMI;
|
||||
OutMI.setOpcode(MI->getOpcode());
|
||||
|
||||
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
||||
const MachineOperand &MO = MI->getOperand(i);
|
||||
MCOperand MCOp;
|
||||
|
||||
switch (MO.getType()) {
|
||||
default:
|
||||
MI->dump();
|
||||
llvm_unreachable("unknown operand type");
|
||||
case MachineOperand::MO_Register:
|
||||
// Ignore all implicit register operands.
|
||||
if (MO.isImplicit()) continue;
|
||||
MCOp = MCOperand::CreateReg(MO.getReg());
|
||||
break;
|
||||
case MachineOperand::MO_Immediate:
|
||||
MCOp = MCOperand::CreateImm(MO.getImm());
|
||||
break;
|
||||
}
|
||||
OutMI.addOperand(MCOp);
|
||||
}
|
||||
|
||||
OutStreamer.EmitInstruction(OutMI);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
//=== MachOWriter.h - Target-independent Mach-O writer support --*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the MachOWriter class.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef MACHOWRITER_H
|
||||
#define MACHOWRITER_H
|
||||
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
|
||||
namespace llvm {
|
||||
class GlobalVariable;
|
||||
class Mangler;
|
||||
class MCCodeEmitter;
|
||||
class MCContext;
|
||||
class MCStreamer;
|
||||
|
||||
/// MachOWriter - This class implements the common target-independent code for
|
||||
/// writing Mach-O files. Targets should derive a class from this to
|
||||
/// parameterize the output format.
|
||||
///
|
||||
class MachOWriter : public MachineFunctionPass {
|
||||
static char ID;
|
||||
|
||||
protected:
|
||||
/// Output stream to send the resultant object file to.
|
||||
///
|
||||
formatted_raw_ostream &O;
|
||||
|
||||
/// Target machine description.
|
||||
///
|
||||
TargetMachine &TM;
|
||||
|
||||
/// Target Asm Printer information.
|
||||
///
|
||||
const MCAsmInfo *MAI;
|
||||
|
||||
/// MCCE - The MCCodeEmitter object that we are exposing to emit machine
|
||||
/// code for functions to the .o file.
|
||||
MCCodeEmitter *MCCE;
|
||||
|
||||
/// OutContext - This is the context for the output file that we are
|
||||
/// streaming. This owns all of the global MC-related objects for the
|
||||
/// generated translation unit.
|
||||
MCContext &OutContext;
|
||||
|
||||
/// OutStreamer - This is the MCStreamer object for the file we are
|
||||
/// generating. This contains the transient state for the current
|
||||
/// translation unit that we are generating (such as the current section
|
||||
/// etc).
|
||||
MCStreamer &OutStreamer;
|
||||
|
||||
/// Name-mangler for global names.
|
||||
///
|
||||
Mangler *Mang;
|
||||
|
||||
/// doInitialization - Emit the file header and all of the global variables
|
||||
/// for the module to the Mach-O file.
|
||||
bool doInitialization(Module &M);
|
||||
|
||||
/// doFinalization - Now that the module has been completely processed, emit
|
||||
/// the Mach-O file to 'O'.
|
||||
bool doFinalization(Module &M);
|
||||
|
||||
bool runOnMachineFunction(MachineFunction &MF);
|
||||
|
||||
public:
|
||||
explicit MachOWriter(formatted_raw_ostream &O, TargetMachine &TM,
|
||||
const MCAsmInfo *T, MCCodeEmitter *MCE);
|
||||
|
||||
virtual ~MachOWriter();
|
||||
|
||||
virtual const char *getPassName() const {
|
||||
return "Mach-O Writer";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -23,7 +23,6 @@
|
||||
#include "llvm/CodeGen/FileWriters.h"
|
||||
#include "llvm/CodeGen/LinkAllAsmWriterComponents.h"
|
||||
#include "llvm/CodeGen/LinkAllCodegenComponents.h"
|
||||
#include "llvm/CodeGen/ObjectCodeEmitter.h"
|
||||
#include "llvm/Config/config.h"
|
||||
#include "llvm/LinkAllVMCore.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
@ -346,9 +345,6 @@ int main(int argc, char **argv) {
|
||||
Passes.add(createVerifierPass());
|
||||
#endif
|
||||
|
||||
// Ask the target to add backend passes as necessary.
|
||||
ObjectCodeEmitter *OCE = 0;
|
||||
|
||||
// Override default to generate verbose assembly.
|
||||
Target.setAsmVerbosityDefault(true);
|
||||
|
||||
@ -364,14 +360,10 @@ int main(int argc, char **argv) {
|
||||
sys::Path(OutputFilename).eraseFromDisk();
|
||||
return 1;
|
||||
case FileModel::AsmFile:
|
||||
case FileModel::MachOFile:
|
||||
break;
|
||||
case FileModel::ElfFile:
|
||||
OCE = AddELFWriter(Passes, *Out, Target);
|
||||
break;
|
||||
}
|
||||
|
||||
if (Target.addPassesToEmitFileFinish(Passes, OCE, OLvl)) {
|
||||
if (Target.addPassesToEmitFileFinish(Passes, (ObjectCodeEmitter *)0, OLvl)){
|
||||
errs() << argv[0] << ": target does not support generation of this"
|
||||
<< " file type!\n";
|
||||
if (Out != &fouts()) delete Out;
|
||||
|
Loading…
Reference in New Issue
Block a user