def visit_Call(self, node): func_type = node.func.type if self.query(node, "is_math"): assert node.func.type.is_known_value result = resolve_math_call(node, node.func.type.value) return self.visit(result) elif func_type.is_builtin: result = self._resolve_builtin_call_or_object(node, func_type.func) result = self.visit(result) return result self.generic_visit(node) return node
def _resolve_abs(self, func, node, argtype): is_math = is_math_function(node.args, abs) # TODO: generate efficient inline code if is_math and argtype.is_float: return resolve_math_call(node, abs) elif is_math and argtype.is_int: if argtype.signed: type = promote_closest(self.context, argtype, [long_, longlong]) funcs = {long_: 'labs', longlong: 'llabs'} return function_util.external_call( self.context, self.llvm_module, funcs[type], args=[node.args[0]]) else: # abs() on unsigned integral value return node.args[0] return None
def _resolve_abs(self, func, node, argtype): is_math = is_math_function(node.args, abs) # TODO: generate efficient inline code if is_math and argtype.is_float: return resolve_math_call(node, abs) elif is_math and argtype.is_int: if argtype.signed: type = promote_closest(self.context, argtype, [long_, longlong]) funcs = {long_: 'labs', longlong: 'llabs'} return function_util.external_call(self.context, self.llvm_module, funcs[type], args=[node.args[0]]) else: # abs() on unsigned integral value return node.args[0] return None
def _resolve_round(self, func, node, argtype): if is_math_function(node.args, round): # round() always returns a float return resolve_math_call(node, round) return None