aarch64: Implement iadd for i128 operands

This commit is contained in:
Afonso Bordado
2021-05-14 18:12:13 +01:00
parent b8fd632fb5
commit d3b525fa29
6 changed files with 179 additions and 67 deletions

View File

@@ -0,0 +1,39 @@
test run
target aarch64
; i128 tests
; TODO: It would be nice if we had native support for i128 immediates in CLIF's parser
function %i128_const_0() -> i64, i64 {
block0:
v1 = iconst.i128 0
v2, v3 = isplit v1
return v2, v3
}
; run: %i128_const_0() == [0, 0]
; TODO: Blocked by https://github.com/bytecodealliance/wasmtime/issues/2906
;function %i128_const_neg_1() -> i64, i64 {
;block0:
; v1 = iconst.i128 -1
; v2, v3 = isplit v1
; return v2, v3
;}
; r-un: %i128_const_neg_1() == [0xffffffff_ffffffff, 0xffffffff_ffffffff]
function %add_i128(i64, i64, i64, i64) -> i64, i64 {
block0(v0: i64,v1: i64,v2: i64,v3: i64):
v4 = iconcat v0, v1
v5 = iconcat v2, v3
v6 = iadd v4, v5
v7, v8 = isplit v6
return v7, v8
}
; run: %add_i128(0, 0, 0, 0) == [0, 0]
; run: %add_i128(0, -1, -1, 0) == [-1, -1]
; run: %add_i128(1, 0, 0, 0) == [1, 0]
; run: %add_i128(1, 0, 1, 0) == [2, 0]
; run: %add_i128(1, 0, -1, -1) == [0, 0]
; run: %add_i128(-1, 0, 1, 0) == [0, 1]

View File

@@ -425,3 +425,18 @@ block0(v0: i8x16):
; nextln: ushl v0.16b, v0.16b, v1.16b
; nextln: ldp fp, lr, [sp], #16
; nextln: ret
function %add_i128(i128, i128) -> i128 {
block0(v0: i128, v1: i128):
v2 = iadd v0, v1
return v2
}
; check: stp fp, lr, [sp, #-16]!
; nextln: mov fp, sp
; nextln: adds x0, x0, x2
; nextln: adc x1, x1, x3
; nextln: ldp fp, lr, [sp], #16
; nextln: ret