2016-03-28 21:09:54 +08:00
|
|
|
//===-- LanaiTargetMachine.cpp - Define TargetMachine for Lanai ---------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-03-28 21:09:54 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Implements the info about Lanai target spec.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "LanaiTargetMachine.h"
|
|
|
|
|
|
|
|
#include "Lanai.h"
|
|
|
|
#include "LanaiTargetObjectFile.h"
|
|
|
|
#include "LanaiTargetTransformInfo.h"
|
2019-05-15 07:17:18 +08:00
|
|
|
#include "TargetInfo/LanaiTargetInfo.h"
|
2016-03-28 21:09:54 +08:00
|
|
|
#include "llvm/Analysis/TargetTransformInfo.h"
|
|
|
|
#include "llvm/CodeGen/Passes.h"
|
|
|
|
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
|
2016-05-21 05:41:53 +08:00
|
|
|
#include "llvm/CodeGen/TargetPassConfig.h"
|
2016-03-28 21:09:54 +08:00
|
|
|
#include "llvm/Support/FormattedStream.h"
|
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
|
|
|
#include "llvm/Target/TargetOptions.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
void initializeLanaiMemAluCombinerPass(PassRegistry &);
|
|
|
|
} // namespace llvm
|
|
|
|
|
CMake: Make most target symbols hidden by default
Summary:
For builds with LLVM_BUILD_LLVM_DYLIB=ON and BUILD_SHARED_LIBS=OFF
this change makes all symbols in the target specific libraries hidden
by default.
A new macro called LLVM_EXTERNAL_VISIBILITY has been added to mark symbols in these
libraries public, which is mainly needed for the definitions of the
LLVMInitialize* functions.
This patch reduces the number of public symbols in libLLVM.so by about
25%. This should improve load times for the dynamic library and also
make abi checker tools, like abidiff require less memory when analyzing
libLLVM.so
One side-effect of this change is that for builds with
LLVM_BUILD_LLVM_DYLIB=ON and LLVM_LINK_LLVM_DYLIB=ON some unittests that
access symbols that are no longer public will need to be statically linked.
Before and after public symbol counts (using gcc 8.2.1, ld.bfd 2.31.1):
nm before/libLLVM-9svn.so | grep ' [A-Zuvw] ' | wc -l
36221
nm after/libLLVM-9svn.so | grep ' [A-Zuvw] ' | wc -l
26278
Reviewers: chandlerc, beanz, mgorny, rnk, hans
Reviewed By: rnk, hans
Subscribers: merge_guards_bot, luismarques, smeenai, ldionne, lenary, s.egerton, pzheng, sameer.abuasal, MaskRay, wuzish, echristo, Jim, hiraditya, michaelplatings, chapuni, jholewinski, arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, javed.absar, sbc100, jgravelle-google, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, mgrang, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, kristina, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D54439
2020-01-15 11:15:07 +08:00
|
|
|
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLanaiTarget() {
|
2016-03-28 21:09:54 +08:00
|
|
|
// Register the target.
|
2016-10-10 07:00:34 +08:00
|
|
|
RegisterTargetMachine<LanaiTargetMachine> registered_target(
|
|
|
|
getTheLanaiTarget());
|
2016-03-28 21:09:54 +08:00
|
|
|
}
|
|
|
|
|
2016-07-16 06:38:32 +08:00
|
|
|
static std::string computeDataLayout() {
|
2016-03-28 21:09:54 +08:00
|
|
|
// Data layout (keep in sync with clang/lib/Basic/Targets.cpp)
|
|
|
|
return "E" // Big endian
|
|
|
|
"-m:e" // ELF name manging
|
|
|
|
"-p:32:32" // 32-bit pointers, 32 bit aligned
|
|
|
|
"-i64:64" // 64 bit integers, 64 bit aligned
|
|
|
|
"-a:0:32" // 32 bit alignment of objects of aggregate type
|
|
|
|
"-n32" // 32 bit native integer width
|
|
|
|
"-S64"; // 64 bit natural stack alignment
|
|
|
|
}
|
|
|
|
|
2016-07-16 06:38:32 +08:00
|
|
|
static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
|
2021-01-13 13:43:50 +08:00
|
|
|
return RM.getValueOr(Reloc::PIC_);
|
2016-05-20 11:21:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
LanaiTargetMachine::LanaiTargetMachine(const Target &T, const Triple &TT,
|
2016-03-28 21:09:54 +08:00
|
|
|
StringRef Cpu, StringRef FeatureString,
|
|
|
|
const TargetOptions &Options,
|
2016-05-20 11:21:37 +08:00
|
|
|
Optional<Reloc::Model> RM,
|
2017-08-03 10:16:21 +08:00
|
|
|
Optional<CodeModel::Model> CodeModel,
|
|
|
|
CodeGenOpt::Level OptLevel, bool JIT)
|
2017-10-13 06:57:28 +08:00
|
|
|
: LLVMTargetMachine(T, computeDataLayout(), TT, Cpu, FeatureString, Options,
|
|
|
|
getEffectiveRelocModel(RM),
|
2018-12-07 20:10:23 +08:00
|
|
|
getEffectiveCodeModel(CodeModel, CodeModel::Medium),
|
|
|
|
OptLevel),
|
2017-08-03 10:16:21 +08:00
|
|
|
Subtarget(TT, Cpu, FeatureString, *this, Options, getCodeModel(),
|
|
|
|
OptLevel),
|
2016-03-28 21:09:54 +08:00
|
|
|
TLOF(new LanaiTargetObjectFile()) {
|
|
|
|
initAsmInfo();
|
|
|
|
}
|
|
|
|
|
(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
|
|
|
|
LanaiTargetMachine::getTargetTransformInfo(const Function &F) {
|
|
|
|
return TargetTransformInfo(LanaiTTIImpl(this, F));
|
2016-03-28 21:09:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
// Lanai Code Generator Pass Configuration Options.
|
|
|
|
class LanaiPassConfig : public TargetPassConfig {
|
|
|
|
public:
|
2017-05-31 05:36:41 +08:00
|
|
|
LanaiPassConfig(LanaiTargetMachine &TM, PassManagerBase *PassManager)
|
2016-03-28 21:09:54 +08:00
|
|
|
: TargetPassConfig(TM, *PassManager) {}
|
|
|
|
|
|
|
|
LanaiTargetMachine &getLanaiTargetMachine() const {
|
|
|
|
return getTM<LanaiTargetMachine>();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool addInstSelector() override;
|
|
|
|
void addPreSched2() override;
|
|
|
|
void addPreEmitPass() override;
|
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
TargetPassConfig *
|
|
|
|
LanaiTargetMachine::createPassConfig(PassManagerBase &PassManager) {
|
2017-05-31 05:36:41 +08:00
|
|
|
return new LanaiPassConfig(*this, &PassManager);
|
2016-03-28 21:09:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Install an instruction selector pass.
|
|
|
|
bool LanaiPassConfig::addInstSelector() {
|
|
|
|
addPass(createLanaiISelDag(getLanaiTargetMachine()));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implemented by targets that want to run passes immediately before
|
|
|
|
// machine code is emitted.
|
|
|
|
void LanaiPassConfig::addPreEmitPass() {
|
|
|
|
addPass(createLanaiDelaySlotFillerPass(getLanaiTargetMachine()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run passes after prolog-epilog insertion and before the second instruction
|
|
|
|
// scheduling pass.
|
|
|
|
void LanaiPassConfig::addPreSched2() {
|
|
|
|
addPass(createLanaiMemAluCombinerPass());
|
|
|
|
}
|