Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GlobalIsel][X86] Support G_PTRTOINT instruction.
Add legalization/selection for x86/x86_64 and corresponding tests. Reviewed By: igorb Differential Revision: https://reviews.llvm.org/D43617 llvm-svn: 326311
- Loading branch information
Alexander Ivchenko
committed
Feb 28, 2018
1 parent
212e676
commit 46e07e3
Showing
7 changed files
with
682 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=CHECK | ||
|
||
define i1 @ptrtoint_s1_p0(i64* %p) { | ||
; CHECK-LABEL: ptrtoint_s1_p0: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: movl %edi, %eax | ||
; CHECK-NEXT: retq | ||
entry: | ||
%0 = ptrtoint i64* %p to i1 | ||
ret i1 %0 | ||
} | ||
|
||
define i8 @ptrtoint_s8_p0(i64* %p) { | ||
; CHECK-LABEL: ptrtoint_s8_p0: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: movl %edi, %eax | ||
; CHECK-NEXT: retq | ||
entry: | ||
%0 = ptrtoint i64* %p to i8 | ||
ret i8 %0 | ||
} | ||
|
||
define i16 @ptrtoint_s16_p0(i64* %p) { | ||
; CHECK-LABEL: ptrtoint_s16_p0: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: movl %edi, %eax | ||
; CHECK-NEXT: retq | ||
entry: | ||
%0 = ptrtoint i64* %p to i16 | ||
ret i16 %0 | ||
} | ||
|
||
define i32 @ptrtoint_s32_p0(i64* %p) { | ||
; CHECK-LABEL: ptrtoint_s32_p0: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: movl %edi, %eax | ||
; CHECK-NEXT: retq | ||
entry: | ||
%0 = ptrtoint i64* %p to i32 | ||
ret i32 %0 | ||
} | ||
|
||
define i64 @ptrtoint_s64_p0(i64* %p) { | ||
; CHECK-LABEL: ptrtoint_s64_p0: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: movq %rdi, %rax | ||
; CHECK-NEXT: retq | ||
entry: | ||
%0 = ptrtoint i64* %p to i64 | ||
ret i64 %0 | ||
} |
141 changes: 141 additions & 0 deletions
141
llvm/test/CodeGen/X86/GlobalISel/x86-legalize-ptrtoint.mir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc -mtriple=i686-linux-gnu -global-isel -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s | ||
|
||
--- | | ||
|
||
define i1 @ptrtoint_s1_p0(i64* %p) { | ||
entry: | ||
%0 = ptrtoint i64* %p to i1 | ||
ret i1 %0 | ||
} | ||
|
||
define i8 @ptrtoint_s8_p0(i64* %p) { | ||
entry: | ||
%0 = ptrtoint i64* %p to i8 | ||
ret i8 %0 | ||
} | ||
|
||
define i16 @ptrtoint_s16_p0(i64* %p) { | ||
entry: | ||
%0 = ptrtoint i64* %p to i16 | ||
ret i16 %0 | ||
} | ||
|
||
define i32 @ptrtoint_s32_p0(i64* %p) { | ||
entry: | ||
%0 = ptrtoint i64* %p to i32 | ||
ret i32 %0 | ||
} | ||
|
||
... | ||
--- | ||
name: ptrtoint_s1_p0 | ||
alignment: 4 | ||
tracksRegLiveness: true | ||
registers: | ||
- { id: 0, class: _ } | ||
- { id: 1, class: _ } | ||
- { id: 2, class: _ } | ||
- { id: 3, class: _ } | ||
frameInfo: | ||
maxAlignment: 4 | ||
fixedStack: | ||
- { id: 0, size: 4, alignment: 16, stack-id: 0, isImmutable: true } | ||
body: | | ||
bb.1.entry: | ||
; CHECK-LABEL: name: ptrtoint_s1_p0 | ||
; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0 | ||
; CHECK: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[FRAME_INDEX]](p0) :: (invariant load 4 from %fixed-stack.0, align 0) | ||
; CHECK: [[PTRTOINT:%[0-9]+]]:_(s1) = G_PTRTOINT [[LOAD]](p0) | ||
; CHECK: [[ANYEXT:%[0-9]+]]:_(s8) = G_ANYEXT [[PTRTOINT]](s1) | ||
; CHECK: $al = COPY [[ANYEXT]](s8) | ||
; CHECK: RET 0, implicit $al | ||
%1:_(p0) = G_FRAME_INDEX %fixed-stack.0 | ||
%0:_(p0) = G_LOAD %1(p0) :: (invariant load 4 from %fixed-stack.0, align 0) | ||
%2:_(s1) = G_PTRTOINT %0(p0) | ||
%3:_(s8) = G_ANYEXT %2(s1) | ||
$al = COPY %3(s8) | ||
RET 0, implicit $al | ||
... | ||
--- | ||
name: ptrtoint_s8_p0 | ||
alignment: 4 | ||
tracksRegLiveness: true | ||
registers: | ||
- { id: 0, class: _ } | ||
- { id: 1, class: _ } | ||
- { id: 2, class: _ } | ||
frameInfo: | ||
maxAlignment: 4 | ||
fixedStack: | ||
- { id: 0, size: 4, alignment: 16, stack-id: 0, isImmutable: true } | ||
body: | | ||
bb.1.entry: | ||
; CHECK-LABEL: name: ptrtoint_s8_p0 | ||
; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0 | ||
; CHECK: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[FRAME_INDEX]](p0) :: (invariant load 4 from %fixed-stack.0, align 0) | ||
; CHECK: [[PTRTOINT:%[0-9]+]]:_(s8) = G_PTRTOINT [[LOAD]](p0) | ||
; CHECK: $al = COPY [[PTRTOINT]](s8) | ||
; CHECK: RET 0, implicit $al | ||
%1:_(p0) = G_FRAME_INDEX %fixed-stack.0 | ||
%0:_(p0) = G_LOAD %1(p0) :: (invariant load 4 from %fixed-stack.0, align 0) | ||
%2:_(s8) = G_PTRTOINT %0(p0) | ||
$al = COPY %2(s8) | ||
RET 0, implicit $al | ||
... | ||
--- | ||
name: ptrtoint_s16_p0 | ||
alignment: 4 | ||
tracksRegLiveness: true | ||
registers: | ||
- { id: 0, class: _ } | ||
- { id: 1, class: _ } | ||
- { id: 2, class: _ } | ||
frameInfo: | ||
maxAlignment: 4 | ||
fixedStack: | ||
- { id: 0, size: 4, alignment: 16, stack-id: 0, isImmutable: true } | ||
body: | | ||
bb.1.entry: | ||
; CHECK-LABEL: name: ptrtoint_s16_p0 | ||
; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0 | ||
; CHECK: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[FRAME_INDEX]](p0) :: (invariant load 4 from %fixed-stack.0, align 0) | ||
; CHECK: [[PTRTOINT:%[0-9]+]]:_(s16) = G_PTRTOINT [[LOAD]](p0) | ||
; CHECK: $ax = COPY [[PTRTOINT]](s16) | ||
; CHECK: RET 0, implicit $ax | ||
%1:_(p0) = G_FRAME_INDEX %fixed-stack.0 | ||
%0:_(p0) = G_LOAD %1(p0) :: (invariant load 4 from %fixed-stack.0, align 0) | ||
%2:_(s16) = G_PTRTOINT %0(p0) | ||
$ax = COPY %2(s16) | ||
RET 0, implicit $ax | ||
... | ||
--- | ||
name: ptrtoint_s32_p0 | ||
alignment: 4 | ||
tracksRegLiveness: true | ||
registers: | ||
- { id: 0, class: _ } | ||
- { id: 1, class: _ } | ||
- { id: 2, class: _ } | ||
frameInfo: | ||
maxAlignment: 4 | ||
fixedStack: | ||
- { id: 0, size: 4, alignment: 16, stack-id: 0, isImmutable: true } | ||
body: | | ||
bb.1.entry: | ||
; CHECK-LABEL: name: ptrtoint_s32_p0 | ||
; CHECK: [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %fixed-stack.0 | ||
; CHECK: [[LOAD:%[0-9]+]]:_(p0) = G_LOAD [[FRAME_INDEX]](p0) :: (invariant load 4 from %fixed-stack.0, align 0) | ||
; CHECK: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[LOAD]](p0) | ||
; CHECK: $eax = COPY [[PTRTOINT]](s32) | ||
; CHECK: RET 0, implicit $eax | ||
%1:_(p0) = G_FRAME_INDEX %fixed-stack.0 | ||
%0:_(p0) = G_LOAD %1(p0) :: (invariant load 4 from %fixed-stack.0, align 0) | ||
%2:_(s32) = G_PTRTOINT %0(p0) | ||
$eax = COPY %2(s32) | ||
RET 0, implicit $eax | ||
... |
Oops, something went wrong.