AMDGPU: Mark test as XFAIL in expensive_checks builds
[llvm-project.git] / llvm / lib / Target / SystemZ / SystemZSubtarget.cpp
blobe4e84460399df3efc1534ebb5602e4cfe91e2f2f
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 //===----------------------------------------------------------------------===//
9 #include "SystemZSubtarget.h"
10 #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
11 #include "llvm/IR/GlobalValue.h"
12 #include "llvm/Target/TargetMachine.h"
14 using namespace llvm;
16 #define DEBUG_TYPE "systemz-subtarget"
18 #define GET_SUBTARGETINFO_TARGET_DESC
19 #define GET_SUBTARGETINFO_CTOR
20 #include "SystemZGenSubtargetInfo.inc"
22 static cl::opt<bool> UseSubRegLiveness(
23 "systemz-subreg-liveness",
24 cl::desc("Enable subregister liveness tracking for SystemZ (experimental)"),
25 cl::Hidden);
27 // Pin the vtable to this file.
28 void SystemZSubtarget::anchor() {}
30 SystemZSubtarget &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);
39 // -msoft-float implies -mno-vx.
40 if (HasSoftFloat)
41 HasVector = false;
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;
52 return *this;
55 SystemZCallingConventionRegisters *
56 SystemZSubtarget::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!");
65 SystemZSubtarget::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)) {}
74 bool SystemZSubtarget::enableSubRegLiveness() const {
75 return UseSubRegLiveness;
78 bool SystemZSubtarget::isAddressedViaADA(const GlobalValue *GV) const {
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;
88 // getKindForGlobal only works with definitions
89 if (GO->isDeclaration()) {
90 return true;
93 // check AvailableExternallyLinkage here as getKindForGlobal() asserts
94 if (GO->hasAvailableExternallyLinkage()) {
95 return true;
98 SectionKind GOKind = TargetLoweringObjectFile::getKindForGlobal(
99 GO, TLInfo.getTargetMachine());
100 if (!GOKind.isReadOnly()) {
101 return true;
104 return false; // R/O variable with multiple of 2 byte alignment
106 return true;
109 bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
110 CodeModel::Model CM) const {
111 if (isTargetzOS())
112 return !isAddressedViaADA(GV);
114 // PC32DBL accesses require the low bit to be clear.
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;
122 // For the small model, all locally-binding symbols are in range.
123 if (CM == CodeModel::Small)
124 return TLInfo.getTargetMachine().shouldAssumeDSOLocal(GV);
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;