Skip to content

Commit

Permalink
[DPWBS-1186] Adding legality rule for G_FFLOOR
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar Solymosi authored and konstantinschwarz committed Feb 6, 2020
1 parent 1f12ae3 commit b43faf8
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
6 changes: 6 additions & 0 deletions llvm/lib/Target/TriCore/TriCoreLegalizerInfo.cpp
Expand Up @@ -277,6 +277,12 @@ TriCoreLegalizerInfo::TriCoreLegalizerInfo(const TriCoreSubtarget &ST) {
else
FPArithmActions.libcallFor({s64});

// G_FFLOOR requires a libcall s32 and s64
getActionDefinitionsBuilder(G_FFLOOR)
.clampScalar(0, s32, s64)
.widenScalarToNextPow2(0)
.libcallFor({s32, s64});

// Load & Store

// G_LOAD is legal for 32 and 64-bit scalar and pointer types.
Expand Down
68 changes: 68 additions & 0 deletions llvm/test/CodeGen/TriCore/GlobalIsel/legalize-ffloor.mir
@@ -0,0 +1,68 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -O0 -mtriple=tricore -global-isel -run-pass=legalizer \
# RUN: -verify-machineinstrs %s -o - | FileCheck %s

---
name: ffloor_s16
body: |
bb.0:
liveins: $d4
; CHECK-LABEL: name: ffloor_s16
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $d4
; CHECK: [[FPTRUNC:%[0-9]+]]:_(s16) = G_FPTRUNC [[COPY]](s32)
; CHECK: [[FPEXT:%[0-9]+]]:_(s32) = G_FPEXT [[FPTRUNC]](s16)
; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $a10, implicit $a10
; CHECK: $d4 = COPY [[FPEXT]](s32)
; CHECK: CALL &floorf, csr_tricore_uppercontext, implicit-def $a11, implicit $psw, implicit $d4, implicit-def $d2
; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $d2
; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $a10, implicit $a10
; CHECK: [[FPTRUNC1:%[0-9]+]]:_(s16) = G_FPTRUNC [[COPY1]](s32)
; CHECK: [[FPEXT1:%[0-9]+]]:_(s32) = G_FPEXT [[FPTRUNC1]](s16)
; CHECK: $d4 = COPY [[FPEXT1]](s32)
%0:_(s32) = COPY $d4
%1:_(s16) = G_FPTRUNC %0:_(s32)
%2:_(s16) = G_FFLOOR %1(s16)
%3:_(s32) = G_FPEXT %2:_(s16)
$d4 = COPY %3(s32)
...

---
name: ffloor_s32
body: |
bb.0:
liveins: $d4
; CHECK-LABEL: name: ffloor_s32
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $d4
; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $a10, implicit $a10
; CHECK: $d4 = COPY [[COPY]](s32)
; CHECK: CALL &floorf, csr_tricore_uppercontext, implicit-def $a11, implicit $psw, implicit $d4, implicit-def $d2
; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY $d2
; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $a10, implicit $a10
; CHECK: $d4 = COPY [[COPY1]](s32)
%0:_(s32) = COPY $d4
%1:_(s32) = G_FFLOOR %0(s32)
$d4 = COPY %1(s32)
...

---
name: ffloor_s64
body: |
bb.0:
liveins: $e4
; CHECK-LABEL: name: ffloor_s64
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $e4
; CHECK: ADJCALLSTACKDOWN 0, 0, implicit-def $a10, implicit $a10
; CHECK: $e4 = COPY [[COPY]](s64)
; CHECK: CALL &floor, csr_tricore_uppercontext, implicit-def $a11, implicit $psw, implicit $e4, implicit-def $e2
; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $e2
; CHECK: ADJCALLSTACKUP 0, 0, implicit-def $a10, implicit $a10
; CHECK: $e4 = COPY [[COPY1]](s64)
%0:_(s64) = COPY $e4
%1:_(s64) = G_FFLOOR %0(s64)
$e4 = COPY %1(s64)
...

0 comments on commit b43faf8

Please sign in to comment.