TargetInfo.h revision 613fd67e575ff1c038535b18dafebca070f3ed91
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"
191752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar#include "llvm/ADT/Triple.h"
209f8eb2032030482b1d3de86e9bee725d93564302Chandler Carruth#include "llvm/System/DataTypes.h"
215414fbac5f1749c0e85a8c4eeb5dfece59c3e30aTorok Edwin#include <cassert>
225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include <vector>
235f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include <string>
245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
25797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnernamespace llvm {
26797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnerstruct fltSemantics;
27797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnerclass StringRef;
28797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner}
29525a05093a4816af961fe2bc6b8a81c17e2e26c2Chris Lattner
305f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang {
315f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass Diagnostic;
32d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbarclass LangOptions;
33103b71c37a3c3a3da7128c1d0232a89b1e8d0d90Chandler Carruthclass MacroBuilder;
34797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattnerclass SourceLocation;
357a9d49fd2bfac00e905b361ba76d26ab5b6c3b09Ted Kremenekclass SourceManager;
36d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbarclass TargetOptions;
37d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar
385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace Builtin { struct Info; }
391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
4042e6737f2efb113563140ad794c21c7709250402Chris Lattner/// TargetInfo - This class exposes information about the current target.
415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer///
425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass TargetInfo {
431752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar  llvm::Triple Triple;
440eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattnerprotected:
45cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  // Target values set by the ctor of the actual target implementation.  Default
46cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  // values are specified by the TargetInfo constructor.
47b030f0272500c6c5602f587ac029ee0dc0e5a05cEli Friedman  bool TLSSupported;
489bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  bool NoAsmVariants;  // True if {|} are normal characters.
49927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char PointerWidth, PointerAlign;
50927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char IntWidth, IntAlign;
5161538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned char FloatWidth, FloatAlign;
52927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char DoubleWidth, DoubleAlign;
5361538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned char LongDoubleWidth, LongDoubleAlign;
54927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char LongWidth, LongAlign;
55927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  unsigned char LongLongWidth, LongLongAlign;
5677e8b53fe3ff630d8d1454db94e38bedda14d5caDaniel Dunbar  const char *DescriptionString;
573fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  const char *UserLabelPrefix;
58cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat;
59264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov  unsigned char RegParmMax, SSERegParmMax;
60bbced580c92afa09cd4423a9bdc90ff61cb1e79aTed Kremenek
61613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  unsigned HasAlignMac68kSupport : 1;
62613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar
63cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  // TargetInfo Constructor.  Default initializes all fields.
64cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  TargetInfo(const std::string &T);
651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumppublic:
67d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0Daniel Dunbar  /// CreateTargetInfo - Construct a target for the given options.
68b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  ///
69b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// \param Opts - The options to use to initialize the target. The target may
70b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// modify the options to canonicalize the target feature information to match
71b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// what the backend expects.
72b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  static TargetInfo* CreateTargetInfo(Diagnostic &Diags, TargetOptions &Opts);
73bbced580c92afa09cd4423a9bdc90ff61cb1e79aTed Kremenek
740eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  virtual ~TargetInfo();
75fb79f7cc00f9c1e04f11ed636eefb36d246b0fb8Ted Kremenek
769c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner  ///===---- Target Data Type Query Methods -------------------------------===//
7731fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta  enum IntType {
782b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner    NoInt = 0,
7931fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    SignedShort,
8031fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    UnsignedShort,
8131fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    SignedInt,
8231fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    UnsignedInt,
8331fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    SignedLong,
8431fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    UnsignedLong,
8531fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    SignedLongLong,
8631fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    UnsignedLongLong
873fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  };
883fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattnerprotected:
893c7b6e46c5f9bdbe0676c52d80df98b68b02be99Eli Friedman  IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType,
909cf910efc4fb7001a6d276ed2eabf01f0f0efaaaEdward O'Callaghan          WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType;
91b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar
92b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// Control whether the alignment of bit-field types is respected when laying
93b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// out structures. If true, then the alignment of the bit-field type will be
94b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// used to (a) impact the alignment of the containing structure, and (b)
95b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// ensure that the individual bit-field will not straddle an alignment
96b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  /// boundary.
97b6830d616a068971f13e1e213e06a945c8c93ceaDaniel Dunbar  unsigned UseBitFieldTypeAlignment : 1;
98b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar
993fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattnerpublic:
1003fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getSizeType() const { return SizeType; }
1013fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getIntMaxType() const { return IntMaxType; }
1023fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getUIntMaxType() const { return UIntMaxType; }
1033fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getPtrDiffType(unsigned AddrSpace) const {
10431fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
10531fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta  }
1066ad474f82f0cf32e13128d89fa5ad3a37ae73530Chris Lattner  IntType getIntPtrType() const { return IntPtrType; }
1073fa8f7491a6a6c1445768ea23ec85d3554c3ba98Chris Lattner  IntType getWCharType() const { return WCharType; }
108e64ef80363c84f4f431e26b61db554c89beeddb6Chris Lattner  IntType getWIntType() const { return WIntType; }
109f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  IntType getChar16Type() const { return Char16Type; }
110f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  IntType getChar32Type() const { return Char32Type; }
1113c7b6e46c5f9bdbe0676c52d80df98b68b02be99Eli Friedman  IntType getInt64Type() const { return Int64Type; }
1129cf910efc4fb7001a6d276ed2eabf01f0f0efaaaEdward O'Callaghan  IntType getSigAtomicType() const { return SigAtomicType; }
1135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
114b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
115b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  /// getTypeWidth - Return the width (in bits) of the specified integer type
116b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  /// enum. For example, SignedInt -> getIntWidth().
117b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  unsigned getTypeWidth(IntType T) const;
118b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
1199099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner  /// getTypeAlign - Return the alignment (in bits) of the specified integer
1209099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner  /// type enum. For example, SignedInt -> getIntAlign().
1219099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner  unsigned getTypeAlign(IntType T) const;
1229099e7bcda3922cee0cffcdf21332ac4aa193ceaChris Lattner
123961f0708fb66375acf47f9e9bc1aecfb3f992aeaChris Lattner  /// isTypeSigned - Return whether an integer types is signed. Returns true if
124b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  /// the type is signed; false otherwise.
125961f0708fb66375acf47f9e9bc1aecfb3f992aeaChris Lattner  bool isTypeSigned(IntType T) const;
126b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
127f72a44330b9d9a4b2d93e9b91cfb8ab7bd4a0643Chris Lattner  /// getPointerWidth - Return the width of pointers on this target, for the
128927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  /// specified address space.
129927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  uint64_t getPointerWidth(unsigned AddrSpace) const {
130927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner    return AddrSpace == 0 ? PointerWidth : getPointerWidthV(AddrSpace);
131927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  }
132927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  uint64_t getPointerAlign(unsigned AddrSpace) const {
133927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner    return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace);
134927686fe8c968ca786fa44d2353eebf59c4f5b8aChris Lattner  }
1351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1369e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getBoolWidth/Align - Return the size of '_Bool' and C++ 'bool' for this
1379e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// target, in bits.
1389e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  unsigned getBoolWidth(bool isWide = false) const { return 8; }  // FIXME
1399e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  unsigned getBoolAlign(bool isWide = false) const { return 8; }  // FIXME
1401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
141f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  unsigned getCharWidth() const { return 8; } // FIXME
142f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  unsigned getCharAlign() const { return 8; } // FIXME
1431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1449e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getShortWidth/Align - Return the size of 'signed short' and
1451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// 'unsigned short' for this target, in bits.
1469e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  unsigned getShortWidth() const { return 16; } // FIXME
1479e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  unsigned getShortAlign() const { return 16; } // FIXME
1481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1499e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for
1509e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// this target, in bits.
1512621fd1d6d3c5eadcae246859f62738645df7540Chris Lattner  unsigned getIntWidth() const { return IntWidth; }
1522621fd1d6d3c5eadcae246859f62738645df7540Chris Lattner  unsigned getIntAlign() const { return IntAlign; }
1531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1549e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getLongWidth/Align - Return the size of 'signed long' and 'unsigned long'
1559e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// for this target, in bits.
1568059e997ee05e4aa87f7e21fed630429a140ee53Chris Lattner  unsigned getLongWidth() const { return LongWidth; }
1578059e997ee05e4aa87f7e21fed630429a140ee53Chris Lattner  unsigned getLongAlign() const { return LongAlign; }
1581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1599e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getLongLongWidth/Align - Return the size of 'signed long long' and
1609e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// 'unsigned long long' for this target, in bits.
161ec10f5886526124ba733fbd0ef8665d576285daaChris Lattner  unsigned getLongLongWidth() const { return LongLongWidth; }
162ec10f5886526124ba733fbd0ef8665d576285daaChris Lattner  unsigned getLongLongAlign() const { return LongLongAlign; }
1631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
164f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// getWCharWidth/Align - Return the size of 'wchar_t' for this target, in
1659e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// bits.
1669184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getWCharWidth() const { return getTypeWidth(WCharType); }
1679184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getWCharAlign() const { return getTypeAlign(WCharType); }
168f72a44330b9d9a4b2d93e9b91cfb8ab7bd4a0643Chris Lattner
169f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// getChar16Width/Align - Return the size of 'char16_t' for this target, in
170f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// bits.
1719184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getChar16Width() const { return getTypeWidth(Char16Type); }
1729184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getChar16Align() const { return getTypeAlign(Char16Type); }
173f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith
174f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// getChar32Width/Align - Return the size of 'char32_t' for this target, in
175f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith  /// bits.
1769184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getChar32Width() const { return getTypeWidth(Char32Type); }
1779184646509d015ea66e796113a8c68598681374bChris Lattner  unsigned getChar32Align() const { return getTypeAlign(Char32Type); }
178f5c209d23b20ada4a9b6235db50317239cbf6ae1Alisdair Meredith
1799e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getFloatWidth/Align/Format - Return the size/align/format of 'float'.
18061538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned getFloatWidth() const { return FloatWidth; }
18161538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned getFloatAlign() const { return FloatAlign; }
182b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner  const llvm::fltSemantics &getFloatFormat() const { return *FloatFormat; }
1839e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner
1849e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
185c8b1227fa8c17d9881815e40c04e19334be536f8Nate Begeman  unsigned getDoubleWidth() const { return DoubleWidth; }
186c8b1227fa8c17d9881815e40c04e19334be536f8Nate Begeman  unsigned getDoubleAlign() const { return DoubleAlign; }
187b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner  const llvm::fltSemantics &getDoubleFormat() const { return *DoubleFormat; }
1889e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner
1899e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long
1909e9b6dc3fd413f5341fab54b681420eeb21cd169Chris Lattner  /// double'.
19161538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned getLongDoubleWidth() const { return LongDoubleWidth; }
19261538a7d1336f3ef3cb81e09f11a1cbb282bcf81Eli Friedman  unsigned getLongDoubleAlign() const { return LongDoubleAlign; }
193b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner  const llvm::fltSemantics &getLongDoubleFormat() const {
194b7cfe88e88cb4f46308de89cf3f0c81bfe624128Chris Lattner    return *LongDoubleFormat;
195cd4fc42896f926ffc081e1c4a8bf4cd647883c14Chris Lattner  }
1961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1975f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this
1981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  /// target, in bits.
1990eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  unsigned getIntMaxTWidth() const {
2009184646509d015ea66e796113a8c68598681374bChris Lattner    return getTypeWidth(IntMaxType);
2015f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  }
2021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2033fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  /// getUserLabelPrefix - This returns the default value of the
2043fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  /// __USER_LABEL_PREFIX__ macro, which is the prefix given to user symbols by
2053fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  /// default.  On most platforms this is "_", but it is "" on some, and "." on
2063fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  /// others.
2073fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  const char *getUserLabelPrefix() const {
2083fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner    return UserLabelPrefix;
2093fdf4678935b27c3d3fd4eb10bf9f5ab98dc0d99Chris Lattner  }
2101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
211b6830d616a068971f13e1e213e06a945c8c93ceaDaniel Dunbar  bool useBitFieldTypeAlignment() const {
212b6830d616a068971f13e1e213e06a945c8c93ceaDaniel Dunbar    return UseBitFieldTypeAlignment;
213b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar  }
214b6a169395c1b30c76daffebcbd2164b6247a5d21Daniel Dunbar
215613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  /// hasAlignMac68kSupport - Check whether this target support '#pragma options
216613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  /// align=mac68k'.
217613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  bool hasAlignMac68kSupport() const {
218613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar    return HasAlignMac68kSupport;
219613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar  }
220613fd67e575ff1c038535b18dafebca070f3ed91Daniel Dunbar
2212b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner  /// getTypeName - Return the user string for the specified integer type enum.
2222b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner  /// For example, SignedShort -> "short".
2232b5abf515f9696912452f431c7738691cf97f4f1Chris Lattner  static const char *getTypeName(IntType T);
2241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
225b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  /// getTypeConstantSuffix - Return the constant suffix for the specified
226b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  /// integer type enum. For example, SignedLong -> "L".
227b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner  static const char *getTypeConstantSuffix(IntType T);
228b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
2299c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner  ///===---- Other target property query methods --------------------------===//
2301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2319c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner  /// getTargetDefines - Appends the target-specific #define values for this
2329c4bea1fa7291035325575c02d33552a124d8ef3Chris Lattner  /// target set to the specified buffer.
23333328642a7a8a126918814ddcbcebf83c121ad54Chris Lattner  virtual void getTargetDefines(const LangOptions &Opts,
234a99927774d07af9c6f0e1945531eadc910592945Benjamin Kramer                                MacroBuilder &Builder) const = 0;
2351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
236b304f77cb621a47221f2aa2d35acdb5c730421ffChris Lattner
2375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// getTargetBuiltins - Return information about target-specific builtins for
2385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// the current primary target, and info about which builtins are non-portable
2395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer  /// across the current set of primary and secondary targets.
2401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual void getTargetBuiltins(const Builtin::Info *&Records,
2410eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner                                 unsigned &NumRecords) const = 0;
2425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
243d19144b244f86227fcc2b0da794929fe83968dd5Chris Lattner  /// getVAListDeclaration - Return the declaration to use for
244d19144b244f86227fcc2b0da794929fe83968dd5Chris Lattner  /// __builtin_va_list, which is target-specific.
2450eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  virtual const char *getVAListDeclaration() const = 0;
246fb5e5ba3c7708f3aef4db0ed30e8470b3ed4206aAnders Carlsson
2473346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  /// isValidGCCRegisterName - Returns whether the passed in string
2483346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  /// is a valid register name according to GCC. This is used by Sema for
2493346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  /// inline asm statements.
25083c021c6d33aa173cf1a6e3bc61006dabb042703Anders Carlsson  bool isValidGCCRegisterName(llvm::StringRef Name) const;
251d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson
252d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // getNormalizedGCCRegisterName - Returns the "normalized" GCC register name.
253d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // For example, on x86 it will return "ax" when "eax" is passed in.
25483c021c6d33aa173cf1a6e3bc61006dabb042703Anders Carlsson  llvm::StringRef getNormalizedGCCRegisterName(llvm::StringRef Name) const;
2551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
25644def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner  struct ConstraintInfo {
25744def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    enum {
25844def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      CI_None = 0x00,
25944def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      CI_AllowsMemory = 0x01,
26044def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      CI_AllowsRegister = 0x02,
261fa780fc4a4983003633c9b560387266101839923Chris Lattner      CI_ReadWrite = 0x04,       // "+r" output constraint (read and write).
262fa780fc4a4983003633c9b560387266101839923Chris Lattner      CI_HasMatchingInput = 0x08 // This output operand has a matching input.
26344def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    };
26444def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    unsigned Flags;
26544def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    int TiedOperand;
2661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
2672819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner    std::string ConstraintStr;  // constraint: "=rm"
2682819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner    std::string Name;           // Operand name: [foo] with no []'s.
269432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner  public:
270f959fb5fb82ae2cbdf8635d734613a01818fb7bfAnders Carlsson    ConstraintInfo(llvm::StringRef ConstraintStr, llvm::StringRef Name)
271f959fb5fb82ae2cbdf8635d734613a01818fb7bfAnders Carlsson      : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
272f959fb5fb82ae2cbdf8635d734613a01818fb7bfAnders Carlsson      Name(Name.str()) {}
273432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner
274432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner    const std::string &getConstraintStr() const { return ConstraintStr; }
2752819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner    const std::string &getName() const { return Name; }
27644def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; }
27744def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; }
27844def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; }
2791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
280fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// hasMatchingInput - Return true if this output operand has a matching
281fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// (tied) input operand.
282fa780fc4a4983003633c9b560387266101839923Chris Lattner    bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; }
2831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
284fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// hasTiedOperand() - Return true if this input operand is a matching
285fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// constraint that ties it to an output operand.  If this returns true,
286fa780fc4a4983003633c9b560387266101839923Chris Lattner    /// then getTiedOperand will indicate which output operand this is tied to.
28744def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    bool hasTiedOperand() const { return TiedOperand != -1; }
28844def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    unsigned getTiedOperand() const {
28944def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      assert(hasTiedOperand() && "Has no tied operand!");
29044def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner      return (unsigned)TiedOperand;
29144def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    }
2921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
29344def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    void setIsReadWrite() { Flags |= CI_ReadWrite; }
29444def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    void setAllowsMemory() { Flags |= CI_AllowsMemory; }
29544def070435a2b5d67f0534f7a3a85a7389d60f2Chris Lattner    void setAllowsRegister() { Flags |= CI_AllowsRegister; }
296fa780fc4a4983003633c9b560387266101839923Chris Lattner    void setHasMatchingInput() { Flags |= CI_HasMatchingInput; }
2971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
298d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    /// setTiedOperand - Indicate that this is an input operand that is tied to
299d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    /// the specified output operand.  Copy over the various constraint
300d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    /// information from the output.
301d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    void setTiedOperand(unsigned N, ConstraintInfo &Output) {
302fa780fc4a4983003633c9b560387266101839923Chris Lattner      Output.setHasMatchingInput();
303d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner      Flags = Output.Flags;
304d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner      TiedOperand = N;
305d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner      // Don't copy Name or constraint string.
306d68876176a0d2c19e3864e7d38f6036c4f72f0a3Chris Lattner    }
307d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  };
308d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson
309d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // validateOutputConstraint, validateInputConstraint - Checks that
310d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // a constraint is valid and provides information about it.
311d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // FIXME: These should return a real error instead of just true/false.
312432c86969eced2ce658b3f3f2aa7407c8864f21bChris Lattner  bool validateOutputConstraint(ConstraintInfo &Info) const;
3132819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner  bool validateInputConstraint(ConstraintInfo *OutputConstraints,
3142819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner                               unsigned NumOutputs,
31545b050e72d058131e6f169fe54888bb91a003fb5Anders Carlsson                               ConstraintInfo &info) const;
31642e1ee0702d8267d632df0fdb5c479a582877c6fAnders Carlsson  bool resolveSymbolicName(const char *&Name,
3172819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner                           ConstraintInfo *OutputConstraints,
3182819fa85651526d59ade4fdc9da2cadd7b132973Chris Lattner                           unsigned NumOutputs, unsigned &Index) const;
3191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3200eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  virtual std::string convertConstraint(const char Constraint) const {
3210eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner    return std::string(1, Constraint);
3220eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  }
3231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
324d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson  // Returns a string of target-specific clobbers, in LLVM format.
3250eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  virtual const char *getClobbers() const = 0;
3261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
3277a4718e813e5e99d478567a482217c7eef8572c5Devang Patel
3281752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar  /// getTriple - Return the target triple of the primary target.
3291752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar  const llvm::Triple &getTriple() const {
3301752ee4849f4c37f5e03193e658be92650b0e65aDaniel Dunbar    return Triple;
3310eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner  }
3321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
333ae3607684c5978dc2d877141015056c9d24f17eaTed Kremenek  const char *getTargetDescription() const {
334364af81157a81cf34bb058a7d5b0185020e5164bSanjiv Gupta    return DescriptionString;
3357a4718e813e5e99d478567a482217c7eef8572c5Devang Patel  }
3363346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson
3373346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  struct GCCRegAlias {
3383346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson    const char * const Aliases[5];
3393346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson    const char * const Register;
3403346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson  };
3412621fd1d6d3c5eadcae246859f62738645df7540Chris Lattner
342dcb4a1a6dd55fdf6c073d2761096f42e26be105aDaniel Dunbar  virtual bool useGlobalsForAutomaticVariables() const { return false; }
343dcb4a1a6dd55fdf6c073d2761096f42e26be105aDaniel Dunbar
3446d7d8398e71a8bd121d3b46e250f1dbcfb9679d4Daniel Dunbar  /// getCFStringSection - Return the section to use for CFString
3458e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar  /// literals, or 0 if no special section is used.
3461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual const char *getCFStringSection() const {
3478e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar    return "__DATA,__cfstring";
3488e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar  }
3498e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar
3502bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian  /// getNSStringSection - Return the section to use for NSString
3512bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian  /// literals, or 0 if no special section is used.
3522bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian  virtual const char *getNSStringSection() const {
3532bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian    return "__OBJC,__cstring_object,regular,no_dead_strip";
3542bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian  }
3552bb5ddaff86ee73d2cea7ec1835978afc88a83f0Fariborz Jahanian
356ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian  /// getNSStringNonFragileABISection - Return the section to use for
357ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian  /// NSString literals, or 0 if no special section is used (NonFragile ABI).
358ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian  virtual const char *getNSStringNonFragileABISection() const {
359ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian    return "__DATA, __objc_stringobj, regular, no_dead_strip";
360ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian  }
361ec951e0c2fc0db00c36bc60c900331dde32c1b43Fariborz Jahanian
362797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// isValidSectionSpecifier - This is an optional hook that targets can
363797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// implement to perform semantic checking on attribute((section("foo")))
364797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// specifiers.  In this case, "foo" is passed in to be checked.  If the
365797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// section specifier is invalid, the backend should return a non-empty string
366797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// that indicates the problem.
367797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  ///
368797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// This hook is a simple quality of implementation feature to catch errors
369797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// and give good diagnostics in cases when the assembler or code generator
370797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  /// would otherwise reject the section specifier.
371797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  ///
372f959fb5fb82ae2cbdf8635d734613a01818fb7bfAnders Carlsson  virtual std::string isValidSectionSpecifier(llvm::StringRef SR) const {
373797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner    return "";
374797c3c4f5dc4fda735e55c6b5d6270a54cf6d263Chris Lattner  }
3758e5c2b8072f4409c7c0004331d1db9652d5209c0Daniel Dunbar
376a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson  /// setForcedLangOptions - Set forced language options.
377a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson  /// Apply changes to the target information with respect to certain
378a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson  /// language options which change the target configuration.
379a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson  virtual void setForcedLangOptions(LangOptions &Opts);
380a6fda124bf380479529d6a80b84b62cacd3cb707John Thompson
381868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar  /// getDefaultFeatures - Get the default set of target features for
382868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar  /// the \args CPU; this should include all legal feature strings on
383868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar  /// the target.
3841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual void getDefaultFeatures(const std::string &CPU,
38517ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar                                  llvm::StringMap<bool> &Features) const {
38617ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  }
38717ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar
388018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar  /// getABI - Get the ABI in use.
389018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar  virtual const char *getABI() const {
390018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar    return "";
391018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar  }
392018ba5ab0671d9b6eefecaffc118c869bea151a1Daniel Dunbar
393eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  /// setCPU - Target the specific CPU.
394eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  ///
395eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  /// \return - False on error (invalid CPU name).
396eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  //
397eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  // FIXME: Remove this.
398eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  virtual bool setCPU(const std::string &Name) {
399eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar    return true;
400eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar  }
401eac7c53f16bc12bcd9baac756b6f9bb77b74b0adDaniel Dunbar
40273b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  /// setABI - Use the specific ABI.
40373b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  ///
40473b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  /// \return - False on error (invalid ABI name).
40573b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  virtual bool setABI(const std::string &Name) {
40673b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar    return false;
40773b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar  }
40873b79596bac6f6169e5979d0c7241924259d2a76Daniel Dunbar
40917ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  /// setFeatureEnabled - Enable or disable a specific target feature,
41017ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  /// the feature name must be valid.
41117ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  ///
41217ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  /// \return - False on error (invalid feature name).
41317ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar  virtual bool setFeatureEnabled(llvm::StringMap<bool> &Features,
41417ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar                                 const std::string &Name,
41517ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar                                 bool Enabled) const {
41617ca3638e852ba81f389e9f896ed0420b52ae606Daniel Dunbar    return false;
417868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar  }
418868bd0aa9281929ef50d2e9a8c82a036906f53f5Daniel Dunbar
41929a790ba422cfeeea9546b6e76777d98fa73cd67Daniel Dunbar  /// HandleTargetOptions - Perform initialization based on the user configured
42029a790ba422cfeeea9546b6e76777d98fa73cd67Daniel Dunbar  /// set of features (e.g., +sse4). The list is guaranteed to have at most one
42129a790ba422cfeeea9546b6e76777d98fa73cd67Daniel Dunbar  /// entry per feature.
422b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  ///
423b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// The target may modify the features list, to change which options are
424b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  /// passed onwards to the backend.
425b93292ab7f2b3d43a9e0ad6421f572d1f5a323b4Daniel Dunbar  virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
42616167a6e3f7dfb7ed0babc5e0baab9fd140e959dChris Lattner  }
427264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov
428264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov  // getRegParmMax - Returns maximal number of args passed in registers.
429264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov  unsigned getRegParmMax() const {
430264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov    return RegParmMax;
431264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov  }
432264a76cdf382c507f4d43e64c89f1503f003ac95Anton Korobeynikov
43321fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  /// isTLSSupported - Whether the target supports thread-local storage.
4346a3bc6df36848188e9d0c1d978170c2b0918c6a3Chris Lattner  bool isTLSSupported() const {
435b030f0272500c6c5602f587ac029ee0dc0e5a05cEli Friedman    return TLSSupported;
436b030f0272500c6c5602f587ac029ee0dc0e5a05cEli Friedman  }
43721fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner
4389bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  /// hasNoAsmVariants - Return true if {|} are normal characters in the
4399bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  /// asm string.  If this returns false (the default), then {abc|xyz} is syntax
44037de281ac149a5c5f14e4935a3738d87370da3edChris Lattner  /// that says that when compiling for asm variant #0, "abc" should be
4419bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  /// generated, but when compiling for asm variant #1, "xyz" should be
4429bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  /// generated.
4439bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  bool hasNoAsmVariants() const {
4449bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner    return NoAsmVariants;
4459bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner  }
4469bffb0701d02a10e77e1ac0f196074eed6466ed0Chris Lattner
44721fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  /// getEHDataRegisterNumber - Return the register number that
44821fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  /// __builtin_eh_return_regno would return with the specified argument.
44921fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  virtual int getEHDataRegisterNumber(unsigned RegNo) const {
45021fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner    return -1;
45121fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner  }
45221fb98ee003e992b0c4e204d98a19e0ef544cae3Chris Lattner
453b030f0272500c6c5602f587ac029ee0dc0e5a05cEli Friedman
4540eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattnerprotected:
4550e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner  virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
4560e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner    return PointerWidth;
4570e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner  }
4580e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner  virtual uint64_t getPointerAlignV(unsigned AddrSpace) const {
4590e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner    return PointerAlign;
4600e5d4ef3155651af17a90fdc07d9f80b33935c0cChris Lattner  }
46131fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta  virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const {
46231fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta    return PtrDiffType;
46331fc07df7f0fc89ebf83ca05a20b29de45a7598dSanjiv Gupta  }
4641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual void getGCCRegNames(const char * const *&Names,
4650eaed12e634dfd14f44620f63b8d3276fed028ddChris Lattner                              unsigned &NumNames) const = 0;
4661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
4673346ae6bba10da0d08c8d548134ddab4e13d040fAnders Carlsson                                unsigned &NumAliases) const = 0;
4681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump  virtual bool validateAsmConstraint(const char *&Name,
469d04c6e23f2e10eeb9936778d67f4a1c4a14cc4f6Anders Carlsson                                     TargetInfo::ConstraintInfo &info) const= 0;
4705f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer};
4715f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
4725f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}  // end namespace clang
4735f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
4745f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif
475