2006-02-05 05:50:24 +00:00
|
|
|
//===-- SparcAsmPrinter.cpp - Sparc LLVM assembly writer ------------------===//
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-03-04 06:00:41 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-03-04 06:00:41 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains a printer that converts from our internal representation
|
2006-02-05 05:50:24 +00:00
|
|
|
// of machine-dependent LLVM code to GAS-format SPARC assembly language.
|
2004-03-04 06:00:41 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2006-12-19 22:59:26 +00:00
|
|
|
#define DEBUG_TYPE "asm-printer"
|
2006-02-05 05:50:24 +00:00
|
|
|
#include "Sparc.h"
|
|
|
|
#include "SparcInstrInfo.h"
|
2009-06-19 15:48:10 +00:00
|
|
|
#include "SparcTargetMachine.h"
|
2004-03-04 06:00:41 +00:00
|
|
|
#include "llvm/Constants.h"
|
|
|
|
#include "llvm/DerivedTypes.h"
|
|
|
|
#include "llvm/Module.h"
|
2005-12-17 07:04:29 +00:00
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
2009-02-18 23:12:06 +00:00
|
|
|
#include "llvm/CodeGen/DwarfWriter.h"
|
2004-03-04 06:00:41 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
|
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2006-09-06 18:34:40 +00:00
|
|
|
#include "llvm/Target/TargetAsmInfo.h"
|
2009-07-28 03:13:23 +00:00
|
|
|
#include "llvm/Target/TargetLoweringObjectFile.h"
|
2009-07-15 20:24:03 +00:00
|
|
|
#include "llvm/Target/TargetRegistry.h"
|
2009-07-08 19:04:27 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2009-07-14 20:18:05 +00:00
|
|
|
#include "llvm/Support/FormattedStream.h"
|
2004-03-04 06:00:41 +00:00
|
|
|
#include "llvm/Support/Mangler.h"
|
2004-09-02 02:37:43 +00:00
|
|
|
#include "llvm/ADT/Statistic.h"
|
|
|
|
#include "llvm/ADT/StringExtras.h"
|
|
|
|
#include "llvm/Support/CommandLine.h"
|
2005-08-17 20:04:34 +00:00
|
|
|
#include "llvm/Support/MathExtras.h"
|
2004-03-06 05:30:21 +00:00
|
|
|
#include <cctype>
|
2008-02-20 11:08:44 +00:00
|
|
|
#include <cstring>
|
2008-07-10 01:44:27 +00:00
|
|
|
#include <map>
|
2004-03-04 06:00:41 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2006-12-19 22:59:26 +00:00
|
|
|
STATISTIC(EmittedInsts, "Number of machine instrs printed");
|
2004-03-04 06:00:41 +00:00
|
|
|
|
2006-12-19 22:59:26 +00:00
|
|
|
namespace {
|
2009-02-24 08:30:20 +00:00
|
|
|
class VISIBILITY_HIDDEN SparcAsmPrinter : public AsmPrinter {
|
2004-03-04 06:00:41 +00:00
|
|
|
/// 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().
|
|
|
|
///
|
|
|
|
typedef std::map<const Value *, unsigned> ValueMapTy;
|
|
|
|
ValueMapTy NumberForBB;
|
2009-06-26 21:45:04 +00:00
|
|
|
unsigned BBNumber;
|
2009-02-24 08:30:20 +00:00
|
|
|
public:
|
2009-07-14 20:18:05 +00:00
|
|
|
explicit SparcAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
|
2009-07-01 01:48:54 +00:00
|
|
|
const TargetAsmInfo *T, bool V)
|
|
|
|
: AsmPrinter(O, TM, T, V), BBNumber(0) {}
|
2004-03-04 06:00:41 +00:00
|
|
|
|
|
|
|
virtual const char *getPassName() const {
|
2006-02-05 05:50:24 +00:00
|
|
|
return "Sparc Assembly Printer";
|
2004-03-04 06:00:41 +00:00
|
|
|
}
|
|
|
|
|
2009-07-21 18:38:57 +00:00
|
|
|
void PrintGlobalVariable(const GlobalVariable *GVar);
|
2004-06-15 19:52:59 +00:00
|
|
|
void printOperand(const MachineInstr *MI, int opNum);
|
2006-02-10 07:35:42 +00:00
|
|
|
void printMemOperand(const MachineInstr *MI, int opNum,
|
|
|
|
const char *Modifier = 0);
|
2006-02-05 05:50:24 +00:00
|
|
|
void printCCOperand(const MachineInstr *MI, int opNum);
|
2006-01-31 06:49:09 +00:00
|
|
|
|
2005-12-16 06:34:17 +00:00
|
|
|
bool printInstruction(const MachineInstr *MI); // autogenerated.
|
2005-04-21 23:30:14 +00:00
|
|
|
bool runOnMachineFunction(MachineFunction &F);
|
2008-10-10 10:15:03 +00:00
|
|
|
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
|
|
|
unsigned AsmVariant, const char *ExtraCode);
|
|
|
|
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
|
|
|
|
unsigned AsmVariant, const char *ExtraCode);
|
2004-03-04 06:00:41 +00:00
|
|
|
};
|
|
|
|
} // end of anonymous namespace
|
|
|
|
|
2006-02-05 05:50:24 +00:00
|
|
|
#include "SparcGenAsmWriter.inc"
|
2005-12-16 06:34:17 +00:00
|
|
|
|
2009-06-19 15:48:10 +00:00
|
|
|
|
2008-02-02 08:39:46 +00:00
|
|
|
/// runOnMachineFunction - This uses the printInstruction()
|
2004-03-04 06:00:41 +00:00
|
|
|
/// method to print assembly for each instruction.
|
|
|
|
///
|
2006-02-05 05:50:24 +00:00
|
|
|
bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
2009-02-24 08:30:20 +00:00
|
|
|
this->MF = &MF;
|
|
|
|
|
2005-12-17 07:04:29 +00:00
|
|
|
SetupMachineFunction(MF);
|
|
|
|
|
2005-12-17 07:11:43 +00:00
|
|
|
// Print out constants referenced by the function
|
|
|
|
EmitConstantPool(MF.getConstantPool());
|
|
|
|
|
2004-03-04 06:00:41 +00:00
|
|
|
// BBNumber is used here so that a given Printer will never give two
|
|
|
|
// BBs the same name. (If you have a better way, please let me know!)
|
|
|
|
|
|
|
|
O << "\n\n";
|
|
|
|
|
2006-10-05 02:48:40 +00:00
|
|
|
// Print out the label for the function.
|
|
|
|
const Function *F = MF.getFunction();
|
2009-07-29 05:09:30 +00:00
|
|
|
SwitchToSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
|
2009-06-30 22:38:32 +00:00
|
|
|
EmitAlignment(MF.getAlignment(), F);
|
2008-08-07 09:53:13 +00:00
|
|
|
O << "\t.globl\t" << CurrentFnName << '\n';
|
2008-08-08 18:25:07 +00:00
|
|
|
|
|
|
|
printVisibility(CurrentFnName, F->getVisibility());
|
|
|
|
|
2004-03-16 22:52:04 +00:00
|
|
|
O << "\t.type\t" << CurrentFnName << ", #function\n";
|
2004-03-04 06:00:41 +00:00
|
|
|
O << CurrentFnName << ":\n";
|
|
|
|
|
|
|
|
// Number each basic block so that we can consistently refer to them
|
|
|
|
// in PC-relative references.
|
2006-10-05 02:48:40 +00:00
|
|
|
// FIXME: Why not use the MBB numbers?
|
2004-03-04 06:00:41 +00:00
|
|
|
NumberForBB.clear();
|
|
|
|
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
|
|
|
I != E; ++I) {
|
|
|
|
NumberForBB[I->getBasicBlock()] = BBNumber++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print out code for the function.
|
|
|
|
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
|
|
|
I != E; ++I) {
|
|
|
|
// Print a label for the basic block.
|
2006-05-02 05:37:32 +00:00
|
|
|
if (I != MF.begin()) {
|
2008-02-28 00:43:03 +00:00
|
|
|
printBasicBlockLabel(I, true, true);
|
2006-05-02 05:37:32 +00:00
|
|
|
O << '\n';
|
|
|
|
}
|
2004-03-04 06:00:41 +00:00
|
|
|
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
2005-04-22 18:06:01 +00:00
|
|
|
II != E; ++II) {
|
2004-03-04 06:00:41 +00:00
|
|
|
// Print the assembly for the instruction.
|
2005-12-17 06:54:41 +00:00
|
|
|
printInstruction(II);
|
2005-12-17 07:04:29 +00:00
|
|
|
++EmittedInsts;
|
2004-03-04 06:00:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We didn't modify anything.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-02-05 05:50:24 +00:00
|
|
|
void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
|
2004-06-15 19:52:59 +00:00
|
|
|
const MachineOperand &MO = MI->getOperand (opNum);
|
2008-02-10 18:45:23 +00:00
|
|
|
const TargetRegisterInfo &RI = *TM.getRegisterInfo();
|
2004-06-15 19:52:59 +00:00
|
|
|
bool CloseParen = false;
|
2008-10-03 15:45:36 +00:00
|
|
|
if (MI->getOpcode() == SP::SETHIi && !MO.isReg() && !MO.isImm()) {
|
2004-06-15 19:52:59 +00:00
|
|
|
O << "%hi(";
|
|
|
|
CloseParen = true;
|
2008-10-03 15:45:36 +00:00
|
|
|
} else if ((MI->getOpcode() == SP::ORri || MI->getOpcode() == SP::ADDri) &&
|
|
|
|
!MO.isReg() && !MO.isImm()) {
|
2004-06-15 19:52:59 +00:00
|
|
|
O << "%lo(";
|
|
|
|
CloseParen = true;
|
|
|
|
}
|
2004-03-05 08:39:09 +00:00
|
|
|
switch (MO.getType()) {
|
2006-05-04 18:05:43 +00:00
|
|
|
case MachineOperand::MO_Register:
|
2008-02-10 18:45:23 +00:00
|
|
|
if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()))
|
2008-02-26 21:11:01 +00:00
|
|
|
O << "%" << LowercaseString (RI.get(MO.getReg()).AsmName);
|
2004-03-05 08:39:09 +00:00
|
|
|
else
|
|
|
|
O << "%reg" << MO.getReg();
|
2004-06-15 19:52:59 +00:00
|
|
|
break;
|
2004-03-05 08:39:09 +00:00
|
|
|
|
2006-05-04 17:21:20 +00:00
|
|
|
case MachineOperand::MO_Immediate:
|
2007-12-30 20:49:49 +00:00
|
|
|
O << (int)MO.getImm();
|
2004-06-15 19:52:59 +00:00
|
|
|
break;
|
2006-04-22 18:53:45 +00:00
|
|
|
case MachineOperand::MO_MachineBasicBlock:
|
2007-12-30 23:10:15 +00:00
|
|
|
printBasicBlockLabel(MO.getMBB());
|
2004-06-17 19:39:23 +00:00
|
|
|
return;
|
2004-03-05 08:39:09 +00:00
|
|
|
case MachineOperand::MO_GlobalAddress:
|
2009-07-14 18:17:16 +00:00
|
|
|
O << Mang->getMangledName(MO.getGlobal());
|
2004-06-15 19:52:59 +00:00
|
|
|
break;
|
2004-03-05 08:39:09 +00:00
|
|
|
case MachineOperand::MO_ExternalSymbol:
|
|
|
|
O << MO.getSymbolName();
|
2004-06-15 19:52:59 +00:00
|
|
|
break;
|
2004-06-27 22:50:44 +00:00
|
|
|
case MachineOperand::MO_ConstantPoolIndex:
|
2007-10-14 05:57:21 +00:00
|
|
|
O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
|
2007-12-30 23:10:15 +00:00
|
|
|
<< MO.getIndex();
|
2004-06-27 22:50:44 +00:00
|
|
|
break;
|
2004-03-05 08:39:09 +00:00
|
|
|
default:
|
2009-07-14 16:55:14 +00:00
|
|
|
llvm_unreachable("<unknown operand type>");
|
2004-03-05 08:39:09 +00:00
|
|
|
}
|
2004-06-15 19:52:59 +00:00
|
|
|
if (CloseParen) O << ")";
|
2004-03-05 08:39:09 +00:00
|
|
|
}
|
|
|
|
|
2006-02-10 07:35:42 +00:00
|
|
|
void SparcAsmPrinter::printMemOperand(const MachineInstr *MI, int opNum,
|
|
|
|
const char *Modifier) {
|
2005-12-17 20:04:49 +00:00
|
|
|
printOperand(MI, opNum);
|
2008-08-07 09:51:25 +00:00
|
|
|
|
2006-02-10 07:35:42 +00:00
|
|
|
// If this is an ADD operand, emit it like normal operands.
|
|
|
|
if (Modifier && !strcmp(Modifier, "arith")) {
|
|
|
|
O << ", ";
|
|
|
|
printOperand(MI, opNum+1);
|
|
|
|
return;
|
|
|
|
}
|
2008-08-07 09:51:25 +00:00
|
|
|
|
2008-10-03 15:45:36 +00:00
|
|
|
if (MI->getOperand(opNum+1).isReg() &&
|
2006-02-05 05:50:24 +00:00
|
|
|
MI->getOperand(opNum+1).getReg() == SP::G0)
|
2005-12-18 02:37:35 +00:00
|
|
|
return; // don't print "+%g0"
|
2008-10-03 15:45:36 +00:00
|
|
|
if (MI->getOperand(opNum+1).isImm() &&
|
2007-12-30 20:49:49 +00:00
|
|
|
MI->getOperand(opNum+1).getImm() == 0)
|
2005-12-18 02:37:35 +00:00
|
|
|
return; // don't print "+0"
|
2008-08-07 09:51:25 +00:00
|
|
|
|
2005-12-17 20:04:49 +00:00
|
|
|
O << "+";
|
2008-10-03 15:45:36 +00:00
|
|
|
if (MI->getOperand(opNum+1).isGlobal() ||
|
|
|
|
MI->getOperand(opNum+1).isCPI()) {
|
Teach the addressing mode stuff to fold "%lo" into 'ri' addressing modes,
allowing us to compile this:
to this:
%G1 = external global int
%G2 = external global int
void %test() {
%X = load int* %G1
store int %X, int* %G2
ret void
}
test:
save -96, %sp, %sp
sethi %hi(G1), %l0
ld [%l0+%lo(G1)], %l0
sethi %hi(G2), %l1
st %l0, [%l1+%lo(G2)]
restore %g0, %g0, %g0
retl
nop
instead of this:
test:
save -96, %sp, %sp
sethi %hi(G1), %l0
or %g0, %lo(G1), %l1
ld [%l1+%l0], %l0
sethi %hi(G2), %l1
or %g0, %lo(G2), %l2
st %l0, [%l2+%l1]
restore %g0, %g0, %g0
retl
nop
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24812 91177308-0d34-0410-b5e6-96231b3b80d8
2005-12-18 02:27:00 +00:00
|
|
|
O << "%lo(";
|
|
|
|
printOperand(MI, opNum+1);
|
|
|
|
O << ")";
|
|
|
|
} else {
|
|
|
|
printOperand(MI, opNum+1);
|
|
|
|
}
|
2005-12-17 20:04:49 +00:00
|
|
|
}
|
|
|
|
|
2006-02-05 05:50:24 +00:00
|
|
|
void SparcAsmPrinter::printCCOperand(const MachineInstr *MI, int opNum) {
|
2007-12-30 20:49:49 +00:00
|
|
|
int CC = (int)MI->getOperand(opNum).getImm();
|
2006-02-05 05:50:24 +00:00
|
|
|
O << SPARCCondCodeToString((SPCC::CondCodes)CC);
|
2006-01-31 06:49:09 +00:00
|
|
|
}
|
|
|
|
|
2009-07-21 18:38:57 +00:00
|
|
|
void SparcAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
|
2008-08-07 09:51:25 +00:00
|
|
|
const TargetData *TD = TM.getTargetData();
|
|
|
|
|
|
|
|
if (!GVar->hasInitializer())
|
|
|
|
return; // External global require no code
|
|
|
|
|
|
|
|
// Check to see if this is a special global used by LLVM, if so, emit it.
|
|
|
|
if (EmitSpecialLLVMGlobal(GVar))
|
|
|
|
return;
|
|
|
|
|
|
|
|
O << "\n\n";
|
2009-07-14 18:17:16 +00:00
|
|
|
std::string name = Mang->getMangledName(GVar);
|
2008-08-07 09:51:25 +00:00
|
|
|
Constant *C = GVar->getInitializer();
|
2009-05-09 07:06:46 +00:00
|
|
|
unsigned Size = TD->getTypeAllocSize(C->getType());
|
2008-08-07 09:51:25 +00:00
|
|
|
unsigned Align = TD->getPreferredAlignment(GVar);
|
|
|
|
|
2008-08-08 18:25:07 +00:00
|
|
|
printVisibility(name, GVar->getVisibility());
|
|
|
|
|
2009-07-29 05:09:30 +00:00
|
|
|
SwitchToSection(getObjFileLowering().SectionForGlobal(GVar, Mang, TM));
|
2008-08-07 09:51:25 +00:00
|
|
|
|
|
|
|
if (C->isNullValue() && !GVar->hasSection()) {
|
|
|
|
if (!GVar->isThreadLocal() &&
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66339 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-07 15:45:40 +00:00
|
|
|
(GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
|
2008-08-07 09:51:25 +00:00
|
|
|
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
|
|
|
|
2009-01-15 20:18:42 +00:00
|
|
|
if (GVar->hasLocalLinkage())
|
2008-08-07 09:53:13 +00:00
|
|
|
O << "\t.local " << name << '\n';
|
2008-08-07 09:51:25 +00:00
|
|
|
|
|
|
|
O << TAI->getCOMMDirective() << name << ',' << Size;
|
|
|
|
if (TAI->getCOMMDirectiveTakesAlignment())
|
|
|
|
O << ',' << (1 << Align);
|
|
|
|
|
|
|
|
O << '\n';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (GVar->getLinkage()) {
|
2009-03-11 20:14:15 +00:00
|
|
|
case GlobalValue::CommonLinkage:
|
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions,
except that they indicate that the global will only be overridden
by an *equivalent* global. In C, a function with weak linkage can
be overridden by a function which behaves completely differently.
This means that IP passes have to skip weak functions, since any
deductions made from the function definition might be wrong, since
the definition could be replaced by something completely different
at link time. This is not allowed in C++, thanks to the ODR
(One-Definition-Rule): if a function is replaced by another at
link-time, then the new function must be the same as the original
function. If a language knows that a function or other global can
only be overridden by an equivalent global, it can give it the
weak_odr linkage type, and the optimizers will understand that it
is alright to make deductions based on the function body. The
code generators on the other hand map weak and weak_odr linkage
to the same thing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66339 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-07 15:45:40 +00:00
|
|
|
case GlobalValue::LinkOnceAnyLinkage:
|
|
|
|
case GlobalValue::LinkOnceODRLinkage:
|
|
|
|
case GlobalValue::WeakAnyLinkage: // FIXME: Verify correct for weak.
|
|
|
|
case GlobalValue::WeakODRLinkage: // FIXME: Verify correct for weak.
|
2008-08-07 09:51:25 +00:00
|
|
|
// Nonnull linkonce -> weak
|
2008-08-07 09:53:13 +00:00
|
|
|
O << "\t.weak " << name << '\n';
|
2008-08-07 09:51:25 +00:00
|
|
|
break;
|
|
|
|
case GlobalValue::AppendingLinkage:
|
|
|
|
// FIXME: appending linkage variables should go into a section of
|
|
|
|
// their name or something. For now, just emit them as external.
|
|
|
|
case GlobalValue::ExternalLinkage:
|
|
|
|
// If external or appending, declare as a global symbol
|
2008-08-07 09:53:13 +00:00
|
|
|
O << TAI->getGlobalDirective() << name << '\n';
|
2008-08-07 09:51:25 +00:00
|
|
|
// FALL THROUGH
|
2009-01-15 20:18:42 +00:00
|
|
|
case GlobalValue::PrivateLinkage:
|
2009-07-20 01:03:30 +00:00
|
|
|
case GlobalValue::LinkerPrivateLinkage:
|
2008-08-07 09:51:25 +00:00
|
|
|
case GlobalValue::InternalLinkage:
|
|
|
|
break;
|
|
|
|
case GlobalValue::GhostLinkage:
|
2009-07-14 16:55:14 +00:00
|
|
|
llvm_unreachable("Should not have any unmaterialized functions!");
|
2008-08-07 09:51:25 +00:00
|
|
|
case GlobalValue::DLLImportLinkage:
|
2009-07-14 16:55:14 +00:00
|
|
|
llvm_unreachable("DLLImport linkage is not supported by this target!");
|
2008-08-07 09:51:25 +00:00
|
|
|
case GlobalValue::DLLExportLinkage:
|
2009-07-14 16:55:14 +00:00
|
|
|
llvm_unreachable("DLLExport linkage is not supported by this target!");
|
2008-08-07 09:51:25 +00:00
|
|
|
default:
|
2009-07-14 16:55:14 +00:00
|
|
|
llvm_unreachable("Unknown linkage type!");
|
2008-08-07 09:51:25 +00:00
|
|
|
}
|
|
|
|
|
2008-08-07 09:53:38 +00:00
|
|
|
EmitAlignment(Align, GVar);
|
2008-08-07 09:51:25 +00:00
|
|
|
|
|
|
|
if (TAI->hasDotTypeDotSizeDirective()) {
|
|
|
|
O << "\t.type " << name << ",#object\n";
|
2008-08-07 09:53:13 +00:00
|
|
|
O << "\t.size " << name << ',' << Size << '\n';
|
2008-08-07 09:51:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
O << name << ":\n";
|
|
|
|
EmitGlobalConstant(C);
|
|
|
|
}
|
2008-10-10 10:15:03 +00:00
|
|
|
|
|
|
|
/// PrintAsmOperand - Print out an operand for an inline asm expression.
|
|
|
|
///
|
|
|
|
bool SparcAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
|
|
|
unsigned AsmVariant,
|
|
|
|
const char *ExtraCode) {
|
2008-10-10 20:29:50 +00:00
|
|
|
if (ExtraCode && ExtraCode[0]) {
|
|
|
|
if (ExtraCode[1] != 0) return true; // Unknown modifier.
|
|
|
|
|
|
|
|
switch (ExtraCode[0]) {
|
|
|
|
default: return true; // Unknown modifier.
|
|
|
|
case 'r':
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-10-10 10:15:03 +00:00
|
|
|
|
|
|
|
printOperand(MI, OpNo);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SparcAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
|
|
|
|
unsigned OpNo,
|
|
|
|
unsigned AsmVariant,
|
|
|
|
const char *ExtraCode) {
|
|
|
|
if (ExtraCode && ExtraCode[0])
|
|
|
|
return true; // Unknown modifier
|
|
|
|
|
|
|
|
O << '[';
|
|
|
|
printMemOperand(MI, OpNo);
|
|
|
|
O << ']';
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2009-06-16 20:12:29 +00:00
|
|
|
|
2009-06-23 23:59:40 +00:00
|
|
|
// Force static initialization.
|
2009-07-15 20:24:03 +00:00
|
|
|
extern "C" void LLVMInitializeSparcAsmPrinter() {
|
2009-07-25 06:49:55 +00:00
|
|
|
RegisterAsmPrinter<SparcAsmPrinter> X(TheSparcTarget);
|
2009-07-15 20:24:03 +00:00
|
|
|
}
|