]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/llvm/tools/clang/include/clang/Basic/TargetInfo.h
MFC r234353:
[FreeBSD/stable/9.git] / contrib / llvm / tools / clang / include / clang / Basic / TargetInfo.h
1 //===--- TargetInfo.h - Expose information about the target -----*- 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 defines the TargetInfo interface.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_BASIC_TARGETINFO_H
15 #define LLVM_CLANG_BASIC_TARGETINFO_H
16
17 #include "clang/Basic/LLVM.h"
18 #include "llvm/ADT/IntrusiveRefCntPtr.h"
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/ADT/StringSwitch.h"
22 #include "llvm/ADT/Triple.h"
23 #include "llvm/Support/DataTypes.h"
24 #include "clang/Basic/AddressSpaces.h"
25 #include "clang/Basic/VersionTuple.h"
26 #include <cassert>
27 #include <vector>
28 #include <string>
29
30 namespace llvm {
31 struct fltSemantics;
32 }
33
34 namespace clang {
35 class DiagnosticsEngine;
36 class LangOptions;
37 class MacroBuilder;
38 class SourceLocation;
39 class SourceManager;
40 class TargetOptions;
41
42 namespace Builtin { struct Info; }
43
44 /// TargetCXXABI - The types of C++ ABIs for which we can generate code.
45 enum TargetCXXABI {
46   /// The generic ("Itanium") C++ ABI, documented at:
47   ///   http://www.codesourcery.com/public/cxx-abi/
48   CXXABI_Itanium,
49
50   /// The ARM C++ ABI, based largely on the Itanium ABI but with
51   /// significant differences.
52   ///    http://infocenter.arm.com
53   ///                    /help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf
54   CXXABI_ARM,
55
56   /// The Visual Studio ABI.  Only scattered official documentation exists.
57   CXXABI_Microsoft
58 };
59
60 /// TargetInfo - This class exposes information about the current target.
61 ///
62 class TargetInfo : public RefCountedBase<TargetInfo> {
63   llvm::Triple Triple;
64 protected:
65   // Target values set by the ctor of the actual target implementation.  Default
66   // values are specified by the TargetInfo constructor.
67   bool BigEndian;
68   bool TLSSupported;
69   bool NoAsmVariants;  // True if {|} are normal characters.
70   unsigned char PointerWidth, PointerAlign;
71   unsigned char BoolWidth, BoolAlign;
72   unsigned char IntWidth, IntAlign;
73   unsigned char HalfWidth, HalfAlign;
74   unsigned char FloatWidth, FloatAlign;
75   unsigned char DoubleWidth, DoubleAlign;
76   unsigned char LongDoubleWidth, LongDoubleAlign;
77   unsigned char LargeArrayMinWidth, LargeArrayAlign;
78   unsigned char LongWidth, LongAlign;
79   unsigned char LongLongWidth, LongLongAlign;
80   unsigned char SuitableAlign;
81   unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
82   const char *DescriptionString;
83   const char *UserLabelPrefix;
84   const char *MCountName;
85   const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat,
86     *LongDoubleFormat;
87   unsigned char RegParmMax, SSERegParmMax;
88   TargetCXXABI CXXABI;
89   const LangAS::Map *AddrSpaceMap;
90
91   mutable StringRef PlatformName;
92   mutable VersionTuple PlatformMinVersion;
93
94   unsigned HasAlignMac68kSupport : 1;
95   unsigned RealTypeUsesObjCFPRet : 3;
96   unsigned ComplexLongDoubleUsesFP2Ret : 1;
97
98   // TargetInfo Constructor.  Default initializes all fields.
99   TargetInfo(const std::string &T);
100
101 public:
102   /// CreateTargetInfo - Construct a target for the given options.
103   ///
104   /// \param Opts - The options to use to initialize the target. The target may
105   /// modify the options to canonicalize the target feature information to match
106   /// what the backend expects.
107   static TargetInfo* CreateTargetInfo(DiagnosticsEngine &Diags,
108                                       TargetOptions &Opts);
109
110   virtual ~TargetInfo();
111
112   ///===---- Target Data Type Query Methods -------------------------------===//
113   enum IntType {
114     NoInt = 0,
115     SignedShort,
116     UnsignedShort,
117     SignedInt,
118     UnsignedInt,
119     SignedLong,
120     UnsignedLong,
121     SignedLongLong,
122     UnsignedLongLong
123   };
124
125   enum RealType {
126     Float = 0,
127     Double,
128     LongDouble
129   };
130
131 protected:
132   IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType,
133           WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType;
134
135   /// Flag whether the Objective-C built-in boolean type should be signed char.
136   /// Otherwise, when this flag is not set, the normal built-in boolean type is
137   /// used.
138   unsigned UseSignedCharForObjCBool : 1;
139
140   /// Control whether the alignment of bit-field types is respected when laying
141   /// out structures. If true, then the alignment of the bit-field type will be
142   /// used to (a) impact the alignment of the containing structure, and (b)
143   /// ensure that the individual bit-field will not straddle an alignment
144   /// boundary.
145   unsigned UseBitFieldTypeAlignment : 1;
146
147   /// Control whether zero length bitfields (e.g., int : 0;) force alignment of
148   /// the next bitfield.  If the alignment of the zero length bitfield is 
149   /// greater than the member that follows it, `bar', `bar' will be aligned as
150   /// the type of the zero-length bitfield.
151   unsigned UseZeroLengthBitfieldAlignment : 1;
152
153   /// If non-zero, specifies a fixed alignment value for bitfields that follow
154   /// zero length bitfield, regardless of the zero length bitfield type.
155   unsigned ZeroLengthBitfieldBoundary;
156
157 public:
158   IntType getSizeType() const { return SizeType; }
159   IntType getIntMaxType() const { return IntMaxType; }
160   IntType getUIntMaxType() const { return UIntMaxType; }
161   IntType getPtrDiffType(unsigned AddrSpace) const {
162     return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
163   }
164   IntType getIntPtrType() const { return IntPtrType; }
165   IntType getWCharType() const { return WCharType; }
166   IntType getWIntType() const { return WIntType; }
167   IntType getChar16Type() const { return Char16Type; }
168   IntType getChar32Type() const { return Char32Type; }
169   IntType getInt64Type() const { return Int64Type; }
170   IntType getSigAtomicType() const { return SigAtomicType; }
171
172
173   /// getTypeWidth - Return the width (in bits) of the specified integer type
174   /// enum. For example, SignedInt -> getIntWidth().
175   unsigned getTypeWidth(IntType T) const;
176
177   /// getTypeAlign - Return the alignment (in bits) of the specified integer
178   /// type enum. For example, SignedInt -> getIntAlign().
179   unsigned getTypeAlign(IntType T) const;
180
181   /// isTypeSigned - Return whether an integer types is signed. Returns true if
182   /// the type is signed; false otherwise.
183   static bool isTypeSigned(IntType T);
184
185   /// getPointerWidth - Return the width of pointers on this target, for the
186   /// specified address space.
187   uint64_t getPointerWidth(unsigned AddrSpace) const {
188     return AddrSpace == 0 ? PointerWidth : getPointerWidthV(AddrSpace);
189   }
190   uint64_t getPointerAlign(unsigned AddrSpace) const {
191     return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace);
192   }
193
194   /// getBoolWidth/Align - Return the size of '_Bool' and C++ 'bool' for this
195   /// target, in bits.
196   unsigned getBoolWidth() const { return BoolWidth; }
197   unsigned getBoolAlign() const { return BoolAlign; }
198
199   unsigned getCharWidth() const { return 8; } // FIXME
200   unsigned getCharAlign() const { return 8; } // FIXME
201
202   /// getShortWidth/Align - Return the size of 'signed short' and
203   /// 'unsigned short' for this target, in bits.
204   unsigned getShortWidth() const { return 16; } // FIXME
205   unsigned getShortAlign() const { return 16; } // FIXME
206
207   /// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for
208   /// this target, in bits.
209   unsigned getIntWidth() const { return IntWidth; }
210   unsigned getIntAlign() const { return IntAlign; }
211
212   /// getLongWidth/Align - Return the size of 'signed long' and 'unsigned long'
213   /// for this target, in bits.
214   unsigned getLongWidth() const { return LongWidth; }
215   unsigned getLongAlign() const { return LongAlign; }
216
217   /// getLongLongWidth/Align - Return the size of 'signed long long' and
218   /// 'unsigned long long' for this target, in bits.
219   unsigned getLongLongWidth() const { return LongLongWidth; }
220   unsigned getLongLongAlign() const { return LongLongAlign; }
221
222   /// getSuitableAlign - Return the alignment that is suitable for storing any
223   /// object with a fundamental alignment requirement.
224   unsigned getSuitableAlign() const { return SuitableAlign; }
225
226   /// getWCharWidth/Align - Return the size of 'wchar_t' for this target, in
227   /// bits.
228   unsigned getWCharWidth() const { return getTypeWidth(WCharType); }
229   unsigned getWCharAlign() const { return getTypeAlign(WCharType); }
230
231   /// getChar16Width/Align - Return the size of 'char16_t' for this target, in
232   /// bits.
233   unsigned getChar16Width() const { return getTypeWidth(Char16Type); }
234   unsigned getChar16Align() const { return getTypeAlign(Char16Type); }
235
236   /// getChar32Width/Align - Return the size of 'char32_t' for this target, in
237   /// bits.
238   unsigned getChar32Width() const { return getTypeWidth(Char32Type); }
239   unsigned getChar32Align() const { return getTypeAlign(Char32Type); }
240
241   /// getHalfWidth/Align/Format - Return the size/align/format of 'half'.
242   unsigned getHalfWidth() const { return HalfWidth; }
243   unsigned getHalfAlign() const { return HalfAlign; }
244   const llvm::fltSemantics &getHalfFormat() const { return *HalfFormat; }
245
246   /// getFloatWidth/Align/Format - Return the size/align/format of 'float'.
247   unsigned getFloatWidth() const { return FloatWidth; }
248   unsigned getFloatAlign() const { return FloatAlign; }
249   const llvm::fltSemantics &getFloatFormat() const { return *FloatFormat; }
250
251   /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
252   unsigned getDoubleWidth() const { return DoubleWidth; }
253   unsigned getDoubleAlign() const { return DoubleAlign; }
254   const llvm::fltSemantics &getDoubleFormat() const { return *DoubleFormat; }
255
256   /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long
257   /// double'.
258   unsigned getLongDoubleWidth() const { return LongDoubleWidth; }
259   unsigned getLongDoubleAlign() const { return LongDoubleAlign; }
260   const llvm::fltSemantics &getLongDoubleFormat() const {
261     return *LongDoubleFormat;
262   }
263
264   /// getFloatEvalMethod - Return the value for the C99 FLT_EVAL_METHOD macro.
265   virtual unsigned getFloatEvalMethod() const { return 0; }
266
267   // getLargeArrayMinWidth/Align - Return the minimum array size that is
268   // 'large' and its alignment.
269   unsigned getLargeArrayMinWidth() const { return LargeArrayMinWidth; }
270   unsigned getLargeArrayAlign() const { return LargeArrayAlign; }
271
272   /// getMaxAtomicPromoteWidth - Return the maximum width lock-free atomic
273   /// operation which will ever be supported for the given target
274   unsigned getMaxAtomicPromoteWidth() const { return MaxAtomicPromoteWidth; }
275   /// getMaxAtomicInlineWidth - Return the maximum width lock-free atomic
276   /// operation which can be inlined given the supported features of the
277   /// given target.
278   unsigned getMaxAtomicInlineWidth() const { return MaxAtomicInlineWidth; }
279
280   /// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this
281   /// target, in bits.
282   unsigned getIntMaxTWidth() const {
283     return getTypeWidth(IntMaxType);
284   }
285
286   /// getRegisterWidth - Return the "preferred" register width on this target.
287   uint64_t getRegisterWidth() const {
288     // Currently we assume the register width on the target matches the pointer
289     // width, we can introduce a new variable for this if/when some target wants
290     // it.
291     return LongWidth; 
292   }
293
294   /// getUserLabelPrefix - This returns the default value of the
295   /// __USER_LABEL_PREFIX__ macro, which is the prefix given to user symbols by
296   /// default.  On most platforms this is "_", but it is "" on some, and "." on
297   /// others.
298   const char *getUserLabelPrefix() const {
299     return UserLabelPrefix;
300   }
301
302   /// MCountName - This returns name of the mcount instrumentation function.
303   const char *getMCountName() const {
304     return MCountName;
305   }
306
307   /// useSignedCharForObjCBool - Check if the Objective-C built-in boolean
308   /// type should be signed char.  Otherwise, if this returns false, the
309   /// normal built-in boolean type should also be used for Objective-C.
310   bool useSignedCharForObjCBool() const {
311     return UseSignedCharForObjCBool;
312   }
313   void noSignedCharForObjCBool() {
314     UseSignedCharForObjCBool = false;
315   }
316
317   /// useBitFieldTypeAlignment() - Check whether the alignment of bit-field 
318   /// types is respected when laying out structures.
319   bool useBitFieldTypeAlignment() const {
320     return UseBitFieldTypeAlignment;
321   }
322
323   /// useZeroLengthBitfieldAlignment() - Check whether zero length bitfields 
324   /// should force alignment of the next member.
325   bool useZeroLengthBitfieldAlignment() const {
326     return UseZeroLengthBitfieldAlignment;
327   }
328
329   /// getZeroLengthBitfieldBoundary() - Get the fixed alignment value in bits
330   /// for a member that follows a zero length bitfield.
331   unsigned getZeroLengthBitfieldBoundary() const {
332     return ZeroLengthBitfieldBoundary;
333   }
334
335   /// hasAlignMac68kSupport - Check whether this target support '#pragma options
336   /// align=mac68k'.
337   bool hasAlignMac68kSupport() const {
338     return HasAlignMac68kSupport;
339   }
340
341   /// getTypeName - Return the user string for the specified integer type enum.
342   /// For example, SignedShort -> "short".
343   static const char *getTypeName(IntType T);
344
345   /// getTypeConstantSuffix - Return the constant suffix for the specified
346   /// integer type enum. For example, SignedLong -> "L".
347   static const char *getTypeConstantSuffix(IntType T);
348
349   /// \brief Check whether the given real type should use the "fpret" flavor of
350   /// Obj-C message passing on this target.
351   bool useObjCFPRetForRealType(RealType T) const {
352     return RealTypeUsesObjCFPRet & (1 << T);
353   }
354
355   /// \brief Check whether _Complex long double should use the "fp2ret" flavor
356   /// of Obj-C message passing on this target.
357   bool useObjCFP2RetForComplexLongDouble() const {
358     return ComplexLongDoubleUsesFP2Ret;
359   }
360
361   ///===---- Other target property query methods --------------------------===//
362
363   /// getTargetDefines - Appends the target-specific #define values for this
364   /// target set to the specified buffer.
365   virtual void getTargetDefines(const LangOptions &Opts,
366                                 MacroBuilder &Builder) const = 0;
367
368
369   /// getTargetBuiltins - Return information about target-specific builtins for
370   /// the current primary target, and info about which builtins are non-portable
371   /// across the current set of primary and secondary targets.
372   virtual void getTargetBuiltins(const Builtin::Info *&Records,
373                                  unsigned &NumRecords) const = 0;
374
375   /// isCLZForZeroUndef - The __builtin_clz* and __builtin_ctz* built-in
376   /// functions are specified to have undefined results for zero inputs, but
377   /// on targets that support these operations in a way that provides
378   /// well-defined results for zero without loss of performance, it is a good
379   /// idea to avoid optimizing based on that undef behavior.
380   virtual bool isCLZForZeroUndef() const { return true; }
381
382   /// getVAListDeclaration - Return the declaration to use for
383   /// __builtin_va_list, which is target-specific.
384   virtual const char *getVAListDeclaration() const = 0;
385
386   /// isValidClobber - Returns whether the passed in string is
387   /// a valid clobber in an inline asm statement. This is used by
388   /// Sema.
389   bool isValidClobber(StringRef Name) const;
390
391   /// isValidGCCRegisterName - Returns whether the passed in string
392   /// is a valid register name according to GCC. This is used by Sema for
393   /// inline asm statements.
394   bool isValidGCCRegisterName(StringRef Name) const;
395
396   // getNormalizedGCCRegisterName - Returns the "normalized" GCC register name.
397   // For example, on x86 it will return "ax" when "eax" is passed in.
398   StringRef getNormalizedGCCRegisterName(StringRef Name) const;
399
400   struct ConstraintInfo {
401     enum {
402       CI_None = 0x00,
403       CI_AllowsMemory = 0x01,
404       CI_AllowsRegister = 0x02,
405       CI_ReadWrite = 0x04,       // "+r" output constraint (read and write).
406       CI_HasMatchingInput = 0x08 // This output operand has a matching input.
407     };
408     unsigned Flags;
409     int TiedOperand;
410
411     std::string ConstraintStr;  // constraint: "=rm"
412     std::string Name;           // Operand name: [foo] with no []'s.
413   public:
414     ConstraintInfo(StringRef ConstraintStr, StringRef Name)
415       : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
416       Name(Name.str()) {}
417
418     const std::string &getConstraintStr() const { return ConstraintStr; }
419     const std::string &getName() const { return Name; }
420     bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; }
421     bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; }
422     bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; }
423
424     /// hasMatchingInput - Return true if this output operand has a matching
425     /// (tied) input operand.
426     bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; }
427
428     /// hasTiedOperand() - Return true if this input operand is a matching
429     /// constraint that ties it to an output operand.  If this returns true,
430     /// then getTiedOperand will indicate which output operand this is tied to.
431     bool hasTiedOperand() const { return TiedOperand != -1; }
432     unsigned getTiedOperand() const {
433       assert(hasTiedOperand() && "Has no tied operand!");
434       return (unsigned)TiedOperand;
435     }
436
437     void setIsReadWrite() { Flags |= CI_ReadWrite; }
438     void setAllowsMemory() { Flags |= CI_AllowsMemory; }
439     void setAllowsRegister() { Flags |= CI_AllowsRegister; }
440     void setHasMatchingInput() { Flags |= CI_HasMatchingInput; }
441
442     /// setTiedOperand - Indicate that this is an input operand that is tied to
443     /// the specified output operand.  Copy over the various constraint
444     /// information from the output.
445     void setTiedOperand(unsigned N, ConstraintInfo &Output) {
446       Output.setHasMatchingInput();
447       Flags = Output.Flags;
448       TiedOperand = N;
449       // Don't copy Name or constraint string.
450     }
451   };
452
453   // validateOutputConstraint, validateInputConstraint - Checks that
454   // a constraint is valid and provides information about it.
455   // FIXME: These should return a real error instead of just true/false.
456   bool validateOutputConstraint(ConstraintInfo &Info) const;
457   bool validateInputConstraint(ConstraintInfo *OutputConstraints,
458                                unsigned NumOutputs,
459                                ConstraintInfo &info) const;
460   bool resolveSymbolicName(const char *&Name,
461                            ConstraintInfo *OutputConstraints,
462                            unsigned NumOutputs, unsigned &Index) const;
463
464   // Constraint parm will be left pointing at the last character of
465   // the constraint.  In practice, it won't be changed unless the
466   // constraint is longer than one character.
467   virtual std::string convertConstraint(const char *&Constraint) const {
468     // 'p' defaults to 'r', but can be overridden by targets.
469     if (*Constraint == 'p')
470       return std::string("r");
471     return std::string(1, *Constraint);
472   }
473
474   // Returns a string of target-specific clobbers, in LLVM format.
475   virtual const char *getClobbers() const = 0;
476
477
478   /// getTriple - Return the target triple of the primary target.
479   const llvm::Triple &getTriple() const {
480     return Triple;
481   }
482
483   const char *getTargetDescription() const {
484     return DescriptionString;
485   }
486
487   struct GCCRegAlias {
488     const char * const Aliases[5];
489     const char * const Register;
490   };
491
492   struct AddlRegName {
493     const char * const Names[5];
494     const unsigned RegNum;
495   };
496
497   /// hasProtectedVisibility - Does this target support "protected"
498   /// visibility?
499   ///
500   /// Any target which dynamic libraries will naturally support
501   /// something like "default" (meaning that the symbol is visible
502   /// outside this shared object) and "hidden" (meaning that it isn't)
503   /// visibilities, but "protected" is really an ELF-specific concept
504   /// with wierd semantics designed around the convenience of dynamic
505   /// linker implementations.  Which is not to suggest that there's
506   /// consistent target-independent semantics for "default" visibility
507   /// either; the entire thing is pretty badly mangled.
508   virtual bool hasProtectedVisibility() const { return true; }
509
510   virtual bool useGlobalsForAutomaticVariables() const { return false; }
511
512   /// getCFStringSection - Return the section to use for CFString
513   /// literals, or 0 if no special section is used.
514   virtual const char *getCFStringSection() const {
515     return "__DATA,__cfstring";
516   }
517
518   /// getNSStringSection - Return the section to use for NSString
519   /// literals, or 0 if no special section is used.
520   virtual const char *getNSStringSection() const {
521     return "__OBJC,__cstring_object,regular,no_dead_strip";
522   }
523
524   /// getNSStringNonFragileABISection - Return the section to use for
525   /// NSString literals, or 0 if no special section is used (NonFragile ABI).
526   virtual const char *getNSStringNonFragileABISection() const {
527     return "__DATA, __objc_stringobj, regular, no_dead_strip";
528   }
529
530   /// isValidSectionSpecifier - This is an optional hook that targets can
531   /// implement to perform semantic checking on attribute((section("foo")))
532   /// specifiers.  In this case, "foo" is passed in to be checked.  If the
533   /// section specifier is invalid, the backend should return a non-empty string
534   /// that indicates the problem.
535   ///
536   /// This hook is a simple quality of implementation feature to catch errors
537   /// and give good diagnostics in cases when the assembler or code generator
538   /// would otherwise reject the section specifier.
539   ///
540   virtual std::string isValidSectionSpecifier(StringRef SR) const {
541     return "";
542   }
543
544   /// setForcedLangOptions - Set forced language options.
545   /// Apply changes to the target information with respect to certain
546   /// language options which change the target configuration.
547   virtual void setForcedLangOptions(LangOptions &Opts);
548
549   /// getDefaultFeatures - Get the default set of target features for the CPU;
550   /// this should include all legal feature strings on the target.
551   virtual void getDefaultFeatures(llvm::StringMap<bool> &Features) const {
552   }
553
554   /// getABI - Get the ABI in use.
555   virtual const char *getABI() const {
556     return "";
557   }
558
559   /// getCXXABI - Get the C++ ABI in use.
560   virtual TargetCXXABI getCXXABI() const {
561     return CXXABI;
562   }
563
564   /// setCPU - Target the specific CPU.
565   ///
566   /// \return - False on error (invalid CPU name).
567   virtual bool setCPU(const std::string &Name) {
568     return false;
569   }
570
571   /// setABI - Use the specific ABI.
572   ///
573   /// \return - False on error (invalid ABI name).
574   virtual bool setABI(const std::string &Name) {
575     return false;
576   }
577
578   /// setCXXABI - Use this specific C++ ABI.
579   ///
580   /// \return - False on error (invalid C++ ABI name).
581   bool setCXXABI(const std::string &Name) {
582     static const TargetCXXABI Unknown = static_cast<TargetCXXABI>(-1);
583     TargetCXXABI ABI = llvm::StringSwitch<TargetCXXABI>(Name)
584       .Case("arm", CXXABI_ARM)
585       .Case("itanium", CXXABI_Itanium)
586       .Case("microsoft", CXXABI_Microsoft)
587       .Default(Unknown);
588     if (ABI == Unknown) return false;
589     return setCXXABI(ABI);
590   }
591
592   /// setCXXABI - Set the C++ ABI to be used by this implementation.
593   ///
594   /// \return - False on error (ABI not valid on this target)
595   virtual bool setCXXABI(TargetCXXABI ABI) {
596     CXXABI = ABI;
597     return true;
598   }
599
600   /// setFeatureEnabled - Enable or disable a specific target feature,
601   /// the feature name must be valid.
602   ///
603   /// \return - False on error (invalid feature name).
604   virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
605                                  StringRef Name,
606                                  bool Enabled) const {
607     return false;
608   }
609
610   /// HandleTargetOptions - Perform initialization based on the user configured
611   /// set of features (e.g., +sse4). The list is guaranteed to have at most one
612   /// entry per feature.
613   ///
614   /// The target may modify the features list, to change which options are
615   /// passed onwards to the backend.
616   virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
617   }
618
619   /// \brief Determine whether the given target has the given feature.
620   virtual bool hasFeature(StringRef Feature) const {
621     return false;
622   }
623   
624   // getRegParmMax - Returns maximal number of args passed in registers.
625   unsigned getRegParmMax() const {
626     assert(RegParmMax < 7 && "RegParmMax value is larger than AST can handle");
627     return RegParmMax;
628   }
629
630   /// isTLSSupported - Whether the target supports thread-local storage.
631   bool isTLSSupported() const {
632     return TLSSupported;
633   }
634
635   /// hasNoAsmVariants - Return true if {|} are normal characters in the
636   /// asm string.  If this returns false (the default), then {abc|xyz} is syntax
637   /// that says that when compiling for asm variant #0, "abc" should be
638   /// generated, but when compiling for asm variant #1, "xyz" should be
639   /// generated.
640   bool hasNoAsmVariants() const {
641     return NoAsmVariants;
642   }
643
644   /// getEHDataRegisterNumber - Return the register number that
645   /// __builtin_eh_return_regno would return with the specified argument.
646   virtual int getEHDataRegisterNumber(unsigned RegNo) const {
647     return -1;
648   }
649
650   /// getStaticInitSectionSpecifier - Return the section to use for C++ static
651   /// initialization functions.
652   virtual const char *getStaticInitSectionSpecifier() const {
653     return 0;
654   }
655
656   const LangAS::Map &getAddressSpaceMap() const {
657     return *AddrSpaceMap;
658   }
659
660   /// \brief Retrieve the name of the platform as it is used in the
661   /// availability attribute.
662   StringRef getPlatformName() const { return PlatformName; }
663
664   /// \brief Retrieve the minimum desired version of the platform, to
665   /// which the program should be compiled.
666   VersionTuple getPlatformMinVersion() const { return PlatformMinVersion; }
667
668   bool isBigEndian() const { return BigEndian; }
669
670 protected:
671   virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
672     return PointerWidth;
673   }
674   virtual uint64_t getPointerAlignV(unsigned AddrSpace) const {
675     return PointerAlign;
676   }
677   virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const {
678     return PtrDiffType;
679   }
680   virtual void getGCCRegNames(const char * const *&Names,
681                               unsigned &NumNames) const = 0;
682   virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
683                                 unsigned &NumAliases) const = 0;
684   virtual void getGCCAddlRegNames(const AddlRegName *&Addl,
685                                   unsigned &NumAddl) const {
686     Addl = 0;
687     NumAddl = 0;
688   }
689   virtual bool validateAsmConstraint(const char *&Name,
690                                      TargetInfo::ConstraintInfo &info) const= 0;
691 };
692
693 }  // end namespace clang
694
695 #endif