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
a6da8020
Commit
a6da8020
authored
May 25, 2015
by
Christoph Mallon
Browse files
be: Move be_emit_asm() into a separate file for asm handling.
parent
73db736b
Changes
7
Hide whitespace changes
Inline
Side-by-side
ir/be/amd64/amd64_emitter.c
View file @
a6da8020
...
...
@@ -13,6 +13,7 @@
#include "amd64_new_nodes.h"
#include "amd64_nodes_attr.h"
#include "be_t.h"
#include "beasm.h"
#include "beblocksched.h"
#include "bediagnostic.h"
#include "begnuas.h"
...
...
ir/be/beasm.c
0 → 100644
View file @
a6da8020
/*
* This file is part of libFirm.
* Copyright (C) 2015 University of Karlsruhe.
*/
#include <ctype.h>
#include "beasm.h"
#include "bediagnostic.h"
#include "beemitter.h"
#include "ident_t.h"
void
be_emit_asm
(
ir_node
const
*
const
asmn
,
ident
*
const
text
,
unsigned
const
n_operands
,
be_emit_asm_operand_func
*
const
emit_asm_operand
)
{
be_emit_cstring
(
"#APP"
);
be_emit_finish_line_gas
(
asmn
);
char
const
*
s
=
get_id_str
(
text
);
if
(
s
[
0
]
!=
'\t'
)
be_emit_char
(
'\t'
);
char
const
*
last
=
s
;
while
((
s
=
strchr
(
s
,
'%'
)))
{
be_emit_string_len
(
last
,
s
-
last
);
++
s
;
/* Skip '%'. */
switch
(
*
s
)
{
case
'%'
:
case
'{'
:
case
'|'
:
case
'}'
:
be_emit_char
(
*
s
++
);
break
;
default:
{
char
const
modifier
=
isalpha
((
unsigned
char
)
*
s
)
?
*
s
++
:
'\0'
;
unsigned
pos
;
int
p
;
if
(
sscanf
(
s
,
"%u%n"
,
&
pos
,
&
p
)
==
1
)
{
s
+=
p
;
if
(
pos
<
n_operands
)
{
emit_asm_operand
(
asmn
,
modifier
,
pos
);
}
else
{
be_errorf
(
asmn
,
"asm operand number '%u' out of range"
,
pos
);
}
}
else
{
be_errorf
(
asmn
,
"could not parse asm operand number"
);
}
break
;
}
}
last
=
s
;
}
be_emit_string
(
last
);
be_emit_cstring
(
"
\n
#NO_APP
\n
"
);
be_emit_write_line
();
}
ir/be/beasm.h
0 → 100644
View file @
a6da8020
/*
* This file is part of libFirm.
* Copyright (C) 2015 University of Karlsruhe.
*/
/**
* @file
* @brief Helper functions to handle inline assembler nodes.
*/
#ifndef FIRM_BE_BEASM_H
#define FIRM_BE_BEASM_H
#include "firm_types.h"
typedef
void
be_emit_asm_operand_func
(
ir_node
const
*
asmn
,
char
modifier
,
unsigned
pos
);
void
be_emit_asm
(
ir_node
const
*
asmn
,
ident
*
text
,
unsigned
n_operands
,
be_emit_asm_operand_func
*
emit_asm_operand
);
#endif
ir/be/beemitter.c
View file @
a6da8020
...
...
@@ -9,9 +9,6 @@
* @author Matthias Braun
* @date 12.03.2007
*/
#include <ctype.h>
#include "bediagnostic.h"
#include "bedwarf.h"
#include "beemitter.h"
#include "benode.h"
...
...
@@ -19,7 +16,6 @@
#include "panic.h"
#include "irnode_t.h"
#include "irprintf.h"
#include "ident.h"
#include "tv.h"
#include "dbginfo.h"
#include "util.h"
...
...
@@ -106,50 +102,3 @@ void be_emit_node(ir_node const *const node)
DEBUG_ONLY
(
if
(
!
emit
)
panic
(
"no emit handler for node %+F (%+G, graph %+F)"
,
node
,
node
,
get_irn_irg
(
node
));)
emit
(
node
);
}
void
be_emit_asm
(
ir_node
const
*
const
asmn
,
ident
*
const
text
,
unsigned
const
n_operands
,
be_emit_asm_operand_func
*
const
emit_asm_operand
)
{
be_emit_cstring
(
"#APP"
);
be_emit_finish_line_gas
(
asmn
);
char
const
*
s
=
get_id_str
(
text
);
if
(
s
[
0
]
!=
'\t'
)
be_emit_char
(
'\t'
);
char
const
*
last
=
s
;
while
((
s
=
strchr
(
s
,
'%'
)))
{
be_emit_string_len
(
last
,
s
-
last
);
++
s
;
/* Skip '%'. */
switch
(
*
s
)
{
case
'%'
:
case
'{'
:
case
'|'
:
case
'}'
:
be_emit_char
(
*
s
++
);
break
;
default:
{
char
const
modifier
=
isalpha
((
unsigned
char
)
*
s
)
?
*
s
++
:
'\0'
;
unsigned
pos
;
int
p
;
if
(
sscanf
(
s
,
"%u%n"
,
&
pos
,
&
p
)
==
1
)
{
s
+=
p
;
if
(
pos
<
n_operands
)
{
emit_asm_operand
(
asmn
,
modifier
,
pos
);
}
else
{
be_errorf
(
asmn
,
"asm operand number '%u' out of range"
,
pos
);
}
}
else
{
be_errorf
(
asmn
,
"could not parse asm operand number"
);
}
break
;
}
}
last
=
s
;
}
be_emit_string
(
last
);
be_emit_cstring
(
"
\n
#NO_APP
\n
"
);
be_emit_write_line
();
}
ir/be/beemitter.h
View file @
a6da8020
...
...
@@ -125,8 +125,4 @@ void be_emit_nothing(ir_node const *node);
*/
void
be_emit_node
(
ir_node
const
*
node
);
typedef
void
be_emit_asm_operand_func
(
ir_node
const
*
asmn
,
char
modifier
,
unsigned
pos
);
void
be_emit_asm
(
ir_node
const
*
asmn
,
ident
*
text
,
unsigned
n_operands
,
be_emit_asm_operand_func
*
emit_asm_operand
);
#endif
ir/be/ia32/ia32_emitter.c
View file @
a6da8020
...
...
@@ -30,6 +30,7 @@
#include "be_t.h"
#include "bearch_ia32_t.h"
#include "beasm.h"
#include "beblocksched.h"
#include "bediagnostic.h"
#include "begnuas.h"
...
...
ir/be/sparc/sparc_emitter.c
View file @
a6da8020
...
...
@@ -11,6 +11,7 @@
#include <inttypes.h>
#include "bearch_sparc_t.h"
#include "beasm.h"
#include "beblocksched.h"
#include "bediagnostic.h"
#include "begnuas.h"
...
...
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