#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
-#include "llvm/Assembly/Writer.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MathExtras.h"
#include <cctype>
-#include <iostream>
using namespace llvm;
namespace {
- Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
+ Statistic EmittedInsts("asm-printer", "Number of machine instrs printed");
static const char *ARMCondCodeToString(ARMCC::CondCodes CC) {
switch (CC) {
: AsmPrinter(O, TM, T) {
}
+ std::set<std::string> ExtWeakSymbols;
+
/// We name each basic block in a Function with a unique number, so
/// that we can consistently refer to them later. This is cleared
/// at the beginning of each call to runOnMachineFunction().
break;
case Function::WeakLinkage:
case Function::LinkOnceLinkage:
- assert(0 && "Not implemented");
+ O << TAI->getWeakRefDirective() << CurrentFnName << "\n";
break;
}
EmitAlignment(2, F);
GlobalValue *GV = MO.getGlobal();
std::string Name = Mang->getValueName(GV);
O << Name;
+ if (GV->hasExternalWeakLinkage()) {
+ ExtWeakSymbols.insert(Name);
+ }
}
break;
case MachineOperand::MO_ExternalSymbol:
unsigned Align = TD->getTypeAlignment(C->getType());
if (C->isNullValue() &&
+ !I->hasSection() &&
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
I->hasWeakLinkage())) {
SwitchToDataSection(".data", I);
O << "\t.comm " << name << "," << TD->getTypeSize(C->getType())
<< "," << (unsigned)TD->getTypeAlignment(C->getType());
- O << "\t\t";
- O << TAI->getCommentString() << " ";
- WriteAsOperand(O, I, true, true, &M);
O << "\n";
} else {
switch (I->getLinkage()) {
}
}
+ if (ExtWeakSymbols.begin() != ExtWeakSymbols.end())
+ SwitchToDataSection("");
+ for (std::set<std::string>::iterator i = ExtWeakSymbols.begin(),
+ e = ExtWeakSymbols.end(); i != e; ++i) {
+ O << TAI->getWeakRefDirective() << *i << "\n";
+ }
+
AsmPrinter::doFinalization(M);
return false; // success
}