Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DPWBS-1210] feat(Legalizer): lower G_DYN_STACKALLOC
Lowering G_DYN_STACKALLOC generates a stack-pointer subtraction
- Loading branch information
Showing
2 changed files
with
66 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
61 changes: 61 additions & 0 deletions
61
llvm/test/CodeGen/TriCore/GlobalIsel/legalize-dyn-stackalloc.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,61 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
# RUN: llc -O0 -mtriple=tricore -global-isel -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s | ||
|
||
--- | | ||
define i8* @test_dyn_stackalloc(i32 %numelts) { | ||
%addr = alloca i8, i32 %numelts | ||
ret i8* %addr | ||
} | ||
|
||
define i8* @test_aligned_dyn_stackalloc(i32 %numelts) { | ||
%addr = alloca i8, i32 %numelts, align 32 | ||
ret i8* %addr | ||
} | ||
... | ||
|
||
--- | ||
name: test_dyn_stackalloc | ||
stack: | ||
- { id: 0, name: addr, type: variable-sized, alignment: 1 } | ||
body: | | ||
bb.1: | ||
liveins: $d4 | ||
; CHECK-LABEL: name: test_dyn_stackalloc | ||
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $d4 | ||
; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $a10 | ||
; CHECK: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[COPY1]](p0) | ||
; CHECK: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[PTRTOINT]], [[COPY]] | ||
; CHECK: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[SUB]](s32) | ||
; CHECK: $a10 = COPY [[INTTOPTR]](p0) | ||
; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0) | ||
; CHECK: $a2 = COPY [[COPY2]](p0) | ||
%0:_(s32) = COPY $d4 | ||
%1:_(p0) = G_DYN_STACKALLOC %0(s32), 0 | ||
$a2 = COPY %1(p0) | ||
... | ||
|
||
--- | ||
name: test_aligned_dyn_stackalloc | ||
stack: | ||
- { id: 0, name: addr, type: variable-sized, alignment: 32 } | ||
body: | | ||
bb.1: | ||
liveins: $d4 | ||
; CHECK-LABEL: name: test_aligned_dyn_stackalloc | ||
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $d4 | ||
; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $a10 | ||
; CHECK: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[COPY1]](p0) | ||
; CHECK: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[PTRTOINT]], [[COPY]] | ||
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -32 | ||
; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[SUB]], [[C]] | ||
; CHECK: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[AND]](s32) | ||
; CHECK: $a10 = COPY [[INTTOPTR]](p0) | ||
; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[INTTOPTR]](p0) | ||
; CHECK: $a2 = COPY [[COPY2]](p0) | ||
%0:_(s32) = COPY $d4 | ||
%1:_(p0) = G_DYN_STACKALLOC %0(s32), 32 | ||
$a2 = COPY %1(p0) | ||
... |