[cfe-commits] r38978 - /cfe/cfe/trunk/Driver/Targets.cpp
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:26:27 PDT 2007
Author: sabre
Date: Wed Jul 11 11:26:27 2007
New Revision: 38978
URL: http://llvm.org/viewvc/llvm-project?rev=38978&view=rev
Log:
Implement TargetInfo hooks for #defines
Modified:
cfe/cfe/trunk/Driver/Targets.cpp
Modified: cfe/cfe/trunk/Driver/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Driver/Targets.cpp?rev=38978&r1=38977&r2=38978&view=diff
==============================================================================
--- cfe/cfe/trunk/Driver/Targets.cpp (original)
+++ cfe/cfe/trunk/Driver/Targets.cpp Wed Jul 11 11:26:27 2007
@@ -37,49 +37,76 @@
clEnumValEnd));
//===----------------------------------------------------------------------===//
-// Common code shared among the Darwin targets.
+// Common code shared among targets.
//===----------------------------------------------------------------------===//
namespace {
class DarwinTargetInfo : public TargetInfoImpl {
public:
-
- // nothing so far.
+ virtual void getTargetDefines(std::vector<std::string> &Defines) const {
+ Defines.push_back("__APPLE__");
+ }
+
};
} // end anonymous namespace.
+/// getPowerPCDefines - Return a set of the PowerPC-specific #defines that are
+/// not tied to a specific subtarget.
+static void getPowerPCDefines(std::vector<std::string> &Defines, bool is64Bit) {
+ Defines.push_back("__ppc__");
+
+}
+
+/// getX86Defines - Return a set of the X86-specific #defines that are
+/// not tied to a specific subtarget.
+static void getX86Defines(std::vector<std::string> &Defines, bool is64Bit) {
+ Defines.push_back("__i386__");
+
+}
+
//===----------------------------------------------------------------------===//
// Specific target implementations.
//===----------------------------------------------------------------------===//
-// FIXME: Move target-specific preprocessor definitions here.
namespace {
class DarwinPPCTargetInfo : public DarwinTargetInfo {
public:
- // nothing so far.
+ virtual void getTargetDefines(std::vector<std::string> &Defines) const {
+ DarwinTargetInfo::getTargetDefines(Defines);
+ getPowerPCDefines(Defines, false);
+ }
};
} // end anonymous namespace.
namespace {
class DarwinPPC64TargetInfo : public DarwinTargetInfo {
public:
- // nothing so far.
+ virtual void getTargetDefines(std::vector<std::string> &Defines) const {
+ DarwinTargetInfo::getTargetDefines(Defines);
+ getPowerPCDefines(Defines, true);
+ }
};
} // end anonymous namespace.
namespace {
class DarwinI386TargetInfo : public DarwinTargetInfo {
public:
- // nothing so far.
+ virtual void getTargetDefines(std::vector<std::string> &Defines) const {
+ DarwinTargetInfo::getTargetDefines(Defines);
+ getX86Defines(Defines, false);
+ }
};
} // end anonymous namespace.
namespace {
class DarwinX86_64TargetInfo : public DarwinTargetInfo {
public:
- // nothing so far.
+ virtual void getTargetDefines(std::vector<std::string> &Defines) const {
+ DarwinTargetInfo::getTargetDefines(Defines);
+ getX86Defines(Defines, true);
+ }
};
} // end anonymous namespace.
@@ -90,6 +117,11 @@
// Note: I have no idea if this is right, just for testing.
WCharWidth = 2;
}
+
+ virtual void getTargetDefines(std::vector<std::string> &Defines) const {
+ // TODO: linux-specific stuff.
+ getX86Defines(Defines, false);
+ }
};
} // end anonymous namespace.
More information about the cfe-commits
mailing list