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
a861ef58
Commit
a861ef58
authored
Nov 18, 2014
by
Christoph Mallon
Browse files
be: Simplify initialisation and evaluation of asm constraints.
parent
c893b2e8
Changes
4
Hide whitespace changes
Inline
Side-by-side
ir/be/be_t.h
View file @
a861ef58
...
...
@@ -57,7 +57,7 @@ struct be_main_env_t {
ir_type
*
pic_symbols_type
;
};
extern
asm_constraint_flags_t
asm_constraint_flags
[
256
]
;
void
be_set_constraint_support
(
asm_constraint_flags_t
flags
,
char
const
*
constraints
)
;
void
be_get_allocatable_regs
(
ir_graph
const
*
irg
,
arch_register_class_t
const
*
cls
,
unsigned
*
raw_bitset
);
...
...
ir/be/bemain.c
View file @
a861ef58
...
...
@@ -107,22 +107,27 @@ static const lc_opt_table_entry_t be_main_options[] = {
static
be_module_list_entry_t
*
isa_ifs
=
NULL
;
static
bool
isa_initialized
=
false
;
asm_constraint_flags_t
asm_constraint_flags
[
256
];
static
asm_constraint_flags_t
asm_constraint_flags
[
256
];
void
be_set_constraint_support
(
asm_constraint_flags_t
const
flags
,
char
const
*
const
constraints
)
{
for
(
char
const
*
i
=
constraints
;
*
i
!=
'\0'
;
++
i
)
{
asm_constraint_flags
[(
unsigned
char
)
*
i
]
=
flags
;
}
}
static
void
be_init_default_asm_constraint_flags
(
void
)
{
/* list of constraints supported by gcc for any machine (or at least
for
(
size_t
i
=
0
;
i
!=
ARRAY_SIZE
(
asm_constraint_flags
);
++
i
)
{
asm_constraint_flags
[
i
]
=
ASM_CONSTRAINT_FLAG_INVALID
;
}
/* List of constraints supported by gcc for any machine (or at least
* recognized). Mark them as NO_SUPPORT so we can differentiate them
* from INVALID. Backends should change the flags they support. */
static
const
unsigned
char
gcc_common_flags
[]
=
{
'?'
,
'!'
,
'&'
,
'%'
,
'i'
,
's'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
'K'
,
'L'
,
'M'
,
'N'
,
'O'
,
'P'
,
'm'
,
'o'
,
'r'
,
'V'
,
'<'
,
'>'
,
'p'
,
'g'
,
'X'
,
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
};
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
gcc_common_flags
);
++
i
)
{
unsigned
char
const
c
=
gcc_common_flags
[
i
];
asm_constraint_flags
[
c
]
=
ASM_CONSTRAINT_FLAG_NO_SUPPORT
;
}
char
const
*
const
gcc_common_flags
=
"!%&0123456789<>?EFGHIJKLMNOPVXgimoprs"
;
be_set_constraint_support
(
ASM_CONSTRAINT_FLAG_NO_SUPPORT
,
gcc_common_flags
);
/* Skip whitespace. */
be_set_constraint_support
(
ASM_CONSTRAINT_FLAG_NONE
,
"
\t\n\r
"
);
}
static
void
initialize_isa
(
void
)
...
...
@@ -149,11 +154,6 @@ asm_constraint_flags_t be_parse_asm_constraints(const char *constraint)
asm_constraint_flags_t
flags
=
ASM_CONSTRAINT_FLAG_NONE
;
for
(
const
char
*
c
=
constraint
;
*
c
!=
'\0'
;
++
c
)
{
switch
(
*
c
)
{
case
' '
:
case
'\t'
:
case
'\n'
:
case
'\r'
:
break
;
case
'='
:
flags
|=
ASM_CONSTRAINT_FLAG_MODIFIER_WRITE
;
flags
|=
ASM_CONSTRAINT_FLAG_MODIFIER_NO_READ
;
...
...
@@ -162,11 +162,6 @@ asm_constraint_flags_t be_parse_asm_constraints(const char *constraint)
flags
|=
ASM_CONSTRAINT_FLAG_MODIFIER_READ
;
flags
|=
ASM_CONSTRAINT_FLAG_MODIFIER_WRITE
;
break
;
case
'&'
:
case
'%'
:
/* not really supported by libFirm yet */
flags
|=
ASM_CONSTRAINT_FLAG_NO_SUPPORT
;
break
;
case
'#'
:
/* text until comma is a comment */
while
(
*
c
!=
0
&&
*
c
!=
','
)
...
...
@@ -176,16 +171,11 @@ asm_constraint_flags_t be_parse_asm_constraints(const char *constraint)
/* next character is a comment */
++
c
;
break
;
default:
{
asm_constraint_flags_t
tflags
=
asm_constraint_flags
[(
int
)
*
c
];
if
(
tflags
!=
0
)
{
flags
|=
tflags
;
}
else
{
flags
|=
ASM_CONSTRAINT_FLAG_INVALID
;
}
default:
flags
|=
asm_constraint_flags
[(
unsigned
char
)
*
c
];
break
;
}
}
}
if
((
...
...
ir/be/ia32/bearch_ia32.c
View file @
a861ef58
...
...
@@ -1268,28 +1268,14 @@ extern const arch_isa_if_t ia32_isa_if;
static
void
init_asm_constraints
(
void
)
{
static
const
unsigned
char
register_flags
[]
=
{
'a'
,
'b'
,
'c'
,
'd'
,
'D'
,
'S'
,
'Q'
,
'q'
,
'A'
,
'l'
,
'R'
,
'r'
,
'p'
,
'f'
,
't'
,
'u'
,
'Y'
,
'X'
,
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
};
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
register_flags
);
++
i
)
{
unsigned
char
const
c
=
register_flags
[
i
];
asm_constraint_flags
[
c
]
=
ASM_CONSTRAINT_FLAG_SUPPORTS_REGISTER
;
}
static
const
unsigned
char
immediate_flags
[]
=
{
'i'
,
'n'
,
'I'
,
'J'
,
'K'
,
'L'
,
'M'
,
'N'
,
'O'
};
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
immediate_flags
);
++
i
)
{
unsigned
char
const
c
=
immediate_flags
[
i
];
asm_constraint_flags
[
c
]
=
ASM_CONSTRAINT_FLAG_SUPPORTS_IMMEDIATE
;
}
asm_constraint_flags
[
'g'
]
=
ASM_CONSTRAINT_FLAG_SUPPORTS_IMMEDIATE
|
ASM_CONSTRAINT_FLAG_SUPPORTS_REGISTER
|
ASM_CONSTRAINT_FLAG_SUPPORTS_MEMOP
;
asm_constraint_flags
[
'm'
]
=
ASM_CONSTRAINT_FLAG_SUPPORTS_MEMOP
;
asm_constraint_flags
[
'o'
]
=
ASM_CONSTRAINT_FLAG_SUPPORTS_MEMOP
;
asm_constraint_flags
[
'V'
]
=
ASM_CONSTRAINT_FLAG_SUPPORTS_MEMOP
;
be_set_constraint_support
(
ASM_CONSTRAINT_FLAG_SUPPORTS_REGISTER
,
"0123456789ADQRSXYabcdflpqrtu"
);
be_set_constraint_support
(
ASM_CONSTRAINT_FLAG_SUPPORTS_IMMEDIATE
,
"IJKLMNOin"
);
be_set_constraint_support
(
ASM_CONSTRAINT_FLAG_SUPPORTS_MEMOP
,
"Vmo"
);
asm_constraint_flags_t
const
g
=
ASM_CONSTRAINT_FLAG_SUPPORTS_IMMEDIATE
|
ASM_CONSTRAINT_FLAG_SUPPORTS_MEMOP
|
ASM_CONSTRAINT_FLAG_SUPPORTS_REGISTER
;
be_set_constraint_support
(
g
,
"g"
);
}
/**
...
...
ir/be/sparc/sparc_transform.c
View file @
a861ef58
...
...
@@ -377,17 +377,8 @@ static arch_register_req_t const *make_register_req(ir_graph *const irg,
void
sparc_init_asm_constraints
(
void
)
{
static
unsigned
char
const
register_flags
[]
=
{
'r'
,
'e'
,
'f'
,
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
};
for
(
size_t
i
=
0
;
i
<
ARRAY_SIZE
(
register_flags
);
++
i
)
{
unsigned
char
const
c
=
register_flags
[
i
];
asm_constraint_flags
[
c
]
=
ASM_CONSTRAINT_FLAG_SUPPORTS_REGISTER
;
}
asm_constraint_flags
[
'A'
]
=
ASM_CONSTRAINT_FLAG_SUPPORTS_IMMEDIATE
;
asm_constraint_flags
[
'I'
]
=
ASM_CONSTRAINT_FLAG_SUPPORTS_IMMEDIATE
;
be_set_constraint_support
(
ASM_CONSTRAINT_FLAG_SUPPORTS_REGISTER
,
"0123456789efr"
);
be_set_constraint_support
(
ASM_CONSTRAINT_FLAG_SUPPORTS_IMMEDIATE
,
"AI"
);
/* Note there are many more flags in gcc which we can't properly support
* at the moment. see gcc/config/sparc/constraints.md */
}
...
...
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