Commit d278bd13 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

be: Only accept the '=' and '+' asm constraint modifiers at the beginning and only one of them.

* GCC does this, too.
* This is sensible, because they apply to all alternatives of a multi-alternative constraint.
* This simplifies the implementation and makes some flags obsolete.
parent 228d07f0
......@@ -40,19 +40,15 @@ typedef enum asm_constraint_flags_t {
ASM_CONSTRAINT_FLAG_NO_SUPPORT = 1u << 3,
/** The input is also written to */
ASM_CONSTRAINT_FLAG_MODIFIER_WRITE = 1u << 4,
/** the input is not written to */
ASM_CONSTRAINT_FLAG_MODIFIER_NO_WRITE = 1u << 5,
/** the input is read */
ASM_CONSTRAINT_FLAG_MODIFIER_READ = 1u << 6,
/** the input is not read */
ASM_CONSTRAINT_FLAG_MODIFIER_NO_READ = 1u << 7,
ASM_CONSTRAINT_FLAG_MODIFIER_READ = 1u << 5,
/** the value is modified before all inputs to the asm block
* are handled. */
ASM_CONSTRAINT_FLAG_MODIFIER_EARLYCLOBBER = 1u << 8,
ASM_CONSTRAINT_FLAG_MODIFIER_EARLYCLOBBER = 1u << 6,
/** This operand and the following operand are commutative */
ASM_CONSTRAINT_FLAG_MODIFIER_COMMUTATIVE = 1u << 9,
ASM_CONSTRAINT_FLAG_MODIFIER_COMMUTATIVE = 1u << 7,
/** invalid constraint (due to parse error) */
ASM_CONSTRAINT_FLAG_INVALID = 1u << 10
ASM_CONSTRAINT_FLAG_INVALID = 1u << 8
} asm_constraint_flags_t;
ENUM_BITSET(asm_constraint_flags_t)
......
......@@ -153,17 +153,16 @@ asm_constraint_flags_t be_parse_asm_constraints(const char *constraint)
{
initialize_isa();
asm_constraint_flags_t flags = ASM_CONSTRAINT_FLAG_NONE;
for (const char *c = constraint; *c != '\0'; ++c) {
asm_constraint_flags_t flags;
char const *c = constraint;
switch (*c) {
case '=': ++c; flags = ASM_CONSTRAINT_FLAG_MODIFIER_WRITE; break;
case '+': ++c; flags = ASM_CONSTRAINT_FLAG_MODIFIER_READ | ASM_CONSTRAINT_FLAG_MODIFIER_WRITE; break;
default: flags = ASM_CONSTRAINT_FLAG_MODIFIER_READ; break;
}
for (; *c != '\0'; ++c) {
switch (*c) {
case '=':
flags |= ASM_CONSTRAINT_FLAG_MODIFIER_WRITE;
flags |= ASM_CONSTRAINT_FLAG_MODIFIER_NO_READ;
break;
case '+':
flags |= ASM_CONSTRAINT_FLAG_MODIFIER_READ;
flags |= ASM_CONSTRAINT_FLAG_MODIFIER_WRITE;
break;
case '#':
/* text until comma is a comment */
while (*c != 0 && *c != ',')
......@@ -176,23 +175,6 @@ asm_constraint_flags_t be_parse_asm_constraints(const char *constraint)
}
}
if ((
flags & ASM_CONSTRAINT_FLAG_MODIFIER_WRITE &&
flags & ASM_CONSTRAINT_FLAG_MODIFIER_NO_WRITE
) || (
flags & ASM_CONSTRAINT_FLAG_MODIFIER_READ &&
flags & ASM_CONSTRAINT_FLAG_MODIFIER_NO_READ
)) {
flags |= ASM_CONSTRAINT_FLAG_INVALID;
}
if (!(flags & (ASM_CONSTRAINT_FLAG_MODIFIER_READ |
ASM_CONSTRAINT_FLAG_MODIFIER_WRITE |
ASM_CONSTRAINT_FLAG_MODIFIER_NO_WRITE |
ASM_CONSTRAINT_FLAG_MODIFIER_NO_READ)
)) {
flags |= ASM_CONSTRAINT_FLAG_MODIFIER_READ;
}
return flags;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment