LLVM API Documentation

Public Member Functions
llvm::CodeExtractor Class Reference

Utility class for extracting code into a new function. More...

#include <CodeExtractor.h>

List of all members.

Public Member Functions

 CodeExtractor (BasicBlock *BB, bool AggregateArgs=false)
 Create a code extractor for a single basic block.
 CodeExtractor (ArrayRef< BasicBlock * > BBs, DominatorTree *DT=nullptr, bool AggregateArgs=false)
 Create a code extractor for a sequence of blocks.
 CodeExtractor (DominatorTree &DT, Loop &L, bool AggregateArgs=false)
 Create a code extractor for a loop body.
 CodeExtractor (DominatorTree &DT, const RegionNode &RN, bool AggregateArgs=false)
 Create a code extractor for a region node.
FunctionextractCodeRegion ()
 Perform the extraction, returning the new function.
bool isEligible () const
 Test whether this code extractor is eligible.
void findInputsOutputs (ValueSet &Inputs, ValueSet &Outputs) const
 Compute the set of input values and output values for the code.

Detailed Description

Utility class for extracting code into a new function.

This utility provides a simple interface for extracting some sequence of code into its own function, replacing it with a call to that function. It also provides various methods to query about the nature and result of such a transformation.

The rough algorithm used is: 1) Find both the inputs and outputs for the extracted region. 2) Pass the inputs as arguments, remapping them within the extracted function to arguments. 3) Add allocas for any scalar outputs, adding all of the outputs' allocas as arguments, and inserting stores to the arguments for any scalars.

Definition at line 44 of file CodeExtractor.h.


Constructor & Destructor Documentation

CodeExtractor::CodeExtractor ( BasicBlock BB,
bool  AggregateArgs = false 
)

Create a code extractor for a single basic block.

In this formation, we don't require a dominator tree. The given basic block is set up for extraction.

Definition at line 122 of file CodeExtractor.cpp.

CodeExtractor::CodeExtractor ( ArrayRef< BasicBlock * >  BBs,
DominatorTree DT = nullptr,
bool  AggregateArgs = false 
)

Create a code extractor for a sequence of blocks.

Given a sequence of basic blocks where the first block in the sequence dominates the rest, prepare a code extractor object for pulling this sequence out into its new function. When a DominatorTree is also given, extra checking and transformations are enabled.

Definition at line 126 of file CodeExtractor.cpp.

CodeExtractor::CodeExtractor ( DominatorTree DT,
Loop L,
bool  AggregateArgs = false 
)

Create a code extractor for a loop body.

Behaves just like the generic code sequence constructor, but uses the block sequence of the loop.

Definition at line 131 of file CodeExtractor.cpp.

CodeExtractor::CodeExtractor ( DominatorTree DT,
const RegionNode RN,
bool  AggregateArgs = false 
)

Create a code extractor for a region node.

Behaves just like the generic code sequence constructor, but uses the block sequence of the region node passed in.

Definition at line 135 of file CodeExtractor.cpp.


Member Function Documentation

void CodeExtractor::findInputsOutputs ( ValueSet Inputs,
ValueSet Outputs 
) const

Compute the set of input values and output values for the code.

These can be used either when performing the extraction or to evaluate the expected size of a call to the extracted function. Note that this work cannot be cached between the two as once we decide to extract a code sequence, that sequence is modified, including changing these sets, before extraction occurs. These modifications won't have any significant impact on the cost however.

Definition at line 160 of file CodeExtractor.cpp.

References llvm::SetVector< T, Vector, Set >::begin(), llvm::BasicBlock::begin(), definedInCaller(), definedInRegion(), llvm::SetVector< T, Vector, Set >::end(), llvm::BasicBlock::end(), I, llvm::ARM_PROC::IE, llvm::SetVector< T, Vector, Set >::insert(), and llvm::Value::users().

Referenced by extractCodeRegion().

Test whether this code extractor is eligible.

Based on the blocks used when constructing the code extractor, determine whether it is eligible for extraction.

Definition at line 95 of file CodeExtractor.h.

References llvm::SetVector< T, Vector, Set >::empty().

Referenced by extractCodeRegion().


The documentation for this class was generated from the following files: