Skip to content

Commit 1b7b3b8

Browse files
authored
[NFC] Move intrinsic related functions to Intrinsic namespace (#110125)
Move static functions `Function::lookupIntrinsicID` and `Function::isTargetIntrinsic` to Intrinsic namespace.
1 parent 38450df commit 1b7b3b8

File tree

10 files changed

+18
-18
lines changed

10 files changed

+18
-18
lines changed

llvm/include/llvm-c/Core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2795,7 +2795,7 @@ void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
27952795
/**
27962796
* Obtain the intrinsic ID number which matches the given function name.
27972797
*
2798-
* @see llvm::Function::lookupIntrinsicID()
2798+
* @see llvm::Intrinsic::lookupIntrinsicID()
27992799
*/
28002800
unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
28012801

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
15551555

15561556
// Assume that target intrinsics are cheap.
15571557
Intrinsic::ID IID = ICA.getID();
1558-
if (Function::isTargetIntrinsic(IID))
1558+
if (Intrinsic::isTargetIntrinsic(IID))
15591559
return TargetTransformInfo::TCC_Basic;
15601560

15611561
if (ICA.isTypeBasedOnly())

llvm/include/llvm/IR/Function.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,6 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
255255
/// returns Intrinsic::not_intrinsic!
256256
bool isIntrinsic() const { return HasLLVMReservedName; }
257257

258-
/// isTargetIntrinsic - Returns true if IID is an intrinsic specific to a
259-
/// certain target. If it is a generic intrinsic false is returned.
260-
static bool isTargetIntrinsic(Intrinsic::ID IID);
261-
262258
/// isTargetIntrinsic - Returns true if this function is an intrinsic and the
263259
/// intrinsic is specific to a certain target. If this is not an intrinsic
264260
/// or a generic intrinsic, false is returned.
@@ -269,8 +265,6 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
269265
/// getIntrinsicID() returns Intrinsic::not_intrinsic.
270266
bool isConstrainedFPIntrinsic() const;
271267

272-
static Intrinsic::ID lookupIntrinsicID(StringRef Name);
273-
274268
/// Update internal caches that depend on the function name (such as the
275269
/// intrinsic ID and libcall cache).
276270
/// Note, this method does not need to be called directly, as it is called

llvm/include/llvm/IR/Intrinsics.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ namespace Intrinsic {
7878
/// Returns true if the intrinsic can be overloaded.
7979
bool isOverloaded(ID id);
8080

81+
/// isTargetIntrinsic - Returns true if IID is an intrinsic specific to a
82+
/// certain target. If it is a generic intrinsic false is returned.
83+
bool isTargetIntrinsic(ID IID);
84+
85+
ID lookupIntrinsicID(StringRef Name);
86+
8187
/// Return the attributes for an intrinsic.
8288
AttributeList getAttributes(LLVMContext &C, ID id);
8389

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
338338

339339
for (const auto &[Name, Info] : make_early_inc_range(ForwardRefVals)) {
340340
if (StringRef(Name).starts_with("llvm.")) {
341-
Intrinsic::ID IID = Function::lookupIntrinsicID(Name);
341+
Intrinsic::ID IID = Intrinsic::lookupIntrinsicID(Name);
342342
if (IID == Intrinsic::not_intrinsic)
343343
// Don't do anything for unknown intrinsics.
344344
continue;
@@ -6301,7 +6301,7 @@ bool isOldDbgFormatIntrinsic(StringRef Name) {
63016301
// intrinsics in the new debug info format.
63026302
if (!Name.starts_with("llvm.dbg."))
63036303
return false;
6304-
Intrinsic::ID FnID = Function::lookupIntrinsicID(Name);
6304+
Intrinsic::ID FnID = Intrinsic::lookupIntrinsicID(Name);
63056305
return FnID == Intrinsic::dbg_declare || FnID == Intrinsic::dbg_value ||
63066306
FnID == Intrinsic::dbg_assign;
63076307
}

llvm/lib/CodeGen/MIRParser/MIParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2654,7 +2654,7 @@ bool MIParser::parseIntrinsicOperand(MachineOperand &Dest) {
26542654
// Find out what intrinsic we're dealing with, first try the global namespace
26552655
// and then the target's private intrinsics if that fails.
26562656
const TargetIntrinsicInfo *TII = MF.getTarget().getIntrinsicInfo();
2657-
Intrinsic::ID ID = Function::lookupIntrinsicID(Name);
2657+
Intrinsic::ID ID = Intrinsic::lookupIntrinsicID(Name);
26582658
if (ID == Intrinsic::not_intrinsic && TII)
26592659
ID = static_cast<Intrinsic::ID>(TII->lookupName(Name));
26602660

llvm/lib/IR/Core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2508,7 +2508,7 @@ const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
25082508
}
25092509

25102510
unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen) {
2511-
return Function::lookupIntrinsicID({Name, NameLen});
2511+
return Intrinsic::lookupIntrinsicID({Name, NameLen});
25122512
}
25132513

25142514
LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID) {

llvm/lib/IR/Function.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -952,12 +952,12 @@ static constexpr const char *const IntrinsicNameTable[] = {
952952
#include "llvm/IR/IntrinsicImpl.inc"
953953
#undef GET_INTRINSIC_TARGET_DATA
954954

955-
bool Function::isTargetIntrinsic(Intrinsic::ID IID) {
955+
bool Intrinsic::isTargetIntrinsic(Intrinsic::ID IID) {
956956
return IID > TargetInfos[0].Count;
957957
}
958958

959959
bool Function::isTargetIntrinsic() const {
960-
return isTargetIntrinsic(IntID);
960+
return Intrinsic::isTargetIntrinsic(IntID);
961961
}
962962

963963
/// Find the segment of \c IntrinsicNameTable for intrinsics with the same
@@ -982,7 +982,7 @@ findTargetSubtable(StringRef Name) {
982982

983983
/// This does the actual lookup of an intrinsic ID which matches the given
984984
/// function name.
985-
Intrinsic::ID Function::lookupIntrinsicID(StringRef Name) {
985+
Intrinsic::ID Intrinsic::lookupIntrinsicID(StringRef Name) {
986986
auto [NameTable, Target] = findTargetSubtable(Name);
987987
int Idx = Intrinsic::lookupLLVMIntrinsicByName(NameTable, Name, Target);
988988
if (Idx == -1)
@@ -1011,7 +1011,7 @@ void Function::updateAfterNameChange() {
10111011
return;
10121012
}
10131013
HasLLVMReservedName = true;
1014-
IntID = lookupIntrinsicID(Name);
1014+
IntID = Intrinsic::lookupIntrinsicID(Name);
10151015
}
10161016

10171017
/// Returns a stable mangling for the type specified for use in the name

llvm/lib/Transforms/Scalar/Scalarizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ bool ScalarizerVisitor::splitBinary(Instruction &I, const Splitter &Split) {
700700
bool ScalarizerVisitor::isTriviallyScalarizable(Intrinsic::ID ID) {
701701
if (isTriviallyVectorizable(ID))
702702
return true;
703-
return Function::isTargetIntrinsic(ID) &&
703+
return Intrinsic::isTargetIntrinsic(ID) &&
704704
TTI->isTargetIntrinsicTriviallyScalarizable(ID);
705705
}
706706

mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ convertCallLLVMIntrinsicOp(CallIntrinsicOp op, llvm::IRBuilderBase &builder,
130130
LLVM::ModuleTranslation &moduleTranslation) {
131131
llvm::Module *module = builder.GetInsertBlock()->getModule();
132132
llvm::Intrinsic::ID id =
133-
llvm::Function::lookupIntrinsicID(op.getIntrinAttr());
133+
llvm::Intrinsic::lookupIntrinsicID(op.getIntrinAttr());
134134
if (!id)
135135
return mlir::emitError(op.getLoc(), "could not find LLVM intrinsic: ")
136136
<< op.getIntrinAttr();

0 commit comments

Comments
 (0)