2012-02-17 16:55:11 +08:00
|
|
|
//===-- MipsTargetMachine.cpp - Define TargetMachine for Mips -------------===//
|
2007-06-06 15:42:06 +08:00
|
|
|
//
|
|
|
|
// 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.
|
2007-06-06 15:42:06 +08:00
|
|
|
//
|
2011-04-16 05:51:11 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 15:42:06 +08:00
|
|
|
//
|
|
|
|
// Implements the info about Mips target spec.
|
|
|
|
//
|
2011-04-16 05:51:11 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 15:42:06 +08:00
|
|
|
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "MipsTargetMachine.h"
|
2017-02-01 09:22:51 +08:00
|
|
|
#include "MCTargetDesc/MipsABIInfo.h"
|
|
|
|
#include "MCTargetDesc/MipsMCTargetDesc.h"
|
2012-03-18 02:46:09 +08:00
|
|
|
#include "Mips.h"
|
2014-01-07 19:48:04 +08:00
|
|
|
#include "Mips16ISelDAGToDAG.h"
|
2013-04-10 03:46:01 +08:00
|
|
|
#include "MipsSEISelDAGToDAG.h"
|
2017-02-01 09:22:51 +08:00
|
|
|
#include "MipsSubtarget.h"
|
2014-11-13 17:26:31 +08:00
|
|
|
#include "MipsTargetObjectFile.h"
|
2017-02-01 09:22:51 +08:00
|
|
|
#include "llvm/ADT/Optional.h"
|
|
|
|
#include "llvm/ADT/STLExtras.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2013-04-10 03:46:01 +08:00
|
|
|
#include "llvm/Analysis/TargetTransformInfo.h"
|
2018-02-23 19:06:40 +08:00
|
|
|
#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
|
|
|
|
#include "llvm/CodeGen/GlobalISel/Legalizer.h"
|
|
|
|
#include "llvm/CodeGen/GlobalISel/RegBankSelect.h"
|
|
|
|
#include "llvm/CodeGen/GlobalISel/InstructionSelect.h"
|
2017-02-01 09:22:51 +08:00
|
|
|
#include "llvm/CodeGen/BasicTTIImpl.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2012-02-03 13:12:41 +08:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2016-05-10 11:21:59 +08:00
|
|
|
#include "llvm/CodeGen/TargetPassConfig.h"
|
2017-02-01 09:22:51 +08:00
|
|
|
#include "llvm/IR/Attributes.h"
|
|
|
|
#include "llvm/IR/Function.h"
|
|
|
|
#include "llvm/Support/CodeGen.h"
|
2013-04-10 03:46:01 +08:00
|
|
|
#include "llvm/Support/Debug.h"
|
2011-08-25 02:08:43 +08:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2014-01-07 19:48:04 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2017-02-01 09:22:51 +08:00
|
|
|
#include "llvm/Target/TargetOptions.h"
|
|
|
|
#include <string>
|
2015-03-14 16:34:25 +08:00
|
|
|
|
2007-06-06 15:42:06 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-22 06:55:11 +08:00
|
|
|
#define DEBUG_TYPE "mips"
|
|
|
|
|
2009-07-25 14:49:55 +08:00
|
|
|
extern "C" void LLVMInitializeMipsTarget() {
|
|
|
|
// Register the target.
|
2016-10-10 07:00:34 +08:00
|
|
|
RegisterTargetMachine<MipsebTargetMachine> X(getTheMipsTarget());
|
|
|
|
RegisterTargetMachine<MipselTargetMachine> Y(getTheMipselTarget());
|
|
|
|
RegisterTargetMachine<MipsebTargetMachine> A(getTheMips64Target());
|
|
|
|
RegisterTargetMachine<MipselTargetMachine> B(getTheMips64elTarget());
|
2018-02-23 19:06:40 +08:00
|
|
|
|
|
|
|
PassRegistry *PR = PassRegistry::getPassRegistry();
|
|
|
|
initializeGlobalISel(*PR);
|
2018-05-12 00:13:53 +08:00
|
|
|
initializeMipsDelaySlotFillerPass(*PR);
|
2018-05-22 21:24:38 +08:00
|
|
|
initializeMipsBranchExpansionPass(*PR);
|
2018-06-13 20:51:37 +08:00
|
|
|
initializeMicroMipsSizeReducePass(*PR);
|
2007-06-06 15:42:06 +08:00
|
|
|
}
|
|
|
|
|
2015-06-11 23:34:59 +08:00
|
|
|
static std::string computeDataLayout(const Triple &TT, StringRef CPU,
|
2015-03-12 08:07:24 +08:00
|
|
|
const TargetOptions &Options,
|
|
|
|
bool isLittle) {
|
2017-02-01 09:22:51 +08:00
|
|
|
std::string Ret;
|
2015-09-16 00:17:27 +08:00
|
|
|
MipsABIInfo ABI = MipsABIInfo::computeTargetABI(TT, CPU, Options.MCOptions);
|
2015-01-27 03:03:15 +08:00
|
|
|
|
|
|
|
// There are both little and big endian mips.
|
|
|
|
if (isLittle)
|
|
|
|
Ret += "e";
|
|
|
|
else
|
|
|
|
Ret += "E";
|
|
|
|
|
2016-07-19 18:49:03 +08:00
|
|
|
if (ABI.IsO32())
|
|
|
|
Ret += "-m:m";
|
|
|
|
else
|
|
|
|
Ret += "-m:e";
|
2015-01-27 03:03:15 +08:00
|
|
|
|
|
|
|
// Pointers are 32 bit on some ABIs.
|
|
|
|
if (!ABI.IsN64())
|
|
|
|
Ret += "-p:32:32";
|
|
|
|
|
2015-07-08 05:31:54 +08:00
|
|
|
// 8 and 16 bit integers only need to have natural alignment, but try to
|
2015-01-27 03:03:15 +08:00
|
|
|
// align them to 32 bits. 64 bit integers have natural alignment.
|
|
|
|
Ret += "-i8:8:32-i16:16:32-i64:64";
|
|
|
|
|
|
|
|
// 32 bit registers are always available and the stack is at least 64 bit
|
|
|
|
// aligned. On N64 64 bit registers are also available and the stack is
|
|
|
|
// 128 bit aligned.
|
|
|
|
if (ABI.IsN64() || ABI.IsN32())
|
|
|
|
Ret += "-n32:64-S128";
|
|
|
|
else
|
|
|
|
Ret += "-n32-S64";
|
|
|
|
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
2017-08-03 10:16:21 +08:00
|
|
|
static Reloc::Model getEffectiveRelocModel(bool JIT,
|
2016-05-19 06:04:49 +08:00
|
|
|
Optional<Reloc::Model> RM) {
|
2017-08-03 10:16:21 +08:00
|
|
|
if (!RM.hasValue() || JIT)
|
2016-05-19 06:04:49 +08:00
|
|
|
return Reloc::Static;
|
|
|
|
return *RM;
|
|
|
|
}
|
|
|
|
|
2007-08-28 13:13:42 +08:00
|
|
|
// On function prologue, the stack is created by decrementing
|
|
|
|
// its pointer. Once decremented, all references are done with positive
|
2010-11-15 08:06:54 +08:00
|
|
|
// offset from the stack/frame pointer, using StackGrowsUp enables
|
2008-08-06 14:14:43 +08:00
|
|
|
// an easier handling.
|
Several changes to Mips backend, experimental fp support being the most
important.
- Cleanup in the Subtarget info with addition of new features, not all support
yet, but they allow the future inclusion of features easier. Among new features,
we have : Arch family info (mips1, mips2, ...), ABI info (o32, eabi), 64-bit
integer
and float registers, allegrex vector FPU (VFPU), single float only support.
- TargetMachine now detects allegrex core.
- Added allegrex (Mips32r2) sext_inreg instructions.
- *Added Float Point Instructions*, handling single float only, and
aliased accesses for 32-bit FPUs.
- Some cleanup in FP instruction formats and FP register classes.
- Calling conventions improved to support mips 32-bit EABI.
- Added Asm Printer support for fp cond codes.
- Added support for sret copy to a return register.
- EABI support added into LowerCALL and FORMAL_ARGS.
- MipsFunctionInfo now keeps a virtual register per function to track the
sret on function entry until function ret.
- MipsInstrInfo FP support into methods (isMoveInstr, isLoadFromStackSlot, ...),
FP cond codes mapping and initial FP Branch Analysis.
- Two new Mips SDNode to handle fp branch and compare instructions : FPBrcond,
FPCmp
- MipsTargetLowering : handling different FP classes, Allegrex support, sret
return copy, no homing location within EABI, non 32-bit stack objects
arguments, and asm constraint for float.
llvm-svn: 53146
2008-07-06 03:05:21 +08:00
|
|
|
// Using CodeModel::Large enables different CALL behavior.
|
2015-06-12 03:41:26 +08:00
|
|
|
MipsTargetMachine::MipsTargetMachine(const Target &T, const Triple &TT,
|
2014-07-02 08:54:07 +08:00
|
|
|
StringRef CPU, StringRef FS,
|
|
|
|
const TargetOptions &Options,
|
2016-05-19 06:04:49 +08:00
|
|
|
Optional<Reloc::Model> RM,
|
2017-08-03 10:16:21 +08:00
|
|
|
Optional<CodeModel::Model> CM,
|
|
|
|
CodeGenOpt::Level OL, bool JIT,
|
2016-05-19 06:04:49 +08:00
|
|
|
bool isLittle)
|
2017-10-13 06:57:28 +08:00
|
|
|
: LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options, isLittle), TT,
|
|
|
|
CPU, FS, Options, getEffectiveRelocModel(JIT, RM),
|
2018-12-07 20:10:23 +08:00
|
|
|
getEffectiveCodeModel(CM, CodeModel::Small), OL),
|
2017-02-01 09:22:51 +08:00
|
|
|
isLittle(isLittle), TLOF(llvm::make_unique<MipsTargetObjectFile>()),
|
2015-09-16 00:17:27 +08:00
|
|
|
ABI(MipsABIInfo::computeTargetABI(TT, CPU, Options.MCOptions)),
|
2017-08-15 05:49:38 +08:00
|
|
|
Subtarget(nullptr), DefaultSubtarget(TT, CPU, FS, isLittle, *this,
|
|
|
|
Options.StackAlignmentOverride),
|
2015-06-12 03:41:26 +08:00
|
|
|
NoMips16Subtarget(TT, CPU, FS.empty() ? "-mips16" : FS.str() + ",-mips16",
|
2017-08-15 05:49:38 +08:00
|
|
|
isLittle, *this, Options.StackAlignmentOverride),
|
2015-06-12 03:41:26 +08:00
|
|
|
Mips16Subtarget(TT, CPU, FS.empty() ? "+mips16" : FS.str() + ",+mips16",
|
2017-08-15 05:49:38 +08:00
|
|
|
isLittle, *this, Options.StackAlignmentOverride) {
|
2014-07-19 07:41:32 +08:00
|
|
|
Subtarget = &DefaultSubtarget;
|
2013-05-13 09:16:13 +08:00
|
|
|
initAsmInfo();
|
2013-04-10 03:46:01 +08:00
|
|
|
}
|
|
|
|
|
2017-02-01 09:22:51 +08:00
|
|
|
MipsTargetMachine::~MipsTargetMachine() = default;
|
2014-11-21 07:37:18 +08:00
|
|
|
|
2017-02-01 09:22:51 +08:00
|
|
|
void MipsebTargetMachine::anchor() {}
|
2011-12-20 10:50:00 +08:00
|
|
|
|
2015-06-12 03:41:26 +08:00
|
|
|
MipsebTargetMachine::MipsebTargetMachine(const Target &T, const Triple &TT,
|
|
|
|
StringRef CPU, StringRef FS,
|
|
|
|
const TargetOptions &Options,
|
2016-05-19 06:04:49 +08:00
|
|
|
Optional<Reloc::Model> RM,
|
2017-08-03 10:16:21 +08:00
|
|
|
Optional<CodeModel::Model> CM,
|
|
|
|
CodeGenOpt::Level OL, bool JIT)
|
|
|
|
: MipsTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, false) {}
|
2011-09-21 11:00:58 +08:00
|
|
|
|
2017-02-01 09:22:51 +08:00
|
|
|
void MipselTargetMachine::anchor() {}
|
2011-12-20 10:50:00 +08:00
|
|
|
|
2015-06-12 03:41:26 +08:00
|
|
|
MipselTargetMachine::MipselTargetMachine(const Target &T, const Triple &TT,
|
|
|
|
StringRef CPU, StringRef FS,
|
|
|
|
const TargetOptions &Options,
|
2016-05-19 06:04:49 +08:00
|
|
|
Optional<Reloc::Model> RM,
|
2017-08-03 10:16:21 +08:00
|
|
|
Optional<CodeModel::Model> CM,
|
|
|
|
CodeGenOpt::Level OL, bool JIT)
|
|
|
|
: MipsTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL, JIT, true) {}
|
2008-06-04 09:45:25 +08:00
|
|
|
|
2014-09-26 09:44:08 +08:00
|
|
|
const MipsSubtarget *
|
2014-09-26 10:57:05 +08:00
|
|
|
MipsTargetMachine::getSubtargetImpl(const Function &F) const {
|
2015-02-14 10:37:48 +08:00
|
|
|
Attribute CPUAttr = F.getFnAttribute("target-cpu");
|
|
|
|
Attribute FSAttr = F.getFnAttribute("target-features");
|
2014-09-26 09:44:08 +08:00
|
|
|
|
|
|
|
std::string CPU = !CPUAttr.hasAttribute(Attribute::None)
|
|
|
|
? CPUAttr.getValueAsString().str()
|
|
|
|
: TargetCPU;
|
|
|
|
std::string FS = !FSAttr.hasAttribute(Attribute::None)
|
|
|
|
? FSAttr.getValueAsString().str()
|
|
|
|
: TargetFS;
|
|
|
|
bool hasMips16Attr =
|
2015-02-14 10:37:48 +08:00
|
|
|
!F.getFnAttribute("mips16").hasAttribute(Attribute::None);
|
2014-09-26 09:44:08 +08:00
|
|
|
bool hasNoMips16Attr =
|
2015-02-14 10:37:48 +08:00
|
|
|
!F.getFnAttribute("nomips16").hasAttribute(Attribute::None);
|
2014-09-26 09:44:08 +08:00
|
|
|
|
2017-05-22 20:47:41 +08:00
|
|
|
bool HasMicroMipsAttr =
|
|
|
|
!F.getFnAttribute("micromips").hasAttribute(Attribute::None);
|
|
|
|
bool HasNoMicroMipsAttr =
|
|
|
|
!F.getFnAttribute("nomicromips").hasAttribute(Attribute::None);
|
|
|
|
|
2014-09-30 05:57:54 +08:00
|
|
|
// FIXME: This is related to the code below to reset the target options,
|
|
|
|
// we need to know whether or not the soft float flag is set on the
|
2015-05-07 18:29:52 +08:00
|
|
|
// function, so we can enable it as a subtarget feature.
|
2015-05-12 09:26:05 +08:00
|
|
|
bool softFloat =
|
|
|
|
F.hasFnAttribute("use-soft-float") &&
|
|
|
|
F.getFnAttribute("use-soft-float").getValueAsString() == "true";
|
2014-09-30 05:57:54 +08:00
|
|
|
|
2014-09-26 09:44:08 +08:00
|
|
|
if (hasMips16Attr)
|
|
|
|
FS += FS.empty() ? "+mips16" : ",+mips16";
|
|
|
|
else if (hasNoMips16Attr)
|
|
|
|
FS += FS.empty() ? "-mips16" : ",-mips16";
|
2017-05-22 20:47:41 +08:00
|
|
|
if (HasMicroMipsAttr)
|
|
|
|
FS += FS.empty() ? "+micromips" : ",+micromips";
|
|
|
|
else if (HasNoMicroMipsAttr)
|
|
|
|
FS += FS.empty() ? "-micromips" : ",-micromips";
|
2015-05-07 18:29:52 +08:00
|
|
|
if (softFloat)
|
|
|
|
FS += FS.empty() ? "+soft-float" : ",+soft-float";
|
2014-09-26 09:44:08 +08:00
|
|
|
|
2015-05-07 18:29:52 +08:00
|
|
|
auto &I = SubtargetMap[CPU + FS];
|
2014-09-26 09:44:08 +08:00
|
|
|
if (!I) {
|
|
|
|
// This needs to be done before we create a new subtarget since any
|
|
|
|
// creation will depend on the TM and the code generation flags on the
|
|
|
|
// function that reside in TargetOptions.
|
|
|
|
resetTargetOptions(F);
|
2017-09-22 16:52:03 +08:00
|
|
|
I = llvm::make_unique<MipsSubtarget>(TargetTriple, CPU, FS, isLittle, *this,
|
|
|
|
Options.StackAlignmentOverride);
|
2014-09-26 09:44:08 +08:00
|
|
|
}
|
|
|
|
return I.get();
|
|
|
|
}
|
|
|
|
|
2014-07-19 07:41:32 +08:00
|
|
|
void MipsTargetMachine::resetSubtarget(MachineFunction *MF) {
|
2018-05-14 20:53:11 +08:00
|
|
|
LLVM_DEBUG(dbgs() << "resetSubtarget\n");
|
2014-09-26 09:44:08 +08:00
|
|
|
|
2017-12-16 06:22:58 +08:00
|
|
|
Subtarget = const_cast<MipsSubtarget *>(getSubtargetImpl(MF->getFunction()));
|
2014-08-05 10:39:49 +08:00
|
|
|
MF->setSubtarget(Subtarget);
|
2014-07-19 07:41:32 +08:00
|
|
|
}
|
|
|
|
|
2012-02-03 13:12:41 +08:00
|
|
|
namespace {
|
2017-02-01 09:22:51 +08:00
|
|
|
|
2012-02-03 13:12:41 +08:00
|
|
|
/// Mips Code Generator Pass Configuration Options.
|
|
|
|
class MipsPassConfig : public TargetPassConfig {
|
|
|
|
public:
|
2017-05-31 05:36:41 +08:00
|
|
|
MipsPassConfig(MipsTargetMachine &TM, PassManagerBase &PM)
|
2017-09-22 16:52:03 +08:00
|
|
|
: TargetPassConfig(TM, PM) {
|
2013-10-08 03:13:53 +08:00
|
|
|
// The current implementation of long branch pass requires a scratch
|
|
|
|
// register ($at) to be available before branch instructions. Tail merging
|
|
|
|
// can break this requirement, so disable it when long branch pass is
|
|
|
|
// enabled.
|
|
|
|
EnableTailMerge = !getMipsSubtarget().enableLongBranchPass();
|
|
|
|
}
|
2012-02-03 13:12:41 +08:00
|
|
|
|
|
|
|
MipsTargetMachine &getMipsTargetMachine() const {
|
|
|
|
return getTM<MipsTargetMachine>();
|
|
|
|
}
|
|
|
|
|
|
|
|
const MipsSubtarget &getMipsSubtarget() const {
|
|
|
|
return *getMipsTargetMachine().getSubtargetImpl();
|
|
|
|
}
|
|
|
|
|
2014-04-29 15:58:02 +08:00
|
|
|
void addIRPasses() override;
|
|
|
|
bool addInstSelector() override;
|
2014-12-12 05:26:47 +08:00
|
|
|
void addPreEmitPass() override;
|
|
|
|
void addPreRegAlloc() override;
|
2018-02-23 19:06:40 +08:00
|
|
|
bool addIRTranslator() override;
|
|
|
|
bool addLegalizeMachineIR() override;
|
|
|
|
bool addRegBankSelect() override;
|
|
|
|
bool addGlobalInstructionSelect() override;
|
2012-02-03 13:12:41 +08:00
|
|
|
};
|
2017-02-01 09:22:51 +08:00
|
|
|
|
|
|
|
} // end anonymous namespace
|
2012-02-03 13:12:41 +08:00
|
|
|
|
2012-02-04 10:56:59 +08:00
|
|
|
TargetPassConfig *MipsTargetMachine::createPassConfig(PassManagerBase &PM) {
|
2017-05-31 05:36:41 +08:00
|
|
|
return new MipsPassConfig(*this, PM);
|
2012-02-03 13:12:41 +08:00
|
|
|
}
|
|
|
|
|
2013-04-11 00:58:04 +08:00
|
|
|
void MipsPassConfig::addIRPasses() {
|
|
|
|
TargetPassConfig::addIRPasses();
|
2017-05-19 01:21:13 +08:00
|
|
|
addPass(createAtomicExpandPass());
|
2013-04-11 00:58:04 +08:00
|
|
|
if (getMipsSubtarget().os16())
|
2017-05-19 01:21:13 +08:00
|
|
|
addPass(createMipsOs16Pass());
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
llvm-svn: 181641
2013-05-11 06:25:39 +08:00
|
|
|
if (getMipsSubtarget().inMips16HardFloat())
|
2017-05-19 01:21:13 +08:00
|
|
|
addPass(createMips16HardFloatPass());
|
2013-04-11 00:58:04 +08:00
|
|
|
}
|
2010-11-15 08:06:54 +08:00
|
|
|
// Install an instruction selector pass using
|
2007-06-06 15:42:06 +08:00
|
|
|
// the ISelDag to gen Mips code.
|
2012-05-01 16:27:43 +08:00
|
|
|
bool MipsPassConfig::addInstSelector() {
|
2017-05-19 01:21:13 +08:00
|
|
|
addPass(createMipsModuleISelDagPass());
|
[mips] SelectionDAGISel subclasses now follow the optimization level.
Summary:
It was recently discovered that, for Mips's SelectionDAGISel subclasses,
all optimization levels caused SelectionDAGISel to behave like -O2.
This change adds the necessary plumbing to initialize the optimization level.
Reviewers: andrew.w.kaylor
Subscribers: andrew.w.kaylor, sdardis, dean, llvm-commits, vradosavljevic, petarj, qcolombet, probinson, dsanders
Differential Revision: https://reviews.llvm.org/D14900
llvm-svn: 275410
2016-07-14 21:25:22 +08:00
|
|
|
addPass(createMips16ISelDag(getMipsTargetMachine(), getOptLevel()));
|
|
|
|
addPass(createMipsSEISelDag(getMipsTargetMachine(), getOptLevel()));
|
2007-06-06 15:42:06 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-12-12 05:26:47 +08:00
|
|
|
void MipsPassConfig::addPreRegAlloc() {
|
2017-05-19 01:21:13 +08:00
|
|
|
addPass(createMipsOptimizePICCallPass());
|
2014-03-11 00:31:25 +08:00
|
|
|
}
|
|
|
|
|
(Re-landing) Expose a TargetMachine::getTargetTransformInfo function
Re-land r321234. It had to be reverted because it broke the shared
library build. The shared library build broke because there was a
missing LLVMBuild dependency from lib/Passes (which calls
TargetMachine::getTargetIRAnalysis) to lib/Target. As far as I can
tell, this problem was always there but was somehow masked
before (perhaps because TargetMachine::getTargetIRAnalysis was a
virtual function).
Original commit message:
This makes the TargetMachine interface a bit simpler. We still need
the std::function in TargetIRAnalysis to avoid having to add a
dependency from Analysis to Target.
See discussion:
http://lists.llvm.org/pipermail/llvm-dev/2017-December/119749.html
I avoided adding all of the backend owners to this review since the
change is simple, but let me know if you feel differently about this.
Reviewers: echristo, MatzeB, hfinkel
Reviewed By: hfinkel
Subscribers: jholewinski, jfb, arsenm, dschuff, mcrosier, sdardis, nemanjai, nhaehnle, javed.absar, sbc100, jgravelle-google, aheejin, kbarton, llvm-commits
Differential Revision: https://reviews.llvm.org/D41464
llvm-svn: 321375
2017-12-23 02:21:59 +08:00
|
|
|
TargetTransformInfo
|
|
|
|
MipsTargetMachine::getTargetTransformInfo(const Function &F) {
|
|
|
|
if (Subtarget->allowMixed16_32()) {
|
2018-05-14 20:53:11 +08:00
|
|
|
LLVM_DEBUG(errs() << "No Target Transform Info Pass Added\n");
|
(Re-landing) Expose a TargetMachine::getTargetTransformInfo function
Re-land r321234. It had to be reverted because it broke the shared
library build. The shared library build broke because there was a
missing LLVMBuild dependency from lib/Passes (which calls
TargetMachine::getTargetIRAnalysis) to lib/Target. As far as I can
tell, this problem was always there but was somehow masked
before (perhaps because TargetMachine::getTargetIRAnalysis was a
virtual function).
Original commit message:
This makes the TargetMachine interface a bit simpler. We still need
the std::function in TargetIRAnalysis to avoid having to add a
dependency from Analysis to Target.
See discussion:
http://lists.llvm.org/pipermail/llvm-dev/2017-December/119749.html
I avoided adding all of the backend owners to this review since the
change is simple, but let me know if you feel differently about this.
Reviewers: echristo, MatzeB, hfinkel
Reviewed By: hfinkel
Subscribers: jholewinski, jfb, arsenm, dschuff, mcrosier, sdardis, nemanjai, nhaehnle, javed.absar, sbc100, jgravelle-google, aheejin, kbarton, llvm-commits
Differential Revision: https://reviews.llvm.org/D41464
llvm-svn: 321375
2017-12-23 02:21:59 +08:00
|
|
|
// FIXME: This is no longer necessary as the TTI returned is per-function.
|
|
|
|
return TargetTransformInfo(F.getParent()->getDataLayout());
|
|
|
|
}
|
|
|
|
|
2018-05-14 20:53:11 +08:00
|
|
|
LLVM_DEBUG(errs() << "Target Transform Info Pass Added\n");
|
(Re-landing) Expose a TargetMachine::getTargetTransformInfo function
Re-land r321234. It had to be reverted because it broke the shared
library build. The shared library build broke because there was a
missing LLVMBuild dependency from lib/Passes (which calls
TargetMachine::getTargetIRAnalysis) to lib/Target. As far as I can
tell, this problem was always there but was somehow masked
before (perhaps because TargetMachine::getTargetIRAnalysis was a
virtual function).
Original commit message:
This makes the TargetMachine interface a bit simpler. We still need
the std::function in TargetIRAnalysis to avoid having to add a
dependency from Analysis to Target.
See discussion:
http://lists.llvm.org/pipermail/llvm-dev/2017-December/119749.html
I avoided adding all of the backend owners to this review since the
change is simple, but let me know if you feel differently about this.
Reviewers: echristo, MatzeB, hfinkel
Reviewed By: hfinkel
Subscribers: jholewinski, jfb, arsenm, dschuff, mcrosier, sdardis, nemanjai, nhaehnle, javed.absar, sbc100, jgravelle-google, aheejin, kbarton, llvm-commits
Differential Revision: https://reviews.llvm.org/D41464
llvm-svn: 321375
2017-12-23 02:21:59 +08:00
|
|
|
return TargetTransformInfo(BasicTTIImpl(this, F));
|
2013-04-10 03:46:01 +08:00
|
|
|
}
|
|
|
|
|
2010-11-15 08:06:54 +08:00
|
|
|
// Implemented by targets that want to run passes immediately before
|
|
|
|
// machine code is emitted. return true if -print-machineinstrs should
|
2007-06-06 15:42:06 +08:00
|
|
|
// print out the code after the passes.
|
2014-12-12 05:26:47 +08:00
|
|
|
void MipsPassConfig::addPreEmitPass() {
|
2018-07-05 17:27:05 +08:00
|
|
|
// Expand pseudo instructions that are sensitive to register allocation.
|
|
|
|
addPass(createMipsExpandPseudoPass());
|
|
|
|
|
|
|
|
// The microMIPS size reduction pass performs instruction reselection for
|
|
|
|
// instructions which can be remapped to a 16 bit instruction.
|
2018-06-13 20:51:37 +08:00
|
|
|
addPass(createMicroMipsSizeReducePass());
|
2016-03-15 00:24:05 +08:00
|
|
|
|
2018-05-22 21:24:38 +08:00
|
|
|
// The delay slot filler pass can potientially create forbidden slot hazards
|
|
|
|
// for MIPSR6 and therefore it should go before MipsBranchExpansion pass.
|
2017-05-19 01:21:13 +08:00
|
|
|
addPass(createMipsDelaySlotFillerPass());
|
2018-05-22 21:24:38 +08:00
|
|
|
|
|
|
|
// This pass expands branches and takes care about the forbidden slot hazards.
|
|
|
|
// Expanding branches may potentially create forbidden slot hazards for
|
|
|
|
// MIPSR6, and fixing such hazard may potentially break a branch by extending
|
|
|
|
// its offset out of range. That's why this pass combine these two tasks, and
|
|
|
|
// runs them alternately until one of them finishes without any changes. Only
|
|
|
|
// then we can be sure that all branches are expanded properly and no hazards
|
|
|
|
// exists.
|
|
|
|
// Any new pass should go before this pass.
|
|
|
|
addPass(createMipsBranchExpansion());
|
|
|
|
|
2016-06-28 22:26:39 +08:00
|
|
|
addPass(createMipsConstantIslandPass());
|
2007-06-06 15:42:06 +08:00
|
|
|
}
|
2018-02-23 19:06:40 +08:00
|
|
|
|
|
|
|
bool MipsPassConfig::addIRTranslator() {
|
|
|
|
addPass(new IRTranslator());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MipsPassConfig::addLegalizeMachineIR() {
|
|
|
|
addPass(new Legalizer());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MipsPassConfig::addRegBankSelect() {
|
|
|
|
addPass(new RegBankSelect());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MipsPassConfig::addGlobalInstructionSelect() {
|
|
|
|
addPass(new InstructionSelect());
|
|
|
|
return false;
|
|
|
|
}
|