aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/CppBackend/CPPBackend.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-22 11:50:17 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-12-22 11:50:17 -0800
commit4d6cb4c875881b133177fd1548f79a1fa91dd099 (patch)
treeb55a7d9d7fbd40265c9ecc7df564b198853cd413 /lib/Target/CppBackend/CPPBackend.cpp
parent1e9d5df67061e962ed148d13258a903f03ce715c (diff)
limit # of vars on one line
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r--lib/Target/CppBackend/CPPBackend.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp
index 27cee90afe..988ddb6db5 100644
--- a/lib/Target/CppBackend/CPPBackend.cpp
+++ b/lib/Target/CppBackend/CPPBackend.cpp
@@ -41,6 +41,7 @@
#include <set> // TODO: unordered_set?
using namespace llvm;
+#include <OptPasses.h>
#include <Relooper.h>
#define dump(x) fprintf(stderr, x "\n")
@@ -1230,11 +1231,17 @@ void JSWriter::printFunctionBody(const Function *F) {
UsedVars["sp"] = Type::getInt32Ty(F->getContext())->getTypeID();
UsedVars["label"] = Type::getInt32Ty(F->getContext())->getTypeID();
if (!UsedVars.empty()) {
- Out << " var ";
+ unsigned Count = 0;
for (VarMap::iterator VI = UsedVars.begin(); VI != UsedVars.end(); ++VI) {
- if (VI != UsedVars.begin()) {
+ if (Count == 20) {
+ Out << ";\n";
+ Count = 0;
+ }
+ if (Count == 0) Out << " var ";
+ if (Count > 0) {
Out << ", ";
}
+ Count++;
Out << VI->first << " = ";
switch (VI->second) {
default:
@@ -1720,7 +1727,10 @@ bool CPPTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
bool DisableVerify,
AnalysisID StartAfter,
AnalysisID StopAfter) {
- if (FileType != TargetMachine::CGFT_AssemblyFile) return true;
+ assert(FileType == TargetMachine::CGFT_AssemblyFile);
+
PM.add(new JSWriter(o));
+
return false;
}
+