1 //===-- ARM64Subtarget.cpp - ARM64 Subtarget Information --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the ARM64 specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #include "ARM64InstrInfo.h"
15 #include "ARM64Subtarget.h"
16 #include "llvm/ADT/SmallVector.h"
17 #include "llvm/CodeGen/MachineScheduler.h"
18 #include "llvm/IR/GlobalValue.h"
19 #include "llvm/Support/TargetRegistry.h"
21 #define GET_SUBTARGETINFO_CTOR
22 #define GET_SUBTARGETINFO_TARGET_DESC
23 #include "ARM64GenSubtargetInfo.inc"
27 ARM64Subtarget::ARM64Subtarget(const std::string &TT, const std::string &CPU,
28 const std::string &FS)
29 : ARM64GenSubtargetInfo(TT, CPU, FS), HasZeroCycleRegMove(false),
30 HasZeroCycleZeroing(false), CPUString(CPU), TargetTriple(TT) {
31 // Determine default and user-specified characteristics
33 if (CPUString.empty())
34 // We default to Cyclone for now.
35 CPUString = "cyclone";
37 ParseSubtargetFeatures(CPUString, FS);
40 /// ClassifyGlobalReference - Find the target operand flags that describe
41 /// how a global value should be referenced for the current subtarget.
43 ARM64Subtarget::ClassifyGlobalReference(const GlobalValue *GV,
44 const TargetMachine &TM) const {
46 // Determine whether this is a reference to a definition or a declaration.
47 // Materializable GVs (in JIT lazy compilation mode) do not require an extra
49 bool isDecl = GV->hasAvailableExternallyLinkage();
50 if (GV->isDeclaration() && !GV->isMaterializable())
53 // If symbol visibility is hidden, the extra load is not needed if
54 // the symbol is definitely defined in the current translation unit.
55 if (TM.getRelocationModel() != Reloc::Static && GV->hasDefaultVisibility() &&
56 (isDecl || GV->isWeakForLinker()))
57 return ARM64II::MO_GOT;
59 if (TM.getCodeModel() == CodeModel::Large && isTargetMachO())
60 return ARM64II::MO_GOT;
62 // FIXME: this will fail on static ELF for weak symbols.
63 return ARM64II::MO_NO_FLAG;
66 /// This function returns the name of a function which has an interface
67 /// like the non-standard bzero function, if such a function exists on
68 /// the current subtarget and it is considered prefereable over
69 /// memset with zero passed as the second argument. Otherwise it
71 const char *ARM64Subtarget::getBZeroEntry() const {
72 // At the moment, always prefer bzero.
76 void ARM64Subtarget::overrideSchedPolicy(MachineSchedPolicy &Policy,
77 MachineInstr *begin, MachineInstr *end,
78 unsigned NumRegionInstrs) const {
79 // LNT run (at least on Cyclone) showed reasonably significant gains for
80 // bi-directional scheduling. 253.perlbmk.
81 Policy.OnlyTopDown = false;
82 Policy.OnlyBottomUp = false;