From 4c0315d05fa0f707875686abc4f91f7a979a7c7b Mon Sep 17 00:00:00 2001 From: aldyh Date: Tue, 8 Nov 2011 11:13:41 +0000 Subject: Merge from transactional-memory branch. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181154 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/calls.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 2 deletions(-) (limited to 'gcc/calls.c') diff --git a/gcc/calls.c b/gcc/calls.c index eeb6b2ec602..382de7fcdeb 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -611,6 +611,69 @@ alloca_call_p (const_tree exp) return false; } +/* Return TRUE if FNDECL is either a TM builtin or a TM cloned + function. Return FALSE otherwise. */ + +static bool +is_tm_builtin (const_tree fndecl) +{ + if (fndecl == NULL) + return false; + + if (decl_is_tm_clone (fndecl)) + return true; + + if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) + { + switch (DECL_FUNCTION_CODE (fndecl)) + { + case BUILT_IN_TM_COMMIT: + case BUILT_IN_TM_COMMIT_EH: + case BUILT_IN_TM_ABORT: + case BUILT_IN_TM_IRREVOCABLE: + case BUILT_IN_TM_GETTMCLONE_IRR: + case BUILT_IN_TM_MEMCPY: + case BUILT_IN_TM_MEMMOVE: + case BUILT_IN_TM_MEMSET: + CASE_BUILT_IN_TM_STORE (1): + CASE_BUILT_IN_TM_STORE (2): + CASE_BUILT_IN_TM_STORE (4): + CASE_BUILT_IN_TM_STORE (8): + CASE_BUILT_IN_TM_STORE (FLOAT): + CASE_BUILT_IN_TM_STORE (DOUBLE): + CASE_BUILT_IN_TM_STORE (LDOUBLE): + CASE_BUILT_IN_TM_STORE (M64): + CASE_BUILT_IN_TM_STORE (M128): + CASE_BUILT_IN_TM_STORE (M256): + CASE_BUILT_IN_TM_LOAD (1): + CASE_BUILT_IN_TM_LOAD (2): + CASE_BUILT_IN_TM_LOAD (4): + CASE_BUILT_IN_TM_LOAD (8): + CASE_BUILT_IN_TM_LOAD (FLOAT): + CASE_BUILT_IN_TM_LOAD (DOUBLE): + CASE_BUILT_IN_TM_LOAD (LDOUBLE): + CASE_BUILT_IN_TM_LOAD (M64): + CASE_BUILT_IN_TM_LOAD (M128): + CASE_BUILT_IN_TM_LOAD (M256): + case BUILT_IN_TM_LOG: + case BUILT_IN_TM_LOG_1: + case BUILT_IN_TM_LOG_2: + case BUILT_IN_TM_LOG_4: + case BUILT_IN_TM_LOG_8: + case BUILT_IN_TM_LOG_FLOAT: + case BUILT_IN_TM_LOG_DOUBLE: + case BUILT_IN_TM_LOG_LDOUBLE: + case BUILT_IN_TM_LOG_M64: + case BUILT_IN_TM_LOG_M128: + case BUILT_IN_TM_LOG_M256: + return true; + default: + break; + } + } + return false; +} + /* Detect flags (function attributes) from the function decl or type node. */ int @@ -644,10 +707,28 @@ flags_from_decl_or_type (const_tree exp) if (TREE_NOTHROW (exp)) flags |= ECF_NOTHROW; + if (flag_tm) + { + if (is_tm_builtin (exp)) + flags |= ECF_TM_BUILTIN; + else if ((flags & ECF_CONST) != 0 + || lookup_attribute ("transaction_pure", + TYPE_ATTRIBUTES (TREE_TYPE (exp)))) + flags |= ECF_TM_PURE; + } + flags = special_function_p (exp, flags); } - else if (TYPE_P (exp) && TYPE_READONLY (exp)) - flags |= ECF_CONST; + else if (TYPE_P (exp)) + { + if (TYPE_READONLY (exp)) + flags |= ECF_CONST; + + if (flag_tm + && ((flags & ECF_CONST) != 0 + || lookup_attribute ("transaction_pure", TYPE_ATTRIBUTES (exp)))) + flags |= ECF_TM_PURE; + } if (TREE_THIS_VOLATILE (exp)) { -- cgit v1.2.1