Skip to content

Commit 1423b88

Browse files
committed
fixup, Drop Twine and std::string
1 parent 11bc0bf commit 1423b88

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

llvm/utils/TableGen/VTEmitter.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/ADT/StringRef.h"
10-
#include "llvm/ADT/Twine.h"
1110
#include "llvm/Support/raw_ostream.h"
1211
#include "llvm/TableGen/Record.h"
1312
#include "llvm/TableGen/TableGenBackend.h"
1413
#include <array>
1514
#include <cassert>
1615
#include <map>
17-
#include <string>
1816
using namespace llvm;
1917

2018
namespace {
@@ -31,14 +29,11 @@ class VTEmitter {
3129

3230
} // End anonymous namespace.
3331

34-
std::string VTtoGetLLVMTyString(const Record *VT) {
32+
static void VTtoGetLLVMTyString(raw_ostream &OS, const Record *VT) {
3533
bool IsVector = VT->getValueAsBit("isVector");
36-
std::string GetLLVMTyString;
3734
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(";
4237

4338
auto OutputVT = IsVector ? VT->getValueAsDef("ElementType") : VT;
4439
int64_t OutputVTSize = OutputVT->getValueAsInt("Size");
@@ -65,18 +60,14 @@ std::string VTtoGetLLVMTyString(const Record *VT) {
6560
FloatTy = (OutputVTName == "ppcf128") ? "PPC_FP128Ty" : "FP128Ty";
6661
break;
6762
}
68-
GetLLVMTyString += (Twine("Type::get") + FloatTy + "(Context)").str();
63+
OS << "Type::get" << FloatTy << "(Context)";
6964
} else if (OutputVT->getValueAsBit("isInteger"))
70-
GetLLVMTyString +=
71-
(Twine("Type::getIntNTy(Context, ") + Twine(OutputVTSize) + ")").str();
65+
OS << "Type::getIntNTy(Context, " << OutputVTSize << ")";
7266
else
7367
llvm_unreachable("Unhandled case");
7468

7569
if (IsVector)
76-
GetLLVMTyString +=
77-
(Twine(", ") + std::to_string(VT->getValueAsInt("nElem")) + ")").str();
78-
79-
return GetLLVMTyString;
70+
OS << ", " << VT->getValueAsInt("nElem") << ")";
8071
}
8172

8273
void VTEmitter::run(raw_ostream &OS) {
@@ -192,8 +183,9 @@ void VTEmitter::run(raw_ostream &OS) {
192183
if (!IsInteger && !IsVector && !IsFP)
193184
continue;
194185

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";
197189
}
198190
OS << "#endif\n\n";
199191
}

0 commit comments

Comments
 (0)