History

inline asm: accept concatenated strings in constraints

This really should be handled implicitly in the preprocessor, but for now this is enough.

Michael Matz committed 10 years ago

Commit bbce3151 parent f9423ff4 files · +8 −7Browse files

Unified · Split

4 files
  1. tcc.h +1 −0
  2. tccasm.c +5 −5
  3. tccgen.c +1 −1
  4. tests/tcctest.c +1 −1
tcc.h+1−0
@@ -1283,6 +1283,7 @@ ST_FUNC int type_size(CType *type, int *a); · 1282 unmodified lines
12831283 ST_FUNC void mk_pointer(CType *type);
12841284 ST_FUNC void vstore(void);
12851285 ST_FUNC void inc(int post, int c);
1286+ST_FUNC void parse_mult_str (CString *astr, const char *msg);
12861287 ST_FUNC void parse_asm_str(CString *astr);
12871288 ST_FUNC int lvalue_type(int t);
12881289 ST_FUNC void indir(void);
tccasm.c+5−5
@@ -1079,6 +1079,7 @@ static void parse_asm_operands(ASMOperand *operands, int *nb_operands_ptr, · 1078 unmodified lines
10791079 if (tok != ':') {
10801080 nb_operands = *nb_operands_ptr;
10811081 for(;;) {
1082+ CString astr;
10821083 if (nb_operands >= MAX_ASM_OPERANDS)
10831084 tcc_error("too many asm operands");
10841085 op = &operands[nb_operands++];
@@ -1091,11 +1092,10 @@ static void parse_asm_operands(ASMOperand *operands, int *nb_operands_ptr, · 6 unmodified lines
10911092 next();
10921093 skip(']');
10931094 }
1094− if (tok != TOK_STR)
1095− expect("string constant");
1096− op->constraint = tcc_malloc(tokc.str.size);
1097− strcpy(op->constraint, tokc.str.data);
1098− next();
1095+ parse_mult_str(&astr, "string constant");
1096+ op->constraint = tcc_malloc(astr.size);
1097+ strcpy(op->constraint, astr.data);
1098+ cstr_free(&astr);
10991099 skip('(');
11001100 gexpr();
11011101 if (is_output) {
tccgen.c+1−1
@@ -2982,7 +2982,7 @@ ST_FUNC void inc(int post, int c) · 2981 unmodified lines
29822982 vpop(); /* if post op, return saved value */
29832983 }
29842984
2985−static void parse_mult_str (CString *astr, const char *msg)
2985+ST_FUNC void parse_mult_str (CString *astr, const char *msg)
29862986 {
29872987 /* read the string */
29882988 if (tok != TOK_STR)
tests/tcctest.c+1−1
@@ -2544,7 +2544,7 @@ static __inline__ __const__ unsigned int swab32(unsigned int x) · 2543 unmodified lines
25442544 __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
25452545 "rorl $16,%0\n\t" /* swap words */
25462546 "xchgb %b0,%h0" /* swap higher bytes */
2547− :"=q" (x)
2547+ :"=" "q" (x)
25482548 : "0" (x));
25492549 return x;
25502550 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t