OLD | NEW |
1 //===- subzero/src/IceClFlags.cpp - Command line flags and parsing --------===// | 1 //===- subzero/src/IceClFlags.cpp - Command line flags and parsing --------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // toSetterParam is template magic that is needed to convert between (llvm::)cl | 156 // toSetterParam is template magic that is needed to convert between (llvm::)cl |
157 // objects and the arguments to ClFlags' setters. ToSetterParam is a traits | 157 // objects and the arguments to ClFlags' setters. ToSetterParam is a traits |
158 // object that we need in order for the multiple specializations to | 158 // object that we need in order for the multiple specializations to |
159 // toSetterParam to agree on their return type. | 159 // toSetterParam to agree on their return type. |
160 template <typename T> struct ToSetterParam { using ReturnType = const T &; }; | 160 template <typename T> struct ToSetterParam { using ReturnType = const T &; }; |
161 | 161 |
162 template <> struct ToSetterParam<cl::list<Ice::VerboseItem>> { | 162 template <> struct ToSetterParam<cl::list<Ice::VerboseItem>> { |
163 using ReturnType = Ice::VerboseMask; | 163 using ReturnType = Ice::VerboseMask; |
164 }; | 164 }; |
165 | 165 |
| 166 template <> struct ToSetterParam<cl::list<std::string>> { |
| 167 using ReturnType = std::vector<std::string>; |
| 168 }; |
| 169 |
166 template <typename T> | 170 template <typename T> |
167 typename ToSetterParam<T>::ReturnType toSetterParam(const T &Param) { | 171 typename ToSetterParam<T>::ReturnType toSetterParam(const T &Param) { |
168 return Param; | 172 return Param; |
169 } | 173 } |
170 | 174 |
171 template <> | 175 template <> |
172 ToSetterParam<cl::list<Ice::VerboseItem>>::ReturnType | 176 ToSetterParam<cl::list<Ice::VerboseItem>>::ReturnType |
173 toSetterParam(const cl::list<Ice::VerboseItem> &Param) { | 177 toSetterParam(const cl::list<Ice::VerboseItem> &Param) { |
174 Ice::VerboseMask VMask = Ice::IceV_None; | 178 Ice::VerboseMask VMask = Ice::IceV_None; |
175 // Don't generate verbose messages if routines to dump messages are not | 179 // Don't generate verbose messages if routines to dump messages are not |
176 // available. | 180 // available. |
177 if (BuildDefs::dump()) { | 181 if (BuildDefs::dump()) { |
178 for (unsigned i = 0; i != Param.size(); ++i) | 182 for (unsigned i = 0; i != Param.size(); ++i) |
179 VMask |= Param[i]; | 183 VMask |= Param[i]; |
180 } | 184 } |
181 return VMask; | 185 return VMask; |
182 } | 186 } |
183 | 187 |
| 188 template <> |
| 189 ToSetterParam<cl::list<std::string>>::ReturnType |
| 190 toSetterParam(const cl::list<std::string> &Param) { |
| 191 return *&Param; |
| 192 } |
| 193 |
184 } // end of anonymous namespace | 194 } // end of anonymous namespace |
185 | 195 |
186 void ClFlags::getParsedClFlags(ClFlags &OutFlags) { | 196 void ClFlags::getParsedClFlags(ClFlags &OutFlags) { |
187 #define X(Name, Type, ClType, ...) OutFlags.set##Name(toSetterParam(Name##Obj)); | 197 #define X(Name, Type, ClType, ...) OutFlags.set##Name(toSetterParam(Name##Obj)); |
188 COMMAND_LINE_FLAGS | 198 COMMAND_LINE_FLAGS |
189 #undef X | 199 #undef X |
190 | 200 |
191 // If any value needs a non-trivial parsed value, set it below. | 201 // If any value needs a non-trivial parsed value, set it below. |
192 OutFlags.setAllowExternDefinedSymbols(AllowExternDefinedSymbolsObj || | 202 OutFlags.setAllowExternDefinedSymbols(AllowExternDefinedSymbolsObj || |
193 DisableInternalObj); | 203 DisableInternalObj); |
194 OutFlags.setDisableHybridAssembly(DisableHybridAssemblyObj || | 204 OutFlags.setDisableHybridAssembly(DisableHybridAssemblyObj || |
195 (OutFileTypeObj != Ice::FT_Iasm)); | 205 (OutFileTypeObj != Ice::FT_Iasm)); |
196 OutFlags.ForceO2.init(OutFlags.getForceO2String()); | 206 OutFlags.ForceO2.init(OutFlags.getForceO2String()); |
197 OutFlags.TestStatus.init(OutFlags.getTestStatusString()); | 207 OutFlags.TestStatus.init(OutFlags.getTestStatusString()); |
198 OutFlags.TimingFocus.init(OutFlags.getTimingFocusOnString()); | 208 OutFlags.TimingFocus.init(OutFlags.getTimingFocusOnString()); |
199 OutFlags.TranslateOnly.init(OutFlags.getTranslateOnlyString()); | 209 OutFlags.TranslateOnly.init(OutFlags.getTranslateOnlyString()); |
200 OutFlags.VerboseFocus.init(OutFlags.getVerboseFocusOnString()); | 210 OutFlags.VerboseFocus.init(OutFlags.getVerboseFocusOnString()); |
201 } | 211 } |
202 | 212 |
203 } // end of namespace Ice | 213 } // end of namespace Ice |
OLD | NEW |