-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCV] Add software pipeliner support for RISC-V
This patch adds basic support of `MachinePipeliner` and disable it by default. The functionality should be OK and all llvm-test-suite tests have passed.
- Loading branch information
Showing
6 changed files
with
179 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
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
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,78 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc -mtriple=riscv64 -mcpu=sifive-p670 -O3 -verify-machineinstrs -riscv-enable-pipeliner=false < %s \ | ||
; RUN: | FileCheck %s --check-prefixes=CHECK-NOT-PIPELINED | ||
; RUN: llc -mtriple=riscv64 -mcpu=sifive-p670 -O3 -verify-machineinstrs -riscv-enable-pipeliner=true < %s \ | ||
; RUN: | FileCheck %s --check-prefixes=CHECK-PIPELINED | ||
|
||
define void @test_1(ptr noalias %in, ptr noalias %out, i32 signext %cnt) "no-builtins" { | ||
; CHECK-NOT-PIPELINED-LABEL: test_1: | ||
; CHECK-NOT-PIPELINED: # %bb.0: # %entry | ||
; CHECK-NOT-PIPELINED-NEXT: blez a2, .LBB0_3 | ||
; CHECK-NOT-PIPELINED-NEXT: # %bb.1: # %for.body.preheader | ||
; CHECK-NOT-PIPELINED-NEXT: addi a2, a2, -1 | ||
; CHECK-NOT-PIPELINED-NEXT: sh2add.uw a2, a2, a1 | ||
; CHECK-NOT-PIPELINED-NEXT: addi a2, a2, 4 | ||
; CHECK-NOT-PIPELINED-NEXT: .LBB0_2: # %for.body | ||
; CHECK-NOT-PIPELINED-NEXT: # =>This Inner Loop Header: Depth=1 | ||
; CHECK-NOT-PIPELINED-NEXT: lw a3, 0(a1) | ||
; CHECK-NOT-PIPELINED-NEXT: addi a1, a1, 4 | ||
; CHECK-NOT-PIPELINED-NEXT: sw a3, 0(a0) | ||
; CHECK-NOT-PIPELINED-NEXT: addi a0, a0, 4 | ||
; CHECK-NOT-PIPELINED-NEXT: bne a1, a2, .LBB0_2 | ||
; CHECK-NOT-PIPELINED-NEXT: .LBB0_3: # %for.end | ||
; CHECK-NOT-PIPELINED-NEXT: ret | ||
; | ||
; CHECK-PIPELINED-LABEL: test_1: | ||
; CHECK-PIPELINED: # %bb.0: # %entry | ||
; CHECK-PIPELINED-NEXT: blez a2, .LBB0_6 | ||
; CHECK-PIPELINED-NEXT: # %bb.1: # %for.body.preheader | ||
; CHECK-PIPELINED-NEXT: lw a3, 0(a1) | ||
; CHECK-PIPELINED-NEXT: addi a2, a2, -1 | ||
; CHECK-PIPELINED-NEXT: addi a4, a0, 4 | ||
; CHECK-PIPELINED-NEXT: sh2add.uw a6, a2, a1 | ||
; CHECK-PIPELINED-NEXT: addi a1, a1, 4 | ||
; CHECK-PIPELINED-NEXT: addi a6, a6, 4 | ||
; CHECK-PIPELINED-NEXT: beq a1, a6, .LBB0_5 | ||
; CHECK-PIPELINED-NEXT: # %bb.2: # %for.body | ||
; CHECK-PIPELINED-NEXT: lw a5, 0(a1) | ||
; CHECK-PIPELINED-NEXT: addi a2, a4, 4 | ||
; CHECK-PIPELINED-NEXT: addi a1, a1, 4 | ||
; CHECK-PIPELINED-NEXT: beq a1, a6, .LBB0_4 | ||
; CHECK-PIPELINED-NEXT: .LBB0_3: # %for.body | ||
; CHECK-PIPELINED-NEXT: # =>This Inner Loop Header: Depth=1 | ||
; CHECK-PIPELINED-NEXT: sw a3, 0(a0) | ||
; CHECK-PIPELINED-NEXT: mv a3, a5 | ||
; CHECK-PIPELINED-NEXT: lw a5, 0(a1) | ||
; CHECK-PIPELINED-NEXT: mv a0, a4 | ||
; CHECK-PIPELINED-NEXT: mv a4, a2 | ||
; CHECK-PIPELINED-NEXT: addi a2, a2, 4 | ||
; CHECK-PIPELINED-NEXT: addi a1, a1, 4 | ||
; CHECK-PIPELINED-NEXT: bne a1, a6, .LBB0_3 | ||
; CHECK-PIPELINED-NEXT: .LBB0_4: | ||
; CHECK-PIPELINED-NEXT: sw a3, 0(a0) | ||
; CHECK-PIPELINED-NEXT: mv a0, a4 | ||
; CHECK-PIPELINED-NEXT: mv a3, a5 | ||
; CHECK-PIPELINED-NEXT: .LBB0_5: | ||
; CHECK-PIPELINED-NEXT: sw a3, 0(a0) | ||
; CHECK-PIPELINED-NEXT: .LBB0_6: # %for.end | ||
; CHECK-PIPELINED-NEXT: ret | ||
entry: | ||
%cmp5 = icmp sgt i32 %cnt, 0 | ||
br i1 %cmp5, label %for.body, label %for.end | ||
|
||
for.body: ; preds = %entry, %for.body | ||
%i.08 = phi i32 [ %inc, %for.body ], [ 0, %entry ] | ||
%in.addr.07 = phi ptr [ %incdec.ptr, %for.body ], [ %in, %entry ] | ||
%out.addr.06 = phi ptr [ %incdec.ptr1, %for.body ], [ %out, %entry ] | ||
%0 = load i32, ptr %out.addr.06, align 4 | ||
store i32 %0, ptr %in.addr.07, align 4 | ||
%incdec.ptr = getelementptr inbounds i8, ptr %in.addr.07, i64 4 | ||
%incdec.ptr1 = getelementptr inbounds i8, ptr %out.addr.06, i64 4 | ||
%inc = add nuw nsw i32 %i.08, 1 | ||
%exitcond.not = icmp eq i32 %inc, %cnt | ||
br i1 %exitcond.not, label %for.end, label %for.body | ||
|
||
for.end: ; preds = %for.body, %entry | ||
ret void | ||
} | ||
|