TargetInfo.h revision 0a0d2b179085a52c10402feebeb6db8b4d96a140
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 174f32786ac45210143654390177105eb749b614e9Ted Kremenek#include "llvm/ADT/IntrusiveRefCntPtr.h" 18868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar#include "llvm/ADT/StringMap.h" 190a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor#include "llvm/ADT/StringRef.h" 2020cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis#include "llvm/ADT/StringSwitch.h" 211752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar#include "llvm/ADT/Triple.h" 2203013fa9a0bf1ef4b907f5fec006c8f4000fdd21Michael J. Spencer#include "llvm/Support/DataTypes.h" 23207f4d8543529221932af82836016a2ef066c917Peter Collingbourne#include "clang/Basic/AddressSpaces.h" 240a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor#include "clang/Basic/VersionTuple.h" 255414fbac5f1749c0e85a8c4eeb5dfece59c3e30aTorok Edwin#include <cassert> 265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include <vector> 275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include <string> 285f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 29797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnernamespace llvm { 30797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnerstruct fltSemantics; 31797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner} 32525a05093a4816af961fe2bc6b8a81c17e2e26c2Chris Lattner 335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 345f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass Diagnostic; 35d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbarclass LangOptions; 36103b71c37a3c3a3da7128c1d0232a89b1e8d0d90Chandler Carruthclass MacroBuilder; 37797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnerclass SourceLocation; 387a9d49fd2bfac00e905b361ba76d26ab5b6c3b09Ted Kremenekclass SourceManager; 39d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbarclass TargetOptions; 40d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar 415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace Builtin { struct Info; } 421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4320cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis/// TargetCXXABI - The types of C++ ABIs for which we can generate code. 4420cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davisenum TargetCXXABI { 45ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall /// The generic ("Itanium") C++ ABI, documented at: 46ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall /// http://www.codesourcery.com/public/cxx-abi/ 4720cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis CXXABI_Itanium, 48ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall 49ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall /// The ARM C++ ABI, based largely on the Itanium ABI but with 50ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall /// significant differences. 51ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall /// http://infocenter.arm.com 52ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall /// /help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf 53ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall CXXABI_ARM, 54ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall 55ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall /// The Visual Studio ABI. Only scattered official documentation exists. 5620cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis CXXABI_Microsoft 5720cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis}; 5820cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis 5942e6737f2efb113563140ad794c21c7709250402Chris Lattner/// TargetInfo - This class exposes information about the current target. 605f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer/// 614f32786ac45210143654390177105eb749b614e9Ted Kremenekclass TargetInfo : public llvm::RefCountedBase<TargetInfo> { 621752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar llvm::Triple Triple; 630eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattnerprotected: 64cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner // Target values set by the ctor of the actual target implementation. Default 65cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner // values are specified by the TargetInfo constructor. 66b030f0272500c6c5602f587ac029ee0dc0e5a05cEli Friedman bool TLSSupported; 679bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner bool NoAsmVariants; // True if {|} are normal characters. 68927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner unsigned char PointerWidth, PointerAlign; 69c81f2a2c7f83e64b3ef2b77030536290d0e2b350Roman Divacky unsigned char BoolWidth, BoolAlign; 70927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner unsigned char IntWidth, IntAlign; 7161538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman unsigned char FloatWidth, FloatAlign; 72927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner unsigned char DoubleWidth, DoubleAlign; 7361538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman unsigned char LongDoubleWidth, LongDoubleAlign; 746deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola unsigned char LargeArrayMinWidth, LargeArrayAlign; 75927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner unsigned char LongWidth, LongAlign; 76927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner unsigned char LongLongWidth, LongLongAlign; 7777e8b53fe3ff630d8d1454db94e38bedda14d5caDaniel Dunbar const char *DescriptionString; 783fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner const char *UserLabelPrefix; 79be4c8705e499b55548467eb7adaa23cbc6edfef9Roman Divacky const char *MCountName; 80cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat; 81264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov unsigned char RegParmMax, SSERegParmMax; 8220cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis TargetCXXABI CXXABI; 83207f4d8543529221932af82836016a2ef066c917Peter Collingbourne const LangAS::Map *AddrSpaceMap; 84bbced580c92afa09cd4423a9bdc90ff61cb1e79aTed Kremenek 850a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor mutable llvm::StringRef PlatformName; 860a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor mutable VersionTuple PlatformMinVersion; 870a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 88613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar unsigned HasAlignMac68kSupport : 1; 89dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar unsigned RealTypeUsesObjCFPRet : 3; 90613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar 91cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner // TargetInfo Constructor. Default initializes all fields. 92cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner TargetInfo(const std::string &T); 931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumppublic: 95d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar /// CreateTargetInfo - Construct a target for the given options. 96b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar /// 97b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar /// \param Opts - The options to use to initialize the target. The target may 98b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar /// modify the options to canonicalize the target feature information to match 99b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar /// what the backend expects. 100b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar static TargetInfo* CreateTargetInfo(Diagnostic &Diags, TargetOptions &Opts); 101bbced580c92afa09cd4423a9bdc90ff61cb1e79aTed Kremenek 1020eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner virtual ~TargetInfo(); 103fb79f7cc00f9c1e04f11ed636eefb36d246b0fb8Ted Kremenek 1049c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner ///===---- Target Data Type Query Methods -------------------------------===// 10531fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta enum IntType { 1062b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner NoInt = 0, 10731fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta SignedShort, 10831fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta UnsignedShort, 10931fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta SignedInt, 11031fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta UnsignedInt, 11131fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta SignedLong, 11231fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta UnsignedLong, 11331fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta SignedLongLong, 11431fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta UnsignedLongLong 1153fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner }; 116dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar 117dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar enum RealType { 118dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar Float = 0, 119dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar Double, 120dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar LongDouble 121dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar }; 122dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar 1233fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattnerprotected: 1243c7b6e46c5f9bdbe0676c52d80df98b68b02be99Eli Friedman IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType, 1259cf910efc4fb7001a6d276ed2eabf01f0f0efaaaEdward O'Callaghan WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType; 126b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar 127b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar /// Control whether the alignment of bit-field types is respected when laying 128b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar /// out structures. If true, then the alignment of the bit-field type will be 129b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar /// used to (a) impact the alignment of the containing structure, and (b) 130b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar /// ensure that the individual bit-field will not straddle an alignment 131b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar /// boundary. 132b6830d616a068971f13e1e213e06a945c8c93ceaDaniel Dunbar unsigned UseBitFieldTypeAlignment : 1; 133b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar 1343fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattnerpublic: 1353fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner IntType getSizeType() const { return SizeType; } 1363fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner IntType getIntMaxType() const { return IntMaxType; } 1373fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner IntType getUIntMaxType() const { return UIntMaxType; } 1383fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner IntType getPtrDiffType(unsigned AddrSpace) const { 13931fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace); 14031fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta } 1416ad474f82f0cf32e13128d89fa5ad3a37ae73530Chris Lattner IntType getIntPtrType() const { return IntPtrType; } 1423fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner IntType getWCharType() const { return WCharType; } 143e64ef80363c84f4f431e26b61db554c89beeddb6Chris Lattner IntType getWIntType() const { return WIntType; } 144f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith IntType getChar16Type() const { return Char16Type; } 145f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith IntType getChar32Type() const { return Char32Type; } 1463c7b6e46c5f9bdbe0676c52d80df98b68b02be99Eli Friedman IntType getInt64Type() const { return Int64Type; } 1479cf910efc4fb7001a6d276ed2eabf01f0f0efaaaEdward O'Callaghan IntType getSigAtomicType() const { return SigAtomicType; } 1485f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 149b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner 150237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer /// getTypeWidth - Return the width (in bits) of the specified integer type 151b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner /// enum. For example, SignedInt -> getIntWidth(). 152b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner unsigned getTypeWidth(IntType T) const; 153b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner 1549099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner /// getTypeAlign - Return the alignment (in bits) of the specified integer 1559099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner /// type enum. For example, SignedInt -> getIntAlign(). 1569099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner unsigned getTypeAlign(IntType T) const; 1579099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner 158961f0708fb66375acf47f9e9bc1aecfb3f992aeaChris Lattner /// isTypeSigned - Return whether an integer types is signed. Returns true if 159b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner /// the type is signed; false otherwise. 1603f59c975aa5d047f7edd1b900b5e885c38af0ef7Chris Lattner static bool isTypeSigned(IntType T); 161b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner 162f72a44330b9d9a4b2d93e9b91cfb8ab7bd4a0643Chris Lattner /// getPointerWidth - Return the width of pointers on this target, for the 163927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner /// specified address space. 164927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner uint64_t getPointerWidth(unsigned AddrSpace) const { 165927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner return AddrSpace == 0 ? PointerWidth : getPointerWidthV(AddrSpace); 166927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner } 167927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner uint64_t getPointerAlign(unsigned AddrSpace) const { 168927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace); 169927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner } 1701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1719e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// getBoolWidth/Align - Return the size of '_Bool' and C++ 'bool' for this 1729e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// target, in bits. 173c81f2a2c7f83e64b3ef2b77030536290d0e2b350Roman Divacky unsigned getBoolWidth() const { return BoolWidth; } 174c81f2a2c7f83e64b3ef2b77030536290d0e2b350Roman Divacky unsigned getBoolAlign() const { return BoolAlign; } 1751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 176f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith unsigned getCharWidth() const { return 8; } // FIXME 177f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith unsigned getCharAlign() const { return 8; } // FIXME 1781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1799e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// getShortWidth/Align - Return the size of 'signed short' and 1801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 'unsigned short' for this target, in bits. 1819e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner unsigned getShortWidth() const { return 16; } // FIXME 1829e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner unsigned getShortAlign() const { return 16; } // FIXME 1831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1849e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for 1859e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// this target, in bits. 1862621fd1d6d3c5eadcae246859f62738645df7540Chris Lattner unsigned getIntWidth() const { return IntWidth; } 1872621fd1d6d3c5eadcae246859f62738645df7540Chris Lattner unsigned getIntAlign() const { return IntAlign; } 1881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1899e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' 1909e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// for this target, in bits. 1918059e997ee05e4aa87f7e21fed630429a140ee53Chris Lattner unsigned getLongWidth() const { return LongWidth; } 1928059e997ee05e4aa87f7e21fed630429a140ee53Chris Lattner unsigned getLongAlign() const { return LongAlign; } 1931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1949e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// getLongLongWidth/Align - Return the size of 'signed long long' and 1959e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// 'unsigned long long' for this target, in bits. 196ec10f5886526124ba733fbd0ef8665d576285daaChris Lattner unsigned getLongLongWidth() const { return LongLongWidth; } 197ec10f5886526124ba733fbd0ef8665d576285daaChris Lattner unsigned getLongLongAlign() const { return LongLongAlign; } 1981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 199f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith /// getWCharWidth/Align - Return the size of 'wchar_t' for this target, in 2009e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// bits. 2019184646509d015ea66e796113a8c68598681374bChris Lattner unsigned getWCharWidth() const { return getTypeWidth(WCharType); } 2029184646509d015ea66e796113a8c68598681374bChris Lattner unsigned getWCharAlign() const { return getTypeAlign(WCharType); } 203f72a44330b9d9a4b2d93e9b91cfb8ab7bd4a0643Chris Lattner 204f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith /// getChar16Width/Align - Return the size of 'char16_t' for this target, in 205f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith /// bits. 2069184646509d015ea66e796113a8c68598681374bChris Lattner unsigned getChar16Width() const { return getTypeWidth(Char16Type); } 2079184646509d015ea66e796113a8c68598681374bChris Lattner unsigned getChar16Align() const { return getTypeAlign(Char16Type); } 208f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith 209f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith /// getChar32Width/Align - Return the size of 'char32_t' for this target, in 210f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith /// bits. 2119184646509d015ea66e796113a8c68598681374bChris Lattner unsigned getChar32Width() const { return getTypeWidth(Char32Type); } 2129184646509d015ea66e796113a8c68598681374bChris Lattner unsigned getChar32Align() const { return getTypeAlign(Char32Type); } 213f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith 2149e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// getFloatWidth/Align/Format - Return the size/align/format of 'float'. 21561538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman unsigned getFloatWidth() const { return FloatWidth; } 21661538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman unsigned getFloatAlign() const { return FloatAlign; } 217b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner const llvm::fltSemantics &getFloatFormat() const { return *FloatFormat; } 2189e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner 2199e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'. 220c8b1227fa8c17d9881815e40c04e19334be536f8Nate Begeman unsigned getDoubleWidth() const { return DoubleWidth; } 221c8b1227fa8c17d9881815e40c04e19334be536f8Nate Begeman unsigned getDoubleAlign() const { return DoubleAlign; } 222b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner const llvm::fltSemantics &getDoubleFormat() const { return *DoubleFormat; } 2239e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner 2249e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long 2259e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner /// double'. 22661538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman unsigned getLongDoubleWidth() const { return LongDoubleWidth; } 22761538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman unsigned getLongDoubleAlign() const { return LongDoubleAlign; } 228b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner const llvm::fltSemantics &getLongDoubleFormat() const { 229b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner return *LongDoubleFormat; 230cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner } 2311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2326deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola // getLargeArrayMinWidth/Align - Return the minimum array size that is 2336deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola // 'large' and its alignment. 2346deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola unsigned getLargeArrayMinWidth() const { return LargeArrayMinWidth; } 2356deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola unsigned getLargeArrayAlign() const { return LargeArrayAlign; } 2366deecb0d46bcfd048e651d2db7c4fb0d6407da96Rafael Espindola 2375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this 2381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// target, in bits. 2390eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner unsigned getIntMaxTWidth() const { 2409184646509d015ea66e796113a8c68598681374bChris Lattner return getTypeWidth(IntMaxType); 2415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 2421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2433fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner /// getUserLabelPrefix - This returns the default value of the 2443fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner /// __USER_LABEL_PREFIX__ macro, which is the prefix given to user symbols by 2453fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner /// default. On most platforms this is "_", but it is "" on some, and "." on 2463fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner /// others. 2473fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner const char *getUserLabelPrefix() const { 2483fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner return UserLabelPrefix; 2493fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner } 2501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 251be4c8705e499b55548467eb7adaa23cbc6edfef9Roman Divacky /// MCountName - This returns name of the mcount instrumentation function. 252be4c8705e499b55548467eb7adaa23cbc6edfef9Roman Divacky const char *getMCountName() const { 253be4c8705e499b55548467eb7adaa23cbc6edfef9Roman Divacky return MCountName; 254be4c8705e499b55548467eb7adaa23cbc6edfef9Roman Divacky } 255be4c8705e499b55548467eb7adaa23cbc6edfef9Roman Divacky 256b6830d616a068971f13e1e213e06a945c8c93ceaDaniel Dunbar bool useBitFieldTypeAlignment() const { 257b6830d616a068971f13e1e213e06a945c8c93ceaDaniel Dunbar return UseBitFieldTypeAlignment; 258b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar } 259b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar 260613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar /// hasAlignMac68kSupport - Check whether this target support '#pragma options 261613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar /// align=mac68k'. 262613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar bool hasAlignMac68kSupport() const { 263613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar return HasAlignMac68kSupport; 264613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar } 265613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar 2662b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner /// getTypeName - Return the user string for the specified integer type enum. 2672b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner /// For example, SignedShort -> "short". 2682b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner static const char *getTypeName(IntType T); 2691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 270b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner /// getTypeConstantSuffix - Return the constant suffix for the specified 271b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner /// integer type enum. For example, SignedLong -> "L". 272b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner static const char *getTypeConstantSuffix(IntType T); 273b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner 274dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar /// \brief Check whether the given real type should use the "fpret" flavor of 275dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar /// Obj-C message passing on this target. 276dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar bool useObjCFPRetForRealType(RealType T) const { 277dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar return RealTypeUsesObjCFPRet & (1 << T); 278dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar } 279dacf9dda17346c628fdd8c5df53c681738db0dc5Daniel Dunbar 2809c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner ///===---- Other target property query methods --------------------------===// 2811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2829c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner /// getTargetDefines - Appends the target-specific #define values for this 2839c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner /// target set to the specified buffer. 28433328642a7a8a126918814ddcbcebf83c121ad54Chris Lattner virtual void getTargetDefines(const LangOptions &Opts, 285a99927774d07af9c6f0e1945531eadc910592945Benjamin Kramer MacroBuilder &Builder) const = 0; 2861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 287b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner 2885f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// getTargetBuiltins - Return information about target-specific builtins for 2895f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// the current primary target, and info about which builtins are non-portable 2905f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// across the current set of primary and secondary targets. 2911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual void getTargetBuiltins(const Builtin::Info *&Records, 2920eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner unsigned &NumRecords) const = 0; 2935f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 294d19144b244f86227fcc2b0da794929fe83968dd5Chris Lattner /// getVAListDeclaration - Return the declaration to use for 295d19144b244f86227fcc2b0da794929fe83968dd5Chris Lattner /// __builtin_va_list, which is target-specific. 2960eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner virtual const char *getVAListDeclaration() const = 0; 297fb5e5ba3c7708f3aef4db0ed30e8470b3ed4206aAnders Carlsson 2983346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson /// isValidGCCRegisterName - Returns whether the passed in string 2993346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson /// is a valid register name according to GCC. This is used by Sema for 3003346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson /// inline asm statements. 30183c021c6d33aa173cf1a6e3bc61006dabb042703Anders Carlsson bool isValidGCCRegisterName(llvm::StringRef Name) const; 302d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson 303d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson // getNormalizedGCCRegisterName - Returns the "normalized" GCC register name. 304d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson // For example, on x86 it will return "ax" when "eax" is passed in. 30583c021c6d33aa173cf1a6e3bc61006dabb042703Anders Carlsson llvm::StringRef getNormalizedGCCRegisterName(llvm::StringRef Name) const; 3061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 30744def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner struct ConstraintInfo { 30844def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner enum { 30944def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner CI_None = 0x00, 31044def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner CI_AllowsMemory = 0x01, 31144def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner CI_AllowsRegister = 0x02, 312fa780fc4a4983003633c9b560387266101839923Chris Lattner CI_ReadWrite = 0x04, // "+r" output constraint (read and write). 313fa780fc4a4983003633c9b560387266101839923Chris Lattner CI_HasMatchingInput = 0x08 // This output operand has a matching input. 31444def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner }; 31544def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner unsigned Flags; 31644def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner int TiedOperand; 3171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3182819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner std::string ConstraintStr; // constraint: "=rm" 3192819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner std::string Name; // Operand name: [foo] with no []'s. 320432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner public: 321f959fb5fb82ae2cbdf8635d734613a01818fb7bfAnders Carlsson ConstraintInfo(llvm::StringRef ConstraintStr, llvm::StringRef Name) 322237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()), 323f959fb5fb82ae2cbdf8635d734613a01818fb7bfAnders Carlsson Name(Name.str()) {} 324432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner 325432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner const std::string &getConstraintStr() const { return ConstraintStr; } 3262819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner const std::string &getName() const { return Name; } 32744def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; } 32844def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; } 32944def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; } 3301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 331fa780fc4a4983003633c9b560387266101839923Chris Lattner /// hasMatchingInput - Return true if this output operand has a matching 332fa780fc4a4983003633c9b560387266101839923Chris Lattner /// (tied) input operand. 333fa780fc4a4983003633c9b560387266101839923Chris Lattner bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; } 3341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 335fa780fc4a4983003633c9b560387266101839923Chris Lattner /// hasTiedOperand() - Return true if this input operand is a matching 336fa780fc4a4983003633c9b560387266101839923Chris Lattner /// constraint that ties it to an output operand. If this returns true, 337fa780fc4a4983003633c9b560387266101839923Chris Lattner /// then getTiedOperand will indicate which output operand this is tied to. 33844def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner bool hasTiedOperand() const { return TiedOperand != -1; } 33944def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner unsigned getTiedOperand() const { 34044def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner assert(hasTiedOperand() && "Has no tied operand!"); 34144def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner return (unsigned)TiedOperand; 34244def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner } 3431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 34444def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner void setIsReadWrite() { Flags |= CI_ReadWrite; } 34544def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner void setAllowsMemory() { Flags |= CI_AllowsMemory; } 34644def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner void setAllowsRegister() { Flags |= CI_AllowsRegister; } 347fa780fc4a4983003633c9b560387266101839923Chris Lattner void setHasMatchingInput() { Flags |= CI_HasMatchingInput; } 3481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 349d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner /// setTiedOperand - Indicate that this is an input operand that is tied to 350d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner /// the specified output operand. Copy over the various constraint 351d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner /// information from the output. 352d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner void setTiedOperand(unsigned N, ConstraintInfo &Output) { 353fa780fc4a4983003633c9b560387266101839923Chris Lattner Output.setHasMatchingInput(); 354d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner Flags = Output.Flags; 355d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner TiedOperand = N; 356d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner // Don't copy Name or constraint string. 357d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner } 358d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson }; 359d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson 360d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson // validateOutputConstraint, validateInputConstraint - Checks that 361d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson // a constraint is valid and provides information about it. 362d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson // FIXME: These should return a real error instead of just true/false. 363432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner bool validateOutputConstraint(ConstraintInfo &Info) const; 3642819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner bool validateInputConstraint(ConstraintInfo *OutputConstraints, 3652819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner unsigned NumOutputs, 36645b050e72d058131e6f169fe54888bb91a003fb5Anders Carlsson ConstraintInfo &info) const; 36742e1ee0702d8267d632df0fdb5c479a582877c6fAnders Carlsson bool resolveSymbolicName(const char *&Name, 3682819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner ConstraintInfo *OutputConstraints, 3692819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner unsigned NumOutputs, unsigned &Index) const; 3701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3710eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner virtual std::string convertConstraint(const char Constraint) const { 372cee55018570c0c46262c6e4ef7beaa707c93fc86Dale Johannesen // 'p' defaults to 'r', but can be overridden by targets. 373cee55018570c0c46262c6e4ef7beaa707c93fc86Dale Johannesen if (Constraint == 'p') 374cee55018570c0c46262c6e4ef7beaa707c93fc86Dale Johannesen return std::string("r"); 3750eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner return std::string(1, Constraint); 3760eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner } 3771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 378d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson // Returns a string of target-specific clobbers, in LLVM format. 3790eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner virtual const char *getClobbers() const = 0; 3801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3817a4718e813e5e99d478567a482217c7eef8572c5Devang Patel 3821752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar /// getTriple - Return the target triple of the primary target. 3831752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar const llvm::Triple &getTriple() const { 3841752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar return Triple; 3850eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner } 3861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 387ae3607684c5978dc2d877141015056c9d24f17eaTed Kremenek const char *getTargetDescription() const { 388364af81157a81cf34bb058a7d5b0185020e5164bSanjiv Gupta return DescriptionString; 3897a4718e813e5e99d478567a482217c7eef8572c5Devang Patel } 3903346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson 3913346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson struct GCCRegAlias { 3923346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson const char * const Aliases[5]; 3933346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson const char * const Register; 3943346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson }; 3952621fd1d6d3c5eadcae246859f62738645df7540Chris Lattner 396dcb4a1a6dd55fdf6c073d2761096f42e26be105aDaniel Dunbar virtual bool useGlobalsForAutomaticVariables() const { return false; } 397dcb4a1a6dd55fdf6c073d2761096f42e26be105aDaniel Dunbar 3986d7d8398e71a8bd121d3b46e250f1dbcfb9679d4Daniel Dunbar /// getCFStringSection - Return the section to use for CFString 3998e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar /// literals, or 0 if no special section is used. 4001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual const char *getCFStringSection() const { 4018e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar return "__DATA,__cfstring"; 4028e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar } 4038e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar 4042bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian /// getNSStringSection - Return the section to use for NSString 4052bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian /// literals, or 0 if no special section is used. 4062bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian virtual const char *getNSStringSection() const { 4072bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian return "__OBJC,__cstring_object,regular,no_dead_strip"; 4082bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian } 4092bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian 410237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer /// getNSStringNonFragileABISection - Return the section to use for 411ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian /// NSString literals, or 0 if no special section is used (NonFragile ABI). 412ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian virtual const char *getNSStringNonFragileABISection() const { 413ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian return "__DATA, __objc_stringobj, regular, no_dead_strip"; 414ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian } 415ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian 416797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner /// isValidSectionSpecifier - This is an optional hook that targets can 417797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner /// implement to perform semantic checking on attribute((section("foo"))) 418797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner /// specifiers. In this case, "foo" is passed in to be checked. If the 419797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner /// section specifier is invalid, the backend should return a non-empty string 420797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner /// that indicates the problem. 421797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner /// 422797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner /// This hook is a simple quality of implementation feature to catch errors 423797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner /// and give good diagnostics in cases when the assembler or code generator 424797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner /// would otherwise reject the section specifier. 425797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner /// 426f959fb5fb82ae2cbdf8635d734613a01818fb7bfAnders Carlsson virtual std::string isValidSectionSpecifier(llvm::StringRef SR) const { 427797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner return ""; 428797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner } 4298e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar 430a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson /// setForcedLangOptions - Set forced language options. 431a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson /// Apply changes to the target information with respect to certain 432a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson /// language options which change the target configuration. 433a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson virtual void setForcedLangOptions(LangOptions &Opts); 434a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson 435868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar /// getDefaultFeatures - Get the default set of target features for 436868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar /// the \args CPU; this should include all legal feature strings on 437868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar /// the target. 4381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual void getDefaultFeatures(const std::string &CPU, 43917ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar llvm::StringMap<bool> &Features) const { 44017ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar } 44117ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar 442018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar /// getABI - Get the ABI in use. 443018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar virtual const char *getABI() const { 444018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar return ""; 445018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar } 446018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar 44798b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis /// getCXXABI - Get the C++ ABI in use. 44820cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis virtual TargetCXXABI getCXXABI() const { 44998b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis return CXXABI; 45098b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis } 45198b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis 452eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar /// setCPU - Target the specific CPU. 453eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar /// 454eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar /// \return - False on error (invalid CPU name). 455eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar // 456eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar // FIXME: Remove this. 457eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar virtual bool setCPU(const std::string &Name) { 458eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar return true; 459eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar } 460eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar 46173b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar /// setABI - Use the specific ABI. 46273b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar /// 46373b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar /// \return - False on error (invalid ABI name). 46473b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar virtual bool setABI(const std::string &Name) { 46573b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar return false; 46673b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar } 46773b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar 46898b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis /// setCXXABI - Use this specific C++ ABI. 46998b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis /// 47020cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis /// \return - False on error (invalid C++ ABI name). 471ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall bool setCXXABI(const std::string &Name) { 472ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall static const TargetCXXABI Unknown = static_cast<TargetCXXABI>(-1); 473ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall TargetCXXABI ABI = llvm::StringSwitch<TargetCXXABI>(Name) 474ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall .Case("arm", CXXABI_ARM) 47520cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis .Case("itanium", CXXABI_Itanium) 47620cf717034ba1f20fc47c025ecb72ed9b631ad13Charles Davis .Case("microsoft", CXXABI_Microsoft) 477ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall .Default(Unknown); 478ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall if (ABI == Unknown) return false; 479ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall return setCXXABI(ABI); 480ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall } 481ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall 482ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall /// setCXXABI - Set the C++ ABI to be used by this implementation. 483ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall /// 484ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall /// \return - False on error (ABI not valid on this target) 485ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall virtual bool setCXXABI(TargetCXXABI ABI) { 486ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCall CXXABI = ABI; 48798b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis return true; 48898b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis } 48998b7c5c496dfccb39287b8f7d8f1444594936d10Charles Davis 49017ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar /// setFeatureEnabled - Enable or disable a specific target feature, 49117ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar /// the feature name must be valid. 49217ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar /// 49317ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar /// \return - False on error (invalid feature name). 49417ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features, 49517ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar const std::string &Name, 49617ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar bool Enabled) const { 49717ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar return false; 498868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar } 499868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar 50029a790ba422cfeeea9546b6e76777d98fa73cd67Daniel Dunbar /// HandleTargetOptions - Perform initialization based on the user configured 50129a790ba422cfeeea9546b6e76777d98fa73cd67Daniel Dunbar /// set of features (e.g., +sse4). The list is guaranteed to have at most one 50229a790ba422cfeeea9546b6e76777d98fa73cd67Daniel Dunbar /// entry per feature. 503b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar /// 504b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar /// The target may modify the features list, to change which options are 505b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar /// passed onwards to the backend. 506b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar virtual void HandleTargetFeatures(std::vector<std::string> &Features) { 50716167a6e3f7dfb7ed0babc5e0baab9fd140e959dChris Lattner } 508264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov 509264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov // getRegParmMax - Returns maximal number of args passed in registers. 510264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov unsigned getRegParmMax() const { 511264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov return RegParmMax; 512264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov } 513264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov 51421fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner /// isTLSSupported - Whether the target supports thread-local storage. 5156a3bc6df36848188e9d0c1d978170c2b0918c6a3Chris Lattner bool isTLSSupported() const { 516b030f0272500c6c5602f587ac029ee0dc0e5a05cEli Friedman return TLSSupported; 517b030f0272500c6c5602f587ac029ee0dc0e5a05cEli Friedman } 518237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer 5199bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner /// hasNoAsmVariants - Return true if {|} are normal characters in the 5209bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner /// asm string. If this returns false (the default), then {abc|xyz} is syntax 52137de281ac149a5c5f14e4935a3738d87370da3edChris Lattner /// that says that when compiling for asm variant #0, "abc" should be 5229bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner /// generated, but when compiling for asm variant #1, "xyz" should be 5239bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner /// generated. 5249bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner bool hasNoAsmVariants() const { 5259bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner return NoAsmVariants; 5269bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner } 527237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer 52821fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner /// getEHDataRegisterNumber - Return the register number that 52921fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner /// __builtin_eh_return_regno would return with the specified argument. 53021fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner virtual int getEHDataRegisterNumber(unsigned RegNo) const { 531237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer return -1; 53221fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner } 533237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer 534237cf582b89bbcc22640cea15426ddc7ada8412bMichael J. Spencer /// getStaticInitSectionSpecifier - Return the section to use for C++ static 53518af368c080b9d60e34e670cd01f7d2d3ad2ba48Anders Carlsson /// initialization functions. 53618af368c080b9d60e34e670cd01f7d2d3ad2ba48Anders Carlsson virtual const char *getStaticInitSectionSpecifier() const { 53718af368c080b9d60e34e670cd01f7d2d3ad2ba48Anders Carlsson return 0; 53818af368c080b9d60e34e670cd01f7d2d3ad2ba48Anders Carlsson } 539207f4d8543529221932af82836016a2ef066c917Peter Collingbourne 540207f4d8543529221932af82836016a2ef066c917Peter Collingbourne const LangAS::Map &getAddressSpaceMap() const { 541207f4d8543529221932af82836016a2ef066c917Peter Collingbourne return *AddrSpaceMap; 542207f4d8543529221932af82836016a2ef066c917Peter Collingbourne } 543207f4d8543529221932af82836016a2ef066c917Peter Collingbourne 5440a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor /// \brief Retrieve the name of the platform as it is used in the 5450a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor /// availability attribute. 5460a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor llvm::StringRef getPlatformName() const { return PlatformName; } 5470a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 5480a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor /// \brief Retrieve the minimum desired version of the platform, to 5490a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor /// which the program should be compiled. 5500a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor VersionTuple getPlatformMinVersion() const { return PlatformMinVersion; } 5510a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 5520eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattnerprotected: 5530e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner virtual uint64_t getPointerWidthV(unsigned AddrSpace) const { 5540e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner return PointerWidth; 5550e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner } 5560e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner virtual uint64_t getPointerAlignV(unsigned AddrSpace) const { 5570e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner return PointerAlign; 5580e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner } 55931fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const { 56031fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta return PtrDiffType; 56131fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta } 5621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual void getGCCRegNames(const char * const *&Names, 5630eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner unsigned &NumNames) const = 0; 5641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, 5653346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson unsigned &NumAliases) const = 0; 5661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual bool validateAsmConstraint(const char *&Name, 567d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson TargetInfo::ConstraintInfo &info) const= 0; 5685f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 5695f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 5715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 573