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
194f0e40
Commit
194f0e40
authored
Feb 13, 2010
by
Matthias Braun
Browse files
use begnuas to emit block labels so we use the correct private prefix on mac and linux
[r27149]
parent
bf9be89c
Changes
9
Show whitespace changes
Inline
Side-by-side
ir/be/TEMPLATE/TEMPLATE_emitter.c
View file @
194f0e40
...
...
@@ -134,8 +134,7 @@ void TEMPLATE_emit_dest_register(const ir_node *node, int pos)
static
void
TEMPLATE_emit_cfop_target
(
const
ir_node
*
node
)
{
ir_node
*
block
=
get_irn_link
(
node
);
be_emit_irprintf
(
"BLOCK_%ld"
,
get_irn_node_nr
(
block
));
be_gas_emit_block_name
(
block
);
}
/***********************************************************************************
...
...
@@ -219,8 +218,8 @@ void TEMPLATE_gen_block(ir_node *block, void *data)
if
(
!
is_Block
(
block
))
return
;
be_emit_
cstring
(
"BLOCK_"
);
be_emit_
irprintf
(
"%ld:
\n
"
,
get_irn_node_nr
(
block
)
);
be_
gas_
emit_
block_name
(
block
);
be_emit_
cstring
(
":
\n
"
);
be_emit_write_line
();
sched_foreach
(
block
,
node
)
{
...
...
ir/be/arm/arm_emitter.c
View file @
194f0e40
...
...
@@ -57,7 +57,6 @@
#include
"../benode.h"
#define BLOCK_PREFIX ".L"
#define SNPRINTF_BUF_LEN 128
DEBUG_ONLY
(
static
firm_dbg_module_t
*
dbg
=
NULL
;)
...
...
@@ -417,20 +416,6 @@ static ir_node *get_cfop_target_block(const ir_node *irn)
return
get_irn_link
(
irn
);
}
/**
* Emits a block label for the given block.
*/
static
void
arm_emit_block_name
(
const
ir_node
*
block
)
{
if
(
has_Block_entity
(
block
))
{
ir_entity
*
entity
=
get_Block_entity
(
block
);
be_gas_emit_entity
(
entity
);
}
else
{
be_emit_cstring
(
BLOCK_PREFIX
);
be_emit_irprintf
(
"%d"
,
get_irn_node_nr
(
block
));
}
}
/**
* Emit the target label for a control flow node.
*/
...
...
@@ -438,7 +423,7 @@ static void arm_emit_cfop_target(const ir_node *irn)
{
ir_node
*
block
=
get_cfop_target_block
(
irn
);
arm
_emit_block_name
(
block
);
be_gas
_emit_block_name
(
block
);
}
/**
...
...
@@ -1060,7 +1045,7 @@ static void arm_emit_block_header(ir_node *block, ir_node *prev)
}
if
(
need_label
)
{
arm
_emit_block_name
(
block
);
be_gas
_emit_block_name
(
block
);
be_emit_char
(
':'
);
be_emit_pad_comment
();
...
...
@@ -1074,7 +1059,7 @@ static void arm_emit_block_header(ir_node *block, ir_node *prev)
}
}
else
{
be_emit_cstring
(
"
\t
/* "
);
arm
_emit_block_name
(
block
);
be_gas
_emit_block_name
(
block
);
be_emit_cstring
(
": "
);
}
if
(
exec_freq
!=
NULL
)
{
...
...
ir/be/beabi.c
View file @
194f0e40
...
...
@@ -2108,11 +2108,11 @@ static ir_entity *create_trampoline(be_main_env_t *be, ir_entity *method)
{
ir_type
*
type
=
get_entity_type
(
method
);
ident
*
old_id
=
get_entity_ld_ident
(
method
);
ident
*
id
=
id_mangle3
(
"
L
"
,
old_id
,
"$stub"
);
ident
*
id
=
id_mangle3
(
""
,
old_id
,
"$stub"
);
ir_type
*
parent
=
be
->
pic_trampolines_type
;
ir_entity
*
ent
=
new_entity
(
parent
,
old_id
,
type
);
set_entity_ld_ident
(
ent
,
id
);
set_entity_visibility
(
ent
,
ir_visibility_
local
);
set_entity_visibility
(
ent
,
ir_visibility_
private
);
return
ent
;
}
...
...
@@ -2134,13 +2134,13 @@ static ir_entity *get_trampoline(be_main_env_t *env, ir_entity *method)
static
ir_entity
*
create_pic_symbol
(
be_main_env_t
*
be
,
ir_entity
*
entity
)
{
ident
*
old_id
=
get_entity_ld_ident
(
entity
);
ident
*
id
=
id_mangle3
(
"
L
"
,
old_id
,
"$non_lazy_ptr"
);
ident
*
id
=
id_mangle3
(
""
,
old_id
,
"$non_lazy_ptr"
);
ir_type
*
e_type
=
get_entity_type
(
entity
);
ir_type
*
type
=
new_type_pointer
(
e_type
);
ir_type
*
parent
=
be
->
pic_symbols_type
;
ir_entity
*
ent
=
new_entity
(
parent
,
old_id
,
type
);
set_entity_ld_ident
(
ent
,
id
);
set_entity_visibility
(
ent
,
ir_visibility_
local
);
set_entity_visibility
(
ent
,
ir_visibility_
private
);
return
ent
;
}
...
...
ir/be/begnuas.c
View file @
194f0e40
...
...
@@ -572,14 +572,6 @@ static void emit_arith_tarval(tarval *tv, int bytes)
panic
(
"Can't dump a tarval with %d bytes"
,
bytes
);
}
/**
* Return the label prefix for labeled blocks.
*/
const
char
*
be_gas_block_label_prefix
(
void
)
{
return
".LG"
;
}
/**
* Return the label prefix for labeled instructions.
*/
...
...
@@ -1373,7 +1365,7 @@ static void emit_indirect_symbol(const ir_entity *entity, be_gas_section_t secti
/* we can only do PIC code on macho so far */
assert
(
be_gas_object_file_format
==
OBJECT_FILE_FORMAT_MACH_O
);
be_emit_
ident
(
get_entity_ld_id
ent
(
entity
)
)
;
be_
gas_
emit_ent
ity
(
entity
);
be_emit_cstring
(
":
\n
"
);
be_emit_write_line
();
be_emit_cstring
(
"
\t
.indirect_symbol "
);
...
...
@@ -1390,21 +1382,41 @@ static void emit_indirect_symbol(const ir_entity *entity, be_gas_section_t secti
}
}
static
void
emit_private_prefix
(
void
)
{
if
(
be_gas_object_file_format
==
OBJECT_FILE_FORMAT_MACH_O
)
{
be_emit_char
(
'L'
);
}
else
{
be_emit_cstring
(
".L"
);
}
}
void
be_gas_emit_entity
(
const
ir_entity
*
entity
)
{
if
(
entity
->
type
==
firm_code_type
)
{
ir_label_t
label
=
get_entity_label
(
entity
);
be_
emit_
string
(
be_gas_block_label
_prefix
()
)
;
be_emit_irprintf
(
"%lu"
,
label
);
emit_
private
_prefix
();
be_emit_irprintf
(
"
_
%lu"
,
label
);
return
;
}
if
(
get_entity_visibility
(
entity
)
==
ir_visibility_private
)
{
be_
emit_
cstring
(
".L"
);
emit_
private_prefix
(
);
}
be_emit_ident
(
get_entity_ld_ident
(
entity
));
}
void
be_gas_emit_block_name
(
const
ir_node
*
block
)
{
if
(
has_Block_entity
(
block
))
{
ir_entity
*
entity
=
get_Block_entity
(
block
);
be_gas_emit_entity
(
entity
);
}
else
{
emit_private_prefix
();
be_emit_irprintf
(
"%ld"
,
get_irn_node_nr
(
block
));
}
}
/**
* Dump a global entity.
*
...
...
ir/be/begnuas.h
View file @
194f0e40
...
...
@@ -94,9 +94,9 @@ void be_gas_emit_function_epilog(const ir_entity *entity);
void
be_gas_emit_entity
(
const
ir_entity
*
entity
);
/**
*
Return the label prefix for labeled
block
s.
*
Emit (a private) symbol name for a firm
block
*/
const
char
*
be_gas_block_
label_prefix
(
void
);
void
be_gas_
emit_
block_
name
(
const
ir_node
*
block
);
/**
* Return the label prefix for labeled instructions.
...
...
ir/be/ia32/ia32_emitter.c
View file @
194f0e40
...
...
@@ -80,8 +80,6 @@
DEBUG_ONLY
(
static
firm_dbg_module_t
*
dbg
=
NULL
;)
#define BLOCK_PREFIX ".L"
#define SNPRINTF_BUF_LEN 128
static
const
ia32_isa_t
*
isa
;
...
...
@@ -509,27 +507,13 @@ static ir_node *get_cfop_target_block(const ir_node *irn)
return
get_irn_link
(
irn
);
}
/**
* Emits a block label for the given block.
*/
static
void
ia32_emit_block_name
(
const
ir_node
*
block
)
{
if
(
has_Block_entity
(
block
))
{
ir_entity
*
entity
=
get_Block_entity
(
block
);
be_gas_emit_entity
(
entity
);
}
else
{
be_emit_cstring
(
BLOCK_PREFIX
);
be_emit_irprintf
(
"%ld"
,
get_irn_node_nr
(
block
));
}
}
/**
* Emits the target label for a control flow node.
*/
static
void
ia32_emit_cfop_target
(
const
ir_node
*
node
)
{
ir_node
*
block
=
get_cfop_target_block
(
node
);
ia32
_emit_block_name
(
block
);
be_gas
_emit_block_name
(
block
);
}
/*
...
...
@@ -1890,10 +1874,14 @@ static void emit_ia32_ClimbFrame(const ir_node *node)
ia32_emitf
(
node
,
"
\t
movl %S0, %D0
\n
"
);
ia32_emitf
(
node
,
"
\t
movl $%u, %S1
\n
"
,
attr
->
count
);
ia32_emitf
(
NULL
,
BLOCK_PREFIX
"%ld:
\n
"
,
get_irn_node_nr
(
node
));
be_gas_emit_block_name
(
node
);
be_emit_cstring
(
":
\n
"
);
be_emit_write_line
();
ia32_emitf
(
node
,
"
\t
movl (%D0), %D0
\n
"
);
ia32_emitf
(
node
,
"
\t
dec %S1
\n
"
);
ia32_emitf
(
node
,
"
\t
jnz "
BLOCK_PREFIX
"%ld
\n
"
,
get_irn_node_nr
(
node
));
be_emit_cstring
(
"
\t
jnz "
);
be_gas_emit_block_name
(
node
);
be_emit_finish_line_gas
(
node
);
}
static
void
emit_be_Return
(
const
ir_node
*
node
)
...
...
@@ -2149,14 +2137,14 @@ static void ia32_emit_block_header(ir_node *block)
}
if
(
need_label
)
{
ia32
_emit_block_name
(
block
);
be_gas
_emit_block_name
(
block
);
be_emit_char
(
':'
);
be_emit_pad_comment
();
be_emit_cstring
(
" /* "
);
}
else
{
be_emit_cstring
(
"
\t
/* "
);
ia32
_emit_block_name
(
block
);
be_gas
_emit_block_name
(
block
);
be_emit_cstring
(
": "
);
}
...
...
@@ -2301,7 +2289,7 @@ void ia32_gen_routine(ia32_code_gen_t *ia32_cg, ir_graph *irg)
ia32_emit_exc_label
(
exc_list
[
i
].
exc_instr
);
be_emit_char
(
'\n'
);
be_emit_cstring
(
"
\t
.long "
);
ia32
_emit_block_name
(
exc_list
[
i
].
block
);
be_gas
_emit_block_name
(
exc_list
[
i
].
block
);
be_emit_char
(
'\n'
);
}
}
...
...
@@ -2451,7 +2439,7 @@ static void bemit_entity(ir_entity *entity, bool entity_sign, int offset,
static
void
bemit_jmp_destination
(
const
ir_node
*
dest_block
)
{
be_emit_cstring
(
"
\t
.long "
);
ia32
_emit_block_name
(
dest_block
);
be_gas
_emit_block_name
(
dest_block
);
be_emit_cstring
(
" - . - 4
\n
"
);
be_emit_write_line
();
}
...
...
ir/be/mips/mips_emitter.c
View file @
194f0e40
...
...
@@ -52,8 +52,6 @@
DEBUG_ONLY
(
static
firm_dbg_module_t
*
dbg
=
NULL
;)
#define BLOCK_PREFIX ".L"
#define SNPRINTF_BUF_LEN 128
/**
...
...
@@ -410,36 +408,13 @@ static void mips_emit_Call(const ir_node *node)
* |_|
************************************************************************/
const
char
*
mips_get_block_label
(
const
ir_node
*
block
)
{
static
char
buf
[
64
];
snprintf
(
buf
,
sizeof
(
buf
),
"BLOCK_%ld"
,
get_irn_node_nr
(
block
));
return
buf
;
}
/**
* Emits a block label from the given block.
*/
static
void
mips_emit_block_label
(
const
ir_node
*
block
)
{
if
(
has_Block_entity
(
block
))
{
ir_entity
*
entity
=
get_Block_entity
(
block
);
be_gas_emit_entity
(
entity
);
}
else
{
be_emit_cstring
(
BLOCK_PREFIX
);
be_emit_irprintf
(
"%ld"
,
get_irn_node_nr
(
block
));
}
}
static
void
mips_emit_Jump
(
const
ir_node
*
node
)
{
const
ir_node
*
block
=
get_irn_link
(
node
);
assert
(
is_Block
(
block
));
be_emit_cstring
(
"
\t
b "
);
mip
s_emit_block_
label
(
block
);
be_ga
s_emit_block_
name
(
block
);
be_emit_finish_line_gas
(
node
);
}
...
...
@@ -465,7 +440,7 @@ void mips_emit_jump_target_proj(const ir_node *node, long projn)
ir_node
*
jumpblock
=
mips_get_jump_block
(
node
,
projn
);
assert
(
jumpblock
!=
NULL
);
mip
s_emit_block_
label
(
jumpblock
);
be_ga
s_emit_block_
name
(
jumpblock
);
}
void
mips_emit_jump_target
(
const
ir_node
*
node
)
...
...
@@ -473,7 +448,7 @@ void mips_emit_jump_target(const ir_node *node)
ir_node
*
jumpblock
=
get_irn_link
(
node
);
assert
(
jumpblock
!=
NULL
);
mip
s_emit_block_
label
(
jumpblock
);
be_ga
s_emit_block_
name
(
jumpblock
);
}
void
mips_emit_jump_or_fallthrough
(
const
ir_node
*
node
,
long
pn
)
...
...
@@ -483,7 +458,7 @@ void mips_emit_jump_or_fallthrough(const ir_node *node, long pn)
/* TODO: use fallthrough when possible */
be_emit_cstring
(
"b "
);
mip
s_emit_block_
label
(
jumpblock
);
be_ga
s_emit_block_
name
(
jumpblock
);
}
/************************************************************************
...
...
@@ -593,7 +568,7 @@ void emit_mips_jump_table(const ir_node *irn)
}
be_emit_cstring("\t.word ");
mip
s_emit_block_
label
(branch->target);
be_ga
s_emit_block_
name
(branch->target);
be_emit_char('\n');
be_emit_write_line();
...
...
@@ -715,7 +690,7 @@ void mips_gen_block(const ir_node *block)
if
(
!
is_Block
(
block
))
return
;
mip
s_emit_block_
label
(
block
);
be_ga
s_emit_block_
name
(
block
);
be_emit_cstring
(
":
\n
"
);
be_emit_write_line
();
...
...
ir/be/ppc32/ppc32_emitter.c
View file @
194f0e40
...
...
@@ -40,6 +40,7 @@
#include
"../besched.h"
#include
"../benode.h"
#include
"../begnuas.h"
#include
"ppc32_emitter.h"
#include
"gen_ppc32_emitter.h"
...
...
@@ -233,17 +234,6 @@ void ppc32_emit_offset(const ir_node *n)
}
}
/**
* Returns the target label for a control flow node.
*/
static
char
*
get_cfop_target
(
const
ir_node
*
irn
,
char
*
buf
)
{
ir_node
*
bl
=
get_irn_link
(
irn
);
snprintf
(
buf
,
SNPRINTF_BUF_LEN
,
"BLOCK_%ld"
,
get_irn_node_nr
(
bl
));
return
buf
;
}
/**
* Emits code for a unconditional jump.
*/
...
...
@@ -252,7 +242,9 @@ static void emit_Jmp(const ir_node *irn)
ir_node
*
block
=
get_nodes_block
(
irn
);
if
(
get_irn_link
(
irn
)
!=
get_irn_link
(
block
))
{
be_emit_irprintf
(
"
\t
b %s"
,
get_cfop_target
(
irn
,
printbuf
));
ir_node
*
dest
=
get_irn_link
(
irn
);
be_emit_cstring
(
"
\t
b "
);
be_gas_emit_block_name
(
dest
);
}
else
{
be_emit_irprintf
(
"/* fallthrough(%+F) */"
,
get_irn_link
(
irn
));
}
...
...
@@ -297,11 +289,10 @@ static void emit_ppc32_Branch(const ir_node *irn)
assert
(
opind
>=
0
&&
opind
<
8
);
if
(
opind
){
get_cfop_target
(
proj
,
printbuf
);
be_emit_irprintf
(
"
\t
%8s"
,
branchops
[
opind
]);
ppc32_emit_source_register
(
irn
,
0
);
be_emit_cstring
(
", "
);
be_emit_
str
in
g
(
pr
intbuf
);
be_
gas_
emit_
block_name
(
get_irn_l
in
k
(
pr
oj
)
);
be_emit_finish_line_gas
(
irn
);
}
...
...
@@ -309,7 +300,7 @@ static void emit_ppc32_Branch(const ir_node *irn)
if
(
edge
)
{
ir_node
*
blk
=
get_edge_src_irn
(
edge
);
be_emit_cstring
(
"
\t
b "
);
be_emit_
string
(
get_cfop_target
(
blk
,
printbuf
));
be_
gas_
emit_
block_name
(
get_irn_link
(
blk
));
be_emit_finish_line_gas
(
irn
);
}
}
...
...
@@ -386,13 +377,15 @@ static void emit_ppc32_Switch(const ir_node *irn)
be_emit_cstring
(
"
\t
beq "
);
ppc32_emit_source_register
(
irn
,
2
);
be_emit_irprintf
(
", %s"
,
get_cfop_target
(
proj
,
printbuf
));
be_emit_cstring
(
", "
);
be_gas_emit_block_name
(
get_irn_link
(
proj
));
be_emit_cstring
(
"/* Branch if equal */
\n
"
);
be_emit_write_line
();
}
}
assert
(
defproj
!=
NULL
&&
"didn't find defProj at Switch"
);
be_emit_irprintf
(
"
\t
b %s"
,
get_cfop_target
(
defproj
,
printbuf
));
be_emit_cstring
(
"
\t
b "
);
be_gas_emit_block_name
(
get_irn_link
(
defproj
));
be_emit_finish_line_gas
(
irn
);
}
...
...
@@ -604,7 +597,8 @@ static void ppc32_gen_block(const ir_node *block)
if
(
!
is_Block
(
block
))
return
;
be_emit_irprintf
(
"BLOCK_%ld:
\n
"
,
get_irn_node_nr
(
block
));
be_gas_emit_block_name
(
block
);
be_emit_cstring
(
":
\n
"
);
be_emit_write_line
();
sched_foreach
(
block
,
irn
)
{
ppc32_emit_node
(
irn
);
...
...
ir/be/sparc/sparc_emitter.c
View file @
194f0e40
...
...
@@ -215,7 +215,7 @@ void sparc_emit_store_mode(const ir_node *node)
static
void
sparc_emit_cfop_target
(
const
ir_node
*
node
)
{
ir_node
*
block
=
get_irn_link
(
node
);
be_emit_
irprintf
(
"BLOCK_%ld"
,
get_irn_node_nr
(
block
)
)
;
be_
gas_
emit_
block_name
(
block
);
}
/**
...
...
@@ -572,8 +572,9 @@ void sparc_gen_block(ir_node *block, void *data)
if
(
!
is_Block
(
block
))
return
;
be_emit_cstring
(
"BLOCK_"
);
be_emit_irprintf
(
"%ld:
\n
"
,
get_irn_node_nr
(
block
));
be_gas_emit_block_name
(
block
);
be_emit_cstring
(
":
\n
"
);
be_emit_write_line
();
sched_foreach
(
block
,
node
)
{
...
...
Write
Preview
Supports
Markdown
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