mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 04:30:12 +00:00
Added support to write out ConstantExpr nodes.
Also, avoid asserting out when writing out an invalid tree since the assembly writer is used when debugging. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2902 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
345e0cfb86
commit
b4dbb4445c
@ -12,6 +12,7 @@
|
|||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
#include "llvm/SlotCalculator.h"
|
#include "llvm/SlotCalculator.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
|
#include "llvm/Instruction.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/iMemory.h"
|
#include "llvm/iMemory.h"
|
||||||
@ -150,8 +151,7 @@ static string calcTypeName(const Type *Ty, vector<const Type *> &TypeStack,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
assert(0 && "Unhandled case in getTypeProps!");
|
Result = "<unrecognized-type>";
|
||||||
Result = "<error>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeStack.pop_back(); // Remove self from stack...
|
TypeStack.pop_back(); // Remove self from stack...
|
||||||
@ -326,8 +326,24 @@ static void WriteConstantInt(ostream &Out, const Constant *CV, bool PrintName,
|
|||||||
} else {
|
} else {
|
||||||
Out << "<pointer reference without context info>";
|
Out << "<pointer reference without context info>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (const ConstantExpr *CE=dyn_cast<ConstantExpr>(CV)) {
|
||||||
|
Out << CE->getOpcodeName();
|
||||||
|
|
||||||
|
bool isGEP = CE->getOpcode() == Instruction::GetElementPtr;
|
||||||
|
Out << (isGEP? " (" : " ");
|
||||||
|
|
||||||
|
for (User::const_op_iterator OI=CE->op_begin(); OI != CE->op_end(); ++OI) {
|
||||||
|
printTypeInt(Out, (*OI)->getType(), TypeTable);
|
||||||
|
WriteAsOperandInternal(Out, *OI, PrintName, TypeTable, Table);
|
||||||
|
if (OI+1 != CE->op_end())
|
||||||
|
Out << ", "; // ((isGEP && OI == CE->op_begin())? " " : ", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isGEP)
|
||||||
|
Out << ")";
|
||||||
} else {
|
} else {
|
||||||
assert(0 && "Unrecognized constant value!!!");
|
Out << "<placeholder or erroneous Constant>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,7 +496,8 @@ ostream &AssemblyWriter::printTypeAtLeastOneLevel(const Type *Ty) {
|
|||||||
} else if (const OpaqueType *OTy = dyn_cast<OpaqueType>(Ty)) {
|
} else if (const OpaqueType *OTy = dyn_cast<OpaqueType>(Ty)) {
|
||||||
Out << OTy->getDescription();
|
Out << OTy->getDescription();
|
||||||
} else {
|
} else {
|
||||||
assert(Ty->isPrimitiveType() && "Unknown derived type!");
|
if (!Ty->isPrimitiveType())
|
||||||
|
Out << "<unknown derived type>";
|
||||||
printType(Ty);
|
printType(Ty);
|
||||||
}
|
}
|
||||||
return Out;
|
return Out;
|
||||||
|
Loading…
Reference in New Issue
Block a user