LLVM 20.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"
11#include "llvm/IR/GlobalValue.h"
13
14using namespace llvm;
15
16#define DEBUG_TYPE "systemz-subtarget"
17
18#define GET_SUBTARGETINFO_TARGET_DESC
19#define GET_SUBTARGETINFO_CTOR
20#include "SystemZGenSubtargetInfo.inc"
21
23 "systemz-subreg-liveness",
24 cl::desc("Enable subregister liveness tracking for SystemZ (experimental)"),
26
27// Pin the vtable to this file.
28void SystemZSubtarget::anchor() {}
29
30SystemZSubtarget &SystemZSubtarget::initializeSubtargetDependencies(
31 StringRef CPU, StringRef TuneCPU, StringRef FS) {
32 if (CPU.empty())
33 CPU = "generic";
34 if (TuneCPU.empty())
35 TuneCPU = CPU;
36 // Parse features string.
37 ParseSubtargetFeatures(CPU, TuneCPU, FS);
38
39 // -msoft-float implies -mno-vx.
40 if (HasSoftFloat)
41 HasVector = false;
42
43 // -mno-vx implicitly disables all vector-related features.
44 if (!HasVector) {
45 HasVectorEnhancements1 = false;
46 HasVectorEnhancements2 = false;
47 HasVectorPackedDecimal = false;
48 HasVectorPackedDecimalEnhancement = false;
49 HasVectorPackedDecimalEnhancement2 = false;
50 }
51
52 return *this;
53}
54
56SystemZSubtarget::initializeSpecialRegisters() {
57 if (isTargetXPLINK64())
58 return new SystemZXPLINK64Registers;
59 else if (isTargetELF())
60 return new SystemZELFRegisters;
61 llvm_unreachable("Invalid Calling Convention. Cannot initialize Special "
62 "Call Registers!");
63}
64
65SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
66 const std::string &TuneCPU,
67 const std::string &FS,
68 const TargetMachine &TM)
69 : SystemZGenSubtargetInfo(TT, CPU, TuneCPU, FS), TargetTriple(TT),
70 SpecialRegisters(initializeSpecialRegisters()),
71 InstrInfo(initializeSubtargetDependencies(CPU, TuneCPU, FS)),
72 TLInfo(TM, *this), FrameLowering(SystemZFrameLowering::create(*this)) {}
73
75 return UseSubRegLiveness;
76}
77
79 if (const auto *GO = dyn_cast<GlobalObject>(GV)) {
80 // A R/O variable is placed in code section. If the R/O variable has as
81 // least two byte alignment, then generated code can use relative
82 // instructions to address the variable. Otherwise, use the ADA to address
83 // the variable.
84 if (GO->getAlignment() & 0x1) {
85 return true;
86 }
87
88 // getKindForGlobal only works with definitions
89 if (GO->isDeclaration()) {
90 return true;
91 }
92
93 // check AvailableExternallyLinkage here as getKindForGlobal() asserts
94 if (GO->hasAvailableExternallyLinkage()) {
95 return true;
96 }
97
99 GO, TLInfo.getTargetMachine());
100 if (!GOKind.isReadOnly()) {
101 return true;
102 }
103
104 return false; // R/O variable with multiple of 2 byte alignment
105 }
106 return true;
107}
108
110 CodeModel::Model CM) const {
111 if (isTargetzOS())
112 return !isAddressedViaADA(GV);
113
114 // PC32DBL accesses require the low bit to be clear.
115 //
116 // FIXME: Explicitly check for functions: the datalayout is currently
117 // missing information about function pointers.
118 const DataLayout &DL = GV->getDataLayout();
119 if (GV->getPointerAlignment(DL) == 1 && !GV->getValueType()->isFunctionTy())
120 return false;
121
122 // For the small model, all locally-binding symbols are in range.
123 if (CM == CodeModel::Small)
124 return TLInfo.getTargetMachine().shouldAssumeDSOLocal(GV);
125
126 // For Medium and above, assume that the symbol is not within the 4GB range.
127 // Taking the address of locally-defined text would be OK, but that
128 // case isn't easy to detect.
129 return false;
130}
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
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:63
const DataLayout & getDataLayout() const
Get the data layout of the module this global belongs to.
Definition: Globals.cpp:130
Type * getValueType() const
Definition: GlobalValue.h:296
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:51
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:147
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:77
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:255
Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
Definition: Value.cpp:927
#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