summaryrefslogtreecommitdiff
path: root/lib/Target
diff options
context:
space:
mode:
authorAndrew Lenharth <andrewl@lenharth.org>2005-04-13 17:17:28 +0000
committerAndrew Lenharth <andrewl@lenharth.org>2005-04-13 17:17:28 +0000
commitc24b537399e872378ce117080928bd6c890c85f7 (patch)
treed1139bbbb394c417d9a182354b00621d19459ccf /lib/Target
parent556c44e116b2f068913a78c8cbe80c5b4e9abbec (diff)
WOW, function calls still seem to work after this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21286 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/Alpha/AlphaAsmPrinter.cpp33
-rw-r--r--lib/Target/Alpha/AlphaISelPattern.cpp10
-rw-r--r--lib/Target/Alpha/AlphaRegisterInfo.cpp6
3 files changed, 30 insertions, 19 deletions
diff --git a/lib/Target/Alpha/AlphaAsmPrinter.cpp b/lib/Target/Alpha/AlphaAsmPrinter.cpp
index 4d4fb94ded2..3e7d5e7bbcb 100644
--- a/lib/Target/Alpha/AlphaAsmPrinter.cpp
+++ b/lib/Target/Alpha/AlphaAsmPrinter.cpp
@@ -49,6 +49,7 @@ namespace {
///
typedef std::map<const Value *, unsigned> ValueMapTy;
ValueMapTy NumberForBB;
+ std::string CurSection;
virtual const char *getPassName() const {
return "Alpha Assembly Printer";
@@ -62,6 +63,7 @@ namespace {
bool runOnMachineFunction(MachineFunction &F);
bool doInitialization(Module &M);
bool doFinalization(Module &M);
+ void SwitchSection(std::ostream &OS, const char *NewSection);
};
} // end of anonymous namespace
@@ -134,8 +136,13 @@ void AlphaAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) {
O << MO.getSymbolName();
return;
- case MachineOperand::MO_GlobalAddress:
- O << Mang->getValueName(MO.getGlobal());
+ case MachineOperand::MO_GlobalAddress:
+ //Abuse PCrel to specify pcrel calls
+ //calls are the only thing that use this flag
+ if (MO.isPCRelative())
+ O << "$" << Mang->getValueName(MO.getGlobal()) << "..ng";
+ else
+ O << Mang->getValueName(MO.getGlobal());
return;
default:
@@ -169,8 +176,8 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
printConstantPool(MF.getConstantPool());
// Print out labels for the function.
- O << "\t.text\n";
- emitAlignment(3);
+ SwitchSection(O, "text");
+ emitAlignment(4);
O << "\t.globl\t" << CurrentFnName << "\n";
O << "\t.ent\t" << CurrentFnName << "\n";
@@ -209,8 +216,9 @@ void AlphaAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
if (CP.empty()) return;
+ SwitchSection(O, "section .rodata");
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
- O << "\t.section\t.rodata\n";
+ // SwitchSection(O, "section .rodata, \"dr\"");
emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
O << "CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString
<< *CP[i] << "\n";
@@ -229,18 +237,17 @@ bool AlphaAsmPrinter::doInitialization(Module &M)
// SwitchSection - Switch to the specified section of the executable if we are
// not already in it!
//
-static void SwitchSection(std::ostream &OS, std::string &CurSection,
- const char *NewSection) {
+void AlphaAsmPrinter::SwitchSection(std::ostream &OS, const char *NewSection)
+{
if (CurSection != NewSection) {
CurSection = NewSection;
if (!CurSection.empty())
- OS << "\t" << NewSection << "\n";
+ OS << "\t." << NewSection << "\n";
}
}
bool AlphaAsmPrinter::doFinalization(Module &M) {
const TargetData &TD = TM.getTargetData();
- std::string CurSection;
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
if (I->hasInitializer()) { // External global require no code
@@ -253,7 +260,7 @@ bool AlphaAsmPrinter::doFinalization(Module &M) {
if (C->isNullValue() &&
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
I->hasWeakLinkage() /* FIXME: Verify correct */)) {
- SwitchSection(O, CurSection, ".data");
+ SwitchSection(O, "data");
if (I->hasInternalLinkage())
O << "\t.local " << name << "\n";
@@ -268,7 +275,7 @@ bool AlphaAsmPrinter::doFinalization(Module &M) {
case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak.
// Nonnull linkonce -> weak
O << "\t.weak " << name << "\n";
- SwitchSection(O, CurSection, "");
+ SwitchSection(O, "");
O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n";
break;
case GlobalValue::AppendingLinkage:
@@ -280,9 +287,9 @@ bool AlphaAsmPrinter::doFinalization(Module &M) {
// FALL THROUGH
case GlobalValue::InternalLinkage:
if (C->isNullValue())
- SwitchSection(O, CurSection, ".data"); //was .bss
+ SwitchSection(O, "bss"); //was .bss
else
- SwitchSection(O, CurSection, ".data");
+ SwitchSection(O, "data");
break;
case GlobalValue::GhostLinkage:
std::cerr << "GhostLinkage cannot appear in AlphaAsmPrinter!\n";
diff --git a/lib/Target/Alpha/AlphaISelPattern.cpp b/lib/Target/Alpha/AlphaISelPattern.cpp
index 8f3752f964b..e594c8664af 100644
--- a/lib/Target/Alpha/AlphaISelPattern.cpp
+++ b/lib/Target/Alpha/AlphaISelPattern.cpp
@@ -1411,15 +1411,15 @@ unsigned ISel::SelectExpr(SDOperand N) {
if (GlobalAddressSDNode *GASD =
dyn_cast<GlobalAddressSDNode>(N.getOperand(1)))
{
- //if (GASD->getGlobal()->isExternal()) {
+ if (GASD->getGlobal()->isExternal()) {
//use safe calling convention
AlphaLowering.restoreGP(BB);
has_sym = true;
- BuildMI(BB, Alpha::CALL, 1).addGlobalAddress(GASD->getGlobal(),true);
- //} else {
+ BuildMI(BB, Alpha::CALL, 1).addGlobalAddress(GASD->getGlobal());
+ } else {
//use PC relative branch call
- //BuildMI(BB, Alpha::BSR, 1, Alpha::R26).addGlobalAddress(GASD->getGlobal(),true);
- //}
+ BuildMI(BB, Alpha::BSR, 1, Alpha::R26).addGlobalAddress(GASD->getGlobal(),true);
+ }
}
else if (ExternalSymbolSDNode *ESSDN =
dyn_cast<ExternalSymbolSDNode>(N.getOperand(1)))
diff --git a/lib/Target/Alpha/AlphaRegisterInfo.cpp b/lib/Target/Alpha/AlphaRegisterInfo.cpp
index 96a05938f1a..eb208a2f2b4 100644
--- a/lib/Target/Alpha/AlphaRegisterInfo.cpp
+++ b/lib/Target/Alpha/AlphaRegisterInfo.cpp
@@ -16,6 +16,7 @@
#include "AlphaRegisterInfo.h"
#include "llvm/Constants.h"
#include "llvm/Type.h"
+#include "llvm/Function.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineFunction.h"
@@ -213,7 +214,10 @@ void AlphaRegisterInfo::emitPrologue(MachineFunction &MF) const {
//handle GOP offset
MI = BuildMI(Alpha::LDGP, 0);
MBB.insert(MBBI, MI);
-
+ //evil const_cast until MO stuff setup to handle const
+ MI = BuildMI(Alpha::ALTENT, 1).addGlobalAddress(const_cast<Function*>(MF.getFunction()), true);
+ MBB.insert(MBBI, MI);
+
// Get the number of bytes to allocate from the FrameInfo
long NumBytes = MFI->getStackSize();