[cfe-commits] r51319 - in /cfe/trunk: include/clang/Basic/TargetInfo.h lib/Basic/TargetInfo.cpp lib/Basic/Targets.cpp
Eli Friedman
eli.friedman at gmail.com
Tue May 20 07:21:01 PDT 2008
Author: efriedma
Date: Tue May 20 09:21:01 2008
New Revision: 51319
URL: http://llvm.org/viewvc/llvm-project?rev=51319&view=rev
Log:
Some small changes to make the target info a bit more accurate.
Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=51319&r1=51318&r2=51319&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue May 20 09:21:01 2008
@@ -38,7 +38,9 @@
unsigned char PointerWidth, PointerAlign;
unsigned char WCharWidth, WCharAlign;
unsigned char IntWidth, IntAlign;
+ unsigned char FloatWidth, FloatAlign;
unsigned char DoubleWidth, DoubleAlign;
+ unsigned char LongDoubleWidth, LongDoubleAlign;
unsigned char LongWidth, LongAlign;
unsigned char LongLongWidth, LongLongAlign;
@@ -114,8 +116,8 @@
unsigned getWCharAlign() const { return WCharAlign; }
/// getFloatWidth/Align/Format - Return the size/align/format of 'float'.
- unsigned getFloatWidth() const { return 32; } // FIXME
- unsigned getFloatAlign() const { return 32; } // FIXME
+ unsigned getFloatWidth() const { return FloatWidth; }
+ unsigned getFloatAlign() const { return FloatAlign; }
const llvm::fltSemantics *getFloatFormat() const { return FloatFormat; }
/// getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
@@ -125,8 +127,8 @@
/// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long
/// double'.
- unsigned getLongDoubleWidth() const { return 64; } // FIXME
- unsigned getLongDoubleAlign() const { return 64; } // FIXME
+ unsigned getLongDoubleWidth() const { return LongDoubleWidth; }
+ unsigned getLongDoubleAlign() const { return LongDoubleAlign; }
const llvm::fltSemantics *getLongDoubleFormat() const {
return LongDoubleFormat;
}
Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=51319&r1=51318&r2=51319&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Tue May 20 09:21:01 2008
@@ -21,15 +21,21 @@
// TargetInfo Constructor.
TargetInfo::TargetInfo(const std::string &T) : Triple(T) {
- // Set defaults. These should be overridden by concrete targets as needed.
+ // Set defaults. Defaults are set for a 32-bit RISC platform,
+ // like PPC or SPARC.
+ // These should be overridden by concrete targets as needed.
CharIsSigned = true;
PointerWidth = PointerAlign = 32;
WCharWidth = WCharAlign = 32;
IntWidth = IntAlign = 32;
LongWidth = LongAlign = 32;
LongLongWidth = LongLongAlign = 64;
+ FloatWidth = 32;
+ FloatAlign = 32;
DoubleWidth = 64;
- DoubleAlign = 32;
+ DoubleAlign = 64;
+ LongDoubleWidth = 64;
+ LongDoubleAlign = 64;
FloatFormat = &llvm::APFloat::IEEEsingle;
DoubleFormat = &llvm::APFloat::IEEEdouble;
LongDoubleFormat = &llvm::APFloat::IEEEdouble;
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=51319&r1=51318&r2=51319&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue May 20 09:21:01 2008
@@ -697,8 +697,13 @@
namespace {
class DarwinI386TargetInfo : public DarwinTargetInfo {
public:
- DarwinI386TargetInfo(const std::string& triple) : DarwinTargetInfo(triple) {}
-
+ DarwinI386TargetInfo(const std::string& triple) : DarwinTargetInfo(triple) {
+ DoubleAlign = LongLongAlign = 32;
+ LongDoubleWidth = 96;
+ LongDoubleAlign = 32;
+ LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
+ }
+
virtual void getTargetDefines(std::vector<char> &Defines) const {
DarwinTargetInfo::getTargetDefines(Defines);
getX86Defines(Defines, false);
@@ -741,6 +746,9 @@
public:
DarwinX86_64TargetInfo(const std::string& triple) : DarwinTargetInfo(triple) {
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
+ LongDoubleWidth = 128;
+ LongDoubleAlign = 128;
+ LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
}
virtual void getTargetDefines(std::vector<char> &Defines) const {
@@ -782,7 +790,9 @@
namespace {
class DarwinARMTargetInfo : public DarwinTargetInfo {
public:
- DarwinARMTargetInfo(const std::string& triple) :DarwinTargetInfo(triple) {}
+ DarwinARMTargetInfo(const std::string& triple) :DarwinTargetInfo(triple) {
+ // FIXME: Are the defaults corrent for ARM?
+ }
virtual void getTargetDefines(std::vector<char> &Defines) const {
DarwinTargetInfo::getTargetDefines(Defines);
@@ -871,7 +881,10 @@
class PIC16TargetInfo : public TargetInfo{
public:
PIC16TargetInfo(const std::string& triple) : TargetInfo(triple) {
- IntWidth = IntAlign = 16;
+ // FIXME: Is IntAlign really supposed to be 16? There seems
+ // little point on a platform with 8-bit loads.
+ IntWidth = IntAlign = LongAlign = LongLongAlign = PointerWidth = 16;
+ PointerAlign = 8;
}
virtual uint64_t getPointerWidthV(unsigned AddrSpace) const { return 16; }
virtual uint64_t getPointerAlignV(unsigned AddrSpace) const { return 8; }
@@ -909,25 +922,25 @@
TargetInfo* TargetInfo::CreateTargetInfo(const std::string &T) {
if (T.find("ppc-") == 0 || T.find("powerpc-") == 0)
return new DarwinPPCTargetInfo(T);
-
+
if (T.find("ppc64-") == 0 || T.find("powerpc64-") == 0)
return new DarwinPPC64TargetInfo(T);
-
+
if (T.find("armv6-") == 0 || T.find("arm-") == 0)
return new DarwinARMTargetInfo(T);
if (T.find("sparc-") == 0)
return new SolarisSparcV8TargetInfo(T); // ugly hack
-
+
if (T.find("x86_64-") == 0)
return new DarwinX86_64TargetInfo(T);
-
+
if (T.find("pic16-") == 0)
return new PIC16TargetInfo(T);
if (IsX86(T))
return new DarwinI386TargetInfo(T);
-
+
return NULL;
}
More information about the cfe-commits
mailing list