[llvm] [RISCV][GISel] Support G_PTRTOINT and G_INTTOPTR (PR #69542)

Amara Emerson via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 18 19:15:22 PDT 2023


================
@@ -122,6 +122,17 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST) {
   getActionDefinitionsBuilder(G_PTR_ADD)
       .legalFor({{p0, XLenLLT}});
 
+  getActionDefinitionsBuilder(G_PTRTOINT)
+      .legalFor({XLenLLT, p0})
+      .widenScalarToNextPow2(0, XLen)
+      .clampScalar(0, XLenLLT, XLenLLT);
+
+  getActionDefinitionsBuilder(G_INTTOPTR)
+      .unsupportedIf([&](const LegalityQuery &Query) {
+        return Query.Types[0].getSizeInBits() != Query.Types[1].getSizeInBits();
+      })
----------------
aemerson wrote:

I don't think this is really needed, the code from AArch64 is ancient and MIR that doesn't meet this condition is probably malformed. We should delete it in AArch64 anyway.

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


More information about the llvm-commits mailing list