aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/rs6000/rs6000.c
diff options
context:
space:
mode:
authorDavid Edelsohn <dje@gcc.gnu.org>2012-09-19 15:05:34 -0400
committerDavid Edelsohn <dje@gcc.gnu.org>2012-09-19 15:05:34 -0400
commit0efbf084f42a63c393962eb2207c826eb91c5029 (patch)
treee66e46b6098e9cdaedd3c575165b2ad9b99dc209 /gcc/config/rs6000/rs6000.c
parent4eddc42b63d1064dfb0fd4c4820616f672e0ccfa (diff)
downloadgcc-0efbf084f42a63c393962eb2207c826eb91c5029.zip
gcc-0efbf084f42a63c393962eb2207c826eb91c5029.tar.gz
gcc-0efbf084f42a63c393962eb2207c826eb91c5029.tar.bz2
[multiple changes]
2012-09-19 Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com> * config/rs6000/rs6000-builtin.def: Add __builtin_ppc_get_timebase and __builtin_ppc_mftb. * config/rs6000/rs6000.c (rs6000_expand_zeroop_builtin): New function to expand an expression that calls a built-in without arguments. (rs6000_expand_builtin): Add __builtin_ppc_get_timebase and __builtin_ppc_mftb. (rs6000_init_builtins): Likewise. * config/rs6000/rs6000.md (rs6000_get_timebase): New pattern. (rs6000_get_timebase_ppc32): New pattern. (rs6000_mftb_<mode>): New pattern. * doc/extend.texi (PowerPC Built-in Functions): New section. (PowerPC AltiVec/VSX Built-in Functions): Move some built-ins unrelated to Altivec/VSX to the new section. 2012-09-19 David Edelsohn <dje.gcc@gmail.com> * rs6000.md (mac*): Remove extra spaces. (mulhw*): Same. From-SVN: r191491
Diffstat (limited to 'gcc/config/rs6000/rs6000.c')
-rw-r--r--gcc/config/rs6000/rs6000.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index a880e5e..007473b 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -9748,6 +9748,30 @@ rs6000_overloaded_builtin_p (enum rs6000_builtins fncode)
return (rs6000_builtin_info[(int)fncode].attr & RS6000_BTC_OVERLOADED) != 0;
}
+/* Expand an expression EXP that calls a builtin without arguments. */
+static rtx
+rs6000_expand_zeroop_builtin (enum insn_code icode, rtx target)
+{
+ rtx pat;
+ enum machine_mode tmode = insn_data[icode].operand[0].mode;
+
+ if (icode == CODE_FOR_nothing)
+ /* Builtin not supported on this processor. */
+ return 0;
+
+ if (target == 0
+ || GET_MODE (target) != tmode
+ || ! (*insn_data[icode].operand[0].predicate) (target, tmode))
+ target = gen_reg_rtx (tmode);
+
+ pat = GEN_FCN (icode) (target);
+ if (! pat)
+ return 0;
+ emit_insn (pat);
+
+ return target;
+}
+
static rtx
rs6000_expand_unop_builtin (enum insn_code icode, tree exp, rtx target)
@@ -11337,6 +11361,16 @@ rs6000_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED,
? CODE_FOR_bpermd_di
: CODE_FOR_bpermd_si), exp, target);
+ case RS6000_BUILTIN_GET_TB:
+ return rs6000_expand_zeroop_builtin (CODE_FOR_rs6000_get_timebase,
+ target);
+
+ case RS6000_BUILTIN_MFTB:
+ return rs6000_expand_zeroop_builtin (((TARGET_64BIT)
+ ? CODE_FOR_rs6000_mftb_di
+ : CODE_FOR_rs6000_mftb_si),
+ target);
+
case ALTIVEC_BUILTIN_MASK_FOR_LOAD:
case ALTIVEC_BUILTIN_MASK_FOR_STORE:
{
@@ -11621,6 +11655,18 @@ rs6000_init_builtins (void)
POWER7_BUILTIN_BPERMD, "__builtin_bpermd");
def_builtin ("__builtin_bpermd", ftype, POWER7_BUILTIN_BPERMD);
+ ftype = build_function_type_list (unsigned_intDI_type_node,
+ NULL_TREE);
+ def_builtin ("__builtin_ppc_get_timebase", ftype, RS6000_BUILTIN_GET_TB);
+
+ if (TARGET_64BIT)
+ ftype = build_function_type_list (unsigned_intDI_type_node,
+ NULL_TREE);
+ else
+ ftype = build_function_type_list (unsigned_intSI_type_node,
+ NULL_TREE);
+ def_builtin ("__builtin_ppc_mftb", ftype, RS6000_BUILTIN_MFTB);
+
#if TARGET_XCOFF
/* AIX libm provides clog as __clog. */
if ((tdecl = builtin_decl_explicit (BUILT_IN_CLOG)) != NULL_TREE)