ROSE
0.9.6a
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
abiStuff.h
Go to the documentation of this file.
1
#ifndef ROSE_ABISTUFF_H
2
#define ROSE_ABISTUFF_H
3
4
5
#include <vector>
6
#include <string>
7
#include <iosfwd>
8
10
13
struct
StructCustomizedSizes
14
{
15
// optional values like x86, x86-64, ia64, sparcv9, sparcv8 etc.
16
std::string
str_abi
;
17
//Primitive types: redundant if ABI is specified.
18
size_t
sz_bool
;
19
size_t
sz_alignof_bool
;
20
size_t
sz_char
;
21
size_t
sz_alignof_char
;
22
size_t
sz_int
;
23
size_t
sz_alignof_int
;
24
size_t
sz_short
;
25
size_t
sz_alignof_short
;
26
size_t
sz_long
;
27
size_t
sz_alignof_long
;
28
size_t
sz_longlong
;
29
size_t
sz_alignof_longlong
;
30
size_t
sz_float
;
31
size_t
sz_alignof_float
;
32
size_t
sz_double
;
33
size_t
sz_alignof_double
;
34
size_t
sz_longdouble
;
35
size_t
sz_alignof_longdouble
;
36
size_t
sz_pointer
;
// memory handle
37
size_t
sz_alignof_pointer
;
38
size_t
sz_reference
;
39
size_t
sz_alignof_reference
;
40
41
//Extended types beyond ABI's scope
42
size_t
sz_void_ptr
;
43
size_t
sz_alignof_void_ptr
;
44
size_t
sz_ptrdiff_t
;
45
size_t
sz_alignof_ptrdiff_t
;
46
size_t
sz_size_t
;
47
size_t
sz_alignof_size_t
;
48
size_t
sz_wchar
;
49
size_t
sz_alignof_wchar
;
50
51
//UPC specified sizes
52
size_t
sz_shared_ptr
;
53
size_t
sz_alignof_shared_ptr
;
54
size_t
sz_pshared_ptr
;
55
size_t
sz_alignof_pshared_ptr
;
56
size_t
sz_mem_handle
;
57
size_t
sz_alignof_mem_handle
;
58
size_t
sz_reg_handle
;
59
size_t
sz_alignof_reg_handle
;
60
61
size_t
sz_alignof_dbl_1st
;
62
size_t
sz_alignof_int64_1st
;
63
size_t
sz_alignof_sharedptr_1st
;
64
size_t
sz_alignof_psharedptr_1st
;
65
size_t
sz_alignof_dbl_innerstruct
;
66
size_t
sz_alignof_int64_innerstruct
;
67
size_t
sz_alignof_sharedptr_innerstruct
;
68
size_t
sz_alignof_psharedptr_innerstruct
;
69
size_t
sz_maxblocksz
;
70
};
71
72
struct
StructLayoutEntry
{
77
SgNode
*
decl
;
80
size_t
byteOffset
;
82
size_t
fieldSize
;
84
size_t
bitFieldContainerSize
;
87
size_t
bitOffset
;
88
89
StructLayoutEntry
(
SgNode
*
decl
,
size_t
byteOffset
,
size_t
fieldSize
,
size_t
bitFieldContainerSize
= 0,
size_t
bitOffset
= 0):
90
decl(decl), byteOffset(byteOffset), fieldSize(fieldSize),
bitFieldContainerSize
(
bitFieldContainerSize
),
bitOffset
(
bitOffset
) {}
91
};
92
93
struct
StructLayoutInfo
{
95
size_t
size
;
97
size_t
alignment
;
99
std::vector<StructLayoutEntry>
fields
;
100
101
StructLayoutInfo
():
size
(0),
alignment
(0),
fields
() {}
102
};
103
104
std::ostream&
operator<<
(std::ostream& o,
const
StructLayoutEntry
& e);
105
std::ostream&
operator<<
(std::ostream& o,
const
StructLayoutInfo
& i);
106
108
// modifiers
109
class
ROSE_DLL_API
ChainableTypeLayoutGenerator
{
110
public
:
111
virtual
~ChainableTypeLayoutGenerator
() {}
112
ChainableTypeLayoutGenerator
*
next
;
113
ChainableTypeLayoutGenerator
*
beginning
;
114
StructCustomizedSizes
*
custom_sizes
;
115
116
ChainableTypeLayoutGenerator
(
ChainableTypeLayoutGenerator
* nx,
StructCustomizedSizes
* sizes=NULL)
117
#ifdef _MSC_VER
118
: next(NULL), beginning(NULL), custom_sizes(sizes)
119
{
120
// DQ (11/27/2009): MSVC reports a warning when "this" is used in the preinitialization list.
121
beginning =
this
;
122
this->setNext(nx);
123
}
124
#else
125
: next(NULL), beginning(
this
), custom_sizes(sizes)
126
{
127
this->setNext(nx);
128
}
129
#endif
130
131
protected
:
132
void
setNext
(
ChainableTypeLayoutGenerator
* nx) {
133
this->next = nx;
134
if
(nx) nx->
setBeginningRecursively
(this->beginning);
135
}
136
void
setBeginningRecursively
(
ChainableTypeLayoutGenerator
* bg) {
137
this->beginning = bg;
138
if
(this->next) this->next->
setBeginningRecursively
(bg);
139
}
140
141
public
:
142
virtual
StructLayoutInfo
layoutType(
SgType
* t)
const
;
143
};
144
146
// Handles structs and unions only
147
// Does not handle C++ stuff (inheritance, virtual functions) for now
148
class
ROSE_DLL_API
NonpackedTypeLayoutGenerator
:
public
ChainableTypeLayoutGenerator
{
149
public
:
150
NonpackedTypeLayoutGenerator
(
ChainableTypeLayoutGenerator
* next)
151
:
ChainableTypeLayoutGenerator
(next)
152
{}
153
virtual
StructLayoutInfo
layoutType
(
SgType
* t)
const
;
154
155
private
:
156
void
layoutOneField(
SgType
* fieldType,
SgNode
* decl,
bool
isUnion
/* Is type being laid out a union? */
,
size_t
& currentOffset,
StructLayoutInfo
& layout)
const
;
157
};
158
160
class
I386PrimitiveTypeLayoutGenerator
:
public
ChainableTypeLayoutGenerator
{
161
public
:
162
I386PrimitiveTypeLayoutGenerator
(
ChainableTypeLayoutGenerator
*
next
)
163
:
ChainableTypeLayoutGenerator
(next)
164
{}
165
virtual
StructLayoutInfo
layoutType
(
SgType
* t)
const
;
166
};
167
169
class
I386_VSPrimitiveTypeLayoutGenerator
:
public
I386PrimitiveTypeLayoutGenerator
{
170
public
:
171
I386_VSPrimitiveTypeLayoutGenerator
(
ChainableTypeLayoutGenerator
*
next
)
172
:
I386PrimitiveTypeLayoutGenerator
(next)
173
{}
174
virtual
StructLayoutInfo
layoutType
(
SgType
* t)
const
;
175
};
176
178
class
X86_64PrimitiveTypeLayoutGenerator
:
public
ChainableTypeLayoutGenerator
{
179
public
:
180
X86_64PrimitiveTypeLayoutGenerator
(
ChainableTypeLayoutGenerator
*
next
)
181
:
ChainableTypeLayoutGenerator
(next)
182
{}
183
virtual
StructLayoutInfo
layoutType
(
SgType
* t)
const
;
184
};
185
187
class
X86_64_VSPrimitiveTypeLayoutGenerator
:
public
X86_64PrimitiveTypeLayoutGenerator
{
188
public
:
189
X86_64_VSPrimitiveTypeLayoutGenerator
(
ChainableTypeLayoutGenerator
*
next
)
190
:
X86_64PrimitiveTypeLayoutGenerator
(next)
191
{}
192
virtual
StructLayoutInfo
layoutType
(
SgType
* t)
const
;
193
};
194
196
class
SystemPrimitiveTypeLayoutGenerator
:
public
ChainableTypeLayoutGenerator
{
197
public
:
198
SystemPrimitiveTypeLayoutGenerator
(
ChainableTypeLayoutGenerator
*
next
)
199
:
ChainableTypeLayoutGenerator
(next)
200
{}
201
virtual
StructLayoutInfo
layoutType
(
SgType
* t)
const
;
202
};
203
205
class
ROSE_DLL_API
CustomizedPrimitiveTypeLayoutGenerator
:
public
ChainableTypeLayoutGenerator
{
206
public
:
207
CustomizedPrimitiveTypeLayoutGenerator
(
ChainableTypeLayoutGenerator
* next,
StructCustomizedSizes
* custom_sizes)
208
:
ChainableTypeLayoutGenerator
(next,custom_sizes)
209
{}
210
virtual
StructLayoutInfo
layoutType
(
SgType
* t)
const
;
211
};
212
213
214
#endif // ROSE_ABISTUFF_H
rose-edg4x
src
frontend
SageIII
sageInterface
abiStuff.h
Generated on Mon May 5 2014 17:28:48 for ROSE by
1.8.4