mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-27 05:30:49 +00:00
convert the last 3 targets to use EmitFunctionBody() now that
it has before/end body hooks. lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp | 49 ++----------- lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp | 87 ++++++------------------ lib/Target/XCore/AsmPrinter/XCoreAsmPrinter.cpp | 56 +++------------ test/CodeGen/XCore/ashr.ll | 2 4 files changed, 48 insertions(+), 146 deletions(-) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94741 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
06ed3e788a
commit
a34103f6fa
@ -29,11 +29,8 @@
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
using namespace llvm;
|
||||
|
||||
STATISTIC(EmittedInsts, "Number of machine instrs printed");
|
||||
|
||||
namespace {
|
||||
struct AlphaAsmPrinter : public AsmPrinter {
|
||||
/// Unique incrementer for label values for referencing Global values.
|
||||
@ -47,12 +44,14 @@ namespace {
|
||||
return "Alpha Assembly Printer";
|
||||
}
|
||||
void printInstruction(const MachineInstr *MI);
|
||||
void EmitInstruction(const MachineInstr *MI) { printInstruction(MI); }
|
||||
static const char *getRegisterName(unsigned RegNo);
|
||||
|
||||
void printOp(const MachineOperand &MO, bool IsCallOp = false);
|
||||
void printOperand(const MachineInstr *MI, int opNum);
|
||||
void printBaseOffsetPair(const MachineInstr *MI, int i, bool brackets=true);
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
virtual void EmitFunctionBodyStart();
|
||||
virtual void EmitFunctionBodyEnd();
|
||||
void EmitStartOfAsmFile(Module &M);
|
||||
|
||||
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
@ -120,44 +119,16 @@ void AlphaAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) {
|
||||
}
|
||||
}
|
||||
|
||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
||||
/// method to print assembly for each instruction.
|
||||
///
|
||||
bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
SetupMachineFunction(MF);
|
||||
O << "\n\n";
|
||||
|
||||
EmitFunctionHeader();
|
||||
|
||||
/// EmitFunctionBodyStart - Targets can override this to emit stuff before
|
||||
/// the first basic block in the function.
|
||||
void AlphaAsmPrinter::EmitFunctionBodyStart() {
|
||||
O << "\t.ent " << *CurrentFnSym << "\n";
|
||||
}
|
||||
|
||||
// Print out code for the function.
|
||||
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
||||
I != E; ++I) {
|
||||
if (I != MF.begin())
|
||||
EmitBasicBlockStart(I);
|
||||
|
||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
||||
II != E; ++II) {
|
||||
// Print the assembly for the instruction.
|
||||
++EmittedInsts;
|
||||
processDebugLoc(II, true);
|
||||
printInstruction(II);
|
||||
|
||||
if (VerboseAsm)
|
||||
EmitComments(*II);
|
||||
O << '\n';
|
||||
processDebugLoc(II, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// EmitFunctionBodyEnd - Targets can override this to emit stuff after
|
||||
/// the last basic block in the function.
|
||||
void AlphaAsmPrinter::EmitFunctionBodyEnd() {
|
||||
O << "\t.end " << *CurrentFnSym << "\n";
|
||||
|
||||
// Print out jump tables referenced by the function
|
||||
EmitJumpTableInfo();
|
||||
|
||||
// We didn't modify anything.
|
||||
return false;
|
||||
}
|
||||
|
||||
void AlphaAsmPrinter::EmitStartOfAsmFile(Module &M) {
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
@ -46,8 +45,6 @@
|
||||
#include <cctype>
|
||||
using namespace llvm;
|
||||
|
||||
STATISTIC(EmittedInsts, "Number of machine instrs printed");
|
||||
|
||||
namespace {
|
||||
class MipsAsmPrinter : public AsmPrinter {
|
||||
const MipsSubtarget *Subtarget;
|
||||
@ -70,16 +67,18 @@ namespace {
|
||||
const char *Modifier = 0);
|
||||
void printFCCOperand(const MachineInstr *MI, int opNum,
|
||||
const char *Modifier = 0);
|
||||
void printSavedRegsBitmask(MachineFunction &MF);
|
||||
void printSavedRegsBitmask();
|
||||
void printHex32(unsigned int Value);
|
||||
|
||||
const char *emitCurrentABIString();
|
||||
void emitFrameDirective(MachineFunction &MF);
|
||||
void emitFrameDirective();
|
||||
|
||||
void printInstruction(const MachineInstr *MI); // autogenerated.
|
||||
void EmitInstruction(const MachineInstr *MI) { printInstruction(MI); }
|
||||
virtual void EmitFunctionBodyStart();
|
||||
virtual void EmitFunctionBodyEnd();
|
||||
static const char *getRegisterName(unsigned RegNo);
|
||||
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
virtual void EmitFunctionEntryLabel();
|
||||
void EmitStartOfAsmFile(Module &M);
|
||||
};
|
||||
@ -124,18 +123,16 @@ namespace {
|
||||
|
||||
// Create a bitmask with all callee saved registers for CPU or Floating Point
|
||||
// registers. For CPU registers consider RA, GP and FP for saving if necessary.
|
||||
void MipsAsmPrinter::
|
||||
printSavedRegsBitmask(MachineFunction &MF)
|
||||
{
|
||||
void MipsAsmPrinter::printSavedRegsBitmask() {
|
||||
const TargetRegisterInfo &RI = *TM.getRegisterInfo();
|
||||
MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>();
|
||||
const MipsFunctionInfo *MipsFI = MF->getInfo<MipsFunctionInfo>();
|
||||
|
||||
// CPU and FPU Saved Registers Bitmasks
|
||||
unsigned int CPUBitmask = 0;
|
||||
unsigned int FPUBitmask = 0;
|
||||
|
||||
// Set the CPU and FPU Bitmasks
|
||||
MachineFrameInfo *MFI = MF.getFrameInfo();
|
||||
const MachineFrameInfo *MFI = MF->getFrameInfo();
|
||||
const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
|
||||
for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
|
||||
unsigned RegNum = MipsRegisterInfo::getRegisterNumbering(CSI[i].getReg());
|
||||
@ -146,11 +143,11 @@ printSavedRegsBitmask(MachineFunction &MF)
|
||||
}
|
||||
|
||||
// Return Address and Frame registers must also be set in CPUBitmask.
|
||||
if (RI.hasFP(MF))
|
||||
if (RI.hasFP(*MF))
|
||||
CPUBitmask |= (1 << MipsRegisterInfo::
|
||||
getRegisterNumbering(RI.getFrameRegister(MF)));
|
||||
getRegisterNumbering(RI.getFrameRegister(*MF)));
|
||||
|
||||
if (MF.getFrameInfo()->hasCalls())
|
||||
if (MFI->hasCalls())
|
||||
CPUBitmask |= (1 << MipsRegisterInfo::
|
||||
getRegisterNumbering(RI.getRARegister()));
|
||||
|
||||
@ -177,12 +174,12 @@ printHex32(unsigned int Value)
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// Frame Directive
|
||||
void MipsAsmPrinter::emitFrameDirective(MachineFunction &MF) {
|
||||
void MipsAsmPrinter::emitFrameDirective() {
|
||||
const TargetRegisterInfo &RI = *TM.getRegisterInfo();
|
||||
|
||||
unsigned stackReg = RI.getFrameRegister(MF);
|
||||
unsigned stackReg = RI.getFrameRegister(*MF);
|
||||
unsigned returnReg = RI.getRARegister();
|
||||
unsigned stackSize = MF.getFrameInfo()->getStackSize();
|
||||
unsigned stackSize = MF->getFrameInfo()->getStackSize();
|
||||
|
||||
|
||||
O << "\t.frame\t" << '$' << LowercaseString(getRegisterName(stackReg))
|
||||
@ -211,45 +208,16 @@ void MipsAsmPrinter::EmitFunctionEntryLabel() {
|
||||
OutStreamer.EmitLabel(CurrentFnSym);
|
||||
}
|
||||
|
||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
||||
/// method to print assembly for each instruction.
|
||||
bool MipsAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
SetupMachineFunction(MF);
|
||||
|
||||
EmitFunctionHeader();
|
||||
|
||||
emitFrameDirective(MF);
|
||||
printSavedRegsBitmask(MF);
|
||||
|
||||
O << '\n';
|
||||
|
||||
// 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.
|
||||
if (I != MF.begin())
|
||||
EmitBasicBlockStart(I);
|
||||
|
||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
||||
II != E; ++II) {
|
||||
processDebugLoc(II, true);
|
||||
|
||||
// Print the assembly for the instruction.
|
||||
printInstruction(II);
|
||||
|
||||
if (VerboseAsm)
|
||||
EmitComments(*II);
|
||||
O << '\n';
|
||||
|
||||
processDebugLoc(II, false);
|
||||
++EmittedInsts;
|
||||
}
|
||||
|
||||
// Each Basic Block is separated by a newline
|
||||
O << '\n';
|
||||
}
|
||||
/// EmitFunctionBodyStart - Targets can override this to emit stuff before
|
||||
/// the first basic block in the function.
|
||||
void MipsAsmPrinter::EmitFunctionBodyStart() {
|
||||
emitFrameDirective();
|
||||
printSavedRegsBitmask();
|
||||
}
|
||||
|
||||
/// EmitFunctionBodyEnd - Targets can override this to emit stuff after
|
||||
/// the last basic block in the function.
|
||||
void MipsAsmPrinter::EmitFunctionBodyEnd() {
|
||||
// There are instruction for this macros, but they must
|
||||
// always be at the function end, and we can't emit and
|
||||
// break with BB logic.
|
||||
@ -257,16 +225,9 @@ bool MipsAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
O << "\t.set\treorder\n";
|
||||
|
||||
O << "\t.end\t" << *CurrentFnSym << '\n';
|
||||
if (MAI->hasDotTypeDotSizeDirective() && !Subtarget->isLinux())
|
||||
O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\n';
|
||||
|
||||
// Print out jump tables referenced by the function
|
||||
EmitJumpTableInfo();
|
||||
|
||||
// We didn't modify anything.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Print out an operand for an inline asm expression.
|
||||
bool MipsAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
unsigned AsmVariant,const char *ExtraCode){
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
@ -42,8 +41,6 @@
|
||||
#include <cctype>
|
||||
using namespace llvm;
|
||||
|
||||
STATISTIC(EmittedInsts, "Number of machine instrs printed");
|
||||
|
||||
static cl::opt<unsigned> MaxThreads("xcore-max-threads", cl::Optional,
|
||||
cl::desc("Maximum number of threads (for emulation thread-local storage)"),
|
||||
cl::Hidden,
|
||||
@ -78,8 +75,9 @@ namespace {
|
||||
void printInstruction(const MachineInstr *MI); // autogenerated.
|
||||
static const char *getRegisterName(unsigned RegNo);
|
||||
|
||||
void printMachineInstruction(const MachineInstr *MI);
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
bool runOnMachineFunction(MachineFunction &MF);
|
||||
void EmitInstruction(const MachineInstr *MI);
|
||||
void EmitFunctionBodyEnd();
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AsmPrinter::getAnalysisUsage(AU);
|
||||
@ -219,6 +217,14 @@ void XCoreAsmPrinter::emitFunctionStart(MachineFunction &MF) {
|
||||
O << *CurrentFnSym << ":\n";
|
||||
}
|
||||
|
||||
|
||||
/// EmitFunctionBodyEnd - Targets can override this to emit stuff after
|
||||
/// the last basic block in the function.
|
||||
void XCoreAsmPrinter::EmitFunctionBodyEnd() {
|
||||
// Emit function end directives
|
||||
O << "\t.cc_bottom " << *CurrentFnSym << ".function\n";
|
||||
}
|
||||
|
||||
/// runOnMachineFunction - This uses the printMachineInstruction()
|
||||
/// method to print assembly for each instruction.
|
||||
///
|
||||
@ -234,34 +240,7 @@ bool XCoreAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
// Emit pre-function debug information.
|
||||
DW->BeginFunction(&MF);
|
||||
|
||||
// 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.
|
||||
if (I != MF.begin())
|
||||
EmitBasicBlockStart(I);
|
||||
|
||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
||||
II != E; ++II) {
|
||||
// Print the assembly for the instruction.
|
||||
printMachineInstruction(II);
|
||||
}
|
||||
|
||||
// Each Basic Block is separated by a newline
|
||||
O << '\n';
|
||||
}
|
||||
|
||||
// Emit function end directives
|
||||
O << "\t.cc_bottom " << *CurrentFnSym << ".function\n";
|
||||
|
||||
// Print out jump tables referenced by the function
|
||||
EmitJumpTableInfo();
|
||||
|
||||
// Emit post-function debug information.
|
||||
DW->EndFunction(&MF);
|
||||
|
||||
// We didn't modify anything.
|
||||
EmitFunctionBody();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -320,11 +299,7 @@ bool XCoreAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
return false;
|
||||
}
|
||||
|
||||
void XCoreAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||
++EmittedInsts;
|
||||
|
||||
processDebugLoc(MI, true);
|
||||
|
||||
void XCoreAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
||||
// Check for mov mnemonic
|
||||
unsigned src, dst, srcSR, dstSR;
|
||||
if (TM.getInstrInfo()->isMoveInstr(*MI, src, dst, srcSR, dstSR)) {
|
||||
@ -333,11 +308,6 @@ void XCoreAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||
return;
|
||||
}
|
||||
printInstruction(MI);
|
||||
if (VerboseAsm)
|
||||
EmitComments(*MI);
|
||||
O << '\n';
|
||||
|
||||
processDebugLoc(MI, false);
|
||||
}
|
||||
|
||||
// Force static initialization.
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llc < %s -march=xcore | FileCheck %s
|
||||
; RUN: llc < %s -march=xcore -asm-verbose=0 | FileCheck %s
|
||||
define i32 @ashr(i32 %a, i32 %b) {
|
||||
%1 = ashr i32 %a, %b
|
||||
ret i32 %1
|
||||
|
Loading…
Reference in New Issue
Block a user