implement insertelement.

llvm-svn: 47811
This commit is contained in:
Chris Lattner 2008-03-02 03:52:39 +00:00
parent 92d929c21d
commit d9cc003b0d
1 changed files with 17 additions and 1 deletions

View File

@ -187,7 +187,7 @@ namespace {
// 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<LoadInst>(I) || isa<VAArgInst>(I) || isa<InsertElementInst>(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;
@ -252,6 +252,8 @@ namespace {
void visitGetElementPtrInst(GetElementPtrInst &I); void visitGetElementPtrInst(GetElementPtrInst &I);
void visitVAArgInst (VAArgInst &I); void visitVAArgInst (VAArgInst &I);
void visitInsertElementInst(InsertElementInst &I);
void visitInstruction(Instruction &I) { void visitInstruction(Instruction &I) {
cerr << "C Writer does not know about " << I; cerr << "C Writer does not know about " << I;
abort(); abort();
@ -3022,6 +3024,20 @@ void CWriter::visitVAArgInst(VAArgInst &I) {
Out << ");\n "; Out << ");\n ";
} }
void CWriter::visitInsertElementInst(InsertElementInst &I) {
const Type *EltTy = I.getType()->getElementType();
writeOperand(I.getOperand(0));
Out << ";\n ";
Out << "((";
printType(Out, PointerType::getUnqual(EltTy));
Out << ")(&" << GetValueName(&I) << "))[";
writeOperand(I.getOperand(1));
Out << "] = (";
writeOperand(I.getOperand(2));
Out << ")";
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// External Interface declaration // External Interface declaration
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//