2008-11-07 18:59:00 +08:00
|
|
|
//===-- XCoreTargetMachine.cpp - Define TargetMachine for XCore -----------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "XCoreTargetMachine.h"
|
|
|
|
#include "XCore.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2013-01-02 19:36:10 +08:00
|
|
|
#include "llvm/IR/Module.h"
|
2008-11-07 18:59:00 +08:00
|
|
|
#include "llvm/PassManager.h"
|
2011-08-25 02:08:43 +08:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2008-11-07 18:59:00 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
/// XCoreTargetMachine ctor - Create an ILP32 architecture model
|
|
|
|
///
|
2011-07-19 14:37:02 +08:00
|
|
|
XCoreTargetMachine::XCoreTargetMachine(const Target &T, StringRef TT,
|
2011-07-20 15:51:56 +08:00
|
|
|
StringRef CPU, StringRef FS,
|
2011-12-03 06:16:29 +08:00
|
|
|
const TargetOptions &Options,
|
2011-11-16 16:38:26 +08:00
|
|
|
Reloc::Model RM, CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL)
|
2014-07-02 08:10:09 +08:00
|
|
|
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
|
|
|
Subtarget(TT, CPU, FS, *this) {
|
2013-05-13 09:16:13 +08:00
|
|
|
initAsmInfo();
|
2008-11-07 18:59:00 +08:00
|
|
|
}
|
|
|
|
|
2012-02-03 13:12:41 +08:00
|
|
|
namespace {
|
|
|
|
/// XCore Code Generator Pass Configuration Options.
|
|
|
|
class XCorePassConfig : public TargetPassConfig {
|
|
|
|
public:
|
2012-02-04 10:56:59 +08:00
|
|
|
XCorePassConfig(XCoreTargetMachine *TM, PassManagerBase &PM)
|
|
|
|
: TargetPassConfig(TM, PM) {}
|
2012-02-03 13:12:41 +08:00
|
|
|
|
|
|
|
XCoreTargetMachine &getXCoreTargetMachine() const {
|
|
|
|
return getTM<XCoreTargetMachine>();
|
|
|
|
}
|
|
|
|
|
2014-04-29 15:57:00 +08:00
|
|
|
bool addPreISel() override;
|
|
|
|
bool addInstSelector() override;
|
|
|
|
bool addPreEmitPass() override;
|
2012-02-03 13:12:41 +08:00
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
2012-02-04 10:56:59 +08:00
|
|
|
TargetPassConfig *XCoreTargetMachine::createPassConfig(PassManagerBase &PM) {
|
|
|
|
return new XCorePassConfig(this, PM);
|
2012-02-03 13:12:41 +08:00
|
|
|
}
|
|
|
|
|
2013-05-05 01:01:55 +08:00
|
|
|
bool XCorePassConfig::addPreISel() {
|
|
|
|
addPass(createXCoreLowerThreadLocalPass());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-02-03 13:12:41 +08:00
|
|
|
bool XCorePassConfig::addInstSelector() {
|
2012-07-03 03:48:31 +08:00
|
|
|
addPass(createXCoreISelDag(getXCoreTargetMachine(), getOptLevel()));
|
2008-11-07 18:59:00 +08:00
|
|
|
return false;
|
|
|
|
}
|
2009-08-15 20:53:15 +08:00
|
|
|
|
2014-01-06 22:21:00 +08:00
|
|
|
bool XCorePassConfig::addPreEmitPass() {
|
|
|
|
addPass(createXCoreFrameToArgsOffsetEliminationPass());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-08-15 20:53:15 +08:00
|
|
|
// Force static initialization.
|
|
|
|
extern "C" void LLVMInitializeXCoreTarget() {
|
|
|
|
RegisterTargetMachine<XCoreTargetMachine> X(TheXCoreTarget);
|
|
|
|
}
|
2013-09-18 20:43:35 +08:00
|
|
|
|
|
|
|
void XCoreTargetMachine::addAnalysisPasses(PassManagerBase &PM) {
|
|
|
|
// Add first the target-independent BasicTTI pass, then our XCore pass. This
|
|
|
|
// allows the XCore pass to delegate to the target independent layer when
|
|
|
|
// appropriate.
|
|
|
|
PM.add(createBasicTargetTransformInfoPass(this));
|
|
|
|
PM.add(createXCoreTargetTransformInfoPass(this));
|
|
|
|
}
|