From: Nick Hildenbrandt Date: Wed, 2 Oct 2002 18:20:18 +0000 (+0000) Subject: No longer include malloc.h. If protoypes are needed for memory functions they will... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=113ad893b9ba66d36db84ca2e74512172994a717;p=oota-llvm.git No longer include malloc.h. If protoypes are needed for memory functions they will be present in the byte code and the generated c as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4013 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 8b7aba9398a..4278f82fff9 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -518,7 +518,6 @@ void CWriter::printModule(Module *M) { // get declaration for alloca Out << "/* Provide Declarations */\n" - << "#include \n" << "#include \n\n" // Provide a definition for null if one does not already exist, @@ -1019,8 +1018,68 @@ void CWriter::printIndexingExpression(Value *Ptr, User::op_iterator I, } } + + + + +/* +void CWriter::printIndexingExpression(Value *Ptr, User::op_iterator I, + User::op_iterator E) { + bool HasImplicitAddress = false; + // If accessing a global value with no indexing, avoid *(&GV) syndrome + if (GlobalValue *V = dyn_cast(Ptr)) { + HasImplicitAddress = true; + } else if (ConstantPointerRef *CPR = dyn_cast(Ptr)) { + HasImplicitAddress = true; + Ptr = CPR->getValue(); // Get to the global... + } + + if (I == E) { + if (!HasImplicitAddress) + Out << "*"; // Implicit zero first argument: '*x' is equivalent to 'x[0]' + + writeOperandInternal(Ptr); + return; + } + + const Constant *CI = dyn_cast(I->get()); + if (HasImplicitAddress && (!CI || !CI->isNullValue())) + Out << "(&"; + + writeOperandInternal(Ptr); + + if (HasImplicitAddress && (!CI || !CI->isNullValue())) { + Out << ")"; + HasImplicitAddress = false; // HIA is only true if we haven't addressed yet + } + + assert(!HasImplicitAddress || (CI && CI->isNullValue()) && + "Can only have implicit address with direct accessing"); + + if (HasImplicitAddress) { + ++I; + } else if (CI && CI->isNullValue() && I+1 != E) { + // Print out the -> operator if possible... + if ((*(I+1))->getType() == Type::UByteTy) { + Out << (HasImplicitAddress ? "." : "->"); + Out << "field" << cast(*(I+1))->getValue(); + I += 2; + } + } + + for (; I != E; ++I) + if ((*I)->getType() == Type::LongTy) { + Out << "["; + writeOperand(*I); + Out << "]"; + } else { + Out << ".field" << cast(*I)->getValue(); + } +} +*/ + void CWriter::visitLoadInst(LoadInst &I) { - Out << "*"; + //Out << "*"; writeOperand(I.getOperand(0)); } diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 8b7aba9398a..4278f82fff9 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -518,7 +518,6 @@ void CWriter::printModule(Module *M) { // get declaration for alloca Out << "/* Provide Declarations */\n" - << "#include \n" << "#include \n\n" // Provide a definition for null if one does not already exist, @@ -1019,8 +1018,68 @@ void CWriter::printIndexingExpression(Value *Ptr, User::op_iterator I, } } + + + + +/* +void CWriter::printIndexingExpression(Value *Ptr, User::op_iterator I, + User::op_iterator E) { + bool HasImplicitAddress = false; + // If accessing a global value with no indexing, avoid *(&GV) syndrome + if (GlobalValue *V = dyn_cast(Ptr)) { + HasImplicitAddress = true; + } else if (ConstantPointerRef *CPR = dyn_cast(Ptr)) { + HasImplicitAddress = true; + Ptr = CPR->getValue(); // Get to the global... + } + + if (I == E) { + if (!HasImplicitAddress) + Out << "*"; // Implicit zero first argument: '*x' is equivalent to 'x[0]' + + writeOperandInternal(Ptr); + return; + } + + const Constant *CI = dyn_cast(I->get()); + if (HasImplicitAddress && (!CI || !CI->isNullValue())) + Out << "(&"; + + writeOperandInternal(Ptr); + + if (HasImplicitAddress && (!CI || !CI->isNullValue())) { + Out << ")"; + HasImplicitAddress = false; // HIA is only true if we haven't addressed yet + } + + assert(!HasImplicitAddress || (CI && CI->isNullValue()) && + "Can only have implicit address with direct accessing"); + + if (HasImplicitAddress) { + ++I; + } else if (CI && CI->isNullValue() && I+1 != E) { + // Print out the -> operator if possible... + if ((*(I+1))->getType() == Type::UByteTy) { + Out << (HasImplicitAddress ? "." : "->"); + Out << "field" << cast(*(I+1))->getValue(); + I += 2; + } + } + + for (; I != E; ++I) + if ((*I)->getType() == Type::LongTy) { + Out << "["; + writeOperand(*I); + Out << "]"; + } else { + Out << ".field" << cast(*I)->getValue(); + } +} +*/ + void CWriter::visitLoadInst(LoadInst &I) { - Out << "*"; + //Out << "*"; writeOperand(I.getOperand(0)); }