mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Finegrainify namespacification
Start using the AsmPrinter base class to factor out a bunch of code git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15840 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
#include "llvm/CodeGen/MachineConstantPool.h"
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
@@ -35,36 +36,17 @@
|
|||||||
#include "Support/Statistic.h"
|
#include "Support/Statistic.h"
|
||||||
#include "Support/StringExtras.h"
|
#include "Support/StringExtras.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
|
using namespace llvm;
|
||||||
namespace llvm {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
||||||
|
|
||||||
struct PowerPCAsmPrinter : public MachineFunctionPass {
|
struct PowerPCAsmPrinter : public AsmPrinter {
|
||||||
/// Output stream on which we're printing assembly code.
|
|
||||||
///
|
|
||||||
std::ostream &O;
|
|
||||||
|
|
||||||
/// Target machine description which we query for reg. names, data
|
|
||||||
/// layout, etc.
|
|
||||||
///
|
|
||||||
PowerPCTargetMachine &TM;
|
|
||||||
|
|
||||||
/// Name-mangler for global names.
|
|
||||||
///
|
|
||||||
Mangler *Mang;
|
|
||||||
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
||||||
std::set<std::string> Strings;
|
std::set<std::string> Strings;
|
||||||
|
|
||||||
PowerPCAsmPrinter(std::ostream &o, TargetMachine &tm) : O(o),
|
PowerPCAsmPrinter(std::ostream &O, TargetMachine &TM)
|
||||||
TM(reinterpret_cast<PowerPCTargetMachine&>(tm)), LabelNumber(0) {}
|
: AsmPrinter(O, TM), LabelNumber(0) {}
|
||||||
|
|
||||||
/// Cache of mangled name for current function. This is
|
|
||||||
/// recalculated at the beginning of each call to
|
|
||||||
/// runOnMachineFunction().
|
|
||||||
///
|
|
||||||
std::string CurrentFnName;
|
|
||||||
|
|
||||||
/// Unique incrementer for label values for referencing Global values.
|
/// Unique incrementer for label values for referencing Global values.
|
||||||
///
|
///
|
||||||
@@ -74,6 +56,10 @@ namespace {
|
|||||||
return "PowerPC Assembly Printer";
|
return "PowerPC Assembly Printer";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PowerPCTargetMachine &getTM() {
|
||||||
|
return static_cast<PowerPCTargetMachine&>(TM);
|
||||||
|
}
|
||||||
|
|
||||||
/// printInstruction - This method is automatically generated by tablegen
|
/// printInstruction - This method is automatically generated by tablegen
|
||||||
/// from the instruction set description. This method returns true if the
|
/// from the instruction set description. This method returns true if the
|
||||||
/// machine instruction was sufficiently described to print it, otherwise it
|
/// machine instruction was sufficiently described to print it, otherwise it
|
||||||
@@ -103,10 +89,8 @@ namespace {
|
|||||||
|
|
||||||
void printConstantPool(MachineConstantPool *MCP);
|
void printConstantPool(MachineConstantPool *MCP);
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
bool runOnMachineFunction(MachineFunction &F);
|
||||||
bool doInitialization(Module &M);
|
|
||||||
bool doFinalization(Module &M);
|
bool doFinalization(Module &M);
|
||||||
void emitGlobalConstant(const Constant* CV);
|
void emitGlobalConstant(const Constant* CV);
|
||||||
void emitConstantValueOnly(const Constant *CV);
|
|
||||||
};
|
};
|
||||||
} // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
|
|
||||||
@@ -115,7 +99,7 @@ namespace {
|
|||||||
/// using the given target machine description. This should work
|
/// using the given target machine description. This should work
|
||||||
/// regardless of whether the function is in SSA form or not.
|
/// regardless of whether the function is in SSA form or not.
|
||||||
///
|
///
|
||||||
FunctionPass *createPPCAsmPrinter(std::ostream &o,TargetMachine &tm) {
|
FunctionPass *llvm::createPPCAsmPrinter(std::ostream &o,TargetMachine &tm) {
|
||||||
return new PowerPCAsmPrinter(o, tm);
|
return new PowerPCAsmPrinter(o, tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,76 +162,6 @@ static void printAsCString(std::ostream &O, const ConstantArray *CVA) {
|
|||||||
O << "\"";
|
O << "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print out the specified constant, without a storage class. Only the
|
|
||||||
// constants valid in constant expressions can occur here.
|
|
||||||
void PowerPCAsmPrinter::emitConstantValueOnly(const Constant *CV) {
|
|
||||||
if (CV->isNullValue())
|
|
||||||
O << "0";
|
|
||||||
else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
|
|
||||||
assert(CB == ConstantBool::True);
|
|
||||||
O << "1";
|
|
||||||
} else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV))
|
|
||||||
O << CI->getValue();
|
|
||||||
else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV))
|
|
||||||
O << CI->getValue();
|
|
||||||
else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV))
|
|
||||||
// This is a constant address for a global variable or function. Use the
|
|
||||||
// name of the variable or function as the address value.
|
|
||||||
O << Mang->getValueName(GV);
|
|
||||||
else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
|
|
||||||
const TargetData &TD = TM.getTargetData();
|
|
||||||
switch (CE->getOpcode()) {
|
|
||||||
case Instruction::GetElementPtr: {
|
|
||||||
// generate a symbolic expression for the byte address
|
|
||||||
const Constant *ptrVal = CE->getOperand(0);
|
|
||||||
std::vector<Value*> idxVec(CE->op_begin()+1, CE->op_end());
|
|
||||||
if (unsigned Offset = TD.getIndexedOffset(ptrVal->getType(), idxVec)) {
|
|
||||||
O << "(";
|
|
||||||
emitConstantValueOnly(ptrVal);
|
|
||||||
O << ") + " << Offset;
|
|
||||||
} else {
|
|
||||||
emitConstantValueOnly(ptrVal);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Instruction::Cast: {
|
|
||||||
// Support only non-converting or widening casts for now, that is, ones
|
|
||||||
// that do not involve a change in value. This assertion is really gross,
|
|
||||||
// and may not even be a complete check.
|
|
||||||
Constant *Op = CE->getOperand(0);
|
|
||||||
const Type *OpTy = Op->getType(), *Ty = CE->getType();
|
|
||||||
|
|
||||||
// Remember, kids, pointers on x86 can be losslessly converted back and
|
|
||||||
// forth into 32-bit or wider integers, regardless of signedness. :-P
|
|
||||||
assert(((isa<PointerType>(OpTy)
|
|
||||||
&& (Ty == Type::LongTy || Ty == Type::ULongTy
|
|
||||||
|| Ty == Type::IntTy || Ty == Type::UIntTy))
|
|
||||||
|| (isa<PointerType>(Ty)
|
|
||||||
&& (OpTy == Type::LongTy || OpTy == Type::ULongTy
|
|
||||||
|| OpTy == Type::IntTy || OpTy == Type::UIntTy))
|
|
||||||
|| (((TD.getTypeSize(Ty) >= TD.getTypeSize(OpTy))
|
|
||||||
&& OpTy->isLosslesslyConvertibleTo(Ty))))
|
|
||||||
&& "FIXME: Don't yet support this kind of constant cast expr");
|
|
||||||
O << "(";
|
|
||||||
emitConstantValueOnly(Op);
|
|
||||||
O << ")";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Instruction::Add:
|
|
||||||
O << "(";
|
|
||||||
emitConstantValueOnly(CE->getOperand(0));
|
|
||||||
O << ") + (";
|
|
||||||
emitConstantValueOnly(CE->getOperand(1));
|
|
||||||
O << ")";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(0 && "Unsupported operator!");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
assert(0 && "Unknown constant value!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print a constant value or values, with the appropriate storage class as a
|
// Print a constant value or values, with the appropriate storage class as a
|
||||||
// prefix.
|
// prefix.
|
||||||
void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
|
void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
|
||||||
@@ -382,9 +296,8 @@ void PowerPCAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
|
|||||||
/// method to print assembly for each instruction.
|
/// method to print assembly for each instruction.
|
||||||
///
|
///
|
||||||
bool PowerPCAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
bool PowerPCAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
|
setupMachineFunction(MF);
|
||||||
O << "\n\n";
|
O << "\n\n";
|
||||||
// What's my mangled name?
|
|
||||||
CurrentFnName = Mang->getValueName(MF.getFunction());
|
|
||||||
|
|
||||||
// Print out constants referenced by the function
|
// Print out constants referenced by the function
|
||||||
printConstantPool(MF.getConstantPool());
|
printConstantPool(MF.getConstantPool());
|
||||||
@@ -467,20 +380,20 @@ void PowerPCAsmPrinter::printOp(const MachineOperand &MO,
|
|||||||
// are taken. Those should be emitted as $non_lazy_ptr below.
|
// are taken. Those should be emitted as $non_lazy_ptr below.
|
||||||
Function *F = dyn_cast<Function>(GV);
|
Function *F = dyn_cast<Function>(GV);
|
||||||
if (F && F->isExternal() && !LoadAddrOp &&
|
if (F && F->isExternal() && !LoadAddrOp &&
|
||||||
TM.CalledFunctions.find(F) != TM.CalledFunctions.end()) {
|
getTM().CalledFunctions.count(F)) {
|
||||||
FnStubs.insert(Name);
|
FnStubs.insert(Name);
|
||||||
O << "L" << Name << "$stub";
|
O << "L" << Name << "$stub";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// External global variables need a non-lazily-resolved stub
|
// External global variables need a non-lazily-resolved stub
|
||||||
if (GV->isExternal() && TM.AddressTaken.find(GV) != TM.AddressTaken.end()) {
|
if (GV->isExternal() && getTM().AddressTaken.count(GV)) {
|
||||||
GVStubs.insert(Name);
|
GVStubs.insert(Name);
|
||||||
O << "L" << Name << "$non_lazy_ptr";
|
O << "L" << Name << "$non_lazy_ptr";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (F && LoadAddrOp && TM.AddressTaken.find(GV) != TM.AddressTaken.end()) {
|
if (F && LoadAddrOp && getTM().AddressTaken.count(GV)) {
|
||||||
LinkOnceStubs.insert(Name);
|
LinkOnceStubs.insert(Name);
|
||||||
O << "L" << Name << "$non_lazy_ptr";
|
O << "L" << Name << "$non_lazy_ptr";
|
||||||
return;
|
return;
|
||||||
@@ -626,11 +539,6 @@ void PowerPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PowerPCAsmPrinter::doInitialization(Module &M) {
|
|
||||||
Mang = new Mangler(M, true);
|
|
||||||
return false; // success
|
|
||||||
}
|
|
||||||
|
|
||||||
// SwitchSection - Switch to the specified section of the executable if we are
|
// SwitchSection - Switch to the specified section of the executable if we are
|
||||||
// not already in it!
|
// not already in it!
|
||||||
//
|
//
|
||||||
@@ -750,8 +658,6 @@ bool PowerPCAsmPrinter::doFinalization(Module &M) {
|
|||||||
<< "\t.long\t" << *i << '\n';
|
<< "\t.long\t" << *i << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
delete Mang;
|
AsmPrinter::doFinalization(M);
|
||||||
return false; // success
|
return false; // success
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
#include "llvm/CodeGen/MachineConstantPool.h"
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
@@ -35,36 +36,17 @@
|
|||||||
#include "Support/Statistic.h"
|
#include "Support/Statistic.h"
|
||||||
#include "Support/StringExtras.h"
|
#include "Support/StringExtras.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
|
using namespace llvm;
|
||||||
namespace llvm {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
||||||
|
|
||||||
struct PowerPCAsmPrinter : public MachineFunctionPass {
|
struct PowerPCAsmPrinter : public AsmPrinter {
|
||||||
/// Output stream on which we're printing assembly code.
|
|
||||||
///
|
|
||||||
std::ostream &O;
|
|
||||||
|
|
||||||
/// Target machine description which we query for reg. names, data
|
|
||||||
/// layout, etc.
|
|
||||||
///
|
|
||||||
PowerPCTargetMachine &TM;
|
|
||||||
|
|
||||||
/// Name-mangler for global names.
|
|
||||||
///
|
|
||||||
Mangler *Mang;
|
|
||||||
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
||||||
std::set<std::string> Strings;
|
std::set<std::string> Strings;
|
||||||
|
|
||||||
PowerPCAsmPrinter(std::ostream &o, TargetMachine &tm) : O(o),
|
PowerPCAsmPrinter(std::ostream &O, TargetMachine &TM)
|
||||||
TM(reinterpret_cast<PowerPCTargetMachine&>(tm)), LabelNumber(0) {}
|
: AsmPrinter(O, TM), LabelNumber(0) {}
|
||||||
|
|
||||||
/// Cache of mangled name for current function. This is
|
|
||||||
/// recalculated at the beginning of each call to
|
|
||||||
/// runOnMachineFunction().
|
|
||||||
///
|
|
||||||
std::string CurrentFnName;
|
|
||||||
|
|
||||||
/// Unique incrementer for label values for referencing Global values.
|
/// Unique incrementer for label values for referencing Global values.
|
||||||
///
|
///
|
||||||
@@ -74,6 +56,10 @@ namespace {
|
|||||||
return "PowerPC Assembly Printer";
|
return "PowerPC Assembly Printer";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PowerPCTargetMachine &getTM() {
|
||||||
|
return static_cast<PowerPCTargetMachine&>(TM);
|
||||||
|
}
|
||||||
|
|
||||||
/// printInstruction - This method is automatically generated by tablegen
|
/// printInstruction - This method is automatically generated by tablegen
|
||||||
/// from the instruction set description. This method returns true if the
|
/// from the instruction set description. This method returns true if the
|
||||||
/// machine instruction was sufficiently described to print it, otherwise it
|
/// machine instruction was sufficiently described to print it, otherwise it
|
||||||
@@ -103,10 +89,8 @@ namespace {
|
|||||||
|
|
||||||
void printConstantPool(MachineConstantPool *MCP);
|
void printConstantPool(MachineConstantPool *MCP);
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
bool runOnMachineFunction(MachineFunction &F);
|
||||||
bool doInitialization(Module &M);
|
|
||||||
bool doFinalization(Module &M);
|
bool doFinalization(Module &M);
|
||||||
void emitGlobalConstant(const Constant* CV);
|
void emitGlobalConstant(const Constant* CV);
|
||||||
void emitConstantValueOnly(const Constant *CV);
|
|
||||||
};
|
};
|
||||||
} // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
|
|
||||||
@@ -115,7 +99,7 @@ namespace {
|
|||||||
/// using the given target machine description. This should work
|
/// using the given target machine description. This should work
|
||||||
/// regardless of whether the function is in SSA form or not.
|
/// regardless of whether the function is in SSA form or not.
|
||||||
///
|
///
|
||||||
FunctionPass *createPPCAsmPrinter(std::ostream &o,TargetMachine &tm) {
|
FunctionPass *llvm::createPPCAsmPrinter(std::ostream &o,TargetMachine &tm) {
|
||||||
return new PowerPCAsmPrinter(o, tm);
|
return new PowerPCAsmPrinter(o, tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,76 +162,6 @@ static void printAsCString(std::ostream &O, const ConstantArray *CVA) {
|
|||||||
O << "\"";
|
O << "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print out the specified constant, without a storage class. Only the
|
|
||||||
// constants valid in constant expressions can occur here.
|
|
||||||
void PowerPCAsmPrinter::emitConstantValueOnly(const Constant *CV) {
|
|
||||||
if (CV->isNullValue())
|
|
||||||
O << "0";
|
|
||||||
else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
|
|
||||||
assert(CB == ConstantBool::True);
|
|
||||||
O << "1";
|
|
||||||
} else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV))
|
|
||||||
O << CI->getValue();
|
|
||||||
else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV))
|
|
||||||
O << CI->getValue();
|
|
||||||
else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV))
|
|
||||||
// This is a constant address for a global variable or function. Use the
|
|
||||||
// name of the variable or function as the address value.
|
|
||||||
O << Mang->getValueName(GV);
|
|
||||||
else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
|
|
||||||
const TargetData &TD = TM.getTargetData();
|
|
||||||
switch (CE->getOpcode()) {
|
|
||||||
case Instruction::GetElementPtr: {
|
|
||||||
// generate a symbolic expression for the byte address
|
|
||||||
const Constant *ptrVal = CE->getOperand(0);
|
|
||||||
std::vector<Value*> idxVec(CE->op_begin()+1, CE->op_end());
|
|
||||||
if (unsigned Offset = TD.getIndexedOffset(ptrVal->getType(), idxVec)) {
|
|
||||||
O << "(";
|
|
||||||
emitConstantValueOnly(ptrVal);
|
|
||||||
O << ") + " << Offset;
|
|
||||||
} else {
|
|
||||||
emitConstantValueOnly(ptrVal);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Instruction::Cast: {
|
|
||||||
// Support only non-converting or widening casts for now, that is, ones
|
|
||||||
// that do not involve a change in value. This assertion is really gross,
|
|
||||||
// and may not even be a complete check.
|
|
||||||
Constant *Op = CE->getOperand(0);
|
|
||||||
const Type *OpTy = Op->getType(), *Ty = CE->getType();
|
|
||||||
|
|
||||||
// Remember, kids, pointers on x86 can be losslessly converted back and
|
|
||||||
// forth into 32-bit or wider integers, regardless of signedness. :-P
|
|
||||||
assert(((isa<PointerType>(OpTy)
|
|
||||||
&& (Ty == Type::LongTy || Ty == Type::ULongTy
|
|
||||||
|| Ty == Type::IntTy || Ty == Type::UIntTy))
|
|
||||||
|| (isa<PointerType>(Ty)
|
|
||||||
&& (OpTy == Type::LongTy || OpTy == Type::ULongTy
|
|
||||||
|| OpTy == Type::IntTy || OpTy == Type::UIntTy))
|
|
||||||
|| (((TD.getTypeSize(Ty) >= TD.getTypeSize(OpTy))
|
|
||||||
&& OpTy->isLosslesslyConvertibleTo(Ty))))
|
|
||||||
&& "FIXME: Don't yet support this kind of constant cast expr");
|
|
||||||
O << "(";
|
|
||||||
emitConstantValueOnly(Op);
|
|
||||||
O << ")";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Instruction::Add:
|
|
||||||
O << "(";
|
|
||||||
emitConstantValueOnly(CE->getOperand(0));
|
|
||||||
O << ") + (";
|
|
||||||
emitConstantValueOnly(CE->getOperand(1));
|
|
||||||
O << ")";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(0 && "Unsupported operator!");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
assert(0 && "Unknown constant value!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print a constant value or values, with the appropriate storage class as a
|
// Print a constant value or values, with the appropriate storage class as a
|
||||||
// prefix.
|
// prefix.
|
||||||
void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
|
void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
|
||||||
@@ -382,9 +296,8 @@ void PowerPCAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
|
|||||||
/// method to print assembly for each instruction.
|
/// method to print assembly for each instruction.
|
||||||
///
|
///
|
||||||
bool PowerPCAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
bool PowerPCAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||||
|
setupMachineFunction(MF);
|
||||||
O << "\n\n";
|
O << "\n\n";
|
||||||
// What's my mangled name?
|
|
||||||
CurrentFnName = Mang->getValueName(MF.getFunction());
|
|
||||||
|
|
||||||
// Print out constants referenced by the function
|
// Print out constants referenced by the function
|
||||||
printConstantPool(MF.getConstantPool());
|
printConstantPool(MF.getConstantPool());
|
||||||
@@ -467,20 +380,20 @@ void PowerPCAsmPrinter::printOp(const MachineOperand &MO,
|
|||||||
// are taken. Those should be emitted as $non_lazy_ptr below.
|
// are taken. Those should be emitted as $non_lazy_ptr below.
|
||||||
Function *F = dyn_cast<Function>(GV);
|
Function *F = dyn_cast<Function>(GV);
|
||||||
if (F && F->isExternal() && !LoadAddrOp &&
|
if (F && F->isExternal() && !LoadAddrOp &&
|
||||||
TM.CalledFunctions.find(F) != TM.CalledFunctions.end()) {
|
getTM().CalledFunctions.count(F)) {
|
||||||
FnStubs.insert(Name);
|
FnStubs.insert(Name);
|
||||||
O << "L" << Name << "$stub";
|
O << "L" << Name << "$stub";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// External global variables need a non-lazily-resolved stub
|
// External global variables need a non-lazily-resolved stub
|
||||||
if (GV->isExternal() && TM.AddressTaken.find(GV) != TM.AddressTaken.end()) {
|
if (GV->isExternal() && getTM().AddressTaken.count(GV)) {
|
||||||
GVStubs.insert(Name);
|
GVStubs.insert(Name);
|
||||||
O << "L" << Name << "$non_lazy_ptr";
|
O << "L" << Name << "$non_lazy_ptr";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (F && LoadAddrOp && TM.AddressTaken.find(GV) != TM.AddressTaken.end()) {
|
if (F && LoadAddrOp && getTM().AddressTaken.count(GV)) {
|
||||||
LinkOnceStubs.insert(Name);
|
LinkOnceStubs.insert(Name);
|
||||||
O << "L" << Name << "$non_lazy_ptr";
|
O << "L" << Name << "$non_lazy_ptr";
|
||||||
return;
|
return;
|
||||||
@@ -626,11 +539,6 @@ void PowerPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PowerPCAsmPrinter::doInitialization(Module &M) {
|
|
||||||
Mang = new Mangler(M, true);
|
|
||||||
return false; // success
|
|
||||||
}
|
|
||||||
|
|
||||||
// SwitchSection - Switch to the specified section of the executable if we are
|
// SwitchSection - Switch to the specified section of the executable if we are
|
||||||
// not already in it!
|
// not already in it!
|
||||||
//
|
//
|
||||||
@@ -750,8 +658,6 @@ bool PowerPCAsmPrinter::doFinalization(Module &M) {
|
|||||||
<< "\t.long\t" << *i << '\n';
|
<< "\t.long\t" << *i << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
delete Mang;
|
AsmPrinter::doFinalization(M);
|
||||||
return false; // success
|
return false; // success
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End llvm namespace
|
|
||||||
|
Reference in New Issue
Block a user