Skip to content

[NFC] Move intrinsic related functions to Intrinsic namespace #110125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm-c/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -2795,7 +2795,7 @@ void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn);
/**
* Obtain the intrinsic ID number which matches the given function name.
*
* @see llvm::Function::lookupIntrinsicID()
* @see llvm::Intrinsic::lookupIntrinsicID()
*/
unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/CodeGen/BasicTTIImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {

// Assume that target intrinsics are cheap.
Intrinsic::ID IID = ICA.getID();
if (Function::isTargetIntrinsic(IID))
if (Intrinsic::isTargetIntrinsic(IID))
return TargetTransformInfo::TCC_Basic;

if (ICA.isTypeBasedOnly())
Expand Down
6 changes: 0 additions & 6 deletions llvm/include/llvm/IR/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,6 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
/// returns Intrinsic::not_intrinsic!
bool isIntrinsic() const { return HasLLVMReservedName; }

/// isTargetIntrinsic - Returns true if IID is an intrinsic specific to a
/// certain target. If it is a generic intrinsic false is returned.
static bool isTargetIntrinsic(Intrinsic::ID IID);

/// isTargetIntrinsic - Returns true if this function is an intrinsic and the
/// intrinsic is specific to a certain target. If this is not an intrinsic
/// or a generic intrinsic, false is returned.
Expand All @@ -269,8 +265,6 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
/// getIntrinsicID() returns Intrinsic::not_intrinsic.
bool isConstrainedFPIntrinsic() const;

static Intrinsic::ID lookupIntrinsicID(StringRef Name);

/// Update internal caches that depend on the function name (such as the
/// intrinsic ID and libcall cache).
/// Note, this method does not need to be called directly, as it is called
Expand Down
6 changes: 6 additions & 0 deletions llvm/include/llvm/IR/Intrinsics.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ namespace Intrinsic {
/// Returns true if the intrinsic can be overloaded.
bool isOverloaded(ID id);

/// isTargetIntrinsic - Returns true if IID is an intrinsic specific to a
/// certain target. If it is a generic intrinsic false is returned.
bool isTargetIntrinsic(ID IID);

ID lookupIntrinsicID(StringRef Name);

/// Return the attributes for an intrinsic.
AttributeList getAttributes(LLVMContext &C, ID id);

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/AsmParser/LLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {

for (const auto &[Name, Info] : make_early_inc_range(ForwardRefVals)) {
if (StringRef(Name).starts_with("llvm.")) {
Intrinsic::ID IID = Function::lookupIntrinsicID(Name);
Intrinsic::ID IID = Intrinsic::lookupIntrinsicID(Name);
if (IID == Intrinsic::not_intrinsic)
// Don't do anything for unknown intrinsics.
continue;
Expand Down Expand Up @@ -6301,7 +6301,7 @@ bool isOldDbgFormatIntrinsic(StringRef Name) {
// intrinsics in the new debug info format.
if (!Name.starts_with("llvm.dbg."))
return false;
Intrinsic::ID FnID = Function::lookupIntrinsicID(Name);
Intrinsic::ID FnID = Intrinsic::lookupIntrinsicID(Name);
return FnID == Intrinsic::dbg_declare || FnID == Intrinsic::dbg_value ||
FnID == Intrinsic::dbg_assign;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MIRParser/MIParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2654,7 +2654,7 @@ bool MIParser::parseIntrinsicOperand(MachineOperand &Dest) {
// Find out what intrinsic we're dealing with, first try the global namespace
// and then the target's private intrinsics if that fails.
const TargetIntrinsicInfo *TII = MF.getTarget().getIntrinsicInfo();
Intrinsic::ID ID = Function::lookupIntrinsicID(Name);
Intrinsic::ID ID = Intrinsic::lookupIntrinsicID(Name);
if (ID == Intrinsic::not_intrinsic && TII)
ID = static_cast<Intrinsic::ID>(TII->lookupName(Name));

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2508,7 +2508,7 @@ const char *LLVMIntrinsicCopyOverloadedName2(LLVMModuleRef Mod, unsigned ID,
}

unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen) {
return Function::lookupIntrinsicID({Name, NameLen});
return Intrinsic::lookupIntrinsicID({Name, NameLen});
}

LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID) {
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/IR/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,12 +952,12 @@ static constexpr const char *const IntrinsicNameTable[] = {
#include "llvm/IR/IntrinsicImpl.inc"
#undef GET_INTRINSIC_TARGET_DATA

bool Function::isTargetIntrinsic(Intrinsic::ID IID) {
bool Intrinsic::isTargetIntrinsic(Intrinsic::ID IID) {
return IID > TargetInfos[0].Count;
}

bool Function::isTargetIntrinsic() const {
return isTargetIntrinsic(IntID);
return Intrinsic::isTargetIntrinsic(IntID);
}

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

/// This does the actual lookup of an intrinsic ID which matches the given
/// function name.
Intrinsic::ID Function::lookupIntrinsicID(StringRef Name) {
Intrinsic::ID Intrinsic::lookupIntrinsicID(StringRef Name) {
auto [NameTable, Target] = findTargetSubtable(Name);
int Idx = Intrinsic::lookupLLVMIntrinsicByName(NameTable, Name, Target);
if (Idx == -1)
Expand Down Expand Up @@ -1011,7 +1011,7 @@ void Function::updateAfterNameChange() {
return;
}
HasLLVMReservedName = true;
IntID = lookupIntrinsicID(Name);
IntID = Intrinsic::lookupIntrinsicID(Name);
}

/// Returns a stable mangling for the type specified for use in the name
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/Scalarizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ bool ScalarizerVisitor::splitBinary(Instruction &I, const Splitter &Split) {
bool ScalarizerVisitor::isTriviallyScalarizable(Intrinsic::ID ID) {
if (isTriviallyVectorizable(ID))
return true;
return Function::isTargetIntrinsic(ID) &&
return Intrinsic::isTargetIntrinsic(ID) &&
TTI->isTargetIntrinsicTriviallyScalarizable(ID);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ convertCallLLVMIntrinsicOp(CallIntrinsicOp op, llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation) {
llvm::Module *module = builder.GetInsertBlock()->getModule();
llvm::Intrinsic::ID id =
llvm::Function::lookupIntrinsicID(op.getIntrinAttr());
llvm::Intrinsic::lookupIntrinsicID(op.getIntrinAttr());
if (!id)
return mlir::emitError(op.getLoc(), "could not find LLVM intrinsic: ")
<< op.getIntrinAttr();
Expand Down
Loading