[llvm] r300735 - [tblgen] GCC/MS builtin to target intrisics map.
Aditya Nandakumar via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 19 12:14:21 PDT 2017
Author: aditya_nandakumar
Date: Wed Apr 19 14:14:20 2017
New Revision: 300735
URL: http://llvm.org/viewvc/llvm-project?rev=300735&view=rev
Log:
[tblgen] GCC/MS builtin to target intrisics map.
Patch by Ettore Speziale
Allow TableGen to generate static functions to perform GCC/MS builtin name to
target specific intrinsic ID mapping.
https://reviews.llvm.org/D31150
Modified:
llvm/trunk/include/llvm/TableGen/StringToOffsetTable.h
llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
Modified: llvm/trunk/include/llvm/TableGen/StringToOffsetTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/StringToOffsetTable.h?rev=300735&r1=300734&r2=300735&view=diff
==============================================================================
--- llvm/trunk/include/llvm/TableGen/StringToOffsetTable.h (original)
+++ llvm/trunk/include/llvm/TableGen/StringToOffsetTable.h Wed Apr 19 14:14:20 2017
@@ -27,6 +27,8 @@ class StringToOffsetTable {
std::string AggregateString;
public:
+ bool Empty() const { return StringOffset.empty(); }
+
unsigned GetOrAddStringOffset(StringRef Str, bool appendZero = true) {
auto IterBool =
StringOffset.insert(std::make_pair(Str, AggregateString.size()));
Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp?rev=300735&r1=300734&r2=300735&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Wed Apr 19 14:14:20 2017
@@ -84,14 +84,11 @@ void IntrinsicEmitter::run(raw_ostream &
// Emit the intrinsic parameter attributes.
EmitAttributes(Ints, OS);
- // Individual targets don't need GCC builtin name mappings.
- if (!TargetOnly) {
- // Emit code to translate GCC builtins into LLVM intrinsics.
- EmitIntrinsicToBuiltinMap(Ints, true, OS);
+ // Emit code to translate GCC builtins into LLVM intrinsics.
+ EmitIntrinsicToBuiltinMap(Ints, true, OS);
- // Emit code to translate MS builtins into LLVM intrinsics.
- EmitIntrinsicToBuiltinMap(Ints, false, OS);
- }
+ // Emit code to translate MS builtins into LLVM intrinsics.
+ EmitIntrinsicToBuiltinMap(Ints, false, OS);
EmitSuffix(OS);
}
@@ -756,6 +753,17 @@ void IntrinsicEmitter::EmitIntrinsicToBu
<< "Builtin(const char "
<< "*TargetPrefixStr, StringRef BuiltinNameStr) {\n";
}
+
+ if (Table.Empty()) {
+ OS << " return ";
+ if (!TargetPrefix.empty())
+ OS << "(" << TargetPrefix << "Intrinsic::ID)";
+ OS << "Intrinsic::not_intrinsic;\n";
+ OS << "}\n";
+ OS << "#endif\n\n";
+ return;
+ }
+
OS << " static const char BuiltinNames[] = {\n";
Table.EmitCharArray(OS);
OS << " };\n\n";
More information about the llvm-commits
mailing list