2010-02-23 19:15:24 +00:00
|
|
|
//===-- MBlazeTargetMachine.cpp - Define TargetMachine for MBlaze ---------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Implements the info about MBlaze target spec.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "MBlaze.h"
|
|
|
|
#include "MBlazeTargetMachine.h"
|
|
|
|
#include "llvm/PassManager.h"
|
2010-10-21 03:57:26 +00:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
|
|
|
#include "llvm/Support/FormattedStream.h"
|
2011-08-24 18:08:43 +00:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2010-10-21 03:57:26 +00:00
|
|
|
#include "llvm/Target/TargetOptions.h"
|
2010-02-23 19:15:24 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
extern "C" void LLVMInitializeMBlazeTarget() {
|
|
|
|
// Register the target.
|
|
|
|
RegisterTargetMachine<MBlazeTargetMachine> X(TheMBlazeTarget);
|
|
|
|
}
|
|
|
|
|
|
|
|
// DataLayout --> Big-endian, 32-bit pointer/ABI/alignment
|
|
|
|
// The stack is always 8 byte aligned
|
|
|
|
// On function prologue, the stack is created by decrementing
|
|
|
|
// its pointer. Once decremented, all references are done with positive
|
|
|
|
// offset from the stack/frame pointer, using StackGrowsUp enables
|
|
|
|
// an easier handling.
|
|
|
|
MBlazeTargetMachine::
|
2011-07-19 06:37:02 +00:00
|
|
|
MBlazeTargetMachine(const Target &T, StringRef TT,
|
2011-12-02 22:16:29 +00:00
|
|
|
StringRef CPU, StringRef FS, const TargetOptions &Options,
|
2011-11-16 08:38:26 +00:00
|
|
|
Reloc::Model RM, CodeModel::Model CM,
|
2011-12-02 22:16:29 +00:00
|
|
|
CodeGenOpt::Level OL)
|
|
|
|
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
|
|
|
Subtarget(TT, CPU, FS),
|
|
|
|
DataLayout("E-p:32:32:32-i8:8:8-i16:16:16"),
|
|
|
|
InstrInfo(*this),
|
|
|
|
FrameLowering(Subtarget),
|
|
|
|
TLInfo(*this), TSInfo(*this), ELFWriterInfo(*this),
|
|
|
|
InstrItins(Subtarget.getInstrItineraryData()) {
|
2010-02-23 19:15:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Install an instruction selector pass using
|
|
|
|
// the ISelDag to gen MBlaze code.
|
2011-11-16 08:38:26 +00:00
|
|
|
bool MBlazeTargetMachine::addInstSelector(PassManagerBase &PM) {
|
2010-02-23 19:15:24 +00:00
|
|
|
PM.add(createMBlazeISelDag(*this));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implemented by targets that want to run passes immediately before
|
|
|
|
// machine code is emitted. return true if -print-machineinstrs should
|
|
|
|
// print out the code after the passes.
|
2011-11-16 08:38:26 +00:00
|
|
|
bool MBlazeTargetMachine::addPreEmitPass(PassManagerBase &PM) {
|
2010-02-23 19:15:24 +00:00
|
|
|
PM.add(createMBlazeDelaySlotFillerPass(*this));
|
|
|
|
return true;
|
|
|
|
}
|