diff options
author | Wesley Peck <peckw@wesleypeck.com> | 2010-10-21 03:34:22 +0000 |
---|---|---|
committer | Wesley Peck <peckw@wesleypeck.com> | 2010-10-21 03:34:22 +0000 |
commit | 60e7127e862e359eb1b4694e5161da6dc4c2c397 (patch) | |
tree | 3b7b7f394b741cfd7b592c76909062d7a30623a7 /lib/Target | |
parent | d9707e3d852622197133a73dcb788a7fcd364015 (diff) |
Reverting the commit 116986. It was breaking the build on llvm-x86_64-linux though it
compiles on OS X. I'll ensure that it builds on a linux machine before committing
again.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116991 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
29 files changed, 603 insertions, 1833 deletions
diff --git a/lib/Target/MBlaze/AsmPrinter/CMakeLists.txt b/lib/Target/MBlaze/AsmPrinter/CMakeLists.txt new file mode 100644 index 0000000000..fac2c1959d --- /dev/null +++ b/lib/Target/MBlaze/AsmPrinter/CMakeLists.txt @@ -0,0 +1,9 @@ +include_directories( + ${CMAKE_CURRENT_BINARY_DIR}/.. + ${CMAKE_CURRENT_SOURCE_DIR}/.. + ) + +add_llvm_library(LLVMMBlazeAsmPrinter + MBlazeAsmPrinter.cpp + ) +add_dependencies(LLVMMBlazeAsmPrinter MBlazeCodeGenTable_gen) diff --git a/lib/Target/MBlaze/MBlazeAsmPrinter.cpp b/lib/Target/MBlaze/AsmPrinter/MBlazeAsmPrinter.cpp index c1ae4502ad..f4b30ad271 100644 --- a/lib/Target/MBlaze/MBlazeAsmPrinter.cpp +++ b/lib/Target/MBlaze/AsmPrinter/MBlazeAsmPrinter.cpp @@ -19,8 +19,6 @@ #include "MBlazeInstrInfo.h" #include "MBlazeTargetMachine.h" #include "MBlazeMachineFunction.h" -#include "MBlazeMCInstLower.h" -#include "InstPrinter/MBlazeInstPrinter.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" @@ -29,7 +27,6 @@ #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/MC/MCInst.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCSymbol.h" @@ -72,15 +69,22 @@ namespace { void emitFrameDirective(); - void EmitInstruction(const MachineInstr *MI); + void printInstruction(const MachineInstr *MI, raw_ostream &O); + void EmitInstruction(const MachineInstr *MI) { + SmallString<128> Str; + raw_svector_ostream OS(Str); + printInstruction(MI, OS); + OutStreamer.EmitRawText(OS.str()); + } virtual void EmitFunctionBodyStart(); virtual void EmitFunctionBodyEnd(); + static const char *getRegisterName(unsigned RegNo); virtual void EmitFunctionEntryLabel(); }; } // end of anonymous namespace -// #include "MBlazeGenAsmWriter.inc" +#include "MBlazeGenAsmWriter.inc" //===----------------------------------------------------------------------===// // @@ -114,15 +118,6 @@ namespace { //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// -void MBlazeAsmPrinter::EmitInstruction(const MachineInstr *MI) { - MBlazeMCInstLower MCInstLowering(OutContext, *Mang, *this); - - MCInst TmpInst; - MCInstLowering.Lower(MI, TmpInst); - OutStreamer.EmitInstruction(TmpInst); -} - -//===----------------------------------------------------------------------===// // Mask directives //===----------------------------------------------------------------------===// @@ -173,41 +168,38 @@ void MBlazeAsmPrinter::printSavedRegsBitmask(raw_ostream &O) { /// Frame Directive void MBlazeAsmPrinter::emitFrameDirective() { - // const TargetRegisterInfo &RI = *TM.getRegisterInfo(); + const TargetRegisterInfo &RI = *TM.getRegisterInfo(); - // unsigned stackReg = RI.getFrameRegister(*MF); - // unsigned returnReg = RI.getRARegister(); - // unsigned stackSize = MF->getFrameInfo()->getStackSize(); + unsigned stackReg = RI.getFrameRegister(*MF); + unsigned returnReg = RI.getRARegister(); + unsigned stackSize = MF->getFrameInfo()->getStackSize(); - /* - OutStreamer.EmitRawText("\t.frame\t" + - Twine(MBlazeInstPrinter::getRegisterName(stackReg)) + + OutStreamer.EmitRawText("\t.frame\t" + Twine(getRegisterName(stackReg)) + "," + Twine(stackSize) + "," + - Twine(MBlazeInstPrinter::getRegisterName(returnReg))); - */ + Twine(getRegisterName(returnReg))); } void MBlazeAsmPrinter::EmitFunctionEntryLabel() { - // OutStreamer.EmitRawText("\t.ent\t" + Twine(CurrentFnSym->getName())); + OutStreamer.EmitRawText("\t.ent\t" + Twine(CurrentFnSym->getName())); OutStreamer.EmitLabel(CurrentFnSym); } /// EmitFunctionBodyStart - Targets can override this to emit stuff before /// the first basic block in the function. void MBlazeAsmPrinter::EmitFunctionBodyStart() { - // emitFrameDirective(); + emitFrameDirective(); - // SmallString<128> Str; - // raw_svector_ostream OS(Str); - // printSavedRegsBitmask(OS); - // OutStreamer.EmitRawText(OS.str()); + SmallString<128> Str; + raw_svector_ostream OS(Str); + printSavedRegsBitmask(OS); + OutStreamer.EmitRawText(OS.str()); } /// EmitFunctionBodyEnd - Targets can override this to emit stuff after /// the last basic block in the function. void MBlazeAsmPrinter::EmitFunctionBodyEnd() { - // OutStreamer.EmitRawText("\t.end\t" + Twine(CurrentFnSym->getName())); + OutStreamer.EmitRawText("\t.end\t" + Twine(CurrentFnSym->getName())); } // Print out an operand for an inline asm expression. @@ -228,7 +220,7 @@ void MBlazeAsmPrinter::printOperand(const MachineInstr *MI, int opNum, switch (MO.getType()) { case MachineOperand::MO_Register: - O << MBlazeInstPrinter::getRegisterName(MO.getReg()); + O << getRegisterName(MO.getReg()); break; case MachineOperand::MO_Immediate: @@ -256,7 +248,7 @@ void MBlazeAsmPrinter::printOperand(const MachineInstr *MI, int opNum, case MachineOperand::MO_JumpTableIndex: O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() - << '_' << MO.getIndex(); + << '_' << MO.getIndex(); break; case MachineOperand::MO_ConstantPoolIndex: @@ -297,18 +289,7 @@ printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O, printOperand(MI, opNum, O); } -static MCInstPrinter *createMBlazeMCInstPrinter(const Target &T, - unsigned SyntaxVariant, - const MCAsmInfo &MAI) { - if (SyntaxVariant == 0) - return new MBlazeInstPrinter(MAI); - return 0; -} - // Force static initialization. extern "C" void LLVMInitializeMBlazeAsmPrinter() { RegisterAsmPrinter<MBlazeAsmPrinter> X(TheMBlazeTarget); - TargetRegistry::RegisterMCInstPrinter(TheMBlazeTarget, - createMBlazeMCInstPrinter); - } diff --git a/lib/Target/MBlaze/InstPrinter/Makefile b/lib/Target/MBlaze/AsmPrinter/Makefile index 9fb6e869d9..c44651cc93 100644 --- a/lib/Target/MBlaze/InstPrinter/Makefile +++ b/lib/Target/MBlaze/AsmPrinter/Makefile @@ -6,11 +6,12 @@ # License. See LICENSE.TXT for details. # ##===----------------------------------------------------------------------===## + LEVEL = ../../../.. LIBRARYNAME = LLVMMBlazeAsmPrinter # Hack: we need to include 'main' MBlaze target directory to grab -# private headers +# private headers CPP.Flags += -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/.. include $(LEVEL)/Makefile.common diff --git a/lib/Target/MBlaze/CMakeLists.txt b/lib/Target/MBlaze/CMakeLists.txt index eb5906e1e7..7b470eec2b 100644 --- a/lib/Target/MBlaze/CMakeLists.txt +++ b/lib/Target/MBlaze/CMakeLists.txt @@ -5,7 +5,6 @@ tablegen(MBlazeGenRegisterNames.inc -gen-register-enums) tablegen(MBlazeGenRegisterInfo.inc -gen-register-desc) tablegen(MBlazeGenInstrNames.inc -gen-instr-enums) tablegen(MBlazeGenInstrInfo.inc -gen-instr-desc) -tablegen(MBlazeGenCodeEmitter.inc -gen-emitter) tablegen(MBlazeGenAsmWriter.inc -gen-asm-writer) tablegen(MBlazeGenDAGISel.inc -gen-dag-isel) tablegen(MBlazeGenCallingConv.inc -gen-callingconv) @@ -24,9 +23,4 @@ add_llvm_target(MBlazeCodeGen MBlazeTargetObjectFile.cpp MBlazeIntrinsicInfo.cpp MBlazeSelectionDAGInfo.cpp - MBlazeAsmPrinter.cpp - MBlazeAsmBackend.cpp - MBlazeMCInstLower.cpp - MBlazeELFWriterInfo.cpp - MBlazeMCCodeEmitter.cpp ) diff --git a/lib/Target/MBlaze/InstPrinter/CMakeLists.txt b/lib/Target/MBlaze/InstPrinter/CMakeLists.txt deleted file mode 100644 index 242a573036..0000000000 --- a/lib/Target/MBlaze/InstPrinter/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. - ${CMAKE_CURRENT_SOURCE_DIR}/.. ) - -add_llvm_library(LLVMMBlazeAsmPrinter - MBlazeInstPrinter.cpp - ) - -add_dependencies(LLVMMBlazeAsmPrinter MBlazeCodeGenTable_gen) diff --git a/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp b/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp deleted file mode 100644 index 4c59b549ee..0000000000 --- a/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.cpp +++ /dev/null @@ -1,140 +0,0 @@ -//===-- MBlazeInstPrinter.cpp - Convert MBlaze MCInst to assembly syntax --===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This class prints an MBlaze MCInst to a .s file. -// -//===----------------------------------------------------------------------===// - -#define DEBUG_TYPE "asm-printer" -#include "MBlaze.h" -#include "MBlazeInstPrinter.h" -#include "llvm/MC/MCInst.h" -#include "llvm/MC/MCAsmInfo.h" -#include "llvm/MC/MCExpr.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/FormattedStream.h" -using namespace llvm; - - -// Include the auto-generated portion of the assembly writer. -#include "MBlazeGenAsmWriter.inc" - -void MBlazeInstPrinter::printInst(const MCInst *MI, raw_ostream &O) { - printInstruction(MI, O); -} - -void MBlazeInstPrinter::printPCRelImmOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) { - const MCOperand &Op = MI->getOperand(OpNo); - if (Op.isImm()) - O << Op.getImm(); - else { - assert(Op.isExpr() && "unknown pcrel immediate operand"); - O << *Op.getExpr(); - } -} - -void MBlazeInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O, const char *Modifier) { - assert((Modifier == 0 || Modifier[0] == 0) && "No modifiers supported"); - const MCOperand &Op = MI->getOperand(OpNo); - if (Op.isReg()) { - O << getRegisterName(Op.getReg()); - } else if (Op.isImm()) { - O << (int32_t)Op.getImm(); - } else { - assert(Op.isExpr() && "unknown operand kind in printOperand"); - O << *Op.getExpr(); - } -} - -void MBlazeInstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O, - const char *Modifier) { - const MCOperand &Base = MI->getOperand(OpNo); - const MCOperand &Disp = MI->getOperand(OpNo+1); - - // Print displacement first - - // If the global address expression is a part of displacement field with a - // register base, we should not emit any prefix symbol here, e.g. - // mov.w &foo, r1 - // vs - // mov.w glb(r1), r2 - // Otherwise (!) msp430-as will silently miscompile the output :( - if (!Base.getReg()) - O << '&'; - - if (Disp.isExpr()) - O << *Disp.getExpr(); - else { - assert(Disp.isImm() && "Expected immediate in displacement field"); - O << Disp.getImm(); - } - - // Print register base field - if (Base.getReg()) - O << getRegisterName(Base.getReg()); -} - -void MBlazeInstPrinter::printFSLImm(const MCInst *MI, int OpNo, - raw_ostream &O) { - const MCOperand &MO = MI->getOperand(OpNo); - if (MO.isImm()) - O << "rfsl" << MO.getImm(); - else - printOperand(MI, OpNo, O, NULL); -} - -void MBlazeInstPrinter::printUnsignedImm(const MCInst *MI, int OpNo, - raw_ostream &O) { - const MCOperand &MO = MI->getOperand(OpNo); - if (MO.isImm()) - O << MO.getImm(); - else - printOperand(MI, OpNo, O, NULL); -} - -void MBlazeInstPrinter::printMemOperand(const MCInst *MI, int OpNo, - raw_ostream &O, const char *Modifier ) { - printOperand(MI, OpNo+1, O, NULL); - O << ", "; - printOperand(MI, OpNo, O, NULL); -} - -/* -void MBlazeInstPrinter::printCCOperand(const MCInst *MI, unsigned OpNo, - raw_ostream &O) { - unsigned CC = MI->getOperand(OpNo).getImm(); - - switch (CC) { - default: - llvm_unreachable("Unsupported CC code"); - break; - case MBlazeCC::COND_E: - O << "eq"; - break; - case MBlazeCC::COND_NE: - O << "ne"; - break; - case MBlazeCC::COND_HS: - O << "hs"; - break; - case MBlazeCC::COND_LO: - O << "lo"; - break; - case MBlazeCC::COND_GE: - O << "ge"; - break; - case MBlazeCC::COND_L: - O << 'l'; - break; - } -} -*/ diff --git a/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.h b/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.h deleted file mode 100644 index 2b80689eaf..0000000000 --- a/lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.h +++ /dev/null @@ -1,46 +0,0 @@ -//===-- MBLazeInstPrinter.h - Convert MBlaze MCInst to assembly syntax ----===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This class prints a MBlaze MCInst to a .s file. -// -//===----------------------------------------------------------------------===// - -#ifndef MBLAZEINSTPRINTER_H -#define MBLAZEINSTPRINTER_H - -#include "llvm/MC/MCInstPrinter.h" - -namespace llvm { - class MCOperand; - - class MBlazeInstPrinter : public MCInstPrinter { - public: - MBlazeInstPrinter(const MCAsmInfo &MAI) : MCInstPrinter(MAI) { - } - - virtual void printInst(const MCInst *MI, raw_ostream &O); - - // Autogenerated by tblgen. - void printInstruction(const MCInst *MI, raw_ostream &O); - static const char *getRegisterName(unsigned RegNo); - static const char *getInstructionName(unsigned Opcode); - - void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O, - const char *Modifier = 0); - void printPCRelImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); - void printSrcMemOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O, - const char *Modifier = 0); - void printFSLImm(const MCInst *MI, int OpNo, raw_ostream &O); - void printUnsignedImm(const MCInst *MI, int OpNo, raw_ostream &O); - void printMemOperand(const MCInst *MI, int OpNo,raw_ostream &O, - const char *Modifier = 0); - }; -} - -#endif diff --git a/lib/Target/MBlaze/MBlaze.h b/lib/Target/MBlaze/MBlaze.h index 00c73f06fe..f9d828b266 100644 --- a/lib/Target/MBlaze/MBlaze.h +++ b/lib/Target/MBlaze/MBlaze.h @@ -21,16 +21,8 @@ namespace llvm { class MBlazeTargetMachine; class FunctionPass; class MachineCodeEmitter; - class MCCodeEmitter; - class TargetAsmBackend; class formatted_raw_ostream; - MCCodeEmitter *createMBlazeMCCodeEmitter(const Target &, - TargetMachine &TM, - MCContext &Ctx); - - TargetAsmBackend *createMBlazeAsmBackend(const Target &, const std::string &); - FunctionPass *createMBlazeISelDag(MBlazeTargetMachine &TM); FunctionPass *createMBlazeDelaySlotFillerPass(MBlazeTargetMachine &TM); diff --git a/lib/Target/MBlaze/MBlaze.td b/lib/Target/MBlaze/MBlaze.td index 1fa1e4dd57..3815b6d0a3 100644 --- a/lib/Target/MBlaze/MBlaze.td +++ b/lib/Target/MBlaze/MBlaze.td @@ -32,35 +32,35 @@ def MBlazeInstrInfo : InstrInfo; //===----------------------------------------------------------------------===// def FeaturePipe3 : SubtargetFeature<"pipe3", "HasPipe3", "true", - "Implements 3-stage pipeline">; + "Implements 3-stage pipeline.">; def FeatureBarrel : SubtargetFeature<"barrel", "HasBarrel", "true", - "Implements barrel shifter">; + "Implements barrel shifter.">; def FeatureDiv : SubtargetFeature<"div", "HasDiv", "true", - "Implements hardware divider">; + "Implements hardware divider.">; def FeatureMul : SubtargetFeature<"mul", "HasMul", "true", - "Implements hardware multiplier">; + "Implements hardware multiplier.">; def FeatureFSL : SubtargetFeature<"fsl", "HasFSL", "true", - "Implements FSL instructions">; + "Implements FSL instructions.">; def FeatureEFSL : SubtargetFeature<"efsl", "HasEFSL", "true", - "Implements extended FSL instructions">; + "Implements extended FSL instructions.">; def FeatureMSRSet : SubtargetFeature<"msrset", "HasMSRSet", "true", - "Implements MSR register set and clear">; + "Implements MSR register set and clear.">; def FeatureException : SubtargetFeature<"exception", "HasException", "true", - "Implements hardware exception support">; + "Implements hardware exception support.">; def FeaturePatCmp : SubtargetFeature<"patcmp", "HasPatCmp", "true", - "Implements pattern compare instruction">; + "Implements pattern compare instruction.">; def FeatureFPU : SubtargetFeature<"fpu", "HasFPU", "true", - "Implements floating point unit">; + "Implements floating point unit.">; def FeatureESR : SubtargetFeature<"esr", "HasESR", "true", "Implements ESR and EAR registers">; def FeaturePVR : SubtargetFeature<"pvr", "HasPVR", "true", - "Implements processor version register">; + "Implements processor version register.">; def FeatureMul64 : SubtargetFeature<"mul64", "HasMul64", "true", "Implements multiplier with 64-bit result">; def FeatureSqrt : SubtargetFeature<"sqrt", "HasSqrt", "true", - "Implements sqrt and floating point convert">; + "Implements sqrt and floating point convert.">; def FeatureMMU : SubtargetFeature<"mmu", "HasMMU", "true", - "Implements memory management unit">; + "Implements memory management unit.">; //===----------------------------------------------------------------------===// // MBlaze processors supported. @@ -69,26 +69,13 @@ def FeatureMMU : SubtargetFeature<"mmu", "HasMMU", "true", class Proc<string Name, list<SubtargetFeature> Features> : Processor<Name, MBlazeGenericItineraries, Features>; + def : Proc<"v400", []>; def : Proc<"v500", []>; def : Proc<"v600", []>; def : Proc<"v700", []>; def : Proc<"v710", []>; -//===----------------------------------------------------------------------===// -// Instruction Descriptions -//===----------------------------------------------------------------------===// - -def MBlazeAsmWriter : AsmWriter { - string AsmWriterClassName = "InstPrinter"; - bit isMCAsmWriter = 1; -} - -//===----------------------------------------------------------------------===// -// Target Declaration -//===----------------------------------------------------------------------===// - def MBlaze : Target { let InstructionSet = MBlazeInstrInfo; - let AssemblyWriters = [MBlazeAsmWriter]; } diff --git a/lib/Target/MBlaze/MBlazeAsmBackend.cpp b/lib/Target/MBlaze/MBlazeAsmBackend.cpp deleted file mode 100644 index 7e11f7371e..0000000000 --- a/lib/Target/MBlaze/MBlazeAsmBackend.cpp +++ /dev/null @@ -1,152 +0,0 @@ -//===-- MBlazeAsmBackend.cpp - MBlaze Assembler Backend -------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Target/TargetAsmBackend.h" -#include "MBlaze.h" -#include "MBlazeFixupKinds.h" -#include "llvm/ADT/Twine.h" -#include "llvm/MC/ELFObjectWriter.h" -#include "llvm/MC/MCAssembler.h" -#include "llvm/MC/MCExpr.h" -#include "llvm/MC/MCObjectFormat.h" -#include "llvm/MC/MCObjectWriter.h" -#include "llvm/MC/MCSectionELF.h" -#include "llvm/MC/MCSectionMachO.h" -#include "llvm/MC/MachObjectWriter.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/Target/TargetRegistry.h" -#include "llvm/Target/TargetAsmBackend.h" -using namespace llvm; - -static unsigned getFixupKindSize(unsigned Kind) { - switch (Kind) { - default: assert(0 && "invalid fixup kind!"); - case FK_Data_1: return 1; - case MBlaze::reloc_pcrel_2byte: - case FK_Data_2: return 2; - case MBlaze::reloc_pcrel_4byte: - case FK_Data_4: return 4; - case FK_Data_8: return 8; - } -} - - -namespace { -class MBlazeAsmBackend : public TargetAsmBackend { -public: - MBlazeAsmBackend(const Target &T) - : TargetAsmBackend(T) { - } - - bool MayNeedRelaxation(const MCInst &Inst) const; - - void RelaxInstruction(const MCInst &Inst, MCInst &Res) const; - - bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const; - - unsigned getPointerSize() const { - return 4; - } -}; - -bool MBlazeAsmBackend::MayNeedRelaxation(const MCInst &Inst) const { - return false; -} - -void MBlazeAsmBackend::RelaxInstruction(const MCInst &Inst, MCInst &Res) const { - assert(0 && "MBlazeAsmBackend::RelaxInstruction() unimplemented"); - return; -} - -bool MBlazeAsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const { - if ((Count % 4) != 0) - return false; - - for (uint64_t i = 0; i < Count; i += 4 ) - OW->Write32( 0x00000000 ); - - return true; -} -} // end anonymous namespace - -namespace { -// FIXME: This should be in a separate file. -// ELF is an ELF of course... -class ELFMBlazeAsmBackend : public MBlazeAsmBackend { - MCELFObjectFormat Format; - -public: - Triple::OSType OSType; - ELFMBlazeAsmBackend(const Target &T, Triple::OSType _OSType) - : MBlazeAsmBackend(T), OSType(_OSType) { - HasScatteredSymbols = true; - } - - virtual const MCObjectFormat &getObjectFormat() const { - return Format; - } - - - void ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF, - uint64_t Value) const; - - bool isVirtualSection(const MCSection &Section) const { - const MCSectionELF &SE = static_cast<const MCSectionELF&>(Section); - return SE.getType() == MCSectionELF::SHT_NOBITS; - } - - MCObjectWriter *createObjectWriter(raw_ostream &OS) const { - return new ELFObjectWriter(OS, /*Is64Bit=*/false, - OSType, - /*IsLittleEndian=*/false, - /*HasRelocationAddend=*/true); - } -}; - -void ELFMBlazeAsmBackend::ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF, - uint64_t Value) const { - unsigned Size = getFixupKindSize(Fixup.getKind()); - - assert(Fixup.getOffset() + Size <= DF.getContents().size() && - "Invalid fixup offset!"); - - char *data = DF.getContents().data() + Fixup.getOffset(); - switch (Size) { - default: llvm_unreachable( "Cannot fixup unknown value." ); - case 1: llvm_unreachable( "Cannot fixup 1 byte value." ); - case 8: llvm_unreachable( "Cannot fixup 8 byte value." ); - - case 4: - *(data+7) = uint8_t(Value); - *(data+6) = uint8_t(Value >> 8); - *(data+3) = uint8_t(Value >> 16); - *(data+2) = uint8_t(Value >> 24); - break; - - case 2: - *(data+3) = uint8_t(Value >> 0); - *(data+2) = uint8_t(Value >> 8); - } -} -} // end anonymous namespace - -TargetAsmBackend *llvm::createMBlazeAsmBackend(const Target &T, - const std::string &TT) { - switch (Triple(TT).getOS()) { - case Triple::Darwin: - assert(0 && "Mac not supported on MBlaze"); - case Triple::MinGW32: - case Triple::Cygwin: - case Triple::Win32: - assert(0 && "Windows not supported on MBlaze"); - default: - return new ELFMBlazeAsmBackend(T, Triple(TT).getOS()); - } -} diff --git a/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp b/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp index be9de6d5a2..b551b79b29 100644 --- a/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp +++ b/lib/Target/MBlaze/MBlazeDelaySlotFiller.cpp @@ -19,10 +19,6 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/ADT/Statistic.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/Debug.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -55,91 +51,6 @@ namespace { char Filler::ID = 0; } // end of anonymous namespace -static bool hasImmInstruction( MachineBasicBlock::iterator &candidate ) { - // Any instruction with an immediate mode operand greater than - // 16-bits requires an implicit IMM instruction. - unsigned numOper = candidate->getNumOperands(); - for( unsigned op = 0; op < numOper; ++op ) { - if( candidate->getOperand(op).isImm() && - (candidate->getOperand(op).getImm() & 0xFFFFFFFFFFFF0000LL) != 0 ) - return true; - - // FIXME: we could probably check to see if the FP value happens - // to not need an IMM instruction. For now we just always - // assume that FP values always do. - if( candidate->getOperand(op).isFPImm() ) - return true; - } - - return false; -} - -static bool delayHasHazard( MachineBasicBlock::iterator &candidate, - MachineBasicBlock::iterator &slot ) { - - // Loop over all of the operands in the branch instruction - // and make sure that none of them are defined by the - // candidate instruction. - unsigned numOper = slot->getNumOperands(); - for( unsigned op = 0; op < numOper; ++op ) { - if( !slot->getOperand(op).isReg() || - !slot->getOperand(op).isUse() || - slot->getOperand(op).isImplicit() ) - continue; - - unsigned cnumOper = ca |