#include "llvm/CallingConv.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
-#include "llvm/ParamAttrsList.h"
#include "llvm/InlineAsm.h"
#include "llvm/Instruction.h"
#include "llvm/Instructions.h"
printType(Operand->getType());
// Print parameter attributes list
if (Attrs != ParamAttr::None)
- Out << ' ' << ParamAttrsList::getParamAttrsText(Attrs);
+ Out << ' ' << ParamAttr::getAsString(Attrs);
// Print the operand
WriteAsOperandInternal(Out, Operand, TypeNames, &Machine);
}
}
const FunctionType *FT = F->getFunctionType();
- const ParamAttrsList *Attrs = F->getParamAttrs();
+ const PAListPtr &Attrs = F->getParamAttrs();
printType(F->getReturnType()) << ' ';
if (!F->getName().empty())
Out << getLLVMName(F->getName(), GlobalPrefix);
I != E; ++I) {
// Insert commas as we go... the first arg doesn't get a comma
if (I != F->arg_begin()) Out << ", ";
- printArgument(I, (Attrs ? Attrs->getParamAttrs(Idx)
- : ParamAttr::None));
+ printArgument(I, Attrs.getParamAttrs(Idx));
Idx++;
}
} else {
// Output type...
printType(FT->getParamType(i));
- ParameterAttributes ArgAttrs = ParamAttr::None;
- if (Attrs) ArgAttrs = Attrs->getParamAttrs(i+1);
+ ParameterAttributes ArgAttrs = Attrs.getParamAttrs(i+1);
if (ArgAttrs != ParamAttr::None)
- Out << ' ' << ParamAttrsList::getParamAttrsText(ArgAttrs);
+ Out << ' ' << ParamAttr::getAsString(ArgAttrs);
}
}
Out << "..."; // Output varargs portion of signature!
}
Out << ')';
- if (Attrs && Attrs->getParamAttrs(0) != ParamAttr::None)
- Out << ' ' << Attrs->getParamAttrsTextByIndex(0);
+ ParameterAttributes RetAttrs = Attrs.getParamAttrs(0);
+ if (RetAttrs != ParamAttr::None)
+ Out << ' ' << ParamAttr::getAsString(Attrs.getParamAttrs(0));
if (F->hasSection())
Out << " section \"" << F->getSection() << '"';
if (F->getAlignment())
if (F->isDeclaration()) {
Out << "\n";
} else {
- Out << " {";
+ Out << " {\n";
// Output all of its basic blocks... for the function
for (Function::const_iterator I = F->begin(), E = F->end(); I != E; ++I)
// Output parameter attributes list
if (Attrs != ParamAttr::None)
- Out << ' ' << ParamAttrsList::getParamAttrsText(Attrs);
+ Out << ' ' << ParamAttr::getAsString(Attrs);
// Output name, if available...
if (Arg->hasName())
/// printBasicBlock - This member is called for each basic block in a method.
///
void AssemblyWriter::printBasicBlock(const BasicBlock *BB) {
- if (BB->hasName()) { // Print out the label if it exists...
- Out << "\n" << getLLVMName(BB->getName(), LabelPrefix) << ':';
- } else if (!BB->use_empty()) { // Don't print block # of no uses...
- Out << "\n; <label>:";
+ if (BB->hasName()) // Print out the label if it exists...
+ Out << getLLVMName(BB->getName(), LabelPrefix) << ':';
+
+ if (const BasicBlock* unwindDest = BB->getUnwindDest()) {
+ if (BB->hasName())
+ Out << ' ';
+
+ Out << "unwinds to";
+ writeOperand(unwindDest, false);
+ }
+
+ if (!BB->hasName() && !BB->use_empty()) { // Don't print block # of no uses...
+ Out << "; <label>:";
int Slot = Machine.getLocalSlot(BB);
if (Slot != -1)
Out << Slot;
}
}
- Out << "\n";
+ if (BB->hasName() || !BB->use_empty() || BB->getUnwindDest() ||
+ BB != &BB->getParent()->getEntryBlock())
+ Out << "\n";
if (AnnotationWriter) AnnotationWriter->emitBasicBlockStartAnnot(BB, Out);
writeOperand(I.getOperand(op+1), false); Out << " ]";
}
} else if (const GetResultInst *GRI = dyn_cast<GetResultInst>(&I)) {
- const StructType *STy = cast<StructType>(I.getOperand(0)->getType());
- unsigned NumElems = STy->getNumElements();
- Out << " {";
- for (unsigned i = 0; i < NumElems; ++i) {
- if (i)
- Out << ",";
- Out << " ";
- printType(STy->getElementType(i));
- }
- Out << " }";
- writeOperand(I.getOperand(0), false);
+ writeOperand(I.getOperand(0), true);
Out << ", " << GRI->getIndex();
} else if (isa<ReturnInst>(I) && !Operand) {
Out << " void";
const PointerType *PTy = cast<PointerType>(Operand->getType());
const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
const Type *RetTy = FTy->getReturnType();
- const ParamAttrsList *PAL = CI->getParamAttrs();
+ const PAListPtr &PAL = CI->getParamAttrs();
// If possible, print out the short form of the call instruction. We can
// only do this if the first argument is a pointer to a nonvararg function,
for (unsigned op = 1, Eop = I.getNumOperands(); op < Eop; ++op) {
if (op > 1)
Out << ',';
- writeParamOperand(I.getOperand(op), PAL ? PAL->getParamAttrs(op) :
- ParamAttr::None);
+ writeParamOperand(I.getOperand(op), PAL.getParamAttrs(op));
}
Out << " )";
- if (PAL && PAL->getParamAttrs(0) != ParamAttr::None)
- Out << ' ' << PAL->getParamAttrsTextByIndex(0);
+ if (PAL.getParamAttrs(0) != ParamAttr::None)
+ Out << ' ' << ParamAttr::getAsString(PAL.getParamAttrs(0));
} else if (const InvokeInst *II = dyn_cast<InvokeInst>(&I)) {
const PointerType *PTy = cast<PointerType>(Operand->getType());
const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
const Type *RetTy = FTy->getReturnType();
- const ParamAttrsList *PAL = II->getParamAttrs();
+ const PAListPtr &PAL = II->getParamAttrs();
// Print the calling convention being used.
switch (II->getCallingConv()) {
for (unsigned op = 3, Eop = I.getNumOperands(); op < Eop; ++op) {
if (op > 3)
Out << ',';
- writeParamOperand(I.getOperand(op), PAL ? PAL->getParamAttrs(op-2) :
- ParamAttr::None);
+ writeParamOperand(I.getOperand(op), PAL.getParamAttrs(op-2));
}
Out << " )";
- if (PAL && PAL->getParamAttrs(0) != ParamAttr::None)
- Out << " " << PAL->getParamAttrsTextByIndex(0);
+ if (PAL.getParamAttrs(0) != ParamAttr::None)
+ Out << " " << ParamAttr::getAsString(PAL.getParamAttrs(0));
Out << "\n\t\t\tto";
writeOperand(II->getNormalDest(), true);
Out << " unwind";
const Type *TheType = Operand->getType();
// Select, Store and ShuffleVector always print all types.
- if (isa<SelectInst>(I) || isa<StoreInst>(I) || isa<ShuffleVectorInst>(I)) {
+ if (isa<SelectInst>(I) || isa<StoreInst>(I) || isa<ShuffleVectorInst>(I)
+ || isa<ReturnInst>(I)) {
PrintAllTypes = true;
} else {
for (unsigned i = 1, E = I.getNumOperands(); i != E; ++i) {
// Located here because so much of the needed functionality is here.
void Type::dump() const { print(*cerr.stream()); cerr << '\n'; }
-void
-ParamAttrsList::dump() const {
- cerr << "PAL[ ";
- for (unsigned i = 0; i < attrs.size(); ++i) {
- uint16_t index = getParamIndex(i);
- ParameterAttributes attrs = getParamAttrs(index);
- cerr << "{" << index << "," << attrs << "} ";
- }
-
- cerr << "]\n";
-}
-
//===----------------------------------------------------------------------===//
// SlotMachine Implementation
//===----------------------------------------------------------------------===//