def generate_emulate(self, result, mpfr_x, mpfr_rnd): """ generate the emulation code for ML_Log2 functions mpfr_x is a mpfr_t variable which should have the right precision mpfr_rnd is the rounding mode """ emulate_func_name = "mpfr_acos" emulate_func_op = FunctionOperator(emulate_func_name, arg_map = {0: FO_Result(0), 1: FO_Arg(0), 2: FO_Arg(1)}, require_header = ["mpfr.h"]) emulate_func = FunctionObject(emulate_func_name, [ML_Mpfr_t, ML_Int32], ML_Mpfr_t, emulate_func_op) mpfr_call = Statement(ReferenceAssign(result, emulate_func(mpfr_x, mpfr_rnd))) return mpfr_call
def __init__(self, pattern, arity=1, exu=None, **kw): TemplateOperatorFormat.__init__( self, pattern, arg_map=({ index: arg_obj for (index, arg_obj) in [(0, FO_Result())] + [(i + 1, FO_Arg(i)) for i in range(arity)] }), *kw) MachineInstruction.__init__(self, exu)
def generate_scheme(self): #func_implementation = CodeFunction(self.function_name, output_format = self.precision) vx = self.implementation.add_input_variable("x", self.get_input_precision()) mpfr_x = Conversion(vx, precision = ML_Mpfr_t) emulate_func_name = "mpfr_exp" emulate_func_op = FunctionOperator(emulate_func_name, arg_map = {0: FO_Result(0), 1: FO_Arg(0)}, require_header = ["mpfr.h"]) emulate_func = FunctionObject(emulate_func_name, [ML_Mpfr_t], ML_Mpfr_t, emulate_func_op) emulate_func_op.declare_prototype = emulate_func mpfr_call = Conversion(emulate_func(mpfr_x), precision = self.precision) scheme = Statement(Return(mpfr_call)) return scheme
def generate_emulate(self, result, mpfr_x, mpfr_rnd): """ generate the emulation code for ML_Log2 functions mpfr_x is a mpfr_t variable which should have the right precision mpfr_rnd is the rounding mode """ #mpfr_x = emulate_implementation.add_input_variable("x", ML_Mpfr_t) #mpfr_rnd = emulate_implementation.add_input_variable("rnd", ML_Int32) emulate_func_name = "mpfr_log10" emulate_func_op = FunctionOperator(emulate_func_name, arg_map={ 0: FO_Result(0), 1: FO_Arg(0), 2: FO_Arg(1) }, require_header=["mpfr.h"]) emulate_func = FunctionObject(emulate_func_name, [ML_Mpfr_t, ML_Int32], ML_Mpfr_t, emulate_func_op) #emulate_func_op.declare_prototype = emulate_func mpfr_call = Statement( ReferenceAssign(result, emulate_func(mpfr_x, mpfr_rnd))) return mpfr_call
StandardAsmOperator("faddd {} = {}, {}", arity=2, exu=DA_FPU), type_strict_match(v4float32, v4float32, v4float32): StandardAsmOperator("faddwq {} = {}, {}", arity=2, exu=DA_FPU), }, }, }, Subtraction: { None: { lambda _: True: { type_strict_match_list([ML_Int32, ML_UInt32], [ ML_UInt32, ML_Int32 ], [ML_Int32, ML_UInt32]): # subtract from: op1 - op0 (reverse) AdvancedAsmOperator("sbfw {} = {}, {}", arg_map={ 0: FO_Result(), 1: FO_Arg(1), 2: FO_Arg(0) }, arity=2, exu=DA_ALU), type_strict_match(ML_Binary32, ML_Binary32, ML_Binary32): # subtract from: op1 - op0 (reverse) AdvancedAsmOperator("fsbfw {} = {}, {}", arg_map={ 0: FO_Result(), 1: FO_Arg(1), 2: FO_Arg(0) }, arity=2, exu=DA_FPU),