From: Henry Linjamäki Date: Thu, 28 Sep 2017 15:29:07 +0000 (+0000) Subject: [BRIGFE] Changed pure attributes to const for the brig-builtins X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f276c46cd81d7a0008c696ddb75638dc6aa25f92;p=gcc.git [BRIGFE] Changed pure attributes to const for the brig-builtins that are actually const. Also: * Fixed brig-lang.c such that the builtin attributes actually have effect... * Made -O3 the default optimization level for BRIG. From-SVN: r253254 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 42cb556407f..21feae7cfd0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2017-09-28 Henry Linjamäki + + * brig-builtins.def: Change pure attributes to const. + 2017-09-28 Joseph Myers * config.gcc (default_gnu_indirect_function): Default to yes for diff --git a/gcc/brig-builtins.def b/gcc/brig-builtins.def index 39f403e0623..c2d84225f40 100644 --- a/gcc/brig-builtins.def +++ b/gcc/brig-builtins.def @@ -107,136 +107,136 @@ DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_GRIDGROUPS, BRIG_OPCODE_GRIDGROUPS, DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BITEXTRACT_S32, BRIG_OPCODE_BITEXTRACT, BRIG_TYPE_S32, "__hsail_bitextract_s32", - BT_FN_INT_INT_UINT_UINT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT_INT_UINT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BITEXTRACT_U32, BRIG_OPCODE_BITEXTRACT, BRIG_TYPE_U32, "__hsail_bitextract_u32", - BT_FN_UINT_UINT_UINT_UINT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT_UINT_UINT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BITEXTRACT_S64, BRIG_OPCODE_BITEXTRACT, BRIG_TYPE_S64, "__hsail_bitextract_s64", - BT_FN_LONG_LONG_UINT_UINT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_LONG_LONG_UINT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BITEXTRACT_U64, BRIG_OPCODE_BITEXTRACT, BRIG_TYPE_U64, "__hsail_bitextract_u64", - BT_FN_ULONG_ULONG_UINT_UINT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_ULONG_ULONG_UINT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BITINSERT_U32, BRIG_OPCODE_BITINSERT, BRIG_TYPE_U32, "__hsail_bitinsert_u32", - BT_FN_UINT_UINT_UINT_UINT_UINT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT_UINT_UINT_UINT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BITINSERT_U64, BRIG_OPCODE_BITINSERT, BRIG_TYPE_U64, "__hsail_bitinsert_u64", BT_FN_ULONG_ULONG_ULONG_UINT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BITMASK_B32, BRIG_OPCODE_BITMASK, BRIG_TYPE_B32, "__hsail_bitmask_u32", BT_FN_UINT_UINT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BITMASK_B64, BRIG_OPCODE_BITMASK, BRIG_TYPE_B64, "__hsail_bitmask_u64", BT_FN_ULONG_UINT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BITREV_B32, BRIG_OPCODE_BITREV, BRIG_TYPE_B32, "__hsail_bitrev_u32", BT_FN_UINT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BITREV_B64, BRIG_OPCODE_BITREV, BRIG_TYPE_B64, "__hsail_bitrev_u64", BT_FN_ULONG_ULONG, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BITSELECT_B32, BRIG_OPCODE_BITSELECT, BRIG_TYPE_B32, "__hsail_bitselect_u32", - BT_FN_UINT_UINT_UINT_UINT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT_UINT_UINT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BITSELECT_U64, BRIG_OPCODE_BITSELECT, BRIG_TYPE_B64, "__hsail_bitselect_u64", - BT_FN_ULONG_ULONG_ULONG_ULONG, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_ULONG_ULONG_ULONG_ULONG, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_FIRSTBIT_U32, BRIG_OPCODE_FIRSTBIT, BRIG_TYPE_U32, "__hsail_firstbit_u32", BT_FN_UINT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_FIRSTBIT_S32, BRIG_OPCODE_FIRSTBIT, BRIG_TYPE_S32, "__hsail_firstbit_s32", BT_FN_UINT_INT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_FIRSTBIT_U64, BRIG_OPCODE_FIRSTBIT, BRIG_TYPE_U64, "__hsail_firstbit_u64", BT_FN_UINT_ULONG, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_FIRSTBIT_S64, BRIG_OPCODE_FIRSTBIT, BRIG_TYPE_S64, "__hsail_firstbit_s64", BT_FN_UINT_LONG, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_LASTBIT_U32, BRIG_OPCODE_LASTBIT, BRIG_TYPE_U32, "__hsail_lastbit_u32", BT_FN_UINT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_LASTBIT_U64, BRIG_OPCODE_LASTBIT, BRIG_TYPE_U64, "__hsail_lastbit_u64", BT_FN_UINT_ULONG, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BORROW_U32, BRIG_OPCODE_BORROW, BRIG_TYPE_U32, "__hsail_borrow_u32", BT_FN_UINT_UINT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BORROW_U64, BRIG_OPCODE_BORROW, BRIG_TYPE_U64, "__hsail_borrow_u64", BT_FN_ULONG_ULONG_ULONG, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_CARRY_U32, BRIG_OPCODE_CARRY, BRIG_TYPE_U32, "__hsail_carry_u32", BT_FN_UINT_UINT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_CARRY_U64, BRIG_OPCODE_CARRY, BRIG_TYPE_U64, "__hsail_carry_u64", BT_FN_ULONG_ULONG_ULONG, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_REM_S32, BRIG_OPCODE_REM, BRIG_TYPE_S32, "__hsail_rem_s32", BT_FN_INT_INT_INT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_REM_S64, BRIG_OPCODE_REM, BRIG_TYPE_S64, "__hsail_rem_s64", BT_FN_LONG_LONG_LONG, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_MIN_F32, BRIG_OPCODE_MIN, BRIG_TYPE_F32, "__hsail_min_f32", BT_FN_FLOAT_FLOAT_FLOAT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_MAX_F32, BRIG_OPCODE_MAX, BRIG_TYPE_F32, "__hsail_max_f32", BT_FN_FLOAT_FLOAT_FLOAT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_MIN_F64, BRIG_OPCODE_MIN, BRIG_TYPE_F64, "__hsail_min_f64", BT_FN_DOUBLE_DOUBLE_DOUBLE, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_MAX_F64, BRIG_OPCODE_MAX, BRIG_TYPE_F64, "__hsail_max_f64", BT_FN_DOUBLE_DOUBLE_DOUBLE, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_CLASS_F32, BRIG_OPCODE_CLASS, BRIG_TYPE_F32, "__hsail_class_f32", BT_FN_UINT_FLOAT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_CLASS_F64, BRIG_OPCODE_CLASS, BRIG_TYPE_F64, "__hsail_class_f64", BT_FN_UINT_DOUBLE_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_CLASS_F32_F16, BRIG_OPCODE_CLASS, - BRIG_TYPE_F16, "__hsail_class_f32_f16", BT_FN_UINT_FLOAT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + BRIG_TYPE_F16, "__hsail_class_f32_f16", + BT_FN_UINT_FLOAT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_FRACT_F32, BRIG_OPCODE_FRACT, BRIG_TYPE_F32, "__hsail_fract_f32", BT_FN_FLOAT_FLOAT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_FRACT_F64, BRIG_OPCODE_FRACT, BRIG_TYPE_F64, "__hsail_fract_f64", BT_FN_DOUBLE_DOUBLE, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BARRIER, BRIG_OPCODE_BARRIER, BRIG_TYPE_NONE, "__hsail_barrier", BT_FN_VOID_PTR, @@ -268,41 +268,41 @@ DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_RELEASEFBAR, BRIG_OPCODE_RELEASEFBAR, DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BITALIGN, BRIG_OPCODE_BITALIGN, BRIG_TYPE_B32, "__hsail_bitalign", - BT_FN_UINT_ULONG_ULONG_UINT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT_ULONG_ULONG_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_BYTEALIGN, BRIG_OPCODE_BYTEALIGN, BRIG_TYPE_B32, "__hsail_bytealign", - BT_FN_UINT_ULONG_ULONG_UINT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT_ULONG_ULONG_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_LERP, BRIG_OPCODE_LERP, BRIG_TYPE_U8X4, "__hsail_lerp", BT_FN_UINT_UINT_UINT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_PACKCVT, BRIG_OPCODE_PACKCVT, BRIG_TYPE_U8X4, "__hsail_packcvt", BT_FN_UINT_FLOAT_FLOAT_FLOAT_FLOAT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_UNPACKCVT, BRIG_OPCODE_UNPACKCVT, BRIG_TYPE_F32, "__hsail_unpackcvt", BT_FN_FLOAT_UINT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_SAD_U16X2, BRIG_OPCODE_SAD, BRIG_TYPE_U16X2, "__hsail_sad_u16x2", - BT_FN_UINT_UINT_UINT_UINT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT_UINT_UINT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_SAD_U32, BRIG_OPCODE_SAD, BRIG_TYPE_U32, "__hsail_sad_u32", BT_FN_UINT_UINT_UINT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_SAD_U8X4, BRIG_OPCODE_SAD, - BRIG_TYPE_U8X4, "__hsail_sad_u8x4", BT_FN_UINT_UINT_UINT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + BRIG_TYPE_U8X4, "__hsail_sad_u8x4", + BT_FN_UINT_UINT_UINT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_SADHI_U8X4, BRIG_OPCODE_SADHI, BRIG_TYPE_U16X2, "__hsail_sadhi_u16x2_u8x4", BT_FN_UINT_UINT_UINT_UINT, - ATTR_PURE_NOTHROW_LEAF_LIST) + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_BUILTIN (BUILT_IN_HSAIL_CLOCK, BRIG_OPCODE_CLOCK, BRIG_TYPE_U64, "__hsail_clock", BT_FN_ULONG, @@ -447,112 +447,112 @@ DEF_HSAIL_ATOMIC_BUILTIN (BUILT_IN_HSAIL_ATOMIC_WRAPINC_U64, DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_ADD_U64, BRIG_OPCODE_ADD, BRIG_TYPE_U64, "__hsail_sat_add_u64", - BT_FN_ULONG_ULONG_ULONG, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_ULONG_ULONG_ULONG, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_ADD_S64, BRIG_OPCODE_ADD, BRIG_TYPE_S64, "__hsail_sat_add_s64", - BT_FN_LONG_LONG_LONG, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_LONG_LONG_LONG, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_ADD_U32, BRIG_OPCODE_ADD, BRIG_TYPE_U32, "__hsail_sat_add_u32", - BT_FN_UINT_UINT_UINT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT_UINT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_ADD_S32, BRIG_OPCODE_ADD, BRIG_TYPE_S32, "__hsail_sat_add_s32", - BT_FN_INT_INT_INT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT_INT_INT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_ADD_U16, BRIG_OPCODE_ADD, BRIG_TYPE_U16, "__hsail_sat_add_u16", - BT_FN_UINT16_UINT16_UINT16, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT16_UINT16_UINT16, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_ADD_S16, BRIG_OPCODE_ADD, BRIG_TYPE_S16, "__hsail_sat_add_s16", - BT_FN_INT16_INT16_INT16, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT16_INT16_INT16, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_ADD_U8, BRIG_OPCODE_ADD, BRIG_TYPE_U8, "__hsail_sat_add_u8", - BT_FN_UINT8_UINT8_UINT8, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT8_UINT8_UINT8, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_ADD_S8, BRIG_OPCODE_ADD, BRIG_TYPE_S8, "__hsail_sat_add_s8", - BT_FN_INT8_INT8_INT8, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT8_INT8_INT8, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_SUB_U64, BRIG_OPCODE_SUB, BRIG_TYPE_U64, "__hsail_sat_sub_u64", - BT_FN_ULONG_ULONG_ULONG, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_ULONG_ULONG_ULONG, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_SUB_S64, BRIG_OPCODE_SUB, BRIG_TYPE_S64, "__hsail_sat_sub_s64", - BT_FN_LONG_LONG_LONG, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_LONG_LONG_LONG, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_SUB_U32, BRIG_OPCODE_SUB, BRIG_TYPE_U32, "__hsail_sat_sub_u32", - BT_FN_UINT_UINT_UINT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT_UINT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_SUB_S32, BRIG_OPCODE_SUB, BRIG_TYPE_S32, "__hsail_sat_sub_s32", - BT_FN_INT_INT_INT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT_INT_INT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_SUB_U16, BRIG_OPCODE_SUB, BRIG_TYPE_U16, "__hsail_sat_sub_u16", - BT_FN_UINT16_UINT16_UINT16, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT16_UINT16_UINT16, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_SUB_S16, BRIG_OPCODE_SUB, BRIG_TYPE_S16, "__hsail_sat_sub_s16", - BT_FN_INT16_INT16_INT16, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT16_INT16_INT16, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_SUB_U8, BRIG_OPCODE_SUB, BRIG_TYPE_U8, "__hsail_sat_sub_u8", - BT_FN_UINT8_UINT8_UINT8, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT8_UINT8_UINT8, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_SUB_S8, BRIG_OPCODE_SUB, BRIG_TYPE_S8, "__hsail_sat_sub_s8", - BT_FN_INT8_INT8_INT8, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT8_INT8_INT8, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_MUL_U64, BRIG_OPCODE_MUL, BRIG_TYPE_U64, "__hsail_sat_mul_u64", - BT_FN_ULONG_ULONG_ULONG, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_ULONG_ULONG_ULONG, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_MUL_S64, BRIG_OPCODE_MUL, BRIG_TYPE_S64, "__hsail_sat_mul_s64", - BT_FN_LONG_LONG_LONG, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_LONG_LONG_LONG, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_MUL_U32, BRIG_OPCODE_MUL, BRIG_TYPE_U32, "__hsail_sat_mul_u32", - BT_FN_UINT_UINT_UINT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT_UINT_UINT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_MUL_S32, BRIG_OPCODE_MUL, BRIG_TYPE_S32, "__hsail_sat_mul_s32", - BT_FN_INT_INT_INT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT_INT_INT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_MUL_U16, BRIG_OPCODE_MUL, BRIG_TYPE_U16, "__hsail_sat_mul_u16", - BT_FN_UINT16_UINT16_UINT16, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT16_UINT16_UINT16, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_MUL_S16, BRIG_OPCODE_MUL, BRIG_TYPE_S16, "__hsail_sat_mul_s16", - BT_FN_INT16_INT16_INT16, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT16_INT16_INT16, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_MUL_U8, BRIG_OPCODE_MUL, BRIG_TYPE_U8, "__hsail_sat_mul_u8", - BT_FN_UINT8_UINT8_UINT8, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT8_UINT8_UINT8, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_SAT_BUILTIN (BUILT_IN_HSAIL_SAT_MUL_S8, BRIG_OPCODE_MUL, BRIG_TYPE_S8, "__hsail_sat_mul_s8", - BT_FN_INT8_INT8_INT8, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT8_INT8_INT8, ATTR_CONST_NOTHROW_LEAF_LIST) #ifndef DEF_HSAIL_INTR_BUILTIN #define DEF_HSAIL_INTR_BUILTIN(ENUM, NAME, TYPE, ATTRS) #endif DEF_HSAIL_INTR_BUILTIN (BUILT_IN_HSAIL_FTZ_F32_F16, "__hsail_ftz_f32_f16", - BT_FN_FLOAT_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_INTR_BUILTIN (BUILT_IN_HSAIL_FTZ_F32, "__hsail_ftz_f32", - BT_FN_FLOAT_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_INTR_BUILTIN (BUILT_IN_HSAIL_FTZ_F64, "__hsail_ftz_f64", - BT_FN_DOUBLE_DOUBLE, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_INTR_BUILTIN (BUILT_IN_HSAIL_PUSH_FRAME, "__hsail_alloca_push_frame", BT_FN_VOID_PTR, ATTR_NOTHROW_LEAF_LIST) @@ -572,10 +572,10 @@ DEF_HSAIL_INTR_BUILTIN (BUILT_IN_HSAIL_LAUNCH_KERNEL, BT_FN_VOID_PTR_PTR_PTR, ATTR_NOTHROW_LEAF_LIST) DEF_HSAIL_INTR_BUILTIN (BUILT_IN_HSAIL_F32_TO_F16, "__hsail_f32_to_f16", - BT_FN_UINT16_UINT32, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT16_UINT32, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_INTR_BUILTIN (BUILT_IN_HSAIL_F16_TO_F32, "__hsail_f16_to_f32", - BT_FN_UINT32_UINT16, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT32_UINT16, ATTR_CONST_NOTHROW_LEAF_LIST) #ifndef DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN #define DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN(ENUM, HSAIL_DEST_TYPE, HSAIL_SRC_TYPE, \ @@ -585,79 +585,90 @@ DEF_HSAIL_INTR_BUILTIN (BUILT_IN_HSAIL_F16_TO_F32, "__hsail_f16_to_f32", DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_U8_F32, BRIG_TYPE_U8, BRIG_TYPE_F32, "__hsail_cvt_zeroi_sat_u8_f32", - BT_FN_UINT8_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT8_FLOAT, + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_S8_F32, BRIG_TYPE_S8, BRIG_TYPE_F32, "__hsail_cvt_zeroi_sat_s8_f32", - BT_FN_INT8_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT8_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_U16_F32, BRIG_TYPE_U16, BRIG_TYPE_F32, "__hsail_cvt_zeroi_sat_u16_f32", - BT_FN_UINT16_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT16_FLOAT, + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_S16_F32, BRIG_TYPE_S16, BRIG_TYPE_F32, "__hsail_cvt_zeroi_sat_s16_f32", - BT_FN_INT16_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT16_FLOAT, + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_U32_F32, BRIG_TYPE_U32, BRIG_TYPE_F32, "__hsail_cvt_zeroi_sat_u32_f32", - BT_FN_UINT32_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT32_FLOAT, + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_S32_F32, BRIG_TYPE_S32, BRIG_TYPE_F32, "__hsail_cvt_zeroi_sat_s32_f32", - BT_FN_INT_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_U64_F32, BRIG_TYPE_U64, BRIG_TYPE_F32, "__hsail_cvt_zeroi_sat_u64_f32", - BT_FN_UINT64_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT64_FLOAT, + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_S64_F32, BRIG_TYPE_S64, BRIG_TYPE_F32, "__hsail_cvt_zeroi_sat_s64_f32", - BT_FN_LONG_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_LONG_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_U8_F64, BRIG_TYPE_U8, BRIG_TYPE_F64, "__hsail_cvt_zeroi_sat_u8_f64", - BT_FN_UINT8_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT8_FLOAT, + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_S8_F64, BRIG_TYPE_S8, BRIG_TYPE_F64, "__hsail_cvt_zeroi_sat_s8_f64", - BT_FN_INT8_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT8_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_U16_F64, BRIG_TYPE_U16, BRIG_TYPE_F64, "__hsail_cvt_zeroi_sat_u16_f64", - BT_FN_UINT16_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT16_FLOAT, + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_S16_F64, BRIG_TYPE_S16, BRIG_TYPE_F64, "__hsail_cvt_zeroi_sat_s16_f64", - BT_FN_INT16_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT16_FLOAT, + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_U32_F64, BRIG_TYPE_U32, BRIG_TYPE_F64, "__hsail_cvt_zeroi_sat_u32_f64", - BT_FN_UINT32_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT32_FLOAT, + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_S32_F64, BRIG_TYPE_S32, BRIG_TYPE_F64, "__hsail_cvt_zeroi_sat_s32_f64", - BT_FN_INT_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_INT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_U64_F64, BRIG_TYPE_U64, BRIG_TYPE_F64, "__hsail_cvt_zeroi_sat_u64_f64", - BT_FN_UINT64_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_UINT64_FLOAT, + ATTR_CONST_NOTHROW_LEAF_LIST) DEF_HSAIL_CVT_ZEROI_SAT_BUILTIN (BUILT_IN_HSAIL_CVT_ZEROI_SAT_S64_F64, BRIG_TYPE_S64, BRIG_TYPE_F64, "__hsail_cvt_zeroi_sat_s64_f64", - BT_FN_LONG_FLOAT, ATTR_PURE_NOTHROW_LEAF_LIST) + BT_FN_LONG_FLOAT, + ATTR_CONST_NOTHROW_LEAF_LIST) diff --git a/gcc/brig/ChangeLog b/gcc/brig/ChangeLog index 0225929c2ef..fb2b09d70e4 100644 --- a/gcc/brig/ChangeLog +++ b/gcc/brig/ChangeLog @@ -1,3 +1,8 @@ +2017-09-28 Henry Linjamäki + + * brig-lang.c: Added function attributes and their handlers. + Make BRIGFE 3-level optimize by default. + 2017-09-27 Pekka Jääskeläinen * brig-lang.c: Improved support for function and module scope diff --git a/gcc/brig/brig-lang.c b/gcc/brig/brig-lang.c index a587c8b6091..970214b3a3f 100644 --- a/gcc/brig/brig-lang.c +++ b/gcc/brig/brig-lang.c @@ -51,6 +51,12 @@ along with GCC; see the file COPYING3. If not see #include "brig-c.h" #include "brig-builtins.h" +static tree handle_leaf_attribute (tree *, tree, tree, int, bool *); +static tree handle_const_attribute (tree *, tree, tree, int, bool *); +static tree handle_pure_attribute (tree *, tree, tree, int, bool *); +static tree handle_nothrow_attribute (tree *, tree, tree, int, bool *); +static tree handle_returns_twice_attribute (tree *, tree, tree, int, bool *); + /* This file is based on Go frontent'd go-lang.c and gogo-tree.cc. */ /* If -v set. */ @@ -128,6 +134,8 @@ brig_langhook_init_options_struct (struct gcc_options *opts) opts->x_flag_finite_math_only = 0; opts->x_flag_signed_zeros = 1; + + opts->x_optimize = 3; } /* Handle Brig specific options. Return 0 if we didn't do anything. */ @@ -432,6 +440,124 @@ brig_localize_identifier (const char *ident) return identifier_to_locale (ident); } +/* Define supported attributes and their handlers. Code copied from + lto-lang.c */ + +/* Table of machine-independent attributes supported in GIMPLE. */ +const struct attribute_spec brig_attribute_table[] = +{ + /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler, + do_diagnostic } */ + { "leaf", 0, 0, true, false, false, + handle_leaf_attribute, false }, + { "const", 0, 0, true, false, false, + handle_const_attribute, false }, + { "pure", 0, 0, true, false, false, + handle_pure_attribute, false }, + { "nothrow", 0, 0, true, false, false, + handle_nothrow_attribute, false }, + { "returns_twice", 0, 0, true, false, false, + handle_returns_twice_attribute, false }, + { NULL, 0, 0, false, false, false, NULL, false } +}; + +/* Attribute handlers. */ +/* Handle a "leaf" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_leaf_attribute (tree *node, tree name, + tree ARG_UNUSED (args), + int ARG_UNUSED (flags), bool *no_add_attrs) +{ + if (TREE_CODE (*node) != FUNCTION_DECL) + { + warning (OPT_Wattributes, "%qE attribute ignored", name); + *no_add_attrs = true; + } + if (!TREE_PUBLIC (*node)) + { + warning (OPT_Wattributes, + "%qE attribute has no effect on unit local functions", name); + *no_add_attrs = true; + } + + return NULL_TREE; +} + +/* Handle a "const" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_const_attribute (tree *node, tree ARG_UNUSED (name), + tree ARG_UNUSED (args), int ARG_UNUSED (flags), + bool * ARG_UNUSED (no_add_attrs)) +{ + tree type = TREE_TYPE (*node); + + /* See FIXME comment on noreturn in c_common_attribute_table. */ + if (TREE_CODE (*node) == FUNCTION_DECL) + TREE_READONLY (*node) = 1; + else if (TREE_CODE (type) == POINTER_TYPE + && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE) + TREE_TYPE (*node) + = build_pointer_type + (build_type_variant (TREE_TYPE (type), 1, + TREE_THIS_VOLATILE (TREE_TYPE (type)))); + else + gcc_unreachable (); + + return NULL_TREE; +} + +/* Handle a "pure" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_pure_attribute (tree *node, tree ARG_UNUSED (name), + tree ARG_UNUSED (args), int ARG_UNUSED (flags), + bool * ARG_UNUSED (no_add_attrs)) +{ + if (TREE_CODE (*node) == FUNCTION_DECL) + DECL_PURE_P (*node) = 1; + else + gcc_unreachable (); + + return NULL_TREE; +} + +/* Handle a "nothrow" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_nothrow_attribute (tree *node, tree ARG_UNUSED (name), + tree ARG_UNUSED (args), int ARG_UNUSED (flags), + bool * ARG_UNUSED (no_add_attrs)) +{ + if (TREE_CODE (*node) == FUNCTION_DECL) + TREE_NOTHROW (*node) = 1; + else + gcc_unreachable (); + + return NULL_TREE; +} + +/* Handle a "returns_twice" attribute. */ + +static tree +handle_returns_twice_attribute (tree *node, tree ARG_UNUSED (name), + tree ARG_UNUSED (args), + int ARG_UNUSED (flags), + bool * ARG_UNUSED (no_add_attrs)) +{ + gcc_assert (TREE_CODE (*node) == FUNCTION_DECL); + + DECL_IS_RETURNS_TWICE (*node) = 1; + + return NULL_TREE; +} + + /* Built-in initialization code cribbed from lto-lang.c which cribbed it from c-common.c. */ @@ -814,6 +940,10 @@ brig_langhook_init (void) #define LANG_HOOKS_GIMPLIFY_EXPR brig_langhook_gimplify_expr #define LANG_HOOKS_EH_PERSONALITY brig_langhook_eh_personality +/* Attribute hooks. */ +#undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE +#define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE brig_attribute_table + struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; #include "gt-brig-brig-lang.h"