2006-02-05 13:50:24 +08:00
|
|
|
//===-- SparcTargetMachine.cpp - Define TargetMachine for Sparc -----------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-02-05 13:50:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "SparcTargetMachine.h"
|
2012-03-18 02:46:09 +08:00
|
|
|
#include "Sparc.h"
|
2012-02-03 13:12:41 +08:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/PassManager.h"
|
2011-08-25 02:08:43 +08:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2006-02-05 13:50:24 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2009-07-25 14:49:55 +08:00
|
|
|
extern "C" void LLVMInitializeSparcTarget() {
|
|
|
|
// Register the target.
|
2010-02-04 14:34:01 +08:00
|
|
|
RegisterTargetMachine<SparcV8TargetMachine> X(TheSparcTarget);
|
|
|
|
RegisterTargetMachine<SparcV9TargetMachine> Y(TheSparcV9Target);
|
2006-09-08 07:39:26 +08:00
|
|
|
}
|
|
|
|
|
2006-02-05 13:50:24 +08:00
|
|
|
/// SparcTargetMachine ctor - Create an ILP32 architecture model
|
|
|
|
///
|
2012-02-03 13:12:41 +08:00
|
|
|
SparcTargetMachine::SparcTargetMachine(const Target &T, StringRef TT,
|
2011-07-19 14:37:02 +08:00
|
|
|
StringRef CPU, StringRef FS,
|
2011-12-03 06:16:29 +08:00
|
|
|
const TargetOptions &Options,
|
2011-07-20 15:51:56 +08:00
|
|
|
Reloc::Model RM, CodeModel::Model CM,
|
2011-11-16 16:38:26 +08:00
|
|
|
CodeGenOpt::Level OL,
|
2011-07-20 15:51:56 +08:00
|
|
|
bool is64bit)
|
2011-12-03 06:16:29 +08:00
|
|
|
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
|
2014-06-27 06:33:55 +08:00
|
|
|
Subtarget(TT, CPU, FS, *this, is64bit) {
|
2013-05-13 09:16:13 +08:00
|
|
|
initAsmInfo();
|
2006-02-05 13:50:24 +08:00
|
|
|
}
|
|
|
|
|
2012-02-03 13:12:41 +08:00
|
|
|
namespace {
|
|
|
|
/// Sparc Code Generator Pass Configuration Options.
|
|
|
|
class SparcPassConfig : public TargetPassConfig {
|
|
|
|
public:
|
2012-02-04 10:56:59 +08:00
|
|
|
SparcPassConfig(SparcTargetMachine *TM, PassManagerBase &PM)
|
|
|
|
: TargetPassConfig(TM, PM) {}
|
2012-02-03 13:12:41 +08:00
|
|
|
|
|
|
|
SparcTargetMachine &getSparcTargetMachine() const {
|
|
|
|
return getTM<SparcTargetMachine>();
|
|
|
|
}
|
|
|
|
|
2014-04-29 15:57:13 +08:00
|
|
|
bool addInstSelector() override;
|
|
|
|
bool addPreEmitPass() override;
|
2012-02-03 13:12:41 +08:00
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
2012-02-04 10:56:59 +08:00
|
|
|
TargetPassConfig *SparcTargetMachine::createPassConfig(PassManagerBase &PM) {
|
|
|
|
return new SparcPassConfig(this, PM);
|
2012-02-03 13:12:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SparcPassConfig::addInstSelector() {
|
2012-07-03 03:48:31 +08:00
|
|
|
addPass(createSparcISelDag(getSparcTargetMachine()));
|
2006-09-04 12:14:57 +08:00
|
|
|
return false;
|
|
|
|
}
|
2006-02-05 13:50:24 +08:00
|
|
|
|
2013-10-08 15:15:22 +08:00
|
|
|
bool SparcTargetMachine::addCodeEmitter(PassManagerBase &PM,
|
|
|
|
JITCodeEmitter &JCE) {
|
|
|
|
// Machine code emitter pass for Sparc.
|
|
|
|
PM.add(createSparcJITCodeEmitterPass(*this, JCE));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-09-04 12:14:57 +08:00
|
|
|
/// addPreEmitPass - This pass may be implemented by targets that want to run
|
|
|
|
/// passes immediately before machine code is emitted. This should return
|
|
|
|
/// true if -print-machineinstrs should print out the code after the passes.
|
2012-02-03 13:12:41 +08:00
|
|
|
bool SparcPassConfig::addPreEmitPass(){
|
2012-07-03 03:48:31 +08:00
|
|
|
addPass(createSparcDelaySlotFillerPass(getSparcTargetMachine()));
|
2006-09-04 12:14:57 +08:00
|
|
|
return true;
|
|
|
|
}
|
2010-02-04 14:34:01 +08:00
|
|
|
|
2011-12-20 10:50:00 +08:00
|
|
|
void SparcV8TargetMachine::anchor() { }
|
|
|
|
|
2010-02-04 14:34:01 +08:00
|
|
|
SparcV8TargetMachine::SparcV8TargetMachine(const Target &T,
|
2011-07-20 15:51:56 +08:00
|
|
|
StringRef TT, StringRef CPU,
|
2011-12-03 06:16:29 +08:00
|
|
|
StringRef FS,
|
|
|
|
const TargetOptions &Options,
|
|
|
|
Reloc::Model RM,
|
2011-11-16 16:38:26 +08:00
|
|
|
CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL)
|
2011-12-03 06:16:29 +08:00
|
|
|
: SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, false) {
|
2010-02-04 14:34:01 +08:00
|
|
|
}
|
|
|
|
|
2011-12-20 10:50:00 +08:00
|
|
|
void SparcV9TargetMachine::anchor() { }
|
|
|
|
|
2012-02-03 13:12:41 +08:00
|
|
|
SparcV9TargetMachine::SparcV9TargetMachine(const Target &T,
|
2011-07-20 15:51:56 +08:00
|
|
|
StringRef TT, StringRef CPU,
|
2011-12-03 06:16:29 +08:00
|
|
|
StringRef FS,
|
|
|
|
const TargetOptions &Options,
|
|
|
|
Reloc::Model RM,
|
2011-11-16 16:38:26 +08:00
|
|
|
CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL)
|
2011-12-03 06:16:29 +08:00
|
|
|
: SparcTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, true) {
|
2010-02-04 14:34:01 +08:00
|
|
|
}
|