CIRCT  19.0.0git
Namespaces | Macros | Functions
MuxToControlFlow.cpp File Reference
#include "circt/Dialect/Arc/ArcInterfaces.h"
#include "circt/Dialect/Arc/ArcOps.h"
#include "circt/Dialect/Arc/ArcPasses.h"
#include "circt/Dialect/Comb/CombOps.h"
#include "circt/Dialect/HW/HWOps.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Pass/Pass.h"
#include "llvm/Support/Debug.h"
#include "circt/Dialect/Arc/ArcPasses.h.inc"
Include dependency graph for MuxToControlFlow.cpp:

Go to the source code of this file.

Namespaces

 circt
 The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
 
 circt::arc
 

Macros

#define DEBUG_TYPE   "arc-mux-to-control-flow"
 
#define GEN_PASS_DEF_MUXTOCONTROLFLOW
 

Functions

static bool isValidToProceedTraversal (Operation *mux, Operation *curr, Value useValue, SmallPtrSetImpl< Operation * > &visited)
 Check whether. More...
 
static void computeFanIn (Operation *mux, Value useValue, SmallPtrSetImpl< Operation * > &visited)
 Compute the set of operations that would only be used in the branch represented by. More...
 
static void cloneOpsIntoBranchesWhenUsedInBoth (mlir::scf::IfOp ifOp)
 Clone ops that are used in both branches of an if-statement but not outside of it. More...
 
static void doConversion (Operation *op, BranchInfo info, const SmallPtrSetImpl< Operation * > &thenOps, const SmallPtrSetImpl< Operation * > &elseOps)
 Perform the actual conversion. More...
 
static uint32_t getCostEstimate (const SmallPtrSetImpl< Operation * > &ops)
 Simple helper to invoke the runtime cost interface for every operation in a set and sum up the costs. More...
 
static BranchInfo getConversionInfo (Operation *op)
 Convert concrete operations that should be converted to if-statements to a more abstract representation the rest of the pass works with. More...
 
static bool isBeneficialToConvert (Operation *op, const SmallPtrSetImpl< Operation * > &thenOps, const SmallPtrSetImpl< Operation * > &elseOps)
 Use the cost measure of each branch to heuristically decide whether to actually perform the conversion. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "arc-mux-to-control-flow"

Definition at line 24 of file MuxToControlFlow.cpp.

◆ GEN_PASS_DEF_MUXTOCONTROLFLOW

#define GEN_PASS_DEF_MUXTOCONTROLFLOW

Definition at line 28 of file MuxToControlFlow.cpp.

Function Documentation

◆ cloneOpsIntoBranchesWhenUsedInBoth()

static void cloneOpsIntoBranchesWhenUsedInBoth ( mlir::scf::IfOp  ifOp)
static

Clone ops that are used in both branches of an if-statement but not outside of it.

This is just here because of experimentation reasons. Doing this might allow for better instruction scheduling to slightly reduce ISA register pressure (however, it is currently too naive to only take the beneficial situations), but it will increase binary size which is especially bad when the hot part would otherwise fit in instruction cache (but doesn't really matter when it doesn't fit anyways as there is no temporal locality anyways).

Definition at line 141 of file MuxToControlFlow.cpp.

References builder.

◆ computeFanIn()

static void computeFanIn ( Operation *  mux,
Value  useValue,
SmallPtrSetImpl< Operation * > &  visited 
)
static

Compute the set of operations that would only be used in the branch represented by.

Parameters
useValue.

Definition at line 105 of file MuxToControlFlow.cpp.

References isValidToProceedTraversal().

◆ doConversion()

static void doConversion ( Operation *  op,
BranchInfo  info,
const SmallPtrSetImpl< Operation * > &  thenOps,
const SmallPtrSetImpl< Operation * > &  elseOps 
)
static

Perform the actual conversion.

Create the if-statement, move the operations in its regions and delete the mux.

Definition at line 180 of file MuxToControlFlow.cpp.

References builder.

◆ getConversionInfo()

static BranchInfo getConversionInfo ( Operation *  op)
static

Convert concrete operations that should be converted to if-statements to a more abstract representation the rest of the pass works with.

This is the place where support for more operations can be added (nothing else has to be changed).

Definition at line 245 of file MuxToControlFlow.cpp.

◆ getCostEstimate()

static uint32_t getCostEstimate ( const SmallPtrSetImpl< Operation * > &  ops)
static

Simple helper to invoke the runtime cost interface for every operation in a set and sum up the costs.

Definition at line 220 of file MuxToControlFlow.cpp.

Referenced by isBeneficialToConvert().

◆ isBeneficialToConvert()

static bool isBeneficialToConvert ( Operation *  op,
const SmallPtrSetImpl< Operation * > &  thenOps,
const SmallPtrSetImpl< Operation * > &  elseOps 
)
static

Use the cost measure of each branch to heuristically decide whether to actually perform the conversion.

TODO: improve and fine-tune this

Definition at line 257 of file MuxToControlFlow.cpp.

References getCostEstimate().

◆ isValidToProceedTraversal()

static bool isValidToProceedTraversal ( Operation *  mux,
Operation *  curr,
Value  useValue,
SmallPtrSetImpl< Operation * > &  visited 
)
static

Check whether.

Parameters
curris valid to be moved into the if-branch, which is the stopping condition of the BFS traversal.

Definition at line 79 of file MuxToControlFlow.cpp.

Referenced by computeFanIn().