Skip to content

Commit

Permalink
[ARM GlobalISel] Support G_CTLZ for Thumb2
Browse files Browse the repository at this point in the history
Same as ARM mode but with different opcode.

llvm-svn: 355191
  • Loading branch information
rovka committed Mar 1, 2019
1 parent ae5303d commit 54829ec
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
7 changes: 0 additions & 7 deletions llvm/lib/Target/ARM/ARMLegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,6 @@ ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {

getActionDefinitionsBuilder({G_FREM, G_FPOW}).libcallFor({s32, s64});

if (ST.isThumb()) {
// FIXME: merge with the code for non-Thumb.
computeTables();
verify(*ST.getInstrInfo());
return;
}

if (ST.hasV5TOps()) {
getActionDefinitionsBuilder(G_CTLZ)
.legalFor({s32, s32})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# RUN: llc -O0 -mtriple arm-linux-gnueabi -mattr=+v5t -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,CLZ
# RUN: llc -O0 -mtriple thumb-linux-gnueabi -mattr=+v6t2 -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,CLZ
# RUN: llc -O0 -mtriple arm-linux-gnueabi -mattr=-v5t -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,LIBCALLS
--- |
define void @test_ctlz_s32() { ret void }
Expand Down
33 changes: 33 additions & 0 deletions llvm/test/CodeGen/ARM/GlobalISel/select-clz.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# RUN: llc -O0 -mtriple arm-- -mattr=+v6 -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,ARM
# RUN: llc -O0 -mtriple thumb-- -mattr=+v6t2 -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,THUMB
--- |
define void @test_clz() { ret void }
...
---
name: test_clz
# CHECK-LABEL: name: test_clz
legalized: true
regBankSelected: true
selected: false
# CHECK: selected: true
registers:
- { id: 0, class: gprb }
- { id: 1, class: gprb }
body: |
bb.0:
liveins: $r0
%0(s32) = COPY $r0
; ARM: [[VREGX:%[0-9]+]]:gpr = COPY $r0
; THUMB: [[VREGX:%[0-9]+]]:rgpr = COPY $r0
%1(s32) = G_CTLZ %0(s32)
; ARM: [[VREGR:%[0-9]+]]:gpr = CLZ [[VREGX]], 14, $noreg
; THUMB: [[VREGR:%[0-9]+]]:rgpr = t2CLZ [[VREGX]], 14, $noreg
$r0 = COPY %1(s32)
; CHECK: $r0 = COPY [[VREGR]]
BX_RET 14, $noreg, implicit $r0
; CHECK: BX_RET 14, $noreg, implicit $r0
...

0 comments on commit 54829ec

Please sign in to comment.