Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DPWBS-1354] feat(Legalizer): add support for G_JUMP_TABLE and G_BRJT
add legalizer tests
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 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
89 changes: 89 additions & 0 deletions
89
llvm/test/CodeGen/TriCore/GlobalIsel/legalize-jump-table-brjt.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,89 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc -mtriple=tricore -global-isel -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s | ||
|
||
--- | | ||
define i32 @jt_test(i32 %x) { | ||
entry: | ||
switch i32 %x, label %return [ | ||
i32 75, label %sw.bb | ||
i32 34, label %sw.bb | ||
i32 56, label %sw.bb | ||
i32 35, label %sw.bb | ||
i32 40, label %sw.bb | ||
i32 4, label %sw.bb1 | ||
i32 5, label %sw.bb1 | ||
i32 6, label %sw.bb1 | ||
] | ||
|
||
sw.bb: ; preds = %entry, %entry, %entry, %entry, %entry | ||
%add = add nsw i32 %x, 42 | ||
br label %return | ||
|
||
sw.bb1: ; preds = %entry, %entry, %entry | ||
%mul = mul nsw i32 %x, 3 | ||
br label %return | ||
|
||
return: ; preds = %sw.bb1, %sw.bb, %entry | ||
%retval.0 = phi i32 [ %mul, %sw.bb1 ], [ %add, %sw.bb ], [ 0, %entry ] | ||
ret i32 %retval.0 | ||
} | ||
|
||
... | ||
--- | ||
name: jt_test | ||
tracksRegLiveness: true | ||
jumpTable: | ||
kind: inline | ||
entries: | ||
- id: 0 | ||
blocks: [ '%bb.3', '%bb.3', '%bb.3', '%bb.4', '%bb.4', '%bb.4', | ||
'%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', | ||
'%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', | ||
'%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', | ||
'%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', | ||
'%bb.2', '%bb.2', '%bb.4', '%bb.4', '%bb.4', '%bb.4', | ||
'%bb.2', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', | ||
'%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', | ||
'%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.2', '%bb.4', | ||
'%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', | ||
'%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', | ||
'%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.4', '%bb.2' ] | ||
body: | | ||
; CHECK-LABEL: name: jt_test | ||
; CHECK: bb.0.entry: | ||
; CHECK: successors: %bb.1(0x80000000) | ||
; CHECK: liveins: $d4 | ||
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $d4 | ||
; CHECK: [[JUMP_TABLE:%[0-9]+]]:_(p0) = G_JUMP_TABLE %jump-table.0 | ||
; CHECK: G_BRJT [[JUMP_TABLE]](p0), %jump-table.0, [[COPY]](s32) | ||
; CHECK: bb.1.entry: | ||
; CHECK: successors: %bb.3(0x2aaaaaab), %bb.4(0x2aaaaaab), %bb.2(0x2aaaaaab) | ||
; CHECK: G_BR %bb.4 | ||
; CHECK: bb.2.sw.bb: | ||
; CHECK: successors: %bb.4(0x80000000) | ||
; CHECK: G_BR %bb.4 | ||
; CHECK: bb.3.sw.bb1: | ||
; CHECK: successors: %bb.4(0x80000000) | ||
; CHECK: bb.4.return: | ||
; CHECK: RET implicit $a11 | ||
bb.0.entry: | ||
liveins: $d4 | ||
%0:_(s32) = COPY $d4 | ||
%1:_(p0) = G_JUMP_TABLE %jump-table.0 | ||
G_BRJT %1:_(p0), %jump-table.0, %0:_(s32) | ||
bb.1.entry: | ||
successors: %bb.3(0x2aaaaaab), %bb.4(0x2aaaaaab), %bb.2(0x2aaaaaab) | ||
G_BR %bb.4 | ||
bb.2.sw.bb: | ||
G_BR %bb.4 | ||
bb.3.sw.bb1: | ||
bb.4.return: | ||
RET implicit $a11 | ||
... |