diff options
author | Chris Lattner <sabre@nondot.org> | 2008-03-08 08:24:01 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-03-08 08:24:01 +0000 |
commit | 0eaed12e634dfd14f44620f63b8d3276fed028dd (patch) | |
tree | e133894632a9b0892959565fa450777e945bd806 /include/clang/Basic | |
parent | 390161183919169c493916efac4c1e1b3828fea6 (diff) |
eliminate the TargetInfoImpl stuff, simplifying the target implementations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48049 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic')
-rw-r--r-- | include/clang/Basic/TargetInfo.h | 138 |
1 files changed, 42 insertions, 96 deletions
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h index 557a7160bb..ec6030135a 100644 --- a/include/clang/Basic/TargetInfo.h +++ b/include/clang/Basic/TargetInfo.h @@ -22,7 +22,6 @@ namespace llvm { struct fltSemantics; } namespace clang { -class TargetInfoImpl; class Diagnostic; class SourceManager; @@ -31,105 +30,105 @@ namespace Builtin { struct Info; } /// TargetInfo - This class exposes information about the current target. /// class TargetInfo { - /// Primary - This tracks the primary target in the target set. - /// - const TargetInfoImpl *Target; - + std::string Triple; +protected: /// These are all caches for target values. unsigned WCharWidth, WCharAlign; //==----------------------------------------------------------------==/ // TargetInfo Construction. //==----------------------------------------------------------------==/ - - TargetInfo(const TargetInfoImpl *TII); + TargetInfo(const std::string &T) : Triple(T) { + // Set defaults. + WCharWidth = WCharAlign = 32; + } public: /// CreateTargetInfo - Return the target info object for the specified target /// triple. static TargetInfo* CreateTargetInfo(const std::string &Triple); - ~TargetInfo(); + virtual ~TargetInfo(); ///===---- Target property query methods --------------------------------===// /// getTargetDefines - Appends the target-specific #define values for this /// target set to the specified buffer. - void getTargetDefines(std::vector<char> &DefineBuffer); + virtual void getTargetDefines(std::vector<char> &DefineBuffer) const = 0; /// isCharSigned - Return true if 'char' is 'signed char' or false if it is /// treated as 'unsigned char'. This is implementation defined according to /// C99 6.2.5p15. In our implementation, this is target-specific. - bool isCharSigned() { + bool isCharSigned() const { // FIXME: implement correctly. return true; } /// getPointerWidth - Return the width of pointers on this target, we /// currently assume one pointer type. - void getPointerInfo(uint64_t &Size, unsigned &Align) { + void getPointerInfo(uint64_t &Size, unsigned &Align) const { Size = 32; // FIXME: implement correctly. Align = 32; } /// getBoolInfo - Return the size of '_Bool' and C++ 'bool' for this target, /// in bits. - void getBoolInfo(uint64_t &Size, unsigned &Align) { + void getBoolInfo(uint64_t &Size, unsigned &Align) const { Size = Align = 8; // FIXME: implement correctly: wrong for ppc32. } /// getCharInfo - Return the size of 'char', 'signed char' and /// 'unsigned char' for this target, in bits. - void getCharInfo(uint64_t &Size, unsigned &Align) { + void getCharInfo(uint64_t &Size, unsigned &Align) const { Size = Align = 8; // FIXME: implement correctly. } /// getShortInfo - Return the size of 'signed short' and 'unsigned short' for /// this target, in bits. - void getShortInfo(uint64_t &Size, unsigned &Align) { + void getShortInfo(uint64_t &Size, unsigned &Align) const { Size = Align = 16; // FIXME: implement correctly. } /// getIntInfo - Return the size of 'signed int' and 'unsigned int' for this /// target, in bits. - void getIntInfo(uint64_t &Size, unsigned &Align) { + void getIntInfo(uint64_t &Size, unsigned &Align) const { Size = Align = 32; // FIXME: implement correctly. } /// getLongInfo - Return the size of 'signed long' and 'unsigned long' for /// this target, in bits. - void getLongInfo(uint64_t &Size, unsigned &Align) { + void getLongInfo(uint64_t &Size, unsigned &Align) const { Size = Align = 32; // FIXME: implement correctly: wrong for ppc64/x86-64 } /// getLongLongInfo - Return the size of 'signed long long' and /// 'unsigned long long' for this target, in bits. - void getLongLongInfo(uint64_t &Size, unsigned &Align) { + void getLongLongInfo(uint64_t &Size, unsigned &Align) const { Size = Align = 64; // FIXME: implement correctly. } /// getFloatInfo - Characterize 'float' for this target. void getFloatInfo(uint64_t &Size, unsigned &Align, - const llvm::fltSemantics *&Format); + const llvm::fltSemantics *&Format) const; /// getDoubleInfo - Characterize 'double' for this target. void getDoubleInfo(uint64_t &Size, unsigned &Align, - const llvm::fltSemantics *&Format); + const llvm::fltSemantics *&Format) const; /// getLongDoubleInfo - Characterize 'long double' for this target. void getLongDoubleInfo(uint64_t &Size, unsigned &Align, - const llvm::fltSemantics *&Format); + const llvm::fltSemantics *&Format) const; /// getWCharInfo - Return the size of wchar_t in bits. /// - void getWCharInfo(uint64_t &Size, unsigned &Align) { + void getWCharInfo(uint64_t &Size, unsigned &Align) const { Size = WCharWidth; Align = WCharAlign; } /// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this /// target, in bits. - unsigned getIntMaxTWidth() { + unsigned getIntMaxTWidth() const { // FIXME: implement correctly. return 64; } @@ -137,12 +136,12 @@ public: /// getTargetBuiltins - Return information about target-specific builtins for /// the current primary target, and info about which builtins are non-portable /// across the current set of primary and secondary targets. - void getTargetBuiltins(const Builtin::Info *&Records, - unsigned &NumRecords) const; + virtual void getTargetBuiltins(const Builtin::Info *&Records, + unsigned &NumRecords) const = 0; /// getVAListDeclaration - Return the declaration to use for /// __builtin_va_list, which is target-specific. - const char *getVAListDeclaration() const; + virtual const char *getVAListDeclaration() const = 0; /// isValidGCCRegisterName - Returns whether the passed in string /// is a valid register name according to GCC. This is used by Sema for @@ -167,20 +166,22 @@ public: bool validateInputConstraint (const char *Name, unsigned NumOutputs, ConstraintInfo &info) const; - std::string convertConstraint(const char Constraint) const; + virtual std::string convertConstraint(const char Constraint) const { + return std::string(1, Constraint); + } // Returns a string of target-specific clobbers, in LLVM format. - const char *getClobbers() const; + virtual const char *getClobbers() const = 0; ///===---- Some helper methods ------------------------------------------===// - unsigned getBoolWidth() { + unsigned getBoolWidth() const { uint64_t Size; unsigned Align; getBoolInfo(Size, Align); return static_cast<unsigned>(Size); } - unsigned getCharWidth(bool isWide = false) { + unsigned getCharWidth(bool isWide = false) const { uint64_t Size; unsigned Align; if (isWide) getWCharInfo(Size, Align); @@ -189,25 +190,25 @@ public: return static_cast<unsigned>(Size); } - unsigned getWCharWidth() { + unsigned getWCharWidth() const { uint64_t Size; unsigned Align; getWCharInfo(Size, Align); return static_cast<unsigned>(Size); } - unsigned getIntWidth() { + unsigned getIntWidth() const { uint64_t Size; unsigned Align; getIntInfo(Size, Align); return static_cast<unsigned>(Size); } - unsigned getLongWidth() { + unsigned getLongWidth() const { uint64_t Size; unsigned Align; getLongInfo(Size, Align); return static_cast<unsigned>(Size); } - unsigned getLongLongWidth() { + unsigned getLongLongWidth() const { uint64_t Size; unsigned Align; getLongLongInfo(Size, Align); return static_cast<unsigned>(Size); @@ -215,10 +216,12 @@ public: /// getTargetPrefix - Return the target prefix used for identifying /// llvm intrinsics. - const char *getTargetPrefix() const; + virtual const char *getTargetPrefix() const = 0; /// getTargetTriple - Return the target triple of the primary target. - const char *getTargetTriple() const; + virtual const char *getTargetTriple() const { + return Triple.c_str(); + } const char *getTargetDescription() const { // FIXME ! @@ -226,76 +229,19 @@ public: return "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:\ 32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"; } -}; - - - - -/// TargetInfoImpl - This class is implemented for specific targets and is used -/// by the TargetInfo class. Target implementations should initialize instance -/// variables and implement various virtual methods if the default values are -/// not appropriate for the target. -class TargetInfoImpl { -protected: - unsigned WCharWidth; /// sizeof(wchar_t) in bits. Default value is 32. - unsigned WCharAlign; /// alignof(wchar_t) in bits. Default value is 32. - std::string Triple; -public: - TargetInfoImpl(const std::string& triple) - : WCharWidth(32), WCharAlign(32), Triple(triple) {} - - virtual ~TargetInfoImpl() {} - - /// getTargetTriple - Return the string representing the target triple this - /// TargetInfoImpl object was created from. - const char* getTargetTriple() const { return Triple.c_str(); } - - virtual const char *getTargetPrefix() const = 0; - - /// getTargetDefines - Return a list of the target-specific #define values set - /// when compiling to this target. Each string should be of the form - /// "#define X Y\n". - virtual void getTargetDefines(std::vector<char> &Defines) const = 0; - - /// getVAListDeclaration - Return the declaration to use for - /// __builtin_va_list, which is target-specific. - virtual const char *getVAListDeclaration() const = 0; - - /// getWCharWidth - Return the size of wchar_t in bits. - /// - void getWCharInfo(unsigned &Size, unsigned &Align) const { - Size = WCharWidth; - Align = WCharAlign; - } - - /// getTargetBuiltins - Return information about target-specific builtins for - /// the target. - virtual void getTargetBuiltins(const Builtin::Info *&Records, - unsigned &NumRecords) const { - Records = 0; - NumRecords = 0; - } - - virtual void getGCCRegNames(const char * const *&Names, - unsigned &NumNames) const = 0; struct GCCRegAlias { const char * const Aliases[5]; const char * const Register; }; + +protected: + virtual void getGCCRegNames(const char * const *&Names, + unsigned &NumNames) const = 0; virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, unsigned &NumAliases) const = 0; - virtual bool validateAsmConstraint(char c, TargetInfo::ConstraintInfo &info) const= 0; - - virtual std::string convertConstraint(const char Constraint) const { - return std::string(1, Constraint); - } - - virtual const char *getClobbers() const = 0; -private: - virtual void ANCHOR(); // out-of-line virtual method for class. }; } // end namespace clang |