OpenASIP  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PRegionMarkerAnalyzer Class Reference

#include <PRegionMarkerAnalyzer.hh>

Collaboration diagram for PRegionMarkerAnalyzer:
Collaboration graph

Public Member Functions

 PRegionMarkerAnalyzer (const llvm::MachineFunction &MF_)
 
virtual ~PRegionMarkerAnalyzer ()
 
bool markersFound () const
 
unsigned pregion (const llvm::MachineInstr &I) const
 

Private Member Functions

bool isPregionEndMarker (const llvm::MachineInstr &I) const
 
bool isPregionStartMarker (const llvm::MachineInstr &I) const
 
unsigned parsePregionID (const llvm::MachineInstr &I) const
 
void findPregions ()
 
void propagatePregionID (const llvm::MachineInstr &start, unsigned id)
 

Private Attributes

const llvm::MachineFunction & MF
 
bool markersFound_
 
std::map< const llvm::MachineInstr *, unsigned > pregionIDs_
 

Detailed Description

Definition at line 42 of file PRegionMarkerAnalyzer.hh.

Constructor & Destructor Documentation

◆ PRegionMarkerAnalyzer()

PRegionMarkerAnalyzer::PRegionMarkerAnalyzer ( const llvm::MachineFunction &  MF_)

Definition at line 48 of file PRegionMarkerAnalyzer.cc.

49  : MF(MF_), markersFound_(false) {
50 
51  for (MachineFunction::const_iterator i = MF.begin();
52  i != MF.end() && !markersFound_; i++) {
53  for (MachineBasicBlock::const_iterator j = i->begin();
54  j != i->end(); j++) {
55  const llvm::MachineInstr& mi = *j;
57  markersFound_ = true;
58  break;
59  }
60  }
61  }
62 
63  if (!markersFound_) return;
64  findPregions();
65 }

References findPregions(), isPregionEndMarker(), isPregionStartMarker(), markersFound_, and MF.

Here is the call graph for this function:

◆ ~PRegionMarkerAnalyzer()

virtual PRegionMarkerAnalyzer::~PRegionMarkerAnalyzer ( )
inlinevirtual

Definition at line 45 of file PRegionMarkerAnalyzer.hh.

45 {}

Member Function Documentation

◆ findPregions()

void PRegionMarkerAnalyzer::findPregions ( )
private

Finds the parallel region markers and propagates the parallel region ids to the instructions dominated by it.

Definition at line 107 of file PRegionMarkerAnalyzer.cc.

107  {
108 
109  for (MachineFunction::const_iterator i = MF.begin();
110  i != MF.end(); i++) {
111  for (MachineBasicBlock::const_iterator j = i->begin();
112  j != i->end(); j++) {
113  const llvm::MachineInstr& mi = *j;
114  if (!isPregionStartMarker(mi))
115  continue;
116  unsigned pregionId = parsePregionID(mi);
117  propagatePregionID(mi, pregionId);
118  }
119  }
120 }

References isPregionStartMarker(), MF, parsePregionID(), and propagatePregionID().

Referenced by PRegionMarkerAnalyzer().

Here is the call graph for this function:

◆ isPregionEndMarker()

bool PRegionMarkerAnalyzer::isPregionEndMarker ( const llvm::MachineInstr &  I) const
private

Definition at line 128 of file PRegionMarkerAnalyzer.cc.

128  {
129  // Count the number of register definitions.
130  if (!I.isInlineAsm()) return false;
131  unsigned numDefs = 0;
132  while (I.getOperand(numDefs).isReg() &&
133  I.getOperand(numDefs).isDef())
134  ++numDefs;
135  TCEString opName = I.getOperand(numDefs).getSymbolName();
136  return opName.startsWith(".pregion_end");
137 }

References TCEString::startsWith().

Referenced by PRegionMarkerAnalyzer(), and propagatePregionID().

Here is the call graph for this function:

◆ isPregionStartMarker()

bool PRegionMarkerAnalyzer::isPregionStartMarker ( const llvm::MachineInstr &  I) const
private

Definition at line 140 of file PRegionMarkerAnalyzer.cc.

140  {
141  if (!I.isInlineAsm()) return false;
142  // Count the number of register definitions.
143  unsigned numDefs = 0;
144  while (I.getOperand(numDefs).isReg() &&
145  I.getOperand(numDefs).isDef())
146  ++numDefs;
147  TCEString opName = I.getOperand(numDefs).getSymbolName();
148  return opName.startsWith(".pregion_start.");
149 }

References TCEString::startsWith().

Referenced by findPregions(), parsePregionID(), PRegionMarkerAnalyzer(), and propagatePregionID().

Here is the call graph for this function:

◆ markersFound()

bool PRegionMarkerAnalyzer::markersFound ( ) const

Definition at line 123 of file PRegionMarkerAnalyzer.cc.

123  {
124  return markersFound_;
125 }

References markersFound_.

Referenced by llvm::LLVMTCEBuilder::addPointerAnnotations().

◆ parsePregionID()

unsigned PRegionMarkerAnalyzer::parsePregionID ( const llvm::MachineInstr &  I) const
private

