forked from Mirrors/tinycc
inline asm: accept concatenated strings in constraints
This really should be handled implicitly in the preprocessor, but for now this is enough.master
parent
f9423ff3fa
commit
bbce31552e
1
tcc.h
1
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 mk_pointer(CType *type);
|
||||||
ST_FUNC void vstore(void);
|
ST_FUNC void vstore(void);
|
||||||
ST_FUNC void inc(int post, int c);
|
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 void parse_asm_str(CString *astr);
|
||||||
ST_FUNC int lvalue_type(int t);
|
ST_FUNC int lvalue_type(int t);
|
||||||
ST_FUNC void indir(void);
|
ST_FUNC void indir(void);
|
||||||
|
|
10
tccasm.c
10
tccasm.c
|
@ -1079,6 +1079,7 @@ static void parse_asm_operands(ASMOperand *operands, int *nb_operands_ptr,
|
||||||
if (tok != ':') {
|
if (tok != ':') {
|
||||||
nb_operands = *nb_operands_ptr;
|
nb_operands = *nb_operands_ptr;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
CString astr;
|
||||||
if (nb_operands >= MAX_ASM_OPERANDS)
|
if (nb_operands >= MAX_ASM_OPERANDS)
|
||||||
tcc_error("too many asm operands");
|
tcc_error("too many asm operands");
|
||||||
op = &operands[nb_operands++];
|
op = &operands[nb_operands++];
|
||||||
|
@ -1091,11 +1092,10 @@ static void parse_asm_operands(ASMOperand *operands, int *nb_operands_ptr,
|
||||||
next();
|
next();
|
||||||
skip(']');
|
skip(']');
|
||||||
}
|
}
|
||||||
if (tok != TOK_STR)
|
parse_mult_str(&astr, "string constant");
|
||||||
expect("string constant");
|
op->constraint = tcc_malloc(astr.size);
|
||||||
op->constraint = tcc_malloc(tokc.str.size);
|
strcpy(op->constraint, astr.data);
|
||||||
strcpy(op->constraint, tokc.str.data);
|
cstr_free(&astr);
|
||||||
next();
|
|
||||||
skip('(');
|
skip('(');
|
||||||
gexpr();
|
gexpr();
|
||||||
if (is_output) {
|
if (is_output) {
|
||||||
|
|
2
tccgen.c
2
tccgen.c
|
@ -2982,7 +2982,7 @@ ST_FUNC void inc(int post, int c)
|
||||||
vpop(); /* if post op, return saved value */
|
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 */
|
/* read the string */
|
||||||
if (tok != TOK_STR)
|
if (tok != TOK_STR)
|
||||||
|
|
|
@ -2544,7 +2544,7 @@ static __inline__ __const__ unsigned int swab32(unsigned int x)
|
||||||
__asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
|
__asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
|
||||||
"rorl $16,%0\n\t" /* swap words */
|
"rorl $16,%0\n\t" /* swap words */
|
||||||
"xchgb %b0,%h0" /* swap higher bytes */
|
"xchgb %b0,%h0" /* swap higher bytes */
|
||||||
:"=q" (x)
|
:"=" "q" (x)
|
||||||
: "0" (x));
|
: "0" (x));
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue