Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
760925b9
Commit
760925b9
authored
Aug 15, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Microoptimize rewriter
parent
31f72898
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
11 deletions
+18
-11
src/asm_writing/rewriter.cpp
src/asm_writing/rewriter.cpp
+15
-8
src/asm_writing/rewriter.h
src/asm_writing/rewriter.h
+3
-3
No files found.
src/asm_writing/rewriter.cpp
View file @
760925b9
...
...
@@ -691,7 +691,7 @@ assembler::XMMRegister RewriterVar::getInXMMReg(Location dest) {
}
bool
RewriterVar
::
isInLocation
(
Location
l
)
{
return
locations
.
count
(
l
)
!=
0
;
return
std
::
find
(
locations
.
begin
(),
locations
.
end
(),
l
)
!=
locations
.
end
()
;
}
RewriterVar
*
Rewriter
::
getArg
(
int
argnum
)
{
...
...
@@ -880,7 +880,7 @@ void Rewriter::_setupCall(bool has_side_effects, const RewriterVar::SmallVector&
addLocationToVar
(
var
,
l
);
}
else
{
assembler
::
Register
r2
=
var
->
getInReg
(
l
);
assert
(
var
->
locations
.
count
(
r2
));
assert
(
var
->
isInLocation
(
r2
));
assert
(
r2
==
r
);
}
}
...
...
@@ -1244,7 +1244,7 @@ void Rewriter::commit() {
}
// silly, but need to make a copy due to the mutations:
for
(
auto
l
:
std
::
vector
<
Location
>
(
var
->
locations
.
begin
(),
var
->
locations
.
end
()))
{
for
(
auto
l
:
llvm
::
SmallVector
<
Location
,
8
>
(
var
->
locations
.
begin
(),
var
->
locations
.
end
()))
{
if
(
l
==
expected
)
continue
;
removeLocationFromVar
(
var
,
l
);
...
...
@@ -1691,7 +1691,7 @@ void Rewriter::addLocationToVar(RewriterVar* var, Location l) {
||
l
.
type
==
Location
::
Stack
,
"%d"
,
l
.
type
);
var
->
locations
.
insert
(
l
);
var
->
locations
.
push_back
(
l
);
vars_by_location
[
l
]
=
var
;
#ifndef NDEBUG
...
...
@@ -1714,7 +1714,12 @@ void Rewriter::removeLocationFromVar(RewriterVar* var, Location l) {
assert
(
vars_by_location
[
l
]
==
var
);
vars_by_location
.
erase
(
l
);
var
->
locations
.
erase
(
l
);
for
(
auto
it
=
var
->
locations
.
begin
(),
it_end
=
var
->
locations
.
end
();
it
!=
it_end
;
++
it
)
{
if
(
*
it
==
l
)
{
it
=
var
->
locations
.
erase
(
it
);
break
;
}
}
}
RewriterVar
*
Rewriter
::
createNewVar
()
{
...
...
@@ -1751,7 +1756,8 @@ assembler::Register RewriterVar::initializeInReg(Location l) {
var
=
this
;
// Add the location to this
this
->
locations
.
insert
(
l
);
assert
(
!
isInLocation
(
l
));
this
->
locations
.
push_back
(
l
);
return
reg
;
}
...
...
@@ -1768,7 +1774,8 @@ assembler::XMMRegister RewriterVar::initializeInXMMReg(Location l) {
var
=
this
;
// Add the location to this
this
->
locations
.
insert
(
l
);
assert
(
!
isInLocation
(
l
));
this
->
locations
.
push_back
(
l
);
return
reg
;
}
...
...
@@ -1825,7 +1832,7 @@ Rewriter::Rewriter(std::unique_ptr<ICSlotRewrite> rewrite, int num_args, const s
RewriterVar
*&
var
=
vars_by_location
[
l
];
if
(
!
var
)
{
var
=
createNewVar
();
var
->
locations
.
insert
(
l
);
var
->
locations
.
push_back
(
l
);
}
this
->
live_outs
.
push_back
(
var
);
...
...
src/asm_writing/rewriter.h
View file @
760925b9
...
...
@@ -227,7 +227,7 @@ public:
private:
Rewriter
*
rewriter
;
std
::
set
<
Location
>
locations
;
llvm
::
SmallVector
<
Location
,
4
>
locations
;
bool
isInLocation
(
Location
l
);
// uses is a vector of the indices into the Rewriter::actions vector
...
...
@@ -320,7 +320,7 @@ protected:
// Loads the constant into any register or if already in a register just return it
assembler
::
Register
loadConst
(
uint64_t
val
,
Location
otherThan
=
Location
::
any
());
std
::
vector
<
std
::
pair
<
uint64_t
,
RewriterVar
*>
>
consts
;
llvm
::
SmallVector
<
std
::
pair
<
uint64_t
,
RewriterVar
*>
,
16
>
consts
;
};
...
...
@@ -463,7 +463,7 @@ protected:
}
}
assert
(
found
);
assert
(
p
.
second
->
locations
.
count
(
p
.
first
)
==
1
);
assert
(
p
.
second
->
isInLocation
(
p
.
first
)
);
}
}
if
(
!
done_guarding
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment