@@ -71,11 +71,22 @@ Builtin::Context::getShardAndInfo(unsigned ID) const {
7171 llvm_unreachable (" Invalid target builtin shard structure!" );
7272}
7373
74+ std::string Builtin::Info::getName (const Builtin::InfosShard &Shard) const {
75+ return (Twine (Shard.NamePrefix ) + (*Shard.Strings )[Offsets.Name ]).str ();
76+ }
77+
7478// / Return the identifier name for the specified builtin,
7579// / e.g. "__builtin_abs".
76- llvm::StringRef Builtin::Context::getName (unsigned ID) const {
80+ std::string Builtin::Context::getName (unsigned ID) const {
7781 const auto &[Shard, I] = getShardAndInfo (ID);
78- return (*Shard.Strings )[I.Offsets .Name ];
82+ return I.getName (Shard);
83+ }
84+
85+ std::string Builtin::Context::getQuotedName (unsigned ID) const {
86+ const auto &[Shard, I] = getShardAndInfo (ID);
87+ return (Twine (" '" ) + Shard.NamePrefix + (*Shard.Strings )[I.Offsets .Name ] +
88+ " '" )
89+ .str ();
7990}
8091
8192const char *Builtin::Context::getTypeString (unsigned ID) const {
@@ -112,12 +123,14 @@ void Builtin::Context::InitializeTarget(const TargetInfo &Target,
112123bool Builtin::Context::isBuiltinFunc (llvm::StringRef FuncName) {
113124 bool InStdNamespace = FuncName.consume_front (" std-" );
114125 for (const auto &Shard : {InfosShard{&BuiltinStrings, BuiltinInfos}})
115- for (const auto &I : Shard.Infos )
116- if (FuncName == (*Shard.Strings )[I.Offsets .Name ] &&
117- (bool )strchr ((*Shard.Strings )[I.Offsets .Attributes ].data (), ' z' ) ==
118- InStdNamespace)
119- return strchr ((*Shard.Strings )[I.Offsets .Attributes ].data (), ' f' ) !=
120- nullptr ;
126+ if (llvm::StringRef FuncNameSuffix = FuncName;
127+ FuncNameSuffix.consume_front (Shard.NamePrefix ))
128+ for (const auto &I : Shard.Infos )
129+ if (FuncNameSuffix == (*Shard.Strings )[I.Offsets .Name ] &&
130+ (bool )strchr ((*Shard.Strings )[I.Offsets .Attributes ].data (), ' z' ) ==
131+ InStdNamespace)
132+ return strchr ((*Shard.Strings )[I.Offsets .Attributes ].data (), ' f' ) !=
133+ nullptr ;
121134
122135 return false ;
123136}
@@ -193,7 +206,7 @@ void Builtin::Context::initializeBuiltins(IdentifierTable &Table,
193206 for (const auto &I : Shard.Infos ) {
194207 // If this is a real builtin (ID != 0) and is supported, add it.
195208 if (ID != 0 && builtinIsSupported (*Shard.Strings , I, LangOpts))
196- Table.get ((* Shard. Strings )[I. Offsets . Name ] ).setBuiltinID (ID);
209+ Table.get (I. getName ( Shard) ).setBuiltinID (ID);
197210 ++ID;
198211 }
199212 assert (ID == FirstTSBuiltin && " Should have added all non-target IDs!" );
@@ -202,14 +215,14 @@ void Builtin::Context::initializeBuiltins(IdentifierTable &Table,
202215 for (const auto &Shard : TargetShards)
203216 for (const auto &I : Shard.Infos ) {
204217 if (builtinIsSupported (*Shard.Strings , I, LangOpts))
205- Table.get ((* Shard. Strings )[I. Offsets . Name ] ).setBuiltinID (ID);
218+ Table.get (I. getName ( Shard) ).setBuiltinID (ID);
206219 ++ID;
207220 }
208221
209222 // Step #3: Register target-specific builtins for AuxTarget.
210223 for (const auto &Shard : AuxTargetShards)
211224 for (const auto &I : Shard.Infos ) {
212- Table.get ((* Shard. Strings )[I. Offsets . Name ] ).setBuiltinID (ID);
225+ Table.get (I. getName ( Shard) ).setBuiltinID (ID);
213226 ++ID;
214227 }
215228 }
@@ -228,10 +241,6 @@ void Builtin::Context::initializeBuiltins(IdentifierTable &Table,
228241 }
229242}
230243
231- std::string Builtin::Context::getQuotedName (unsigned ID) const {
232- return (llvm::Twine (" '" ) + getName (ID) + " '" ).str ();
233- }
234-
235244unsigned Builtin::Context::getRequiredVectorWidth (unsigned ID) const {
236245 const char *WidthPos = ::strchr (getAttributesString (ID), ' V' );
237246 if (!WidthPos)
0 commit comments