[PATCH] D24076: [ARM] Use __rt_div functions for DIVREM on Windows

Renato Golin via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 13 06:45:41 PDT 2016


rengolin added a comment.

Given that all of these changes are related to isTargetWindows everywhere, the assumption is that this can only work for windows. Once someone wants to use rt_div on non-Windows, we'll need to come up with a isWeirdABI which Windows and and that taget are members of, just like isEABI and others. So, for now, isWindows is ok.

Just a few more inline comments, and the tests and it should be good.


================
Comment at: lib/Target/ARM/ARMISelLowering.cpp:964-982
@@ -970,10 +963,21 @@
 
-    setLibcallName(RTLIB::SDIVREM_I8,  "__aeabi_idivmod");
-    setLibcallName(RTLIB::SDIVREM_I16, "__aeabi_idivmod");
-    setLibcallName(RTLIB::SDIVREM_I32, "__aeabi_idivmod");
-    setLibcallName(RTLIB::SDIVREM_I64, "__aeabi_ldivmod");
-    setLibcallName(RTLIB::UDIVREM_I8,  "__aeabi_uidivmod");
-    setLibcallName(RTLIB::UDIVREM_I16, "__aeabi_uidivmod");
-    setLibcallName(RTLIB::UDIVREM_I32, "__aeabi_uidivmod");
-    setLibcallName(RTLIB::UDIVREM_I64, "__aeabi_uldivmod");
+    if (Subtarget->isTargetWindows()) {
+      setLibcallName(RTLIB::SDIVREM_I8,  "__rt_sdiv");
+      setLibcallName(RTLIB::SDIVREM_I16, "__rt_sdiv");
+      setLibcallName(RTLIB::SDIVREM_I32, "__rt_sdiv");
+      setLibcallName(RTLIB::SDIVREM_I64, "__rt_sdiv64");
+      setLibcallName(RTLIB::UDIVREM_I8,  "__rt_udiv");
+      setLibcallName(RTLIB::UDIVREM_I16, "__rt_udiv");
+      setLibcallName(RTLIB::UDIVREM_I32, "__rt_udiv");
+      setLibcallName(RTLIB::UDIVREM_I64, "__rt_udiv64");
+    } else {
+      setLibcallName(RTLIB::SDIVREM_I8,  "__aeabi_idivmod");
+      setLibcallName(RTLIB::SDIVREM_I16, "__aeabi_idivmod");
+      setLibcallName(RTLIB::SDIVREM_I32, "__aeabi_idivmod");
+      setLibcallName(RTLIB::SDIVREM_I64, "__aeabi_ldivmod");
+      setLibcallName(RTLIB::UDIVREM_I8,  "__aeabi_uidivmod");
+      setLibcallName(RTLIB::UDIVREM_I16, "__aeabi_uidivmod");
+      setLibcallName(RTLIB::UDIVREM_I32, "__aeabi_uidivmod");
+      setLibcallName(RTLIB::UDIVREM_I64, "__aeabi_uldivmod");
+    }
 
----------------
Ah, makes sense. Looks good this way.

================
Comment at: lib/Target/ARM/ARMISelLowering.cpp:12206-12207
@@ -12248,3 +12205,4 @@
   for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
-    EVT ArgVT = N->getOperand(i).getValueType();
+    unsigned src = Subtarget->isTargetWindows() ? e - 1 - i : i;
+    EVT ArgVT = N->getOperand(src).getValueType();
     Type *ArgTy = ArgVT.getTypeForEVT(*Context);
----------------
No, don't change the SDNode, just std::swap the two arguments in Args after the loop.


https://reviews.llvm.org/D24076





More information about the llvm-commits mailing list