mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 04:33:05 +00:00
d021bb8003
This is the third patch in a small series. It contains the CodeGen support for lowering the gc.statepoint intrinsic sequences (223078) to the STATEPOINT pseudo machine instruction (223085). The change also includes the set of helper routines and classes for working with gc.statepoints, gc.relocates, and gc.results since the lowering code uses them. With this change, gc.statepoints should be functionally complete. The documentation will follow in the fourth change, and there will likely be some cleanup changes, but interested parties can start experimenting now. I'm not particularly happy with the amount of code or complexity involved with the lowering step, but at least it's fairly well isolated. The statepoint lowering code is split into it's own files and anyone not working on the statepoint support itself should be able to ignore it. During the lowering process, we currently spill aggressively to stack. This is not entirely ideal (and we have plans to do better), but it's functional, relatively straight forward, and matches closely the implementations of the patchpoint intrinsics. Most of the complexity comes from trying to keep relocated copies of values in the same stack slots across statepoints. Doing so avoids the insertion of pointless load and store instructions to reshuffle the stack. The current implementation isn't as effective as I'd like, but it is functional and 'good enough' for many common use cases. In the long term, I'd like to figure out how to integrate the statepoint lowering with the register allocator. In principal, we shouldn't need to eagerly spill at all. The register allocator should do any spilling required and the statepoint should simply record that fact. Depending on how challenging that turns out to be, we may invest in a smarter global stack slot assignment mechanism as a stop gap measure. Reviewed by: atrick, ributzka git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223137 91177308-0d34-0410-b5e6-96231b3b80d8
75 lines
2.6 KiB
LLVM
75 lines
2.6 KiB
LLVM
; RUN: llc < %s | FileCheck %s
|
|
; This file contains a collection of basic tests to ensure we didn't
|
|
; screw up normal call lowering when there are no deopt or gc arguments.
|
|
|
|
target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-pc-linux-gnu"
|
|
|
|
declare zeroext i1 @return_i1()
|
|
declare zeroext i32 @return_i32()
|
|
declare i32* @return_i32ptr()
|
|
declare float @return_float()
|
|
|
|
define i1 @test_i1_return() {
|
|
; CHECK-LABEL: test_i1_return
|
|
; This is just checking that a i1 gets lowered normally when there's no extra
|
|
; state arguments to the statepoint
|
|
; CHECK: pushq %rax
|
|
; CHECK: callq return_i1
|
|
; CHECK: popq %rdx
|
|
; CHECK: retq
|
|
entry:
|
|
%safepoint_token = tail call i32 (i1 ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()* @return_i1, i32 0, i32 0, i32 0)
|
|
%call1 = call zeroext i1 @llvm.experimental.gc.result.int.i1(i32 %safepoint_token)
|
|
ret i1 %call1
|
|
}
|
|
|
|
define i32 @test_i32_return() {
|
|
; CHECK-LABEL: test_i32_return
|
|
; CHECK: pushq %rax
|
|
; CHECK: callq return_i32
|
|
; CHECK: popq %rdx
|
|
; CHECK: retq
|
|
entry:
|
|
%safepoint_token = tail call i32 (i32 ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_i32f(i32 ()* @return_i32, i32 0, i32 0, i32 0)
|
|
%call1 = call zeroext i32 @llvm.experimental.gc.result.int.i32(i32 %safepoint_token)
|
|
ret i32 %call1
|
|
}
|
|
|
|
define i32* @test_i32ptr_return() {
|
|
; CHECK-LABEL: test_i32ptr_return
|
|
; CHECK: pushq %rax
|
|
; CHECK: callq return_i32ptr
|
|
; CHECK: popq %rdx
|
|
; CHECK: retq
|
|
entry:
|
|
%safepoint_token = tail call i32 (i32* ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_p0i32f(i32* ()* @return_i32ptr, i32 0, i32 0, i32 0)
|
|
%call1 = call i32* @llvm.experimental.gc.result.ptr.p0i32(i32 %safepoint_token)
|
|
ret i32* %call1
|
|
}
|
|
|
|
define float @test_float_return() {
|
|
; CHECK-LABEL: test_float_return
|
|
; CHECK: pushq %rax
|
|
; CHECK: callq return_float
|
|
; CHECK: popq %rax
|
|
; CHECK: retq
|
|
entry:
|
|
%safepoint_token = tail call i32 (float ()*, i32, i32, ...)* @llvm.experimental.gc.statepoint.p0f_f32f(float ()* @return_float, i32 0, i32 0, i32 0)
|
|
%call1 = call float @llvm.experimental.gc.result.float.f32(i32 %safepoint_token)
|
|
ret float %call1
|
|
}
|
|
|
|
declare i32 @llvm.experimental.gc.statepoint.p0f_i1f(i1 ()*, i32, i32, ...)
|
|
declare i1 @llvm.experimental.gc.result.int.i1(i32)
|
|
|
|
declare i32 @llvm.experimental.gc.statepoint.p0f_i32f(i32 ()*, i32, i32, ...)
|
|
declare i32 @llvm.experimental.gc.result.int.i32(i32)
|
|
|
|
declare i32 @llvm.experimental.gc.statepoint.p0f_p0i32f(i32* ()*, i32, i32, ...)
|
|
declare i32* @llvm.experimental.gc.result.ptr.p0i32(i32)
|
|
|
|
declare i32 @llvm.experimental.gc.statepoint.p0f_f32f(float ()*, i32, i32, ...)
|
|
declare float @llvm.experimental.gc.result.float.f32(i32)
|
|
|