Adds incoming block parameters to blocks that allow them.
(&mut self)
| 336 | |
| 337 | /// Adds incoming block parameters to blocks that allow them. |
| 338 | fn add_blockparams(&mut self) -> Result<()> { |
| 339 | // Entry points cannot have blockparams. |
| 340 | for block in self.func.blocks.keys() { |
| 341 | if self.func.entry_points.contains(&block) { |
| 342 | continue; |
| 343 | } |
| 344 | // Blockparams are only allowed if we have multiple predecessors. |
| 345 | if self.func.blocks[block].preds.len() <= 1 { |
| 346 | continue; |
| 347 | } |
| 348 | let can_add_indirect_remats = self.domtree.immediate_dominator(block).is_some(); |
| 349 | |
| 350 | // Define some values for incoming blockparams. |
| 351 | for _ in 0..self |
| 352 | .u |
| 353 | .int_in_range(self.config.blockparams_per_block.clone())? |
| 354 | { |
| 355 | let bank = RegBank::new(self.u.choose_index(self.reginfo.num_banks())?); |
| 356 | let value = self.new_value(bank)?; |
| 357 | if can_add_indirect_remats && !self.u.arbitrary()? { |
| 358 | self.add_indirect_remat(value, block, true)?; |
| 359 | } |
| 360 | self.func.blocks[block].block_params_in.push(value); |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | Ok(()) |
| 365 | } |
| 366 | |
| 367 | /// Generate the contents of a basic block. |
| 368 | /// |
no test coverage detected