15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- TargetInfo.h - Expose information about the target -----*- C++ -*-===//
25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//                     The LLVM Compiler Infrastructure
45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source
60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details.
75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
102b59a2cbfdb93fcf1a4a303e1ea7753ff1c7b319Nate Begeman//  This file defines the TargetInfo interface.
115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//
125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===//
135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_BASIC_TARGETINFO_H
155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_BASIC_TARGETINFO_H
165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
17686775deca8b8685eb90801495880e3abdd844c2Chris Lattner#include "clang/Basic/LLVM.h"
184f32786ac45210143654390177105eb749b614e9Ted Kremenek#include "llvm/ADT/IntrusiveRefCntPtr.h"
19868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar#include "llvm/ADT/StringMap.h"
200a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor#include "llvm/ADT/StringRef.h"
2120cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis#include "llvm/ADT/StringSwitch.h"
221752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar#include "llvm/ADT/Triple.h"
2303013fa9a0bf1ef4b907f5fec006c8f4000fdd21Michael J. Spencer#include "llvm/Support/DataTypes.h"
24207f4d8543529221932af82836016a2ef066c917Peter Collingbourne#include "clang/Basic/AddressSpaces.h"
250a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor#include "clang/Basic/VersionTuple.h"
265414fbac5f1749c0e85a8c4eeb5dfece59c3e30aTorok Edwin#include <cassert>
275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include <vector>
285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include <string>
295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
30797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnernamespace llvm {
31797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnerstruct fltSemantics;
32797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner}
33525a05093a4816af961fe2bc6b8a81c17e2e26c2Chris Lattner
345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
35d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikieclass DiagnosticsEngine;
36d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbarclass LangOptions;
37103b71c37a3c3a3da7128c1d0232a89b1e8d0d90Chandler Carruthclass MacroBuilder;
38797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnerclass SourceLocation;
397a9d49fd2bfac00e905b361ba76d26ab5b6c3b09Ted Kremenekclass SourceManager;
40d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbarclass TargetOptions;
41d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar
425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace Builtin { struct Info; }
431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4420cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis/// TargetCXXABI - The types of C++ ABIs for which we can generate code.
4520cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davisenum TargetCXXABI {
46ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  /// The generic ("Itanium") C++ ABI, documented at:
47ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  ///   http://www.codesourcery.com/public/cxx-abi/
4820cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis  CXXABI_Itanium,
49ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall
50ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  /// The ARM C++ ABI, based largely on the Itanium ABI but with
51ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  /// significant differences.
52ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  ///    http://infocenter.arm.com
53ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  ///                    /help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf
54ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  CXXABI_ARM,
55ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall
56ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  /// The Visual Studio ABI.  Only scattered official documentation exists.
5720cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis  CXXABI_Microsoft
5820cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis};
5920cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis
6042e6737f2efb113563140ad794c21c7709250402Chris Lattner/// TargetInfo - This class exposes information about the current target.
615f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer///
62c93dc7889644293e318e19d82830ea2acc45b678Dylan Noblesmithclass TargetInfo : public RefCountedBase<TargetInfo> {
631752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar  llvm::Triple Triple;
640eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattnerprotected:
65cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  // Target values set by the ctor of the actual target implementation.  Default
66cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  // values are specified by the TargetInfo constructor.
67e6a24e83e71f361c7b7de82cf24ee6f5ddc7f1c2Eli Friedman  bool BigEndian;
68b030f0272500c6c5602f587ac029ee0dc0e5a05cEli Friedman  bool TLSSupported;
699bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  bool NoAsmVariants;  // True if {|} are normal characters.
70927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char PointerWidth, PointerAlign;
71c81f2a2c7f83e64b3ef2b77030536290d0e2b350Roman Divacky  unsigned char BoolWidth, BoolAlign;
72927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char IntWidth, IntAlign;
73aa4a99b4a62615db243f7a5c433169f2fc704420Anton Korobeynikov  unsigned char HalfWidth, HalfAlign;
7461538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned char FloatWidth, FloatAlign;
75927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char DoubleWidth, DoubleAlign;
7661538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned char LongDoubleWidth, LongDoubleAlign;
776deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola  unsigned char LargeArrayMinWidth, LargeArrayAlign;
78927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char LongWidth, LongAlign;
79927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char LongLongWidth, LongLongAlign;
807ec59c78f1e19157767648cbe3f0e3630ca1afe7Nick Lewycky  unsigned char SuitableAlign;
812be460723940f8184ec36529b6f6ddf59c04e411Eli Friedman  unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
8277e8b53fe3ff630d8d1454db94e38bedda14d5caDaniel Dunbar  const char *DescriptionString;
833fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  const char *UserLabelPrefix;
84be4c8705e499b55548467eb7adaa23cbc6edfef9Roman Divacky  const char *MCountName;
85aa4a99b4a62615db243f7a5c433169f2fc704420Anton Korobeynikov  const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat,
86aa4a99b4a62615db243f7a5c433169f2fc704420Anton Korobeynikov    *LongDoubleFormat;
87264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov  unsigned char RegParmMax, SSERegParmMax;
8820cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis  TargetCXXABI CXXABI;
89207f4d8543529221932af82836016a2ef066c917Peter Collingbourne  const LangAS::Map *AddrSpaceMap;
90bbced580c92afa09cd4423a9bdc90ff61cb1e79aTed Kremenek
91686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  mutable StringRef PlatformName;
920a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor  mutable VersionTuple PlatformMinVersion;
930a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor
94613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  unsigned HasAlignMac68kSupport : 1;
95dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  unsigned RealTypeUsesObjCFPRet : 3;
96eea64802558cc398571938b1f28cda1d4fa79ec3Anders Carlsson  unsigned ComplexLongDoubleUsesFP2Ret : 1;
97613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar
98cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  // TargetInfo Constructor.  Default initializes all fields.
99cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  TargetInfo(const std::string &T);
1001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumppublic:
102d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar  /// CreateTargetInfo - Construct a target for the given options.
103b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  ///
104b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// \param Opts - The options to use to initialize the target. The target may
105b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// modify the options to canonicalize the target feature information to match
106b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// what the backend expects.
107d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie  static TargetInfo* CreateTargetInfo(DiagnosticsEngine &Diags,
108d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie                                      TargetOptions &Opts);
109bbced580c92afa09cd4423a9bdc90ff61cb1e79aTed Kremenek
1100eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  virtual ~TargetInfo();
111fb79f7cc00f9c1e04f11ed636eefb36d246b0fb8Ted Kremenek
1129c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner  ///===---- Target Data Type Query Methods -------------------------------===//
11331fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta  enum IntType {
1142b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner    NoInt = 0,
11531fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    SignedShort,
11631fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    UnsignedShort,
11731fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    SignedInt,
11831fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    UnsignedInt,
11931fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    SignedLong,
12031fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    UnsignedLong,
12131fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    SignedLongLong,
12231fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    UnsignedLongLong
1233fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  };
124dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar
125dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  enum RealType {
126dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar    Float = 0,
127dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar    Double,
128dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar    LongDouble
129dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  };
130dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar
1313fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattnerprotected:
1323c7b6e46c5f9bdbe0676c52d80df98b68b02be99Eli Friedman  IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType,
1339cf910efc4fb7001a6d276ed2eabf01f0f0efaaaEdward O'Callaghan          WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType;
134b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar
13593a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian  /// Flag whether the Objective-C built-in boolean type should be signed char.
13693a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian  /// Otherwise, when this flag is not set, the normal built-in boolean type is
13793a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian  /// used.
13893a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian  unsigned UseSignedCharForObjCBool : 1;
13993a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian
140b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// Control whether the alignment of bit-field types is respected when laying
141b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// out structures. If true, then the alignment of the bit-field type will be
142b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// used to (a) impact the alignment of the containing structure, and (b)
143b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// ensure that the individual bit-field will not straddle an alignment
144b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// boundary.
145b6830d616a068971f13e1e213e06a945c8c93ceaDaniel Dunbar  unsigned UseBitFieldTypeAlignment : 1;
146b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar
14761a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  /// Control whether zero length bitfields (e.g., int : 0;) force alignment of
14861a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  /// the next bitfield.  If the alignment of the zero length bitfield is
14961a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  /// greater than the member that follows it, `bar', `bar' will be aligned as
15061a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  /// the type of the zero-length bitfield.
15161a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  unsigned UseZeroLengthBitfieldAlignment : 1;
15261a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier
15361a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  /// If non-zero, specifies a fixed alignment value for bitfields that follow
15461a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  /// zero length bitfield, regardless of the zero length bitfield type.
15561a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  unsigned ZeroLengthBitfieldBoundary;
15661a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier
1573fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattnerpublic:
1583fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getSizeType() const { return SizeType; }
1593fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getIntMaxType() const { return IntMaxType; }
1603fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getUIntMaxType() const { return UIntMaxType; }
1613fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getPtrDiffType(unsigned AddrSpace) const {
16231fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
16331fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta  }
1646ad474f82f0cf32e13128d89fa5ad3a37ae73530Chris Lattner  IntType getIntPtrType() const { return IntPtrType; }
1653fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getWCharType() const { return WCharType; }
166e64ef80363c84f4f431e26b61db554c89beeddb6Chris Lattner  IntType getWIntType() const { return WIntType; }
167f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  IntType getChar16Type() const { return Char16Type; }
168f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  IntType getChar32Type() const { return Char32Type; }
1693c7b6e46c5f9bdbe0676c52d80df98b68b02be99Eli Friedman  IntType getInt64Type() const { return Int64Type; }
1709cf910efc4fb7001a6d276ed2eabf01f0f0efaaaEdward O'Callaghan  IntType getSigAtomicType() const { return SigAtomicType; }
1715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
172b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
173237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer  /// getTypeWidth - Return the width (in bits) of the specified integer type
174b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  /// enum. For example, SignedInt -> getIntWidth().
175b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  unsigned getTypeWidth(IntType T) const;
176b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
1779099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner  /// getTypeAlign - Return the alignment (in bits) of the specified integer
1789099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner  /// type enum. For example, SignedInt -> getIntAlign().
1799099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner  unsigned getTypeAlign(IntType T) const;
1809099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner
181961f0708fb66375acf47f9e9bc1aecfb3f992aeaChris Lattner  /// isTypeSigned - Return whether an integer types is signed. Returns true if
182b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  /// the type is signed; false otherwise.
1833f59c975aa5d047f7edd1b900b5e885c38af0ef7Chris Lattner  static bool isTypeSigned(IntType T);
184b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
185f72a44330b9d9a4b2d93e9b91cfb8ab7bd4a0643Chris Lattner  /// getPointerWidth - Return the width of pointers on this target, for the
186927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  /// specified address space.
187927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  uint64_t getPointerWidth(unsigned AddrSpace) const {
188927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner    return AddrSpace == 0 ? PointerWidth : getPointerWidthV(AddrSpace);
189927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  }
190927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  uint64_t getPointerAlign(unsigned AddrSpace) const {
191927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner    return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace);
192927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  }
1931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1949e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getBoolWidth/Align - Return the size of '_Bool' and C++ 'bool' for this
1959e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// target, in bits.
196c81f2a2c7f83e64b3ef2b77030536290d0e2b350Roman Divacky  unsigned getBoolWidth() const { return BoolWidth; }
197c81f2a2c7f83e64b3ef2b77030536290d0e2b350Roman Divacky  unsigned getBoolAlign() const { return BoolAlign; }
1981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
199f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  unsigned getCharWidth() const { return 8; } // FIXME
200f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  unsigned getCharAlign() const { return 8; } // FIXME
2011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2029e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getShortWidth/Align - Return the size of 'signed short' and
2031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// 'unsigned short' for this target, in bits.
2049e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  unsigned getShortWidth() const { return 16; } // FIXME
2059e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  unsigned getShortAlign() const { return 16; } // FIXME
2061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2079e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for
2089e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// this target, in bits.
2092621fd1d6d3c5eadcae246859f62738645df7540Chris Lattner  unsigned getIntWidth() const { return IntWidth; }
2102621fd1d6d3c5eadcae246859f62738645df7540Chris Lattner  unsigned getIntAlign() const { return IntAlign; }
2111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2129e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getLongWidth/Align - Return the size of 'signed long' and 'unsigned long'
2139e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// for this target, in bits.
2148059e997ee05e4aa87f7e21fed630429a140ee53Chris Lattner  unsigned getLongWidth() const { return LongWidth; }
2158059e997ee05e4aa87f7e21fed630429a140ee53Chris Lattner  unsigned getLongAlign() const { return LongAlign; }
2161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2179e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getLongLongWidth/Align - Return the size of 'signed long long' and
2189e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// 'unsigned long long' for this target, in bits.
219ec10f5886526124ba733fbd0ef8665d576285daaChris Lattner  unsigned getLongLongWidth() const { return LongLongWidth; }
220ec10f5886526124ba733fbd0ef8665d576285daaChris Lattner  unsigned getLongLongAlign() const { return LongLongAlign; }
2211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2227ec59c78f1e19157767648cbe3f0e3630ca1afe7Nick Lewycky  /// getSuitableAlign - Return the alignment that is suitable for storing any
2237ec59c78f1e19157767648cbe3f0e3630ca1afe7Nick Lewycky  /// object with a fundamental alignment requirement.
2247ec59c78f1e19157767648cbe3f0e3630ca1afe7Nick Lewycky  unsigned getSuitableAlign() const { return SuitableAlign; }
2257ec59c78f1e19157767648cbe3f0e3630ca1afe7Nick Lewycky
226f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// getWCharWidth/Align - Return the size of 'wchar_t' for this target, in
2279e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// bits.
2289184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getWCharWidth() const { return getTypeWidth(WCharType); }
2299184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getWCharAlign() const { return getTypeAlign(WCharType); }
230f72a44330b9d9a4b2d93e9b91cfb8ab7bd4a0643Chris Lattner
231f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// getChar16Width/Align - Return the size of 'char16_t' for this target, in
232f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// bits.
2339184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getChar16Width() const { return getTypeWidth(Char16Type); }
2349184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getChar16Align() const { return getTypeAlign(Char16Type); }
235f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith
236f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// getChar32Width/Align - Return the size of 'char32_t' for this target, in
237f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// bits.
2389184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getChar32Width() const { return getTypeWidth(Char32Type); }
2399184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getChar32Align() const { return getTypeAlign(Char32Type); }
240f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith
241aa4a99b4a62615db243f7a5c433169f2fc704420Anton Korobeynikov  /// getHalfWidth/Align/Format - Return the size/align/format of 'half'.
242aa4a99b4a62615db243f7a5c433169f2fc704420Anton Korobeynikov  unsigned getHalfWidth() const { return HalfWidth; }
243aa4a99b4a62615db243f7a5c433169f2fc704420Anton Korobeynikov  unsigned getHalfAlign() const { return HalfAlign; }
244aa4a99b4a62615db243f7a5c433169f2fc704420Anton Korobeynikov  const llvm::fltSemantics &getHalfFormat() const { return *HalfFormat; }
245aa4a99b4a62615db243f7a5c433169f2fc704420Anton Korobeynikov
2469e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getFloatWidth/Align/Format - Return the size/align/format of 'float'.
24761538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned getFloatWidth() const { return FloatWidth; }
24861538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned getFloatAlign() const { return FloatAlign; }
249b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner  const llvm::fltSemantics &getFloatFormat() const { return *FloatFormat; }
2509e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner
2519e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
252c8b1227fa8c17d9881815e40c04e19334be536f8Nate Begeman  unsigned getDoubleWidth() const { return DoubleWidth; }
253c8b1227fa8c17d9881815e40c04e19334be536f8Nate Begeman  unsigned getDoubleAlign() const { return DoubleAlign; }
254b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner  const llvm::fltSemantics &getDoubleFormat() const { return *DoubleFormat; }
2559e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner
2569e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long
2579e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// double'.
25861538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned getLongDoubleWidth() const { return LongDoubleWidth; }
25961538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned getLongDoubleAlign() const { return LongDoubleAlign; }
260b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner  const llvm::fltSemantics &getLongDoubleFormat() const {
261b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner    return *LongDoubleFormat;
262cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  }
2631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
264b406669fea7c8db83a377f368f1689c848296974Benjamin Kramer  /// getFloatEvalMethod - Return the value for the C99 FLT_EVAL_METHOD macro.
265b406669fea7c8db83a377f368f1689c848296974Benjamin Kramer  virtual unsigned getFloatEvalMethod() const { return 0; }
266b406669fea7c8db83a377f368f1689c848296974Benjamin Kramer
2676deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola  // getLargeArrayMinWidth/Align - Return the minimum array size that is
2686deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola  // 'large' and its alignment.
2696deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola  unsigned getLargeArrayMinWidth() const { return LargeArrayMinWidth; }
2706deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola  unsigned getLargeArrayAlign() const { return LargeArrayAlign; }
2716deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola
2722be460723940f8184ec36529b6f6ddf59c04e411Eli Friedman  /// getMaxAtomicPromoteWidth - Return the maximum width lock-free atomic
2732be460723940f8184ec36529b6f6ddf59c04e411Eli Friedman  /// operation which will ever be supported for the given target
2742be460723940f8184ec36529b6f6ddf59c04e411Eli Friedman  unsigned getMaxAtomicPromoteWidth() const { return MaxAtomicPromoteWidth; }
2752be460723940f8184ec36529b6f6ddf59c04e411Eli Friedman  /// getMaxAtomicInlineWidth - Return the maximum width lock-free atomic
2762be460723940f8184ec36529b6f6ddf59c04e411Eli Friedman  /// operation which can be inlined given the supported features of the
2772be460723940f8184ec36529b6f6ddf59c04e411Eli Friedman  /// given target.
2782be460723940f8184ec36529b6f6ddf59c04e411Eli Friedman  unsigned getMaxAtomicInlineWidth() const { return MaxAtomicInlineWidth; }
2792be460723940f8184ec36529b6f6ddf59c04e411Eli Friedman
2805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this
2811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// target, in bits.
2820eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  unsigned getIntMaxTWidth() const {
2839184646509d015ea66e796113a8c68598681374bChris Lattner    return getTypeWidth(IntMaxType);
2845f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
2851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
28608737c49bd98f73b50fe90fd19f97c41cd29e3d1Daniel Dunbar  /// getRegisterWidth - Return the "preferred" register width on this target.
28708737c49bd98f73b50fe90fd19f97c41cd29e3d1Daniel Dunbar  uint64_t getRegisterWidth() const {
28808737c49bd98f73b50fe90fd19f97c41cd29e3d1Daniel Dunbar    // Currently we assume the register width on the target matches the pointer
28908737c49bd98f73b50fe90fd19f97c41cd29e3d1Daniel Dunbar    // width, we can introduce a new variable for this if/when some target wants
29008737c49bd98f73b50fe90fd19f97c41cd29e3d1Daniel Dunbar    // it.
29108737c49bd98f73b50fe90fd19f97c41cd29e3d1Daniel Dunbar    return LongWidth;
29208737c49bd98f73b50fe90fd19f97c41cd29e3d1Daniel Dunbar  }
29308737c49bd98f73b50fe90fd19f97c41cd29e3d1Daniel Dunbar
2943fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  /// getUserLabelPrefix - This returns the default value of the
2953fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  /// __USER_LABEL_PREFIX__ macro, which is the prefix given to user symbols by
2963fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  /// default.  On most platforms this is "_", but it is "" on some, and "." on
2973fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  /// others.
2983fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  const char *getUserLabelPrefix() const {
2993fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner    return UserLabelPrefix;
3003fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  }
3011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
302be4c8705e499b55548467eb7adaa23cbc6edfef9Roman Divacky  /// MCountName - This returns name of the mcount instrumentation function.
303be4c8705e499b55548467eb7adaa23cbc6edfef9Roman Divacky  const char *getMCountName() const {
304be4c8705e499b55548467eb7adaa23cbc6edfef9Roman Divacky    return MCountName;
305be4c8705e499b55548467eb7adaa23cbc6edfef9Roman Divacky  }
306be4c8705e499b55548467eb7adaa23cbc6edfef9Roman Divacky
30793a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian  /// useSignedCharForObjCBool - Check if the Objective-C built-in boolean
30893a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian  /// type should be signed char.  Otherwise, if this returns false, the
30993a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian  /// normal built-in boolean type should also be used for Objective-C.
31093a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian  bool useSignedCharForObjCBool() const {
31193a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian    return UseSignedCharForObjCBool;
31293a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian  }
31393a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian  void noSignedCharForObjCBool() {
31493a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian    UseSignedCharForObjCBool = false;
31593a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian  }
31693a49944e0e68e32bc22d45d44ee136b34beffb3Fariborz Jahanian
31770529099e60c0bb53fdf0f31b387f487807b3d99Chad Rosier  /// useBitFieldTypeAlignment() - Check whether the alignment of bit-field
31870529099e60c0bb53fdf0f31b387f487807b3d99Chad Rosier  /// types is respected when laying out structures.
319b6830d616a068971f13e1e213e06a945c8c93ceaDaniel Dunbar  bool useBitFieldTypeAlignment() const {
320b6830d616a068971f13e1e213e06a945c8c93ceaDaniel Dunbar    return UseBitFieldTypeAlignment;
321b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  }
322b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar
32361a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  /// useZeroLengthBitfieldAlignment() - Check whether zero length bitfields
32461a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  /// should force alignment of the next member.
32561a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  bool useZeroLengthBitfieldAlignment() const {
32661a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier    return UseZeroLengthBitfieldAlignment;
32761a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  }
32861a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier
3296e43f3f0e2fa7a4b50d2497de94a40437cd26003Chad Rosier  /// getZeroLengthBitfieldBoundary() - Get the fixed alignment value in bits
3306e43f3f0e2fa7a4b50d2497de94a40437cd26003Chad Rosier  /// for a member that follows a zero length bitfield.
33161a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  unsigned getZeroLengthBitfieldBoundary() const {
33261a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier    return ZeroLengthBitfieldBoundary;
33361a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier  }
33461a62216a0bb33fb668ab653d9f9a704e43d2fc6Chad Rosier
335613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  /// hasAlignMac68kSupport - Check whether this target support '#pragma options
336613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  /// align=mac68k'.
337613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  bool hasAlignMac68kSupport() const {
338613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar    return HasAlignMac68kSupport;
339613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  }
340613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar
3412b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner  /// getTypeName - Return the user string for the specified integer type enum.
3422b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner  /// For example, SignedShort -> "short".
3432b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner  static const char *getTypeName(IntType T);
3441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
345b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  /// getTypeConstantSuffix - Return the constant suffix for the specified
346b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  /// integer type enum. For example, SignedLong -> "L".
347b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  static const char *getTypeConstantSuffix(IntType T);
348b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
349dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  /// \brief Check whether the given real type should use the "fpret" flavor of
350dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  /// Obj-C message passing on this target.
351dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  bool useObjCFPRetForRealType(RealType T) const {
352dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar    return RealTypeUsesObjCFPRet & (1 << T);
353dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  }
354dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar
355eea64802558cc398571938b1f28cda1d4fa79ec3Anders Carlsson  /// \brief Check whether _Complex long double should use the "fp2ret" flavor
356eea64802558cc398571938b1f28cda1d4fa79ec3Anders Carlsson  /// of Obj-C message passing on this target.
357eea64802558cc398571938b1f28cda1d4fa79ec3Anders Carlsson  bool useObjCFP2RetForComplexLongDouble() const {
358eea64802558cc398571938b1f28cda1d4fa79ec3Anders Carlsson    return ComplexLongDoubleUsesFP2Ret;
359eea64802558cc398571938b1f28cda1d4fa79ec3Anders Carlsson  }
360eea64802558cc398571938b1f28cda1d4fa79ec3Anders Carlsson
3619c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner  ///===---- Other target property query methods --------------------------===//
3621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3639c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner  /// getTargetDefines - Appends the target-specific #define values for this
3649c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner  /// target set to the specified buffer.
36533328642a7a8a126918814ddcbcebf83c121ad54Chris Lattner  virtual void getTargetDefines(const LangOptions &Opts,
366a99927774d07af9c6f0e1945531eadc910592945Benjamin Kramer                                MacroBuilder &Builder) const = 0;
3671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
368b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
3695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// getTargetBuiltins - Return information about target-specific builtins for
3705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// the current primary target, and info about which builtins are non-portable
3715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// across the current set of primary and secondary targets.
3721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual void getTargetBuiltins(const Builtin::Info *&Records,
3730eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner                                 unsigned &NumRecords) const = 0;
3745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
3758b30a9379f730875ba8fb2d0fe2d43611e0c20ffBob Wilson  /// isCLZForZeroUndef - The __builtin_clz* and __builtin_ctz* built-in
3768b30a9379f730875ba8fb2d0fe2d43611e0c20ffBob Wilson  /// functions are specified to have undefined results for zero inputs, but
3778b30a9379f730875ba8fb2d0fe2d43611e0c20ffBob Wilson  /// on targets that support these operations in a way that provides
3788b30a9379f730875ba8fb2d0fe2d43611e0c20ffBob Wilson  /// well-defined results for zero without loss of performance, it is a good
3798b30a9379f730875ba8fb2d0fe2d43611e0c20ffBob Wilson  /// idea to avoid optimizing based on that undef behavior.
3808b30a9379f730875ba8fb2d0fe2d43611e0c20ffBob Wilson  virtual bool isCLZForZeroUndef() const { return true; }
3818b30a9379f730875ba8fb2d0fe2d43611e0c20ffBob Wilson
382d19144b244f86227fcc2b0da794929fe83968dd5Chris Lattner  /// getVAListDeclaration - Return the declaration to use for
383d19144b244f86227fcc2b0da794929fe83968dd5Chris Lattner  /// __builtin_va_list, which is target-specific.
3840eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  virtual const char *getVAListDeclaration() const = 0;
385fb5e5ba3c7708f3aef4db0ed30e8470b3ed4206aAnders Carlsson
386de31fd7eeebdc64fb043463e7f515dab8eccac8dEric Christopher  /// isValidClobber - Returns whether the passed in string is
387de31fd7eeebdc64fb043463e7f515dab8eccac8dEric Christopher  /// a valid clobber in an inline asm statement. This is used by
388de31fd7eeebdc64fb043463e7f515dab8eccac8dEric Christopher  /// Sema.
389686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  bool isValidClobber(StringRef Name) const;
390de31fd7eeebdc64fb043463e7f515dab8eccac8dEric Christopher
3913346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  /// isValidGCCRegisterName - Returns whether the passed in string
3923346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  /// is a valid register name according to GCC. This is used by Sema for
3933346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  /// inline asm statements.
394686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  bool isValidGCCRegisterName(StringRef Name) const;
395d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson
396d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // getNormalizedGCCRegisterName - Returns the "normalized" GCC register name.
397d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // For example, on x86 it will return "ax" when "eax" is passed in.
398686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  StringRef getNormalizedGCCRegisterName(StringRef Name) const;
3991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
40044def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner  struct ConstraintInfo {
40144def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    enum {
40244def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      CI_None = 0x00,
40344def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      CI_AllowsMemory = 0x01,
40444def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      CI_AllowsRegister = 0x02,
405fa780fc4a4983003633c9b560387266101839923Chris Lattner      CI_ReadWrite = 0x04,       // "+r" output constraint (read and write).
406fa780fc4a4983003633c9b560387266101839923Chris Lattner      CI_HasMatchingInput = 0x08 // This output operand has a matching input.
40744def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    };
40844def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    unsigned Flags;
40944def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    int TiedOperand;
4101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4112819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner    std::string ConstraintStr;  // constraint: "=rm"
4122819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner    std::string Name;           // Operand name: [foo] with no []'s.
413432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner  public:
414686775deca8b8685eb90801495880e3abdd844c2Chris Lattner    ConstraintInfo(StringRef ConstraintStr, StringRef Name)
415237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer      : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
416f959fb5fb82ae2cbdf8635d734613a01818fb7bfAnders Carlsson      Name(Name.str()) {}
417432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner
418432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner    const std::string &getConstraintStr() const { return ConstraintStr; }
4192819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner    const std::string &getName() const { return Name; }
42044def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; }
42144def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; }
42244def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; }
4231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
424fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// hasMatchingInput - Return true if this output operand has a matching
425fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// (tied) input operand.
426fa780fc4a4983003633c9b560387266101839923Chris Lattner    bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; }
4271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
428fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// hasTiedOperand() - Return true if this input operand is a matching
429fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// constraint that ties it to an output operand.  If this returns true,
430fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// then getTiedOperand will indicate which output operand this is tied to.
43144def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    bool hasTiedOperand() const { return TiedOperand != -1; }
43244def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    unsigned getTiedOperand() const {
43344def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      assert(hasTiedOperand() && "Has no tied operand!");
43444def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      return (unsigned)TiedOperand;
43544def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    }
4361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
43744def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    void setIsReadWrite() { Flags |= CI_ReadWrite; }
43844def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    void setAllowsMemory() { Flags |= CI_AllowsMemory; }
43944def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    void setAllowsRegister() { Flags |= CI_AllowsRegister; }
440fa780fc4a4983003633c9b560387266101839923Chris Lattner    void setHasMatchingInput() { Flags |= CI_HasMatchingInput; }
4411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
442d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    /// setTiedOperand - Indicate that this is an input operand that is tied to
443d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    /// the specified output operand.  Copy over the various constraint
444d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    /// information from the output.
445d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    void setTiedOperand(unsigned N, ConstraintInfo &Output) {
446fa780fc4a4983003633c9b560387266101839923Chris Lattner      Output.setHasMatchingInput();
447d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner      Flags = Output.Flags;
448d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner      TiedOperand = N;
449d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner      // Don't copy Name or constraint string.
450d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    }
451d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  };
452d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson
453d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // validateOutputConstraint, validateInputConstraint - Checks that
454d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // a constraint is valid and provides information about it.
455d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // FIXME: These should return a real error instead of just true/false.
456432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner  bool validateOutputConstraint(ConstraintInfo &Info) const;
4572819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner  bool validateInputConstraint(ConstraintInfo *OutputConstraints,
4582819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner                               unsigned NumOutputs,
45945b050e72d058131e6f169fe54888bb91a003fb5Anders Carlsson                               ConstraintInfo &info) const;
46042e1ee0702d8267d632df0fdb5c479a582877c6fAnders Carlsson  bool resolveSymbolicName(const char *&Name,
4612819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner                           ConstraintInfo *OutputConstraints,
4622819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner                           unsigned NumOutputs, unsigned &Index) const;
4631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4646ce33d67e2ed4f8c9395a807bebd25be04580c0fStuart Hastings  // Constraint parm will be left pointing at the last character of
4656ce33d67e2ed4f8c9395a807bebd25be04580c0fStuart Hastings  // the constraint.  In practice, it won't be changed unless the
4666ce33d67e2ed4f8c9395a807bebd25be04580c0fStuart Hastings  // constraint is longer than one character.
467002333f8b2cf1a8614e532f6ce366b21af85142cStuart Hastings  virtual std::string convertConstraint(const char *&Constraint) const {
468cee55018570c0c46262c6e4ef7beaa707c93fc86Dale Johannesen    // 'p' defaults to 'r', but can be overridden by targets.
469002333f8b2cf1a8614e532f6ce366b21af85142cStuart Hastings    if (*Constraint == 'p')
470cee55018570c0c46262c6e4ef7beaa707c93fc86Dale Johannesen      return std::string("r");
471002333f8b2cf1a8614e532f6ce366b21af85142cStuart Hastings    return std::string(1, *Constraint);
4720eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  }
4731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
474d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // Returns a string of target-specific clobbers, in LLVM format.
4750eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  virtual const char *getClobbers() const = 0;
4761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4777a4718e813e5e99d478567a482217c7eef8572c5Devang Patel
4781752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar  /// getTriple - Return the target triple of the primary target.
4791752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar  const llvm::Triple &getTriple() const {
4801752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar    return Triple;
4810eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  }
4821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
483ae3607684c5978dc2d877141015056c9d24f17eaTed Kremenek  const char *getTargetDescription() const {
484364af81157a81cf34bb058a7d5b0185020e5164bSanjiv Gupta    return DescriptionString;
4857a4718e813e5e99d478567a482217c7eef8572c5Devang Patel  }
4863346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson
4873346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  struct GCCRegAlias {
4883346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson    const char * const Aliases[5];
4893346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson    const char * const Register;
4903346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  };
4912621fd1d6d3c5eadcae246859f62738645df7540Chris Lattner
492cfd323d0d4476dd4ff64097c91b114067ecaa82bEric Christopher  struct AddlRegName {
493cfd323d0d4476dd4ff64097c91b114067ecaa82bEric Christopher    const char * const Names[5];
494cfd323d0d4476dd4ff64097c91b114067ecaa82bEric Christopher    const unsigned RegNum;
495cfd323d0d4476dd4ff64097c91b114067ecaa82bEric Christopher  };
496cfd323d0d4476dd4ff64097c91b114067ecaa82bEric Christopher
4974188760f6bb20f91c6883dffd89204419f852deeJohn McCall  /// hasProtectedVisibility - Does this target support "protected"
4984188760f6bb20f91c6883dffd89204419f852deeJohn McCall  /// visibility?
4994188760f6bb20f91c6883dffd89204419f852deeJohn McCall  ///
5004188760f6bb20f91c6883dffd89204419f852deeJohn McCall  /// Any target which dynamic libraries will naturally support
5014188760f6bb20f91c6883dffd89204419f852deeJohn McCall  /// something like "default" (meaning that the symbol is visible
5024188760f6bb20f91c6883dffd89204419f852deeJohn McCall  /// outside this shared object) and "hidden" (meaning that it isn't)
5034188760f6bb20f91c6883dffd89204419f852deeJohn McCall  /// visibilities, but "protected" is really an ELF-specific concept
5044188760f6bb20f91c6883dffd89204419f852deeJohn McCall  /// with wierd semantics designed around the convenience of dynamic
5054188760f6bb20f91c6883dffd89204419f852deeJohn McCall  /// linker implementations.  Which is not to suggest that there's
5064188760f6bb20f91c6883dffd89204419f852deeJohn McCall  /// consistent target-independent semantics for "default" visibility
5074188760f6bb20f91c6883dffd89204419f852deeJohn McCall  /// either; the entire thing is pretty badly mangled.
5084188760f6bb20f91c6883dffd89204419f852deeJohn McCall  virtual bool hasProtectedVisibility() const { return true; }
5094188760f6bb20f91c6883dffd89204419f852deeJohn McCall
510dcb4a1a6dd55fdf6c073d2761096f42e26be105aDaniel Dunbar  virtual bool useGlobalsForAutomaticVariables() const { return false; }
511dcb4a1a6dd55fdf6c073d2761096f42e26be105aDaniel Dunbar
5126d7d8398e71a8bd121d3b46e250f1dbcfb9679d4Daniel Dunbar  /// getCFStringSection - Return the section to use for CFString
5138e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar  /// literals, or 0 if no special section is used.
5141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual const char *getCFStringSection() const {
5158e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar    return "__DATA,__cfstring";
5168e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar  }
5178e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar
5182bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian  /// getNSStringSection - Return the section to use for NSString
5192bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian  /// literals, or 0 if no special section is used.
5202bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian  virtual const char *getNSStringSection() const {
5212bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian    return "__OBJC,__cstring_object,regular,no_dead_strip";
5222bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian  }
5232bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian
524237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer  /// getNSStringNonFragileABISection - Return the section to use for
525ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian  /// NSString literals, or 0 if no special section is used (NonFragile ABI).
526ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian  virtual const char *getNSStringNonFragileABISection() const {
527ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian    return "__DATA, __objc_stringobj, regular, no_dead_strip";
528ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian  }
529ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian
530797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// isValidSectionSpecifier - This is an optional hook that targets can
531797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// implement to perform semantic checking on attribute((section("foo")))
532797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// specifiers.  In this case, "foo" is passed in to be checked.  If the
533797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// section specifier is invalid, the backend should return a non-empty string
534797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// that indicates the problem.
535797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  ///
536797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// This hook is a simple quality of implementation feature to catch errors
537797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// and give good diagnostics in cases when the assembler or code generator
538797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// would otherwise reject the section specifier.
539797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  ///
540686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  virtual std::string isValidSectionSpecifier(StringRef SR) const {
541797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner    return "";
542797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  }
5438e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar
544a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson  /// setForcedLangOptions - Set forced language options.
545a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson  /// Apply changes to the target information with respect to certain
546a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson  /// language options which change the target configuration.
547a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson  virtual void setForcedLangOptions(LangOptions &Opts);
548a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson
549c3a2e654f1e1c5cf956d0666d9c4c2f60a66f112Chandler Carruth  /// getDefaultFeatures - Get the default set of target features for the CPU;
550c3a2e654f1e1c5cf956d0666d9c4c2f60a66f112Chandler Carruth  /// this should include all legal feature strings on the target.
551c3a2e654f1e1c5cf956d0666d9c4c2f60a66f112Chandler Carruth  virtual void getDefaultFeatures(llvm::StringMap<bool> &Features) const {
55217ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  }
55317ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar
554018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar  /// getABI - Get the ABI in use.
555018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar  virtual const char *getABI() const {
556018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar    return "";
557018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar  }
558018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar
55998b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis  /// getCXXABI - Get the C++ ABI in use.
56020cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis  virtual TargetCXXABI getCXXABI() const {
56198b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis    return CXXABI;
56298b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis  }
56398b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis
564eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  /// setCPU - Target the specific CPU.
565eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  ///
566eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  /// \return - False on error (invalid CPU name).
567eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  virtual bool setCPU(const std::string &Name) {
568c3a2e654f1e1c5cf956d0666d9c4c2f60a66f112Chandler Carruth    return false;
569eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  }
570eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar
57173b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  /// setABI - Use the specific ABI.
57273b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  ///
57373b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  /// \return - False on error (invalid ABI name).
57473b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  virtual bool setABI(const std::string &Name) {
57573b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar    return false;
57673b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  }
57773b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar
57898b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis  /// setCXXABI - Use this specific C++ ABI.
57998b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis  ///
58020cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis  /// \return - False on error (invalid C++ ABI name).
581ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  bool setCXXABI(const std::string &Name) {
582ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall    static const TargetCXXABI Unknown = static_cast<TargetCXXABI>(-1);
583ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall    TargetCXXABI ABI = llvm::StringSwitch<TargetCXXABI>(Name)
584ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall      .Case("arm", CXXABI_ARM)
58520cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis      .Case("itanium", CXXABI_Itanium)
58620cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis      .Case("microsoft", CXXABI_Microsoft)
587ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall      .Default(Unknown);
588ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall    if (ABI == Unknown) return false;
589ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall    return setCXXABI(ABI);
590ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  }
591ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall
592ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  /// setCXXABI - Set the C++ ABI to be used by this implementation.
593ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  ///
594ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  /// \return - False on error (ABI not valid on this target)
595ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  virtual bool setCXXABI(TargetCXXABI ABI) {
596ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall    CXXABI = ABI;
59798b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis    return true;
59898b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis  }
59998b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis
60017ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  /// setFeatureEnabled - Enable or disable a specific target feature,
60117ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  /// the feature name must be valid.
60217ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  ///
60317ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  /// \return - False on error (invalid feature name).
60417ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
605713575afdac1f31de39b4a730143b8d96eeadb6dBenjamin Kramer                                 StringRef Name,
60617ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar                                 bool Enabled) const {
60717ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar    return false;
608868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar  }
609868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar
61029a790ba422cfeeea9546b6e76777d98fa73cd67Daniel Dunbar  /// HandleTargetOptions - Perform initialization based on the user configured
61129a790ba422cfeeea9546b6e76777d98fa73cd67Daniel Dunbar  /// set of features (e.g., +sse4). The list is guaranteed to have at most one
61229a790ba422cfeeea9546b6e76777d98fa73cd67Daniel Dunbar  /// entry per feature.
613b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  ///
614b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// The target may modify the features list, to change which options are
615b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// passed onwards to the backend.
616b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
61716167a6e3f7dfb7ed0babc5e0baab9fd140e959dChris Lattner  }
618264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov
619e727d21d3fd5f6f68d9e7a260bbf84dc2fc8ae3aDouglas Gregor  /// \brief Determine whether the given target has the given feature.
620e727d21d3fd5f6f68d9e7a260bbf84dc2fc8ae3aDouglas Gregor  virtual bool hasFeature(StringRef Feature) const {
621e727d21d3fd5f6f68d9e7a260bbf84dc2fc8ae3aDouglas Gregor    return false;
622e727d21d3fd5f6f68d9e7a260bbf84dc2fc8ae3aDouglas Gregor  }
623e727d21d3fd5f6f68d9e7a260bbf84dc2fc8ae3aDouglas Gregor
624264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov  // getRegParmMax - Returns maximal number of args passed in registers.
625264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov  unsigned getRegParmMax() const {
6267e47e1e7e6a2b83d903c97129f27e92f584c3dc2Douglas Gregor    assert(RegParmMax < 7 && "RegParmMax value is larger than AST can handle");
627264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov    return RegParmMax;
628264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov  }
629264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov
63021fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  /// isTLSSupported - Whether the target supports thread-local storage.
6316a3bc6df36848188e9d0c1d978170c2b0918c6a3Chris Lattner  bool isTLSSupported() const {
632b030f0272500c6c5602f587ac029ee0dc0e5a05cEli Friedman    return TLSSupported;
633b030f0272500c6c5602f587ac029ee0dc0e5a05cEli Friedman  }
634237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer
6359bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  /// hasNoAsmVariants - Return true if {|} are normal characters in the
6369bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  /// asm string.  If this returns false (the default), then {abc|xyz} is syntax
63737de281ac149a5c5f14e4935a3738d87370da3edChris Lattner  /// that says that when compiling for asm variant #0, "abc" should be
6389bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  /// generated, but when compiling for asm variant #1, "xyz" should be
6399bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  /// generated.
6409bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  bool hasNoAsmVariants() const {
6419bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner    return NoAsmVariants;
6429bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  }
643237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer
64421fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  /// getEHDataRegisterNumber - Return the register number that
64521fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  /// __builtin_eh_return_regno would return with the specified argument.
64621fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  virtual int getEHDataRegisterNumber(unsigned RegNo) const {
647237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer    return -1;
64821fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  }
649237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer
650237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer  /// getStaticInitSectionSpecifier - Return the section to use for C++ static
65118af368c080b9d60e34e670cd01f7d2d3ad2ba48Anders Carlsson  /// initialization functions.
65218af368c080b9d60e34e670cd01f7d2d3ad2ba48Anders Carlsson  virtual const char *getStaticInitSectionSpecifier() const {
65318af368c080b9d60e34e670cd01f7d2d3ad2ba48Anders Carlsson    return 0;
65418af368c080b9d60e34e670cd01f7d2d3ad2ba48Anders Carlsson  }
655207f4d8543529221932af82836016a2ef066c917Peter Collingbourne
656207f4d8543529221932af82836016a2ef066c917Peter Collingbourne  const LangAS::Map &getAddressSpaceMap() const {
657207f4d8543529221932af82836016a2ef066c917Peter Collingbourne    return *AddrSpaceMap;
658207f4d8543529221932af82836016a2ef066c917Peter Collingbourne  }
659207f4d8543529221932af82836016a2ef066c917Peter Collingbourne
6600a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor  /// \brief Retrieve the name of the platform as it is used in the
6610a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor  /// availability attribute.
662686775deca8b8685eb90801495880e3abdd844c2Chris Lattner  StringRef getPlatformName() const { return PlatformName; }
6630a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor
6640a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor  /// \brief Retrieve the minimum desired version of the platform, to
6650a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor  /// which the program should be compiled.
6660a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor  VersionTuple getPlatformMinVersion() const { return PlatformMinVersion; }
6670a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor
668e6a24e83e71f361c7b7de82cf24ee6f5ddc7f1c2Eli Friedman  bool isBigEndian() const { return BigEndian; }
669e6a24e83e71f361c7b7de82cf24ee6f5ddc7f1c2Eli Friedman
6700eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattnerprotected:
6710e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner  virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
6720e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner    return PointerWidth;
6730e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner  }
6740e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner  virtual uint64_t getPointerAlignV(unsigned AddrSpace) const {
6750e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner    return PointerAlign;
6760e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner  }
67731fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta  virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const {
67831fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    return PtrDiffType;
67931fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta  }
6801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual void getGCCRegNames(const char * const *&Names,
6810eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner                              unsigned &NumNames) const = 0;
6821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
6833346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson                                unsigned &NumAliases) const = 0;
684cfd323d0d4476dd4ff64097c91b114067ecaa82bEric Christopher  virtual void getGCCAddlRegNames(const AddlRegName *&Addl,
685cfd323d0d4476dd4ff64097c91b114067ecaa82bEric Christopher				  unsigned &NumAddl) const {
686cfd323d0d4476dd4ff64097c91b114067ecaa82bEric Christopher    Addl = 0;
687cfd323d0d4476dd4ff64097c91b114067ecaa82bEric Christopher    NumAddl = 0;
688cfd323d0d4476dd4ff64097c91b114067ecaa82bEric Christopher  }
6891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual bool validateAsmConstraint(const char *&Name,
690d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson                                     TargetInfo::ConstraintInfo &info) const= 0;
6915f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
6925f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
6935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
6945f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
6955f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
696