[clang] [flang] [flang] Add MSC_VER and target arch defines when targeting the MSVC ABI (PR #73250)

David Truby via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 30 08:23:46 PST 2023


================
@@ -204,6 +204,29 @@ void Flang::AddAArch64TargetArgs(const ArgList &Args,
   }
 }
 
+static void addVSDefines(const ToolChain &TC, const ArgList &Args,
+                         ArgStringList &CmdArgs) {
+
+  unsigned ver = 0;
+  const VersionTuple vt = TC.computeMSVCVersion(nullptr, Args);
+  ver = vt.getMajor() * 10000000 + vt.getMinor().value_or(0) * 100000 +
+        vt.getSubminor().value_or(0);
+  CmdArgs.push_back(Args.MakeArgString("-D_MSC_VER=" + Twine(ver / 100000)));
+  CmdArgs.push_back(Args.MakeArgString("-D_MSC_FULL_VER=" + Twine(ver)));
+
+  llvm::Triple triple = TC.getTriple();
+  if (triple.isAArch64()) {
+    CmdArgs.push_back("-D_M_ARM64=1");
+  } else if (triple.isX86() && triple.isArch32Bit()) {
+    CmdArgs.push_back("-D_M_IX86=600");
+  } else if (triple.isX86() && triple.isArch64Bit()) {
+    CmdArgs.push_back("-D_M_X64=100");
+  } else {
+    llvm_unreachable(
+        "Flang on Windows only supports X86_32, X86_64 and AArch64");
+  }
----------------
DavidTruby wrote:

We don't support 32 bit _hosts_ but I think we do support 32 bit _targets_

https://github.com/llvm/llvm-project/pull/73250


More information about the cfe-commits mailing list