// Inputs for the loom-llvm-arith-to-arith mechanical raising stage. // // Each sample is a module of llvm.func callables whose bodies mix LLVM // leading/trailing zero-count intrinsics carrying either is_zero_poison // setting with ordinary integer LLVM computations. Operand and result // types are exact standard numeric types (signless integers and // fixed-shape vectors of them), so type exactness never by itself blocks // the mechanical spelling. Enclosing callables optionally state // importer-owned passthrough function attributes. start: {new NFUN = random.randint(1, 3); new F = 0} 'module {\n' funcs '}\n'; funcs: (F < NFUN) func {F += 1} funcs | (F == NFUN) ''; func: {new TY = random.choice(['i32', 'i8', 'i16', 'i64', 'vector<4xi32>', 'vector<2xi64>']); new NOPS = random.randint(1, 4); new K = 0} 'llvm.func @zero_counts_' fname '(%arg0: ' ty ')' fattrs ' {\n' body ' llvm.return\n}\n'; fname: [str(F)]; ty: [TY]; kidx: [str(K)]; fattrs: '' | ' attributes {passthrough = ["nounwind"]}' | ' attributes {passthrough = ["strictfp"]}' | ' attributes {passthrough = [["no-trapping-math", "true"]], target_cpu = "generic"}'; body: (K < NOPS) op {K += 1} body | (K == NOPS) ''; op: count_op | count_op_flagged | binary_op; // Zero-count intrinsic with a freely sampled poison-on-zero contract. count_op: ' %v' kidx ' = "llvm.intr.' zkind '"(%arg0) <{is_zero_poison = ' poison_flag '}> : (' ty ') -> ' ty '\n'; // Same construct, sampled so that the poison-flagged form stays frequent. count_op_flagged: ' %v' kidx ' = "llvm.intr.' zkind '"(%arg0) <{is_zero_poison = true}> : (' ty ') -> ' ty '\n'; binary_op: ' %v' kidx ' = llvm.add %arg0, %arg0 : ' ty '\n' | ' %v' kidx ' = llvm.mul %arg0, %arg0 : ' ty '\n' | ' %v' kidx ' = llvm.and %arg0, %arg0 : ' ty '\n'; zkind: 'ctlz' | 'cttz'; poison_flag: 'true' | 'false';