[PATCH] D127412: [Systemz/z/OS] Add llvm.read_register() intrinsic support for zOS
Yusra Syeda via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 9 09:04:40 PDT 2022
yusra.syeda created this revision.
yusra.syeda added reviewers: uweigand, Kai, Everybody0523, abhina.sreeskantharajan.
Herald added a subscriber: hiraditya.
Herald added a project: All.
yusra.syeda requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch adds the llvm.read_register() intrinsic for zOS by adding support for the getRegisterByName() function.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D127412
Files:
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
llvm/test/CodeGen/SystemZ/zos-stackpointer.ll
Index: llvm/test/CodeGen/SystemZ/zos-stackpointer.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/SystemZ/zos-stackpointer.ll
@@ -0,0 +1,16 @@
+; RUN: llc < %s -mtriple=s390x-ibm-zos | FileCheck %s
+
+; CHECK-LABEL: get_stack:
+; CHECK: lgr 3, 4
+; CHECK: b 2(7)
+
+define i8* @get_stack() nounwind {
+entry:
+ %0 = call i64 @llvm.read_register.i64(metadata !0)
+ %1 = inttoptr i64 %0 to i8*
+ ret i8* %1
+}
+
+declare i64 @llvm.read_register.i64(metadata) nounwind
+
+!0 = !{!"r4"}
Index: llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
===================================================================
--- llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -1258,12 +1258,16 @@
// FIXME? Maybe this could be a TableGen attribute on some registers and
// this table could be generated automatically from RegInfo.
-Register SystemZTargetLowering::getRegisterByName(const char *RegName, LLT VT,
- const MachineFunction &MF) const {
+Register
+SystemZTargetLowering::getRegisterByName(const char *RegName, LLT VT,
+ const MachineFunction &MF) const {
+ const SystemZSubtarget *Subtarget = &MF.getSubtarget<SystemZSubtarget>();
- Register Reg = StringSwitch<Register>(RegName)
- .Case("r15", SystemZ::R15D)
- .Default(0);
+ Register Reg =
+ StringSwitch<Register>(RegName)
+ .Case("r4", Subtarget->isTargetXPLINK64() ? SystemZ::R4D : 0)
+ .Case("r15", Subtarget->isTargetELF() ? SystemZ::R15D : 0)
+ .Default(0);
if (Reg)
return Reg;
report_fatal_error("Invalid register name global variable");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127412.435581.patch
Type: text/x-patch
Size: 1799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220609/8f86fd0d/attachment-0001.bin>
More information about the llvm-commits
mailing list