1 //===-- SystemZSubtarget.cpp - SystemZ subtarget information --------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "SystemZSubtarget.h"
10 #include "MCTargetDesc/SystemZMCTargetDesc.h"
11 #include "llvm/IR/GlobalValue.h"
12 #include "llvm/Target/TargetMachine.h"
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)"),
27 // Pin the vtable to this file.
28 void SystemZSubtarget::anchor() {}
31 SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
32 StringRef CPUName = CPU;
35 // Parse features string.
36 ParseSubtargetFeatures(CPUName, FS);
38 // -msoft-float implies -mno-vx.
45 SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
46 const std::string &FS,
47 const TargetMachine &TM)
48 : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false),
49 HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false),
50 HasPopulationCount(false), HasMessageSecurityAssist3(false),
51 HasMessageSecurityAssist4(false), HasResetReferenceBitsMultiple(false),
52 HasFastSerialization(false), HasInterlockedAccess1(false),
53 HasMiscellaneousExtensions(false),
54 HasExecutionHint(false), HasLoadAndTrap(false),
55 HasTransactionalExecution(false), HasProcessorAssist(false),
56 HasDFPZonedConversion(false), HasEnhancedDAT2(false),
57 HasVector(false), HasLoadStoreOnCond2(false),
58 HasLoadAndZeroRightmostByte(false), HasMessageSecurityAssist5(false),
59 HasDFPPackedConversion(false),
60 HasMiscellaneousExtensions2(false), HasGuardedStorage(false),
61 HasMessageSecurityAssist7(false), HasMessageSecurityAssist8(false),
62 HasVectorEnhancements1(false), HasVectorPackedDecimal(false),
63 HasInsertReferenceBitsMultiple(false),
64 HasMiscellaneousExtensions3(false), HasMessageSecurityAssist9(false),
65 HasVectorEnhancements2(false), HasVectorPackedDecimalEnhancement(false),
66 HasEnhancedSort(false), HasDeflateConversion(false), HasSoftFloat(false),
67 TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
68 TLInfo(TM, *this), TSInfo(), FrameLowering() {}
71 bool SystemZSubtarget::enableSubRegLiveness() const {
72 return UseSubRegLiveness;
75 bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
76 CodeModel::Model CM) const {
77 // PC32DBL accesses require the low bit to be clear.
79 // FIXME: Explicitly check for functions: the datalayout is currently
80 // missing information about function pointers.
81 const DataLayout &DL = GV->getParent()->getDataLayout();
82 if (GV->getPointerAlignment(DL) == 1 && !GV->getValueType()->isFunctionTy())
85 // For the small model, all locally-binding symbols are in range.
86 if (CM == CodeModel::Small)
87 return TLInfo.getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV);
89 // For Medium and above, assume that the symbol is not within the 4GB range.
90 // Taking the address of locally-defined text would be OK, but that
91 // case isn't easy to detect.