[llvm-commits] [llvm] r47812 - /llvm/trunk/lib/Target/CBackend/CBackend.cpp
Chris Lattner
sabre at nondot.org
Sat Mar 1 19:57:08 PST 2008
Author: lattner
Date: Sat Mar 1 21:57:08 2008
New Revision: 47812
URL: http://llvm.org/viewvc/llvm-project?rev=47812&view=rev
Log:
implement extractelement.
Modified:
llvm/trunk/lib/Target/CBackend/CBackend.cpp
Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=47812&r1=47811&r2=47812&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
+++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Sat Mar 1 21:57:08 2008
@@ -191,8 +191,10 @@
// Don't inline a load across a store or other bad things!
return false;
- // Must not be used in inline asm
- if (I.hasOneUse() && isInlineAsm(*I.use_back())) return false;
+ // Must not be used in inline asm or extractelement.
+ if (I.hasOneUse() &&
+ (isInlineAsm(*I.use_back()) || isa<ExtractElementInst>(I)))
+ return false;
// Only inline instruction it if it's use is in the same BB as the inst.
return I.getParent() == cast<Instruction>(I.use_back())->getParent();
@@ -253,6 +255,7 @@
void visitVAArgInst (VAArgInst &I);
void visitInsertElementInst(InsertElementInst &I);
+ void visitExtractElementInst(ExtractElementInst &I);
void visitInstruction(Instruction &I) {
cerr << "C Writer does not know about " << I;
@@ -3037,6 +3040,18 @@
Out << ")";
}
+void CWriter::visitExtractElementInst(ExtractElementInst &I) {
+ // We know that our operand is not inlined.
+ Out << "((";
+ const Type *EltTy =
+ cast<VectorType>(I.getOperand(0)->getType())->getElementType();
+ printType(Out, PointerType::getUnqual(EltTy));
+ Out << ")(&" << GetValueName(I.getOperand(0)) << "))[";
+ writeOperand(I.getOperand(1));
+ Out << "]";
+}
+
+
//===----------------------------------------------------------------------===//
// External Interface declaration
More information about the llvm-commits
mailing list