[llvm] r283792 - Use StringRef in TableGen generated Intrinsics.gen file (NFC)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 10 12:31:09 PDT 2016
Author: mehdi_amini
Date: Mon Oct 10 14:31:09 2016
New Revision: 283792
URL: http://llvm.org/viewvc/llvm-project?rev=283792&view=rev
Log:
Use StringRef in TableGen generated Intrinsics.gen file (NFC)
Modified:
llvm/trunk/include/llvm/IR/Intrinsics.h
llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
Modified: llvm/trunk/include/llvm/IR/Intrinsics.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Intrinsics.h?rev=283792&r1=283791&r2=283792&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Intrinsics.h (original)
+++ llvm/trunk/include/llvm/IR/Intrinsics.h Mon Oct 10 14:31:09 2016
@@ -88,10 +88,10 @@ namespace Intrinsic {
StringRef Name);
/// Map a GCC builtin name to an intrinsic ID.
- ID getIntrinsicForGCCBuiltin(const char *Prefix, const char *BuiltinName);
+ ID getIntrinsicForGCCBuiltin(const char *Prefix, StringRef BuiltinName);
/// Map a MS builtin name to an intrinsic ID.
- ID getIntrinsicForMSBuiltin(const char *Prefix, const char *BuiltinName);
+ ID getIntrinsicForMSBuiltin(const char *Prefix, StringRef BuiltinName);
/// This is a type descriptor which explains the type requirements of an
/// intrinsic. This is returned by getIntrinsicInfoTableEntries.
Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp?rev=283792&r1=283791&r2=283792&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Mon Oct 10 14:31:09 2016
@@ -714,11 +714,11 @@ void IntrinsicEmitter::EmitIntrinsicToBu
if (TargetOnly) {
OS << "static " << TargetPrefix << "Intrinsic::ID "
<< "getIntrinsicFor" << CompilerName << "Builtin(const char "
- << "*TargetPrefixStr, const char *BuiltinNameStr) {\n";
+ << "*TargetPrefixStr, StringRef BuiltinNameStr) {\n";
} else {
OS << "Intrinsic::ID Intrinsic::getIntrinsicFor" << CompilerName
<< "Builtin(const char "
- << "*TargetPrefixStr, const char *BuiltinNameStr) {\n";
+ << "*TargetPrefixStr, StringRef BuiltinNameStr) {\n";
}
OS << " static const char BuiltinNames[] = {\n";
Table.EmitCharArray(OS);
@@ -730,13 +730,11 @@ void IntrinsicEmitter::EmitIntrinsicToBu
OS << " const char *getName() const {\n";
OS << " return &BuiltinNames[StrTabOffset];\n";
OS << " }\n";
- OS << " bool operator<(const char *RHS) const {\n";
- OS << " return strcmp(getName(), RHS) < 0;\n";
+ OS << " bool operator<(StringRef RHS) const {\n";
+ OS << " return strncmp(getName(), RHS.data(), RHS.size()) < 0;\n";
OS << " }\n";
OS << " };\n";
-
- OS << " StringRef BuiltinName(BuiltinNameStr);\n";
OS << " StringRef TargetPrefix(TargetPrefixStr);\n\n";
// Note: this could emit significantly better code if we cared.
@@ -759,7 +757,7 @@ void IntrinsicEmitter::EmitIntrinsicToBu
OS << " std::end(" << I->first << "Names),\n";
OS << " BuiltinNameStr);\n";
OS << " if (I != std::end(" << I->first << "Names) &&\n";
- OS << " strcmp(I->getName(), BuiltinNameStr) == 0)\n";
+ OS << " I->getName() == BuiltinNameStr)\n";
OS << " return I->IntrinID;\n";
OS << " }\n";
}
More information about the llvm-commits
mailing list