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
ae09b8df
Commit
ae09b8df
authored
11 years ago
by
kotsifa2
Browse files
Options
Downloads
Patches
Plain Diff
Edited DFG2LLVM pass
1. Bug fix 2. Properly remove or replace intrinsics
parent
973995ac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llvm/lib/Transforms/DFG2LLVM/DFG2LLVM.cpp
+24
-10
24 additions, 10 deletions
llvm/lib/Transforms/DFG2LLVM/DFG2LLVM.cpp
with
24 additions
and
10 deletions
llvm/lib/Transforms/DFG2LLVM/DFG2LLVM.cpp
+
24
−
10
View file @
ae09b8df
...
...
@@ -57,7 +57,6 @@ namespace {
void
codeGen
(
DFLeafNode
*
N
)
{
std
::
vector
<
IntrinsicInst
*>
IItoRemove
;
std
::
vector
<
std
::
pair
<
IntrinsicInst
*
,
Value
*>
>
IItoReplace
;
BuildDFG
::
HandleToDFNode
Leaf_HandleToDFNodeMap
;
// Get the function associated woth the dataflow node
...
...
@@ -91,12 +90,13 @@ namespace {
// get the parent node of the arg node
// get argument node
ArgII
=
cast
<
IntrinsicInst
>
((
II
->
getOperand
(
0
))
->
stripPointerCasts
());
// get the parent node of the arg node
ArgDFNode
=
Leaf_HandleToDFNodeMap
[
ArgII
];
// get the parent node of the arg node
// Add mapping <intrinsic, parent node> to the node-specific map
// the argument node must have been added to the map, orelse the
// code could not refer to it
Leaf_HandleToDFNodeMap
[
II
]
=
ArgDFNode
;
Leaf_HandleToDFNodeMap
[
II
]
=
ArgDFNode
->
getParent
();
IItoRemove
.
push_back
(
II
);
}
break
;
...
...
@@ -107,8 +107,11 @@ namespace {
int
numOfDim
=
Leaf_HandleToDFNodeMap
[
ArgII
]
->
getNumOfDim
();
IntegerType
*
IntTy
=
Type
::
getInt32Ty
(
getGlobalContext
());
ConstantInt
*
numOfDimConstant
=
ConstantInt
::
getSigned
(
IntTy
,
(
int64_t
)
numOfDim
);
IItoReplace
.
push_back
(
std
::
make_pair
(
II
,
numOfDimConstant
));
// Replace the result of the intrinsic with the computed value
II
->
replaceAllUsesWith
(
numOfDimConstant
);
IItoRemove
.
push_back
(
II
);
}
break
;
/*********************** llvm.visc.getNodeInstanceID() ************************/
...
...
@@ -166,8 +169,12 @@ namespace {
assert
(
false
&&
"Unable to translate this intrinsic"
);
}
CallInst
*
CI
=
CallInst
::
Create
(
OpenCLFunction
,
Args
);
IItoReplace
.
push_back
(
std
::
make_pair
(
II
,
CI
));
// Create call instruction, insert it before the intrinsic and
// replace the uses of the previous instruction with the new one
CallInst
*
CI
=
CallInst
::
Create
(
OpenCLFunction
,
Args
,
""
,
II
);
II
->
replaceAllUsesWith
(
CI
);
IItoRemove
.
push_back
(
II
);
}
break
;
/********************** llvm.visc.getNumNodeInstances() ***********************/
...
...
@@ -226,8 +233,12 @@ namespace {
assert
(
false
&&
"Unable to translate this intrinsic"
);
}
CallInst
*
CI
=
CallInst
::
Create
(
OpenCLFunction
,
Args
);
IItoReplace
.
push_back
(
std
::
make_pair
(
II
,
CI
));
// Create call instruction, insert it before the intrinsic and
// replace the uses of the previous instruction with the new one
CallInst
*
CI
=
CallInst
::
Create
(
OpenCLFunction
,
Args
,
""
,
II
);
II
->
replaceAllUsesWith
(
CI
);
IItoRemove
.
push_back
(
II
);
}
break
;
default
:
...
...
@@ -250,7 +261,8 @@ namespace {
// using dyn_cast in order to determine if we replace with inst or value
//TODO: maybe leave these instructions to be removed by a later DCE pass
//We need to do this explicitly: DCE pass will not remove them because we
// have assumed theworst memory behaviour for these function calls
for
(
std
::
vector
<
IntrinsicInst
*>::
iterator
i
=
IItoRemove
.
begin
();
i
!=
IItoRemove
.
end
();
++
i
)
(
*
i
)
->
eraseFromParent
();
...
...
@@ -297,6 +309,8 @@ namespace {
// Initiate code generation for root DFNode
CGTVisitor
->
visit
(
Root
);
//TODO: Edit module epilogue to remove the VISC intrinsic declarations
return
true
;
}
...
...
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