function eml_shift_checks(fnname, a, shift_idx)

%   Copyright 2002-2014 The MathWorks, Inc.

%#codegen

coder.internal.prefer_const(fnname, a, shift_idx);

eml_invariant(isscalar(shift_idx) && isreal(shift_idx), ...
    'fixed:bitsxx:invalidShiftVal', fnname);

if isfi(a)
    aNT = numerictype(a);
    eml_invariant(aNT.WordLength > 1, ...
                  'fixed:coder:bitsxxInpWLMustBeGTOne', fnname);
    
    % Except for bitshift, none of the functions support slope bias inputs
    if ~strcmp(fnname, 'bitshift')
        eml_invariant(~eml_isslopebiasscaled(a), ...
            'fixed:coder:slopeBiasInputsNotSupported');
    end
end

% Avoid run-time checking. Do checking only if shift value is a constant.
if eml_is_const(shift_idx)
    eml_invariant(isequal(double(shift_idx), coder.const(double(int32(shift_idx)))), ...
        'fixed:bitsxx:invalidShiftVal', fnname);
end
