Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hpvm-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
hpvm-release
Commits
5f734814
Commit
5f734814
authored
10 years ago
by
kotsifa2
Browse files
Options
Downloads
Patches
Plain Diff
Refactored BuildDFG pass (required for adding the VISC to LLVM pass).
parent
5a8d69fb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
llvm/include/llvm/BuildDFG/BuildDFG.h
+55
-0
55 additions, 0 deletions
llvm/include/llvm/BuildDFG/BuildDFG.h
llvm/lib/Transforms/BuildDFG/BuildDFG.cpp
+47
-79
47 additions, 79 deletions
llvm/lib/Transforms/BuildDFG/BuildDFG.cpp
with
102 additions
and
79 deletions
llvm/include/llvm/BuildDFG/BuildDFG.h
0 → 100644
+
55
−
0
View file @
5f734814
//== BuildDFG.h - Header file for "Hierarchical Dataflow Graph Builder Pass" =//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include
"llvm/ADT/ValueMap.h"
#include
"llvm/IR/Module.h"
#include
"llvm/IR/Function.h"
#include
"llvm/IR/Instructions.h"
#include
"llvm/IR/IntrinsicInst.h"
#include
"llvm/IR/Value.h"
#include
"llvm/IR/DFGraph.h"
#include
"llvm/Pass.h"
using
namespace
llvm
;
namespace
builddfg
{
// BuildDFG - The first implementation.
struct
BuildDFG
:
public
ModulePass
{
static
char
ID
;
// Pass identification, replacement for typeid
BuildDFG
()
:
ModulePass
(
ID
)
{}
private
:
// Member variables
DFInternalNode
*
Root
;
typedef
ValueMap
<
Value
*
,
DFNode
*>
HandleToDFNode
;
typedef
ValueMap
<
Value
*
,
DFEdge
*>
HandleToDFEdge
;
HandleToDFNode
HandleToDFNodeMap
;
// This map associates the i8* pointer
// with the DFNode structure that it
// represents
HandleToDFEdge
HandleToDFEdgeMap
;
// This map associates the i8* pointer
// with the DFEdge structure that it
// represents
// Functions
bool
isViscLaunchIntrinsic
(
Instruction
*
I
);
bool
isViscGraphIntrinsic
(
Instruction
*
I
);
void
handleCreateNode
(
DFInternalNode
*
N
,
IntrinsicInst
*
II
);
void
handleCreateEdge
(
DFInternalNode
*
N
,
IntrinsicInst
*
II
);
void
BuildGraph
(
DFInternalNode
*
N
,
Function
*
F
);
public
:
virtual
bool
runOnModule
(
Module
&
M
);
};
}
// End of namespace
This diff is collapsed.
Click to expand it.
llvm/lib/Transforms/BuildDFG/BuildDFG.cpp
+
47
−
79
View file @
5f734814
...
...
@@ -8,102 +8,69 @@
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "buildDFG"
#include
"llvm/BuildDFG/BuildDFG.h"
#include
"llvm/ADT/Statistic.h"
#include
"llvm/ADT/ValueMap.h"
#include
"llvm/IR/Module.h"
#include
"llvm/IR/Function.h"
#include
"llvm/IR/Instructions.h"
#include
"llvm/IR/IntrinsicInst.h"
#include
"llvm/IR/ValueSymbolTable.h"
#include
"llvm/IR/Value.h"
#include
"llvm/IR/DFGraph.h"
#include
"llvm/Pass.h"
#include
"llvm/Support/InstIterator.h"
#include
"llvm/Support/raw_ostream.h"
using
namespace
llvm
;
STATISTIC
(
IntrinsicCounter
,
"Counts number of visc intrinsics greeted"
);
namespace
{
// BuildDFG - The first implementation.
struct
BuildDFG
:
public
ModulePass
{
static
char
ID
;
// Pass identification, replacement for typeid
BuildDFG
()
:
ModulePass
(
ID
)
{}
private
:
// Member variables
DFInternalNode
*
Root
;
typedef
ValueMap
<
Value
*
,
DFNode
*>
HandleToDFNode
;
typedef
ValueMap
<
Value
*
,
DFEdge
*>
HandleToDFEdge
;
HandleToDFNode
HandleToDFNodeMap
;
// This map associates the i8* pointer
// with the DFNode structure that it
// represents
HandleToDFEdge
HandleToDFEdgeMap
;
// This map associates the i8* pointer
// with the DFEdge structure that it
// represents
// Functions
bool
isViscLaunchIntrinsic
(
Instruction
*
I
);
bool
isViscGraphIntrinsic
(
Instruction
*
I
);
void
handleCreateNode
(
DFInternalNode
*
N
,
IntrinsicInst
*
II
);
void
handleCreateEdge
(
DFInternalNode
*
N
,
IntrinsicInst
*
II
);
void
BuildGraph
(
DFInternalNode
*
N
,
Function
*
F
);
public
:
virtual
bool
runOnModule
(
Module
&
M
)
{
Function
*
f
;
// Root function, initialized later
bool
foundRootFunction
=
false
;
// Loop over all of the global variables
for
(
Module
::
const_global_iterator
i
=
M
.
global_begin
(),
e
=
M
.
global_end
();
(
i
!=
e
)
&&
(
!
foundRootFunction
);
++
i
)
{
errs
()
<<
"Global: "
<<
i
->
getName
()
<<
"
\t
"
<<
*
(
i
->
getOperand
(
0
))
<<
"
\n
"
;
// Find the root (main) function
// The name of the root function is llvm.visc.root (for now)
if
((
i
->
getName
()).
equals
(
"llvm.visc.root"
))
{
errs
()
<<
"----------- Found Root Function -------------
\n\n
"
;
foundRootFunction
=
true
;
f
=
cast
<
Function
>
(
i
->
getOperand
(
0
));
}
namespace
builddfg
{
bool
BuildDFG
::
runOnModule
(
Module
&
M
)
{
Function
*
f
;
// Root function, initialized later
bool
foundRootFunction
=
false
;
// Loop over all of the global variables
for
(
Module
::
const_global_iterator
i
=
M
.
global_begin
(),
e
=
M
.
global_end
();
(
i
!=
e
)
&&
(
!
foundRootFunction
);
++
i
)
{
errs
()
<<
"Global: "
<<
i
->
getName
()
<<
"
\t
"
<<
*
(
i
->
getOperand
(
0
))
<<
"
\n
"
;
// Find the root (main) function
// The name of the root function is llvm.visc.root (for now)
if
((
i
->
getName
()).
equals
(
"llvm.visc.root"
))
{
errs
()
<<
"----------- Found Root Function -------------
\n\n
"
;
foundRootFunction
=
true
;
f
=
cast
<
Function
>
(
i
->
getOperand
(
0
));
}
}
assert
(
foundRootFunction
&&
"Root function not found!"
);
assert
(
foundRootFunction
&&
"Root function not found!"
);
// Root function has been initialized from this point on.
// Root function has been initialized from this point on.
errs
()
<<
"-------- Searching for launch site ----------
\n
"
;
errs
()
<<
"-------- Searching for launch site ----------
\n
"
;
bool
foundLaunchSite
=
false
;
IntrinsicInst
*
II
;
bool
foundLaunchSite
=
false
;
IntrinsicInst
*
II
;
for
(
inst_iterator
i
=
inst_begin
(
f
),
e
=
inst_end
(
f
);
(
i
!=
e
)
&&
(
!
foundLaunchSite
);
++
i
)
{
Instruction
*
I
=
&*
i
;
// Grab pointer to Instruction
if
(
isViscLaunchIntrinsic
(
I
))
{
errs
()
<<
"------------ Found launch site --------------
\n
"
;
foundLaunchSite
=
true
;
II
=
cast
<
IntrinsicInst
>
(
I
);
}
for
(
inst_iterator
i
=
inst_begin
(
f
),
e
=
inst_end
(
f
);
(
i
!=
e
)
&&
(
!
foundLaunchSite
);
++
i
)
{
Instruction
*
I
=
&*
i
;
// Grab pointer to Instruction
if
(
isViscLaunchIntrinsic
(
I
))
{
errs
()
<<
"------------ Found launch site --------------
\n
"
;
foundLaunchSite
=
true
;
II
=
cast
<
IntrinsicInst
>
(
I
);
}
}
assert
(
foundLaunchSite
&&
"Launch site not found!"
);
assert
(
foundLaunchSite
&&
"Launch site not found!"
);
// Intrinsic Instruction has been initialized from this point on.
// Intrinsic Instruction has been initialized from this point on.
Function
*
F
=
cast
<
Function
>
((
II
->
getOperand
(
0
))
->
stripPointerCasts
());
Root
=
DFInternalNode
::
Create
(
II
,
F
);
BuildGraph
(
Root
,
F
);
Function
*
F
=
cast
<
Function
>
((
II
->
getOperand
(
0
))
->
stripPointerCasts
());
Root
=
DFInternalNode
::
Create
(
II
,
F
);
BuildGraph
(
Root
,
F
);
viewDFGraph
(
Root
->
getChildGraph
());
return
false
;
//TODO: What does returning "false" mean?
}
viewDFGraph
(
Root
->
getChildGraph
());
return
false
;
//TODO: What does returning "false" mean?
}
};
// Returns true if instruction I is a visc launch intrinsic, false otherwise
bool
BuildDFG
::
isViscLaunchIntrinsic
(
Instruction
*
I
)
{
...
...
@@ -250,8 +217,9 @@ namespace {
}
}
}
}
// End of namespace
char
BuildDFG
::
ID
=
0
;
static
RegisterPass
<
BuildDFG
>
X
(
"buildDFG"
,
"Hierarchical Dataflow Graph Builder Pass"
,
false
,
false
);
char
BuildDFG
::
ID
=
0
;
static
RegisterPass
<
BuildDFG
>
X
(
"buildDFG"
,
"Hierarchical Dataflow Graph Builder Pass"
,
false
,
false
);
}
// End of namespace
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment