Remove trailing whitespace, patch by Markus Oberhumer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21379 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Misha Brukman
2005-04-20 16:05:03 +00:00
parent 22c46da12b
commit d6a29a5304
3 changed files with 115 additions and 115 deletions

View File

@ -1,10 +1,10 @@
//===-- Writer.cpp - Library for converting LLVM code to C ----------------===// //===-- Writer.cpp - Library for converting LLVM code to C ----------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This library converts LLVM code to C code, compilable by GCC and other C // This library converts LLVM code to C code, compilable by GCC and other C
@ -59,11 +59,11 @@ namespace {
virtual bool runOnModule(Module &M); virtual bool runOnModule(Module &M);
}; };
/// CWriter - This class is the main chunk of code that converts an LLVM /// CWriter - This class is the main chunk of code that converts an LLVM
/// module to a C translation unit. /// module to a C translation unit.
class CWriter : public FunctionPass, public InstVisitor<CWriter> { class CWriter : public FunctionPass, public InstVisitor<CWriter> {
std::ostream &Out; std::ostream &Out;
IntrinsicLowering &IL; IntrinsicLowering &IL;
Mangler *Mang; Mangler *Mang;
LoopInfo *LI; LoopInfo *LI;
@ -144,7 +144,7 @@ namespace {
// Must be an expression, must be used exactly once. If it is dead, we // Must be an expression, must be used exactly once. If it is dead, we
// emit it inline where it would go. // emit it inline where it would go.
if (I.getType() == Type::VoidTy || !I.hasOneUse() || if (I.getType() == Type::VoidTy || !I.hasOneUse() ||
isa<TerminatorInst>(I) || isa<CallInst>(I) || isa<PHINode>(I) || isa<TerminatorInst>(I) || isa<CallInst>(I) || isa<PHINode>(I) ||
isa<LoadInst>(I) || isa<VAArgInst>(I) || isa<VANextInst>(I)) isa<LoadInst>(I) || isa<VAArgInst>(I) || isa<VANextInst>(I))
// Don't inline a load across a store or other bad things! // Don't inline a load across a store or other bad things!
return false; return false;
@ -226,7 +226,7 @@ namespace {
bool CBackendNameAllUsedStructs::runOnModule(Module &M) { bool CBackendNameAllUsedStructs::runOnModule(Module &M) {
// Get a set of types that are used by the program... // Get a set of types that are used by the program...
std::set<const Type *> UT = getAnalysis<FindUsedTypes>().getTypes(); std::set<const Type *> UT = getAnalysis<FindUsedTypes>().getTypes();
// Loop over the module symbol table, removing types from UT that are // Loop over the module symbol table, removing types from UT that are
// already named, and removing names for types that are not used. // already named, and removing names for types that are not used.
// //
@ -283,7 +283,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
std::cerr << "Unknown primitive type: " << *Ty << "\n"; std::cerr << "Unknown primitive type: " << *Ty << "\n";
abort(); abort();
} }
// Check to see if the type is named. // Check to see if the type is named.
if (!IgnoreName || isa<OpaqueType>(Ty)) { if (!IgnoreName || isa<OpaqueType>(Ty)) {
std::map<const Type *, std::string>::iterator I = TypeNames.find(Ty); std::map<const Type *, std::string>::iterator I = TypeNames.find(Ty);
@ -293,7 +293,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
switch (Ty->getTypeID()) { switch (Ty->getTypeID()) {
case Type::FunctionTyID: { case Type::FunctionTyID: {
const FunctionType *MTy = cast<FunctionType>(Ty); const FunctionType *MTy = cast<FunctionType>(Ty);
std::stringstream FunctionInnards; std::stringstream FunctionInnards;
FunctionInnards << " (" << NameSoFar << ") ("; FunctionInnards << " (" << NameSoFar << ") (";
for (FunctionType::param_iterator I = MTy->param_begin(), for (FunctionType::param_iterator I = MTy->param_begin(),
E = MTy->param_end(); I != E; ++I) { E = MTy->param_end(); I != E; ++I) {
@ -302,7 +302,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
printType(FunctionInnards, *I, ""); printType(FunctionInnards, *I, "");
} }
if (MTy->isVarArg()) { if (MTy->isVarArg()) {
if (MTy->getNumParams()) if (MTy->getNumParams())
FunctionInnards << ", ..."; FunctionInnards << ", ...";
} else if (!MTy->getNumParams()) { } else if (!MTy->getNumParams()) {
FunctionInnards << "void"; FunctionInnards << "void";
@ -323,7 +323,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
Out << ";\n"; Out << ";\n";
} }
return Out << '}'; return Out << '}';
} }
case Type::PointerTyID: { case Type::PointerTyID: {
const PointerType *PTy = cast<PointerType>(Ty); const PointerType *PTy = cast<PointerType>(Ty);
@ -362,7 +362,7 @@ void CWriter::printConstantArray(ConstantArray *CPA) {
// As a special case, print the array as a string if it is an array of // As a special case, print the array as a string if it is an array of
// ubytes or an array of sbytes with positive values. // ubytes or an array of sbytes with positive values.
// //
const Type *ETy = CPA->getType()->getElementType(); const Type *ETy = CPA->getType()->getElementType();
bool isString = (ETy == Type::SByteTy || ETy == Type::UByteTy); bool isString = (ETy == Type::SByteTy || ETy == Type::UByteTy);
@ -370,7 +370,7 @@ void CWriter::printConstantArray(ConstantArray *CPA) {
if (isString && (CPA->getNumOperands() == 0 || if (isString && (CPA->getNumOperands() == 0 ||
!cast<Constant>(*(CPA->op_end()-1))->isNullValue())) !cast<Constant>(*(CPA->op_end()-1))->isNullValue()))
isString = false; isString = false;
if (isString) { if (isString) {
Out << '\"'; Out << '\"';
// Keep track of whether the last number was a hexadecimal escape // Keep track of whether the last number was a hexadecimal escape
@ -379,7 +379,7 @@ void CWriter::printConstantArray(ConstantArray *CPA) {
// Do not include the last character, which we know is null // Do not include the last character, which we know is null
for (unsigned i = 0, e = CPA->getNumOperands()-1; i != e; ++i) { for (unsigned i = 0, e = CPA->getNumOperands()-1; i != e; ++i) {
unsigned char C = cast<ConstantInt>(CPA->getOperand(i))->getRawValue(); unsigned char C = cast<ConstantInt>(CPA->getOperand(i))->getRawValue();
// Print it out literally if it is a printable character. The only thing // Print it out literally if it is a printable character. The only thing
// to be careful about is when the last letter output was a hex escape // to be careful about is when the last letter output was a hex escape
// code, in which case we have to be careful not to print out hex digits // code, in which case we have to be careful not to print out hex digits
@ -401,7 +401,7 @@ void CWriter::printConstantArray(ConstantArray *CPA) {
case '\v': Out << "\\v"; break; case '\v': Out << "\\v"; break;
case '\a': Out << "\\a"; break; case '\a': Out << "\\a"; break;
case '\"': Out << "\\\""; break; case '\"': Out << "\\\""; break;
case '\'': Out << "\\\'"; break; case '\'': Out << "\\\'"; break;
default: default:
Out << "\\x"; Out << "\\x";
Out << (char)(( C/16 < 10) ? ( C/16 +'0') : ( C/16 -10+'A')); Out << (char)(( C/16 < 10) ? ( C/16 +'0') : ( C/16 -10+'A'));
@ -580,7 +580,7 @@ void CWriter::printConstant(Constant *CPV) {
} else { } else {
if (IsNAN(FPC->getValue())) { if (IsNAN(FPC->getValue())) {
// The value is NaN // The value is NaN
// The prefix for a quiet NaN is 0x7FF8. For a signalling NaN, // The prefix for a quiet NaN is 0x7FF8. For a signalling NaN,
// it's 0x7ff4. // it's 0x7ff4.
const unsigned long QuietNaN = 0x7ff8UL; const unsigned long QuietNaN = 0x7ff8UL;
@ -698,10 +698,10 @@ void CWriter::writeOperandInternal(Value *Operand) {
Out << ')'; Out << ')';
return; return;
} }
Constant* CPV = dyn_cast<Constant>(Operand); Constant* CPV = dyn_cast<Constant>(Operand);
if (CPV && !isa<GlobalValue>(CPV)) { if (CPV && !isa<GlobalValue>(CPV)) {
printConstant(CPV); printConstant(CPV);
} else { } else {
Out << Mang->getValueName(Operand); Out << Mang->getValueName(Operand);
} }
@ -771,7 +771,7 @@ static void generateCompilerSpecificCode(std::ostream& Out) {
// Define NaN and Inf as GCC builtins if using GCC, as 0 otherwise // Define NaN and Inf as GCC builtins if using GCC, as 0 otherwise
// From the GCC documentation: // From the GCC documentation:
// //
// double __builtin_nan (const char *str) // double __builtin_nan (const char *str)
// //
// This is an implementation of the ISO C99 function nan. // This is an implementation of the ISO C99 function nan.
@ -824,7 +824,7 @@ bool CWriter::doInitialization(Module &M) {
TheModule = &M; TheModule = &M;
IL.AddPrototypes(M); IL.AddPrototypes(M);
// Ensure that all structure types have names... // Ensure that all structure types have names...
Mang = new Mangler(M); Mang = new Mangler(M);
@ -837,11 +837,11 @@ bool CWriter::doInitialization(Module &M) {
// Provide a definition for `bool' if not compiling with a C++ compiler. // Provide a definition for `bool' if not compiling with a C++ compiler.
Out << "\n" Out << "\n"
<< "#ifndef __cplusplus\ntypedef unsigned char bool;\n#endif\n" << "#ifndef __cplusplus\ntypedef unsigned char bool;\n#endif\n"
<< "\n\n/* Support for floating point constants */\n" << "\n\n/* Support for floating point constants */\n"
<< "typedef unsigned long long ConstantDoubleTy;\n" << "typedef unsigned long long ConstantDoubleTy;\n"
<< "typedef unsigned int ConstantFloatTy;\n" << "typedef unsigned int ConstantFloatTy;\n"
<< "\n\n/* Global Declarations */\n"; << "\n\n/* Global Declarations */\n";
// First output all the declarations for the program, because C requires // First output all the declarations for the program, because C requires
@ -868,7 +868,7 @@ bool CWriter::doInitialization(Module &M) {
Out << "\n/* Function Declarations */\n"; Out << "\n/* Function Declarations */\n";
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
// Don't print declarations for intrinsic functions. // Don't print declarations for intrinsic functions.
if (!I->getIntrinsicID() && if (!I->getIntrinsicID() &&
I->getName() != "setjmp" && I->getName() != "longjmp") { I->getName() != "setjmp" && I->getName() != "longjmp") {
printFunctionSignature(I, true); printFunctionSignature(I, true);
if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__"; if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__";
@ -965,9 +965,9 @@ void CWriter::printFloatingPointConstants(Function &F) {
if (!isFPCSafeToPrint(FPC) && // Do not put in FPConstantMap if safe. if (!isFPCSafeToPrint(FPC) && // Do not put in FPConstantMap if safe.
!FPConstantMap.count(FPC)) { !FPConstantMap.count(FPC)) {
double Val = FPC->getValue(); double Val = FPC->getValue();
FPConstantMap[FPC] = FPCounter; // Number the FP constants FPConstantMap[FPC] = FPCounter; // Number the FP constants
if (FPC->getType() == Type::DoubleTy) { if (FPC->getType() == Type::DoubleTy) {
DBLUnion.D = Val; DBLUnion.D = Val;
Out << "static const ConstantDoubleTy FPConstant" << FPCounter++ Out << "static const ConstantDoubleTy FPConstant" << FPCounter++
@ -981,7 +981,7 @@ void CWriter::printFloatingPointConstants(Function &F) {
} else } else
assert(0 && "Unknown float type!"); assert(0 && "Unknown float type!");
} }
Out << '\n'; Out << '\n';
} }
@ -996,7 +996,7 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
// If there are no type names, exit early. // If there are no type names, exit early.
if (I == End) return; if (I == End) return;
// Print out forward declarations for structure types before anything else! // Print out forward declarations for structure types before anything else!
Out << "/* Structure forward decls */\n"; Out << "/* Structure forward decls */\n";
for (; I != End; ++I) for (; I != End; ++I)
@ -1017,7 +1017,7 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
printType(Out, Ty, Name); printType(Out, Ty, Name);
Out << ";\n"; Out << ";\n";
} }
Out << '\n'; Out << '\n';
// Keep track of which structures have been printed so far... // Keep track of which structures have been printed so far...
@ -1047,10 +1047,10 @@ void CWriter::printContainedStructs(const Type *Ty,
if (isa<StructType>(Ty1) || isa<ArrayType>(Ty1)) if (isa<StructType>(Ty1) || isa<ArrayType>(Ty1))
printContainedStructs(*I, StructPrinted); printContainedStructs(*I, StructPrinted);
} }
//Print structure type out.. //Print structure type out..
StructPrinted.insert(STy); StructPrinted.insert(STy);
std::string Name = TypeNames[STy]; std::string Name = TypeNames[STy];
printType(Out, STy, Name, true); printType(Out, STy, Name, true);
Out << ";\n\n"; Out << ";\n\n";
} }
@ -1066,15 +1066,15 @@ void CWriter::printContainedStructs(const Type *Ty,
void CWriter::printFunctionSignature(const Function *F, bool Prototype) { void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
if (F->hasInternalLinkage()) Out << "static "; if (F->hasInternalLinkage()) Out << "static ";
// Loop over the arguments, printing them... // Loop over the arguments, printing them...
const FunctionType *FT = cast<FunctionType>(F->getFunctionType()); const FunctionType *FT = cast<FunctionType>(F->getFunctionType());
std::stringstream FunctionInnards; std::stringstream FunctionInnards;
// Print out the name... // Print out the name...
FunctionInnards << Mang->getValueName(F) << '('; FunctionInnards << Mang->getValueName(F) << '(';
if (!F->isExternal()) { if (!F->isExternal()) {
if (!F->arg_empty()) { if (!F->arg_empty()) {
std::string ArgName; std::string ArgName;
@ -1086,7 +1086,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
FunctionInnards << ", "; FunctionInnards << ", ";
if (I->hasName() || !Prototype) if (I->hasName() || !Prototype)
ArgName = Mang->getValueName(I); ArgName = Mang->getValueName(I);
else else
ArgName = ""; ArgName = "";
printType(FunctionInnards, I->getType(), ArgName); printType(FunctionInnards, I->getType(), ArgName);
} }
@ -1128,7 +1128,7 @@ void CWriter::printFunction(Function &F) {
Out << " "; Out << " ";
printType(Out, I->getType(), Mang->getValueName(&*I)); printType(Out, I->getType(), Mang->getValueName(&*I));
Out << ";\n"; Out << ";\n";
if (isa<PHINode>(*I)) { // Print out PHI node temporaries as well... if (isa<PHINode>(*I)) { // Print out PHI node temporaries as well...
Out << " "; Out << " ";
printType(Out, I->getType(), printType(Out, I->getType(),
@ -1151,7 +1151,7 @@ void CWriter::printFunction(Function &F) {
printBasicBlock(BB); printBasicBlock(BB);
} }
} }
Out << "}\n\n"; Out << "}\n\n";
} }
@ -1173,7 +1173,7 @@ void CWriter::printLoop(Loop *L) {
if (BBLoop == L) if (BBLoop == L)
printBasicBlock(BB); printBasicBlock(BB);
else if (BB == BBLoop->getHeader() && BBLoop->getParentLoop() == L) else if (BB == BBLoop->getHeader() && BBLoop->getParentLoop() == L)
printLoop(BBLoop); printLoop(BBLoop);
} }
Out << " } while (1); /* end of syntactic loop '" Out << " } while (1); /* end of syntactic loop '"
<< L->getHeader()->getName() << "' */\n"; << L->getHeader()->getName() << "' */\n";
@ -1192,9 +1192,9 @@ void CWriter::printBasicBlock(BasicBlock *BB) {
NeedsLabel = true; NeedsLabel = true;
break; break;
} }
if (NeedsLabel) Out << Mang->getValueName(BB) << ":\n"; if (NeedsLabel) Out << Mang->getValueName(BB) << ":\n";
// Output all of the instructions in the basic block... // Output all of the instructions in the basic block...
for (BasicBlock::iterator II = BB->begin(), E = --BB->end(); II != E; for (BasicBlock::iterator II = BB->begin(), E = --BB->end(); II != E;
++II) { ++II) {
@ -1207,7 +1207,7 @@ void CWriter::printBasicBlock(BasicBlock *BB) {
Out << ";\n"; Out << ";\n";
} }
} }
// Don't emit prefix or suffix for the terminator... // Don't emit prefix or suffix for the terminator...
visit(*BB->getTerminator()); visit(*BB->getTerminator());
} }
@ -1218,7 +1218,7 @@ void CWriter::printBasicBlock(BasicBlock *BB) {
// //
void CWriter::visitReturnInst(ReturnInst &I) { void CWriter::visitReturnInst(ReturnInst &I) {
// Don't output a void return if this is the last basic block in the function // Don't output a void return if this is the last basic block in the function
if (I.getNumOperands() == 0 && if (I.getNumOperands() == 0 &&
&*--I.getParent()->getParent()->end() == I.getParent() && &*--I.getParent()->getParent()->end() == I.getParent() &&
!I.getParent()->size() == 1) { !I.getParent()->size() == 1) {
return; return;
@ -1272,7 +1272,7 @@ bool CWriter::isGotoCodeNecessary(BasicBlock *From, BasicBlock *To) {
} }
void CWriter::printPHICopiesForSuccessor (BasicBlock *CurBlock, void CWriter::printPHICopiesForSuccessor (BasicBlock *CurBlock,
BasicBlock *Successor, BasicBlock *Successor,
unsigned Indent) { unsigned Indent) {
for (BasicBlock::iterator I = Successor->begin(); isa<PHINode>(I); ++I) { for (BasicBlock::iterator I = Successor->begin(); isa<PHINode>(I); ++I) {
PHINode *PN = cast<PHINode>(I); PHINode *PN = cast<PHINode>(I);
@ -1306,10 +1306,10 @@ void CWriter::visitBranchInst(BranchInst &I) {
Out << " if ("; Out << " if (";
writeOperand(I.getCondition()); writeOperand(I.getCondition());
Out << ") {\n"; Out << ") {\n";
printPHICopiesForSuccessor (I.getParent(), I.getSuccessor(0), 2); printPHICopiesForSuccessor (I.getParent(), I.getSuccessor(0), 2);
printBranchToBlock(I.getParent(), I.getSuccessor(0), 2); printBranchToBlock(I.getParent(), I.getSuccessor(0), 2);
if (isGotoCodeNecessary(I.getParent(), I.getSuccessor(1))) { if (isGotoCodeNecessary(I.getParent(), I.getSuccessor(1))) {
Out << " } else {\n"; Out << " } else {\n";
printPHICopiesForSuccessor (I.getParent(), I.getSuccessor(1), 2); printPHICopiesForSuccessor (I.getParent(), I.getSuccessor(1), 2);
@ -1407,9 +1407,9 @@ void CWriter::visitCastInst(CastInst &I) {
if (isa<PointerType>(I.getType())&&I.getOperand(0)->getType()->isIntegral() || if (isa<PointerType>(I.getType())&&I.getOperand(0)->getType()->isIntegral() ||
isa<PointerType>(I.getOperand(0)->getType())&&I.getType()->isIntegral()) { isa<PointerType>(I.getOperand(0)->getType())&&I.getType()->isIntegral()) {
// Avoid "cast to pointer from integer of different size" warnings // Avoid "cast to pointer from integer of different size" warnings
Out << "(long)"; Out << "(long)";
} }
writeOperand(I.getOperand(0)); writeOperand(I.getOperand(0));
} }
@ -1420,7 +1420,7 @@ void CWriter::visitSelectInst(SelectInst &I) {
writeOperand(I.getTrueValue()); writeOperand(I.getTrueValue());
Out << ") : ("; Out << ") : (";
writeOperand(I.getFalseValue()); writeOperand(I.getFalseValue());
Out << "))"; Out << "))";
} }
@ -1444,9 +1444,9 @@ void CWriter::lowerIntrinsics(Function &F) {
default: default:
// All other intrinsic calls we must lower. // All other intrinsic calls we must lower.
Instruction *Before = 0; Instruction *Before = 0;
if (CI != &BB->front()) if (CI != &BB->front())
Before = prior(BasicBlock::iterator(CI)); Before = prior(BasicBlock::iterator(CI));
IL.LowerIntrinsicCall(CI); IL.LowerIntrinsicCall(CI);
if (Before) { // Move iterator to instruction after call if (Before) { // Move iterator to instruction after call
I = Before; ++I; I = Before; ++I;
@ -1464,9 +1464,9 @@ void CWriter::visitCallInst(CallInst &I) {
if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID()) { if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID()) {
switch (ID) { switch (ID) {
default: assert(0 && "Unknown LLVM intrinsic!"); default: assert(0 && "Unknown LLVM intrinsic!");
case Intrinsic::vastart: case Intrinsic::vastart:
Out << "0; "; Out << "0; ";
Out << "va_start(*(va_list*)&" << Mang->getValueName(&I) << ", "; Out << "va_start(*(va_list*)&" << Mang->getValueName(&I) << ", ";
// Output the last argument to the enclosing function... // Output the last argument to the enclosing function...
if (I.getParent()->getParent()->arg_empty()) { if (I.getParent()->getParent()->arg_empty()) {
@ -1529,7 +1529,7 @@ void CWriter::visitCallInst(CallInst &I) {
} }
Value *Callee = I.getCalledValue(); Value *Callee = I.getCalledValue();
// GCC is really a PITA. It does not permit codegening casts of functions to // GCC is really a PITA. It does not permit codegening casts of functions to
// function pointers if they are in a call (it generates a trap instruction // function pointers if they are in a call (it generates a trap instruction
// instead!). We work around this by inserting a cast to void* in between the // instead!). We work around this by inserting a cast to void* in between the
@ -1567,7 +1567,7 @@ void CWriter::visitCallInst(CallInst &I) {
const PointerType *PTy = cast<PointerType>(Callee->getType()); const PointerType *PTy = cast<PointerType>(Callee->getType());
const FunctionType *FTy = cast<FunctionType>(PTy->getElementType()); const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
const Type *RetTy = FTy->getReturnType(); const Type *RetTy = FTy->getReturnType();
if (!WroteCallee) writeOperand(Callee); if (!WroteCallee) writeOperand(Callee);
Out << '('; Out << '(';
@ -1596,7 +1596,7 @@ void CWriter::visitCallInst(CallInst &I) {
} }
} }
Out << ')'; Out << ')';
} }
void CWriter::visitMallocInst(MallocInst &I) { void CWriter::visitMallocInst(MallocInst &I) {
assert(0 && "lowerallocations pass didn't work!"); assert(0 && "lowerallocations pass didn't work!");
@ -1711,7 +1711,7 @@ void CWriter::visitVANextInst(VANextInst &I) {
Out << Mang->getValueName(I.getOperand(0)); Out << Mang->getValueName(I.getOperand(0));
Out << "; va_arg(*(va_list*)&" << Mang->getValueName(&I) << ", "; Out << "; va_arg(*(va_list*)&" << Mang->getValueName(&I) << ", ";
printType(Out, I.getArgType()); printType(Out, I.getArgType());
Out << ')'; Out << ')';
} }
void CWriter::visitVAArgInst(VAArgInst &I) { void CWriter::visitVAArgInst(VAArgInst &I) {

View File

@ -1,12 +1,12 @@
//===-- CTargetMachine.h - TargetMachine for the C backend ------*- C++ -*-===// //===-- CTargetMachine.h - TargetMachine for the C backend ------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file declares the TargetMachine that is used by the C backend. // This file declares the TargetMachine that is used by the C backend.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -1,10 +1,10 @@
//===-- Writer.cpp - Library for converting LLVM code to C ----------------===// //===-- Writer.cpp - Library for converting LLVM code to C ----------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
// This file was developed by the LLVM research group and is distributed under // This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details. // the University of Illinois Open Source License. See LICENSE.TXT for details.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This library converts LLVM code to C code, compilable by GCC and other C // This library converts LLVM code to C code, compilable by GCC and other C
@ -59,11 +59,11 @@ namespace {
virtual bool runOnModule(Module &M); virtual bool runOnModule(Module &M);
}; };
/// CWriter - This class is the main chunk of code that converts an LLVM /// CWriter - This class is the main chunk of code that converts an LLVM
/// module to a C translation unit. /// module to a C translation unit.
class CWriter : public FunctionPass, public InstVisitor<CWriter> { class CWriter : public FunctionPass, public InstVisitor<CWriter> {
std::ostream &Out; std::ostream &Out;
IntrinsicLowering &IL; IntrinsicLowering &IL;
Mangler *Mang; Mangler *Mang;
LoopInfo *LI; LoopInfo *LI;
@ -144,7 +144,7 @@ namespace {
// Must be an expression, must be used exactly once. If it is dead, we // Must be an expression, must be used exactly once. If it is dead, we
// emit it inline where it would go. // emit it inline where it would go.
if (I.getType() == Type::VoidTy || !I.hasOneUse() || if (I.getType() == Type::VoidTy || !I.hasOneUse() ||
isa<TerminatorInst>(I) || isa<CallInst>(I) || isa<PHINode>(I) || isa<TerminatorInst>(I) || isa<CallInst>(I) || isa<PHINode>(I) ||
isa<LoadInst>(I) || isa<VAArgInst>(I) || isa<VANextInst>(I)) isa<LoadInst>(I) || isa<VAArgInst>(I) || isa<VANextInst>(I))
// Don't inline a load across a store or other bad things! // Don't inline a load across a store or other bad things!
return false; return false;
@ -226,7 +226,7 @@ namespace {
bool CBackendNameAllUsedStructs::runOnModule(Module &M) { bool CBackendNameAllUsedStructs::runOnModule(Module &M) {
// Get a set of types that are used by the program... // Get a set of types that are used by the program...
std::set<const Type *> UT = getAnalysis<FindUsedTypes>().getTypes(); std::set<const Type *> UT = getAnalysis<FindUsedTypes>().getTypes();
// Loop over the module symbol table, removing types from UT that are // Loop over the module symbol table, removing types from UT that are
// already named, and removing names for types that are not used. // already named, and removing names for types that are not used.
// //
@ -283,7 +283,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
std::cerr << "Unknown primitive type: " << *Ty << "\n"; std::cerr << "Unknown primitive type: " << *Ty << "\n";
abort(); abort();
} }
// Check to see if the type is named. // Check to see if the type is named.
if (!IgnoreName || isa<OpaqueType>(Ty)) { if (!IgnoreName || isa<OpaqueType>(Ty)) {
std::map<const Type *, std::string>::iterator I = TypeNames.find(Ty); std::map<const Type *, std::string>::iterator I = TypeNames.find(Ty);
@ -293,7 +293,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
switch (Ty->getTypeID()) { switch (Ty->getTypeID()) {
case Type::FunctionTyID: { case Type::FunctionTyID: {
const FunctionType *MTy = cast<FunctionType>(Ty); const FunctionType *MTy = cast<FunctionType>(Ty);
std::stringstream FunctionInnards; std::stringstream FunctionInnards;
FunctionInnards << " (" << NameSoFar << ") ("; FunctionInnards << " (" << NameSoFar << ") (";
for (FunctionType::param_iterator I = MTy->param_begin(), for (FunctionType::param_iterator I = MTy->param_begin(),
E = MTy->param_end(); I != E; ++I) { E = MTy->param_end(); I != E; ++I) {
@ -302,7 +302,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
printType(FunctionInnards, *I, ""); printType(FunctionInnards, *I, "");
} }
if (MTy->isVarArg()) { if (MTy->isVarArg()) {
if (MTy->getNumParams()) if (MTy->getNumParams())
FunctionInnards << ", ..."; FunctionInnards << ", ...";
} else if (!MTy->getNumParams()) { } else if (!MTy->getNumParams()) {
FunctionInnards << "void"; FunctionInnards << "void";
@ -323,7 +323,7 @@ std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
Out << ";\n"; Out << ";\n";
} }
return Out << '}'; return Out << '}';
} }
case Type::PointerTyID: { case Type::PointerTyID: {
const PointerType *PTy = cast<PointerType>(Ty); const PointerType *PTy = cast<PointerType>(Ty);
@ -362,7 +362,7 @@ void CWriter::printConstantArray(ConstantArray *CPA) {
// As a special case, print the array as a string if it is an array of // As a special case, print the array as a string if it is an array of
// ubytes or an array of sbytes with positive values. // ubytes or an array of sbytes with positive values.
// //
const Type *ETy = CPA->getType()->getElementType(); const Type *ETy = CPA->getType()->getElementType();
bool isString = (ETy == Type::SByteTy || ETy == Type::UByteTy); bool isString = (ETy == Type::SByteTy || ETy == Type::UByteTy);
@ -370,7 +370,7 @@ void CWriter::printConstantArray(ConstantArray *CPA) {
if (isString && (CPA->getNumOperands() == 0 || if (isString && (CPA->getNumOperands() == 0 ||
!cast<Constant>(*(CPA->op_end()-1))->isNullValue())) !cast<Constant>(*(CPA->op_end()-1))->isNullValue()))
isString = false; isString = false;
if (isString) { if (isString) {
Out << '\"'; Out << '\"';
// Keep track of whether the last number was a hexadecimal escape // Keep track of whether the last number was a hexadecimal escape
@ -379,7 +379,7 @@ void CWriter::printConstantArray(ConstantArray *CPA) {
// Do not include the last character, which we know is null // Do not include the last character, which we know is null
for (unsigned i = 0, e = CPA->getNumOperands()-1; i != e; ++i) { for (unsigned i = 0, e = CPA->getNumOperands()-1; i != e; ++i) {
unsigned char C = cast<ConstantInt>(CPA->getOperand(i))->getRawValue(); unsigned char C = cast<ConstantInt>(CPA->getOperand(i))->getRawValue();
// Print it out literally if it is a printable character. The only thing // Print it out literally if it is a printable character. The only thing
// to be careful about is when the last letter output was a hex escape // to be careful about is when the last letter output was a hex escape
// code, in which case we have to be careful not to print out hex digits // code, in which case we have to be careful not to print out hex digits
@ -401,7 +401,7 @@ void CWriter::printConstantArray(ConstantArray *CPA) {
case '\v': Out << "\\v"; break; case '\v': Out << "\\v"; break;
case '\a': Out << "\\a"; break; case '\a': Out << "\\a"; break;
case '\"': Out << "\\\""; break; case '\"': Out << "\\\""; break;
case '\'': Out << "\\\'"; break; case '\'': Out << "\\\'"; break;
default: default:
Out << "\\x"; Out << "\\x";
Out << (char)(( C/16 < 10) ? ( C/16 +'0') : ( C/16 -10+'A')); Out << (char)(( C/16 < 10) ? ( C/16 +'0') : ( C/16 -10+'A'));
@ -580,7 +580,7 @@ void CWriter::printConstant(Constant *CPV) {
} else { } else {
if (IsNAN(FPC->getValue())) { if (IsNAN(FPC->getValue())) {
// The value is NaN // The value is NaN
// The prefix for a quiet NaN is 0x7FF8. For a signalling NaN, // The prefix for a quiet NaN is 0x7FF8. For a signalling NaN,
// it's 0x7ff4. // it's 0x7ff4.
const unsigned long QuietNaN = 0x7ff8UL; const unsigned long QuietNaN = 0x7ff8UL;
@ -698,10 +698,10 @@ void CWriter::writeOperandInternal(Value *Operand) {
Out << ')'; Out << ')';
return; return;
} }
Constant* CPV = dyn_cast<Constant>(Operand); Constant* CPV = dyn_cast<Constant>(Operand);
if (CPV && !isa<GlobalValue>(CPV)) { if (CPV && !isa<GlobalValue>(CPV)) {
printConstant(CPV); printConstant(CPV);
} else { } else {
Out << Mang->getValueName(Operand); Out << Mang->getValueName(Operand);
} }
@ -771,7 +771,7 @@ static void generateCompilerSpecificCode(std::ostream& Out) {
// Define NaN and Inf as GCC builtins if using GCC, as 0 otherwise // Define NaN and Inf as GCC builtins if using GCC, as 0 otherwise
// From the GCC documentation: // From the GCC documentation:
// //
// double __builtin_nan (const char *str) // double __builtin_nan (const char *str)
// //
// This is an implementation of the ISO C99 function nan. // This is an implementation of the ISO C99 function nan.
@ -824,7 +824,7 @@ bool CWriter::doInitialization(Module &M) {
TheModule = &M; TheModule = &M;
IL.AddPrototypes(M); IL.AddPrototypes(M);
// Ensure that all structure types have names... // Ensure that all structure types have names...
Mang = new Mangler(M); Mang = new Mangler(M);
@ -837,11 +837,11 @@ bool CWriter::doInitialization(Module &M) {
// Provide a definition for `bool' if not compiling with a C++ compiler. // Provide a definition for `bool' if not compiling with a C++ compiler.
Out << "\n" Out << "\n"
<< "#ifndef __cplusplus\ntypedef unsigned char bool;\n#endif\n" << "#ifndef __cplusplus\ntypedef unsigned char bool;\n#endif\n"
<< "\n\n/* Support for floating point constants */\n" << "\n\n/* Support for floating point constants */\n"
<< "typedef unsigned long long ConstantDoubleTy;\n" << "typedef unsigned long long ConstantDoubleTy;\n"
<< "typedef unsigned int ConstantFloatTy;\n" << "typedef unsigned int ConstantFloatTy;\n"
<< "\n\n/* Global Declarations */\n"; << "\n\n/* Global Declarations */\n";
// First output all the declarations for the program, because C requires // First output all the declarations for the program, because C requires
@ -868,7 +868,7 @@ bool CWriter::doInitialization(Module &M) {
Out << "\n/* Function Declarations */\n"; Out << "\n/* Function Declarations */\n";
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
// Don't print declarations for intrinsic functions. // Don't print declarations for intrinsic functions.
if (!I->getIntrinsicID() && if (!I->getIntrinsicID() &&
I->getName() != "setjmp" && I->getName() != "longjmp") { I->getName() != "setjmp" && I->getName() != "longjmp") {
printFunctionSignature(I, true); printFunctionSignature(I, true);
if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__"; if (I->hasWeakLinkage()) Out << " __ATTRIBUTE_WEAK__";
@ -965,9 +965,9 @@ void CWriter::printFloatingPointConstants(Function &F) {
if (!isFPCSafeToPrint(FPC) && // Do not put in FPConstantMap if safe. if (!isFPCSafeToPrint(FPC) && // Do not put in FPConstantMap if safe.
!FPConstantMap.count(FPC)) { !FPConstantMap.count(FPC)) {
double Val = FPC->getValue(); double Val = FPC->getValue();
FPConstantMap[FPC] = FPCounter; // Number the FP constants FPConstantMap[FPC] = FPCounter; // Number the FP constants
if (FPC->getType() == Type::DoubleTy) { if (FPC->getType() == Type::DoubleTy) {
DBLUnion.D = Val; DBLUnion.D = Val;
Out << "static const ConstantDoubleTy FPConstant" << FPCounter++ Out << "static const ConstantDoubleTy FPConstant" << FPCounter++
@ -981,7 +981,7 @@ void CWriter::printFloatingPointConstants(Function &F) {
} else } else
assert(0 && "Unknown float type!"); assert(0 && "Unknown float type!");
} }
Out << '\n'; Out << '\n';
} }
@ -996,7 +996,7 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
// If there are no type names, exit early. // If there are no type names, exit early.
if (I == End) return; if (I == End) return;
// Print out forward declarations for structure types before anything else! // Print out forward declarations for structure types before anything else!
Out << "/* Structure forward decls */\n"; Out << "/* Structure forward decls */\n";
for (; I != End; ++I) for (; I != End; ++I)
@ -1017,7 +1017,7 @@ void CWriter::printModuleTypes(const SymbolTable &ST) {
printType(Out, Ty, Name); printType(Out, Ty, Name);
Out << ";\n"; Out << ";\n";
} }
Out << '\n'; Out << '\n';
// Keep track of which structures have been printed so far... // Keep track of which structures have been printed so far...
@ -1047,10 +1047,10 @@ void CWriter::printContainedStructs(const Type *Ty,
if (isa<StructType>(Ty1) || isa<ArrayType>(Ty1)) if (isa<StructType>(Ty1) || isa<ArrayType>(Ty1))
printContainedStructs(*I, StructPrinted); printContainedStructs(*I, StructPrinted);
} }
//Print structure type out.. //Print structure type out..
StructPrinted.insert(STy); StructPrinted.insert(STy);
std::string Name = TypeNames[STy]; std::string Name = TypeNames[STy];
printType(Out, STy, Name, true); printType(Out, STy, Name, true);
Out << ";\n\n"; Out << ";\n\n";
} }
@ -1066,15 +1066,15 @@ void CWriter::printContainedStructs(const Type *Ty,
void CWriter::printFunctionSignature(const Function *F, bool Prototype) { void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
if (F->hasInternalLinkage()) Out << "static "; if (F->hasInternalLinkage()) Out << "static ";
// Loop over the arguments, printing them... // Loop over the arguments, printing them...
const FunctionType *FT = cast<FunctionType>(F->getFunctionType()); const FunctionType *FT = cast<FunctionType>(F->getFunctionType());
std::stringstream FunctionInnards; std::stringstream FunctionInnards;
// Print out the name... // Print out the name...
FunctionInnards << Mang->getValueName(F) << '('; FunctionInnards << Mang->getValueName(F) << '(';
if (!F->isExternal()) { if (!F->isExternal()) {
if (!F->arg_empty()) { if (!F->arg_empty()) {
std::string ArgName; std::string ArgName;
@ -1086,7 +1086,7 @@ void CWriter::printFunctionSignature(const Function *F, bool Prototype) {
FunctionInnards << ", "; FunctionInnards << ", ";
if (I->hasName() || !Prototype) if (I->hasName() || !Prototype)
ArgName = Mang->getValueName(I); ArgName = Mang->getValueName(I);
else else
ArgName = ""; ArgName = "";
printType(FunctionInnards, I->getType(), ArgName); printType(FunctionInnards, I->getType(), ArgName);
} }
@ -1128,7 +1128,7 @@ void CWriter::printFunction(Function &F) {
Out << " "; Out << " ";
printType(Out, I->getType(), Mang->getValueName(&*I)); printType(Out, I->getType(), Mang->getValueName(&*I));
Out << ";\n"; Out << ";\n";
if (isa<PHINode>(*I)) { // Print out PHI node temporaries as well... if (isa<PHINode>(*I)) { // Print out PHI node temporaries as well...
Out << " "; Out << " ";
printType(Out, I->getType(), printType(Out, I->getType(),
@ -1151,7 +1151,7 @@ void CWriter::printFunction(Function &F) {
printBasicBlock(BB); printBasicBlock(BB);
} }
} }
Out << "}\n\n"; Out << "}\n\n";
} }
@ -1173,7 +1173,7 @@ void CWriter::printLoop(Loop *L) {
if (BBLoop == L) if (BBLoop == L)
printBasicBlock(BB); printBasicBlock(BB);
else if (BB == BBLoop->getHeader() && BBLoop->getParentLoop() == L) else if (BB == BBLoop->getHeader() && BBLoop->getParentLoop() == L)
printLoop(BBLoop); printLoop(BBLoop);
} }
Out << " } while (1); /* end of syntactic loop '" Out << " } while (1); /* end of syntactic loop '"
<< L->getHeader()->getName() << "' */\n"; << L->getHeader()->getName() << "' */\n";
@ -1192,9 +1192,9 @@ void CWriter::printBasicBlock(BasicBlock *BB) {
NeedsLabel = true; NeedsLabel = true;
break; break;
} }
if (NeedsLabel) Out << Mang->getValueName(BB) << ":\n"; if (NeedsLabel) Out << Mang->getValueName(BB) << ":\n";
// Output all of the instructions in the basic block... // Output all of the instructions in the basic block...
for (BasicBlock::iterator II = BB->begin(), E = --BB->end(); II != E; for (BasicBlock::iterator II = BB->begin(), E = --BB->end(); II != E;
++II) { ++II) {
@ -1207,7 +1207,7 @@ void CWriter::printBasicBlock(BasicBlock *BB) {
Out << ";\n"; Out << ";\n";
} }
} }
// Don't emit prefix or suffix for the terminator... // Don't emit prefix or suffix for the terminator...
visit(*BB->getTerminator()); visit(*BB->getTerminator());
} }
@ -1218,7 +1218,7 @@ void CWriter::printBasicBlock(BasicBlock *BB) {
// //
void CWriter::visitReturnInst(ReturnInst &I) { void CWriter::visitReturnInst(ReturnInst &I) {
// Don't output a void return if this is the last basic block in the function // Don't output a void return if this is the last basic block in the function
if (I.getNumOperands() == 0 && if (I.getNumOperands() == 0 &&
&*--I.getParent()->getParent()->end() == I.getParent() && &*--I.getParent()->getParent()->end() == I.getParent() &&
!I.getParent()->size() == 1) { !I.getParent()->size() == 1) {
return; return;
@ -1272,7 +1272,7 @@ bool CWriter::isGotoCodeNecessary(BasicBlock *From, BasicBlock *To) {
} }
void CWriter::printPHICopiesForSuccessor (BasicBlock *CurBlock, void CWriter::printPHICopiesForSuccessor (BasicBlock *CurBlock,
BasicBlock *Successor, BasicBlock *Successor,
unsigned Indent) { unsigned Indent) {
for (BasicBlock::iterator I = Successor->begin(); isa<PHINode>(I); ++I) { for (BasicBlock::iterator I = Successor->begin(); isa<PHINode>(I); ++I) {
PHINode *PN = cast<PHINode>(I); PHINode *PN = cast<PHINode>(I);
@ -1306,10 +1306,10 @@ void CWriter::visitBranchInst(BranchInst &I) {
Out << " if ("; Out << " if (";
writeOperand(I.getCondition()); writeOperand(I.getCondition());
Out << ") {\n"; Out << ") {\n";
printPHICopiesForSuccessor (I.getParent(), I.getSuccessor(0), 2); printPHICopiesForSuccessor (I.getParent(), I.getSuccessor(0), 2);
printBranchToBlock(I.getParent(), I.getSuccessor(0), 2); printBranchToBlock(I.getParent(), I.getSuccessor(0), 2);
if (isGotoCodeNecessary(I.getParent(), I.getSuccessor(1))) { if (isGotoCodeNecessary(I.getParent(), I.getSuccessor(1))) {
Out << " } else {\n"; Out << " } else {\n";
printPHICopiesForSuccessor (I.getParent(), I.getSuccessor(1), 2); printPHICopiesForSuccessor (I.getParent(), I.getSuccessor(1), 2);
@ -1407,9 +1407,9 @@ void CWriter::visitCastInst(CastInst &I) {
if (isa<PointerType>(I.getType())&&I.getOperand(0)->getType()->isIntegral() || if (isa<PointerType>(I.getType())&&I.getOperand(0)->getType()->isIntegral() ||
isa<PointerType>(I.getOperand(0)->getType())&&I.getType()->isIntegral()) { isa<PointerType>(I.getOperand(0)->getType())&&I.getType()->isIntegral()) {
// Avoid "cast to pointer from integer of different size" warnings // Avoid "cast to pointer from integer of different size" warnings
Out << "(long)"; Out << "(long)";
} }
writeOperand(I.getOperand(0)); writeOperand(I.getOperand(0));
} }
@ -1420,7 +1420,7 @@ void CWriter::visitSelectInst(SelectInst &I) {
writeOperand(I.getTrueValue()); writeOperand(I.getTrueValue());
Out << ") : ("; Out << ") : (";
writeOperand(I.getFalseValue()); writeOperand(I.getFalseValue());
Out << "))"; Out << "))";
} }
@ -1444,9 +1444,9 @@ void CWriter::lowerIntrinsics(Function &F) {
default: default:
// All other intrinsic calls we must lower. // All other intrinsic calls we must lower.
Instruction *Before = 0; Instruction *Before = 0;
if (CI != &BB->front()) if (CI != &BB->front())
Before = prior(BasicBlock::iterator(CI)); Before = prior(BasicBlock::iterator(CI));
IL.LowerIntrinsicCall(CI); IL.LowerIntrinsicCall(CI);
if (Before) { // Move iterator to instruction after call if (Before) { // Move iterator to instruction after call
I = Before; ++I; I = Before; ++I;
@ -1464,9 +1464,9 @@ void CWriter::visitCallInst(CallInst &I) {
if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID()) { if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID()) {
switch (ID) { switch (ID) {
default: assert(0 && "Unknown LLVM intrinsic!"); default: assert(0 && "Unknown LLVM intrinsic!");
case Intrinsic::vastart: case Intrinsic::vastart:
Out << "0; "; Out << "0; ";
Out << "va_start(*(va_list*)&" << Mang->getValueName(&I) << ", "; Out << "va_start(*(va_list*)&" << Mang->getValueName(&I) << ", ";
// Output the last argument to the enclosing function... // Output the last argument to the enclosing function...
if (I.getParent()->getParent()->arg_empty()) { if (I.getParent()->getParent()->arg_empty()) {
@ -1529,7 +1529,7 @@ void CWriter::visitCallInst(CallInst &I) {
} }
Value *Callee = I.getCalledValue(); Value *Callee = I.getCalledValue();
// GCC is really a PITA. It does not permit codegening casts of functions to // GCC is really a PITA. It does not permit codegening casts of functions to
// function pointers if they are in a call (it generates a trap instruction // function pointers if they are in a call (it generates a trap instruction
// instead!). We work around this by inserting a cast to void* in between the // instead!). We work around this by inserting a cast to void* in between the
@ -1567,7 +1567,7 @@ void CWriter::visitCallInst(CallInst &I) {
const PointerType *PTy = cast<PointerType>(Callee->getType()); const PointerType *PTy = cast<PointerType>(Callee->getType());
const FunctionType *FTy = cast<FunctionType>(PTy->getElementType()); const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
const Type *RetTy = FTy->getReturnType(); const Type *RetTy = FTy->getReturnType();
if (!WroteCallee) writeOperand(Callee); if (!WroteCallee) writeOperand(Callee);
Out << '('; Out << '(';
@ -1596,7 +1596,7 @@ void CWriter::visitCallInst(CallInst &I) {
} }
} }
Out << ')'; Out << ')';
} }
void CWriter::visitMallocInst(MallocInst &I) { void CWriter::visitMallocInst(MallocInst &I) {
assert(0 && "lowerallocations pass didn't work!"); assert(0 && "lowerallocations pass didn't work!");
@ -1711,7 +1711,7 @@ void CWriter::visitVANextInst(VANextInst &I) {
Out << Mang->getValueName(I.getOperand(0)); Out << Mang->getValueName(I.getOperand(0));
Out << "; va_arg(*(va_list*)&" << Mang->getValueName(&I) << ", "; Out << "; va_arg(*(va_list*)&" << Mang->getValueName(&I) << ", ";
printType(Out, I.getArgType()); printType(Out, I.getArgType());
Out << ')'; Out << ')';
} }
void CWriter::visitVAArgInst(VAArgInst &I) { void CWriter::visitVAArgInst(VAArgInst &I) {