blob: c28c26b0eafcd399188727adea31d907d4a008fe [file] [log] [blame]
Tim Northover00ed9962014-03-29 10:18:08 +00001//===-- ARM64Subtarget.cpp - ARM64 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 ARM64 specific subclass of TargetSubtarget.
11//
12//===----------------------------------------------------------------------===//
13
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"
20
21#define GET_SUBTARGETINFO_CTOR
22#define GET_SUBTARGETINFO_TARGET_DESC
23#include "ARM64GenSubtargetInfo.inc"
24
25using namespace llvm;
26
27ARM64Subtarget::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
32
33 if (CPUString.empty())
34 // We default to Cyclone for now.
35 CPUString = "cyclone";
36
37 ParseSubtargetFeatures(CPUString, FS);
38}
39
40/// ClassifyGlobalReference - Find the target operand flags that describe
41/// how a global value should be referenced for the current subtarget.
42unsigned char
43ARM64Subtarget::ClassifyGlobalReference(const GlobalValue *GV,
44 const TargetMachine &TM) const {
45
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
48 // load from stub.
49 bool isDecl = GV->hasAvailableExternallyLinkage();
50 if (GV->isDeclaration() && !GV->isMaterializable())
51 isDecl = true;
52
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;
58
59 if (TM.getCodeModel() == CodeModel::Large && isTargetMachO())
60 return ARM64II::MO_GOT;
61
62 // FIXME: this will fail on static ELF for weak symbols.
63 return ARM64II::MO_NO_FLAG;
64}
65
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
70/// returns null.
71const char *ARM64Subtarget::getBZeroEntry() const {
72 // At the moment, always prefer bzero.
73 return "bzero";
74}
75
76void 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;
83}