Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
d88be975
Commit
d88be975
authored
Jul 04, 2001
by
Götz Lindenmaier
Browse files
Added support for lowering to entites, types.
added support for visibilit of entities, allocation mode [r215]
parent
dc6419a8
Changes
6
Hide whitespace changes
Inline
Side-by-side
ir/tr/entity.c
View file @
d88be975
...
...
@@ -39,6 +39,8 @@ new_entity (type *owner, ident *name, type *type)
res
->
owner
=
owner
;
res
->
name
=
name
;
res
->
type
=
type
;
res
->
allocation
=
dynamic_allocated
;
res
->
visibility
=
local
;
res
->
ld_name
=
NULL
;
res
->
visit
=
0
;
...
...
@@ -122,6 +124,29 @@ set_entity_type (entity *ent, type *type) {
ent
->
type
=
type
;
}
inline
ent_allocation
get_entity_allocation
(
entity
*
ent
)
{
return
ent
->
allocation
;
}
inline
void
set_entity_allocation
(
entity
*
ent
,
ent_allocation
al
)
{
ent
->
allocation
=
al
;
}
inline
ent_visibility
get_entity_visibility
(
entity
*
ent
)
{
return
ent
->
visibility
;
}
inline
void
set_entity_visibility
(
entity
*
ent
,
ent_visibility
vis
)
{
if
(
vis
!=
local
)
assert
(
ent
->
allocation
==
static_allocated
);
ent
->
visibility
=
vis
;
}
inline
int
get_entity_offset
(
entity
*
ent
)
{
return
ent
->
offset
;
...
...
ir/tr/entity.h
View file @
d88be975
...
...
@@ -97,6 +97,32 @@ inline void assert_legal_owner_of_ent(type *owner);
type
*
get_entity_type
(
entity
*
ent
);
void
set_entity_type
(
entity
*
ent
,
type
*
type
);
typedef
enum
{
dynamic_allocated
,
/* The entity is allocated during runtime, either explicitly
by an Alloc node or implicitly as component of a compound
type. This is the default. */
static_allocated
/* The entity is allocated statically. We can use a
SymConst as address of the entity. */
}
ent_allocation
;
ent_allocation
get_entity_allocation
(
entity
*
ent
);
void
set_entity_allocation
(
entity
*
ent
,
ent_allocation
al
);
/* This enumeration flags the visibility of entities. This is necessary
for partial compilation. */
typedef
enum
{
local
,
/* The entity is only visible locally. This is the default. */
external_visible
,
/* The entity is visible to other external program parts, but
it is defined here. It may not be optimized away. The entity must
be static_allocated. */
external_allocated
/* The entity is defined and allocated externaly. This compilation
must not allocate memory for this entity. The entity must
be static_allocated. */
}
ent_visibility
;
ent_visibility
get_entity_visibility
(
entity
*
ent
);
void
set_entity_visibility
(
entity
*
ent
,
ent_visibility
vis
);
int
get_entity_offset
(
entity
*
ent
);
void
set_entity_offset
(
entity
*
ent
,
int
offset
);
...
...
ir/tr/entity_t.h
View file @
d88be975
...
...
@@ -47,6 +47,10 @@ struct entity {
basic type of the language or a class itself */
type
*
owner
;
/* The class this entity belongs to. In case of local
variables the method they are defined in. */
ent_allocation
allocation
;
/* Distinguishes static and dynamically allocated
entities. */
ent_visibility
visibility
;
/* Specifies visibility to external program
fragments */
int
offset
;
/* Offset in byte for this entity. Fixed when layout
of owner is determined. */
/* for methods */
...
...
ir/tr/type.c
View file @
d88be975
...
...
@@ -52,6 +52,7 @@ new_type(tp_op *type_op, ir_mode *mode, ident* name) {
res
->
type_op
=
type_op
;
res
->
mode
=
mode
;
res
->
name
=
name
;
res
->
state
=
layout_undefined
;
res
->
size
=
-
1
;
res
->
visit
=
0
;
...
...
@@ -102,16 +103,34 @@ int get_type_size(type *tp) {
assert
(
tp
);
return
tp
->
size
;
}
void
set_type_size
(
type
*
tp
,
int
size
)
{
void
set_type_size
(
type
*
tp
,
int
size
)
{
assert
(
tp
);
/* For pointer and primitive size depends on the mode. */
assert
((
tp
->
type_op
!=
type_pointer
)
&&
(
tp
->
type_op
!=
type_primitive
))
;
tp
->
size
=
size
;
if
((
tp
->
type_op
!=
type_pointer
)
&&
(
tp
->
type_op
!=
type_primitive
))
tp
->
size
=
size
;
}
type_state
get_type_state
(
type
*
tp
)
{
assert
(
tp
);
return
tp
->
state
;
}
void
set_type_state
(
type
*
tp
,
type_state
state
)
{
assert
(
tp
);
/* For pointer and primitive always fixed. */
if
((
tp
->
type_op
!=
type_pointer
)
&&
(
tp
->
type_op
!=
type_primitive
))
tp
->
state
=
state
;
}
unsigned
long
get_type_visited
(
type
*
tp
)
{
assert
(
tp
);
return
tp
->
visit
;
}
void
set_type_visited
(
type
*
tp
,
unsigned
long
num
)
{
assert
(
tp
);
tp
->
visit
=
num
;
...
...
@@ -475,6 +494,7 @@ type *new_type_pointer (ident *name, type *points_to) {
res
=
new_type
(
type_pointer
,
mode_p
,
name
);
res
->
attr
.
pa
.
points_to
=
points_to
;
res
->
size
=
get_mode_size
(
res
->
mode
);
res
->
state
=
layout_fixed
;
return
res
;
}
/* manipulate fields of type_pointer */
...
...
@@ -503,6 +523,7 @@ type *new_type_primitive (ident *name, ir_mode *mode) {
type
*
res
;
res
=
new_type
(
type_primitive
,
mode
,
name
);
res
->
size
=
get_mode_size
(
mode
);
res
->
state
=
layout_fixed
;
return
res
;
}
...
...
ir/tr/type.h
View file @
d88be975
...
...
@@ -105,8 +105,28 @@ void set_type_nameid(type *tp, ident* id);
const
char
*
get_type_name
(
type
*
tp
);
int
get_type_size
(
type
*
tp
);
/* For primitives and pointer types the size is always fixed.
This call is legal but has no effect. */
void
set_type_size
(
type
*
tp
,
int
size
);
typedef
enum
{
layout_undefined
,
/* The layout of this type is not defined.
Address computation to access fields is not
possible, fields must be accessed by Sel nodes.
This is the default value except for pointer and
primitive types. */
layout_fixed
/* The layout is fixed, all component/member entities
have an offset assigned. Size of the type is known.
Arrays can be accessed by explicit address
computation. Default for pointer and primitive types.
*/
}
type_state
;
type_state
get_type_state
(
type
*
tp
);
/* For primitives and pointer types the layout is always fixed.
This call is legal but has no effect. */
void
set_type_state
(
type
*
tp
,
type_state
state
);
unsigned
long
get_type_visited
(
type
*
tp
);
void
set_type_visited
(
type
*
tp
,
unsigned
long
num
);
/* Sets visited field in type to type_visited. */
...
...
ir/tr/type_t.h
View file @
d88be975
...
...
@@ -91,6 +91,8 @@ struct type {
tp_op
*
type_op
;
ir_mode
*
mode
;
ident
*
name
;
type_state
state
;
/* Represents the types state: layout undefined or
fixed. */
int
size
;
/* Size of an entity of this type. This is determined
when fixing the layout of this class. Size must be
given in bytes. */
...
...
@@ -111,7 +113,7 @@ struct type {
* name - an ident for the name of this type.
* RESULT
* a new type of the given type. The remaining private attributes are not
* initalized.
* initalized.
The type is in state layout_undefined.
***
*/
inline
type
*
...
...
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