LLVM  3.7.0
AArch64Subtarget.cpp
Go to the documentation of this file.
1 //===-- AArch64Subtarget.cpp - AArch64 Subtarget Information ----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the AArch64 specific subclass of TargetSubtarget.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "AArch64InstrInfo.h"
15 #include "AArch64PBQPRegAlloc.h"
16 #include "AArch64Subtarget.h"
17 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/IR/GlobalValue.h"
21 
22 using namespace llvm;
23 
24 #define DEBUG_TYPE "aarch64-subtarget"
25 
26 #define GET_SUBTARGETINFO_CTOR
27 #define GET_SUBTARGETINFO_TARGET_DESC
28 #include "AArch64GenSubtargetInfo.inc"
29 
30 static cl::opt<bool>
31 EnableEarlyIfConvert("aarch64-early-ifcvt", cl::desc("Enable the early if "
32  "converter pass"), cl::init(true), cl::Hidden);
33 
35 AArch64Subtarget::initializeSubtargetDependencies(StringRef FS) {
36  // Determine default and user-specified characteristics
37 
38  if (CPUString.empty())
39  CPUString = "generic";
40 
42  return *this;
43 }
44 
45 AArch64Subtarget::AArch64Subtarget(const Triple &TT, const std::string &CPU,
46  const std::string &FS,
47  const TargetMachine &TM, bool LittleEndian)
48  : AArch64GenSubtargetInfo(TT, CPU, FS), ARMProcFamily(Others),
49  HasV8_1aOps(false), HasFPARMv8(false), HasNEON(false), HasCrypto(false),
50  HasCRC(false), HasZeroCycleRegMove(false), HasZeroCycleZeroing(false),
51  IsLittle(LittleEndian), CPUString(CPU), TargetTriple(TT), FrameLowering(),
52  InstrInfo(initializeSubtargetDependencies(FS)), TSInfo(),
53  TLInfo(TM, *this) {}
54 
55 /// ClassifyGlobalReference - Find the target operand flags that describe
56 /// how a global value should be referenced for the current subtarget.
57 unsigned char
59  const TargetMachine &TM) const {
60  bool isDef = GV->isStrongDefinitionForLinker();
61 
62  // MachO large model always goes via a GOT, simply to get a single 8-byte
63  // absolute relocation on all global addresses.
65  return AArch64II::MO_GOT;
66 
67  // The small code mode's direct accesses use ADRP, which cannot necessarily
68  // produce the value 0 (if the code is above 4GB).
70  // In PIC mode use the GOT, but in absolute mode use a constant pool load.
73  else
74  return AArch64II::MO_GOT;
75  }
76 
77  // If symbol visibility is hidden, the extra load is not needed if
78  // the symbol is definitely defined in the current translation unit.
79 
80  // The handling of non-hidden symbols in PIC mode is rather target-dependent:
81  // + On MachO, if the symbol is defined in this module the GOT can be
82  // skipped.
83  // + On ELF, the R_AARCH64_COPY relocation means that even symbols actually
84  // defined could end up in unexpected places. Use a GOT.
86  if (isTargetMachO())
88  else
89  // No need to go through the GOT for local symbols on ELF.
91  }
92 
93  return AArch64II::MO_NO_FLAG;
94 }
95 
96 /// This function returns the name of a function which has an interface
97 /// like the non-standard bzero function, if such a function exists on
98 /// the current subtarget and it is considered prefereable over
99 /// memset with zero passed as the second argument. Otherwise it
100 /// returns null.
101 const char *AArch64Subtarget::getBZeroEntry() const {
102  // Prefer bzero on Darwin only.
103  if(isTargetDarwin())
104  return "bzero";
105 
106  return nullptr;
107 }
108 
111  unsigned NumRegionInstrs) const {
112  // LNT run (at least on Cyclone) showed reasonably significant gains for
113  // bi-directional scheduling. 253.perlbmk.
114  Policy.OnlyTopDown = false;
115  Policy.OnlyBottomUp = false;
116 }
117 
119  return EnableEarlyIfConvert;
120 }
121 
122 std::unique_ptr<PBQPRAConstraint>
124  if (!isCortexA57())
125  return nullptr;
126 
127  return llvm::make_unique<A57ChainingConstraint>();
128 }
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:240
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
const_iterator begin(StringRef path)
Get begin iterator over path.
Definition: Path.cpp:232
bool hasDefaultVisibility() const
Definition: GlobalValue.h:140
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
Definition: GlobalValue.h:353
#define false
Definition: ConvertUTF.c:65
MO_CONSTPOOL - This flag indicates that a symbol operand represents the address of a constant pool en...
MO_GOT - This flag indicates that a symbol operand represents the address of the GOT entry for the sy...
bool enableEarlyIfConversion() const override
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:325
CodeModel::Model getCodeModel() const
Returns the code model.
unsigned char ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const
ClassifyGlobalReference - Find the target operand flags that describe how a global value should be re...
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
bool hasExternalWeakLinkage() const
Definition: GlobalValue.h:281
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
ParseSubtargetFeatures - Parses features string setting specified subtarget options.
std::string CPUString
CPUString - String name of used CPU.
const char * getBZeroEntry() const
This function returns the name of a function which has an interface like the non-standard bzero funct...
bool isTargetDarwin() const
void overrideSchedPolicy(MachineSchedPolicy &Policy, MachineInstr *begin, MachineInstr *end, unsigned NumRegionInstrs) const override
Define a generic scheduling policy for targets that don't provide their own MachineSchedStrategy.
Representation of each machine instruction.
Definition: MachineInstr.h:51
std::unique_ptr< PBQPRAConstraint > getCustomPBQPConstraints() const override
AArch64Subtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const TargetMachine &TM, bool LittleEndian)
This constructor initializes the data members to match that of the specified triple.
bool hasLocalLinkage() const
Definition: GlobalValue.h:280
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
static cl::opt< bool > EnableEarlyIfConvert("aarch64-early-ifcvt", cl::desc("Enable the early if ""converter pass"), cl::init(true), cl::Hidden)