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
1002 pr = 2;1002 pr = 2;
1003 break;1003 break;
1004 case 'r':1004 case 'r':
1005 case 'p':
1005 pr = 3;1006 pr = 3;
1006 break;1007 break;
1007 case 'N':1008 case 'N':
@@ -1170,6 +1171,7 @@ ST_FUNC void asm_compute_constraints(ASMOperand *operands, · 162 unmodified lines
1170 }1171 }
1171 goto try_next;1172 goto try_next;
1172 case 'r':1173 case 'r':
1174 case 'p': /* A general address, for x86(64) any register is acceptable*/
1173 /* any general register */1175 /* any general register */
1174 for(reg = 0; reg < 8; reg++) {1176 for(reg = 0; reg < 8; reg++) {
1175 if (!is_reg_allocated(reg))1177 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
991 modifier = 0;991 modifier = 0;
992 if (*str == 'c' || *str == 'n' ||992 if (*str == 'c' || *str == 'n' ||
993 *str == 'b' || *str == 'w' ||993 *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')
995 modifier = *str++;998 modifier = *str++;
996 index = find_constraint(operands, nb_operands, str, &str);999 index = find_constraint(operands, nb_operands, str, &str);
997 if (index < 0)1000 if (index < 0)
tests/tcctest.c+9−0
@@ -2600,6 +2600,14 @@ int fls64(unsigned long long x) · 2599 unmodified lines
2600}2600}
2601#endif2601#endif
2602 2602
2603void 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
2603unsigned int set;2611unsigned int set;
2604 2612
2605void asm_test(void)2613void asm_test(void)
@@ -2633,6 +2641,7 @@ void asm_test(void) · 27 unmodified lines
2633 s1.b = 43;2641 s1.b = 43;
2634 printf("mconstraint: %d", mconstraint_test(&s2));2642 printf("mconstraint: %d", mconstraint_test(&s2));
2635 printf(" %d %d\n", s1.a, s1.b);2643 printf(" %d %d\n", s1.a, s1.b);
2644 other_constraints_test();
2636 set = 0xff;2645 set = 0xff;
2637 sigdelset1(&set, 2);2646 sigdelset1(&set, 2);
2638 sigaddset1(&set, 16);2647 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