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"
10 #include "MCTargetDesc/SystemZMCTargetDesc.h"
11 #include "llvm/IR/GlobalValue.h"
12
13 using namespace llvm;
14
15 #define DEBUG_TYPE "systemz-subtarget"
16
17 #define GET_SUBTARGETINFO_TARGET_DESC
18 #define GET_SUBTARGETINFO_CTOR
19 #include "SystemZGenSubtargetInfo.inc"
20
21 static cl::opt<bool> UseSubRegLiveness(
22 "systemz-subreg-liveness",
23 cl::desc("Enable subregister liveness tracking for SystemZ (experimental)"),
24 cl::Hidden);
25
26 // Pin the vtable to this file.
anchor()27 void SystemZSubtarget::anchor() {}
28
29 SystemZSubtarget &
initializeSubtargetDependencies(StringRef CPU,StringRef FS)30 SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
31 std::string CPUName = CPU;
32 if (CPUName.empty())
33 CPUName = "generic";
34 // Parse features string.
35 ParseSubtargetFeatures(CPUName, FS);
36 return *this;
37 }
38
SystemZSubtarget(const Triple & TT,const std::string & CPU,const std::string & FS,const TargetMachine & TM)39 SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
40 const std::string &FS,
41 const TargetMachine &TM)
42 : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false),
43 HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false),
44 HasPopulationCount(false), HasMessageSecurityAssist3(false),
45 HasMessageSecurityAssist4(false), HasResetReferenceBitsMultiple(false),
46 HasFastSerialization(false), HasInterlockedAccess1(false),
47 HasMiscellaneousExtensions(false),
48 HasExecutionHint(false), HasLoadAndTrap(false),
49 HasTransactionalExecution(false), HasProcessorAssist(false),
50 HasDFPZonedConversion(false), HasEnhancedDAT2(false),
51 HasVector(false), HasLoadStoreOnCond2(false),
52 HasLoadAndZeroRightmostByte(false), HasMessageSecurityAssist5(false),
53 HasDFPPackedConversion(false),
54 HasMiscellaneousExtensions2(false), HasGuardedStorage(false),
55 HasMessageSecurityAssist7(false), HasMessageSecurityAssist8(false),
56 HasVectorEnhancements1(false), HasVectorPackedDecimal(false),
57 HasInsertReferenceBitsMultiple(false),
58 HasMiscellaneousExtensions3(false), HasMessageSecurityAssist9(false),
59 HasVectorEnhancements2(false), HasVectorPackedDecimalEnhancement(false),
60 HasEnhancedSort(false), HasDeflateConversion(false),
61 TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
62 TLInfo(TM, *this), TSInfo(), FrameLowering() {}
63
64
enableSubRegLiveness() const65 bool SystemZSubtarget::enableSubRegLiveness() const {
66 return UseSubRegLiveness;
67 }
68
isPC32DBLSymbol(const GlobalValue * GV,CodeModel::Model CM) const69 bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
70 CodeModel::Model CM) const {
71 // PC32DBL accesses require the low bit to be clear. Note that a zero
72 // value selects the default alignment and is therefore OK.
73 if (GV->getAlignment() == 1)
74 return false;
75
76 // For the small model, all locally-binding symbols are in range.
77 if (CM == CodeModel::Small)
78 return TLInfo.getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV);
79
80 // For Medium and above, assume that the symbol is not within the 4GB range.
81 // Taking the address of locally-defined text would be OK, but that
82 // case isn't easy to detect.
83 return false;
84 }
85