llvm.org GIT mirror llvm / 48c8dfd
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300735 91177308-0d34-0410-b5e6-96231b3b80d8 Aditya Nandakumar 3 years ago
2 changed file(s) with 18 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
2626 std::string AggregateString;
2727
2828 public:
29 bool Empty() const { return StringOffset.empty(); }
30
2931 unsigned GetOrAddStringOffset(StringRef Str, bool appendZero = true) {
3032 auto IterBool =
3133 StringOffset.insert(std::make_pair(Str, AggregateString.size()));
8383 // Emit the intrinsic parameter attributes.
8484 EmitAttributes(Ints, OS);
8585
86 // Individual targets don't need GCC builtin name mappings.
87 if (!TargetOnly) {
88 // Emit code to translate GCC builtins into LLVM intrinsics.
89 EmitIntrinsicToBuiltinMap(Ints, true, OS);
90
91 // Emit code to translate MS builtins into LLVM intrinsics.
92 EmitIntrinsicToBuiltinMap(Ints, false, OS);
93 }
86 // Emit code to translate GCC builtins into LLVM intrinsics.
87 EmitIntrinsicToBuiltinMap(Ints, true, OS);
88
89 // Emit code to translate MS builtins into LLVM intrinsics.
90 EmitIntrinsicToBuiltinMap(Ints, false, OS);
9491
9592 EmitSuffix(OS);
9693 }
755752 << "Builtin(const char "
756753 << "*TargetPrefixStr, StringRef BuiltinNameStr) {\n";
757754 }
755
756 if (Table.Empty()) {
757 OS << " return ";
758 if (!TargetPrefix.empty())
759 OS << "(" << TargetPrefix << "Intrinsic::ID)";
760 OS << "Intrinsic::not_intrinsic;\n";
761 OS << "}\n";
762 OS << "#endif\n\n";
763 return;
764 }
765
758766 OS << " static const char BuiltinNames[] = {\n";
759767 Table.EmitCharArray(OS);
760768 OS << " };\n\n";