Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 11th, 2012  |  syntax: None  |  size: 0.61 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. What is the specific GCC flag that turns on immediate value propagation for inline assembly parameters?
  2. #include <stdlib.h>
  3.  
  4. static int i;
  5.  
  6. static inline __attribute__((always_inline)) test(int x)
  7. {
  8.     asm volatile("mov %1, %0" : "=r"(i): "i"(x));
  9. }
  10.  
  11. int main(void)
  12. {
  13.     test(5);
  14.  
  15.     return i;
  16. }
  17.        
  18. gcc -O test.c
  19.        
  20. gcc test.c
  21.        
  22. void foo (void)
  23. {
  24.   int i = 6;
  25.  
  26.   asm volatile ("" : : "i" (i));
  27. }
  28.        
  29. gcc -ftree-ter test.c   # no errors
  30.        
  31. alw.c: In function ‘main’:
  32. alw.c:7:5: warning: asm operand 1 probably doesn’t match constraints [enabled by default]
  33. alw.c:7:5: error: impossible constraint in ‘asm’