Example #1
0
 def not_(self, value, name=""):
     """
     Bitwise integer complement:
         name = ~value
     """
     if isinstance(value.type, types.VectorType):
         rhs = values.Constant(value.type, (-1, ) * value.type.count)
     else:
         rhs = values.Constant(value.type, -1)
     return self.xor(value, rhs, name=name)
Example #2
0
    def not_(self):
        """
        Bitwise integer complement:
            ~value
        """
        if isinstance(self.type, types.VectorType):
            rhs = values.Constant(self.type, (-1, ) * self.type.count)
        else:
            rhs = values.Constant(self.type, -1)

        return self.xor(rhs)
Example #3
0
 def neg(self):
     """
     Integer negative:
         -value
     """
     zero = values.Constant(self.type, 0)
     return zero.sub(self)
Example #4
0
    def alloca(self, typ, size=None, name=""):
        """
        Stack-allocate a slot for *size* elements of the given type.
        (default one element)
        """
        if size is None:
            pass
        elif isinstance(size, (values.Value, values.Constant)):
            assert isinstance(size.type, types.IntType)
        else:
            # If it is not a Value instance,
            # assume to be a Python integer.
            size = values.Constant(types.IntType(32), size)

        al = instructions.AllocaInstr(self.block, typ, size, name)
        self._insert(al)
        return al
Example #5
0
 def neg(self, value, name=""):
     """
     Integer negative:
         name = -value
     """
     return self.sub(values.Constant(value.type, 0), value, name=name)