1 //===-- AArch64Subtarget.cpp - AArch64 Subtarget Information --------------===//
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 AArch64 specific subclass of TargetSubtargetInfo.
12 //===----------------------------------------------------------------------===//
14 #include "AArch64Subtarget.h"
15 #include "AArch64RegisterInfo.h"
16 #include "MCTargetDesc/AArch64MCTargetDesc.h"
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/IR/GlobalValue.h"
19 #include "llvm/Support/CommandLine.h"
20 #include "llvm/Target/TargetSubtargetInfo.h"
22 #define DEBUG_TYPE "aarch64-subtarget"
24 #define GET_SUBTARGETINFO_TARGET_DESC
25 #define GET_SUBTARGETINFO_CTOR
26 #include "AArch64GenSubtargetInfo.inc"
36 static cl::opt<AlignMode>
37 Align(cl::desc("Load/store alignment support"),
38 cl::Hidden, cl::init(DefaultAlign),
40 clEnumValN(DefaultAlign, "aarch64-default-align",
41 "Generate unaligned accesses only on hardware/OS "
42 "combinations that are known to support them"),
43 clEnumValN(StrictAlign, "aarch64-strict-align",
44 "Disallow all unaligned memory accesses"),
45 clEnumValN(NoStrictAlign, "aarch64-no-strict-align",
46 "Allow unaligned memory accesses"),
49 // Pin the vtable to this file.
50 void AArch64Subtarget::anchor() {}
52 AArch64Subtarget::AArch64Subtarget(StringRef TT, StringRef CPU, StringRef FS,
54 : AArch64GenSubtargetInfo(TT, CPU, FS), ARMProcFamily(Others),
55 HasFPARMv8(false), HasNEON(false), HasCrypto(false), TargetTriple(TT),
56 CPUString(CPU), IsLittleEndian(LittleEndian) {
58 initializeSubtargetFeatures(CPU, FS);
61 void AArch64Subtarget::initializeSubtargetFeatures(StringRef CPU,
63 AllowsUnalignedMem = false;
66 CPUString = "generic";
68 std::string FullFS = FS;
69 if (CPUString == "generic") {
70 // Enable FP by default.
74 FullFS = "+fp-armv8," + FullFS;
77 ParseSubtargetFeatures(CPU, FullFS);
81 // Linux targets support unaligned accesses on AARCH64
82 AllowsUnalignedMem = isTargetLinux();
85 AllowsUnalignedMem = false;
88 AllowsUnalignedMem = true;
93 bool AArch64Subtarget::GVIsIndirectSymbol(const GlobalValue *GV,
94 Reloc::Model RelocM) const {
95 if (RelocM == Reloc::Static)
98 return !GV->hasLocalLinkage() && !GV->hasHiddenVisibility();