Hi,

I generate builtin function directly in the middle end and and expand
the builtin function in the x86 backend to certain set of
instructions.

I've defined x86 builtin functions in the gcc backend like this:

{ OPTION_MASK_ISA_TSTAR | OPTION_MASK_ISA_64BIT,
CODE_FOR_tstar_create, "__builtin_ia32_tcreate", IX86_BUILTIN_TCREATE,
UNKNOWN, (int) PVOID_FTYPE_UINT_UINT },
and corresponding define_insn in .md file.

This works with .c file as a input, and it'll generate the assemble
code I expect.

But if I try to generate the builtin functions directly in GCC middle
end, by using DEF_BUILTIN

  DEF_BUILTIN (BUILTIN_TCREATE, "__builtin_ia32_tcreate", BUILT_IN_MD,
                         BT_FN_PTR_SIZE_SIZE, BT_FN_PTR_SIZE_SIZE,    \
                         false, true, true, ATTRS, false, flags)

It's not working anymore and throw an ICE, I suspect this because the
inconsistent
definition of builtin function in both middle and backend
(at least for DECL_FUNCTION_CODE (fndecl) ).

Do you have any suggestions?

---------------------------- back trace attached
---------------------------------
#0  fancy_abort (file=0xb45b0f "../../gcc/c-decl.c", line=3569,
function=0xb45a10 "c_builtin_function") at ../../gcc/diagnostic.c:892
#1  0x000000000049634f in c_builtin_function (decl=0x7ffff7fb4500) at
../../gcc/c-decl.c:3569
#2  0x000000000065ad86 in add_builtin_function_common (name=<value
optimized out>, type=0x7ffff7edf7e0, function_code=478, cl=<value
optimized out>, library_name=0x0, attrs=0\
x0, hook=0x496290 <c_builtin_function>) at ../../gcc/langhooks.c:562
#3  0x000000000065ae04 in add_builtin_function (name=0xb45b0f
"../../gcc/c-decl.c", type=0xdf1, function_code=11819536, cl=7,
library_name=0x4000 <Address 0x4000 out of bound\
s>, attrs=0x0) at ../../gcc/langhooks.c:576
#4  0x000000000089ed7e in def_builtin () at ../../gcc/config/i386/i386.c:24449
#5  def_builtin_const () at ../../gcc/config/i386/i386.c:24473
#6  ix86_init_mmx_sse_builtins () at ../../gcc/config/i386/i386.c:25613
#7  0x00000000008a0d86 in ix86_init_builtins () at
../../gcc/config/i386/i386.c:25878
#8  0x00000000004e7abf in c_define_builtins () at
../../gcc/c-family/c-common.c:4517
#9  c_common_nodes_and_builtins () at ../../gcc/c-family/c-common.c:4970
#10 0x000000000049b4e3 in c_init_decl_processing () at ../../gcc/c-decl.c:3487
#11 0x00000000004b4ee9 in c_objc_common_init () at ../../gcc/c-objc-common.c:62
#12 0x000000000072608d in lang_dependent_init (argc=4,
argv=0x7fffffffe468) at ../../gcc/toplev.c:1742
#13 do_compile (argc=4, argv=0x7fffffffe468) at ../../gcc/toplev.c:1899
#14 toplev_main (argc=4, argv=0x7fffffffe468) at ../../gcc/toplev.c:1963
#15 0x00007ffff7195c4d in __libc_start_main (main=<value optimized
out>, argc=<value optimized out>, ubp_av=<value optimized out>,
init=<value optimized out>, fini=<value opt\
imized out>, rtld_fini=<value optimized out>,
stack_end=0x7fffffffe458) at libc-start.c:226
#16 0x000000000048e099 in _start ()


Feng

Reply via email to