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 GET_SUBTARGETINFO_TARGET_DESC
23 #define GET_SUBTARGETINFO_CTOR
24 #include "AArch64GenSubtargetInfo.inc"
34 static cl::opt<AlignMode>
35 Align(cl::desc("Load/store alignment support"),
36 cl::Hidden, cl::init(DefaultAlign),
38 clEnumValN(DefaultAlign, "aarch64-default-align",
39 "Generate unaligned accesses only on hardware/OS "
40 "combinations that are known to support them"),
41 clEnumValN(StrictAlign, "aarch64-strict-align",
42 "Disallow all unaligned memory accesses"),
43 clEnumValN(NoStrictAlign, "aarch64-no-strict-align",
44 "Allow unaligned memory accesses"),
47 // Pin the vtable to this file.
48 void AArch64Subtarget::anchor() {}
50 AArch64Subtarget::AArch64Subtarget(StringRef TT, StringRef CPU, StringRef FS,
52 : AArch64GenSubtargetInfo(TT, CPU, FS), ARMProcFamily(Others),
53 HasFPARMv8(false), HasNEON(false), HasCrypto(false), TargetTriple(TT),
54 CPUString(CPU), IsLittleEndian(LittleEndian) {
56 initializeSubtargetFeatures(CPU, FS);
59 void AArch64Subtarget::initializeSubtargetFeatures(StringRef CPU,
61 AllowsUnalignedMem = false;
64 CPUString = "generic";
66 std::string FullFS = FS;
67 if (CPUString == "generic") {
68 // Enable FP by default.
72 FullFS = "+fp-armv8," + FullFS;
75 ParseSubtargetFeatures(CPU, FullFS);
79 // Linux targets support unaligned accesses on AARCH64
80 AllowsUnalignedMem = isTargetLinux();
83 AllowsUnalignedMem = false;
86 AllowsUnalignedMem = true;
91 bool AArch64Subtarget::GVIsIndirectSymbol(const GlobalValue *GV,
92 Reloc::Model RelocM) const {
93 if (RelocM == Reloc::Static)
96 return !GV->hasLocalLinkage() && !GV->hasHiddenVisibility();