// http://llvm.org/docs/LangRef.html#srem-instr
// keywords: arithmetic; binary; instr

.type SRemInstruction <: symbol
.decl srem_instr(instr:SRemInstruction)

instr(v) :- srem_instr(v).

.decl srem_instr_first_operand(instr:SRemInstruction, op:Operand)
.decl srem_instr_second_operand(instr:SRemInstruction, op:Operand)


//------------------------------------------------------------------------------
// [Constraints]
//
// 1) The two arguments to the ‘srem‘ instr must be:
//      (i)  integer or
//      (ii) vector of integer values.
//
// 2) Both arguments must have identical types.
//
// 3) The resulting value is the same type as its operands.
//------------------------------------------------------------------------------

schema_invalid_instr(Instr, __FILE__, __LINE__) :-
   schema_sanity(),
   srem_instr(Instr),
   !srem_instr_first_operand(Instr, _).

schema_invalid_instr(Instr, __FILE__, __LINE__) :-
   schema_sanity(),
   srem_instr(Instr),
   !srem_instr_second_operand(Instr, _).

schema_invalid_instr(Instr, __FILE__, __LINE__) :-
   schema_sanity(),
   srem_instr(Instr),
   instr_returns_type(Instr, Type),
   !integer_type(Type),
   !integer_vector_type(Type).

schema_invalid_instr(Instr, __FILE__, __LINE__) :-
   schema_sanity(),
   instr_returns_type(Instr, Type),
   srem_instr_first_operand(Instr, LeftOp),
   !operand_has_type(LeftOp, Type).

schema_invalid_instr(Instr, __FILE__, __LINE__) :-
   schema_sanity(),
   instr_returns_type(Instr, Type),
   srem_instr_second_operand(Instr, RightOp),
   !operand_has_type(RightOp, Type).
