2009-01-03 08:47:43 Where can I find the implement of Blackfin GCC Built-in Functions
haiping zeng (CHINA)
Message: 67318
Hi.
as show in the title of this thread:
Where can I find the implement of Blackfin GCC Built-in Functions.
as follow:
__builtin_bfin_mult_fr1x32
__builtin_bfin_add_fr1x32
__builtin_bfin_add_fr1x16
-------------------------------------------------------------------------------------------
Word16 round(Word32 L_var1)
{
Word16 var_out;
Word32 L_arrondi;
L_arrondi = L_add(L_var1, (Word32)0x00008000L);
var_out = extract_h(L_arrondi);
return(var_out);
}
-------------------------------------------------------------------------------------------
Becuase i want to study how to code the Blackfin GCC Built-in Function and add the round function to become the Blackfin GCC Built-in Function.could someone give me some helps?thanks.
QuoteReplyEditDelete
2009-01-03 08:59:48 Re: Where can I find the implement of Blackfin GCC Built-in Functions
Mike Frysinger (UNITED STATES)
Message: 67319
all of the builtins come from gcc itself, so look in the gcc source directory. gcc-*/gcc/config/bfin/ ...
QuoteReplyEditDelete
2009-01-13 03:56:53 Re: Where can I find the implement of Blackfin GCC Built-in Functions
haiping zeng (CHINA)
Message: 67843
Hi
i want to find the implement of Blackfin GCC Built-in Functions from the Index of /trunk/gcc-4.1/gcc/config/bfin/...(links as :http://blackfin.uclinux.org/gf/project/toolchain/scmsvn/?action=browse&path=%2Ftrunk%2Fgcc-4.1%2Fgcc%2Fconfig%2Fbfin%2F),but i cannt find some codes about that implement.
QuoteReplyEditDelete
2009-01-13 06:18:29 Re: Where can I find the implement of Blackfin GCC Built-in Functions
Mike Frysinger (UNITED STATES)
Message: 67862
you'll need to be specific as to what function exactly you're looking for ... all the Blackfin specific builtins are in there
QuoteReplyEditDelete
2009-01-13 07:09:06 Re: Where can I find the implement of Blackfin GCC Built-in Functions
haiping zeng (CHINA)
Message: 67869
such as :__builtin_bfin_mult_fr1x32();
in bfin.c file ,what we can find is only like this :
def_builtin ("__builtin_bfin_mult_fr1x32", int_ftype_short_short,
BFIN_BUILTIN_MULT_1X32);
def_builtin ("__builtin_bfin_mult_fr1x32x32", int_ftype_int_int,
BFIN_BUILTIN_MULT_1X32X32);
def_builtin ("__builtin_bfin_mult_fr1x32x32NS", int_ftype_int_int,
BFIN_BUILTIN_MULT_1X32X32NS);
{ CODE_FOR_flag_mulhisi, "__builtin_bfin_mult_fr1x32", BFIN_BUILTIN_MULT_1X32, MACFLAG_NONE }
but i can not find the implement of this function? Could you tell me which files i can find that?
QuoteReplyEditDelete
2009-01-13 07:26:36 Re: Where can I find the implement of Blackfin GCC Built-in Functions
Mike Frysinger (UNITED STATES)
Message: 67870
that's because it isnt an external symbol. it expands into assembly. the bfin.c file contains that information as well (look for the associated constant BFIN_BUILTIN_MULT_1X32).
QuoteReplyEditDelete
2009-01-13 08:31:25 Re: Where can I find the implement of Blackfin GCC Built-in Functions
haiping zeng (CHINA)
Message: 67876
Hi ,Mike ,
yes ,i find the symbol BFIN_BUILTIN_MULT_1X32 in a emum{...};
enum bfin_builtins
3859: {
3860: BFIN_BUILTIN_CSYNC,
3861: BFIN_BUILTIN_SSYNC,
3862: BFIN_BUILTIN_COMPOSE_2X16,
3863: BFIN_BUILTIN_EXTRACTLO,
3864: BFIN_BUILTIN_EXTRACTHI,
3865:
3866: BFIN_BUILTIN_SSADD_2X16,
3867: BFIN_BUILTIN_SSSUB_2X16,
3868: BFIN_BUILTIN_SSADDSUB_2X16,
3869: BFIN_BUILTIN_SSSUBADD_2X16,
3870: BFIN_BUILTIN_MULT_2X16,
3871: BFIN_BUILTIN_MULTR_2X16,
3872: BFIN_BUILTIN_NEG_2X16,
3873: BFIN_BUILTIN_ABS_2X16,
3874: BFIN_BUILTIN_MIN_2X16,
3875: BFIN_BUILTIN_MAX_2X16,
3876:
3877: BFIN_BUILTIN_SSADD_1X16,
3878: BFIN_BUILTIN_SSSUB_1X16,
3879: BFIN_BUILTIN_MULT_1X16,
3880: BFIN_BUILTIN_MULTR_1X16,
3881: BFIN_BUILTIN_NORM_1X16,
3882: BFIN_BUILTIN_NEG_1X16,
3883: BFIN_BUILTIN_ABS_1X16,
3884: BFIN_BUILTIN_MIN_1X16,
3885: BFIN_BUILTIN_MAX_1X16,
3886:
3887: BFIN_BUILTIN_DIFFHL_2X16,
3888: BFIN_BUILTIN_DIFFLH_2X16,
3889:
3890: BFIN_BUILTIN_SSADD_1X32,
3891: BFIN_BUILTIN_SSSUB_1X32,
3892: BFIN_BUILTIN_NORM_1X32,
3893: BFIN_BUILTIN_NEG_1X32,
3894: BFIN_BUILTIN_MIN_1X32,
3895: BFIN_BUILTIN_MAX_1X32,
3896: BFIN_BUILTIN_MULT_1X32,
3897:
3898: BFIN_BUILTIN_MULHISILL,
3899: BFIN_BUILTIN_MULHISILH,
3900: BFIN_BUILTIN_MULHISIHL,
3901: BFIN_BUILTIN_MULHISIHH,
3902:
3903: BFIN_BUILTIN_LSHIFT_1X16,
3904: BFIN_BUILTIN_LSHIFT_2X16,
3905: BFIN_BUILTIN_SSASHIFT_1X16,
3906: BFIN_BUILTIN_SSASHIFT_2X16,
3907:
3908: BFIN_BUILTIN_CPLX_MUL_16,
3909: BFIN_BUILTIN_CPLX_MAC_16,
3910: BFIN_BUILTIN_CPLX_MSU_16,
3911:
3912: BFIN_BUILTIN_MAX
3913: };
do you mean that the symbol "BFIN_BUILTIN_MULT_1X32" tell the gcc to expand this function( __builtin_bfin_mult_fr1x32()) into assembly code by some optimizations,but in fact ,this is no the implement of this function is gcc codes ?
QuoteReplyEditDelete
2009-01-14 05:49:22 Re: Where can I find the implement of Blackfin GCC Built-in Functions
haiping zeng (CHINA)
Message: 67931
Hi,there is no body know it?
it don't matter, Any advices is welcome.
QuoteReplyEditDelete
2009-01-14 06:07:44 Re: Where can I find the implement of Blackfin GCC Built-in Functions
Mike Frysinger (UNITED STATES)
Message: 67935
what exactly is your question ? you wanted to know where the builtin came from and you were told where it can be found.
QuoteReplyEditDelete
2009-01-14 07:28:52 Re: Where can I find the implement of Blackfin GCC Built-in Functions
haiping zeng (CHINA)
Message: 67941
oh,sorry!
i don't express my question exactly,
what i mean is that i wanted to know where the builtin came from!
QuoteReplyEditDelete
2009-01-14 11:44:24 Re: Where can I find the implement of Blackfin GCC Built-in Functions
Mike Frysinger (UNITED STATES)
Message: 67943
and you were told where it came from, so is that the only question you had ?
QuoteReplyEditDelete
2009-01-14 21:40:13 Re: Where can I find the implement of Blackfin GCC Built-in Functions
haiping zeng (CHINA)
Message: 67952
oh,yes !
where it come from?
For example,i want to find it like this:
__builtin_bfin_add_fr1x32 {
...some codes....
}
or somethings like!
QuoteReplyEditDelete
2009-01-14 21:53:43 Re: Where can I find the implement of Blackfin GCC Built-in Functions
haiping zeng (CHINA)
Message: 67953
another example:
23 #define __builtin_bfin_max(a,b) ((a)>=(b)?(a):(b))
24 #define __builtin_bfin_min(a,b) ((a)<=(b)?(a):(b))
25 #define __builtin_bfin_lmax(a,b) ((a)>=(b)?(a):(b))
26 #define __builtin_bfin_lmin(a,b) ((a)<=(b)?(a):(b))
27 #define __builtin_bfin_max_fr1x32(a,b) ((a)>=(b)?(a):(b))
28 #define __builtin_bfin_min_fr1x32(a,b) ((a)<=(b)?(a):(b))
QuoteReplyEditDelete
2009-01-14 22:36:30 Re: Where can I find the implement of Blackfin GCC Built-in Functions
Robin Getz (UNITED STATES)
Message: 67954
Haiping:
It is all in the souce code for gcc. If you don't know how to read it - or don't understand what it is doing - or how it works - that is a different question that "where is it" - Mike already answered that with " look in the gcc source directory. gcc-*/gcc/config/bfin/ ..."
grep and a little bit sleuthing can go much faster than asking the same question for 2 weeks.
-Robin
QuoteReplyEditDelete
2009-01-15 03:50:35 Re: Where can I find the implement of Blackfin GCC Built-in Functions
haiping zeng (CHINA)
Message: 67961
Robin:
Thank
Maybe you are right!i shoud not ask this question so many times and should creat a new thread for another
question !but i have found in gcc-*/gcc/config/bfin/ ...,and i cant find what i need.such as :
__builtin_bfin_add_fr1x32,why i want to find it ?
because i want to know how it works. Maybe this is another question!
QuoteReplyEditDelete
2009-01-15 07:54:30 Re: Where can I find the implement of Blackfin GCC Built-in Functions
Robin Getz (UNITED STATES)
Message: 67982
Haiping:
Everything you need is between the toolchain source, and grep.
A trivial example: - find out where the built-in csync comes from:
rgetz@imhotep:~/blackfin/trunk/toolchain/gcc-4.3/gcc/config/bfin> grep builtin_bfin_csync *
bfin.c: def_builtin ("__builtin_bfin_csync", void_ftype_void, BFIN_BUILTIN_CSYNC);
rgetz@imhotep:~/blackfin/trunk/toolchain/gcc-4.3/gcc/config/bfin> grep BFIN_BUILTIN_CSYNC *
bfin.c: BFIN_BUILTIN_CSYNC,
bfin.c: def_builtin ("__builtin_bfin_csync", void_ftype_void, BFIN_BUILTIN_CSYNC);
bfin.c: case BFIN_BUILTIN_CSYNC:
bfin_expand_builtin (tree exp, rtx target ATTRIBUTE_UNUSED,
rtx subtarget ATTRIBUTE_UNUSED,
enum machine_mode mode ATTRIBUTE_UNUSED,
int ignore ATTRIBUTE_UNUSED)
{
switch (fcode)
{
case BFIN_BUILTIN_CSYNC:
emit_insn (gen_csync ());
And there you go -
It is a similar for all.
For many built-ins -- the build in is not written in Blackfin assembly, but in RLT (so the compiler can do a better job in the optimizations.) for example:
case BFIN_BUILTIN_DIFFHL_2X16:
case BFIN_BUILTIN_DIFFLH_2X16:
case BFIN_BUILTIN_SUM_2X16:
arg0 = CALL_EXPR_ARG (exp, 0);
op0 = expand_expr (arg0, NULL_RTX, VOIDmode, 0);
icode = (fcode == BFIN_BUILTIN_DIFFHL_2X16 ? CODE_FOR_subhilov2hi3
: fcode == BFIN_BUILTIN_DIFFLH_2X16 ? CODE_FOR_sublohiv2hi3
: CODE_FOR_ssaddhilov2hi3);
tmode = insn_data[icode].operand[0].mode;
mode0 = insn_data[icode].operand[1].mode;
if (! target
|| GET_MODE (target) != tmode
|| ! (*insn_data[icode].operand[0].predicate) (target, tmode))
target = gen_reg_rtx (tmode);
if (VECTOR_MODE_P (mode0))
op0 = safe_vector_operand (op0, mode0);
if (! (*insn_data[icode].operand[1].predicate) (op0, mode0))
op0 = copy_to_mode_reg (mode0, op0);
pat = GEN_FCN (icode) (target, op0, op0);
if (! pat)
return 0;
emit_insn (pat);
return target;
If you need help figuring that out - then it is time to buy a book on gcc.
-Robin
QuoteReplyEditDelete
2009-01-15 19:53:00 Re: Where can I find the implement of Blackfin GCC Built-in Functions
haiping zeng (CHINA)
Message: 68003
Robin
Thanks a lots!
I got it.
"For many built-ins -- the build in is not written in Blackfin assembly, but in RLT (so the compiler can do a better job in the optimizations.)"--this is the answer i need!
becuace i think that the build in was written in Blackfin assembly at first,so i find anywhere and can not find anything!