2017-08-24 17:40:33 +02:00
|
|
|
//===- ARCTargetMachine.cpp - Define TargetMachine for ARC ------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01: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
|
2017-08-24 17:40:33 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ARCTargetMachine.h"
|
|
|
|
#include "ARC.h"
|
|
|
|
#include "ARCTargetTransformInfo.h"
|
2019-05-15 00:06:04 +02:00
|
|
|
#include "TargetInfo/ARCTargetInfo.h"
|
2017-08-24 17:40:33 +02:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
|
|
|
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
|
|
|
|
#include "llvm/CodeGen/TargetPassConfig.h"
|
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
static Reloc::Model getRelocModel(Optional<Reloc::Model> RM) {
|
2021-01-13 06:43:50 +01:00
|
|
|
return RM.getValueOr(Reloc::Static);
|
2017-08-24 17:40:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// ARCTargetMachine ctor - Create an ILP32 architecture model
|
|
|
|
ARCTargetMachine::ARCTargetMachine(const Target &T, const Triple &TT,
|
|
|
|
StringRef CPU, StringRef FS,
|
|
|
|
const TargetOptions &Options,
|
|
|
|
Optional<Reloc::Model> RM,
|
|
|
|
Optional<CodeModel::Model> CM,
|
|
|
|
CodeGenOpt::Level OL, bool JIT)
|
2017-10-13 00:57:28 +02:00
|
|
|
: LLVMTargetMachine(T,
|
|
|
|
"e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-"
|
|
|
|
"f32:32:32-i64:32-f64:32-a:0:32-n32",
|
|
|
|
TT, CPU, FS, Options, getRelocModel(RM),
|
2018-12-07 13:10:23 +01:00
|
|
|
getEffectiveCodeModel(CM, CodeModel::Small), OL),
|
2019-08-15 17:54:37 +02:00
|
|
|
TLOF(std::make_unique<TargetLoweringObjectFileELF>()),
|
2020-01-29 09:59:16 +01:00
|
|
|
Subtarget(TT, std::string(CPU), std::string(FS), *this) {
|
2017-08-24 17:40:33 +02:00
|
|
|
initAsmInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
ARCTargetMachine::~ARCTargetMachine() = default;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
/// ARC Code Generator Pass Configuration Options.
|
|
|
|
class ARCPassConfig : public TargetPassConfig {
|
|
|
|
public:
|
|
|
|
ARCPassConfig(ARCTargetMachine &TM, PassManagerBase &PM)
|
|
|
|
: TargetPassConfig(TM, PM) {}
|
|
|
|
|
|
|
|
ARCTargetMachine &getARCTargetMachine() const {
|
|
|
|
return getTM<ARCTargetMachine>();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool addInstSelector() override;
|
|
|
|
void addPreEmitPass() override;
|
|
|
|
void addPreRegAlloc() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end anonymous namespace
|
|
|
|
|
|
|
|
TargetPassConfig *ARCTargetMachine::createPassConfig(PassManagerBase &PM) {
|
|
|
|
return new ARCPassConfig(*this, PM);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ARCPassConfig::addInstSelector() {
|
|
|
|
addPass(createARCISelDag(getARCTargetMachine(), getOptLevel()));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ARCPassConfig::addPreEmitPass() { addPass(createARCBranchFinalizePass()); }
|
|
|
|
|
2019-03-20 21:06:21 +01:00
|
|
|
void ARCPassConfig::addPreRegAlloc() {
|
|
|
|
addPass(createARCExpandPseudosPass());
|
|
|
|
addPass(createARCOptAddrMode());
|
|
|
|
}
|
2017-08-24 17:40:33 +02:00
|
|
|
|
|
|
|
// Force static initialization.
|
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 04:15:07 +01:00
|
|
|
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCTarget() {
|
2017-08-24 17:40:33 +02:00
|
|
|
RegisterTargetMachine<ARCTargetMachine> X(getTheARCTarget());
|
|
|
|
}
|
|
|
|
|
(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-22 19:21:59 +01:00
|
|
|
TargetTransformInfo
|
|
|
|
ARCTargetMachine::getTargetTransformInfo(const Function &F) {
|
|
|
|
return TargetTransformInfo(ARCTTIImpl(this, F));
|
2017-08-24 17:40:33 +02:00
|
|
|
}
|