Index: osprey/be/cg/x8664/cgtarget.cxx
===================================================================
--- osprey/be/cg/x8664/cgtarget.cxx	(revision 3376)
+++ osprey/be/cg/x8664/cgtarget.cxx	(working copy)
@@ -105,6 +105,7 @@
 #include "calls.h"
 #include "cg_loop.h"
 #include "config_lno.h"  // for LNO_Prefetch_Ahead
+#include "erbe.h"
 
 UINT32 CGTARG_branch_taken_penalty;
 BOOL CGTARG_branch_taken_penalty_overridden = FALSE;
@@ -3111,7 +3112,8 @@
                            const WN* load,
                            TN* pref_tn,
                            ISA_REGISTER_SUBCLASS* subclass, 
-			   TYPE_ID type)
+			   TYPE_ID type,
+                           const WN* asm_wn)
 {
   // skip constraint modifiers:
   // = input and output parameters are separated in the WHIRL for ASM
@@ -3185,17 +3187,21 @@
       // immediate could have been put in preg by wopt
       load = Preg_Is_Rematerializable(WN_load_offset(load), NULL);
     }
-    FmtAssert(load && (WN_operator(load) == OPR_INTCONST ||
+    if (!(load && (WN_operator(load) == OPR_INTCONST ||
                        (WN_operator(load) == OPR_LDA &&
-                        ST_sym_class(WN_st(load)) == CLASS_CONST)),
-              ("Cannot find immediate operand for ASM"));
+                        ST_sym_class(WN_st(load)) == CLASS_CONST)))) {
+      ErrMsgSrcpos(EC_Invalid_Asm_Constrain, WN_Get_Linenum(asm_wn),
+                    ": Cannot find immediate operand for ASM");
+    }
     if (WN_operator(load) == OPR_INTCONST)
     {
       ret_tn = Gen_Literal_TN(WN_const_val(load), 
                               MTYPE_bit_size(WN_rtype(load))/8);
       // Bugs 3177, 3043 - safety check from gnu/config/i386/i386.h.
-      FmtAssert(CONST_OK_FOR_LETTER(WN_const_val(load), *constraint), 
-       ("The value of immediate operand supplied is not within expected range."));
+      if (!CONST_OK_FOR_LETTER(WN_const_val(load), *constraint)) {
+        ErrMsgSrcpos(EC_Invalid_Asm_Constrain, WN_Get_Linenum(asm_wn),
+                ": The value of immediate operand supplied is not within expected range.");
+      }
     }
     else
     {
Index: osprey/be/cg/whirl2ops.cxx
===================================================================
--- osprey/be/cg/whirl2ops.cxx	(revision 3376)
+++ osprey/be/cg/whirl2ops.cxx	(working copy)
@@ -6652,8 +6652,12 @@
     TN* tn = CGTARG_TN_For_Asm_Operand(constraint, load, pref_tn, &subclass);
 #else
     TN* tn = CGTARG_TN_For_Asm_Operand(constraint, load, pref_tn, &subclass, 
-				       default_type);
+				       default_type
+#ifdef TARG_X8664
+                                       ,asm_wn
 #endif
+                                       );
+#endif
 
     ASM_OP_result_constraint(asm_info)[num_results] = constraint;
     ASM_OP_result_subclass(asm_info)[num_results] = subclass;
@@ -6717,8 +6721,12 @@
     TN* tn = CGTARG_TN_For_Asm_Operand(constraint, load, pref_tn, &subclass);
 #else
     TN* tn = CGTARG_TN_For_Asm_Operand(constraint, load, pref_tn, &subclass, 
-				       MTYPE_I4);
+				       MTYPE_I4
+#ifdef TARG_X8664
+                                       ,asm_wn
 #endif
+                                       );
+#endif
 
     ASM_OP_opnd_constraint(asm_info)[num_opnds] = constraint;
     ASM_OP_opnd_subclass(asm_info)[num_opnds] = subclass;
Index: osprey/be/cg/cgtarget.h
===================================================================
--- osprey/be/cg/cgtarget.h	(revision 3376)
+++ osprey/be/cg/cgtarget.h	(working copy)
@@ -811,6 +811,13 @@
                                      const WN* load,
                                      TN* pref_tn,
                                      ISA_REGISTER_SUBCLASS* subclass);
+#elif defined(TARG_X8664)
+extern TN* CGTARG_TN_For_Asm_Operand(const char* constraint, 
+                                     const WN* load,
+                                     TN* pref_tn,
+                                     ISA_REGISTER_SUBCLASS* subclass, 
+				     TYPE_ID type,
+                                     const WN* asm_wn);
 #else
 extern TN* CGTARG_TN_For_Asm_Operand(const char* constraint, 
                                      const WN* load,
Index: osprey/be/com/erbe.h
===================================================================
--- osprey/be/com/erbe.h	(revision 3376)
+++ osprey/be/com/erbe.h	(working copy)
@@ -190,9 +190,11 @@
 #define EC_Ptr_Assumed_Global	 EC_BASE_BE+152
 #define EC_Load_Past_Struct	 EC_BASE_BE+153
 #define EC_Shared_Atomic64_Opnd  EC_BASE_BE+154
-#define EC_Memset_Too_Large EC_BASE_BE+155 /* int */
+#define EC_Memset_Too_Large      EC_BASE_BE+155 /* int */
 #endif /* TARG_NVISA */
 
+#define EC_Invalid_Asm_Constrain EC_BASE_BE+156 /* str */
+
 #ifdef __cplusplus
 }
 #endif
Index: osprey/be/com/erbe.desc
===================================================================
--- osprey/be/com/erbe.desc	(revision 3376)
+++ osprey/be/com/erbe.desc	(working copy)
@@ -339,6 +339,10 @@
     1, ET_INT, 0,0,0,0 },
 #endif /* TARG_NVISA */
 
+  { EC_Invalid_Asm_Constrain, EM_User | ES_ERRABORT, RAG_EN_NONE,
+    "Invalid 'asm' constrain %s",
+    1, ET_STRING, 0,0,0,0 },
+
   /* All error descriptor lists must end with a -1 error code: */
   { -1,	0, RAG_EN_NONE, "", 0, 0,0,0,0,0,0 }
 };
