Skip to content

Commit dd13f57

Browse files
committed
Add a new version of simd function to allow three arguments for x86_VPBLENDD
1 parent a13a333 commit dd13f57

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

x86/proofs/x86.ml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,24 +1311,39 @@ let x86_VPADDW = new_definition
13111311
let res:(128)word = simd8 word_add (word_zx x) (word_zx y) in
13121312
(dest := (word_zx res):N word) s`;;
13131313

1314+
(* TODO: move to HOL Light *)
1315+
let msimd2 = new_definition
1316+
`(msimd2:(M word->N word->N word->N word)->
1317+
((M)tybit0)word->((N)tybit0)word->((N)tybit0) word->((N)tybit0) word) f m x y =
1318+
word_join (f (word_subword m (dimindex(:M),dimindex(:M)))
1319+
(word_subword x (dimindex(:N),dimindex(:N)))
1320+
(word_subword y (dimindex(:N),dimindex(:N))))
1321+
(f (word_subword m (0,dimindex(:M)))
1322+
(word_subword x (0,dimindex(:N)))
1323+
(word_subword y (0,dimindex(:N))))`;;
1324+
1325+
let msimd4 = new_definition
1326+
`msimd4 (f:M word->N word->N word->N word) = msimd2 (msimd2 f)`;;
1327+
1328+
let msimd8 = new_definition
1329+
`msimd8 (f:M word->N word->N word->N word) = msimd2 (msimd4 f)`;;
1330+
1331+
let msimd16 = new_definition
1332+
`msimd16 (f:M word->N word->N word->N word) = msimd2 (msimd8 f)`;;
1333+
13141334
let x86_VPBLENDD = new_definition
13151335
`x86_VPBLENDD dest src1 src2 imm8 (s:x86state) =
13161336
let (x:N word) = read src1 s
13171337
and (y:N word) = read src2 s
1318-
and mask_val = val(read imm8 s) in
1338+
and imm8 = read imm8 s in
1339+
let fn = \(i:(1)word) (x:int32) (y:int32). if i = word 1 then x else y in
13191340
if dimindex(:N) = 256 then
1320-
let res:(256)word = usimd8 (\(i:(3)word).
1321-
let x_elem = word_subword (word_zx x) ((val i)*32, 32)
1322-
and y_elem = word_subword (word_zx y) ((val i)*32, 32) in
1323-
if bit (val i) (word mask_val) then y_elem else x_elem) (word_zx x) in
1341+
let res:(256)word = msimd8 fn (word_zx imm8) (word_zx x) (word_zx y) in
13241342
(dest := (word_zx res):N word) s
13251343
else
1326-
let res:(128)word = usimd4 (\(i:(2)word).
1327-
let x_elem = word_subword (word_zx x) ((val i)*32, 32)
1328-
and y_elem = word_subword (word_zx y) ((val i)*32, 32) in
1329-
if bit (val i) (word mask_val) then y_elem else x_elem) (word_zx x) in
1344+
let res:(128)word = msimd4 fn (word_zx imm8) (word_zx x) (word_zx y) in
13301345
(dest := (word_zx res):N word) s`;;
1331-
1346+
13321347
let x86_VPMULHW = new_definition
13331348
`x86_VPMULHW dest src1 src2 (s:x86state) =
13341349
let (x:N word) = read src1 s
@@ -2823,7 +2838,7 @@ let x86_RET_POP_RIP = prove
28232838
(*** Simplify word operations in SIMD instructions ***)
28242839

28252840
let all_simd_rules =
2826-
[usimd16;usimd8;usimd4;usimd2;simd16;simd8;simd4;simd2];;
2841+
[usimd16;usimd8;usimd4;usimd2;simd16;simd8;simd4;simd2;msimd16;msimd8;msimd4;msimd2];;
28272842

28282843
let EXPAND_SIMD_RULE =
28292844
CONV_RULE (TOP_DEPTH_CONV WORD_SIMPLE_SUBWORD_CONV) o

0 commit comments

Comments
 (0)