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__.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55098 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index 73bffd9..761bbcb 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -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);
   }