1284c1978SDimitry Andric //===-- SystemZSubtarget.cpp - SystemZ subtarget information --------------===//
2284c1978SDimitry Andric //
3284c1978SDimitry Andric // The LLVM Compiler Infrastructure
4284c1978SDimitry Andric //
5284c1978SDimitry Andric // This file is distributed under the University of Illinois Open Source
6284c1978SDimitry Andric // License. See LICENSE.TXT for details.
7284c1978SDimitry Andric //
8284c1978SDimitry Andric //===----------------------------------------------------------------------===//
9284c1978SDimitry Andric
10284c1978SDimitry Andric #include "SystemZSubtarget.h"
1191bc56edSDimitry Andric #include "MCTargetDesc/SystemZMCTargetDesc.h"
12284c1978SDimitry Andric #include "llvm/IR/GlobalValue.h"
1391bc56edSDimitry Andric
1491bc56edSDimitry Andric using namespace llvm;
1591bc56edSDimitry Andric
1691bc56edSDimitry Andric #define DEBUG_TYPE "systemz-subtarget"
17284c1978SDimitry Andric
18284c1978SDimitry Andric #define GET_SUBTARGETINFO_TARGET_DESC
19284c1978SDimitry Andric #define GET_SUBTARGETINFO_CTOR
20284c1978SDimitry Andric #include "SystemZGenSubtargetInfo.inc"
21284c1978SDimitry Andric
22*b5893f02SDimitry Andric static cl::opt<bool> UseSubRegLiveness(
23*b5893f02SDimitry Andric "systemz-subreg-liveness",
24*b5893f02SDimitry Andric cl::desc("Enable subregister liveness tracking for SystemZ (experimental)"),
25*b5893f02SDimitry Andric cl::Hidden);
26*b5893f02SDimitry Andric
2791bc56edSDimitry Andric // Pin the vtable to this file.
anchor()28f785676fSDimitry Andric void SystemZSubtarget::anchor() {}
29f785676fSDimitry Andric
3091bc56edSDimitry Andric SystemZSubtarget &
initializeSubtargetDependencies(StringRef CPU,StringRef FS)3191bc56edSDimitry Andric SystemZSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
32284c1978SDimitry Andric std::string CPUName = CPU;
33284c1978SDimitry Andric if (CPUName.empty())
34f785676fSDimitry Andric CPUName = "generic";
35284c1978SDimitry Andric // Parse features string.
36284c1978SDimitry Andric ParseSubtargetFeatures(CPUName, FS);
3791bc56edSDimitry Andric return *this;
38284c1978SDimitry Andric }
39284c1978SDimitry Andric
SystemZSubtarget(const Triple & TT,const std::string & CPU,const std::string & FS,const TargetMachine & TM)408f0fd8f6SDimitry Andric SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
4191bc56edSDimitry Andric const std::string &FS,
4291bc56edSDimitry Andric const TargetMachine &TM)
4391bc56edSDimitry Andric : SystemZGenSubtargetInfo(TT, CPU, FS), HasDistinctOps(false),
4491bc56edSDimitry Andric HasLoadStoreOnCond(false), HasHighWord(false), HasFPExtension(false),
45a580b014SDimitry Andric HasPopulationCount(false), HasMessageSecurityAssist3(false),
46a580b014SDimitry Andric HasMessageSecurityAssist4(false), HasResetReferenceBitsMultiple(false),
475517e702SDimitry Andric HasFastSerialization(false), HasInterlockedAccess1(false),
485517e702SDimitry Andric HasMiscellaneousExtensions(false),
49d88c1a5aSDimitry Andric HasExecutionHint(false), HasLoadAndTrap(false),
50ff0cc061SDimitry Andric HasTransactionalExecution(false), HasProcessorAssist(false),
51a580b014SDimitry Andric HasDFPZonedConversion(false), HasEnhancedDAT2(false),
52d88c1a5aSDimitry Andric HasVector(false), HasLoadStoreOnCond2(false),
535517e702SDimitry Andric HasLoadAndZeroRightmostByte(false), HasMessageSecurityAssist5(false),
5489cb50c9SDimitry Andric HasDFPPackedConversion(false),
55b40b48b8SDimitry Andric HasMiscellaneousExtensions2(false), HasGuardedStorage(false),
56b40b48b8SDimitry Andric HasMessageSecurityAssist7(false), HasMessageSecurityAssist8(false),
57b40b48b8SDimitry Andric HasVectorEnhancements1(false), HasVectorPackedDecimal(false),
58b40b48b8SDimitry Andric HasInsertReferenceBitsMultiple(false),
59d88c1a5aSDimitry Andric TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
60d88c1a5aSDimitry Andric TLInfo(TM, *this), TSInfo(), FrameLowering() {}
6191bc56edSDimitry Andric
62*b5893f02SDimitry Andric
enableSubRegLiveness() const63*b5893f02SDimitry Andric bool SystemZSubtarget::enableSubRegLiveness() const {
64*b5893f02SDimitry Andric return UseSubRegLiveness;
65*b5893f02SDimitry Andric }
66*b5893f02SDimitry Andric
isPC32DBLSymbol(const GlobalValue * GV,CodeModel::Model CM) const67284c1978SDimitry Andric bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
68284c1978SDimitry Andric CodeModel::Model CM) const {
69284c1978SDimitry Andric // PC32DBL accesses require the low bit to be clear. Note that a zero
70284c1978SDimitry Andric // value selects the default alignment and is therefore OK.
71284c1978SDimitry Andric if (GV->getAlignment() == 1)
72284c1978SDimitry Andric return false;
73284c1978SDimitry Andric
74284c1978SDimitry Andric // For the small model, all locally-binding symbols are in range.
75284c1978SDimitry Andric if (CM == CodeModel::Small)
763ca95b02SDimitry Andric return TLInfo.getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV);
77284c1978SDimitry Andric
78284c1978SDimitry Andric // For Medium and above, assume that the symbol is not within the 4GB range.
79284c1978SDimitry Andric // Taking the address of locally-defined text would be OK, but that
80284c1978SDimitry Andric // case isn't easy to detect.
81284c1978SDimitry Andric return false;
82284c1978SDimitry Andric }
83