[llvm-commits] CVS: llvm/lib/Target/CBackend/CBackend.cpp
Reid Spencer
reid at x10sys.com
Sat Mar 3 08:33:50 PST 2007
Changes in directory llvm/lib/Target/CBackend:
CBackend.cpp updated: 1.328 -> 1.329
---
Log message:
Make sure that when we store a value it is masked to its correct bit
width. This helps CBE work with non-standard integer bit widths.
---
Diffs of the changes: (+15 -1)
CBackend.cpp | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletion(-)
Index: llvm/lib/Target/CBackend/CBackend.cpp
diff -u llvm/lib/Target/CBackend/CBackend.cpp:1.328 llvm/lib/Target/CBackend/CBackend.cpp:1.329
--- llvm/lib/Target/CBackend/CBackend.cpp:1.328 Fri Feb 23 16:45:08 2007
+++ llvm/lib/Target/CBackend/CBackend.cpp Sat Mar 3 10:33:33 2007
@@ -2815,7 +2815,21 @@
writeOperand(I.getPointerOperand());
if (I.isVolatile()) Out << ')';
Out << " = ";
- writeOperand(I.getOperand(0));
+ Value *Operand = I.getOperand(0);
+ Constant *BitMask = 0;
+ if (const IntegerType* ITy = dyn_cast<IntegerType>(Operand->getType()))
+ if (!ITy->isPowerOf2ByteWidth())
+ // We have a bit width that doesn't match an even power-of-2 byte
+ // size. Consequently we must & the value with the type's bit mask
+ BitMask = ConstantInt::get(ITy, ITy->getBitMask());
+ if (BitMask)
+ Out << "((";
+ writeOperand(Operand);
+ if (BitMask) {
+ Out << ") & ";
+ printConstant(BitMask);
+ Out << ")";
+ }
}
void CWriter::visitGetElementPtrInst(GetElementPtrInst &I) {
More information about the llvm-commits
mailing list