LLVM 19.0.0git
SystemZSubtarget.cpp
Go to the documentation of this file.
1//===-- SystemZSubtarget.cpp - SystemZ subtarget information --------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "SystemZSubtarget.h"
12#include "llvm/IR/GlobalValue.h"
14
15using namespace llvm;
16
17#define DEBUG_TYPE "systemz-subtarget"
18
19#define GET_SUBTARGETINFO_TARGET_DESC
20#define GET_SUBTARGETINFO_CTOR
21#include "SystemZGenSubtargetInfo.inc"
22
24 "systemz-subreg-liveness",
25 cl::desc("Enable subregister liveness tracking for SystemZ (experimental)"),
27
28// Pin the vtable to this file.
29void SystemZSubtarget::anchor() {}
30
31SystemZSubtarget &SystemZSubtarget::initializeSubtargetDependencies(
32 StringRef CPU, StringRef TuneCPU, StringRef FS) {
33 if (CPU.empty())
34 CPU = "generic";
35 if (TuneCPU.empty())
36 TuneCPU = CPU;
37 // Parse features string.
38 ParseSubtargetFeatures(CPU, TuneCPU, FS);
39
40 // -msoft-float implies -mno-vx.
41 if (HasSoftFloat)
42 HasVector = false;
43
44 // -mno-vx implicitly disables all vector-related features.
45 if (!HasVector) {
46 HasVectorEnhancements1 = false;
47 HasVectorEnhancements2 = false;
48 HasVectorPackedDecimal = false;
49 HasVectorPackedDecimalEnhancement = false;
50 HasVectorPackedDecimalEnhancement2 = false;
51 }
52
53 return *this;
54}
55
57SystemZSubtarget::initializeSpecialRegisters() {
58 if (isTargetXPLINK64())
59 return new SystemZXPLINK64Registers;
60 else if (isTargetELF())
61 return new SystemZELFRegisters;
62 llvm_unreachable("Invalid Calling Convention. Cannot initialize Special "
63 "Call Registers!");
64}
65
66SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
67 const std::string &TuneCPU,
68 const std::string &FS,
69 const TargetMachine &TM)
70 : SystemZGenSubtargetInfo(TT, CPU, TuneCPU, FS), TargetTriple(TT),
71 SpecialRegisters(initializeSpecialRegisters()),
72 InstrInfo(initializeSubtargetDependencies(CPU, TuneCPU, FS)),
73 TLInfo(TM, *this), FrameLowering(SystemZFrameLowering::create(*this)) {}
74
76 return UseSubRegLiveness;
77}
78
80 if (const auto *GO = dyn_cast<GlobalObject>(GV)) {
81 // A R/O variable is placed in code section. If the R/O variable has as
82 // least two byte alignment, then generated code can use relative
83 // instructions to address the variable. Otherwise, use the ADA to address
84 // the variable.
85 if (GO->getAlignment() & 0x1) {
86 return true;
87 }
88
89 // getKindForGlobal only works with definitions
90 if (GO->isDeclaration()) {
91 return true;
92 }
93
94 // check AvailableExternallyLinkage here as getKindForGlobal() asserts
95 if (GO->hasAvailableExternallyLinkage()) {
96 return true;
97 }
98
100 GO, TLInfo.getTargetMachine());
101 if (!GOKind.isReadOnly()) {
102 return true;
103 }
104
105 return false; // R/O variable with multiple of 2 byte alignment
106 }
107 return true;
108}
109
111 CodeModel::Model CM) const {
112 if (isTargetzOS())
113 return !isAddressedViaADA(GV);
114
115 // PC32DBL accesses require the low bit to be clear.
116 //
117 // FIXME: Explicitly check for functions: the datalayout is currently
118 // missing information about function pointers.
119 const DataLayout &DL = GV->getParent()->getDataLayout();
120 if (GV->getPointerAlignment(DL) == 1 && !GV->getValueType()->isFunctionTy())
121 return false;
122
123 // For the small model, all locally-binding symbols are in range.
124 if (CM == CodeModel::Small)
125 return TLInfo.getTargetMachine().shouldAssumeDSOLocal(GV);
126
127 // For Medium and above, assume that the symbol is not within the 4GB range.
128 // Taking the address of locally-defined text would be OK, but that
129 // case isn't easy to detect.
130 return false;
131}
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static cl::opt< bool > UseSubRegLiveness("ppc-track-subreg-liveness", cl::desc("Enable subregister liveness tracking for PPC"), cl::init(true), cl::Hidden)
const char LLVMTargetMachineRef TM
static cl::opt< bool > UseSubRegLiveness("systemz-subreg-liveness", cl::desc("Enable subregister liveness tracking for SystemZ (experimental)"), cl::Hidden)
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:110
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:656
Type * getValueType() const
Definition: GlobalValue.h:296
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.h:293
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
bool isReadOnly() const
Definition: SectionKind.h:131
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
A SystemZ-specific class detailing special use registers particular for calling conventions.
ELF calling convention specific use registers Particular when on zLinux in 64 bit mode.
bool isPC32DBLSymbol(const GlobalValue *GV, CodeModel::Model CM) const
bool enableSubRegLiveness() const override
bool isAddressedViaADA(const GlobalValue *GV) const
SystemZSubtarget(const Triple &TT, const std::string &CPU, const std::string &TuneCPU, const std::string &FS, const TargetMachine &TM)
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
XPLINK64 calling convention specific use registers Particular to z/OS when in 64 bit mode.
const TargetMachine & getTargetMachine() const
static SectionKind getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM)
Classify the specified global variable into a set of target independent categories embodied in Sectio...
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:76
bool shouldAssumeDSOLocal(const GlobalValue *GV) const
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:246
Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
Definition: Value.cpp:926
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18