}
std::ostream &printType(std::ostream &Out, const Type *Ty,
- bool isSigned = true,
+ bool isSigned = false,
const std::string &VariableName = "",
bool IgnoreName = false);
std::ostream &printPrimitiveType(std::ostream &Out, const Type *Ty,
if (PrintedType)
FunctionInnards << ", ";
printType(FunctionInnards, *I,
- /*isSigned=*/!FTy->paramHasAttr(Idx, FunctionType::ZExtAttribute), "");
+ /*isSigned=*/FTy->paramHasAttr(Idx, FunctionType::SExtAttribute), "");
PrintedType = true;
}
if (FTy->isVarArg()) {
FunctionInnards << ')';
std::string tstr = FunctionInnards.str();
printType(Out, RetTy,
- /*isSigned=*/!FTy->paramHasAttr(0, FunctionType::SExtAttribute), tstr);
+ /*isSigned=*/FTy->paramHasAttr(0, FunctionType::SExtAttribute), tstr);
}
std::ostream &
if (I != FTy->param_begin())
FunctionInnards << ", ";
printType(FunctionInnards, *I,
- /*isSigned=*/!FTy->paramHasAttr(Idx, FunctionType::ZExtAttribute), "");
+ /*isSigned=*/FTy->paramHasAttr(Idx, FunctionType::SExtAttribute), "");
++Idx;
}
if (FTy->isVarArg()) {
FunctionInnards << ')';
std::string tstr = FunctionInnards.str();
printType(Out, FTy->getReturnType(),
- /*isSigned=*/!FTy->paramHasAttr(0, FunctionType::ZExtAttribute), tstr);
+ /*isSigned=*/FTy->paramHasAttr(0, FunctionType::SExtAttribute), tstr);
return Out;
}
case Type::StructTyID: {
for (StructType::element_iterator I = STy->element_begin(),
E = STy->element_end(); I != E; ++I) {
Out << " ";
- printType(Out, *I, true, "field" + utostr(Idx++));
+ printType(Out, *I, false, "field" + utostr(Idx++));
Out << ";\n";
}
return Out << '}';
isa<PackedType>(PTy->getElementType()))
ptrName = "(" + ptrName + ")";
- return printType(Out, PTy->getElementType(), true, ptrName);
+ return printType(Out, PTy->getElementType(), false, ptrName);
}
case Type::ArrayTyID: {
const ArrayType *ATy = cast<ArrayType>(Ty);
unsigned NumElements = ATy->getNumElements();
if (NumElements == 0) NumElements = 1;
- return printType(Out, ATy->getElementType(), true,
+ return printType(Out, ATy->getElementType(), false,
NameSoFar + "[" + utostr(NumElements) + "]");
}
const PackedType *PTy = cast<PackedType>(Ty);
unsigned NumElements = PTy->getNumElements();
if (NumElements == 0) NumElements = 1;
- return printType(Out, PTy->getElementType(), true,
+ return printType(Out, PTy->getElementType(), false,
NameSoFar + "[" + utostr(NumElements) + "]");
}
if (ConstantInt *CI = dyn_cast<ConstantInt>(CPV)) {
const Type* Ty = CI->getType();
Out << "((";
- printPrimitiveType(Out, Ty, true) << ')';
+ printPrimitiveType(Out, Ty, false) << ')';
if (CI->isMinValue(true))
Out << CI->getZExtValue() << 'u';
else
}
if (NeedsExplicitCast) {
Out << "((";
- if (Ty->isPrimitiveType())
+ if (Ty->isInteger())
printPrimitiveType(Out, Ty, TypeIsSigned);
else
- printType(Out, Ty);
+ printType(Out, Ty); // not integer, sign doesn't matter
Out << ")(";
}
return NeedsExplicitCast;
// operand.
if (shouldCast) {
Out << "((";
- if (OpTy->isPrimitiveType())
+ if (OpTy->isInteger())
printPrimitiveType(Out, OpTy, castIsSigned);
else
- printType(Out, OpTy);
+ printType(Out, OpTy); // not integer, sign doesn't matter
Out << ")";
writeOperand(Operand);
Out << ")";
I != E; ++I) {
if (I->hasExternalLinkage()) {
Out << "extern ";
- printType(Out, I->getType()->getElementType(), true,
+ printType(Out, I->getType()->getElementType(), false,
Mang->getValueName(I));
Out << ";\n";
} else if (I->hasDLLImportLinkage()) {
Out << "__declspec(dllimport) ";
- printType(Out, I->getType()->getElementType(), true,
+ printType(Out, I->getType()->getElementType(), false,
Mang->getValueName(I));
Out << ";\n";
} else if (I->hasExternalWeakLinkage()) {
Out << "extern ";
- printType(Out, I->getType()->getElementType(), true,
+ printType(Out, I->getType()->getElementType(), false,
Mang->getValueName(I));
Out << " __EXTERNAL_WEAK__ ;\n";
}
Out << "static ";
else
Out << "extern ";
- printType(Out, I->getType()->getElementType(), true,
+ printType(Out, I->getType()->getElementType(), false,
Mang->getValueName(I));
if (I->hasLinkOnceLinkage())
else if (I->hasDLLExportLinkage())
Out << "__declspec(dllexport) ";
- printType(Out, I->getType()->getElementType(), true,
+ printType(Out, I->getType()->getElementType(), false,
Mang->getValueName(I));
if (I->hasLinkOnceLinkage())
Out << " __attribute__((common))";
const Type *Ty = cast<Type>(I->second);
std::string Name = "l_" + Mang->makeNameProper(I->first);
Out << "typedef ";
- printType(Out, Ty, true, Name);
+ printType(Out, Ty, false, Name);
Out << ";\n";
}
if (StructPrinted.insert(STy).second) {
// Print structure type out.
std::string Name = TypeNames[STy];
- printType(Out, STy, true, Name, true);
+ printType(Out, STy, false, Name, true);
Out << ";\n\n";
}
}
else
ArgName = "";
printType(FunctionInnards, I->getType(),
- /*isSigned=*/!FT->paramHasAttr(Idx, FunctionType::ZExtAttribute),
+ /*isSigned=*/FT->paramHasAttr(Idx, FunctionType::SExtAttribute),
ArgName);
PrintedArg = true;
++Idx;
for (; I != E; ++I) {
if (PrintedArg) FunctionInnards << ", ";
printType(FunctionInnards, *I,
- /*isSigned=*/!FT->paramHasAttr(Idx, FunctionType::ZExtAttribute));
+ /*isSigned=*/FT->paramHasAttr(Idx, FunctionType::SExtAttribute));
PrintedArg = true;
++Idx;
}
// Print out the return type and the signature built above.
printType(Out, RetTy,
- /*isSigned=*/!FT->paramHasAttr(0, FunctionType::ZExtAttribute),
+ /*isSigned=*/FT->paramHasAttr(0, FunctionType::SExtAttribute),
FunctionInnards.str());
}
const Type *StructTy =
cast<PointerType>(F.arg_begin()->getType())->getElementType();
Out << " ";
- printType(Out, StructTy, true, "StructReturn");
+ printType(Out, StructTy, false, "StructReturn");
Out << "; /* Struct return temporary */\n";
Out << " ";
- printType(Out, F.arg_begin()->getType(), true,
+ printType(Out, F.arg_begin()->getType(), false,
Mang->getValueName(F.arg_begin()));
Out << " = &StructReturn;\n";
}
for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) {
if (const AllocaInst *AI = isDirectAlloca(&*I)) {
Out << " ";
- printType(Out, AI->getAllocatedType(), true, Mang->getValueName(AI));
+ printType(Out, AI->getAllocatedType(), false, Mang->getValueName(AI));
Out << "; /* Address-exposed local */\n";
PrintedVar = true;
} else if (I->getType() != Type::VoidTy && !isInlinableInst(*I)) {
Out << " ";
- printType(Out, I->getType(), true, Mang->getValueName(&*I));
+ printType(Out, I->getType(), false, Mang->getValueName(&*I));
Out << ";\n";
if (isa<PHINode>(*I)) { // Print out PHI node temporaries as well...
Out << " ";
- printType(Out, I->getType(), true,
+ printType(Out, I->getType(), false,
Mang->getValueName(&*I)+"__PHI_TEMPORARY");
Out << ";\n";
}
|| (I.getType() == Type::FloatTy)) {
needsCast = true;
Out << "((";
- printType(Out, I.getType());
+ printType(Out, I.getType(), false);
Out << ")(";
}
(*AI)->getType() != FTy->getParamType(ArgNo)) {
Out << '(';
printType(Out, FTy->getParamType(ArgNo),
- /*isSigned=*/!FTy->paramHasAttr(Idx, FunctionType::ZExtAttribute));
+ /*isSigned=*/FTy->paramHasAttr(Idx, FunctionType::SExtAttribute));
Out << ')';
}
writeOperand(*AI);
Out << '*';
if (I.isVolatile()) {
Out << "((";
- printType(Out, I.getType(), true, "volatile*");
+ printType(Out, I.getType(), false, "volatile*");
Out << ")";
}
Out << '*';
if (I.isVolatile()) {
Out << "((";
- printType(Out, I.getOperand(0)->getType(), true, " volatile*");
+ printType(Out, I.getOperand(0)->getType(), false, " volatile*");
Out << ")";
}
writeOperand(I.getPointerOperand());
}
std::ostream &printType(std::ostream &Out, const Type *Ty,
- bool isSigned = true,
+ bool isSigned = false,
const std::string &VariableName = "",
bool IgnoreName = false);
std::ostream &printPrimitiveType(std::ostream &Out, const Type *Ty,
if (PrintedType)
FunctionInnards << ", ";
printType(FunctionInnards, *I,
- /*isSigned=*/!FTy->paramHasAttr(Idx, FunctionType::ZExtAttribute), "");
+ /*isSigned=*/FTy->paramHasAttr(Idx, FunctionType::SExtAttribute), "");
PrintedType = true;
}
if (FTy->isVarArg()) {
FunctionInnards << ')';
std::string tstr = FunctionInnards.str();
printType(Out, RetTy,
- /*isSigned=*/!FTy->paramHasAttr(0, FunctionType::SExtAttribute), tstr);
+ /*isSigned=*/FTy->paramHasAttr(0, FunctionType::SExtAttribute), tstr);
}
std::ostream &
if (I != FTy->param_begin())
FunctionInnards << ", ";
printType(FunctionInnards, *I,
- /*isSigned=*/!FTy->paramHasAttr(Idx, FunctionType::ZExtAttribute), "");
+ /*isSigned=*/FTy->paramHasAttr(Idx, FunctionType::SExtAttribute), "");
++Idx;
}
if (FTy->isVarArg()) {
FunctionInnards << ')';
std::string tstr = FunctionInnards.str();
printType(Out, FTy->getReturnType(),
- /*isSigned=*/!FTy->paramHasAttr(0, FunctionType::ZExtAttribute), tstr);
+ /*isSigned=*/FTy->paramHasAttr(0, FunctionType::SExtAttribute), tstr);
return Out;
}
case Type::StructTyID: {
for (StructType::element_iterator I = STy->element_begin(),
E = STy->element_end(); I != E; ++I) {
Out << " ";
- printType(Out, *I, true, "field" + utostr(Idx++));
+ printType(Out, *I, false, "field" + utostr(Idx++));
Out << ";\n";
}
return Out << '}';
isa<PackedType>(PTy->getElementType()))
ptrName = "(" + ptrName + ")";
- return printType(Out, PTy->getElementType(), true, ptrName);
+ return printType(Out, PTy->getElementType(), false, ptrName);
}
case Type::ArrayTyID: {
const ArrayType *ATy = cast<ArrayType>(Ty);
unsigned NumElements = ATy->getNumElements();
if (NumElements == 0) NumElements = 1;
- return printType(Out, ATy->getElementType(), true,
+ return printType(Out, ATy->getElementType(), false,
NameSoFar + "[" + utostr(NumElements) + "]");
}
const PackedType *PTy = cast<PackedType>(Ty);
unsigned NumElements = PTy->getNumElements();
if (NumElements == 0) NumElements = 1;
- return printType(Out, PTy->getElementType(), true,
+ return printType(Out, PTy->getElementType(), false,
NameSoFar + "[" + utostr(NumElements) + "]");
}
if (ConstantInt *CI = dyn_cast<ConstantInt>(CPV)) {
const Type* Ty = CI->getType();
Out << "((";
- printPrimitiveType(Out, Ty, true) << ')';
+ printPrimitiveType(Out, Ty, false) << ')';
if (CI->isMinValue(true))
Out << CI->getZExtValue() << 'u';
else
}
if (NeedsExplicitCast) {
Out << "((";
- if (Ty->isPrimitiveType())
+ if (Ty->isInteger())
printPrimitiveType(Out, Ty, TypeIsSigned);
else
- printType(Out, Ty);
+ printType(Out, Ty); // not integer, sign doesn't matter
Out << ")(";
}
return NeedsExplicitCast;
// operand.
if (shouldCast) {
Out << "((";
- if (OpTy->isPrimitiveType())
+ if (OpTy->isInteger())
printPrimitiveType(Out, OpTy, castIsSigned);
else
- printType(Out, OpTy);
+ printType(Out, OpTy); // not integer, sign doesn't matter
Out << ")";
writeOperand(Operand);
Out << ")";
I != E; ++I) {
if (I->hasExternalLinkage()) {
Out << "extern ";
- printType(Out, I->getType()->getElementType(), true,
+ printType(Out, I->getType()->getElementType(), false,
Mang->getValueName(I));
Out << ";\n";
} else if (I->hasDLLImportLinkage()) {
Out << "__declspec(dllimport) ";
- printType(Out, I->getType()->getElementType(), true,
+ printType(Out, I->getType()->getElementType(), false,
Mang->getValueName(I));
Out << ";\n";
} else if (I->hasExternalWeakLinkage()) {
Out << "extern ";
- printType(Out, I->getType()->getElementType(), true,
+ printType(Out, I->getType()->getElementType(), false,
Mang->getValueName(I));
Out << " __EXTERNAL_WEAK__ ;\n";
}
Out << "static ";
else
Out << "extern ";
- printType(Out, I->getType()->getElementType(), true,
+ printType(Out, I->getType()->getElementType(), false,
Mang->getValueName(I));
if (I->hasLinkOnceLinkage())
else if (I->hasDLLExportLinkage())
Out << "__declspec(dllexport) ";
- printType(Out, I->getType()->getElementType(), true,
+ printType(Out, I->getType()->getElementType(), false,
Mang->getValueName(I));
if (I->hasLinkOnceLinkage())
Out << " __attribute__((common))";
const Type *Ty = cast<Type>(I->second);
std::string Name = "l_" + Mang->makeNameProper(I->first);
Out << "typedef ";
- printType(Out, Ty, true, Name);
+ printType(Out, Ty, false, Name);
Out << ";\n";
}
if (StructPrinted.insert(STy).second) {
// Print structure type out.
std::string Name = TypeNames[STy];
- printType(Out, STy, true, Name, true);
+ printType(Out, STy, false, Name, true);
Out << ";\n\n";
}
}
else
ArgName = "";
printType(FunctionInnards, I->getType(),
- /*isSigned=*/!FT->paramHasAttr(Idx, FunctionType::ZExtAttribute),
+ /*isSigned=*/FT->paramHasAttr(Idx, FunctionType::SExtAttribute),
ArgName);
PrintedArg = true;
++Idx;
for (; I != E; ++I) {
if (PrintedArg) FunctionInnards << ", ";
printType(FunctionInnards, *I,
- /*isSigned=*/!FT->paramHasAttr(Idx, FunctionType::ZExtAttribute));
+ /*isSigned=*/FT->paramHasAttr(Idx, FunctionType::SExtAttribute));
PrintedArg = true;
++Idx;
}
// Print out the return type and the signature built above.
printType(Out, RetTy,
- /*isSigned=*/!FT->paramHasAttr(0, FunctionType::ZExtAttribute),
+ /*isSigned=*/FT->paramHasAttr(0, FunctionType::SExtAttribute),
FunctionInnards.str());
}
const Type *StructTy =
cast<PointerType>(F.arg_begin()->getType())->getElementType();
Out << " ";
- printType(Out, StructTy, true, "StructReturn");
+ printType(Out, StructTy, false, "StructReturn");
Out << "; /* Struct return temporary */\n";
Out << " ";
- printType(Out, F.arg_begin()->getType(), true,
+ printType(Out, F.arg_begin()->getType(), false,
Mang->getValueName(F.arg_begin()));
Out << " = &StructReturn;\n";
}
for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) {
if (const AllocaInst *AI = isDirectAlloca(&*I)) {
Out << " ";
- printType(Out, AI->getAllocatedType(), true, Mang->getValueName(AI));
+ printType(Out, AI->getAllocatedType(), false, Mang->getValueName(AI));
Out << "; /* Address-exposed local */\n";
PrintedVar = true;
} else if (I->getType() != Type::VoidTy && !isInlinableInst(*I)) {
Out << " ";
- printType(Out, I->getType(), true, Mang->getValueName(&*I));
+ printType(Out, I->getType(), false, Mang->getValueName(&*I));
Out << ";\n";
if (isa<PHINode>(*I)) { // Print out PHI node temporaries as well...
Out << " ";
- printType(Out, I->getType(), true,
+ printType(Out, I->getType(), false,
Mang->getValueName(&*I)+"__PHI_TEMPORARY");
Out << ";\n";
}
|| (I.getType() == Type::FloatTy)) {
needsCast = true;
Out << "((";
- printType(Out, I.getType());
+ printType(Out, I.getType(), false);
Out << ")(";
}
(*AI)->getType() != FTy->getParamType(ArgNo)) {
Out << '(';
printType(Out, FTy->getParamType(ArgNo),
- /*isSigned=*/!FTy->paramHasAttr(Idx, FunctionType::ZExtAttribute));
+ /*isSigned=*/FTy->paramHasAttr(Idx, FunctionType::SExtAttribute));
Out << ')';
}
writeOperand(*AI);
Out << '*';
if (I.isVolatile()) {
Out << "((";
- printType(Out, I.getType(), true, "volatile*");
+ printType(Out, I.getType(), false, "volatile*");
Out << ")";
}
Out << '*';
if (I.isVolatile()) {
Out << "((";
- printType(Out, I.getOperand(0)->getType(), true, " volatile*");
+ printType(Out, I.getOperand(0)->getType(), false, " volatile*");
Out << ")";
}
writeOperand(I.getPointerOperand());