Author: jaewook Date: 2011-11-30 13:35:54 -0500 (Wed, 30 Nov 2011) New Revision: 3829
Modified: trunk/osprey/be/be/driver.cxx trunk/osprey/be/be/driver_util.cxx trunk/osprey/be/cg/Makefile.gbase trunk/osprey/be/cg/cg.cxx trunk/osprey/be/cg/tn.h trunk/osprey/be/cg/tnutil.cxx trunk/osprey/be/com/cfg_base.h trunk/osprey/be/com/comp_driver.cxx trunk/osprey/be/com/comp_driver.h trunk/osprey/common/com/comp_decl.cxx trunk/osprey/common/com/comp_decl.h trunk/osprey/common/com/config.h trunk/osprey/common/util/flags.h trunk/osprey/driver/OPTIONS Log: This is the CGSSA implementation, which supports SSA on CG IR. For details, please refer to the design document in the following URL. http://wiki.open64.net/index.php/CodeGen_SSA_Design_Document Design reviewed by Sun Chan and code reviewed by Jian-Xin Lai. Modified: trunk/osprey/be/be/driver.cxx =================================================================== --- trunk/osprey/be/be/driver.cxx 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/be/be/driver.cxx 2011-11-30 18:35:54 UTC (rev 3829) @@ -2161,6 +2161,9 @@ load_components (argc, argv); be_debug(); + // process the component internal options + O64_Driver::GetInstance()->ProcessComponentOption(); + MEM_POOL_Push (&MEM_src_pool); MEM_POOL_Push (&MEM_src_nz_pool); if ( Show_Progress ) { Modified: trunk/osprey/be/be/driver_util.cxx =================================================================== --- trunk/osprey/be/be/driver_util.cxx 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/be/be/driver_util.cxx 2011-11-30 18:35:54 UTC (rev 3829) @@ -206,11 +206,14 @@ if (Process_Command_Line_Group (cp, Common_Option_Groups)) continue; - /* process a command-line option group using componentization-based - new approach */ - if (O64_Driver::GetInstance()->ProcessComponentOption(argv[i])) + /* Save the component internal options in the format of + -COMP-name:option_list. The reason that we only save here + instead of process is that some component are not registered + yet. Only after load_components, all the needed so are + and component are registered. */ + if (O64_Driver::GetInstance()->SaveComponentOption(argv[i])) continue; - + switch ( *cp++ ) { #ifdef TARG_IA64 Modified: trunk/osprey/be/cg/Makefile.gbase =================================================================== --- trunk/osprey/be/cg/Makefile.gbase 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/be/cg/Makefile.gbase 2011-11-30 18:35:54 UTC (rev 3829) @@ -325,7 +325,7 @@ expand.cxx \ pqs_cg.cxx \ pqs.cxx \ - register_targ.cxx + register_targ.cxx ifeq ($(OLIVE_AUTO_CG), TRUE) BE_CG_TARG_CXX_SRCS += olive_gen_expr.cxx BE_CG_TARG_CXX_SRCS += olive_convert_longlong.cxx @@ -477,6 +477,11 @@ hb_cflow.cxx \ cxx_memory.cxx \ cg_gcov.cxx \ + cg_cfg.cxx \ + cgssa_core.cxx \ + cgssa_build.cxx \ + cgssa_update.cxx \ + gpo.cxx \ $(DERIVED_SRCS) ifeq ($(BUILD_TARGET), SL) Modified: trunk/osprey/be/cg/cg.cxx =================================================================== --- trunk/osprey/be/cg/cg.cxx 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/be/cg/cg.cxx 2011-11-30 18:35:54 UTC (rev 3829) @@ -156,7 +156,12 @@ #include "edge_profile.h" #include "config_opt.h" #endif +#include "cg_cfg.h" +#include "cgssa_core.h" +#include "gpo.h" +using namespace CGSSA_NAME; + MEM_POOL MEM_local_region_pool; /* allocations local to processing a region */ MEM_POOL MEM_local_region_nz_pool; @@ -1018,6 +1023,11 @@ Check_for_Dump ( TP_FIND_GLOB, NULL ); } + CFLOW_Optimize(CFLOW_UNREACHABLE, "CFLOW (GPO pass)"); + CG_PerformGPO(CG_GPO::GPO_Before_RA); + GRA_LIVE_Recalc_Liveness(region ? REGION_get_rid( rwn) : NULL); + GRA_LIVE_Rename_TNs(); + if (Enable_CG_Peephole) { Set_Error_Phase("Extended Block Optimizer"); Start_Timer(T_EBO_CU); Modified: trunk/osprey/be/cg/tn.h =================================================================== --- trunk/osprey/be/cg/tn.h 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/be/cg/tn.h 2011-11-30 18:35:54 UTC (rev 3829) @@ -697,6 +697,7 @@ * range First_Regular_TN..Last_TN. */ extern TN_NUM Last_Dedicated_TN;/* The last dedicated TN number */ +extern TN_NUM Last_Distinct_Dedicated_TN; extern TN_NUM First_Regular_TN; /* after all the preallocated TNs */ extern TN_NUM Last_TN; /* The last allocated TN number */ extern TN_NUM First_REGION_TN; /* The first non-dedicated TN in the current REGION */ Modified: trunk/osprey/be/cg/tnutil.cxx =================================================================== --- trunk/osprey/be/cg/tnutil.cxx 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/be/cg/tnutil.cxx 2011-11-30 18:35:54 UTC (rev 3829) @@ -181,6 +181,8 @@ /* TN_number of the last dedicated TN */ TN_NUM Last_Dedicated_TN = 0; +/* TN_number of the last distinct dedicated TN*/ +TN_NUM Last_Distinct_Dedicated_TN = 0; /* TN_number of the first non-dedicated TN. */ TN_NUM First_Regular_TN = 0; /* TN_number of the first non-dedicated TN in the current REGION. */ @@ -513,6 +515,8 @@ } } + Last_Distinct_Dedicated_TN = tnum; + /* Initialize the dedicated integer register TNs: */ Zero_TN = ded_tns[REGISTER_CLASS_zero][REGISTER_zero]; Ep_TN = ded_tns[REGISTER_CLASS_ep][REGISTER_ep]; Modified: trunk/osprey/be/com/cfg_base.h =================================================================== --- trunk/osprey/be/com/cfg_base.h 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/be/com/cfg_base.h 2011-11-30 18:35:54 UTC (rev 3829) @@ -397,6 +397,7 @@ template<typename _Tcfg> friend class DOM_BUILDER; template<typename _Tcfg> friend class DF_BUILDER; template<typename _Tcfg, BOOL _Fwd> friend class DFS_ITERATOR; + template<typename _Tcfg, BOOL _Fwd> friend class PO_ITERATOR; template<typename _Tsc, typename _Tsm, typename _Tnc> friend class CFG_BASE; template<typename _Tcfg, typename _Twalker, BOOL _Dom> friend class DOM_WALKER_HELPER; @@ -720,7 +721,120 @@ }; + //=================================================================== +// PO_ITERATOR +// iterators to traverse the CFG in postorder +// template parameter +// _Tcfg: type of cfg +// _Fwd: BOOL, traverse the CFG(TRUE) or RCFG(FALSE) +// CFG: traverse from entry to exit by the succs list +// RCFG: traverse from exit to entry by the preds list +//=================================================================== +template<typename _Tcfg, BOOL _Fwd> +class PO_ITERATOR { + +public: + typedef typename _Tcfg::BB_NODE BB_NODE; + typedef typename _Tcfg::BB_LIST BB_LIST; + +private: + BB_NODE* _current_node; // current node to be processed + std::list<BB_NODE*> _ancestors; // _ancestors of _current_node + std::list<typename BB_LIST::iterator> _iter_list; // _ancestors' iterators pointing to the next kid + std::vector<bool> _visited; + + void goto_next_node() { + if (_ancestors.empty()) { + _current_node = NULL; + return; + } + + BB_NODE* parent = _ancestors.front(); + typename BB_LIST::iterator iter = _iter_list.front(); + + while (iter != parent->bb_end(_Fwd)) { + if (_visited[(*iter)->Get_id()]) { + iter++; + continue; + } + + Push_node(*iter); // push this kid onto the stack + parent = _ancestors.front(); + iter = _iter_list.front(); + } + + _current_node = Pop_node(); + } + + // add a node to _ancestors. The node must not have been visited. + void Push_node(BB_NODE* node) { + Is_True(_visited[node->Get_id()] == false, ("node has been visited")); + _visited[node->Get_id()] = true; + + _ancestors.push_front(node); + _iter_list.push_front(node->bb_begin(_Fwd)); + } + + BB_NODE* Pop_node() { + BB_NODE* node = _ancestors.front(); + _ancestors.pop_front(); + _iter_list.pop_front(); + + return node; + } + +public: + PO_ITERATOR() : _current_node(NULL) { } + PO_ITERATOR(BB_NODE* node, int max_size) : _current_node(node) { + _visited.resize(max_size, false); + if (node == NULL) return; + + Push_node(node); + goto_next_node(); + } + PO_ITERATOR(const PO_ITERATOR<_Tcfg, _Fwd>& rhs) + : _current_node(rhs._current_node), + _ancestors(rhs._ancestors), + _iter_list(rhs._iter_list), + _visited(rhs._visited) { } + +public: + BB_NODE* operator->() { + Is_True(_current_node != NULL, ("current node is NULL")); + return _current_node; + } + BB_NODE& operator* () { + Is_True(_current_node != NULL, ("current node is NULL")); + return *_current_node; + } + + PO_ITERATOR<_Tcfg, _Fwd>& operator++() { + Is_True(_current_node != NULL, ("current node is NULL")); + goto_next_node(); + return *this; + } + + bool operator==(const PO_ITERATOR<_Tcfg, _Fwd>& rit) { + // since each node can be only visited once, ignore the _iter_list; + return (_current_node == rit._current_node); + } + + bool operator!=(const PO_ITERATOR<_Tcfg, _Fwd>& rit) { + return !(operator==(rit)); + } + + PO_ITERATOR<_Tcfg, _Fwd>& operator=(const PO_ITERATOR<_Tcfg, _Fwd>& rit) { + _current_node = rit._current_node; + _ancestors = rit._ancestors; + _iter_list = rit._iter_list; + _visited = rit._visited; + } +}; + + + +//=================================================================== // DOM_WALKER_HELPER // take a walker to traverse the DOM tree in deep-first order // template parameter: @@ -798,6 +912,8 @@ typedef DFS_ITERATOR<BB_NODE, TRUE> dfs_fwd_iterator; typedef DFS_ITERATOR<BB_NODE, FALSE> dfs_bwd_iterator; + typedef PO_ITERATOR<BB_NODE, TRUE> po_dfs_iterator; + typedef PO_ITERATOR<BB_NODE, FALSE> rpo_dfs_iterator; typedef typename _Tnodecontainer::iterator bb_iterator; typedef typename _Tnodecontainer::const_iterator const_bb_iterator; @@ -897,6 +1013,12 @@ dfs_bwd_iterator Dfs_bwd_begin() { dfs_bwd_iterator it(Get_dummy_exit(), Get_max_id()); return it; } dfs_bwd_iterator Dfs_bwd_end() { dfs_bwd_iterator it(NULL, 0); return it; } + // Postorder iterators + po_dfs_iterator Po_dfs_begin() { po_dfs_iterator it(Get_dummy_entry(), Get_max_id()); return it; } + po_dfs_iterator Po_dfs_end() { po_dfs_iterator it(NULL, 0); return it; } + rpo_dfs_iterator Rpo_dfs_begin() { rpo_dfs_iterator it(Get_dummy_exit(), Get_max_id()); return it; } + rpo_dfs_iterator Rpo_dfs_end() { rpo_dfs_iterator it(NULL, 0); return it; } + // BB iterators bb_iterator BB_begin() { return _node_container.begin(); } bb_iterator BB_end() { return _node_container.end(); } Modified: trunk/osprey/be/com/comp_driver.cxx =================================================================== --- trunk/osprey/be/com/comp_driver.cxx 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/be/com/comp_driver.cxx 2011-11-30 18:35:54 UTC (rev 3829) @@ -36,6 +36,7 @@ #include "errors.h" #include "mempool.h" #include "cxx_memory.h" +#include "erglob.h" O64_Driver * O64_Driver::_theInstance = NULL; @@ -71,18 +72,16 @@ // ======================================================================= O64_Driver::O64_Driver() - :_NumRegisteredComponents(COMPONENT_first), - _CurrentWN(NULL) + :_CurrentWN(NULL), _CompOptionArgc(0) { MEM_POOL_Initialize(&_DriverPool, "DriverPool", FALSE); MEM_POOL_Initialize(&_LocalPool, "LocalMemPool", FALSE); MEM_POOL_Push(&_DriverPool); - _ComponentDescriptorList.NumOfComponents = COMPONENT_last; - _ComponentDescriptorList.ComponentDescriptors = (O64_ComponentDescriptor **) - MEM_POOL_Alloc(&_DriverPool, sizeof(O64_ComponentDescriptor*)*COMPONENT_last); - + _CompOptionArgv = (char **) + MEM_POOL_Alloc(&_DriverPool, sizeof(char*)*MaxOptionNum); + _ComponentDescriptorList.InitCompDescList(&_DriverPool); } O64_Driver::~O64_Driver() @@ -115,22 +114,44 @@ void O64_Driver::RegisterComponent(O64_COMPONENT component, const O64_ComponentDescriptor* desc) { - Is_True((COMPONENT_first <= component) && - (component < COMPONENT_last) && desc, ("RegisterComponent: invalid component")); + Is_True((COMPONENT_first <= component) && + (component < COMPONENT_last) && desc, + ("RegisterComponent: invalid component")); - _ComponentDescriptorList.ComponentDescriptors[component]= - const_cast<O64_ComponentDescriptor*>(desc); + _ComponentDescriptorList.SetComponentDescriptor(component, desc); + _ComponentDescriptorList.SetComponentRegistered(component); + _ComponentDescriptorList.SetNumOfRegisteredComponents( + _ComponentDescriptorList.GetNumOfRegisteredComponents() + 1); - _NumRegisteredComponents++; } -// Process O64_Option class to store option values from the command line. -// The new option handling mechnisam co-exists with the old option handling -// mechnisam. +// Save the componentization related commands into a string list +// in O64_Driver. The commands will be processed once all the modules are +// loaded and thus all the components are registered. bool -O64_Driver::ProcessComponentOption(char * argv) +O64_Driver::SaveComponentOption(const char * argv) { - FmtAssert(_NumRegisteredComponents == COMPONENT_last, + char * temp_str; + if (!STRNCMP(argv, "-COMP-", STRLEN("-COMP-"))) { + temp_str = STRDUP(argv); + temp_str = temp_str + STRLEN("-COMP-"); + _CompOptionArgv[_CompOptionArgc] = (char *) + MEM_POOL_Alloc(&_DriverPool, sizeof(char)*(STRLEN(temp_str)+1)); + STRCPY(_CompOptionArgv[_CompOptionArgc], temp_str); + _CompOptionArgc++; + FmtAssert(_CompOptionArgc <= MaxOptionNum, + ("too large option string")); + return true; + } + return false; +} + +// Create O64_Option object to store all registed components' option (if not exist) +// Process the component-based command option +void +O64_Driver::ProcessComponentOption() +{ + FmtAssert(_NumRegisteredComponents <= COMPONENT_last, ("[O64_Driver] Component Registration Error")); if (_CurrentOption == NULL) { @@ -138,7 +159,10 @@ Is_True(_CurrentOption, ("[O64_Driver] Null CurrentOption")); } - return (_CurrentOption->ProcessComponentOption_(argv)); + for (INT i = 0; i < _CompOptionArgc; i++) { + if (!_CurrentOption->ProcessComponentOption_(_CompOptionArgv[i])) + ErrMsg (EC_Unknown_Flag, _CompOptionArgv[i][0], _CompOptionArgv[i]); + } } TRACE_OPTION_KIND @@ -181,6 +205,8 @@ "none", "ir", "cfg", + "ssa", + "vcg", "max" }; @@ -205,10 +231,10 @@ // if -COMP:db=ir is specified, this option is DUMP_ir; // if -COMP:db=cfg is specified, this option is DUMP_cfg; - O64_ENUM_OPTION_DESC(OPT_dump_before, "dump [ir|cfg|max] before the component", + O64_ENUM_OPTION_DESC(OPT_dump_before, "dump [ir|cfg|ssa|vcg|max] before the component", "dump_before", "db",OV_INTERNAL, false, DUMP_none, DUMP_none, DUMP_maximal, DUMP_ir, DumpOptionNames), - O64_ENUM_OPTION_DESC(OPT_dump_after, "dump [ir|cfg|max] after the component", + O64_ENUM_OPTION_DESC(OPT_dump_after, "dump [ir|cfg|ssa|vcg|max] after the component", "dump_after", "da", OV_INTERNAL, false, DUMP_none, DUMP_none, DUMP_maximal, DUMP_ir, DumpOptionNames), O64_ENUM_OPTION_DESC(OPT_trace, "dump out trace information [info|min|med|max]", @@ -216,6 +242,10 @@ TRACE_maximal, TraceOptionNames), O64_OPTION_DESC(OPT_stats, "gather and print component statistics", "STATS", "stats", OVK_NONE, OV_INTERNAL, false, false, 0, 0), + O64_OPTION_DESC(OPT_skip_b, "skip the function unit before", + "skip_b", "skip_b", OVK_UINT32, OV_INTERNAL, false, 0, 0, UINT32_MAX), + O64_OPTION_DESC(OPT_skip_a, "skip the function unit after", + "skip_a", "skip_a", OVK_UINT32, OV_INTERNAL, false, UINT32_MAX, 0, UINT32_MAX), O64_OPTION_DESC(OPT_common_last, "end marker", 0, 0, OVK_INVALID, OV_INTERNAL, false, 0, 0, 0) }; @@ -226,15 +256,26 @@ _ComponentDescriptorList = O64_Driver::GetInstance()->GetComponentDescriptorList(); _MemPool = O64_Driver::GetInstance()->GetDriverMemPool(); - _Options = (_Value **) MEM_POOL_Alloc(_MemPool, sizeof(_Value*) *GetNumOfComponents_()); + _Options = (_Value **) MEM_POOL_Alloc(_MemPool, + sizeof(_Value*) *GetNumOfComponents_()); + _OptionsSet = (BOOL **) MEM_POOL_Alloc(_MemPool, + sizeof(BOOL*) *GetNumOfComponents_()); for (UINT32 component = 0; component < GetNumOfComponents_(); ++component) { + // if the component not registered, we could not find its option + // descriptors + if (!_ComponentDescriptorList->IsComponentRegistered(component)) + continue; + UINT32 option; for (option = 0; GetOptionName_(component, option); ++option); - _Options[component] = (_Value *) MEM_POOL_Alloc(_MemPool, sizeof(_Value) * option); + _Options[component] = (_Value *) MEM_POOL_Alloc(_MemPool, + sizeof(_Value) * option); + _OptionsSet[component] = (BOOL*) MEM_POOL_Alloc(_MemPool, + sizeof(BOOL) * option); for (option = 0; GetOptionName_(component, option); ++option) { @@ -250,6 +291,9 @@ { for (INT32 component = 0; component < GetNumOfComponents_(); ++component) { + if (!_ComponentDescriptorList->IsComponentRegistered(component)) + continue; + for (INT32 option = 0; GetOptionName_(component, option); ++option) { // free the strings that are generated by STRDUP @@ -260,9 +304,11 @@ } MEM_POOL_FREE(_MemPool, _Options[component]); + MEM_POOL_FREE(_MemPool, _OptionsSet[component]); } MEM_POOL_FREE(_MemPool, _Options); + MEM_POOL_FREE(_MemPool, _OptionsSet); } // @@ -276,16 +322,10 @@ char * option_dup, * option_start; - // the first char should be '-' option_start = component_options; - if (*option_start != '-') return false; - - option_start++; - if (*option_start == '\0') return false; - option_dup = STRDUP(option_start); - if (!STRCMP("OPTIONS", option_dup)) { + if (!STRCASECMP("OPTIONS", option_dup)) { PrintOptionsUsage_(); return true; } @@ -294,13 +334,15 @@ if (option_start == NULL) return false; for (INT32 component = 0; component <= GetNumOfComponents_(); ++component) { + if (!_ComponentDescriptorList->IsComponentRegistered(component)) { + continue; + } if (!STRCASECMP(GetComponentName_(component), option_start)) { option_start = STRTOK(NULL, ":"); if (ProcessOptionList_(component, option_start)) return true; } } - return false; }; @@ -363,10 +405,8 @@ } } if (!option_found) { - FmtAssert(false, ("invalid option")); return false; } - return true; } @@ -375,8 +415,6 @@ bool O64_Option::SetOptionValue_(INT32 component, INT32 option, char * option_value) { - bool return_value = false; - INT32 int32_value; INT64 int64_value; UINT32 uint32_value; @@ -463,8 +501,12 @@ break; default: Is_True(false, ("Unimplemented option kind")); - break; - } + return false; + } + + //set the _OptionSet (i.e., the value is from command line) + _OptionsSet[component][option] = TRUE; + return true; } // the print name for each option kind Modified: trunk/osprey/be/com/comp_driver.h =================================================================== --- trunk/osprey/be/com/comp_driver.h 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/be/com/comp_driver.h 2011-11-30 18:35:54 UTC (rev 3829) @@ -61,8 +61,8 @@ OptionId(id), OptionDesc(desc), OptionName(name), OptionAbbrev(abbrev), OptionKind(kind), OptionVisibility(visibility), OptionPragma(pragma), - DefaultVal(def), MinVal(min), MaxVal(max), - OptionSet(false) { Is_True(kind != OVK_ENUM, ("kind should not be OVK_ENUM")); }; + DefaultVal(def), MinVal(min), MaxVal(max) + { Is_True(kind != OVK_ENUM, ("kind should not be OVK_ENUM")); }; template <typename enum_type> O64_OptionDescriptor(INT32 id, const char * desc, @@ -74,8 +74,8 @@ OptionName(name), OptionAbbrev(abbrev), OptionKind(OVK_ENUM), OptionVisibility(visibility), OptionPragma(pragma), DefaultVal(def), MinVal(min), MaxVal(max), - DefaultSetVal(defset), ValueNames(valuenames), - OptionSet(false) {}; + DefaultSetVal(defset), ValueNames(valuenames) + {}; INT32 OptionId; OPTION_KIND OptionKind; @@ -85,7 +85,6 @@ const char * OptionName; const char * OptionAbbrev; const char * OptionDesc; - BOOL OptionSet; /* the value is set from command line */ INT64 DefaultVal; INT64 MinVal; @@ -111,10 +110,45 @@ #define O64_COMPONENT_DESC(desc, name, opt_desc) desc, name, opt_desc -struct O64_ComponentDescriptorList +class O64_ComponentDescriptorList { - INT32 NumOfComponents; - O64_ComponentDescriptor ** ComponentDescriptors; +private: + INT32 _NumOfComponents; + INT32 _NumOfRegisteredComponents; + O64_ComponentDescriptor ** _ComponentDescriptors; + BOOL * _ComponentRegistered; + +public: + O64_ComponentDescriptorList() {}; + ~O64_ComponentDescriptorList() {}; + + void InitCompDescList(MEM_POOL * mem_pool) { + _NumOfComponents = COMPONENT_last; + _NumOfRegisteredComponents = COMPONENT_first; + _ComponentDescriptors = (O64_ComponentDescriptor **) + MEM_POOL_Alloc(mem_pool, + sizeof(O64_ComponentDescriptor*)*COMPONENT_last); + _ComponentRegistered = (BOOL *) + MEM_POOL_Alloc(mem_pool, sizeof(BOOL)*COMPONENT_last); + memset(_ComponentRegistered, 0, sizeof(BOOL)*COMPONENT_last); + } + + // the num of components is the total number of static components + // it could be different from the number registered components + // since ome of components may not be registered (the module + // could be not loaded) + INT32 GetNumOfComponents() {return _NumOfComponents; } + INT32 GetNumOfRegisteredComponents() { return _NumOfRegisteredComponents; } + void SetNumOfRegisteredComponents(INT32 num) + { _NumOfRegisteredComponents = num; } + BOOL SetComponentRegistered(INT32 comp) { _ComponentRegistered[comp] = TRUE; } + BOOL IsComponentRegistered(INT32 comp) { return _ComponentRegistered[comp]; } + O64_ComponentDescriptor * GetComponentDescriptor(INT32 comp) { + return _ComponentDescriptors[comp]; + } + void SetComponentDescriptor(INT32 comp, const O64_ComponentDescriptor* desc) { + _ComponentDescriptors[comp] = const_cast <O64_ComponentDescriptor*>(desc); + } }; class O64_ComponentInitializer @@ -125,6 +159,8 @@ class O64_Option; /* forward declaration */ +#define MaxOptionNum 100 + class O64_Driver { public: @@ -151,7 +187,8 @@ MEM_POOL * GetLocalMemPool() { return &_LocalPool; }; WN* GetCurrentWN() { return _CurrentWN; }; void SetCurrentWN(WN* wn){ _CurrentWN = wn; }; - bool ProcessComponentOption(char *argv); + bool SaveComponentOption(const char * argv); + void ProcessComponentOption(); TRACE_OPTION_KIND GetTraceKind(); BOOL TimeStats(); BOOL MemStats(); @@ -170,6 +207,8 @@ O64_Option* _CurrentOption; WN* _CurrentWN; + INT _CompOptionArgc; + char** _CompOptionArgv; O64_Driver(); ~O64_Driver(); @@ -221,6 +260,7 @@ OPTION_LIST * GetListOption(INT32 component, INT32 option); template <typename enum_ret> enum_ret GetEnumOption(INT32 component, INT32 option); + BOOL GetOptionSet(INT32 component, INT32 option); private: @@ -235,6 +275,7 @@ }; INT32 GetNumOfComponents_() const; + INT32 GetNumOfRegisteredComponents_() const; const O64_ComponentDescriptor* GetComponentDescriptor_(INT32 component); const O64_OptionDescriptor * GetOptionDescriptor_(INT32 component, INT32 option); @@ -261,10 +302,11 @@ private: _Value ** _Options; /* store value for each option for each component */ + BOOL ** _OptionsSet; MEM_POOL * _MemPool; /* point to O64_Driver's _DriverPool */ const O64_OptionDescriptor* _CommonOptionDescriptors; - const O64_ComponentDescriptorList * _ComponentDescriptorList; /* to component descriptor list */ + O64_ComponentDescriptorList * _ComponentDescriptorList; friend class O64_Driver; friend class O64_Component; @@ -278,7 +320,7 @@ inline const O64_ComponentDescriptor* O64_Option::GetComponentDescriptor_(INT32 component) { - return _ComponentDescriptorList->ComponentDescriptors[component]; + return _ComponentDescriptorList->GetComponentDescriptor(component); } inline const char * @@ -343,6 +385,12 @@ return _Options[component][option]._ListVal; } +inline BOOL +O64_Option::GetOptionSet(INT32 component, INT32 option) +{ + return _OptionsSet[component][option]; +} + inline const OPTION_KIND O64_Option::GetOptionKind_(INT32 component, INT32 option) { @@ -364,9 +412,15 @@ inline INT32 O64_Option::GetNumOfComponents_() const { - return _ComponentDescriptorList->NumOfComponents; + return _ComponentDescriptorList->GetNumOfComponents(); } +inline INT32 +O64_Option::GetNumOfRegisteredComponents_() const +{ + return _ComponentDescriptorList->GetNumOfRegisteredComponents(); +} + inline void O64_Option::SetDefaultOption_(INT32 component, INT32 option) { @@ -414,6 +468,9 @@ Is_True(false, ("Unimplemented option kind")); break; } + + // unset the _OptionSet (i.e., the value is from default value) + _OptionsSet[component][option]= FALSE; }; inline INT64 @@ -428,12 +485,6 @@ return GetOptionDescriptor_(component, option)->OptionName; } -inline BOOL -O64_Option::GetOptionSet_(INT32 component, INT32 option) -{ - return GetOptionDescriptor_(component, option)->OptionSet; -} - inline INT64 O64_Option::GetMinVal_(INT32 component, INT32 option) { Modified: trunk/osprey/common/com/comp_decl.cxx =================================================================== --- trunk/osprey/common/com/comp_decl.cxx 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/common/com/comp_decl.cxx 2011-11-30 18:35:54 UTC (rev 3829) @@ -41,8 +41,23 @@ _CurrentComponent = component; _canBeDisabled = ComponentDisableable_(_CurrentComponent); _Driver = O64_Driver::GetInstance(); + if (!_Driver->GetComponentDescriptorList()->IsComponentRegistered(component)) { + _enable = false; + _disable = true; + return; + } + _CurrentOption = _Driver->GetCurrentOption(); - + + + if (Current_PU_Count() < _CurrentOption->GetUIntOption(_CurrentComponent, OPT_skip_b) || + Current_PU_Count() > _CurrentOption->GetUIntOption(_CurrentComponent, OPT_skip_a)) + { + _enable = false; + _disable = true; + return; + } + _enable = _CurrentOption->GetBoolOption(_CurrentComponent, OPT_enable); _disable = _CurrentOption->GetBoolOption(_CurrentComponent, OPT_disable); @@ -64,6 +79,10 @@ O64_Component::~O64_Component() { + if (Current_PU_Count() < _CurrentOption->GetUIntOption(_CurrentComponent, OPT_skip_b) || + Current_PU_Count() > _CurrentOption->GetUIntOption(_CurrentComponent, OPT_skip_a)) + return; + if (_disable) return; ProcessDumpOptions_( @@ -81,7 +100,7 @@ void O64_Component::StartEndMessage_(bool isStart) { - if (_Driver->GetTraceKind() != TRACE_maximal) return; + if (_Driver->GetTraceKind() != TRACE_info) return; fprintf(TFile, "[DRIVER]%s %-10s", isStart ? "starting" : "finished", @@ -96,28 +115,22 @@ void O64_Component::ProcessDumpOptions_(DUMP_KIND dumpKind) { - bool dump_ir = false, dump_cfg = false; - switch(dumpKind) { case DUMP_none: return; case DUMP_ir: - dump_ir = true; + if (_Driver->GetCurrentWN()) + fdump_tree(TFile, _Driver->GetCurrentWN()); break; case DUMP_cfg: - dump_cfg = true; break; + case DUMP_ssa: + break; case DUMP_maximal: - dump_ir = true; - dump_cfg = true; break; default: break; } - - if (dump_ir) { - fdump_tree(TFile, _Driver->GetCurrentWN()); - } } static O64_COMPONENT NonDisableAbles[] = Modified: trunk/osprey/common/com/comp_decl.h =================================================================== --- trunk/osprey/common/com/comp_decl.h 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/common/com/comp_decl.h 2011-11-30 18:35:54 UTC (rev 3829) @@ -67,7 +67,7 @@ bool _invalidSSA; /* SSA needs to be invalidated after this opt */ void StartEndMessage_(bool); - void ProcessDumpOptions_(DUMP_KIND); + virtual void ProcessDumpOptions_(DUMP_KIND); bool LookupDisableable_(INT32 comp); bool ComponentDisableable_(O64_COMPONENT comp); @@ -82,6 +82,6 @@ }; // Declare the public interface for each component -// extern void OPT_Perform(); +extern INT32 Current_PU_Count(); #endif /* comp_decl_INCLUDED */ Modified: trunk/osprey/common/com/config.h =================================================================== --- trunk/osprey/common/com/config.h 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/common/com/config.h 2011-11-30 18:35:54 UTC (rev 3829) @@ -971,6 +971,16 @@ #ifndef STRCHR #define STRCHR(a,b) strchr(a,b) #endif +#ifndef STRNCMP +#define STRNCMP(a,b,c) strncmp(a,b,c) +#endif +#ifndef STRCAT +#define STRCAT(a,b) strcat(a,b) +#endif +#ifndef STRCPY +#define STRCPY(a,b) strcpy(a,b) +#endif + #ifdef __cplusplus } #endif Modified: trunk/osprey/common/util/flags.h =================================================================== --- trunk/osprey/common/util/flags.h 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/common/util/flags.h 2011-11-30 18:35:54 UTC (rev 3829) @@ -307,7 +307,7 @@ /* Define the option kinds: */ typedef enum { - OVK_INVALID, + OVK_INVALID = 0, OVK_NONE, /* Option never takes a value */ OVK_BOOL, /* boolean value */ OVK_INT32, /* 32-bit integer value */ @@ -451,6 +451,8 @@ OPT_dump_after, OPT_trace, OPT_stats, + OPT_skip_b, + OPT_skip_a, OPT_common_last, OPT_component_first = OPT_common_last @@ -470,6 +472,8 @@ DUMP_none =0, DUMP_ir, DUMP_cfg, + DUMP_ssa, + DUMP_vcg, DUMP_maximal } DUMP_KIND; @@ -478,6 +482,7 @@ COMPONENT_invalid = -1, COMPONENT_first = 0, COMPONENT_driver = COMPONENT_first, + COMPONENT_cg_gpo, COMPONENT_last } O64_COMPONENT; Modified: trunk/osprey/driver/OPTIONS =================================================================== --- trunk/osprey/driver/OPTIONS 2011-11-29 14:39:37 UTC (rev 3828) +++ trunk/osprey/driver/OPTIONS 2011-11-30 18:35:54 UTC (rev 3829) @@ -357,8 +357,6 @@ % Basic option groups: % See opt_actions.c::Process_Ofast if you change the -OPT: item. --OPTIONS ; ALL be "-OPTIONS" - "print out all be option usage" -OPT:%s Process_Opt_Group(optargs); ALL CMP,ipap "-OPT:%s" "option group to control optimization" -OPT:unroll_level=n ; ALL be "" @@ -407,8 +405,8 @@ "equivalent to -HP:" -HUGEPAGE Process_Hugepage_Default(); ALL be "" "equivalent to -HP" --DRIVER:%s ; ALL be "-DRIVER:%s" - "options for internal use in driver" +-COMP-%s ; All be "-COMP-%s" + "options for internal use in each component" -VHO:%s ; ALL ffe,be,ipl "-VHO:%s" "option group to control vho lowering" ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d _______________________________________________ Open64-devel mailing list Open64-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open64-devel