mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-02 00:16:25 +00:00
2a6af41342
The LDD/STD instructions can load/store a 64bit quantity from/to memory to/from a consecutive even/odd pair of (32-bit) registers. They are part of SparcV8, and also present in SparcV9. (Although deprecated there, as you can store 64bits in one register). As recommended on llvmdev in the thread "How to enable use of 64bit load/store for 32bit architecture" from Apr 2015, I've modeled the 64-bit load/store operations as working on a v2i32 type, rather than making i64 a legal type, but with few legal operations. The latter does not (currently) work, as there is much code in llvm which assumes that if i64 is legal, operations like "add" will actually work on it. The same assumption does not hold for v2i32 -- for vector types, it is workable to support only load/store, and expand everything else. This patch: - Adds a new register class, IntPair, for even/odd pairs of registers. - Modifies the list of reserved registers, the stack spilling code, and register copying code to support the IntPair register class. - Adds support in AsmParser. (note that in asm text, you write the name of the first register of the pair only. So the parser has to morph the single register into the equivalent paired register). - Adds the new instructions themselves (LDD/STD/LDDA/STDA). - Hooks up the instructions and registers as a vector type v2i32. Adds custom legalizer to transform i64 load/stores into v2i32 load/stores and bitcasts, so that the new instructions can actually be generated, and marks all operations other than load/store on v2i32 as needing to be expanded. - Copies the unfortunate SelectInlineAsm hack from ARMISelDAGToDAG. This hack undoes the transformation of i64 operands into two arbitrarily-allocated separate i32 registers in SelectionDAGBuilder. and instead passes them in a single IntPair. (Arbitrarily allocated registers are not useful, asm code expects to be receiving a pair, which can be passed to ldd/std.) Also adds a bunch of test cases covering all the bugs I've added along the way. Differential Revision: http://reviews.llvm.org/D8713 llvm-svn: 244484
85 lines
2.5 KiB
LLVM
85 lines
2.5 KiB
LLVM
; RUN: llc -march=sparc <%s | FileCheck %s
|
|
|
|
; CHECK-LABEL: test_constraint_r
|
|
; CHECK: add %o1, %o0, %o0
|
|
define i32 @test_constraint_r(i32 %a, i32 %b) {
|
|
entry:
|
|
%0 = tail call i32 asm sideeffect "add $2, $1, $0", "=r,r,r"(i32 %a, i32 %b)
|
|
ret i32 %0
|
|
}
|
|
|
|
; CHECK-LABEL: test_constraint_I:
|
|
; CHECK: add %o0, 1023, %o0
|
|
define i32 @test_constraint_I(i32 %a) {
|
|
entry:
|
|
%0 = tail call i32 asm sideeffect "add $1, $2, $0", "=r,r,rI"(i32 %a, i32 1023)
|
|
ret i32 %0
|
|
}
|
|
|
|
; CHECK-LABEL: test_constraint_I_neg:
|
|
; CHECK: add %o0, -4096, %o0
|
|
define i32 @test_constraint_I_neg(i32 %a) {
|
|
entry:
|
|
%0 = tail call i32 asm sideeffect "add $1, $2, $0", "=r,r,rI"(i32 %a, i32 -4096)
|
|
ret i32 %0
|
|
}
|
|
|
|
; CHECK-LABEL: test_constraint_I_largeimm:
|
|
; CHECK: sethi 9, [[R0:%[gilo][0-7]]]
|
|
; CHECK: or [[R0]], 784, [[R1:%[gilo][0-7]]]
|
|
; CHECK: add %o0, [[R1]], %o0
|
|
define i32 @test_constraint_I_largeimm(i32 %a) {
|
|
entry:
|
|
%0 = tail call i32 asm sideeffect "add $1, $2, $0", "=r,r,rI"(i32 %a, i32 10000)
|
|
ret i32 %0
|
|
}
|
|
|
|
; CHECK-LABEL: test_constraint_reg:
|
|
; CHECK: ldda [%o1] 43, %g2
|
|
; CHECK: ldda [%o1] 43, %g4
|
|
define void @test_constraint_reg(i32 %s, i32* %ptr) {
|
|
entry:
|
|
%0 = tail call i64 asm sideeffect "ldda [$1] $2, $0", "={r2},r,n"(i32* %ptr, i32 43)
|
|
%1 = tail call i64 asm sideeffect "ldda [$1] $2, $0", "={g4},r,n"(i32* %ptr, i32 43)
|
|
ret void
|
|
}
|
|
|
|
;; Ensure that i64 args to asm are allocated to the IntPair register class.
|
|
;; Also checks that register renaming for leaf proc works.
|
|
; CHECK-LABEL: test_constraint_r_i64:
|
|
; CHECK: mov %o0, %o5
|
|
; CHECK: sra %o5, 31, %o4
|
|
; CHECK: std %o4, [%o1]
|
|
define i32 @test_constraint_r_i64(i32 %foo, i64* %out, i32 %o) {
|
|
entry:
|
|
%conv = sext i32 %foo to i64
|
|
tail call void asm sideeffect "std $0, [$1]", "r,r,~{memory}"(i64 %conv, i64* %out)
|
|
ret i32 %o
|
|
}
|
|
|
|
;; Same test without leaf-proc opt
|
|
; CHECK-LABEL: test_constraint_r_i64_noleaf:
|
|
; CHECK: mov %i0, %i5
|
|
; CHECK: sra %i5, 31, %i4
|
|
; CHECK: std %i4, [%i1]
|
|
define i32 @test_constraint_r_i64_noleaf(i32 %foo, i64* %out, i32 %o) #0 {
|
|
entry:
|
|
%conv = sext i32 %foo to i64
|
|
tail call void asm sideeffect "std $0, [$1]", "r,r,~{memory}"(i64 %conv, i64* %out)
|
|
ret i32 %o
|
|
}
|
|
attributes #0 = { "no-frame-pointer-elim"="true" }
|
|
|
|
;; Ensures that tied in and out gets allocated properly.
|
|
; CHECK-LABEL: test_i64_inout:
|
|
; CHECK: sethi 0, %o2
|
|
; CHECK: mov 5, %o3
|
|
; CHECK: xor %o2, %g0, %o2
|
|
; CHECK: mov %o2, %o0
|
|
; CHECK: ret
|
|
define i64 @test_i64_inout() {
|
|
entry:
|
|
%0 = call i64 asm sideeffect "xor $1, %g0, $0", "=r,0,~{i1}"(i64 5);
|
|
ret i64 %0
|
|
}
|