def __init__(self, parent, vector1, vector2, mask, name=""): if not isinstance(vector1.type, types.VectorType): raise TypeError("vector1 needs to be of VectorType.") if vector2 != Undefined: if vector2.type != vector1.type: raise TypeError( "vector2 needs to be " + "Undefined or of the same type as vector1." ) if ( not isinstance(mask, Constant) or not isinstance(mask.type, types.VectorType) or not ( isinstance(mask.type.element, types.IntType) and mask.type.element.width == 32 ) ): raise TypeError("mask needs to be a constant i32 vector.") typ = types.VectorType(vector1.type.element, mask.type.count) index_range = range( vector1.type.count if vector2 == Undefined else 2 * vector1.type.count ) if not all(ii.constant in index_range for ii in mask.constant): raise IndexError("mask values need to be in {0}".format(index_range),) super(ShuffleVector, self).__init__( parent, typ, "shufflevector", [vector1, vector2, mask], name=name )
def __init__(self, parent, op, lhs, rhs, name='', flags=[]): if op not in self.VALID_OP: raise ValueError("invalid comparison %r for %s" % (op, self.OPNAME)) for flag in flags: if flag not in self.VALID_FLAG: raise ValueError("invalid flag %r for %s" % (flag, self.OPNAME)) opname = self.OPNAME if isinstance(lhs.type, types.VectorType): typ = types.VectorType(types.IntType(1), lhs.type.count) else: typ = types.IntType(1) super(CompareInstr, self).__init__(parent, typ, opname, [lhs, rhs], flags=flags, name=name) self.op = op