Definition at line 152 of file PRegionMarkerAnalyzer.cc.

152  {
153  if (!isPregionStartMarker(I)) return UINT_MAX;
154 
155  unsigned numDefs = 0;
156  while (I.getOperand(numDefs).isReg() &&
157  I.getOperand(numDefs).isDef())
158  ++numDefs;
159 
160  TCEString opName = I.getOperand(numDefs).getSymbolName();
161 
162  return Conversion::toUnsignedInt(opName.split(".").at(2));
163 }

References isPregionStartMarker(), TCEString::split(), and Conversion::toUnsignedInt().

Referenced by findPregions().

Here is the call graph for this function:

◆ pregion()

unsigned PRegionMarkerAnalyzer::pregion ( const llvm::MachineInstr &  I) const

Definition at line 166 of file PRegionMarkerAnalyzer.cc.

166  {
167  if (pregionIDs_.find(&I) != pregionIDs_.end())
168  return (*pregionIDs_.find(&I)).second;
169  else
170  return UINT_MAX;
171 }

References pregionIDs_.

Referenced by llvm::LLVMTCEBuilder::addPointerAnnotations().

◆ propagatePregionID()

void PRegionMarkerAnalyzer::propagatePregionID ( const llvm::MachineInstr &  start,
unsigned  id 
)
private

Definition at line 68 of file PRegionMarkerAnalyzer.cc.

69  {
70  const llvm::MachineBasicBlock* mbb = start.getParent();
71 
72  for (MachineBasicBlock::const_iterator i = &start;
73  i != mbb->end();
74  ++i) {
75  const llvm::MachineInstr* mi = &*i;
76  if (mi != &start &&
78  return;
79 
80  if (mi->isCall() && !mi->isInlineAsm()) return;
81 
82 #ifdef DEBUG_PREGIONS
83  std::cerr << "### PRA: propagating region id " << id << " to ";
84  mi->dump();
85 #endif
86  pregionIDs_[mi] = id;
87  }
88  for (MachineBasicBlock::const_succ_iterator i = mbb->succ_begin();
89  i != mbb->succ_end(); ++i) {
90  const llvm::MachineBasicBlock* child = *i;
91  const llvm::MachineInstr* first = &child->front();
92  // avoid looping forever by checking whether the info
93  // has been propagated already to the recusrively
94  // traversed basic blocks
95  if (pregionIDs_.find(first) == pregionIDs_.end() &&
96  !isPregionStartMarker(*first) && !isPregionEndMarker(*first))
97  propagatePregionID(child->front(), id);
98  }
99 }

References isPregionEndMarker(), isPregionStartMarker(), and pregionIDs_.

Referenced by findPregions().

Here is the call graph for this function:

Member Data Documentation

◆ markersFound_

bool PRegionMarkerAnalyzer::markersFound_
private

Definition at line 61 of file PRegionMarkerAnalyzer.hh.

Referenced by markersFound(), and PRegionMarkerAnalyzer().

◆ MF

const llvm::MachineFunction& PRegionMarkerAnalyzer::MF
private

Definition at line 60 of file PRegionMarkerAnalyzer.hh.

Referenced by findPregions(), and PRegionMarkerAnalyzer().

◆ pregionIDs_

std::map<const llvm::MachineInstr*, unsigned> PRegionMarkerAnalyzer::pregionIDs_
private

Definition at line 62 of file PRegionMarkerAnalyzer.hh.

Referenced by pregion(), and propagatePregionID().


The documentation for this class was generated from the following files:
TCEString::split
std::vector< TCEString > split(const std::string &delim) const
Definition: TCEString.cc:114
TCEString::startsWith
bool startsWith(const std::string &str) const
PRegionMarkerAnalyzer::parsePregionID
unsigned parsePregionID(const llvm::MachineInstr &I) const
Definition: PRegionMarkerAnalyzer.cc:152
PRegionMarkerAnalyzer::findPregions
void findPregions()
Definition: PRegionMarkerAnalyzer.cc:107
PRegionMarkerAnalyzer::propagatePregionID
void propagatePregionID(const llvm::MachineInstr &start, unsigned id)
Definition: PRegionMarkerAnalyzer.cc:68
PRegionMarkerAnalyzer::isPregionEndMarker
bool isPregionEndMarker(const llvm::MachineInstr &I) const
Definition: PRegionMarkerAnalyzer.cc:128
PRegionMarkerAnalyzer::MF
const llvm::MachineFunction & MF
Definition: PRegionMarkerAnalyzer.hh:60
PRegionMarkerAnalyzer::isPregionStartMarker
bool isPregionStartMarker(const llvm::MachineInstr &I) const
Definition: PRegionMarkerAnalyzer.cc:140
PRegionMarkerAnalyzer::pregionIDs_
std::map< const llvm::MachineInstr *, unsigned > pregionIDs_
Definition: PRegionMarkerAnalyzer.hh:62
PRegionMarkerAnalyzer::markersFound_
bool markersFound_
Definition: PRegionMarkerAnalyzer.hh:61
Conversion::toUnsignedInt
static unsigned int toUnsignedInt(const T &source)
TCEString
Definition: TCEString.hh:53