eece389302e7d921092ad2d2dcbe2ff14e7dd5aa
[oota-llvm.git] / lib / Target / AArch64 / AArch64Subtarget.cpp
1 //===-- AArch64Subtarget.cpp - AArch64 Subtarget Information --------------===//
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 TargetSubtargetInfo.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "AArch64Subtarget.h"
15 #include "AArch64RegisterInfo.h"
16 #include "MCTargetDesc/AArch64MCTargetDesc.h"
17 #include "llvm/IR/GlobalValue.h"
18 #include "llvm/Target/TargetSubtargetInfo.h"
19 #include "llvm/Support/CommandLine.h"
20 #include "llvm/ADT/SmallVector.h"
21
22 #define GET_SUBTARGETINFO_TARGET_DESC
23 #define GET_SUBTARGETINFO_CTOR
24 #include "AArch64GenSubtargetInfo.inc"
25
26 using namespace llvm;
27
28 AArch64Subtarget::AArch64Subtarget(StringRef TT, StringRef CPU, StringRef FS)
29     : AArch64GenSubtargetInfo(TT, CPU, FS), HasFPARMv8(false), HasNEON(false),
30       HasCrypto(false), TargetTriple(TT), CPUString(CPU) {
31
32   initializeSubtargetFeatures(CPU, FS);
33 }
34
35 void AArch64Subtarget::initializeSubtargetFeatures(StringRef CPU,
36                                                    StringRef FS) {
37   if (CPU.empty())
38     CPUString = "generic";
39
40   std::string FullFS = FS;
41   if (CPUString == "generic") {
42     // Enable FP by default.
43     if (FullFS.empty())
44       FullFS = "+fp-armv8";
45     else
46       FullFS = "+fp-armv8," + FullFS;
47   }
48
49   ParseSubtargetFeatures(CPU, FullFS);
50 }
51
52 bool AArch64Subtarget::GVIsIndirectSymbol(const GlobalValue *GV,
53                                           Reloc::Model RelocM) const {
54   if (RelocM == Reloc::Static)
55     return false;
56
57   return !GV->hasLocalLinkage() && !GV->hasHiddenVisibility();
58 }