TargetInfo.h revision 237cf582b89bbcc22640cea15426ddc7ada8412b
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
17868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar// FIXME: Daniel isn't smart enough to use a prototype for this.
18868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar#include "llvm/ADT/StringMap.h"
1920cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis#include "llvm/ADT/StringSwitch.h"
201752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar#include "llvm/ADT/Triple.h"
219f8eb2032030482b1d3de86e9bee725d93564302Chandler Carruth#include "llvm/System/DataTypes.h"
225414fbac5f1749c0e85a8c4eeb5dfece59c3e30aTorok Edwin#include <cassert>
235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include <vector>
245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include <string>
255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
26797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnernamespace llvm {
27797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnerstruct fltSemantics;
28797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnerclass StringRef;
29797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner}
30525a05093a4816af961fe2bc6b8a81c17e2e26c2Chris Lattner
315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass Diagnostic;
33d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbarclass LangOptions;
34103b71c37a3c3a3da7128c1d0232a89b1e8d0d90Chandler Carruthclass MacroBuilder;
35797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnerclass SourceLocation;
367a9d49fd2bfac00e905b361ba76d26ab5b6c3b09Ted Kremenekclass SourceManager;
37d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbarclass TargetOptions;
38d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar
395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace Builtin { struct Info; }
401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4120cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis/// TargetCXXABI - The types of C++ ABIs for which we can generate code.
4220cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davisenum TargetCXXABI {
43ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  /// The generic ("Itanium") C++ ABI, documented at:
44ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  ///   http://www.codesourcery.com/public/cxx-abi/
4520cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis  CXXABI_Itanium,
46ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall
47ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  /// The ARM C++ ABI, based largely on the Itanium ABI but with
48ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  /// significant differences.
49ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  ///    http://infocenter.arm.com
50ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  ///                    /help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf
51ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  CXXABI_ARM,
52ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall
53ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  /// The Visual Studio ABI.  Only scattered official documentation exists.
5420cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis  CXXABI_Microsoft
5520cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis};
5620cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis
5742e6737f2efb113563140ad794c21c7709250402Chris Lattner/// TargetInfo - This class exposes information about the current target.
585f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer///
595f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass TargetInfo {
601752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar  llvm::Triple Triple;
610eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattnerprotected:
62cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  // Target values set by the ctor of the actual target implementation.  Default
63cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  // values are specified by the TargetInfo constructor.
64b030f0272500c6c5602f587ac029ee0dc0e5a05cEli Friedman  bool TLSSupported;
659bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  bool NoAsmVariants;  // True if {|} are normal characters.
66927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char PointerWidth, PointerAlign;
67927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char IntWidth, IntAlign;
6861538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned char FloatWidth, FloatAlign;
69927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char DoubleWidth, DoubleAlign;
7061538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned char LongDoubleWidth, LongDoubleAlign;
716deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola  unsigned char LargeArrayMinWidth, LargeArrayAlign;
72927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char LongWidth, LongAlign;
73927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char LongLongWidth, LongLongAlign;
7477e8b53fe3ff630d8d1454db94e38bedda14d5caDaniel Dunbar  const char *DescriptionString;
753fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  const char *UserLabelPrefix;
76cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat;
77264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov  unsigned char RegParmMax, SSERegParmMax;
7820cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis  TargetCXXABI CXXABI;
79bbced580c92afa09cd4423a9bdc90ff61cb1e79aTed Kremenek
80613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  unsigned HasAlignMac68kSupport : 1;
81dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  unsigned RealTypeUsesObjCFPRet : 3;
82613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar
83cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  // TargetInfo Constructor.  Default initializes all fields.
84cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  TargetInfo(const std::string &T);
851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumppublic:
87d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar  /// CreateTargetInfo - Construct a target for the given options.
88b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  ///
89b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// \param Opts - The options to use to initialize the target. The target may
90b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// modify the options to canonicalize the target feature information to match
91b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// what the backend expects.
92b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  static TargetInfo* CreateTargetInfo(Diagnostic &Diags, TargetOptions &Opts);
93bbced580c92afa09cd4423a9bdc90ff61cb1e79aTed Kremenek
940eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  virtual ~TargetInfo();
95fb79f7cc00f9c1e04f11ed636eefb36d246b0fb8Ted Kremenek
969c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner  ///===---- Target Data Type Query Methods -------------------------------===//
9731fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta  enum IntType {
982b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner    NoInt = 0,
9931fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    SignedShort,
10031fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    UnsignedShort,
10131fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    SignedInt,
10231fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    UnsignedInt,
10331fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    SignedLong,
10431fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    UnsignedLong,
10531fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    SignedLongLong,
10631fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    UnsignedLongLong
1073fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  };
108dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar
109dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  enum RealType {
110dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar    Float = 0,
111dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar    Double,
112dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar    LongDouble
113dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  };
114dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar
1153fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattnerprotected:
1163c7b6e46c5f9bdbe0676c52d80df98b68b02be99Eli Friedman  IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType,
1179cf910efc4fb7001a6d276ed2eabf01f0f0efaaaEdward O'Callaghan          WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType;
118b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar
119b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// Control whether the alignment of bit-field types is respected when laying
120b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// out structures. If true, then the alignment of the bit-field type will be
121b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// used to (a) impact the alignment of the containing structure, and (b)
122b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// ensure that the individual bit-field will not straddle an alignment
123b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// boundary.
124b6830d616a068971f13e1e213e06a945c8c93ceaDaniel Dunbar  unsigned UseBitFieldTypeAlignment : 1;
125b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar
1263fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattnerpublic:
1273fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getSizeType() const { return SizeType; }
1283fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getIntMaxType() const { return IntMaxType; }
1293fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getUIntMaxType() const { return UIntMaxType; }
1303fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getPtrDiffType(unsigned AddrSpace) const {
13131fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
13231fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta  }
1336ad474f82f0cf32e13128d89fa5ad3a37ae73530Chris Lattner  IntType getIntPtrType() const { return IntPtrType; }
1343fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getWCharType() const { return WCharType; }
135e64ef80363c84f4f431e26b61db554c89beeddb6Chris Lattner  IntType getWIntType() const { return WIntType; }
136f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  IntType getChar16Type() const { return Char16Type; }
137f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  IntType getChar32Type() const { return Char32Type; }
1383c7b6e46c5f9bdbe0676c52d80df98b68b02be99Eli Friedman  IntType getInt64Type() const { return Int64Type; }
1399cf910efc4fb7001a6d276ed2eabf01f0f0efaaaEdward O'Callaghan  IntType getSigAtomicType() const { return SigAtomicType; }
1405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
141b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
142237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer  /// getTypeWidth - Return the width (in bits) of the specified integer type
143b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  /// enum. For example, SignedInt -> getIntWidth().
144b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  unsigned getTypeWidth(IntType T) const;
145b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
1469099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner  /// getTypeAlign - Return the alignment (in bits) of the specified integer
1479099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner  /// type enum. For example, SignedInt -> getIntAlign().
1489099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner  unsigned getTypeAlign(IntType T) const;
1499099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner
150961f0708fb66375acf47f9e9bc1aecfb3f992aeaChris Lattner  /// isTypeSigned - Return whether an integer types is signed. Returns true if
151b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  /// the type is signed; false otherwise.
152961f0708fb66375acf47f9e9bc1aecfb3f992aeaChris Lattner  bool isTypeSigned(IntType T) const;
153b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
154f72a44330b9d9a4b2d93e9b91cfb8ab7bd4a0643Chris Lattner  /// getPointerWidth - Return the width of pointers on this target, for the
155927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  /// specified address space.
156927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  uint64_t getPointerWidth(unsigned AddrSpace) const {
157927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner    return AddrSpace == 0 ? PointerWidth : getPointerWidthV(AddrSpace);
158927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  }
159927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  uint64_t getPointerAlign(unsigned AddrSpace) const {
160927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner    return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace);
161927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  }
1621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1639e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getBoolWidth/Align - Return the size of '_Bool' and C++ 'bool' for this
1649e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// target, in bits.
1659e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  unsigned getBoolWidth(bool isWide = false) const { return 8; }  // FIXME
1669e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  unsigned getBoolAlign(bool isWide = false) const { return 8; }  // FIXME
1671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
168f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  unsigned getCharWidth() const { return 8; } // FIXME
169f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  unsigned getCharAlign() const { return 8; } // FIXME
1701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1719e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getShortWidth/Align - Return the size of 'signed short' and
1721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// 'unsigned short' for this target, in bits.
1739e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  unsigned getShortWidth() const { return 16; } // FIXME
1749e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  unsigned getShortAlign() const { return 16; } // FIXME
1751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1769e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for
1779e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// this target, in bits.
1782621fd1d6d3c5eadcae246859f62738645df7540Chris Lattner  unsigned getIntWidth() const { return IntWidth; }
1792621fd1d6d3c5eadcae246859f62738645df7540Chris Lattner  unsigned getIntAlign() const { return IntAlign; }
1801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1819e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getLongWidth/Align - Return the size of 'signed long' and 'unsigned long'
1829e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// for this target, in bits.
1838059e997ee05e4aa87f7e21fed630429a140ee53Chris Lattner  unsigned getLongWidth() const { return LongWidth; }
1848059e997ee05e4aa87f7e21fed630429a140ee53Chris Lattner  unsigned getLongAlign() const { return LongAlign; }
1851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1869e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getLongLongWidth/Align - Return the size of 'signed long long' and
1879e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// 'unsigned long long' for this target, in bits.
188ec10f5886526124ba733fbd0ef8665d576285daaChris Lattner  unsigned getLongLongWidth() const { return LongLongWidth; }
189ec10f5886526124ba733fbd0ef8665d576285daaChris Lattner  unsigned getLongLongAlign() const { return LongLongAlign; }
1901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
191f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// getWCharWidth/Align - Return the size of 'wchar_t' for this target, in
1929e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// bits.
1939184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getWCharWidth() const { return getTypeWidth(WCharType); }
1949184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getWCharAlign() const { return getTypeAlign(WCharType); }
195f72a44330b9d9a4b2d93e9b91cfb8ab7bd4a0643Chris Lattner
196f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// getChar16Width/Align - Return the size of 'char16_t' for this target, in
197f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// bits.
1989184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getChar16Width() const { return getTypeWidth(Char16Type); }
1999184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getChar16Align() const { return getTypeAlign(Char16Type); }
200f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith
201f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// getChar32Width/Align - Return the size of 'char32_t' for this target, in
202f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// bits.
2039184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getChar32Width() const { return getTypeWidth(Char32Type); }
2049184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getChar32Align() const { return getTypeAlign(Char32Type); }
205f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith
2069e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getFloatWidth/Align/Format - Return the size/align/format of 'float'.
20761538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned getFloatWidth() const { return FloatWidth; }
20861538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned getFloatAlign() const { return FloatAlign; }
209b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner  const llvm::fltSemantics &getFloatFormat() const { return *FloatFormat; }
2109e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner
2119e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
212c8b1227fa8c17d9881815e40c04e19334be536f8Nate Begeman  unsigned getDoubleWidth() const { return DoubleWidth; }
213c8b1227fa8c17d9881815e40c04e19334be536f8Nate Begeman  unsigned getDoubleAlign() const { return DoubleAlign; }
214b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner  const llvm::fltSemantics &getDoubleFormat() const { return *DoubleFormat; }
2159e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner
2169e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long
2179e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// double'.
21861538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned getLongDoubleWidth() const { return LongDoubleWidth; }
21961538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned getLongDoubleAlign() const { return LongDoubleAlign; }
220b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner  const llvm::fltSemantics &getLongDoubleFormat() const {
221b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner    return *LongDoubleFormat;
222cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  }
2231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2246deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola  // getLargeArrayMinWidth/Align - Return the minimum array size that is
2256deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola  // 'large' and its alignment.
2266deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola  unsigned getLargeArrayMinWidth() const { return LargeArrayMinWidth; }
2276deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola  unsigned getLargeArrayAlign() const { return LargeArrayAlign; }
2286deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola
2295f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this
2301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// target, in bits.
2310eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  unsigned getIntMaxTWidth() const {
2329184646509d015ea66e796113a8c68598681374bChris Lattner    return getTypeWidth(IntMaxType);
2335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
2341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2353fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  /// getUserLabelPrefix - This returns the default value of the
2363fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  /// __USER_LABEL_PREFIX__ macro, which is the prefix given to user symbols by
2373fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  /// default.  On most platforms this is "_", but it is "" on some, and "." on
2383fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  /// others.
2393fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  const char *getUserLabelPrefix() const {
2403fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner    return UserLabelPrefix;
2413fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  }
2421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
243b6830d616a068971f13e1e213e06a945c8c93ceaDaniel Dunbar  bool useBitFieldTypeAlignment() const {
244b6830d616a068971f13e1e213e06a945c8c93ceaDaniel Dunbar    return UseBitFieldTypeAlignment;
245b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  }
246b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar
247613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  /// hasAlignMac68kSupport - Check whether this target support '#pragma options
248613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  /// align=mac68k'.
249613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  bool hasAlignMac68kSupport() const {
250613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar    return HasAlignMac68kSupport;
251613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  }
252613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar
2532b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner  /// getTypeName - Return the user string for the specified integer type enum.
2542b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner  /// For example, SignedShort -> "short".
2552b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner  static const char *getTypeName(IntType T);
2561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
257b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  /// getTypeConstantSuffix - Return the constant suffix for the specified
258b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  /// integer type enum. For example, SignedLong -> "L".
259b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  static const char *getTypeConstantSuffix(IntType T);
260b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
261dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  /// \brief Check whether the given real type should use the "fpret" flavor of
262dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  /// Obj-C message passing on this target.
263dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  bool useObjCFPRetForRealType(RealType T) const {
264dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar    return RealTypeUsesObjCFPRet & (1 << T);
265dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar  }
266dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar
2679c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner  ///===---- Other target property query methods --------------------------===//
2681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2699c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner  /// getTargetDefines - Appends the target-specific #define values for this
2709c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner  /// target set to the specified buffer.
27133328642a7a8a126918814ddcbcebf83c121ad54Chris Lattner  virtual void getTargetDefines(const LangOptions &Opts,
272a99927774d07af9c6f0e1945531eadc910592945Benjamin Kramer                                MacroBuilder &Builder) const = 0;
2731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
274b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
2755f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// getTargetBuiltins - Return information about target-specific builtins for
2765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// the current primary target, and info about which builtins are non-portable
2775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// across the current set of primary and secondary targets.
2781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual void getTargetBuiltins(const Builtin::Info *&Records,
2790eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner                                 unsigned &NumRecords) const = 0;
2805f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
281d19144b244f86227fcc2b0da794929fe83968dd5Chris Lattner  /// getVAListDeclaration - Return the declaration to use for
282d19144b244f86227fcc2b0da794929fe83968dd5Chris Lattner  /// __builtin_va_list, which is target-specific.
2830eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  virtual const char *getVAListDeclaration() const = 0;
284fb5e5ba3c7708f3aef4db0ed30e8470b3ed4206aAnders Carlsson
2853346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  /// isValidGCCRegisterName - Returns whether the passed in string
2863346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  /// is a valid register name according to GCC. This is used by Sema for
2873346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  /// inline asm statements.
28883c021c6d33aa173cf1a6e3bc61006dabb042703Anders Carlsson  bool isValidGCCRegisterName(llvm::StringRef Name) const;
289d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson
290d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // getNormalizedGCCRegisterName - Returns the "normalized" GCC register name.
291d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // For example, on x86 it will return "ax" when "eax" is passed in.
29283c021c6d33aa173cf1a6e3bc61006dabb042703Anders Carlsson  llvm::StringRef getNormalizedGCCRegisterName(llvm::StringRef Name) const;
2931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
29444def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner  struct ConstraintInfo {
29544def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    enum {
29644def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      CI_None = 0x00,
29744def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      CI_AllowsMemory = 0x01,
29844def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      CI_AllowsRegister = 0x02,
299fa780fc4a4983003633c9b560387266101839923Chris Lattner      CI_ReadWrite = 0x04,       // "+r" output constraint (read and write).
300fa780fc4a4983003633c9b560387266101839923Chris Lattner      CI_HasMatchingInput = 0x08 // This output operand has a matching input.
30144def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    };
30244def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    unsigned Flags;
30344def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    int TiedOperand;
3041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3052819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner    std::string ConstraintStr;  // constraint: "=rm"
3062819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner    std::string Name;           // Operand name: [foo] with no []'s.
307432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner  public:
308f959fb5fb82ae2cbdf8635d734613a01818fb7bfAnders Carlsson    ConstraintInfo(llvm::StringRef ConstraintStr, llvm::StringRef Name)
309237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer      : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
310f959fb5fb82ae2cbdf8635d734613a01818fb7bfAnders Carlsson      Name(Name.str()) {}
311432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner
312432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner    const std::string &getConstraintStr() const { return ConstraintStr; }
3132819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner    const std::string &getName() const { return Name; }
31444def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; }
31544def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; }
31644def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; }
3171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
318fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// hasMatchingInput - Return true if this output operand has a matching
319fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// (tied) input operand.
320fa780fc4a4983003633c9b560387266101839923Chris Lattner    bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; }
3211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
322fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// hasTiedOperand() - Return true if this input operand is a matching
323fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// constraint that ties it to an output operand.  If this returns true,
324fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// then getTiedOperand will indicate which output operand this is tied to.
32544def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    bool hasTiedOperand() const { return TiedOperand != -1; }
32644def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    unsigned getTiedOperand() const {
32744def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      assert(hasTiedOperand() && "Has no tied operand!");
32844def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      return (unsigned)TiedOperand;
32944def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    }
3301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
33144def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    void setIsReadWrite() { Flags |= CI_ReadWrite; }
33244def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    void setAllowsMemory() { Flags |= CI_AllowsMemory; }
33344def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    void setAllowsRegister() { Flags |= CI_AllowsRegister; }
334fa780fc4a4983003633c9b560387266101839923Chris Lattner    void setHasMatchingInput() { Flags |= CI_HasMatchingInput; }
3351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
336d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    /// setTiedOperand - Indicate that this is an input operand that is tied to
337d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    /// the specified output operand.  Copy over the various constraint
338d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    /// information from the output.
339d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    void setTiedOperand(unsigned N, ConstraintInfo &Output) {
340fa780fc4a4983003633c9b560387266101839923Chris Lattner      Output.setHasMatchingInput();
341d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner      Flags = Output.Flags;
342d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner      TiedOperand = N;
343d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner      // Don't copy Name or constraint string.
344d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    }
345d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  };
346d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson
347d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // validateOutputConstraint, validateInputConstraint - Checks that
348d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // a constraint is valid and provides information about it.
349d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // FIXME: These should return a real error instead of just true/false.
350432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner  bool validateOutputConstraint(ConstraintInfo &Info) const;
3512819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner  bool validateInputConstraint(ConstraintInfo *OutputConstraints,
3522819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner                               unsigned NumOutputs,
35345b050e72d058131e6f169fe54888bb91a003fb5Anders Carlsson                               ConstraintInfo &info) const;
35442e1ee0702d8267d632df0fdb5c479a582877c6fAnders Carlsson  bool resolveSymbolicName(const char *&Name,
3552819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner                           ConstraintInfo *OutputConstraints,
3562819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner                           unsigned NumOutputs, unsigned &Index) const;
3571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3580eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  virtual std::string convertConstraint(const char Constraint) const {
3590eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner    return std::string(1, Constraint);
3600eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  }
3611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
362d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // Returns a string of target-specific clobbers, in LLVM format.
3630eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  virtual const char *getClobbers() const = 0;
3641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3657a4718e813e5e99d478567a482217c7eef8572c5Devang Patel
3661752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar  /// getTriple - Return the target triple of the primary target.
3671752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar  const llvm::Triple &getTriple() const {
3681752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar    return Triple;
3690eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  }
3701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
371ae3607684c5978dc2d877141015056c9d24f17eaTed Kremenek  const char *getTargetDescription() const {
372364af81157a81cf34bb058a7d5b0185020e5164bSanjiv Gupta    return DescriptionString;
3737a4718e813e5e99d478567a482217c7eef8572c5Devang Patel  }
3743346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson
3753346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  struct GCCRegAlias {
3763346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson    const char * const Aliases[5];
3773346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson    const char * const Register;
3783346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  };
3792621fd1d6d3c5eadcae246859f62738645df7540Chris Lattner
380dcb4a1a6dd55fdf6c073d2761096f42e26be105aDaniel Dunbar  virtual bool useGlobalsForAutomaticVariables() const { return false; }
381dcb4a1a6dd55fdf6c073d2761096f42e26be105aDaniel Dunbar
3826d7d8398e71a8bd121d3b46e250f1dbcfb9679d4Daniel Dunbar  /// getCFStringSection - Return the section to use for CFString
3838e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar  /// literals, or 0 if no special section is used.
3841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual const char *getCFStringSection() const {
3858e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar    return "__DATA,__cfstring";
3868e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar  }
3878e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar
3882bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian  /// getNSStringSection - Return the section to use for NSString
3892bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian  /// literals, or 0 if no special section is used.
3902bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian  virtual const char *getNSStringSection() const {
3912bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian    return "__OBJC,__cstring_object,regular,no_dead_strip";
3922bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian  }
3932bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian
394237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer  /// getNSStringNonFragileABISection - Return the section to use for
395ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian  /// NSString literals, or 0 if no special section is used (NonFragile ABI).
396ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian  virtual const char *getNSStringNonFragileABISection() const {
397ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian    return "__DATA, __objc_stringobj, regular, no_dead_strip";
398ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian  }
399ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian
400797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// isValidSectionSpecifier - This is an optional hook that targets can
401797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// implement to perform semantic checking on attribute((section("foo")))
402797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// specifiers.  In this case, "foo" is passed in to be checked.  If the
403797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// section specifier is invalid, the backend should return a non-empty string
404797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// that indicates the problem.
405797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  ///
406797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// This hook is a simple quality of implementation feature to catch errors
407797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// and give good diagnostics in cases when the assembler or code generator
408797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// would otherwise reject the section specifier.
409797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  ///
410f959fb5fb82ae2cbdf8635d734613a01818fb7bfAnders Carlsson  virtual std::string isValidSectionSpecifier(llvm::StringRef SR) const {
411797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner    return "";
412797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  }
4138e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar
414a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson  /// setForcedLangOptions - Set forced language options.
415a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson  /// Apply changes to the target information with respect to certain
416a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson  /// language options which change the target configuration.
417a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson  virtual void setForcedLangOptions(LangOptions &Opts);
418a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson
419868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar  /// getDefaultFeatures - Get the default set of target features for
420868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar  /// the \args CPU; this should include all legal feature strings on
421868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar  /// the target.
4221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual void getDefaultFeatures(const std::string &CPU,
42317ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar                                  llvm::StringMap<bool> &Features) const {
42417ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  }
42517ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar
426018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar  /// getABI - Get the ABI in use.
427018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar  virtual const char *getABI() const {
428018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar    return "";
429018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar  }
430018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar
43198b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis  /// getCXXABI - Get the C++ ABI in use.
43220cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis  virtual TargetCXXABI getCXXABI() const {
43398b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis    return CXXABI;
43498b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis  }
43598b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis
436eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  /// setCPU - Target the specific CPU.
437eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  ///
438eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  /// \return - False on error (invalid CPU name).
439eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  //
440eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  // FIXME: Remove this.
441eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  virtual bool setCPU(const std::string &Name) {
442eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar    return true;
443eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  }
444eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar
44573b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  /// setABI - Use the specific ABI.
44673b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  ///
44773b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  /// \return - False on error (invalid ABI name).
44873b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  virtual bool setABI(const std::string &Name) {
44973b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar    return false;
45073b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  }
45173b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar
45298b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis  /// setCXXABI - Use this specific C++ ABI.
45398b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis  ///
45420cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis  /// \return - False on error (invalid C++ ABI name).
455ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  bool setCXXABI(const std::string &Name) {
456ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall    static const TargetCXXABI Unknown = static_cast<TargetCXXABI>(-1);
457ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall    TargetCXXABI ABI = llvm::StringSwitch<TargetCXXABI>(Name)
458ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall      .Case("arm", CXXABI_ARM)
45920cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis      .Case("itanium", CXXABI_Itanium)
46020cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis      .Case("microsoft", CXXABI_Microsoft)
461ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall      .Default(Unknown);
462ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall    if (ABI == Unknown) return false;
463ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall    return setCXXABI(ABI);
464ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  }
465ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall
466ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  /// setCXXABI - Set the C++ ABI to be used by this implementation.
467ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  ///
468ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  /// \return - False on error (ABI not valid on this target)
469ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall  virtual bool setCXXABI(TargetCXXABI ABI) {
470ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall    CXXABI = ABI;
47198b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis    return true;
47298b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis  }
47398b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis
47417ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  /// setFeatureEnabled - Enable or disable a specific target feature,
47517ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  /// the feature name must be valid.
47617ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  ///
47717ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  /// \return - False on error (invalid feature name).
47817ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
47917ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar                                 const std::string &Name,
48017ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar                                 bool Enabled) const {
48117ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar    return false;
482868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar  }
483868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar
48429a790ba422cfeeea9546b6e76777d98fa73cd67Daniel Dunbar  /// HandleTargetOptions - Perform initialization based on the user configured
48529a790ba422cfeeea9546b6e76777d98fa73cd67Daniel Dunbar  /// set of features (e.g., +sse4). The list is guaranteed to have at most one
48629a790ba422cfeeea9546b6e76777d98fa73cd67Daniel Dunbar  /// entry per feature.
487b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  ///
488b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// The target may modify the features list, to change which options are
489b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// passed onwards to the backend.
490b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
49116167a6e3f7dfb7ed0babc5e0baab9fd140e959dChris Lattner  }
492264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov
493264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov  // getRegParmMax - Returns maximal number of args passed in registers.
494264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov  unsigned getRegParmMax() const {
495264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov    return RegParmMax;
496264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov  }
497264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov
49821fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  /// isTLSSupported - Whether the target supports thread-local storage.
4996a3bc6df36848188e9d0c1d978170c2b0918c6a3Chris Lattner  bool isTLSSupported() const {
500b030f0272500c6c5602f587ac029ee0dc0e5a05cEli Friedman    return TLSSupported;
501b030f0272500c6c5602f587ac029ee0dc0e5a05cEli Friedman  }
502237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer
5039bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  /// hasNoAsmVariants - Return true if {|} are normal characters in the
5049bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  /// asm string.  If this returns false (the default), then {abc|xyz} is syntax
50537de281ac149a5c5f14e4935a3738d87370da3edChris Lattner  /// that says that when compiling for asm variant #0, "abc" should be
5069bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  /// generated, but when compiling for asm variant #1, "xyz" should be
5079bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  /// generated.
5089bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  bool hasNoAsmVariants() const {
5099bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner    return NoAsmVariants;
5109bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  }
511237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer
51221fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  /// getEHDataRegisterNumber - Return the register number that
51321fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  /// __builtin_eh_return_regno would return with the specified argument.
51421fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  virtual int getEHDataRegisterNumber(unsigned RegNo) const {
515237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer    return -1;
51621fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  }
517237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer
518237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer  /// getStaticInitSectionSpecifier - Return the section to use for C++ static
51918af368c080b9d60e34e670cd01f7d2d3ad2ba48Anders Carlsson  /// initialization functions.
52018af368c080b9d60e34e670cd01f7d2d3ad2ba48Anders Carlsson  virtual const char *getStaticInitSectionSpecifier() const {
52118af368c080b9d60e34e670cd01f7d2d3ad2ba48Anders Carlsson    return 0;
52218af368c080b9d60e34e670cd01f7d2d3ad2ba48Anders Carlsson  }
523237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer
5240eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattnerprotected:
5250e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner  virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
5260e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner    return PointerWidth;
5270e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner  }
5280e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner  virtual uint64_t getPointerAlignV(unsigned AddrSpace) const {
5290e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner    return PointerAlign;
5300e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner  }
53131fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta  virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const {
53231fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    return PtrDiffType;
53331fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta  }
5341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual void getGCCRegNames(const char * const *&Names,
5350eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner                              unsigned &NumNames) const = 0;
5361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
5373346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson                                unsigned &NumAliases) const = 0;
5381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual bool validateAsmConstraint(const char *&Name,
539d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson                                     TargetInfo::ConstraintInfo &info) const= 0;
5405f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
5415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
5425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
5435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
5445f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
545