MCPcopy Create free account
hub / github.com/Amanieu/regalloc3 / arbitrary_with_config

Method arbitrary_with_config

src/debug_utils/generic_function/arbitrary.rs:73–103  ·  view source on GitHub ↗

Constructs a randomly-generated `GenericFunction`. This function is guaranteed to pass validation with the given (valid) [`RegInfo`] implementation.

(
        reginfo: &impl RegInfo,
        u: &mut Unstructured<'_>,
        config: ArbitraryFunctionConfig,
    )

Source from the content-addressed store, hash-verified

71 /// This function is guaranteed to pass validation with the given (valid)
72 /// [`RegInfo`] implementation.
73 pub fn arbitrary_with_config(
74 reginfo: &impl RegInfo,
75 u: &mut Unstructured<'_>,
76 config: ArbitraryFunctionConfig,
77 ) -> Result<Self> {
78 let mut builder = FunctionBuilder::new(u, reginfo, config);
79 builder.gen_cfg_skeleton()?;
80 builder.block_insts.grow_to(builder.func.num_blocks());
81 builder.defs_by_blocks.grow_to(builder.func.num_blocks());
82
83 let postorder = PostOrder::for_function(&builder.func);
84 builder.domtree.compute(&builder.func, &postorder);
85
86 builder.add_blockparams()?;
87
88 for block in postorder.cfg_postorder() {
89 builder.func.blocks[block].immediate_dominator =
90 builder.domtree.immediate_dominator(block).into();
91 builder.gen_block_insts(block)?;
92 }
93
94 // Generate some unused values.
95 for _ in 0..builder.u.int_in_range(0..=10)? {
96 let bank = RegBank::new(builder.u.choose_index(reginfo.num_banks())?);
97 builder.new_value(bank)?;
98 }
99
100 builder.finalize()?;
101
102 Ok(builder.func)
103 }
104}
105
106struct FunctionBuilder<'a, 'b, R> {

Callers

nothing calls this directly

Calls 11

gen_cfg_skeletonMethod · 0.80
add_blockparamsMethod · 0.80
cfg_postorderMethod · 0.80
immediate_dominatorMethod · 0.80
gen_block_instsMethod · 0.80
num_banksMethod · 0.80
new_valueMethod · 0.80
finalizeMethod · 0.80
grow_toMethod · 0.45
num_blocksMethod · 0.45
computeMethod · 0.45

Tested by

no test coverage detected