Removed #include <iostream> and replaced streams with llvm streams.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31949 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling
2006-11-27 23:54:50 +00:00
parent 29c277fc2c
commit 480f093dc2
3 changed files with 47 additions and 47 deletions

View File

@ -24,7 +24,6 @@
#include "llvm/Support/MutexGuard.h" #include "llvm/Support/MutexGuard.h"
#include "llvm/System/DynamicLibrary.h" #include "llvm/System/DynamicLibrary.h"
#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetData.h"
#include <iostream>
using namespace llvm; using namespace llvm;
namespace { namespace {
@ -159,13 +158,13 @@ static void *CreateArgv(ExecutionEngine *EE,
unsigned PtrSize = EE->getTargetData()->getPointerSize(); unsigned PtrSize = EE->getTargetData()->getPointerSize();
char *Result = new char[(InputArgv.size()+1)*PtrSize]; char *Result = new char[(InputArgv.size()+1)*PtrSize];
DEBUG(std::cerr << "ARGV = " << (void*)Result << "\n"); DOUT << "ARGV = " << (void*)Result << "\n";
const Type *SBytePtr = PointerType::get(Type::SByteTy); const Type *SBytePtr = PointerType::get(Type::SByteTy);
for (unsigned i = 0; i != InputArgv.size(); ++i) { for (unsigned i = 0; i != InputArgv.size(); ++i) {
unsigned Size = InputArgv[i].size()+1; unsigned Size = InputArgv[i].size()+1;
char *Dest = new char[Size]; char *Dest = new char[Size];
DEBUG(std::cerr << "ARGV[" << i << "] = " << (void*)Dest << "\n"); DOUT << "ARGV[" << i << "] = " << (void*)Dest << "\n";
std::copy(InputArgv[i].begin(), InputArgv[i].end(), Dest); std::copy(InputArgv[i].begin(), InputArgv[i].end(), Dest);
Dest[Size-1] = 0; Dest[Size-1] = 0;
@ -403,7 +402,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
default: default:
break; break;
} }
std::cerr << "ConstantExpr not handled as global var init: " << *CE << "\n"; llvm_cerr << "ConstantExpr not handled as global var init: " << *CE << "\n";
abort(); abort();
} }
@ -433,7 +432,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
assert(0 && "Unknown constant pointer type!"); assert(0 && "Unknown constant pointer type!");
break; break;
default: default:
std::cout << "ERROR: Constant unimp for type: " << *C->getType() << "\n"; llvm_cerr << "ERROR: Constant unimp for type: " << *C->getType() << "\n";
abort(); abort();
} }
return Result; return Result;
@ -478,7 +477,7 @@ void ExecutionEngine::StoreValueToMemory(GenericValue Val, GenericValue *Ptr,
Ptr->Untyped[7] = (unsigned char)(Val.ULongVal >> 56); Ptr->Untyped[7] = (unsigned char)(Val.ULongVal >> 56);
break; break;
default: default:
std::cout << "Cannot store value of type " << *Ty << "!\n"; llvm_cerr << "Cannot store value of type " << *Ty << "!\n";
} }
} else { } else {
switch (Ty->getTypeID()) { switch (Ty->getTypeID()) {
@ -512,7 +511,7 @@ void ExecutionEngine::StoreValueToMemory(GenericValue Val, GenericValue *Ptr,
Ptr->Untyped[0] = (unsigned char)(Val.ULongVal >> 56); Ptr->Untyped[0] = (unsigned char)(Val.ULongVal >> 56);
break; break;
default: default:
std::cout << "Cannot store value of type " << *Ty << "!\n"; llvm_cerr << "Cannot store value of type " << *Ty << "!\n";
} }
} }
} }
@ -553,7 +552,7 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr,
((uint64_t)Ptr->Untyped[7] << 56); ((uint64_t)Ptr->Untyped[7] << 56);
break; break;
default: default:
std::cout << "Cannot load value of type " << *Ty << "!\n"; llvm_cerr << "Cannot load value of type " << *Ty << "!\n";
abort(); abort();
} }
} else { } else {
@ -587,7 +586,7 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr,
((uint64_t)Ptr->Untyped[0] << 56); ((uint64_t)Ptr->Untyped[0] << 56);
break; break;
default: default:
std::cout << "Cannot load value of type " << *Ty << "!\n"; llvm_cerr << "Cannot load value of type " << *Ty << "!\n";
abort(); abort();
} }
} }
@ -635,7 +634,7 @@ void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) {
} }
default: default:
std::cerr << "Bad Type: " << *Init->getType() << "\n"; llvm_cerr << "Bad Type: " << *Init->getType() << "\n";
assert(0 && "Unknown constant type to initialize memory with!"); assert(0 && "Unknown constant type to initialize memory with!");
} }
} }
@ -719,7 +718,7 @@ void ExecutionEngine::emitGlobals() {
sys::DynamicLibrary::SearchForAddressOfSymbol(I->getName().c_str())) sys::DynamicLibrary::SearchForAddressOfSymbol(I->getName().c_str()))
addGlobalMapping(I, SymAddr); addGlobalMapping(I, SymAddr);
else { else {
std::cerr << "Could not resolve external global address: " llvm_cerr << "Could not resolve external global address: "
<< I->getName() << "\n"; << I->getName() << "\n";
abort(); abort();
} }
@ -761,7 +760,7 @@ void ExecutionEngine::emitGlobals() {
// already in the map. // already in the map.
void ExecutionEngine::EmitGlobalVariable(const GlobalVariable *GV) { void ExecutionEngine::EmitGlobalVariable(const GlobalVariable *GV) {
void *GA = getPointerToGlobalIfAvailable(GV); void *GA = getPointerToGlobalIfAvailable(GV);
DEBUG(std::cerr << "Global '" << GV->getName() << "' -> " << GA << "\n"); DOUT << "Global '" << GV->getName() << "' -> " << GA << "\n";
const Type *ElTy = GV->getType()->getElementType(); const Type *ElTy = GV->getType()->getElementType();
size_t GVSize = (size_t)getTargetData()->getTypeSize(ElTy); size_t GVSize = (size_t)getTargetData()->getTypeSize(ElTy);

View File

@ -187,7 +187,7 @@ GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE,
getOperandValue(CE->getOperand(1), SF), getOperandValue(CE->getOperand(1), SF),
getOperandValue(CE->getOperand(2), SF)); getOperandValue(CE->getOperand(2), SF));
default: default:
std::cerr << "Unhandled ConstantExpr: " << *CE << "\n"; llvm_cerr << "Unhandled ConstantExpr: " << *CE << "\n";
abort(); abort();
return GenericValue(); return GenericValue();
} }
@ -235,7 +235,7 @@ static GenericValue executeAddInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(+, Float); IMPLEMENT_BINARY_OPERATOR(+, Float);
IMPLEMENT_BINARY_OPERATOR(+, Double); IMPLEMENT_BINARY_OPERATOR(+, Double);
default: default:
std::cout << "Unhandled type for Add instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for Add instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -256,7 +256,7 @@ static GenericValue executeSubInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(-, Float); IMPLEMENT_BINARY_OPERATOR(-, Float);
IMPLEMENT_BINARY_OPERATOR(-, Double); IMPLEMENT_BINARY_OPERATOR(-, Double);
default: default:
std::cout << "Unhandled type for Sub instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for Sub instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -277,7 +277,7 @@ static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(*, Float); IMPLEMENT_BINARY_OPERATOR(*, Float);
IMPLEMENT_BINARY_OPERATOR(*, Double); IMPLEMENT_BINARY_OPERATOR(*, Double);
default: default:
std::cout << "Unhandled type for Mul instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for Mul instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -295,7 +295,7 @@ static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SIGNLESS_BINOP(/, UInt, Int); IMPLEMENT_SIGNLESS_BINOP(/, UInt, Int);
IMPLEMENT_SIGNLESS_BINOP(/, ULong, Long); IMPLEMENT_SIGNLESS_BINOP(/, ULong, Long);
default: default:
std::cout << "Unhandled type for UDiv instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for UDiv instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -310,7 +310,7 @@ static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SIGNLESS_BINOP(/, Int, UInt); IMPLEMENT_SIGNLESS_BINOP(/, Int, UInt);
IMPLEMENT_SIGNLESS_BINOP(/, Long, ULong); IMPLEMENT_SIGNLESS_BINOP(/, Long, ULong);
default: default:
std::cout << "Unhandled type for SDiv instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for SDiv instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -323,7 +323,7 @@ static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(/, Float); IMPLEMENT_BINARY_OPERATOR(/, Float);
IMPLEMENT_BINARY_OPERATOR(/, Double); IMPLEMENT_BINARY_OPERATOR(/, Double);
default: default:
std::cout << "Unhandled type for Div instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for Div instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -338,7 +338,7 @@ static GenericValue executeURemInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SIGNLESS_BINOP(%, UInt, Int); IMPLEMENT_SIGNLESS_BINOP(%, UInt, Int);
IMPLEMENT_SIGNLESS_BINOP(%, ULong, Long); IMPLEMENT_SIGNLESS_BINOP(%, ULong, Long);
default: default:
std::cout << "Unhandled type for URem instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for URem instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -353,7 +353,7 @@ static GenericValue executeSRemInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SIGNLESS_BINOP(%, Int, UInt); IMPLEMENT_SIGNLESS_BINOP(%, Int, UInt);
IMPLEMENT_SIGNLESS_BINOP(%, Long, ULong); IMPLEMENT_SIGNLESS_BINOP(%, Long, ULong);
default: default:
std::cout << "Unhandled type for Rem instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for Rem instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -370,7 +370,7 @@ static GenericValue executeFRemInst(GenericValue Src1, GenericValue Src2,
Dest.DoubleVal = fmod(Src1.DoubleVal, Src2.DoubleVal); Dest.DoubleVal = fmod(Src1.DoubleVal, Src2.DoubleVal);
break; break;
default: default:
std::cout << "Unhandled type for Rem instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for Rem instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -390,7 +390,7 @@ static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(&, ULong); IMPLEMENT_BINARY_OPERATOR(&, ULong);
IMPLEMENT_BINARY_OPERATOR(&, Long); IMPLEMENT_BINARY_OPERATOR(&, Long);
default: default:
std::cout << "Unhandled type for And instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for And instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -410,7 +410,7 @@ static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(|, ULong); IMPLEMENT_BINARY_OPERATOR(|, ULong);
IMPLEMENT_BINARY_OPERATOR(|, Long); IMPLEMENT_BINARY_OPERATOR(|, Long);
default: default:
std::cout << "Unhandled type for Or instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for Or instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -430,7 +430,7 @@ static GenericValue executeXorInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_BINARY_OPERATOR(^, ULong); IMPLEMENT_BINARY_OPERATOR(^, ULong);
IMPLEMENT_BINARY_OPERATOR(^, Long); IMPLEMENT_BINARY_OPERATOR(^, Long);
default: default:
std::cout << "Unhandled type for Xor instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for Xor instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -464,7 +464,7 @@ static GenericValue executeSetEQInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(==, Double); IMPLEMENT_SETCC(==, Double);
IMPLEMENT_POINTERSETCC(==); IMPLEMENT_POINTERSETCC(==);
default: default:
std::cout << "Unhandled type for SetEQ instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for SetEQ instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -487,7 +487,7 @@ static GenericValue executeSetNEInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_POINTERSETCC(!=); IMPLEMENT_POINTERSETCC(!=);
default: default:
std::cout << "Unhandled type for SetNE instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for SetNE instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -509,7 +509,7 @@ static GenericValue executeSetLEInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(<=, Double); IMPLEMENT_SETCC(<=, Double);
IMPLEMENT_POINTERSETCC(<=); IMPLEMENT_POINTERSETCC(<=);
default: default:
std::cout << "Unhandled type for SetLE instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for SetLE instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -531,7 +531,7 @@ static GenericValue executeSetGEInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(>=, Double); IMPLEMENT_SETCC(>=, Double);
IMPLEMENT_POINTERSETCC(>=); IMPLEMENT_POINTERSETCC(>=);
default: default:
std::cout << "Unhandled type for SetGE instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for SetGE instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -553,7 +553,7 @@ static GenericValue executeSetLTInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(<, Double); IMPLEMENT_SETCC(<, Double);
IMPLEMENT_POINTERSETCC(<); IMPLEMENT_POINTERSETCC(<);
default: default:
std::cout << "Unhandled type for SetLT instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for SetLT instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -575,7 +575,7 @@ static GenericValue executeSetGTInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SETCC(>, Double); IMPLEMENT_SETCC(>, Double);
IMPLEMENT_POINTERSETCC(>); IMPLEMENT_POINTERSETCC(>);
default: default:
std::cout << "Unhandled type for SetGT instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for SetGT instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -608,7 +608,7 @@ void Interpreter::visitBinaryOperator(BinaryOperator &I) {
case Instruction::SetLT: R = executeSetLTInst(Src1, Src2, Ty); break; case Instruction::SetLT: R = executeSetLTInst(Src1, Src2, Ty); break;
case Instruction::SetGT: R = executeSetGTInst(Src1, Src2, Ty); break; case Instruction::SetGT: R = executeSetGTInst(Src1, Src2, Ty); break;
default: default:
std::cout << "Don't know how to handle this binary operator!\n-->" << I; llvm_cerr << "Don't know how to handle this binary operator!\n-->" << I;
abort(); abort();
} }
@ -709,7 +709,7 @@ void Interpreter::visitUnwindInst(UnwindInst &I) {
} }
void Interpreter::visitUnreachableInst(UnreachableInst &I) { void Interpreter::visitUnreachableInst(UnreachableInst &I) {
std::cerr << "ERROR: Program executed an 'unreachable' instruction!\n"; llvm_cerr << "ERROR: Program executed an 'unreachable' instruction!\n";
abort(); abort();
} }
@ -977,7 +977,7 @@ static GenericValue executeShlInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SHIFT(<<, ULong); IMPLEMENT_SHIFT(<<, ULong);
IMPLEMENT_SHIFT(<<, Long); IMPLEMENT_SHIFT(<<, Long);
default: default:
std::cout << "Unhandled type for Shl instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for Shl instruction: " << *Ty << "\n";
} }
return Dest; return Dest;
} }
@ -991,7 +991,7 @@ static GenericValue executeLShrInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SIGNLESS_SHIFT(>>, UInt, Int); IMPLEMENT_SIGNLESS_SHIFT(>>, UInt, Int);
IMPLEMENT_SIGNLESS_SHIFT(>>, ULong, Long); IMPLEMENT_SIGNLESS_SHIFT(>>, ULong, Long);
default: default:
std::cout << "Unhandled type for LShr instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for LShr instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -1006,7 +1006,7 @@ static GenericValue executeAShrInst(GenericValue Src1, GenericValue Src2,
IMPLEMENT_SIGNLESS_SHIFT(>>, Int, UInt); IMPLEMENT_SIGNLESS_SHIFT(>>, Int, UInt);
IMPLEMENT_SIGNLESS_SHIFT(>>, Long, ULong); IMPLEMENT_SIGNLESS_SHIFT(>>, Long, ULong);
default: default:
std::cout << "Unhandled type for AShr instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled type for AShr instruction: " << *Ty << "\n";
abort(); abort();
} }
return Dest; return Dest;
@ -1064,14 +1064,14 @@ void Interpreter::visitAShr(ShiftInst &I) {
IMPLEMENT_CAST(DESTTY, DESTCTY, Float); \ IMPLEMENT_CAST(DESTTY, DESTCTY, Float); \
IMPLEMENT_CAST(DESTTY, DESTCTY, Double) \ IMPLEMENT_CAST(DESTTY, DESTCTY, Double) \
default: \ default: \
std::cout << "Unhandled cast: " \ llvm_cerr << "Unhandled cast: " \
<< *SrcTy << " to " << *DstTy << "\n"; \ << *SrcTy << " to " << *DstTy << "\n"; \
abort(); \ abort(); \
} \ } \
break break
#define IMPLEMENT_CAST_END \ #define IMPLEMENT_CAST_END \
default: std::cout \ default: llvm_cerr \
<< "Unhandled dest type for cast instruction: " \ << "Unhandled dest type for cast instruction: " \
<< *DstTy << "\n"; \ << *DstTy << "\n"; \
abort(); \ abort(); \
@ -1225,7 +1225,7 @@ GenericValue Interpreter::executeCastOperation(Instruction::CastOps opcode,
IMPLEMENT_CAST_END IMPLEMENT_CAST_END
break; break;
default: default:
std::cout llvm_cerr
<< "Invalid cast opcode for cast instruction: " << opcode << "\n"; << "Invalid cast opcode for cast instruction: " << opcode << "\n";
abort(); abort();
} }
@ -1265,7 +1265,7 @@ void Interpreter::visitVAArgInst(VAArgInst &I) {
IMPLEMENT_VAARG(Double); IMPLEMENT_VAARG(Double);
IMPLEMENT_VAARG(Bool); IMPLEMENT_VAARG(Bool);
default: default:
std::cout << "Unhandled dest type for vaarg instruction: " << *Ty << "\n"; llvm_cerr << "Unhandled dest type for vaarg instruction: " << *Ty << "\n";
abort(); abort();
} }
@ -1328,7 +1328,7 @@ void Interpreter::run() {
// Track the number of dynamic instructions executed. // Track the number of dynamic instructions executed.
++NumDynamicInsts; ++NumDynamicInsts;
DEBUG(std::cerr << "About to interpret: " << I); DOUT << "About to interpret: " << I;
visit(I); // Dispatch to one of the visit* methods... visit(I); // Dispatch to one of the visit* methods...
} }
} }

