From 3ee2ea86258923be31cd7d4d344d2e124f4dbb0f Mon Sep 17 00:00:00 2001 From: Anand Shukla Date: Sun, 21 Jul 2002 09:35:01 +0000 Subject: [PATCH] Adding code for outputing length in .s git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2979 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/SparcV9/EmitBytecodeToAssembly.cpp | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp index 141361d1e3c..3ca8b165823 100644 --- a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp +++ b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp @@ -10,13 +10,16 @@ #include "llvm/Pass.h" #include "llvm/Bytecode/Writer.h" #include +#include +#include +using std::ostream; namespace { // sparcasmbuf - stream buf for encoding output bytes as .byte directives for // the sparc assembler. // - class sparcasmbuf : public streambuf { + class sparcasmbuf : public std::streambuf { std::ostream &BaseStr; public: typedef char char_type; @@ -63,14 +66,29 @@ namespace { virtual bool run(Module &M) { // Write bytecode out to the sparc assembly stream + Out << "\n\n!LLVM BYTECODE OUTPUT\n\t.section \".rodata\"\n\t.align 8\n"; Out << "\t.global LLVMBytecode\n\t.type LLVMBytecode,#object\n"; Out << "LLVMBytecode:\n"; - osparcasmstream OS(Out); + //changed --anand, to get the size of bytecode + std::ostringstream Ostr; + osparcasmstream OS(Ostr); WriteBytecodeToFile(&M, OS); + //compute length: count number of "." + std::string myString=Ostr.str(); + int llvm_len=0; + for(std::string::iterator si=myString.begin(), se=myString.end(); si!=se; si++) + if(*si == '.') + llvm_len++; + + //now put Ostr into Out + //count no of + Out<