#include "llvm/Module.h"
#include "llvm/Type.h"
#include "llvm/Assembly/Writer.h"
-#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/Mangler.h"
#include "llvm/ADT/Statistic.h"
-
+#include <iostream>
using namespace llvm;
namespace {
}
bool printInstruction(const MachineInstr *MI);
void printOp(const MachineOperand &MO, bool IsCallOp = false);
- void printOperand(const MachineInstr *MI, int opNum, MVT::ValueType VT);
+ void printOperand(const MachineInstr *MI, int opNum);
void printBaseOffsetPair (const MachineInstr *MI, int i, bool brackets=true);
void printMachineInstruction(const MachineInstr *MI);
bool runOnMachineFunction(MachineFunction &F);
#include "AlphaGenAsmWriter.inc"
-void AlphaAsmPrinter::printOperand(const MachineInstr *MI, int opNum, MVT::ValueType VT)
+void AlphaAsmPrinter::printOperand(const MachineInstr *MI, int opNum)
{
const MachineOperand &MO = MI->getOperand(opNum);
if (MO.getType() == MachineOperand::MO_MachineRegister) {
case MachineOperand::MO_GlobalAddress:
//Abuse PCrel to specify pcrel calls
//calls are the only thing that use this flag
- if (MO.isPCRelative())
- O << PrivateGlobalPrefix << Mang->getValueName(MO.getGlobal()) << "..ng";
- else
+// if (MO.isPCRelative())
+// O << PrivateGlobalPrefix << Mang->getValueName(MO.getGlobal()) << "..ng";
+// else
O << Mang->getValueName(MO.getGlobal());
return;
EmitConstantPool(MF.getConstantPool());
// Print out labels for the function.
- SwitchSection("\t.section .text", MF.getFunction());
- EmitAlignment(4);
- O << "\t.globl " << CurrentFnName << "\n";
+ const Function *F = MF.getFunction();
+ SwitchSection(".text", F);
+ EmitAlignment(4, F);
+ switch (F->getLinkage()) {
+ default: assert(0 && "Unknown linkage type!");
+ case Function::InternalLinkage: // Symbols default to internal.
+ break;
+ case Function::ExternalLinkage:
+ O << "\t.globl " << CurrentFnName << "\n";
+ break;
+ case Function::WeakLinkage:
+ case Function::LinkOnceLinkage:
+ O << "\t.weak " << CurrentFnName << "\n";
+ break;
+ }
+
O << "\t.ent " << CurrentFnName << "\n";
O << CurrentFnName << ":\n";
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
if (I->hasInitializer()) { // External global require no code
+ // Check to see if this is a special global used by LLVM, if so, emit it.
+ if (EmitSpecialLLVMGlobal(I))
+ continue;
+
O << "\n\n";
std::string name = Mang->getValueName(I);
Constant *C = I->getInitializer();
unsigned Size = TD.getTypeSize(C->getType());
- unsigned Align = TD.getTypeAlignmentShift(C->getType());
+ // unsigned Align = TD.getTypeAlignmentShift(C->getType());
+ unsigned Align = getPreferredAlignmentLog(I);
if (C->isNullValue() &&
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
O << "\t.local " << name << "\n";
O << "\t.comm " << name << "," << TD.getTypeSize(C->getType())
- << "," << (1 << Align);
- O << "\t\t# ";
- WriteAsOperand(O, I, true, true, &M);
- O << "\n";
+ << "," << (1 << Align)
+ << "\n";
} else {
switch (I->getLinkage()) {
case GlobalValue::LinkOnceLinkage:
EmitAlignment(Align);
O << "\t.type " << name << ",@object\n";
O << "\t.size " << name << "," << Size << "\n";
- O << name << ":\t\t\t\t# ";
- WriteAsOperand(O, I, true, true, &M);
- O << " = ";
- WriteAsOperand(O, C, false, false, &M);
- O << "\n";
+ O << name << ":\n";
EmitGlobalConstant(C);
}
}