-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV] Implement trampolines for rv64 #96309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
94f4194
[RISCV] Implement trampolines for rv64
rofirrim 3e3d9fc
Use MCCodeEmitter to encode instructions rather than hardcoded constants
rofirrim 5e3ce76
Remove stray blank line
rofirrim 82367f4
clang-format
rofirrim 3a76960
Apply suggestions from code review
rofirrim b6f7492
Avoid awkward variable names
rofirrim ca45c15
Reduce the amount of repetition
rofirrim 215597b
clang-format
rofirrim 9a0c0bb
Remove assertions
rofirrim 63d0daa
Hoist initialisation
rofirrim 6d65d1b
Only flush the part of the trampoline buffer containing instructions
rofirrim 3a73d1c
Reduce the amount of repetition
rofirrim 54248d5
Remove some more repetition
rofirrim acb1e6b
Update test
rofirrim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,80 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \ | ||
; RUN: | FileCheck -check-prefix=RV64 %s | ||
; RUN: llc -mtriple=riscv64-unknown-linux-gnu -verify-machineinstrs < %s \ | ||
; RUN: | FileCheck -check-prefix=RV64-LINUX %s | ||
|
||
declare void @llvm.init.trampoline(ptr, ptr, ptr) | ||
declare ptr @llvm.adjust.trampoline(ptr) | ||
declare i64 @f(ptr nest, i64) | ||
|
||
define i64 @test0(i64 %n, ptr %p) nounwind { | ||
; RV64-LABEL: test0: | ||
; RV64: # %bb.0: | ||
; RV64-NEXT: addi sp, sp, -64 | ||
; RV64-NEXT: sd ra, 56(sp) # 8-byte Folded Spill | ||
; RV64-NEXT: sd s0, 48(sp) # 8-byte Folded Spill | ||
; RV64-NEXT: sd s1, 40(sp) # 8-byte Folded Spill | ||
; RV64-NEXT: mv s0, a0 | ||
; RV64-NEXT: lui a0, %hi(f) | ||
; RV64-NEXT: addi a0, a0, %lo(f) | ||
; RV64-NEXT: sd a0, 32(sp) | ||
; RV64-NEXT: li a0, 919 | ||
; RV64-NEXT: lui a2, %hi(.LCPI0_0) | ||
; RV64-NEXT: ld a2, %lo(.LCPI0_0)(a2) | ||
; RV64-NEXT: lui a3, 6203 | ||
; RV64-NEXT: addi a3, a3, 643 | ||
; RV64-NEXT: sw a0, 8(sp) | ||
; RV64-NEXT: sw a3, 12(sp) | ||
; RV64-NEXT: sd a2, 16(sp) | ||
; RV64-NEXT: sd a1, 24(sp) | ||
; RV64-NEXT: addi a1, sp, 24 | ||
; RV64-NEXT: addi a0, sp, 8 | ||
; RV64-NEXT: addi s1, sp, 8 | ||
; RV64-NEXT: call __clear_cache | ||
; RV64-NEXT: mv a0, s0 | ||
; RV64-NEXT: jalr s1 | ||
; RV64-NEXT: ld ra, 56(sp) # 8-byte Folded Reload | ||
; RV64-NEXT: ld s0, 48(sp) # 8-byte Folded Reload | ||
; RV64-NEXT: ld s1, 40(sp) # 8-byte Folded Reload | ||
; RV64-NEXT: addi sp, sp, 64 | ||
; RV64-NEXT: ret | ||
; | ||
; RV64-LINUX-LABEL: test0: | ||
; RV64-LINUX: # %bb.0: | ||
; RV64-LINUX-NEXT: addi sp, sp, -64 | ||
; RV64-LINUX-NEXT: sd ra, 56(sp) # 8-byte Folded Spill | ||
; RV64-LINUX-NEXT: sd s0, 48(sp) # 8-byte Folded Spill | ||
; RV64-LINUX-NEXT: sd s1, 40(sp) # 8-byte Folded Spill | ||
; RV64-LINUX-NEXT: mv s0, a0 | ||
; RV64-LINUX-NEXT: lui a0, %hi(f) | ||
; RV64-LINUX-NEXT: addi a0, a0, %lo(f) | ||
; RV64-LINUX-NEXT: sd a0, 32(sp) | ||
; RV64-LINUX-NEXT: li a0, 919 | ||
; RV64-LINUX-NEXT: lui a2, %hi(.LCPI0_0) | ||
; RV64-LINUX-NEXT: ld a2, %lo(.LCPI0_0)(a2) | ||
; RV64-LINUX-NEXT: lui a3, 6203 | ||
; RV64-LINUX-NEXT: addi a3, a3, 643 | ||
; RV64-LINUX-NEXT: sw a0, 8(sp) | ||
; RV64-LINUX-NEXT: sw a3, 12(sp) | ||
; RV64-LINUX-NEXT: sd a2, 16(sp) | ||
; RV64-LINUX-NEXT: sd a1, 24(sp) | ||
; RV64-LINUX-NEXT: addi a1, sp, 24 | ||
; RV64-LINUX-NEXT: addi a0, sp, 8 | ||
; RV64-LINUX-NEXT: addi s1, sp, 8 | ||
; RV64-LINUX-NEXT: li a2, 0 | ||
; RV64-LINUX-NEXT: call __riscv_flush_icache | ||
; RV64-LINUX-NEXT: mv a0, s0 | ||
; RV64-LINUX-NEXT: jalr s1 | ||
; RV64-LINUX-NEXT: ld ra, 56(sp) # 8-byte Folded Reload | ||
; RV64-LINUX-NEXT: ld s0, 48(sp) # 8-byte Folded Reload | ||
; RV64-LINUX-NEXT: ld s1, 40(sp) # 8-byte Folded Reload | ||
; RV64-LINUX-NEXT: addi sp, sp, 64 | ||
; RV64-LINUX-NEXT: ret | ||
%alloca = alloca [32 x i8], align 8 | ||
call void @llvm.init.trampoline(ptr %alloca, ptr @f, ptr %p) | ||
%tramp = call ptr @llvm.adjust.trampoline(ptr %alloca) | ||
%ret = call i64 %tramp(i64 %n) | ||
ret i64 %ret | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.