Hi,

   Could a gatekeeper please help review the fix for bug950?

a sample case:
 void
outb(unsigned short port, unsigned char val)
{
  __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
}

opencc compiles it with:
/tmp/ccspin#.i28qhO.s: Assembler messages:
/tmp/ccspin#.i28qhO.s:36: Error: invalid character '%' in mnemonic
The assembler output:
 #   5    __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
        movl %edx,%edx                  # [1]
        movl %eax,%eax                  # [1]
        out%B0 (%dx)
is undesired, we miss the handling of op suffix format in ASM template.

Suggested patch:

--- a/osprey/be/cg/cgemit.cxx
+++ b/osprey/be/cg/cgemit.cxx
@@ -3637,6 +3637,38 @@ Modify_Asm_String (char* asm_string, UINT32
position, bool memory,
       asm_string =  Replace_Substring(asm_string, x86pattern, suffix);
     }
   }
+
+  // open64.net bug950. Handle any template modifers
+  // %L,%W,%B,%Q,%S,%T. Referrence i386.c(gcc) print_operand.
+  {
+    char L_suffix[5];
+    char W_suffix[5];
+    char B_suffix[5];
+    char Q_suffix[5];
+    char S_suffix[5];
+    char T_suffix[5];
+    sprintf(L_suffix,"%%L%d",position);
+    sprintf(W_suffix,"%%W%d",position);
+    sprintf(B_suffix,"%%B%d",position);
+    sprintf(Q_suffix,"%%Q%d",position);
+    sprintf(S_suffix,"%%S%d",position);
+    sprintf(T_suffix,"%%T%d",position);
+    if (strstr(asm_string, L_suffix) != NULL) {
+      asm_string =  Replace_Substring(asm_string, L_suffix, "l");
+    } else if (strstr(asm_string, W_suffix) != NULL) {
+      asm_string =  Replace_Substring(asm_string, W_suffix, "w");
+    } else if (strstr(asm_string, B_suffix) != NULL) {
+      asm_string =  Replace_Substring(asm_string, B_suffix, "b");
+    } else if (strstr(asm_string, Q_suffix) != NULL) {
+      asm_string =  Replace_Substring(asm_string, Q_suffix, "l");
+    } else if (strstr(asm_string, S_suffix) != NULL) {
+      asm_string =  Replace_Substring(asm_string, S_suffix, "s");
+    } else if (strstr(asm_string, T_suffix) != NULL) {
+      asm_string =  Replace_Substring(asm_string, T_suffix, "t");
+    }
+  }
+
+
 #endif // TARG_X8664

TIA for the review


Regards
Gang
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to