Skip to content

Commit c2b61fc

Browse files
authored
[NFC][LLVM] Use namespace Intrinsic in Intrinsics.cpp (llvm#114822)
Add `using namespace Intrinsic` to Intrinsics.cpp file.
1 parent 2c13dec commit c2b61fc

File tree

1 file changed

+40
-52
lines changed

1 file changed

+40
-52
lines changed

llvm/lib/IR/Intrinsics.cpp

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "llvm/IR/Type.h"
3333

3434
using namespace llvm;
35+
using namespace Intrinsic;
3536

3637
/// Table of string intrinsic names indexed by enum value.
3738
static constexpr const char *const IntrinsicNameTable[] = {
@@ -48,7 +49,7 @@ StringRef Intrinsic::getBaseName(ID id) {
4849

4950
StringRef Intrinsic::getName(ID id) {
5051
assert(id < num_intrinsics && "Invalid intrinsic ID!");
51-
assert(!Intrinsic::isOverloaded(id) &&
52+
assert(!isOverloaded(id) &&
5253
"This version of getName does not support overloading");
5354
return getBaseName(id);
5455
}
@@ -151,27 +152,27 @@ static std::string getMangledTypeStr(Type *Ty, bool &HasUnnamedType) {
151152
return Result;
152153
}
153154

154-
static std::string getIntrinsicNameImpl(Intrinsic::ID Id, ArrayRef<Type *> Tys,
155-
Module *M, FunctionType *FT,
155+
static std::string getIntrinsicNameImpl(ID Id, ArrayRef<Type *> Tys, Module *M,
156+
FunctionType *FT,
156157
bool EarlyModuleCheck) {
157158

158-
assert(Id < Intrinsic::num_intrinsics && "Invalid intrinsic ID!");
159-
assert((Tys.empty() || Intrinsic::isOverloaded(Id)) &&
159+
assert(Id < num_intrinsics && "Invalid intrinsic ID!");
160+
assert((Tys.empty() || isOverloaded(Id)) &&
160161
"This version of getName is for overloaded intrinsics only");
161162
(void)EarlyModuleCheck;
162163
assert((!EarlyModuleCheck || M ||
163164
!any_of(Tys, [](Type *T) { return isa<PointerType>(T); })) &&
164165
"Intrinsic overloading on pointer types need to provide a Module");
165166
bool HasUnnamedType = false;
166-
std::string Result(Intrinsic::getBaseName(Id));
167+
std::string Result(getBaseName(Id));
167168
for (Type *Ty : Tys)
168169
Result += "." + getMangledTypeStr(Ty, HasUnnamedType);
169170
if (HasUnnamedType) {
170171
assert(M && "unnamed types need a module");
171172
if (!FT)
172-
FT = Intrinsic::getType(M->getContext(), Id, Tys);
173+
FT = getType(M->getContext(), Id, Tys);
173174
else
174-
assert((FT == Intrinsic::getType(M->getContext(), Id, Tys)) &&
175+
assert((FT == getType(M->getContext(), Id, Tys)) &&
175176
"Provided FunctionType must match arguments");
176177
return M->getUniqueIntrinsicName(Result, Id, FT);
177178
}
@@ -198,13 +199,10 @@ enum IIT_Info {
198199
#undef GET_INTRINSIC_IITINFO
199200
};
200201

201-
static void
202-
DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos,
203-
IIT_Info LastInfo,
204-
SmallVectorImpl<Intrinsic::IITDescriptor> &OutputTable) {
205-
using namespace Intrinsic;
206-
207-
bool IsScalableVector = (LastInfo == IIT_SCALABLE_VEC);
202+
static void DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos,
203+
IIT_Info LastInfo,
204+
SmallVectorImpl<IITDescriptor> &OutputTable) {
205+
bool IsScalableVector = LastInfo == IIT_SCALABLE_VEC;
208206

209207
IIT_Info Info = IIT_Info(Infos[NextElt++]);
210208
unsigned StructElts = 2;
@@ -481,10 +479,8 @@ void Intrinsic::getIntrinsicInfoTableEntries(
481479
DecodeIITType(NextElt, IITEntries, IIT_Done, T);
482480
}
483481

484-
static Type *DecodeFixedType(ArrayRef<Intrinsic::IITDescriptor> &Infos,
482+
static Type *DecodeFixedType(ArrayRef<IITDescriptor> &Infos,
485483
ArrayRef<Type *> Tys, LLVMContext &Context) {
486-
using namespace Intrinsic;
487-
488484
IITDescriptor D = Infos.front();
489485
Infos = Infos.slice(1);
490486

@@ -617,13 +613,10 @@ bool Intrinsic::isOverloaded(ID id) {
617613
#include "llvm/IR/IntrinsicImpl.inc"
618614
#undef GET_INTRINSIC_TARGET_DATA
619615

620-
bool Intrinsic::isTargetIntrinsic(Intrinsic::ID IID) {
621-
return IID > TargetInfos[0].Count;
622-
}
616+
bool Intrinsic::isTargetIntrinsic(ID IID) { return IID > TargetInfos[0].Count; }
623617

624-
int llvm::Intrinsic::lookupLLVMIntrinsicByName(ArrayRef<const char *> NameTable,
625-
StringRef Name,
626-
StringRef Target) {
618+
int Intrinsic::lookupLLVMIntrinsicByName(ArrayRef<const char *> NameTable,
619+
StringRef Name, StringRef Target) {
627620
assert(Name.starts_with("llvm.") && "Unexpected intrinsic prefix");
628621
assert(Name.drop_front(5).starts_with(Target) && "Unexpected target");
629622

@@ -685,24 +678,23 @@ findTargetSubtable(StringRef Name) {
685678

686679
/// This does the actual lookup of an intrinsic ID which matches the given
687680
/// function name.
688-
Intrinsic::ID Intrinsic::lookupIntrinsicID(StringRef Name) {
681+
ID Intrinsic::lookupIntrinsicID(StringRef Name) {
689682
auto [NameTable, Target] = findTargetSubtable(Name);
690-
int Idx = Intrinsic::lookupLLVMIntrinsicByName(NameTable, Name, Target);
683+
int Idx = lookupLLVMIntrinsicByName(NameTable, Name, Target);
691684
if (Idx == -1)
692-
return Intrinsic::not_intrinsic;
685+
return not_intrinsic;
693686

694687
// Intrinsic IDs correspond to the location in IntrinsicNameTable, but we have
695688
// an index into a sub-table.
696689
int Adjust = NameTable.data() - IntrinsicNameTable;
697-
Intrinsic::ID ID = static_cast<Intrinsic::ID>(Idx + Adjust);
690+
ID Id = static_cast<ID>(Idx + Adjust);
698691

699692
// If the intrinsic is not overloaded, require an exact match. If it is
700693
// overloaded, require either exact or prefix match.
701694
const auto MatchSize = strlen(NameTable[Idx]);
702695
assert(Name.size() >= MatchSize && "Expected either exact or prefix match");
703696
bool IsExactMatch = Name.size() == MatchSize;
704-
return IsExactMatch || Intrinsic::isOverloaded(ID) ? ID
705-
: Intrinsic::not_intrinsic;
697+
return IsExactMatch || isOverloaded(Id) ? Id : not_intrinsic;
706698
}
707699

708700
/// This defines the "Intrinsic::getAttributes(ID id)" method.
@@ -743,8 +735,7 @@ Function *Intrinsic::getDeclarationIfExists(Module *M, ID id,
743735

744736
bool Intrinsic::isConstrainedFPIntrinsic(ID QID) {
745737
switch (QID) {
746-
#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
747-
case Intrinsic::INTRINSIC:
738+
#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) case INTRINSIC:
748739
#include "llvm/IR/ConstrainedOps.def"
749740
#undef INSTRUCTION
750741
return true;
@@ -753,10 +744,10 @@ bool Intrinsic::isConstrainedFPIntrinsic(ID QID) {
753744
}
754745
}
755746

756-
bool Intrinsic::hasConstrainedFPRoundingModeOperand(Intrinsic::ID QID) {
747+
bool Intrinsic::hasConstrainedFPRoundingModeOperand(ID QID) {
757748
switch (QID) {
758749
#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC) \
759-
case Intrinsic::INTRINSIC: \
750+
case INTRINSIC: \
760751
return ROUND_MODE == 1;
761752
#include "llvm/IR/ConstrainedOps.def"
762753
#undef INSTRUCTION
@@ -765,16 +756,13 @@ bool Intrinsic::hasConstrainedFPRoundingModeOperand(Intrinsic::ID QID) {
765756
}
766757
}
767758

768-
using DeferredIntrinsicMatchPair =
769-
std::pair<Type *, ArrayRef<Intrinsic::IITDescriptor>>;
759+
using DeferredIntrinsicMatchPair = std::pair<Type *, ArrayRef<IITDescriptor>>;
770760

771761
static bool
772-
matchIntrinsicType(Type *Ty, ArrayRef<Intrinsic::IITDescriptor> &Infos,
762+
matchIntrinsicType(Type *Ty, ArrayRef<IITDescriptor> &Infos,
773763
SmallVectorImpl<Type *> &ArgTys,
774764
SmallVectorImpl<DeferredIntrinsicMatchPair> &DeferredChecks,
775765
bool IsDeferredCheck) {
776-
using namespace Intrinsic;
777-
778766
// If we ran out of descriptors, there are too many arguments.
779767
if (Infos.empty())
780768
return true;
@@ -993,9 +981,9 @@ matchIntrinsicType(Type *Ty, ArrayRef<Intrinsic::IITDescriptor> &Infos,
993981
llvm_unreachable("unhandled");
994982
}
995983

996-
Intrinsic::MatchIntrinsicTypesResult
984+
MatchIntrinsicTypesResult
997985
Intrinsic::matchIntrinsicSignature(FunctionType *FTy,
998-
ArrayRef<Intrinsic::IITDescriptor> &Infos,
986+
ArrayRef<IITDescriptor> &Infos,
999987
SmallVectorImpl<Type *> &ArgTys) {
1000988
SmallVector<DeferredIntrinsicMatchPair, 2> DeferredChecks;
1001989
if (matchIntrinsicType(FTy->getReturnType(), Infos, ArgTys, DeferredChecks,
@@ -1019,8 +1007,8 @@ Intrinsic::matchIntrinsicSignature(FunctionType *FTy,
10191007
return MatchIntrinsicTypes_Match;
10201008
}
10211009

1022-
bool Intrinsic::matchIntrinsicVarArg(
1023-
bool isVarArg, ArrayRef<Intrinsic::IITDescriptor> &Infos) {
1010+
bool Intrinsic::matchIntrinsicVarArg(bool isVarArg,
1011+
ArrayRef<IITDescriptor> &Infos) {
10241012
// If there are no descriptors left, then it can't be a vararg.
10251013
if (Infos.empty())
10261014
return isVarArg;
@@ -1038,20 +1026,20 @@ bool Intrinsic::matchIntrinsicVarArg(
10381026
return true;
10391027
}
10401028

1041-
bool Intrinsic::getIntrinsicSignature(Intrinsic::ID ID, FunctionType *FT,
1029+
bool Intrinsic::getIntrinsicSignature(ID ID, FunctionType *FT,
10421030
SmallVectorImpl<Type *> &ArgTys) {
10431031
if (!ID)
10441032
return false;
10451033

1046-
SmallVector<Intrinsic::IITDescriptor, 8> Table;
1034+
SmallVector<IITDescriptor, 8> Table;
10471035
getIntrinsicInfoTableEntries(ID, Table);
1048-
ArrayRef<Intrinsic::IITDescriptor> TableRef = Table;
1036+
ArrayRef<IITDescriptor> TableRef = Table;
10491037

1050-
if (Intrinsic::matchIntrinsicSignature(FT, TableRef, ArgTys) !=
1051-
Intrinsic::MatchIntrinsicTypesResult::MatchIntrinsicTypes_Match) {
1038+
if (matchIntrinsicSignature(FT, TableRef, ArgTys) !=
1039+
MatchIntrinsicTypesResult::MatchIntrinsicTypes_Match) {
10521040
return false;
10531041
}
1054-
if (Intrinsic::matchIntrinsicVarArg(FT->isVarArg(), TableRef))
1042+
if (matchIntrinsicVarArg(FT->isVarArg(), TableRef))
10551043
return false;
10561044
return true;
10571045
}
@@ -1067,10 +1055,10 @@ std::optional<Function *> Intrinsic::remangleIntrinsicFunction(Function *F) {
10671055
if (!getIntrinsicSignature(F, ArgTys))
10681056
return std::nullopt;
10691057

1070-
Intrinsic::ID ID = F->getIntrinsicID();
1058+
ID ID = F->getIntrinsicID();
10711059
StringRef Name = F->getName();
10721060
std::string WantedName =
1073-
Intrinsic::getName(ID, ArgTys, F->getParent(), F->getFunctionType());
1061+
getName(ID, ArgTys, F->getParent(), F->getFunctionType());
10741062
if (Name == WantedName)
10751063
return std::nullopt;
10761064

@@ -1086,7 +1074,7 @@ std::optional<Function *> Intrinsic::remangleIntrinsicFunction(Function *F) {
10861074
// invalid and we'll get an error.
10871075
ExistingGV->setName(WantedName + ".renamed");
10881076
}
1089-
return Intrinsic::getOrInsertDeclaration(F->getParent(), ID, ArgTys);
1077+
return getOrInsertDeclaration(F->getParent(), ID, ArgTys);
10901078
}();
10911079

10921080
NewDecl->setCallingConv(F->getCallingConv());

0 commit comments

Comments
 (0)