#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLowering.h"
#include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/ADT/SmallPtrSet.h"
#include <cerrno>
using namespace llvm;
char AsmPrinter::ID = 0;
AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm,
const TargetAsmInfo *T)
- : MachineFunctionPass((intptr_t)&ID), FunctionNumber(0), O(o), TM(tm), TAI(T),
+ : MachineFunctionPass((intptr_t)&ID), FunctionNumber(0), O(o),
+ TM(tm), TAI(T), TRI(tm.getRegisterInfo()),
IsInTextSection(false)
{}
O << TAI->getWeakRefDirective() << Name << "\n";
else if (!I->hasInternalLinkage())
assert(0 && "Invalid alias linkage");
-
+
+ if (I->hasHiddenVisibility()) {
+ if (const char *Directive = TAI->getHiddenDirective())
+ O << Directive << Name << "\n";
+ } else if (I->hasProtectedVisibility()) {
+ if (const char *Directive = TAI->getProtectedDirective())
+ O << Directive << Name << "\n";
+ }
+
O << TAI->getSetDirective() << ' ' << Name << ", " << Target << "\n";
// If the aliasee has external weak linkage it can be referenced only by
E = CMM->begin(); I != E; )
(*--I)->finishAssembly(O, *this, *TAI);
+ // If we don't have any trampolines, then we don't require stack memory
+ // to be executable. Some targets have a directive to declare this.
+ Function* InitTrampolineIntrinsic = M.getFunction("llvm.init.trampoline");
+ if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->use_empty())
+ if (TAI->getNonexecutableStackDirective())
+ O << TAI->getNonexecutableStackDirective() << "\n";
+
delete Mang; Mang = 0;
return false;
}
std::string AsmPrinter::getCurrentFunctionEHName(const MachineFunction *MF) {
assert(MF && "No machine function?");
- return Mang->makeNameProper(MF->getFunction()->getName() + ".eh",
- TAI->getGlobalPrefix());
+ std::string Name = MF->getFunction()->getName();
+ if (Name.empty())
+ Name = Mang->getValueName(MF->getFunction());
+ return Mang->makeNameProper(Name + ".eh", TAI->getGlobalPrefix());
}
void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
const Type *type = CV->getType();
printDataDirective(type);
EmitConstantValueOnly(CV);
+ if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
+ O << "\t\t\t"
+ << TAI->getCommentString()
+ << " 0x" << CI->getValue().toStringUnsigned(16);
+ }
O << "\n";
}
O << "\n\t" << TAI->getInlineAsmEnd() << "\n";
}
+/// printImplicitDef - This method prints the specified machine instruction
+/// that is an implicit def.
+void AsmPrinter::printImplicitDef(const MachineInstr *MI) const {
+ O << "\t" << TAI->getCommentString() << " implicit-def: "
+ << TRI->getAsmName(MI->getOperand(0).getReg()) << "\n";
+}
+
/// printLabel - This method prints a local label used by debug and
/// exception handling tables.
void AsmPrinter::printLabel(const MachineInstr *MI) const {
}
}
+void AsmPrinter::printSuffixedName(std::string &Name, const char* Suffix) {
+ if (Name[0]=='\"')
+ O << "\"" << TAI->getPrivateGlobalPrefix() <<
+ Name.substr(1, Name.length()-2) << Suffix << "\"";
+ else
+ O << TAI->getPrivateGlobalPrefix() << Name << Suffix;
+}