1//===-- MBlazeTargetMachine.cpp - Define TargetMachine for MBlaze ---------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// Implements the info about MBlaze target spec. 11// 12//===----------------------------------------------------------------------===// 13 14#include "MBlaze.h" 15#include "MBlazeTargetMachine.h" 16#include "llvm/PassManager.h" 17#include "llvm/CodeGen/Passes.h" 18#include "llvm/Support/FormattedStream.h" 19#include "llvm/Support/TargetRegistry.h" 20#include "llvm/Target/TargetOptions.h" 21using namespace llvm; 22 23extern "C" void LLVMInitializeMBlazeTarget() { 24 // Register the target. 25 RegisterTargetMachine<MBlazeTargetMachine> X(TheMBlazeTarget); 26} 27 28// DataLayout --> Big-endian, 32-bit pointer/ABI/alignment 29// The stack is always 8 byte aligned 30// On function prologue, the stack is created by decrementing 31// its pointer. Once decremented, all references are done with positive 32// offset from the stack/frame pointer, using StackGrowsUp enables 33// an easier handling. 34MBlazeTargetMachine:: 35MBlazeTargetMachine(const Target &T, StringRef TT, 36 StringRef CPU, StringRef FS, 37 Reloc::Model RM, CodeModel::Model CM): 38 LLVMTargetMachine(T, TT, CPU, FS, RM, CM), 39 Subtarget(TT, CPU, FS), 40 DataLayout("E-p:32:32:32-i8:8:8-i16:16:16"), 41 InstrInfo(*this), 42 FrameLowering(Subtarget), 43 TLInfo(*this), TSInfo(*this), ELFWriterInfo(*this), 44 InstrItins(Subtarget.getInstrItineraryData()) { 45} 46 47// Install an instruction selector pass using 48// the ISelDag to gen MBlaze code. 49bool MBlazeTargetMachine::addInstSelector(PassManagerBase &PM, 50 CodeGenOpt::Level OptLevel) { 51 PM.add(createMBlazeISelDag(*this)); 52 return false; 53} 54 55// Implemented by targets that want to run passes immediately before 56// machine code is emitted. return true if -print-machineinstrs should 57// print out the code after the passes. 58bool MBlazeTargetMachine::addPreEmitPass(PassManagerBase &PM, 59 CodeGenOpt::Level OptLevel) { 60 PM.add(createMBlazeDelaySlotFillerPass(*this)); 61 return true; 62} 63