aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2016-07-11 16:42:18 +0200
committerMichael Matz <matz@suse.de>2016-12-15 17:47:08 +0100
commitbbce31552ec7a9f4ac8a92f31d95d4a4c1be66d0 (patch)
tree2577638dfaa03734355b58946963e929ea06b7be
parentf9423ff3fa5ac2374ed1a36c2d93475539f63f35 (diff)
downloadtinycc-bbce31552ec7a9f4ac8a92f31d95d4a4c1be66d0.tar.gz
tinycc-bbce31552ec7a9f4ac8a92f31d95d4a4c1be66d0.tar.bz2
inline asm: accept concatenated strings in constraints
This really should be handled implicitly in the preprocessor, but for now this is enough.
-rw-r--r--tcc.h1
-rw-r--r--tccasm.c10
-rw-r--r--tccgen.c2
-rw-r--r--tests/tcctest.c2
4 files changed, 8 insertions, 7 deletions
diff --git a/tcc.h b/tcc.h
index f1d577b..470b8dc 100644
--- a/tcc.h
+++ b/tcc.h
@@ -1283,6 +1283,7 @@ ST_FUNC int type_size(CType *type, int *a);
ST_FUNC void mk_pointer(CType *type);
ST_FUNC void vstore(void);
ST_FUNC void inc(int post, int c);
+ST_FUNC void parse_mult_str (CString *astr, const char *msg);
ST_FUNC void parse_asm_str(CString *astr);
ST_FUNC int lvalue_type(int t);
ST_FUNC void indir(void);
diff --git a/tccasm.c b/tccasm.c
index b651f68..eed3cdb 100644
--- a/tccasm.c
+++ b/tccasm.c
@@ -1079,6 +1079,7 @@ static void parse_asm_operands(ASMOperand *operands, int *nb_operands_ptr,
if (tok != ':') {
nb_operands = *nb_operands_ptr;
for(;;) {
+ CString astr;
if (nb_operands >= MAX_ASM_OPERANDS)
tcc_error("too many asm operands");
op = &operands[nb_operands++];
@@ -1091,11 +1092,10 @@ static void parse_asm_operands(ASMOperand *operands, int *nb_operands_ptr,
next();
skip(']');
}
- if (tok != TOK_STR)
- expect("string constant");
- op->constraint = tcc_malloc(tokc.str.size);
- strcpy(op->constraint, tokc.str.data);
- next();
+ parse_mult_str(&astr, "string constant");
+ op->constraint = tcc_malloc(astr.size);
+ strcpy(op->constraint, astr.data);
+ cstr_free(&astr);
skip('(');
gexpr();
if (is_output) {
diff --git a/tccgen.c b/tccgen.c
index c7be9f8..202ed07 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -2982,7 +2982,7 @@ ST_FUNC void inc(int post, int c)
vpop(); /* if post op, return saved value */
}
-static void parse_mult_str (CString *astr, const char *msg)
+ST_FUNC void parse_mult_str (CString *astr, const char *msg)
{
/* read the string */
if (tok != TOK_STR)
diff --git a/tests/tcctest.c b/tests/tcctest.c
index bb6e741..a6878db 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -2544,7 +2544,7 @@ static __inline__ __const__ unsigned int swab32(unsigned int x)
__asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
"rorl $16,%0\n\t" /* swap words */
"xchgb %b0,%h0" /* swap higher bytes */
- :"=q" (x)
+ :"=" "q" (x)
: "0" (x));
return x;
}