[PATCH] D107086: [Lanai] fix lowering wide returns

Serge Bazanski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 29 09:36:40 PDT 2021


q3k created this revision.
Herald added a subscriber: hiraditya.
q3k requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This implements LanaiTargetLowering::CanLowerReturn, thereby ensuring
all return values conform to the RetCC and get sret-demoted as
necessary.

A regression test is also added that exercises this functionality.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107086

Files:
  llvm/lib/Target/Lanai/LanaiISelLowering.cpp
  llvm/lib/Target/Lanai/LanaiISelLowering.h
  llvm/test/CodeGen/Lanai/lowering-128.ll


Index: llvm/test/CodeGen/Lanai/lowering-128.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/Lanai/lowering-128.ll
@@ -0,0 +1,14 @@
+; RUN: llc -march=lanai < %s | FileCheck %s
+
+; Tests that lowering wide registers (128 bits or more) works on Lanai.
+; The emitted assembly is not checked, we just do a smoketest.
+
+target datalayout = "E-m:e-p:32:32-i64:64-a:0:32-n32-S64"
+target triple = "lanai"
+
+; CHECK-LABEL: add128:
+define i128 @add128(i128 %x, i128 %y) {
+  %a = add i128 %x, %y
+  ret i128 %a
+}
+
Index: llvm/lib/Target/Lanai/LanaiISelLowering.h
===================================================================
--- llvm/lib/Target/Lanai/LanaiISelLowering.h
+++ llvm/lib/Target/Lanai/LanaiISelLowering.h
@@ -90,6 +90,11 @@
   SDValue LowerSRL_PARTS(SDValue Op, SelectionDAG &DAG) const;
   SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
 
+  bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
+                      bool isVarArg,
+                      const SmallVectorImpl<ISD::OutputArg> &Outs,
+                      LLVMContext &Context) const override;
+
   Register getRegisterByName(const char *RegName, LLT VT,
                              const MachineFunction &MF) const override;
   std::pair<unsigned, const TargetRegisterClass *>
Index: llvm/lib/Target/Lanai/LanaiISelLowering.cpp
===================================================================
--- llvm/lib/Target/Lanai/LanaiISelLowering.cpp
+++ llvm/lib/Target/Lanai/LanaiISelLowering.cpp
@@ -530,6 +530,15 @@
   return Chain;
 }
 
+bool LanaiTargetLowering::CanLowerReturn(
+    CallingConv::ID CallConv, MachineFunction &MF, bool IsVarArg,
+    const SmallVectorImpl<ISD::OutputArg> &Outs, LLVMContext &Context) const {
+  SmallVector<CCValAssign, 16> RVLocs;
+  CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, Context);
+
+  return CCInfo.CheckReturn(Outs, RetCC_Lanai32);
+}
+
 SDValue
 LanaiTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
                                  bool IsVarArg,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107086.362810.patch
Type: text/x-patch
Size: 2089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210729/812cbd46/attachment.bin>


More information about the llvm-commits mailing list