diff options
author | Chris Lattner <sabre@nondot.org> | 2008-03-02 03:52:39 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-03-02 03:52:39 +0000 |
commit | 33a44d928bfea796e8f1a3d929aefedc317eefa5 (patch) | |
tree | 7bf297eedaad52161a21cda47a7677ca915d347f /lib/Target/CBackend/CBackend.cpp | |
parent | 90683abb56cb4af2cfef08e2383ef6cb5b50788b (diff) |
implement insertelement.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47811 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/CBackend/CBackend.cpp')
-rw-r--r-- | lib/Target/CBackend/CBackend.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 4c361527e2..bdef34d7eb 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -187,7 +187,7 @@ namespace { // emit it inline where it would go. if (I.getType() == Type::VoidTy || !I.hasOneUse() || 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! return false; @@ -251,6 +251,8 @@ namespace { void visitStoreInst (StoreInst &I); void visitGetElementPtrInst(GetElementPtrInst &I); void visitVAArgInst (VAArgInst &I); + + void visitInsertElementInst(InsertElementInst &I); void visitInstruction(Instruction &I) { cerr << "C Writer does not know about " << I; @@ -3022,6 +3024,20 @@ void CWriter::visitVAArgInst(VAArgInst &I) { 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 //===----------------------------------------------------------------------===// |