History

inline asm: Accept 'p' constraint and 'P' template mod

'p' is conservatively the same as 'r' and 'P' as template modifier can be ignored in TCC.

Michael Matz committed 10 years ago

Commit 253afee1 parent 63e3ff73 files · +15 −1Browse files

Unified · Split

3 files
  1. i386-asm.c +2 −0
  2. tccasm.c +4 −1
  3. tests/tcctest.c +9 −0
i386-asm.c+2−0
@@ -1002,6 +1002,7 @@ static inline int constraint_priority(const char *str) · 1001 unmodified lines
10021002 pr = 2;
10031003 break;
10041004 case 'r':
1005+ case 'p':
10051006 pr = 3;
10061007 break;
10071008 case 'N':
@@ -1170,6 +1171,7 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands, · 162 unmodified lines
11701171 }
11711172 goto try_next;
11721173 case 'r':
1174+ case 'p': /* A general address, for x86(64) any register is acceptable*/
11731175 /* any general register */
11741176 for(reg = 0; reg < 8; reg++) {
11751177 if (!is_reg_allocated(reg))
tccasm.c+4−1
@@ -991,7 +991,10 @@ static void subst_asm_operands(ASMOperand *operands, int nb_operands, · 990 unmodified lines
991991 modifier = 0;
992992 if (*str == 'c' || *str == 'n' ||
993993 *str == 'b' || *str == 'w' ||
994− *str == 'h' || *str == 'k' || *str == 'q')
994+ *str == 'h' || *str == 'k' || *str == 'q' ||
995+ /* P in GCC would add "@PLT" to symbol refs in PIC mode
996+ Ignore this in TCC. */
997+ *str == 'P')
995998 modifier = *str++;
996999 index = find_constraint(operands, nb_operands, str, &str);
9971000 if (index < 0)
tests/tcctest.c+9−0
@@ -2600,6 +2600,14 @@ int fls64(unsigned long long x) · 2599 unmodified lines
26002600 }
26012601 #endif
26022602
2603+void other_constraints_test(void)
2604+{
2605+ unsigned long ret;
2606+ int var;
2607+ __asm__ volatile ("movq %P1,%0" : "=r" (ret) : "p" (&var));
2608+ printf ("oc1: %d\n", ret == (unsigned long)&var);
2609+}
2610+
26032611 unsigned int set;
26042612
26052613 void asm_test(void)
@@ -2633,6 +2641,7 @@ void asm_test(void) · 27 unmodified lines
26332641 s1.b = 43;
26342642 printf("mconstraint: %d", mconstraint_test(&s2));
26352643 printf(" %d %d\n", s1.a, s1.b);
2644+ other_constraints_test();
26362645 set = 0xff;
26372646 sigdelset1(&set, 2);
26382647 sigaddset1(&set, 16);

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