[llvm] r367104 - [MIPS GlobalISel] Select inttoptr and ptrtoint
Petar Avramovic via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 26 06:08:06 PDT 2019
Author: petar.avramovic
Date: Fri Jul 26 06:08:06 2019
New Revision: 367104
URL: http://llvm.org/viewvc/llvm-project?rev=367104&view=rev
Log:
[MIPS GlobalISel] Select inttoptr and ptrtoint
Select G_INTTOPTR and G_PTRTOINT for MIPS32.
Differential Revision: https://reviews.llvm.org/D65217
Added:
llvm/trunk/test/CodeGen/Mips/GlobalISel/instruction-select/inttoptr_and_ptrtoint.mir
llvm/trunk/test/CodeGen/Mips/GlobalISel/legalizer/inttoptr_and_ptrtoint.mir
llvm/trunk/test/CodeGen/Mips/GlobalISel/llvm-ir/inttoptr_and_ptrtoint.ll
llvm/trunk/test/CodeGen/Mips/GlobalISel/regbankselect/inttoptr_and_ptrtoint.mir
Modified:
llvm/trunk/lib/Target/Mips/MipsInstructionSelector.cpp
llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp
llvm/trunk/lib/Target/Mips/MipsRegisterBankInfo.cpp
Modified: llvm/trunk/lib/Target/Mips/MipsInstructionSelector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstructionSelector.cpp?rev=367104&r1=367103&r2=367104&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsInstructionSelector.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsInstructionSelector.cpp Fri Jul 26 06:08:06 2019
@@ -265,6 +265,11 @@ bool MipsInstructionSelector::select(Mac
.add(I.getOperand(2));
break;
}
+ case G_INTTOPTR:
+ case G_PTRTOINT: {
+ I.setDesc(TII.get(COPY));
+ return selectCopy(I, MRI);
+ }
case G_FRAME_INDEX: {
MI = BuildMI(MBB, I, I.getDebugLoc(), TII.get(Mips::ADDiu))
.add(I.getOperand(0))
Modified: llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp?rev=367104&r1=367103&r2=367104&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp Fri Jul 26 06:08:06 2019
@@ -89,9 +89,12 @@ MipsLegalizerInfo::MipsLegalizerInfo(con
.legalFor({s32})
.clampScalar(0, s32, s32);
- getActionDefinitionsBuilder(G_GEP)
+ getActionDefinitionsBuilder({G_GEP, G_INTTOPTR})
.legalFor({{p0, s32}});
+ getActionDefinitionsBuilder(G_PTRTOINT)
+ .legalFor({{s32, p0}});
+
getActionDefinitionsBuilder(G_FRAME_INDEX)
.legalFor({p0});
Modified: llvm/trunk/lib/Target/Mips/MipsRegisterBankInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsRegisterBankInfo.cpp?rev=367104&r1=367103&r2=367104&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsRegisterBankInfo.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsRegisterBankInfo.cpp Fri Jul 26 06:08:06 2019
@@ -388,6 +388,8 @@ MipsRegisterBankInfo::getInstrMapping(co
case G_ZEXTLOAD:
case G_SEXTLOAD:
case G_GEP:
+ case G_INTTOPTR:
+ case G_PTRTOINT:
case G_AND:
case G_OR:
case G_XOR:
Added: llvm/trunk/test/CodeGen/Mips/GlobalISel/instruction-select/inttoptr_and_ptrtoint.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/GlobalISel/instruction-select/inttoptr_and_ptrtoint.mir?rev=367104&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/GlobalISel/instruction-select/inttoptr_and_ptrtoint.mir (added)
+++ llvm/trunk/test/CodeGen/Mips/GlobalISel/instruction-select/inttoptr_and_ptrtoint.mir Fri Jul 26 06:08:06 2019
@@ -0,0 +1,51 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -O0 -mtriple=mipsel-linux-gnu -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32
+--- |
+
+ define void @inttoptr() {entry: ret void}
+ define void @ptrtoint() {entry: ret void}
+
+...
+---
+name: inttoptr
+alignment: 2
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1.entry:
+ liveins: $a0
+
+ ; MIPS32-LABEL: name: inttoptr
+ ; MIPS32: liveins: $a0
+ ; MIPS32: [[COPY:%[0-9]+]]:gpr32 = COPY $a0
+ ; MIPS32: $v0 = COPY [[COPY]]
+ ; MIPS32: RetRA implicit $v0
+ %0:gprb(s32) = COPY $a0
+ %1:gprb(p0) = G_INTTOPTR %0(s32)
+ $v0 = COPY %1(p0)
+ RetRA implicit $v0
+
+...
+---
+name: ptrtoint
+alignment: 2
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+body: |
+ bb.1.entry:
+ liveins: $a0
+
+ ; MIPS32-LABEL: name: ptrtoint
+ ; MIPS32: liveins: $a0
+ ; MIPS32: [[COPY:%[0-9]+]]:gpr32 = COPY $a0
+ ; MIPS32: $v0 = COPY [[COPY]]
+ ; MIPS32: RetRA implicit $v0
+ %0:gprb(p0) = COPY $a0
+ %1:gprb(s32) = G_PTRTOINT %0(p0)
+ $v0 = COPY %1(s32)
+ RetRA implicit $v0
+
+...
+
Added: llvm/trunk/test/CodeGen/Mips/GlobalISel/legalizer/inttoptr_and_ptrtoint.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/GlobalISel/legalizer/inttoptr_and_ptrtoint.mir?rev=367104&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/GlobalISel/legalizer/inttoptr_and_ptrtoint.mir (added)
+++ llvm/trunk/test/CodeGen/Mips/GlobalISel/legalizer/inttoptr_and_ptrtoint.mir Fri Jul 26 06:08:06 2019
@@ -0,0 +1,48 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -O0 -mtriple=mipsel-linux-gnu -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32
+--- |
+
+ define void @inttoptr() {entry: ret void}
+ define void @ptrtoint() {entry: ret void}
+
+...
+---
+name: inttoptr
+alignment: 2
+tracksRegLiveness: true
+body: |
+ bb.1.entry:
+ liveins: $a0
+
+ ; MIPS32-LABEL: name: inttoptr
+ ; MIPS32: liveins: $a0
+ ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a0
+ ; MIPS32: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[COPY]](s32)
+ ; MIPS32: $v0 = COPY [[INTTOPTR]](p0)
+ ; MIPS32: RetRA implicit $v0
+ %0:_(s32) = COPY $a0
+ %1:_(p0) = G_INTTOPTR %0(s32)
+ $v0 = COPY %1(p0)
+ RetRA implicit $v0
+
+...
+---
+name: ptrtoint
+alignment: 2
+tracksRegLiveness: true
+body: |
+ bb.1.entry:
+ liveins: $a0
+
+ ; MIPS32-LABEL: name: ptrtoint
+ ; MIPS32: liveins: $a0
+ ; MIPS32: [[COPY:%[0-9]+]]:_(p0) = COPY $a0
+ ; MIPS32: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[COPY]](p0)
+ ; MIPS32: $v0 = COPY [[PTRTOINT]](s32)
+ ; MIPS32: RetRA implicit $v0
+ %0:_(p0) = COPY $a0
+ %1:_(s32) = G_PTRTOINT %0(p0)
+ $v0 = COPY %1(s32)
+ RetRA implicit $v0
+
+...
Added: llvm/trunk/test/CodeGen/Mips/GlobalISel/llvm-ir/inttoptr_and_ptrtoint.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/GlobalISel/llvm-ir/inttoptr_and_ptrtoint.ll?rev=367104&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/GlobalISel/llvm-ir/inttoptr_and_ptrtoint.ll (added)
+++ llvm/trunk/test/CodeGen/Mips/GlobalISel/llvm-ir/inttoptr_and_ptrtoint.ll Fri Jul 26 06:08:06 2019
@@ -0,0 +1,24 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32
+
+define i32* @inttoptr(i32 %a) {
+; MIPS32-LABEL: inttoptr:
+; MIPS32: # %bb.0: # %entry
+; MIPS32-NEXT: move $2, $4
+; MIPS32-NEXT: jr $ra
+; MIPS32-NEXT: nop
+entry:
+ %0 = inttoptr i32 %a to i32*
+ ret i32* %0
+}
+
+define i32 @ptrtoint(i32* %a) {
+; MIPS32-LABEL: ptrtoint:
+; MIPS32: # %bb.0: # %entry
+; MIPS32-NEXT: move $2, $4
+; MIPS32-NEXT: jr $ra
+; MIPS32-NEXT: nop
+entry:
+ %0 = ptrtoint i32* %a to i32
+ ret i32 %0
+}
Added: llvm/trunk/test/CodeGen/Mips/GlobalISel/regbankselect/inttoptr_and_ptrtoint.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/GlobalISel/regbankselect/inttoptr_and_ptrtoint.mir?rev=367104&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/GlobalISel/regbankselect/inttoptr_and_ptrtoint.mir (added)
+++ llvm/trunk/test/CodeGen/Mips/GlobalISel/regbankselect/inttoptr_and_ptrtoint.mir Fri Jul 26 06:08:06 2019
@@ -0,0 +1,50 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -O0 -mtriple=mipsel-linux-gnu -run-pass=regbankselect -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32
+--- |
+
+ define void @inttoptr() {entry: ret void}
+ define void @ptrtoint() {entry: ret void}
+
+...
+---
+name: inttoptr
+alignment: 2
+legalized: true
+tracksRegLiveness: true
+body: |
+ bb.1.entry:
+ liveins: $a0
+
+ ; MIPS32-LABEL: name: inttoptr
+ ; MIPS32: liveins: $a0
+ ; MIPS32: [[COPY:%[0-9]+]]:gprb(s32) = COPY $a0
+ ; MIPS32: [[INTTOPTR:%[0-9]+]]:gprb(p0) = G_INTTOPTR [[COPY]](s32)
+ ; MIPS32: $v0 = COPY [[INTTOPTR]](p0)
+ ; MIPS32: RetRA implicit $v0
+ %0:_(s32) = COPY $a0
+ %1:_(p0) = G_INTTOPTR %0(s32)
+ $v0 = COPY %1(p0)
+ RetRA implicit $v0
+
+...
+---
+name: ptrtoint
+alignment: 2
+legalized: true
+tracksRegLiveness: true
+body: |
+ bb.1.entry:
+ liveins: $a0
+
+ ; MIPS32-LABEL: name: ptrtoint
+ ; MIPS32: liveins: $a0
+ ; MIPS32: [[COPY:%[0-9]+]]:gprb(p0) = COPY $a0
+ ; MIPS32: [[PTRTOINT:%[0-9]+]]:gprb(s32) = G_PTRTOINT [[COPY]](p0)
+ ; MIPS32: $v0 = COPY [[PTRTOINT]](s32)
+ ; MIPS32: RetRA implicit $v0
+ %0:_(p0) = COPY $a0
+ %1:_(s32) = G_PTRTOINT %0(p0)
+ $v0 = COPY %1(s32)
+ RetRA implicit $v0
+
+...
More information about the llvm-commits
mailing list