%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*- fundamental -*-
% fftwgel_isdefinitions.pl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Description:	This module features the definitions of SIMD instructions.
% Language:	SICStus Prolog 3
% Copyright:	2003, Stefan Kral
% Author: 	Stefan Kral (URL mailto:skral@complang.tuwien.ac.at)
% License:	GNU General Public License (GPL) Version 2 (or higher)
% History:	Fri Feb 21 12:17:13 CET 2003: created
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

:- use_module(fftw_isdefinitions).

is_simdinstrs([]).
is_simdinstrs([X|Xs]) :-
   is_simdinstr(X),
   is_simdinstrs(Xs).

is_simdinstr(simd_load1(P,A,X,D1+0)) :-
   is_access(P),
   is_array(A),
   is_index(X),
   is_scalarreg(D1).
is_simdinstr(simd_load2(P1,A1,X1,P2,A2,X2,D1+D2)) :-
   is_access(P1),
   is_array(A1),
   is_index(X1),
   is_access(P2),
   is_array(A2),
   is_index(X2),
   is_scalarregs([D1,D2]).
is_simdinstr(simd_store2(S1+S2,P1,A1,X1,P2,A2,X2)) :-
   is_scalarregs([S1,S2]),
   is_access(P1),
   is_array(A1),
   is_index(X1),
   is_access(P2),
   is_array(A2),
   is_index(X2).
is_simdinstr(simd_unaryop1(lo,Op,S1+D2,D1+D2)) :-
   is_scalarunaryop(Op),
   is_scalarregs([S1,D1,D2]).
is_simdinstr(simd_unaryop1(hi,Op,D1+S2,D1+D2)) :-
   is_scalarunaryop(Op),
   is_scalarregs([S2,D1,D2]).
is_simdinstr(simd_unaryop2(Op1,Op2,S1+S2,D1+D2)) :-
   is_scalarunaryop(Op1),
   is_scalarunaryop(Op2),
   is_scalarregs([S1,S2,D1,D2]).
is_simdinstr(simd_binop2(BType, Op1, Op2, S1+S2, T1+T2, D1+D2)) :-
   is_simdbindingtype(BType),
   is_scalarbinop(Op1),
   is_scalarbinop(Op2),
   is_scalarregs([S1,S2,T1,T2,D1,D2]).
is_simdinstr(simd_binop2(acc, Op1, Op2, S1+0, T1+T2, S1+D2)) :-
   is_scalarbinop(Op1),
   is_scalarbinop(Op2),
   is_scalarregs([S1,T1,T2,D2]).
is_simdinstr(simd_binop2(acc, Op1, Op2, S1+S2, T1+0, D1+T1)) :-
   is_scalarbinop(Op1),
   is_scalarbinop(Op2),
   is_scalarregs([S1,S2,T1,D1]).

is_simdbindingtype(acc).
is_simdbindingtype(par).
is_simdbindingtype(chi).
