2013-05-07 00:15:19 +08:00
|
|
|
//===-- SystemZMCTargetDesc.cpp - SystemZ target descriptions -------------===//
|
|
|
|
//
|
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
|
2013-05-07 00:15:19 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "SystemZMCTargetDesc.h"
|
2019-05-11 11:36:16 +08:00
|
|
|
#include "SystemZInstPrinter.h"
|
2013-05-07 00:15:19 +08:00
|
|
|
#include "SystemZMCAsmInfo.h"
|
2021-09-12 23:16:35 +08:00
|
|
|
#include "SystemZTargetStreamer.h"
|
2019-05-15 08:46:18 +08:00
|
|
|
#include "TargetInfo/SystemZTargetInfo.h"
|
2021-09-09 23:26:50 +08:00
|
|
|
#include "llvm/MC/MCContext.h"
|
2019-04-12 15:40:01 +08:00
|
|
|
#include "llvm/MC/MCDwarf.h"
|
2013-05-07 00:15:19 +08:00
|
|
|
#include "llvm/MC/MCInstrInfo.h"
|
2015-05-16 05:58:42 +08:00
|
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
2013-05-07 00:15:19 +08:00
|
|
|
#include "llvm/MC/MCStreamer.h"
|
|
|
|
#include "llvm/MC/MCSubtargetInfo.h"
|
2021-10-09 01:48:15 +08:00
|
|
|
#include "llvm/MC/TargetRegistry.h"
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2014-04-22 10:03:14 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2013-05-07 00:15:19 +08:00
|
|
|
#define GET_INSTRINFO_MC_DESC
|
|
|
|
#include "SystemZGenInstrInfo.inc"
|
|
|
|
|
|
|
|
#define GET_SUBTARGETINFO_MC_DESC
|
|
|
|
#include "SystemZGenSubtargetInfo.inc"
|
|
|
|
|
|
|
|
#define GET_REGINFO_MC_DESC
|
|
|
|
#include "SystemZGenRegisterInfo.inc"
|
|
|
|
|
2013-05-14 17:36:44 +08:00
|
|
|
const unsigned SystemZMC::GR32Regs[16] = {
|
2013-09-30 16:48:38 +08:00
|
|
|
SystemZ::R0L, SystemZ::R1L, SystemZ::R2L, SystemZ::R3L,
|
|
|
|
SystemZ::R4L, SystemZ::R5L, SystemZ::R6L, SystemZ::R7L,
|
|
|
|
SystemZ::R8L, SystemZ::R9L, SystemZ::R10L, SystemZ::R11L,
|
|
|
|
SystemZ::R12L, SystemZ::R13L, SystemZ::R14L, SystemZ::R15L
|
2013-05-14 17:36:44 +08:00
|
|
|
};
|
|
|
|
|
2013-09-30 18:45:16 +08:00
|
|
|
const unsigned SystemZMC::GRH32Regs[16] = {
|
|
|
|
SystemZ::R0H, SystemZ::R1H, SystemZ::R2H, SystemZ::R3H,
|
|
|
|
SystemZ::R4H, SystemZ::R5H, SystemZ::R6H, SystemZ::R7H,
|
|
|
|
SystemZ::R8H, SystemZ::R9H, SystemZ::R10H, SystemZ::R11H,
|
|
|
|
SystemZ::R12H, SystemZ::R13H, SystemZ::R14H, SystemZ::R15H
|
|
|
|
};
|
|
|
|
|
2013-05-14 17:36:44 +08:00
|
|
|
const unsigned SystemZMC::GR64Regs[16] = {
|
|
|
|
SystemZ::R0D, SystemZ::R1D, SystemZ::R2D, SystemZ::R3D,
|
|
|
|
SystemZ::R4D, SystemZ::R5D, SystemZ::R6D, SystemZ::R7D,
|
|
|
|
SystemZ::R8D, SystemZ::R9D, SystemZ::R10D, SystemZ::R11D,
|
|
|
|
SystemZ::R12D, SystemZ::R13D, SystemZ::R14D, SystemZ::R15D
|
|
|
|
};
|
|
|
|
|
|
|
|
const unsigned SystemZMC::GR128Regs[16] = {
|
|
|
|
SystemZ::R0Q, 0, SystemZ::R2Q, 0,
|
|
|
|
SystemZ::R4Q, 0, SystemZ::R6Q, 0,
|
|
|
|
SystemZ::R8Q, 0, SystemZ::R10Q, 0,
|
|
|
|
SystemZ::R12Q, 0, SystemZ::R14Q, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
const unsigned SystemZMC::FP32Regs[16] = {
|
|
|
|
SystemZ::F0S, SystemZ::F1S, SystemZ::F2S, SystemZ::F3S,
|
|
|
|
SystemZ::F4S, SystemZ::F5S, SystemZ::F6S, SystemZ::F7S,
|
|
|
|
SystemZ::F8S, SystemZ::F9S, SystemZ::F10S, SystemZ::F11S,
|
|
|
|
SystemZ::F12S, SystemZ::F13S, SystemZ::F14S, SystemZ::F15S
|
|
|
|
};
|
|
|
|
|
|
|
|
const unsigned SystemZMC::FP64Regs[16] = {
|
|
|
|
SystemZ::F0D, SystemZ::F1D, SystemZ::F2D, SystemZ::F3D,
|
|
|
|
SystemZ::F4D, SystemZ::F5D, SystemZ::F6D, SystemZ::F7D,
|
|
|
|
SystemZ::F8D, SystemZ::F9D, SystemZ::F10D, SystemZ::F11D,
|
|
|
|
SystemZ::F12D, SystemZ::F13D, SystemZ::F14D, SystemZ::F15D
|
|
|
|
};
|
|
|
|
|
|
|
|
const unsigned SystemZMC::FP128Regs[16] = {
|
|
|
|
SystemZ::F0Q, SystemZ::F1Q, 0, 0,
|
|
|
|
SystemZ::F4Q, SystemZ::F5Q, 0, 0,
|
|
|
|
SystemZ::F8Q, SystemZ::F9Q, 0, 0,
|
|
|
|
SystemZ::F12Q, SystemZ::F13Q, 0, 0
|
|
|
|
};
|
|
|
|
|
2015-05-06 03:23:40 +08:00
|
|
|
const unsigned SystemZMC::VR32Regs[32] = {
|
|
|
|
SystemZ::F0S, SystemZ::F1S, SystemZ::F2S, SystemZ::F3S,
|
|
|
|
SystemZ::F4S, SystemZ::F5S, SystemZ::F6S, SystemZ::F7S,
|
|
|
|
SystemZ::F8S, SystemZ::F9S, SystemZ::F10S, SystemZ::F11S,
|
|
|
|
SystemZ::F12S, SystemZ::F13S, SystemZ::F14S, SystemZ::F15S,
|
|
|
|
SystemZ::F16S, SystemZ::F17S, SystemZ::F18S, SystemZ::F19S,
|
|
|
|
SystemZ::F20S, SystemZ::F21S, SystemZ::F22S, SystemZ::F23S,
|
|
|
|
SystemZ::F24S, SystemZ::F25S, SystemZ::F26S, SystemZ::F27S,
|
|
|
|
SystemZ::F28S, SystemZ::F29S, SystemZ::F30S, SystemZ::F31S
|
|
|
|
};
|
|
|
|
|
|
|
|
const unsigned SystemZMC::VR64Regs[32] = {
|
|
|
|
SystemZ::F0D, SystemZ::F1D, SystemZ::F2D, SystemZ::F3D,
|
|
|
|
SystemZ::F4D, SystemZ::F5D, SystemZ::F6D, SystemZ::F7D,
|
|
|
|
SystemZ::F8D, SystemZ::F9D, SystemZ::F10D, SystemZ::F11D,
|
|
|
|
SystemZ::F12D, SystemZ::F13D, SystemZ::F14D, SystemZ::F15D,
|
|
|
|
SystemZ::F16D, SystemZ::F17D, SystemZ::F18D, SystemZ::F19D,
|
|
|
|
SystemZ::F20D, SystemZ::F21D, SystemZ::F22D, SystemZ::F23D,
|
|
|
|
SystemZ::F24D, SystemZ::F25D, SystemZ::F26D, SystemZ::F27D,
|
|
|
|
SystemZ::F28D, SystemZ::F29D, SystemZ::F30D, SystemZ::F31D
|
|
|
|
};
|
|
|
|
|
|
|
|
const unsigned SystemZMC::VR128Regs[32] = {
|
|
|
|
SystemZ::V0, SystemZ::V1, SystemZ::V2, SystemZ::V3,
|
|
|
|
SystemZ::V4, SystemZ::V5, SystemZ::V6, SystemZ::V7,
|
|
|
|
SystemZ::V8, SystemZ::V9, SystemZ::V10, SystemZ::V11,
|
|
|
|
SystemZ::V12, SystemZ::V13, SystemZ::V14, SystemZ::V15,
|
|
|
|
SystemZ::V16, SystemZ::V17, SystemZ::V18, SystemZ::V19,
|
|
|
|
SystemZ::V20, SystemZ::V21, SystemZ::V22, SystemZ::V23,
|
|
|
|
SystemZ::V24, SystemZ::V25, SystemZ::V26, SystemZ::V27,
|
|
|
|
SystemZ::V28, SystemZ::V29, SystemZ::V30, SystemZ::V31
|
|
|
|
};
|
|
|
|
|
2016-11-09 04:15:26 +08:00
|
|
|
const unsigned SystemZMC::AR32Regs[16] = {
|
|
|
|
SystemZ::A0, SystemZ::A1, SystemZ::A2, SystemZ::A3,
|
|
|
|
SystemZ::A4, SystemZ::A5, SystemZ::A6, SystemZ::A7,
|
|
|
|
SystemZ::A8, SystemZ::A9, SystemZ::A10, SystemZ::A11,
|
|
|
|
SystemZ::A12, SystemZ::A13, SystemZ::A14, SystemZ::A15
|
|
|
|
};
|
|
|
|
|
2017-07-01 04:43:40 +08:00
|
|
|
const unsigned SystemZMC::CR64Regs[16] = {
|
|
|
|
SystemZ::C0, SystemZ::C1, SystemZ::C2, SystemZ::C3,
|
|
|
|
SystemZ::C4, SystemZ::C5, SystemZ::C6, SystemZ::C7,
|
|
|
|
SystemZ::C8, SystemZ::C9, SystemZ::C10, SystemZ::C11,
|
|
|
|
SystemZ::C12, SystemZ::C13, SystemZ::C14, SystemZ::C15
|
|
|
|
};
|
|
|
|
|
2013-09-25 18:11:07 +08:00
|
|
|
unsigned SystemZMC::getFirstReg(unsigned Reg) {
|
|
|
|
static unsigned Map[SystemZ::NUM_TARGET_REGS];
|
|
|
|
static bool Initialized = false;
|
|
|
|
if (!Initialized) {
|
|
|
|
for (unsigned I = 0; I < 16; ++I) {
|
|
|
|
Map[GR32Regs[I]] = I;
|
2013-10-01 19:26:28 +08:00
|
|
|
Map[GRH32Regs[I]] = I;
|
2013-09-25 18:11:07 +08:00
|
|
|
Map[GR64Regs[I]] = I;
|
|
|
|
Map[GR128Regs[I]] = I;
|
|
|
|
Map[FP128Regs[I]] = I;
|
2016-11-09 04:15:26 +08:00
|
|
|
Map[AR32Regs[I]] = I;
|
2013-09-25 18:11:07 +08:00
|
|
|
}
|
2015-05-06 03:23:40 +08:00
|
|
|
for (unsigned I = 0; I < 32; ++I) {
|
|
|
|
Map[VR32Regs[I]] = I;
|
|
|
|
Map[VR64Regs[I]] = I;
|
|
|
|
Map[VR128Regs[I]] = I;
|
|
|
|
}
|
2013-09-25 18:11:07 +08:00
|
|
|
}
|
|
|
|
assert(Reg < SystemZ::NUM_TARGET_REGS);
|
|
|
|
return Map[Reg];
|
|
|
|
}
|
|
|
|
|
2013-05-13 09:16:13 +08:00
|
|
|
static MCAsmInfo *createSystemZMCAsmInfo(const MCRegisterInfo &MRI,
|
2019-10-23 18:24:35 +08:00
|
|
|
const Triple &TT,
|
|
|
|
const MCTargetOptions &Options) {
|
2021-09-25 04:25:27 +08:00
|
|
|
if (TT.isOSzOS())
|
|
|
|
return new SystemZMCAsmInfoGOFF(TT);
|
|
|
|
|
|
|
|
MCAsmInfo *MAI = new SystemZMCAsmInfoELF(TT);
|
2020-05-23 06:18:05 +08:00
|
|
|
MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(
|
|
|
|
nullptr, MRI.getDwarfRegNum(SystemZ::R15D, true),
|
2021-03-10 03:34:48 +08:00
|
|
|
SystemZMC::ELFCFAOffsetFromInitialSP);
|
2013-05-13 09:16:13 +08:00
|
|
|
MAI->addInitialFrameState(Inst);
|
2013-05-07 00:15:19 +08:00
|
|
|
return MAI;
|
|
|
|
}
|
|
|
|
|
|
|
|
static MCInstrInfo *createSystemZMCInstrInfo() {
|
|
|
|
MCInstrInfo *X = new MCInstrInfo();
|
|
|
|
InitSystemZMCInstrInfo(X);
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2015-09-16 00:17:27 +08:00
|
|
|
static MCRegisterInfo *createSystemZMCRegisterInfo(const Triple &TT) {
|
2013-05-07 00:15:19 +08:00
|
|
|
MCRegisterInfo *X = new MCRegisterInfo();
|
|
|
|
InitSystemZMCRegisterInfo(X, SystemZ::R14D);
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2015-09-16 00:17:27 +08:00
|
|
|
static MCSubtargetInfo *
|
|
|
|
createSystemZMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
|
2020-08-15 05:56:54 +08:00
|
|
|
return createSystemZMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
|
2013-05-07 00:15:19 +08:00
|
|
|
}
|
|
|
|
|
2015-09-16 00:17:27 +08:00
|
|
|
static MCInstPrinter *createSystemZMCInstPrinter(const Triple &T,
|
2015-03-31 08:10:04 +08:00
|
|
|
unsigned SyntaxVariant,
|
2013-05-07 00:15:19 +08:00
|
|
|
const MCAsmInfo &MAI,
|
|
|
|
const MCInstrInfo &MII,
|
2015-03-31 08:10:04 +08:00
|
|
|
const MCRegisterInfo &MRI) {
|
2013-05-07 00:15:19 +08:00
|
|
|
return new SystemZInstPrinter(MAI, MII, MRI);
|
|
|
|
}
|
|
|
|
|
2021-09-09 23:26:50 +08:00
|
|
|
void SystemZTargetStreamer::emitConstantPools() {
|
|
|
|
// Emit EXRL target instructions.
|
|
|
|
if (EXRLTargets2Sym.empty())
|
|
|
|
return;
|
|
|
|
// Switch to the .text section.
|
|
|
|
const MCObjectFileInfo &OFI = *Streamer.getContext().getObjectFileInfo();
|
|
|
|
Streamer.SwitchSection(OFI.getTextSection());
|
|
|
|
for (auto &I : EXRLTargets2Sym) {
|
|
|
|
Streamer.emitLabel(I.second);
|
|
|
|
const MCInstSTIPair &MCI_STI = I.first;
|
|
|
|
Streamer.emitInstruction(MCI_STI.first, *MCI_STI.second);
|
|
|
|
}
|
|
|
|
EXRLTargets2Sym.clear();
|
|
|
|
}
|
|
|
|
|
2021-09-12 23:16:35 +08:00
|
|
|
namespace {
|
|
|
|
class SystemZTargetAsmStreamer : public SystemZTargetStreamer {
|
|
|
|
formatted_raw_ostream &OS;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SystemZTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS)
|
|
|
|
: SystemZTargetStreamer(S), OS(OS) {}
|
|
|
|
void emitMachine(StringRef CPU) override {
|
|
|
|
OS << "\t.machine " << CPU << "\n";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class SystemZTargetELFStreamer : public SystemZTargetStreamer {
|
|
|
|
public:
|
|
|
|
SystemZTargetELFStreamer(MCStreamer &S) : SystemZTargetStreamer(S) {}
|
|
|
|
void emitMachine(StringRef CPU) override {}
|
|
|
|
};
|
|
|
|
} // end namespace
|
|
|
|
|
|
|
|
static MCTargetStreamer *
|
|
|
|
createAsmTargetStreamer(MCStreamer &S,
|
|
|
|
formatted_raw_ostream &OS,
|
|
|
|
MCInstPrinter *InstPrint,
|
|
|
|
bool isVerboseAsm) {
|
|
|
|
return new SystemZTargetAsmStreamer(S, OS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static MCTargetStreamer *
|
|
|
|
createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
|
|
|
|
return new SystemZTargetELFStreamer(S);
|
|
|
|
}
|
|
|
|
|
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 LLVMInitializeSystemZTargetMC() {
|
2013-05-07 00:15:19 +08:00
|
|
|
// Register the MCAsmInfo.
|
2016-10-10 07:00:34 +08:00
|
|
|
TargetRegistry::RegisterMCAsmInfo(getTheSystemZTarget(),
|
2013-05-07 00:15:19 +08:00
|
|
|
createSystemZMCAsmInfo);
|
|
|
|
|
|
|
|
// Register the MCCodeEmitter.
|
2016-10-10 07:00:34 +08:00
|
|
|
TargetRegistry::RegisterMCCodeEmitter(getTheSystemZTarget(),
|
2015-09-22 19:15:07 +08:00
|
|
|
createSystemZMCCodeEmitter);
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// Register the MCInstrInfo.
|
2016-10-10 07:00:34 +08:00
|
|
|
TargetRegistry::RegisterMCInstrInfo(getTheSystemZTarget(),
|
2013-05-07 00:15:19 +08:00
|
|
|
createSystemZMCInstrInfo);
|
|
|
|
|
|
|
|
// Register the MCRegisterInfo.
|
2016-10-10 07:00:34 +08:00
|
|
|
TargetRegistry::RegisterMCRegInfo(getTheSystemZTarget(),
|
2013-05-07 00:15:19 +08:00
|
|
|
createSystemZMCRegisterInfo);
|
|
|
|
|
|
|
|
// Register the MCSubtargetInfo.
|
2016-10-10 07:00:34 +08:00
|
|
|
TargetRegistry::RegisterMCSubtargetInfo(getTheSystemZTarget(),
|
2013-05-07 00:15:19 +08:00
|
|
|
createSystemZMCSubtargetInfo);
|
|
|
|
|
|
|
|
// Register the MCAsmBackend.
|
2016-10-10 07:00:34 +08:00
|
|
|
TargetRegistry::RegisterMCAsmBackend(getTheSystemZTarget(),
|
2013-05-07 00:15:19 +08:00
|
|
|
createSystemZMCAsmBackend);
|
|
|
|
|
|
|
|
// Register the MCInstPrinter.
|
2016-10-10 07:00:34 +08:00
|
|
|
TargetRegistry::RegisterMCInstPrinter(getTheSystemZTarget(),
|
2013-05-07 00:15:19 +08:00
|
|
|
createSystemZMCInstPrinter);
|
2021-09-12 23:16:35 +08:00
|
|
|
|
|
|
|
// Register the asm streamer.
|
|
|
|
TargetRegistry::RegisterAsmTargetStreamer(getTheSystemZTarget(),
|
|
|
|
createAsmTargetStreamer);
|
|
|
|
|
|
|
|
// Register the obj streamer
|
|
|
|
TargetRegistry::RegisterObjectTargetStreamer(getTheSystemZTarget(),
|
|
|
|
createObjectTargetStreamer);
|
2013-05-07 00:15:19 +08:00
|
|
|
}
|