X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FSparcV9%2FEmitBytecodeToAssembly.cpp;h=4a99cb3c4ca4cb87c32a2854c86e42bd8dabf2f3;hb=c5ddc8b74b1ab5f7e068a6db8071fef75527f0e7;hp=fdf8f3ec3614a911214ee7724b551cb276293887;hpb=96c466b06ab0c830b07329c1b16037f585ccbe40;p=oota-llvm.git diff --git a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp index fdf8f3ec361..4a99cb3c4ca 100644 --- a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp +++ b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp @@ -11,12 +11,14 @@ #include "llvm/Bytecode/Writer.h" #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; @@ -38,7 +40,7 @@ namespace { // as the underlying streambuf to write the data to. This streambuf formats // the output as .byte directives for sparc output. // - class osparcasmstream : public ostream { + class osparcasmstream : public std::ostream { sparcasmbuf sb; public: typedef char char_type; @@ -46,7 +48,7 @@ namespace { typedef std::streampos pos_type; typedef std::streamoff off_type; - explicit osparcasmstream(ostream &On) : ostream(&sb), sb(On) { } + explicit osparcasmstream(std::ostream &On) : std::ostream(&sb), sb(On) { } sparcasmbuf *rdbuf() const { return const_cast(&sb); @@ -60,17 +62,31 @@ namespace { SparcBytecodeWriter(std::ostream &out) : Out(out) {} const char *getPassName() const { return "Emit Bytecode to Sparc Assembly";} - - virtual bool run(Module *M) { + + 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"; + //changed --anand, to get the size of bytecode osparcasmstream OS(Out); - WriteBytecodeToFile(M, OS); + WriteBytecodeToFile(&M, OS); + Out << ".end_LLVMBytecode:\n"; Out << "\t.size LLVMBytecode, .end_LLVMBytecode-LLVMBytecode\n\n"; + + + Out <<"\n\n!LLVM BYTECODE Length\n"; + Out <<"\t.section \".data\",#alloc,#write\n"; + Out <<"\t.global llvm_length\n"; + Out <<"\t.align 4\n"; + Out <<"\t.type llvm_length,#object\n"; + Out <<"\t.size llvm_length,4\n"; + Out <<"llvm_length:\n"; + Out <<"\t.word\t.end_LLVMBytecode-LLVMBytecode\n"; return false; } };