mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-08 19:25:47 +00:00
Eliminate the printCallOperand method, using a 'call' modifier on
printOperand instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26025 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -63,7 +63,9 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void X86ATTAsmPrinter::printOp(const MachineOperand &MO, bool isCallOp) {
|
void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||||
|
const char *Modifier) {
|
||||||
|
const MachineOperand &MO = MI->getOperand(OpNo);
|
||||||
const MRegisterInfo &RI = *TM.getRegisterInfo();
|
const MRegisterInfo &RI = *TM.getRegisterInfo();
|
||||||
switch (MO.getType()) {
|
switch (MO.getType()) {
|
||||||
case MachineOperand::MO_VirtualRegister:
|
case MachineOperand::MO_VirtualRegister:
|
||||||
@@ -92,6 +94,7 @@ void X86ATTAsmPrinter::printOp(const MachineOperand &MO, bool isCallOp) {
|
|||||||
abort ();
|
abort ();
|
||||||
return;
|
return;
|
||||||
case MachineOperand::MO_GlobalAddress: {
|
case MachineOperand::MO_GlobalAddress: {
|
||||||
|
bool isCallOp = Modifier && !strcmp(Modifier, "call");
|
||||||
// Darwin block shameless ripped from PowerPCAsmPrinter.cpp
|
// Darwin block shameless ripped from PowerPCAsmPrinter.cpp
|
||||||
if (forDarwin) {
|
if (forDarwin) {
|
||||||
if (!isCallOp) O << '$';
|
if (!isCallOp) O << '$';
|
||||||
@@ -132,7 +135,8 @@ void X86ATTAsmPrinter::printOp(const MachineOperand &MO, bool isCallOp) {
|
|||||||
O << Offset;
|
O << Offset;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case MachineOperand::MO_ExternalSymbol:
|
case MachineOperand::MO_ExternalSymbol: {
|
||||||
|
bool isCallOp = Modifier && !strcmp(Modifier, "call");
|
||||||
if (isCallOp && forDarwin) {
|
if (isCallOp && forDarwin) {
|
||||||
std::string Name(GlobalPrefix); Name += MO.getSymbolName();
|
std::string Name(GlobalPrefix); Name += MO.getSymbolName();
|
||||||
FnStubs.insert(Name);
|
FnStubs.insert(Name);
|
||||||
@@ -142,6 +146,7 @@ void X86ATTAsmPrinter::printOp(const MachineOperand &MO, bool isCallOp) {
|
|||||||
if (!isCallOp) O << '$';
|
if (!isCallOp) O << '$';
|
||||||
O << GlobalPrefix << MO.getSymbolName();
|
O << GlobalPrefix << MO.getSymbolName();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
O << "<unknown operand type>"; return;
|
O << "<unknown operand type>"; return;
|
||||||
}
|
}
|
||||||
@@ -183,7 +188,7 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
|
|||||||
O << "+" << DispSpec.getImmedValue();
|
O << "+" << DispSpec.getImmedValue();
|
||||||
if (IndexReg.getReg()) {
|
if (IndexReg.getReg()) {
|
||||||
O << "(,";
|
O << "(,";
|
||||||
printOp(IndexReg);
|
printOperand(MI, Op+2);
|
||||||
if (ScaleVal != 1)
|
if (ScaleVal != 1)
|
||||||
O << "," << ScaleVal;
|
O << "," << ScaleVal;
|
||||||
O << ")";
|
O << ")";
|
||||||
@@ -192,7 +197,7 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (DispSpec.isGlobalAddress()) {
|
if (DispSpec.isGlobalAddress()) {
|
||||||
printOp(DispSpec, true);
|
printOperand(MI, Op+3, "call");
|
||||||
} else {
|
} else {
|
||||||
int DispVal = DispSpec.getImmedValue();
|
int DispVal = DispSpec.getImmedValue();
|
||||||
if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg()))
|
if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg()))
|
||||||
@@ -202,11 +207,11 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
|
|||||||
if (IndexReg.getReg() || BaseReg.getReg()) {
|
if (IndexReg.getReg() || BaseReg.getReg()) {
|
||||||
O << "(";
|
O << "(";
|
||||||
if (BaseReg.getReg())
|
if (BaseReg.getReg())
|
||||||
printOp(BaseReg);
|
printOperand(MI, Op);
|
||||||
|
|
||||||
if (IndexReg.getReg()) {
|
if (IndexReg.getReg()) {
|
||||||
O << ",";
|
O << ",";
|
||||||
printOp(IndexReg);
|
printOperand(MI, Op+2);
|
||||||
if (ScaleVal != 1)
|
if (ScaleVal != 1)
|
||||||
O << "," << ScaleVal;
|
O << "," << ScaleVal;
|
||||||
}
|
}
|
||||||
|
@@ -34,13 +34,9 @@ struct X86ATTAsmPrinter : public X86SharedAsmPrinter {
|
|||||||
/// returns false.
|
/// returns false.
|
||||||
bool printInstruction(const MachineInstr *MI);
|
bool printInstruction(const MachineInstr *MI);
|
||||||
|
|
||||||
// This method is used by the tablegen'erated instruction printer.
|
// These methods are used by the tablegen'erated instruction printer.
|
||||||
void printOperand(const MachineInstr *MI, unsigned OpNo){
|
void printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||||
printOp(MI->getOperand(OpNo));
|
const char *Modifier = 0);
|
||||||
}
|
|
||||||
void printCallOperand(const MachineInstr *MI, unsigned OpNo) {
|
|
||||||
printOp(MI->getOperand(OpNo), true); // Don't print '$' prefix.
|
|
||||||
}
|
|
||||||
void printi8mem(const MachineInstr *MI, unsigned OpNo) {
|
void printi8mem(const MachineInstr *MI, unsigned OpNo) {
|
||||||
printMemReference(MI, OpNo);
|
printMemReference(MI, OpNo);
|
||||||
}
|
}
|
||||||
@@ -64,7 +60,6 @@ struct X86ATTAsmPrinter : public X86SharedAsmPrinter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void printMachineInstruction(const MachineInstr *MI);
|
void printMachineInstruction(const MachineInstr *MI);
|
||||||
void printOp(const MachineOperand &MO, bool isCallOperand = false);
|
|
||||||
void printSSECC(const MachineInstr *MI, unsigned Op);
|
void printSSECC(const MachineInstr *MI, unsigned Op);
|
||||||
void printMemReference(const MachineInstr *MI, unsigned Op);
|
void printMemReference(const MachineInstr *MI, unsigned Op);
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
bool runOnMachineFunction(MachineFunction &F);
|
||||||
|
@@ -159,10 +159,6 @@ def i16i8imm : Operand<i16>;
|
|||||||
// 32-bits but only 8 bits are significant.
|
// 32-bits but only 8 bits are significant.
|
||||||
def i32i8imm : Operand<i32>;
|
def i32i8imm : Operand<i32>;
|
||||||
|
|
||||||
// PCRelative calls need special operand formatting.
|
|
||||||
let PrintMethod = "printCallOperand" in
|
|
||||||
def calltarget : Operand<i32>;
|
|
||||||
|
|
||||||
// Branch targets have OtherVT type.
|
// Branch targets have OtherVT type.
|
||||||
def brtarget : Operand<OtherVT>;
|
def brtarget : Operand<OtherVT>;
|
||||||
|
|
||||||
@@ -516,7 +512,7 @@ let isCall = 1, noResults = 1 in
|
|||||||
// All calls clobber the non-callee saved registers...
|
// All calls clobber the non-callee saved registers...
|
||||||
let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
|
let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
|
||||||
XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
|
XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
|
||||||
def CALLpcrel32 : I<0xE8, RawFrm, (ops calltarget:$dst), "call $dst",
|
def CALLpcrel32 : I<0xE8, RawFrm, (ops i32imm:$dst), "call ${dst:call}",
|
||||||
[]>;
|
[]>;
|
||||||
def CALL32r : I<0xFF, MRM2r, (ops R32:$dst), "call {*}$dst",
|
def CALL32r : I<0xFF, MRM2r, (ops R32:$dst), "call {*}$dst",
|
||||||
[(X86call R32:$dst)]>;
|
[(X86call R32:$dst)]>;
|
||||||
@@ -526,7 +522,7 @@ let isCall = 1, noResults = 1 in
|
|||||||
|
|
||||||
// Tail call stuff.
|
// Tail call stuff.
|
||||||
let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
|
let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
|
||||||
def TAILJMPd : IBr<0xE9, (ops calltarget:$dst), "jmp $dst # TAIL CALL", []>;
|
def TAILJMPd : IBr<0xE9, (ops i32imm:$dst), "jmp ${dst:call} # TAIL CALL", []>;
|
||||||
let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
|
let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
|
||||||
def TAILJMPr : I<0xFF, MRM4r, (ops R32:$dst), "jmp {*}$dst # TAIL CALL", []>;
|
def TAILJMPr : I<0xFF, MRM4r, (ops R32:$dst), "jmp {*}$dst # TAIL CALL", []>;
|
||||||
let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
|
let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
|
||||||
|
@@ -74,8 +74,8 @@ void X86IntelAsmPrinter::printSSECC(const MachineInstr *MI, unsigned Op) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
|
void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
|
||||||
bool elideOffsetKeyword /* = false */) {
|
const char *Modifier) {
|
||||||
const MRegisterInfo &RI = *TM.getRegisterInfo();
|
const MRegisterInfo &RI = *TM.getRegisterInfo();
|
||||||
switch (MO.getType()) {
|
switch (MO.getType()) {
|
||||||
case MachineOperand::MO_VirtualRegister:
|
case MachineOperand::MO_VirtualRegister:
|
||||||
@@ -109,7 +109,7 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
|
|||||||
abort ();
|
abort ();
|
||||||
return;
|
return;
|
||||||
case MachineOperand::MO_GlobalAddress: {
|
case MachineOperand::MO_GlobalAddress: {
|
||||||
if (!elideOffsetKeyword)
|
if (!Modifier || strcmp(Modifier, "call"))
|
||||||
O << "OFFSET ";
|
O << "OFFSET ";
|
||||||
O << Mang->getValueName(MO.getGlobal());
|
O << Mang->getValueName(MO.getGlobal());
|
||||||
int Offset = MO.getOffset();
|
int Offset = MO.getOffset();
|
||||||
@@ -161,7 +161,7 @@ void X86IntelAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
|
|||||||
O << "[";
|
O << "[";
|
||||||
bool NeedPlus = false;
|
bool NeedPlus = false;
|
||||||
if (BaseReg.getReg()) {
|
if (BaseReg.getReg()) {
|
||||||
printOp(BaseReg, true);
|
printOp(BaseReg, "call");
|
||||||
NeedPlus = true;
|
NeedPlus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ void X86IntelAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
|
|||||||
if (DispSpec.isGlobalAddress()) {
|
if (DispSpec.isGlobalAddress()) {
|
||||||
if (NeedPlus)
|
if (NeedPlus)
|
||||||
O << " + ";
|
O << " + ";
|
||||||
printOp(DispSpec, true);
|
printOp(DispSpec, "call");
|
||||||
} else {
|
} else {
|
||||||
int DispVal = DispSpec.getImmedValue();
|
int DispVal = DispSpec.getImmedValue();
|
||||||
if (DispVal || (!BaseReg.getReg() && !IndexReg.getReg())) {
|
if (DispVal || (!BaseReg.getReg() && !IndexReg.getReg())) {
|
||||||
|
@@ -37,21 +37,18 @@ struct X86IntelAsmPrinter : public X86SharedAsmPrinter {
|
|||||||
bool printInstruction(const MachineInstr *MI);
|
bool printInstruction(const MachineInstr *MI);
|
||||||
|
|
||||||
// This method is used by the tablegen'erated instruction printer.
|
// This method is used by the tablegen'erated instruction printer.
|
||||||
void printOperand(const MachineInstr *MI, unsigned OpNo){
|
void printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||||
|
const char *Modifier = 0) {
|
||||||
const MachineOperand &MO = MI->getOperand(OpNo);
|
const MachineOperand &MO = MI->getOperand(OpNo);
|
||||||
if (MO.getType() == MachineOperand::MO_MachineRegister) {
|
if (MO.getType() == MachineOperand::MO_MachineRegister) {
|
||||||
assert(MRegisterInfo::isPhysicalRegister(MO.getReg())&&"Not physref??");
|
assert(MRegisterInfo::isPhysicalRegister(MO.getReg())&&"Not physref??");
|
||||||
// Bug Workaround: See note in Printer::doInitialization about %.
|
// Bug Workaround: See note in Printer::doInitialization about %.
|
||||||
O << "%" << TM.getRegisterInfo()->get(MO.getReg()).Name;
|
O << "%" << TM.getRegisterInfo()->get(MO.getReg()).Name;
|
||||||
} else {
|
} else {
|
||||||
printOp(MO);
|
printOp(MO, Modifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printCallOperand(const MachineInstr *MI, unsigned OpNo) {
|
|
||||||
printOp(MI->getOperand(OpNo), true); // Don't print "OFFSET".
|
|
||||||
}
|
|
||||||
|
|
||||||
void printi8mem(const MachineInstr *MI, unsigned OpNo) {
|
void printi8mem(const MachineInstr *MI, unsigned OpNo) {
|
||||||
O << "BYTE PTR ";
|
O << "BYTE PTR ";
|
||||||
printMemReference(MI, OpNo);
|
printMemReference(MI, OpNo);
|
||||||
@@ -82,7 +79,7 @@ struct X86IntelAsmPrinter : public X86SharedAsmPrinter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void printMachineInstruction(const MachineInstr *MI);
|
void printMachineInstruction(const MachineInstr *MI);
|
||||||
void printOp(const MachineOperand &MO, bool elideOffsetKeyword = false);
|
void printOp(const MachineOperand &MO, const char *Modifier = 0);
|
||||||
void printSSECC(const MachineInstr *MI, unsigned Op);
|
void printSSECC(const MachineInstr *MI, unsigned Op);
|
||||||
void printMemReference(const MachineInstr *MI, unsigned Op);
|
void printMemReference(const MachineInstr *MI, unsigned Op);
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
bool runOnMachineFunction(MachineFunction &F);
|
||||||
|
Reference in New Issue
Block a user