diff options
author | Anand Shukla <ashukla@cs.uiuc.edu> | 2002-07-21 09:35:01 +0000 |
---|---|---|
committer | Anand Shukla <ashukla@cs.uiuc.edu> | 2002-07-21 09:35:01 +0000 |
commit | 889faf8bc942ffa8bd4e60a40e657eb9a6e9d7d5 (patch) | |
tree | 210b39a42b09385eb5e70e69a0c99a5c1f23f876 /llvm/lib/Target/Sparc/EmitBytecodeToAssembly.cpp | |
parent | b3f6bfe0dff4f9fabc58bb89cb42173e169af613 (diff) | |
download | bcm5719-llvm-889faf8bc942ffa8bd4e60a40e657eb9a6e9d7d5.tar.gz bcm5719-llvm-889faf8bc942ffa8bd4e60a40e657eb9a6e9d7d5.zip |
Adding code for outputing length in .s
llvm-svn: 2979
Diffstat (limited to 'llvm/lib/Target/Sparc/EmitBytecodeToAssembly.cpp')
-rw-r--r-- | llvm/lib/Target/Sparc/EmitBytecodeToAssembly.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/llvm/lib/Target/Sparc/EmitBytecodeToAssembly.cpp b/llvm/lib/Target/Sparc/EmitBytecodeToAssembly.cpp index 141361d1e3c..3ca8b165823 100644 --- a/llvm/lib/Target/Sparc/EmitBytecodeToAssembly.cpp +++ b/llvm/lib/Target/Sparc/EmitBytecodeToAssembly.cpp @@ -10,13 +10,16 @@ #include "llvm/Pass.h" #include "llvm/Bytecode/Writer.h" #include <iostream> +#include <sstream> +#include <string> +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<<Ostr.str(); Out << ".end_LLVMBytecode:\n"; Out << "\t.size LLVMBytecode, .end_LLVMBytecode-LLVMBytecode\n\n"; + + Out <<"\n\n!LLVM BYTECODE Length\n\t.section \".data\",#alloc,#write\n\t.global llvm_length\n\t.align 4\n\t.type llvm_length,#object\n\t.size llvm_length,4\nllvm_length:\n\t.word "<<llvm_len<<"\n"; return false; } }; |