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
4eb5b941
Commit
4eb5b941
authored
Apr 05, 2016
by
Marius Wachtler
Committed by
Kevin Modzelewski
Apr 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move Location from rewriter.h to types.h
parent
bacf0cfa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
76 deletions
+73
-76
src/asm_writing/rewriter.h
src/asm_writing/rewriter.h
+0
-76
src/asm_writing/types.h
src/asm_writing/types.h
+73
-0
No files found.
src/asm_writing/rewriter.h
View file @
4eb5b941
...
...
@@ -41,82 +41,6 @@ class ICInvalidator;
class
RewriterVar
;
struct
Location
{
public:
enum
LocationType
:
uint8_t
{
Register
,
XMMRegister
,
Stack
,
Scratch
,
// stack location, relative to the scratch start
// For representing constants that fit in 32-bits, that can be encoded as immediates
AnyReg
,
// special type for use when specifying a location as a destination
None
,
// special type that represents the lack of a location, ex where a "ret void" gets returned
Uninitialized
,
// special type for an uninitialized (and invalid) location
};
public:
LocationType
type
;
union
{
// only valid if type==Register; uses X86 numbering, not dwarf numbering.
// also valid if type==XMMRegister
int32_t
regnum
;
// only valid if type==Stack; this is the offset from bottom of the original frame.
// ie argument #6 will have a stack_offset of 0, #7 will have a stack offset of 8, etc
int32_t
stack_offset
;
// only valid if type == Scratch; offset from the beginning of the scratch area
int32_t
scratch_offset
;
int32_t
_data
;
};
constexpr
Location
()
noexcept
:
type
(
Uninitialized
),
_data
(
-
1
)
{}
constexpr
Location
(
const
Location
&
r
)
=
default
;
Location
&
operator
=
(
const
Location
&
r
)
=
default
;
constexpr
Location
(
LocationType
type
,
int32_t
data
)
:
type
(
type
),
_data
(
data
)
{}
constexpr
Location
(
assembler
::
Register
reg
)
:
type
(
Register
),
regnum
(
reg
.
regnum
)
{}
constexpr
Location
(
assembler
::
XMMRegister
reg
)
:
type
(
XMMRegister
),
regnum
(
reg
.
regnum
)
{}
constexpr
Location
(
assembler
::
GenericRegister
reg
)
:
type
(
reg
.
type
==
assembler
::
GenericRegister
::
GP
?
Register
:
reg
.
type
==
assembler
::
GenericRegister
::
XMM
?
XMMRegister
:
None
),
regnum
(
reg
.
type
==
assembler
::
GenericRegister
::
GP
?
reg
.
gp
.
regnum
:
reg
.
xmm
.
regnum
)
{}
assembler
::
Register
asRegister
()
const
;
assembler
::
XMMRegister
asXMMRegister
()
const
;
bool
isClobberedByCall
()
const
;
static
constexpr
Location
any
()
{
return
Location
(
AnyReg
,
0
);
}
static
constexpr
Location
none
()
{
return
Location
(
None
,
0
);
}
static
Location
forArg
(
int
argnum
);
static
Location
forXMMArg
(
int
argnum
);
bool
operator
==
(
const
Location
rhs
)
const
{
return
this
->
asInt
()
==
rhs
.
asInt
();
}
bool
operator
!=
(
const
Location
rhs
)
const
{
return
!
(
*
this
==
rhs
);
}
bool
operator
<
(
const
Location
&
rhs
)
const
{
return
this
->
asInt
()
<
rhs
.
asInt
();
}
uint64_t
asInt
()
const
{
return
(
int
)
type
+
((
uint64_t
)
_data
<<
4
);
}
void
dump
()
const
;
};
static_assert
(
sizeof
(
Location
)
<=
8
,
""
);
}
namespace
std
{
template
<
>
struct
hash
<
pyston
::
Location
>
{
size_t
operator
()(
const
pyston
::
Location
p
)
const
{
return
p
.
asInt
();
}
};
}
namespace
pyston
{
// Replacement for unordered_map<Location, T>
template
<
class
T
>
class
LocMap
{
private:
...
...
src/asm_writing/types.h
View file @
4eb5b941
...
...
@@ -176,6 +176,79 @@ struct JumpDestination {
static
JumpDestination
fromStart
(
int
offset
)
{
return
JumpDestination
(
FROM_START
,
offset
);
}
};
}
struct
Location
{
public:
enum
LocationType
:
uint8_t
{
Register
,
XMMRegister
,
Stack
,
Scratch
,
// stack location, relative to the scratch start
// For representing constants that fit in 32-bits, that can be encoded as immediates
AnyReg
,
// special type for use when specifying a location as a destination
None
,
// special type that represents the lack of a location, ex where a "ret void" gets returned
Uninitialized
,
// special type for an uninitialized (and invalid) location
};
public:
LocationType
type
;
union
{
// only valid if type==Register; uses X86 numbering, not dwarf numbering.
// also valid if type==XMMRegister
int32_t
regnum
;
// only valid if type==Stack; this is the offset from bottom of the original frame.
// ie argument #6 will have a stack_offset of 0, #7 will have a stack offset of 8, etc
int32_t
stack_offset
;
// only valid if type == Scratch; offset from the beginning of the scratch area
int32_t
scratch_offset
;
int32_t
_data
;
};
constexpr
Location
()
noexcept
:
type
(
Uninitialized
),
_data
(
-
1
)
{}
constexpr
Location
(
const
Location
&
r
)
=
default
;
Location
&
operator
=
(
const
Location
&
r
)
=
default
;
constexpr
Location
(
LocationType
type
,
int32_t
data
)
:
type
(
type
),
_data
(
data
)
{}
constexpr
Location
(
assembler
::
Register
reg
)
:
type
(
Register
),
regnum
(
reg
.
regnum
)
{}
constexpr
Location
(
assembler
::
XMMRegister
reg
)
:
type
(
XMMRegister
),
regnum
(
reg
.
regnum
)
{}
constexpr
Location
(
assembler
::
GenericRegister
reg
)
:
type
(
reg
.
type
==
assembler
::
GenericRegister
::
GP
?
Register
:
reg
.
type
==
assembler
::
GenericRegister
::
XMM
?
XMMRegister
:
None
),
regnum
(
reg
.
type
==
assembler
::
GenericRegister
::
GP
?
reg
.
gp
.
regnum
:
reg
.
xmm
.
regnum
)
{}
assembler
::
Register
asRegister
()
const
;
assembler
::
XMMRegister
asXMMRegister
()
const
;
bool
isClobberedByCall
()
const
;
static
constexpr
Location
any
()
{
return
Location
(
AnyReg
,
0
);
}
static
constexpr
Location
none
()
{
return
Location
(
None
,
0
);
}
static
Location
forArg
(
int
argnum
);
static
Location
forXMMArg
(
int
argnum
);
bool
operator
==
(
const
Location
rhs
)
const
{
return
this
->
asInt
()
==
rhs
.
asInt
();
}
bool
operator
!=
(
const
Location
rhs
)
const
{
return
!
(
*
this
==
rhs
);
}
bool
operator
<
(
const
Location
&
rhs
)
const
{
return
this
->
asInt
()
<
rhs
.
asInt
();
}
uint64_t
asInt
()
const
{
return
(
int
)
type
+
((
uint64_t
)
_data
<<
4
);
}
void
dump
()
const
;
};
static_assert
(
sizeof
(
Location
)
<=
8
,
""
);
}
namespace
std
{
template
<
>
struct
hash
<
pyston
::
Location
>
{
size_t
operator
()(
const
pyston
::
Location
p
)
const
{
return
p
.
asInt
();
}
};
}
#endif
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