%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*- fundamental -*-
% fftw_isdefinitions.pl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Description:	This module features the definitions of scalar instructions
%		and a few related data-types.
% 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:16:04 CET 2003: created
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

is_scalarinstrs([]).
is_scalarinstrs([X|Xs]) :-
   is_scalarinstr(X),
   is_scalarinstrs(Xs).

is_scalarinstr(load(Access, Array, Index, Reg)) :-
   is_access(Access),
   is_inputarray(Array),  
   is_index(Index),
   is_scalarreg(Reg).
is_scalarinstr(store(Reg, Access, Array, Index)) :-
   is_scalarreg(Reg),
   is_access(Access),
   is_outputarray(Array),  
   is_index(Index).
is_scalarinstr(binop(BOp,S1,S2,D)) :-
   is_scalarbinop(BOp),
   is_scalarregs([S1,S2,D]).
is_scalarinstr(unaryop(UOp,S,D)) :-
   is_scalarunaryop(UOp),
   is_scalarregs([S,D]).

is_scalarunaryop(mulconst(K)) :-
   atom(K).

is_scalarbinop(add).
is_scalarbinop(sub).
is_scalarbinop(mul).

is_access(real).
is_access(P) :-
   is_interleavedcomplexaccess(P).
is_access(P) :-
   is_splitcomplexaccess(P).

is_interleavedcomplexaccess(realPartOfIComplex).
is_interleavedcomplexaccess(imagPartOfIComplex).

is_splitcomplexaccess(realPartOfSComplex).
is_splitcomplexaccess(imagPartOfSComplex).

is_scalarregs([]).
is_scalarregs([R|Rs]) :-
   is_scalarreg(R),
   is_scalarregs(Rs).

is_scalarreg(R) :-
   atom(R).

is_array(A) :-
   is_inputarray(A).
is_array(A) :-
   is_outputarray(A).

is_inputarray(input).
is_inputarray(twiddle).

is_outputarray(output).

is_index(I) :-
   integer(I).