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 "MBlazeTargetMachine.h"
|
2012-03-17 18:46:09 +00:00
|
|
|
#include "MBlaze.h"
|
2010-02-23 19:15:24 +00:00
|
|
|
#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
|
|
|
}
|
|
|
|
|
2012-02-03 05:12:41 +00:00
|
|
|
namespace {
|
|
|
|
/// MBlaze Code Generator Pass Configuration Options.
|
|
|
|
class MBlazePassConfig : public TargetPassConfig {
|
|
|
|
public:
|
2012-02-04 02:56:59 +00:00
|
|
|
MBlazePassConfig(MBlazeTargetMachine *TM, PassManagerBase &PM)
|
|
|
|
: TargetPassConfig(TM, PM) {}
|
2012-02-03 05:12:41 +00:00
|
|
|
|
|
|
|
MBlazeTargetMachine &getMBlazeTargetMachine() const {
|
|
|
|
return getTM<MBlazeTargetMachine>();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool addInstSelector();
|
|
|
|
virtual bool addPreEmitPass();
|
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
2012-02-04 02:56:59 +00:00
|
|
|
TargetPassConfig *MBlazeTargetMachine::createPassConfig(PassManagerBase &PM) {
|
|
|
|
return new MBlazePassConfig(this, PM);
|
2012-02-03 05:12:41 +00:00
|
|
|
}
|
|
|
|
|
2010-02-23 19:15:24 +00:00
|
|
|
// Install an instruction selector pass using
|
|
|
|
// the ISelDag to gen MBlaze code.
|
2012-02-03 05:12:41 +00:00
|
|
|
bool MBlazePassConfig::addInstSelector() {
|
2012-05-01 08:27:43 +00:00
|
|
|
PM->add(createMBlazeISelDag(getMBlazeTargetMachine()));
|
2010-02-23 19:15:24 +00:00
|
|
|
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.
|
2012-02-03 05:12:41 +00:00
|
|
|
bool MBlazePassConfig::addPreEmitPass() {
|
2012-05-01 08:27:43 +00:00
|
|
|
PM->add(createMBlazeDelaySlotFillerPass(getMBlazeTargetMachine()));
|
2010-02-23 19:15:24 +00:00
|
|
|
return true;
|
|
|
|
}
|