View File

@ -22,6 +22,7 @@
#include "Interpreter.h" #include "Interpreter.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Support/Streams.h"
#include "llvm/System/DynamicLibrary.h" #include "llvm/System/DynamicLibrary.h"
#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetData.h"
#include <csignal> #include <csignal>
@ -91,7 +92,7 @@ GenericValue Interpreter::callExternalFunction(Function *F,
std::map<const Function *, ExFunc>::iterator FI = Functions.find(F); std::map<const Function *, ExFunc>::iterator FI = Functions.find(F);
ExFunc Fn = (FI == Functions.end()) ? lookupFunction(F) : FI->second; ExFunc Fn = (FI == Functions.end()) ? lookupFunction(F) : FI->second;
if (Fn == 0) { if (Fn == 0) {
std::cout << "Tried to execute an unknown external function: " llvm_cerr << "Tried to execute an unknown external function: "
<< F->getType()->getDescription() << " " << F->getName() << "\n"; << F->getType()->getDescription() << " " << F->getName() << "\n";
if (F->getName() == "__main") if (F->getName() == "__main")
return GenericValue(); return GenericValue();
@ -112,19 +113,19 @@ extern "C" { // Don't add C++ manglings to llvm mangling :)
// void putchar(sbyte) // void putchar(sbyte)
GenericValue lle_Vb_putchar(FunctionType *M, const vector<GenericValue> &Args) { GenericValue lle_Vb_putchar(FunctionType *M, const vector<GenericValue> &Args) {
std::cout << Args[0].SByteVal; llvm_cout << Args[0].SByteVal;
return GenericValue(); return GenericValue();
} }
// int putchar(int) // int putchar(int)
GenericValue lle_ii_putchar(FunctionType *M, const vector<GenericValue> &Args) { GenericValue lle_ii_putchar(FunctionType *M, const vector<GenericValue> &Args) {
std::cout << ((char)Args[0].IntVal) << std::flush; llvm_cout << ((char)Args[0].IntVal) << std::flush;
return Args[0]; return Args[0];
} }
// void putchar(ubyte) // void putchar(ubyte)
GenericValue lle_VB_putchar(FunctionType *M, const vector<GenericValue> &Args) { GenericValue lle_VB_putchar(FunctionType *M, const vector<GenericValue> &Args) {
std::cout << Args[0].SByteVal << std::flush; llvm_cout << Args[0].SByteVal << std::flush;
return Args[0]; return Args[0];
} }
@ -330,7 +331,7 @@ GenericValue lle_X_sprintf(FunctionType *M, const vector<GenericValue> &Args) {
sprintf(Buffer, FmtBuf, (void*)GVTOP(Args[ArgNo++])); break; sprintf(Buffer, FmtBuf, (void*)GVTOP(Args[ArgNo++])); break;
case 's': case 's':
sprintf(Buffer, FmtBuf, (char*)GVTOP(Args[ArgNo++])); break; sprintf(Buffer, FmtBuf, (char*)GVTOP(Args[ArgNo++])); break;
default: std::cout << "<unknown printf code '" << *FmtStr << "'!>"; default: llvm_cerr << "<unknown printf code '" << *FmtStr << "'!>";
ArgNo++; break; ArgNo++; break;
} }
strcpy(OutputBuffer, Buffer); strcpy(OutputBuffer, Buffer);
@ -348,7 +349,7 @@ GenericValue lle_X_printf(FunctionType *M, const vector<GenericValue> &Args) {
NewArgs.push_back(PTOGV(Buffer)); NewArgs.push_back(PTOGV(Buffer));
NewArgs.insert(NewArgs.end(), Args.begin(), Args.end()); NewArgs.insert(NewArgs.end(), Args.begin(), Args.end());
GenericValue GV = lle_X_sprintf(M, NewArgs); GenericValue GV = lle_X_sprintf(M, NewArgs);
std::cout << Buffer; llvm_cout << Buffer;
return GV; return GV;
} }