aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2009-07-14 09:53:14 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2009-07-14 09:53:14 +0000
commit94ac0343cc866c632f230d069656c4358197ddf6 (patch)
tree54ff3a0ec217f9fdfb92d6eb5904f664c3472181 /lib
parente9fd67e2c678200f5ea264292828b5938b8ea31d (diff)
downloadexternal_llvm-94ac0343cc866c632f230d069656c4358197ddf6.zip
external_llvm-94ac0343cc866c632f230d069656c4358197ddf6.tar.gz
external_llvm-94ac0343cc866c632f230d069656c4358197ddf6.tar.bz2
Add extra sign extension to the same bit width before int sign
extension to another bit width. This is needed to get correct singed value. Patch by Artur Pietrek! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75629 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/MSIL/MSILWriter.cpp14
-rw-r--r--lib/Target/MSIL/MSILWriter.h2
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/Target/MSIL/MSILWriter.cpp b/lib/Target/MSIL/MSILWriter.cpp
index 61ec028..81e5cd4 100644
--- a/lib/Target/MSIL/MSILWriter.cpp
+++ b/lib/Target/MSIL/MSILWriter.cpp
@@ -670,12 +670,18 @@ void MSILWriter::printIndirectSave(const Type* Ty) {
void MSILWriter::printCastInstruction(unsigned int Op, const Value* V,
- const Type* Ty) {
+ const Type* Ty, const Type* SrcTy) {
std::string Tmp("");
printValueLoad(V);
switch (Op) {
// Signed
case Instruction::SExt:
+ // If sign extending int, convert first from unsigned to signed
+ // with the same bit size - because otherwise we will loose the sign.
+ if (SrcTy) {
+ Tmp = "conv."+getTypePostfix(SrcTy,false,true);
+ printSimpleInstruction(Tmp.c_str());
+ }
case Instruction::SIToFP:
case Instruction::FPToSI:
Tmp = "conv."+getTypePostfix(Ty,false,true);
@@ -1152,9 +1158,13 @@ void MSILWriter::printInstruction(const Instruction* Inst) {
case Instruction::Store:
printIndirectSave(Inst->getOperand(1), Inst->getOperand(0));
break;
+ case Instruction::SExt:
+ printCastInstruction(Inst->getOpcode(),Left,
+ cast<CastInst>(Inst)->getDestTy(),
+ cast<CastInst>(Inst)->getSrcTy());
+ break;
case Instruction::Trunc:
case Instruction::ZExt:
- case Instruction::SExt:
case Instruction::FPTrunc:
case Instruction::FPExt:
case Instruction::UIToFP:
diff --git a/lib/Target/MSIL/MSILWriter.h b/lib/Target/MSIL/MSILWriter.h
index 2ef8a85..ea0dfad 100644
--- a/lib/Target/MSIL/MSILWriter.h
+++ b/lib/Target/MSIL/MSILWriter.h
@@ -187,7 +187,7 @@ namespace {
void printIndirectSave(const Type* Ty);
void printCastInstruction(unsigned int Op, const Value* V,
- const Type* Ty);
+ const Type* Ty, const Type* SrcTy=0);
void printGepInstruction(const Value* V, gep_type_iterator I,
gep_type_iterator E);