mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 02:33:33 +00:00
CodeGen: soften f16 type by default instead of marking legal.
Actual support for softening f16 operations is still limited, and can be added when it's needed. But Soften is much closer to being a useful thing to try than keeping it Legal when no registers can actually hold such values. Longer term, we probably want something between Soften and Promote semantics for most targets, it'll be more efficient to promote the 4 basic operations to f32 than libcall them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213372 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dc80347f0e
commit
0afed03229
@ -1635,7 +1635,7 @@ public:
|
|||||||
LegalizeTypeAction LA = ValueTypeActions.getTypeAction(SVT);
|
LegalizeTypeAction LA = ValueTypeActions.getTypeAction(SVT);
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
(LA == TypeLegal ||
|
(LA == TypeLegal || LA == TypeSoftenFloat ||
|
||||||
ValueTypeActions.getTypeAction(NVT) != TypePromoteInteger)
|
ValueTypeActions.getTypeAction(NVT) != TypePromoteInteger)
|
||||||
&& "Promote may not follow Expand or Promote");
|
&& "Promote may not follow Expand or Promote");
|
||||||
|
|
||||||
|
@ -1104,6 +1104,13 @@ void TargetLoweringBase::computeRegisterProperties() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isTypeLegal(MVT::f16)) {
|
||||||
|
NumRegistersForVT[MVT::f16] = NumRegistersForVT[MVT::i16];
|
||||||
|
RegisterTypeForVT[MVT::f16] = RegisterTypeForVT[MVT::i16];
|
||||||
|
TransformToType[MVT::f16] = MVT::i16;
|
||||||
|
ValueTypeActions.setTypeAction(MVT::f16, TypeSoftenFloat);
|
||||||
|
}
|
||||||
|
|
||||||
// Loop over all of the vector value types to see which need transformations.
|
// Loop over all of the vector value types to see which need transformations.
|
||||||
for (unsigned i = MVT::FIRST_VECTOR_VALUETYPE;
|
for (unsigned i = MVT::FIRST_VECTOR_VALUETYPE;
|
||||||
i <= (unsigned)MVT::LAST_VECTOR_VALUETYPE; ++i) {
|
i <= (unsigned)MVT::LAST_VECTOR_VALUETYPE; ++i) {
|
||||||
|
26
test/CodeGen/AArch64/half.ll
Normal file
26
test/CodeGen/AArch64/half.ll
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
; RUN: llc < %s -mtriple=arm64-apple-ios7.0 | FileCheck %s
|
||||||
|
|
||||||
|
define void @test_load_store(half* %in, half* %out) {
|
||||||
|
; CHECK-LABEL: test_load_store:
|
||||||
|
; CHECK: ldr [[TMP:h[0-9]+]], [x0]
|
||||||
|
; CHECK: str [[TMP]], [x1]
|
||||||
|
%val = load half* %in
|
||||||
|
store half %val, half* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define i16 @test_bitcast_from_half(half* %addr) {
|
||||||
|
; CHECK-LABEL: test_bitcast_from_half:
|
||||||
|
; CHECK: ldrh w0, [x0]
|
||||||
|
%val = load half* %addr
|
||||||
|
%val_int = bitcast half %val to i16
|
||||||
|
ret i16 %val_int
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @test_bitcast_to_half(half* %addr, i16 %in) {
|
||||||
|
; CHECK-LABEL: test_bitcast_to_half:
|
||||||
|
; CHECK: strh w1, [x0]
|
||||||
|
%val_fp = bitcast i16 %in to half
|
||||||
|
store half %val_fp, half* %addr
|
||||||
|
ret void
|
||||||
|
}
|
26
test/CodeGen/ARM/half.ll
Normal file
26
test/CodeGen/ARM/half.ll
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
; RUN: llc < %s -mtriple=thumbv7s-apple-ios7.0 | FileCheck %s
|
||||||
|
|
||||||
|
define void @test_load_store(half* %in, half* %out) {
|
||||||
|
; CHECK-LABEL: test_load_store:
|
||||||
|
; CHECK: ldrh [[TMP:r[0-9]+]], [r0]
|
||||||
|
; CHECK: strh [[TMP]], [r1]
|
||||||
|
%val = load half* %in
|
||||||
|
store half %val, half* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define i16 @test_bitcast_from_half(half* %addr) {
|
||||||
|
; CHECK-LABEL: test_bitcast_from_half:
|
||||||
|
; CHECK: ldrh r0, [r0]
|
||||||
|
%val = load half* %addr
|
||||||
|
%val_int = bitcast half %val to i16
|
||||||
|
ret i16 %val_int
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @test_bitcast_to_half(half* %addr, i16 %in) {
|
||||||
|
; CHECK-LABEL: test_bitcast_to_half:
|
||||||
|
; CHECK: strh r1, [r0]
|
||||||
|
%val_fp = bitcast i16 %in to half
|
||||||
|
store half %val_fp, half* %addr
|
||||||
|
ret void
|
||||||
|
}
|
30
test/CodeGen/NVPTX/half.ll
Normal file
30
test/CodeGen/NVPTX/half.ll
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
; RUN: llc < %s -march=nvptx | FileCheck %s
|
||||||
|
|
||||||
|
define void @test_load_store(half addrspace(1)* %in, half addrspace(1)* %out) {
|
||||||
|
; CHECK-LABEL: @test_load_store
|
||||||
|
; CHECK: ld.global.u16 [[TMP:%rs[0-9]+]], [{{%r[0-9]+}}]
|
||||||
|
; CHECK: st.global.u16 [{{%r[0-9]+}}], [[TMP]]
|
||||||
|
%val = load half addrspace(1)* %in
|
||||||
|
store half %val, half addrspace(1) * %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @test_bitcast_from_half(half addrspace(1)* %in, i16 addrspace(1)* %out) {
|
||||||
|
; CHECK-LABEL: @test_bitcast_from_half
|
||||||
|
; CHECK: ld.global.u16 [[TMP:%rs[0-9]+]], [{{%r[0-9]+}}]
|
||||||
|
; CHECK: st.global.u16 [{{%r[0-9]+}}], [[TMP]]
|
||||||
|
%val = load half addrspace(1) * %in
|
||||||
|
%val_int = bitcast half %val to i16
|
||||||
|
store i16 %val_int, i16 addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @test_bitcast_to_half(half addrspace(1)* %out, i16 addrspace(1)* %in) {
|
||||||
|
; CHECK-LABEL: @test_bitcast_to_half
|
||||||
|
; CHECK: ld.global.u16 [[TMP:%rs[0-9]+]], [{{%r[0-9]+}}]
|
||||||
|
; CHECK: st.global.u16 [{{%r[0-9]+}}], [[TMP]]
|
||||||
|
%val = load i16 addrspace(1)* %in
|
||||||
|
%val_fp = bitcast i16 %val to half
|
||||||
|
store half %val_fp, half addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
30
test/CodeGen/R600/half.ll
Normal file
30
test/CodeGen/R600/half.ll
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
; RUN: llc < %s -march=r600 -mcpu=SI | FileCheck %s
|
||||||
|
|
||||||
|
define void @test_load_store(half addrspace(1)* %in, half addrspace(1)* %out) {
|
||||||
|
; CHECK-LABEL: @test_load_store
|
||||||
|
; CHECK: BUFFER_LOAD_USHORT [[TMP:v[0-9]+]]
|
||||||
|
; CHECK: BUFFER_STORE_SHORT [[TMP]]
|
||||||
|
%val = load half addrspace(1)* %in
|
||||||
|
store half %val, half addrspace(1) * %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @test_bitcast_from_half(half addrspace(1)* %in, i16 addrspace(1)* %out) {
|
||||||
|
; CHECK-LABEL: @test_bitcast_from_half
|
||||||
|
; CHECK: BUFFER_LOAD_USHORT [[TMP:v[0-9]+]]
|
||||||
|
; CHECK: BUFFER_STORE_SHORT [[TMP]]
|
||||||
|
%val = load half addrspace(1) * %in
|
||||||
|
%val_int = bitcast half %val to i16
|
||||||
|
store i16 %val_int, i16 addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @test_bitcast_to_half(half addrspace(1)* %out, i16 addrspace(1)* %in) {
|
||||||
|
; CHECK-LABEL: @test_bitcast_to_half
|
||||||
|
; CHECK: BUFFER_LOAD_USHORT [[TMP:v[0-9]+]]
|
||||||
|
; CHECK: BUFFER_STORE_SHORT [[TMP]]
|
||||||
|
%val = load i16 addrspace(1)* %in
|
||||||
|
%val_fp = bitcast i16 %val to half
|
||||||
|
store half %val_fp, half addrspace(1)* %out
|
||||||
|
ret void
|
||||||
|
}
|
27
test/CodeGen/X86/half.ll
Normal file
27
test/CodeGen/X86/half.ll
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
; RUN: llc < %s -march=x86-64 -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=-f16c | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-LIBCALL
|
||||||
|
; RUN: llc < %s -march=x86-64 -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+f16c | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-F16C
|
||||||
|
|
||||||
|
define void @test_load_store(half* %in, half* %out) {
|
||||||
|
; CHECK-LABEL: test_load_store:
|
||||||
|
; CHECK: movw (%rdi), [[TMP:%[a-z0-9]+]]
|
||||||
|
; CHECK: movw [[TMP]], (%rsi)
|
||||||
|
%val = load half* %in
|
||||||
|
store half %val, half* %out
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
define i16 @test_bitcast_from_half(half* %addr) {
|
||||||
|
; CHECK-LABEL: test_bitcast_from_half:
|
||||||
|
; CHECK: movzwl (%rdi), %eax
|
||||||
|
%val = load half* %addr
|
||||||
|
%val_int = bitcast half %val to i16
|
||||||
|
ret i16 %val_int
|
||||||
|
}
|
||||||
|
|
||||||
|
define void @test_bitcast_to_half(half* %addr, i16 %in) {
|
||||||
|
; CHECK-LABEL: test_bitcast_to_half:
|
||||||
|
; CHECK: movw %si, (%rdi)
|
||||||
|
%val_fp = bitcast i16 %in to half
|
||||||
|
store half %val_fp, half* %addr
|
||||||
|
ret void
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user