Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 1 | //===--- ARM.h - Declare ARM target feature support -------------*- 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 declares ARM TargetInfo objects. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_ARM_H |
| 15 | #define LLVM_CLANG_LIB_BASIC_TARGETS_ARM_H |
| 16 | |
| 17 | #include "OSTargets.h" |
| 18 | #include "clang/Basic/TargetInfo.h" |
| 19 | #include "clang/Basic/TargetOptions.h" |
| 20 | #include "llvm/ADT/Triple.h" |
| 21 | #include "llvm/Support/Compiler.h" |
| 22 | #include "llvm/Support/TargetParser.h" |
| 23 | |
| 24 | namespace clang { |
| 25 | namespace targets { |
| 26 | |
| 27 | class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public TargetInfo { |
| 28 | // Possible FPU choices. |
| 29 | enum FPUMode { |
| 30 | VFP2FPU = (1 << 0), |
| 31 | VFP3FPU = (1 << 1), |
| 32 | VFP4FPU = (1 << 2), |
| 33 | NeonFPU = (1 << 3), |
| 34 | FPARMV8 = (1 << 4) |
| 35 | }; |
| 36 | |
| 37 | // Possible HWDiv features. |
| 38 | enum HWDivMode { HWDivThumb = (1 << 0), HWDivARM = (1 << 1) }; |
| 39 | |
| 40 | static bool FPUModeIsVFP(FPUMode Mode) { |
| 41 | return Mode & (VFP2FPU | VFP3FPU | VFP4FPU | NeonFPU | FPARMV8); |
| 42 | } |
| 43 | |
| 44 | static const TargetInfo::GCCRegAlias GCCRegAliases[]; |
| 45 | static const char *const GCCRegNames[]; |
| 46 | |
| 47 | std::string ABI, CPU; |
| 48 | |
| 49 | StringRef CPUProfile; |
| 50 | StringRef CPUAttr; |
| 51 | |
| 52 | enum { FP_Default, FP_VFP, FP_Neon } FPMath; |
| 53 | |
Florian Hahn | ef5bbd6 | 2017-07-27 16:28:39 +0000 | [diff] [blame] | 54 | llvm::ARM::ISAKind ArchISA; |
| 55 | llvm::ARM::ArchKind ArchKind = llvm::ARM::ArchKind::ARMV4T; |
| 56 | llvm::ARM::ProfileKind ArchProfile; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 57 | unsigned ArchVersion; |
| 58 | |
| 59 | unsigned FPU : 5; |
| 60 | |
| 61 | unsigned IsAAPCS : 1; |
| 62 | unsigned HWDiv : 2; |
| 63 | |
| 64 | // Initialized via features. |
| 65 | unsigned SoftFloat : 1; |
| 66 | unsigned SoftFloatABI : 1; |
| 67 | |
| 68 | unsigned CRC : 1; |
| 69 | unsigned Crypto : 1; |
| 70 | unsigned DSP : 1; |
| 71 | unsigned Unaligned : 1; |
| 72 | |
| 73 | enum { |
| 74 | LDREX_B = (1 << 0), /// byte (8-bit) |
| 75 | LDREX_H = (1 << 1), /// half (16-bit) |
| 76 | LDREX_W = (1 << 2), /// word (32-bit) |
| 77 | LDREX_D = (1 << 3), /// double (64-bit) |
| 78 | }; |
| 79 | |
| 80 | uint32_t LDREX; |
| 81 | |
| 82 | // ACLE 6.5.1 Hardware floating point |
| 83 | enum { |
| 84 | HW_FP_HP = (1 << 1), /// half (16-bit) |
| 85 | HW_FP_SP = (1 << 2), /// single (32-bit) |
| 86 | HW_FP_DP = (1 << 3), /// double (64-bit) |
| 87 | }; |
| 88 | uint32_t HW_FP; |
| 89 | |
| 90 | static const Builtin::Info BuiltinInfo[]; |
| 91 | |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 92 | void setABIAAPCS(); |
| 93 | void setABIAPCS(bool IsAAPCS16); |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 94 | |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 95 | void setArchInfo(); |
Florian Hahn | ef5bbd6 | 2017-07-27 16:28:39 +0000 | [diff] [blame] | 96 | void setArchInfo(llvm::ARM::ArchKind Kind); |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 97 | |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 98 | void setAtomic(); |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 99 | |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 100 | bool isThumb() const; |
| 101 | bool supportsThumb() const; |
| 102 | bool supportsThumb2() const; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 103 | |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 104 | StringRef getCPUAttr() const; |
| 105 | StringRef getCPUProfile() const; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 106 | |
| 107 | public: |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 108 | ARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 109 | |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 110 | StringRef getABI() const override; |
| 111 | bool setABI(const std::string &Name) override; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 112 | |
| 113 | // FIXME: This should be based on Arch attributes, not CPU names. |
| 114 | bool |
| 115 | initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, |
| 116 | StringRef CPU, |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 117 | const std::vector<std::string> &FeaturesVec) const override; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 118 | |
| 119 | bool handleTargetFeatures(std::vector<std::string> &Features, |
| 120 | DiagnosticsEngine &Diags) override; |
| 121 | |
| 122 | bool hasFeature(StringRef Feature) const override; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 123 | |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 124 | bool isValidCPUName(StringRef Name) const override; |
| 125 | bool setCPU(const std::string &Name) override; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 126 | |
| 127 | bool setFPMath(StringRef Name) override; |
| 128 | |
Akira Hatanaka | 502775a | 2017-12-09 00:02:37 +0000 | [diff] [blame] | 129 | bool useFP16ConversionIntrinsics() const override { |
| 130 | return false; |
| 131 | } |
| 132 | |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 133 | void getTargetDefinesARMV81A(const LangOptions &Opts, |
| 134 | MacroBuilder &Builder) const; |
| 135 | |
| 136 | void getTargetDefinesARMV82A(const LangOptions &Opts, |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 137 | MacroBuilder &Builder) const; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 138 | void getTargetDefines(const LangOptions &Opts, |
| 139 | MacroBuilder &Builder) const override; |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 140 | |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 141 | ArrayRef<Builtin::Info> getTargetBuiltins() const override; |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 142 | |
| 143 | bool isCLZForZeroUndef() const override; |
| 144 | BuiltinVaListKind getBuiltinVaListKind() const override; |
| 145 | |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 146 | ArrayRef<const char *> getGCCRegNames() const override; |
| 147 | ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override; |
| 148 | bool validateAsmConstraint(const char *&Name, |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 149 | TargetInfo::ConstraintInfo &Info) const override; |
| 150 | std::string convertConstraint(const char *&Constraint) const override; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 151 | bool |
| 152 | validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size, |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 153 | std::string &SuggestedModifier) const override; |
| 154 | const char *getClobbers() const override; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 155 | |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 156 | CallingConvCheckResult checkCallingConvention(CallingConv CC) const override; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 157 | |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 158 | int getEHDataRegisterNumber(unsigned RegNo) const override; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 159 | |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 160 | bool hasSjLjLowering() const override; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 161 | }; |
| 162 | |
| 163 | class LLVM_LIBRARY_VISIBILITY ARMleTargetInfo : public ARMTargetInfo { |
| 164 | public: |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 165 | ARMleTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 166 | void getTargetDefines(const LangOptions &Opts, |
| 167 | MacroBuilder &Builder) const override; |
| 168 | }; |
| 169 | |
| 170 | class LLVM_LIBRARY_VISIBILITY ARMbeTargetInfo : public ARMTargetInfo { |
| 171 | public: |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 172 | ARMbeTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 173 | void getTargetDefines(const LangOptions &Opts, |
| 174 | MacroBuilder &Builder) const override; |
| 175 | }; |
| 176 | |
| 177 | class LLVM_LIBRARY_VISIBILITY WindowsARMTargetInfo |
| 178 | : public WindowsTargetInfo<ARMleTargetInfo> { |
| 179 | const llvm::Triple Triple; |
| 180 | |
| 181 | public: |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 182 | WindowsARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); |
| 183 | |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 184 | void getVisualStudioDefines(const LangOptions &Opts, |
| 185 | MacroBuilder &Builder) const; |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 186 | |
| 187 | BuiltinVaListKind getBuiltinVaListKind() const override; |
| 188 | |
| 189 | CallingConvCheckResult checkCallingConvention(CallingConv CC) const override; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 190 | }; |
| 191 | |
| 192 | // Windows ARM + Itanium C++ ABI Target |
| 193 | class LLVM_LIBRARY_VISIBILITY ItaniumWindowsARMleTargetInfo |
| 194 | : public WindowsARMTargetInfo { |
| 195 | public: |
| 196 | ItaniumWindowsARMleTargetInfo(const llvm::Triple &Triple, |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 197 | const TargetOptions &Opts); |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 198 | |
| 199 | void getTargetDefines(const LangOptions &Opts, |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 200 | MacroBuilder &Builder) const override; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 201 | }; |
| 202 | |
| 203 | // Windows ARM, MS (C++) ABI |
| 204 | class LLVM_LIBRARY_VISIBILITY MicrosoftARMleTargetInfo |
| 205 | : public WindowsARMTargetInfo { |
| 206 | public: |
| 207 | MicrosoftARMleTargetInfo(const llvm::Triple &Triple, |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 208 | const TargetOptions &Opts); |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 209 | |
| 210 | void getTargetDefines(const LangOptions &Opts, |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 211 | MacroBuilder &Builder) const override; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 212 | }; |
| 213 | |
| 214 | // ARM MinGW target |
| 215 | class LLVM_LIBRARY_VISIBILITY MinGWARMTargetInfo : public WindowsARMTargetInfo { |
| 216 | public: |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 217 | MinGWARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 218 | |
| 219 | void getTargetDefines(const LangOptions &Opts, |
| 220 | MacroBuilder &Builder) const override; |
| 221 | }; |
| 222 | |
| 223 | // ARM Cygwin target |
| 224 | class LLVM_LIBRARY_VISIBILITY CygwinARMTargetInfo : public ARMleTargetInfo { |
| 225 | public: |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 226 | CygwinARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); |
| 227 | |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 228 | void getTargetDefines(const LangOptions &Opts, |
| 229 | MacroBuilder &Builder) const override; |
| 230 | }; |
| 231 | |
| 232 | class LLVM_LIBRARY_VISIBILITY DarwinARMTargetInfo |
| 233 | : public DarwinTargetInfo<ARMleTargetInfo> { |
| 234 | protected: |
| 235 | void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 236 | MacroBuilder &Builder) const override; |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 237 | |
| 238 | public: |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 239 | DarwinARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 240 | }; |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 241 | |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 242 | // 32-bit RenderScript is armv7 with width and align of 'long' set to 8-bytes |
| 243 | class LLVM_LIBRARY_VISIBILITY RenderScript32TargetInfo |
| 244 | : public ARMleTargetInfo { |
| 245 | public: |
| 246 | RenderScript32TargetInfo(const llvm::Triple &Triple, |
Tim Northover | ad4c5db | 2017-07-24 17:06:23 +0000 | [diff] [blame] | 247 | const TargetOptions &Opts); |
| 248 | |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 249 | void getTargetDefines(const LangOptions &Opts, |
| 250 | MacroBuilder &Builder) const override; |
| 251 | }; |
| 252 | |
| 253 | } // namespace targets |
| 254 | } // namespace clang |
| 255 | |
| 256 | #endif // LLVM_CLANG_LIB_BASIC_TARGETS_ARM_H |