// Inputs for --loom-materialize-fmuladd: S0 modules whose callable regions own // unresolved `llvm.intr.fmuladd` operations, plus parents with no unresolved // choice, unrepresentable intrinsics, and intrinsics owned by nested callables. start: {new NFUNC = random.randint(0, 3); new FID = 0} 'module {\n' funcs '}\n'; funcs: (FID < NFUNC) one_func {FID += 1} funcs | (FID == NFUNC) ''; one_func: {new KIND = random.choice(['plain', 'plain', 'plain', 'blocked', 'nested', 'resolved'])} func_form; func_form: (KIND == 'plain') plain_func | (KIND == 'blocked') blocked_func | (KIND == 'nested') nested_func | (KIND == 'resolved') resolved_func; // A complete parent owning one or two unresolved, exactly representable // `llvm.intr.fmuladd` operations in the default floating environment. plain_func: {new TY = random.choice(['f32', 'f64', 'f16', 'vector<4xf32>']); new NFMA = random.randint(1, 2); new K = 0} 'llvm.func @plain_' [str(FID)] '(%x: ' [TY] ', %y: ' [TY] ', %z: ' [TY] ') -> ' [TY] ' {\n' residual_op fma_chain ' llvm.return %x : ' [TY] '\n' '}\n\n'; fma_chain: (K < NFMA) fma_op {K += 1} fma_chain | (K == NFMA) ''; fma_op: ' %r' [str(FID)] '_' [str(K)] ' = llvm.intr.fmuladd(%x, %y, %z) ' fastmath_attr ': (' [TY] ', ' [TY] ', ' [TY] ') -> ' [TY] ' loc("fmuladd_' [str(FID)] '_' [str(K)] '")\n'; // The imported fast-math contract of the source intrinsic. fastmath_attr: {new FM = random.choice([0, 1, 2, 3])} fastmath_body; fastmath_body: (FM == 0) '' | (FM == 1) '{fastmathFlags = #llvm.fastmath} ' | (FM == 2) '{fastmathFlags = #llvm.fastmath} ' | (FM == 3) '{fastmathFlags = #llvm.fastmath} '; // Residual computation the ExecutionShape decision must leave alone. residual_op: {new RES = random.choice([0, 1])} residual_body; residual_body: (RES == 0) '' | (RES == 1) ' %m' [str(FID)] ' = llvm.fmul %x, %y : ' [TY] '\n'; // A callable stating a floating-point policy no standard operation restates: // its intrinsic is not exactly representable and stays explicit. blocked_func: {new TY = random.choice(['f32', 'f64']); new POLICY = random.choice([0, 1, 2])} 'llvm.func @blocked_' [str(FID)] '(%x: ' [TY] ', %y: ' [TY] ', %z: ' [TY] ') -> ' [TY] ' ' policy_attrs '{\n' ' %b' [str(FID)] ' = llvm.intr.fmuladd(%x, %y, %z) : (' [TY] ', ' [TY] ', ' [TY] ') -> ' [TY] ' loc("fmuladd_blocked_' [str(FID)] '")\n' ' llvm.return %x : ' [TY] '\n' '}\n\n'; policy_attrs: (POLICY == 0) 'attributes {reciprocal_estimates = "all"} ' | (POLICY == 1) 'attributes {passthrough = ["strictfp"]} ' | (POLICY == 2) 'attributes {no_signed_zeros_fp_math = true} '; // A native func.func owning a nested imported llvm.func: the intrinsic belongs // to the nested callable, which owns its own body. nested_func: {new TY = random.choice(['f32', 'f64'])} 'func.func @native_' [str(FID)] '(%a: ' [TY] ') -> ' [TY] ' {\n' ' builtin.module {\n' ' llvm.func @inner_' [str(FID)] '(%x: ' [TY] ', %y: ' [TY] ', %z: ' [TY] ') -> ' [TY] ' {\n' ' %n' [str(FID)] ' = llvm.intr.fmuladd(%x, %y, %z) {fastmathFlags = #llvm.fastmath} : (' [TY] ', ' [TY] ', ' [TY] ') -> ' [TY] ' loc("fmuladd_nested_' [str(FID)] '")\n' ' llvm.return %x : ' [TY] '\n' ' }\n' ' }\n' ' return %a : ' [TY] '\n' '}\n\n'; // A parent with no unresolved selected-Spatial execution-shape choice. resolved_func: {new TY = random.choice(['f32', 'f64'])} 'llvm.func @resolved_' [str(FID)] '(%x: ' [TY] ', %y: ' [TY] ', %z: ' [TY] ') -> ' [TY] ' {\n' ' %p' [str(FID)] ' = math.fma %x, %y, %z : ' [TY] '\n' ' %q' [str(FID)] ' = arith.mulf %x, %y : ' [TY] '\n' ' %s' [str(FID)] ' = arith.addf %q' [str(FID)] ', %z : ' [TY] '\n' ' llvm.return %x : ' [TY] '\n' '}\n\n';