[cfe-commits] r55098 - /cfe/trunk/lib/Basic/Targets.cpp

Eli Friedman eli.friedman at gmail.com
Wed Aug 20 18:40:20 PDT 2008


Author: efriedma
Date: Wed Aug 20 20:40:19 2008
New Revision: 55098

URL: http://llvm.org/viewvc/llvm-project?rev=55098&view=rev
Log:
Initial implementation of Windows x86 target; at the moment, the only 
difference from generic x86 is the defines.  The rest is non-trivial to 
implement.

I'm not planning on adding any more targets myself; if there are any 
targets anyone is currently using that are missing, feel free to add 
them, or ask me to add them.

This concludes the work I'm planning for the TargetInfo 
implementations at the moment; all the other issues with TargetInfo require
some API changes, and I haven't really thought it through.  Some of the
remaining issues: allowing targets to define size_t and wchar_t properly,
adding some sort of __builtin_type_info intrinsic so we can finish clang's 
limits.h and float.h and get rid of a massive number of macro 
definitions, allowing target-specific command-line options, allowing
target-specific defaults for certain command-line options like
-fms-extensions, exposing vector alignment outside of the description 
string, exposing endianness outside of the description string, allowing 
targets to expose special bit-field layout requirements, exposing some 
sort of custom hook for call generation in CodeGen, and adding CPU 
selection to control defines like __SSE__.


Modified:
    cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=55098&r1=55097&r2=55098&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Aug 20 20:40:19 2008
@@ -673,6 +673,33 @@
 } // end anonymous namespace
 
 namespace {
+// x86-32 Windows target
+class WindowsX86_32TargetInfo : public X86_32TargetInfo {
+public:
+  WindowsX86_32TargetInfo(const std::string& triple)
+    : X86_32TargetInfo(triple) {
+    // FIXME: Fix wchar_t.
+    // FIXME: We should probably enable -fms-extensions by default for
+    // this target.
+  }
+  virtual void getTargetDefines(std::vector<char> &Defines) const {
+    X86_32TargetInfo::getTargetDefines(Defines);
+    // This list is based off of the the list of things MingW defines
+    Define(Defines, "__WIN32__");
+    Define(Defines, "__WIN32");
+    Define(Defines, "_WIN32");
+    Define(Defines, "WIN32");
+    Define(Defines, "__WINNT__");
+    Define(Defines, "__WINNT");
+    Define(Defines, "WINNT");
+    Define(Defines, "_WIN32");
+    Define(Defines, "_X86_");
+    Define(Defines, "__MSVCRT__");
+  }
+};
+} // end anonymous namespace
+
+namespace {
 // x86-64 generic target
 class X86_64TargetInfo : public X86TargetInfo {
 public:
@@ -935,6 +962,8 @@
       return new DarwinI386TargetInfo(T);
     if (isLinux)
       return new LinuxX86_32TargetInfo(T);
+    if (isWindows)
+      return new WindowsX86_32TargetInfo(T);
     return new X86_32TargetInfo(T);
   }
 





More information about the cfe-commits mailing list