This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

support tnat instruction on IA-64. error occurs in bundling. help


Hi
I am working on IA-64 and GCC-4.1.1
I modify ia64.md to support tnat instruction. More specifically, I add
the following define_insn:
	
	(define_insn "shift_tnat"
	  [(set (match_operand:BI 0 "register_operand" "=c")
		(unspec:BI [(match_operand:DI 1 "gr_register_operand" "r")]
			   UNSPEC_TNAT))]
	  ""
	  "tnat.nz %0, %I0 = %1"
	  [(set_attr "itanium_class" "tnat")])

add one line in
	define_attr "type" "unknown,A,I,M,F,B,L,X,S"
thus:
	;; chk_s has an I and an M form; use type A for convenience.
	(define_attr "type" "unknown,A,I,M,F,B,L,X,S"
	  (cond [(eq_attr "itanium_class" "ld,st,fld,fldp,stf,sem,nop_m")
(const_string "M")
		 (eq_attr "itanium_class" "rse_m,syst_m,syst_m0") (const_string "M")
		 (eq_attr "itanium_class" "frar_m,toar_m,frfr,tofr") (const_string "M")
		 (eq_attr "itanium_class" "lfetch") (const_string "M")
		 (eq_attr "itanium_class" "chk_s,ialu,icmp,ilog,mmalua") (const_string "A")
		 (eq_attr "itanium_class" "fmisc,fmac,fcmp,xmpy") (const_string "F")
		 (eq_attr "itanium_class" "fcvtfx,nop_f") (const_string "F")
		 (eq_attr "itanium_class" "tnat") (const_string "I")
		~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tnat instruction is emit
on Integer unit.
		 (eq_attr "itanium_class" "frar_i,toar_i,frbr,tobr") (const_string "I")
		 (eq_attr "itanium_class" "frpr,topr,ishf,xtd,tbit") (const_string "I")
		 (eq_attr "itanium_class" "mmmul,mmshf,mmshfi,nop_i") (const_string "I")
		 (eq_attr "itanium_class" "br,scall,nop_b") (const_string "B")
		 (eq_attr "itanium_class" "stop_bit") (const_string "S")
		 (eq_attr "itanium_class" "nop_x") (const_string "X")
		 (eq_attr "itanium_class" "long_i") (const_string "L")]
		(const_string "unknown")))

and one value in attribute "itanium_class"
thus:
	(define_attr "itanium_class" "unknown,ignore,stop_bit,br,fcmp,fcvtfx,fld,
		fldp,fmac,fmisc,frar_i,frar_m,frbr,frfr,frpr,ialu,icmp,ilog,ishf,
		ld,chk_s,tnat,long_i,mmalua,mmmul,mmshf,mmshfi,rse_m,scall,sem,stf,
		                ~~~~
	        st,syst_m0, syst_m,tbit,toar_i,toar_m,tobr,tofr,topr,xmpy,xtd,nop,
	        nop_b,nop_f,nop_i,nop_m,nop_x,lfetch,pre_cycle"
	  (const_string "unknown"))
	
I also modify ia64.c to support UNSPEC_TNAT, in function rtx_needs_barrier.
	case UNSPEC_FR_SPILL:
	case UNSPEC_FR_RESTORE:
	case UNSPEC_GETF_EXP:
	case UNSPEC_SETF_EXP:
            case UNSPEC_ADDP4:
            case UNSPEC_FR_SQRT_RECIP_APPROX:
             case UNSPEC_TNAT:           /* support tnat instruction */
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            if(XINT(x, 1) == UNSPEC_TNAT)
           {
               print_rtl_single (stderr, x);
               fflush(stderr);
           }

	  need_barrier = rtx_needs_barrier (XVECEXP (x, 0, 0), flags, pred);
	  break;
However, when I use the new GCC to compile the following function
	
	long      ga[20] = {0, };
	int        gb[20] = {0, };
	char     gc[20] = {0, };
	short    gd[20] = {0, };
	
	void test_leaf_function()
	{
	  fprintf(stderr, "in function test_leaf_function\n");
	
	  if(ga[0] != 0)
	  {
	    ga[0] = 20;
	    ga[0] = gd[1];
	  }
	
	  ga[0] = 100;
	  ga[0] = 0;
	
	  if (gb[0] != 5)
	    ga[0] = gb[0];
	  else
	    ga[0] = gb[1];
	
	  ga[3] = ga[2]+gc[1];
	
	  gc[0] = 0;
	  gd[0] = 0;
	}
	

it reports the error:
	error insn:
	(insn 163 185 312 0 giftlib_test.c:90 (set (reg:BI 263 p7)
	        (unspec:BI [
	                (reg/f:DI 14 r14 [376])
	            ] 32)) 300 {shift_tnat} (insn_list:REG_DEP_ANTI 187
(insn_list:REG_DEP_ANTI 178 (insn_list:REG_DEP_ANTI 179
(insn_list:REG_DEP_ANTI 181 (insn_list:REG_DEP_ANTI 186
(insn_list:REG_DEP_OUTPUT 176 (insn_list:REG_DEP_TRUE 77 (nil))))))))
	    (nil))
	giftlib_test.c: In function  "foo"
	giftlib_test.c:99: internal compiler error: in bundling, at
config/ia64/ia64.c:7457
	Please submit a full bug report,
	with preprocessed source if appropriate.
	See <URL:http://gcc.gnu.org/bugs.html> for instructions.
	
I follow the error at ia64.c: 7457,  a assertion fails
	/* Move the position backward in the window.  Group barrier has
		 no slot.  Asm insn takes all bundle.  */
	      if (INSN_CODE (insn) != CODE_FOR_insn_group_barrier
		  && GET_CODE (PATTERN (insn)) != ASM_INPUT
		  && asm_noperands (PATTERN (insn)) < 0)
		pos--;
	      /* Long insn takes 2 slots.  */
	      if (ia64_safe_type (insn) == TYPE_L)
		pos--;
	
	      if(pos < 0)
	      {
	        fprintf(stderr, "error insn:\n");
	        print_rtl_single (stderr, insn);
	      }
	
	      gcc_assert (pos >= 0);
	    ~~~~~~~~~~~~~~~~~~~~~~~~
	
I have no idea about this error. Is there any thing I miss to support
the tnat instruction ?


Any help is truly appreciated.

Thanks


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]