7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " llvm/ADT/StringRef.h"
10
- #include " llvm/ADT/Twine.h"
11
10
#include " llvm/Support/raw_ostream.h"
12
11
#include " llvm/TableGen/Record.h"
13
12
#include " llvm/TableGen/TableGenBackend.h"
14
13
#include < array>
15
14
#include < cassert>
16
15
#include < map>
17
- #include < string>
18
16
using namespace llvm ;
19
17
20
18
namespace {
@@ -31,14 +29,11 @@ class VTEmitter {
31
29
32
30
} // End anonymous namespace.
33
31
34
- std::string VTtoGetLLVMTyString (const Record *VT) {
32
+ static void VTtoGetLLVMTyString (raw_ostream &OS, const Record *VT) {
35
33
bool IsVector = VT->getValueAsBit (" isVector" );
36
- std::string GetLLVMTyString;
37
34
if (IsVector)
38
- GetLLVMTyString +=
39
- (Twine (VT->getValueAsBit (" isScalable" ) ? " Scalable" : " Fixed" ) +
40
- " VectorType::get(" )
41
- .str ();
35
+ OS << (VT->getValueAsBit (" isScalable" ) ? " Scalable" : " Fixed" )
36
+ << " VectorType::get(" ;
42
37
43
38
auto OutputVT = IsVector ? VT->getValueAsDef (" ElementType" ) : VT;
44
39
int64_t OutputVTSize = OutputVT->getValueAsInt (" Size" );
@@ -65,18 +60,14 @@ std::string VTtoGetLLVMTyString(const Record *VT) {
65
60
FloatTy = (OutputVTName == " ppcf128" ) ? " PPC_FP128Ty" : " FP128Ty" ;
66
61
break ;
67
62
}
68
- GetLLVMTyString += ( Twine ( " Type::get" ) + FloatTy + " (Context)" ). str () ;
63
+ OS << " Type::get" << FloatTy << " (Context)" ;
69
64
} else if (OutputVT->getValueAsBit (" isInteger" ))
70
- GetLLVMTyString +=
71
- (Twine (" Type::getIntNTy(Context, " ) + Twine (OutputVTSize) + " )" ).str ();
65
+ OS << " Type::getIntNTy(Context, " << OutputVTSize << " )" ;
72
66
else
73
67
llvm_unreachable (" Unhandled case" );
74
68
75
69
if (IsVector)
76
- GetLLVMTyString +=
77
- (Twine (" , " ) + std::to_string (VT->getValueAsInt (" nElem" )) + " )" ).str ();
78
-
79
- return GetLLVMTyString;
70
+ OS << " , " << VT->getValueAsInt (" nElem" ) << " )" ;
80
71
}
81
72
82
73
void VTEmitter::run (raw_ostream &OS) {
@@ -192,8 +183,9 @@ void VTEmitter::run(raw_ostream &OS) {
192
183
if (!IsInteger && !IsVector && !IsFP)
193
184
continue ;
194
185
195
- OS << " GET_VT_EVT(" << VT->getValueAsString (" LLVMName" ) << " , "
196
- << VTtoGetLLVMTyString (VT) << " )\n " ;
186
+ OS << " GET_VT_EVT(" << VT->getValueAsString (" LLVMName" ) << " , " ;
187
+ VTtoGetLLVMTyString (OS, VT);
188
+ OS << " )\n " ;
197
189
}
198
190
OS << " #endif\n\n " ;
199
191
}
0 commit comments