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.
27 void SystemZSubtarget::anchor() {}
28 
29 SystemZSubtarget &
30 SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
31   StringRef CPUName = CPU;
32   if (CPUName.empty())
33     CPUName = "generic";
34   // Parse features string.
35   ParseSubtargetFeatures(CPUName, FS);
36 
37   // -msoft-float implies -mno-vx.
38   if (HasSoftFloat)
39     HasVector = false;
40 
41   return *this;
42 }
43 
44 SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
45                                    const std::string &FS,
46                                    const TargetMachine &TM)
47     : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false),
48       HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false),
49       HasPopulationCount(false), HasMessageSecurityAssist3(false),
50       HasMessageSecurityAssist4(false), HasResetReferenceBitsMultiple(false),
51       HasFastSerialization(false), HasInterlockedAccess1(false),
52       HasMiscellaneousExtensions(false),
53       HasExecutionHint(false), HasLoadAndTrap(false),
54       HasTransactionalExecution(false), HasProcessorAssist(false),
55       HasDFPZonedConversion(false), HasEnhancedDAT2(false),
56       HasVector(false), HasLoadStoreOnCond2(false),
57       HasLoadAndZeroRightmostByte(false), HasMessageSecurityAssist5(false),
58       HasDFPPackedConversion(false),
59       HasMiscellaneousExtensions2(false), HasGuardedStorage(false),
60       HasMessageSecurityAssist7(false), HasMessageSecurityAssist8(false),
61       HasVectorEnhancements1(false), HasVectorPackedDecimal(false),
62       HasInsertReferenceBitsMultiple(false),
63       HasMiscellaneousExtensions3(false), HasMessageSecurityAssist9(false),
64       HasVectorEnhancements2(false), HasVectorPackedDecimalEnhancement(false),
65       HasEnhancedSort(false), HasDeflateConversion(false), HasSoftFloat(false),
66       TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
67       TLInfo(TM, *this), TSInfo(), FrameLowering() {}
68 
69 
70 bool SystemZSubtarget::enableSubRegLiveness() const {
71   return UseSubRegLiveness;
72 }
73 
74 bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
75                                        CodeModel::Model CM) const {
76   // PC32DBL accesses require the low bit to be clear.  Note that a zero
77   // value selects the default alignment and is therefore OK.
78   if (GV->getAlignment() == 1)
79     return false;
80 
81   // For the small model, all locally-binding symbols are in range.
82   if (CM == CodeModel::Small)
83     return TLInfo.getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV);
84 
85   // For Medium and above, assume that the symbol is not within the 4GB range.
86   // Taking the address of locally-defined text would be OK, but that
87   // case isn't easy to detect.
88   return false;
89 }
90