From 3c2684d13646a76a0dd9ca6a8da5bd7fc0de6e8a Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Sun, 3 May 2009 13:08:13 +0000 Subject: [PATCH] Some early full call lowering draft for direct calls git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70729 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/MSP430/MSP430AsmPrinter.cpp | 28 +++++++++++++++++++------- lib/Target/MSP430/MSP430InstrInfo.td | 16 +++++++++++---- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/lib/Target/MSP430/MSP430AsmPrinter.cpp b/lib/Target/MSP430/MSP430AsmPrinter.cpp index 6f1c8ebfd08..a9a27110296 100644 --- a/lib/Target/MSP430/MSP430AsmPrinter.cpp +++ b/lib/Target/MSP430/MSP430AsmPrinter.cpp @@ -127,19 +127,33 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum, const MachineOperand &MO = MI->getOperand(OpNum); switch (MO.getType()) { case MachineOperand::MO_Register: - if (TargetRegisterInfo::isPhysicalRegister(MO.getReg())) - O << TM.getRegisterInfo()->get(MO.getReg()).AsmName; - else - assert(0 && "not implemented"); - break; + assert (TargetRegisterInfo::isPhysicalRegister(MO.getReg()) && + "Virtual registers should be already mapped!"); + O << TM.getRegisterInfo()->get(MO.getReg()).AsmName; + return; case MachineOperand::MO_Immediate: if (!Modifier || strcmp(Modifier, "nohash")) O << '#'; O << MO.getImm(); - break; + return; case MachineOperand::MO_MachineBasicBlock: printBasicBlockLabel(MO.getMBB()); - break; + return; + case MachineOperand::MO_GlobalAddress: { + bool isMemOp = Modifier && !strcmp(Modifier, "mem"); + bool isCallOp = Modifier && !strcmp(Modifier, "call"); + std::string Name = Mang->getValueName(MO.getGlobal()); + assert(MO.getOffset() == 0 && "No offsets allowed!"); + + if (isCallOp) + O << '#'; + else if (isMemOp) + O << '&'; + + O << Name; + + return; + } default: assert(0 && "Not implemented yet!"); } diff --git a/lib/Target/MSP430/MSP430InstrInfo.td b/lib/Target/MSP430/MSP430InstrInfo.td index 1f13f2dd944..5d3566df5ff 100644 --- a/lib/Target/MSP430/MSP430InstrInfo.td +++ b/lib/Target/MSP430/MSP430InstrInfo.td @@ -106,10 +106,12 @@ let isCall = 1 in // registers are added manually. let Defs = [R12W, R13W, R14W, R15W, SRW], Uses = [SPW] in { - def CALL32r : Pseudo<(outs), (ins GR16:$dst, variable_ops), - "call\t{*}$dst", [(MSP430call GR16:$dst)]>; - def CALL32m : Pseudo<(outs), (ins memsrc:$dst, variable_ops), - "call\t{*}$dst", [(MSP430call (load addr:$dst))]>; + def CALLi : Pseudo<(outs), (ins i16imm:$dst, variable_ops), + "call\t${dst:call}", [(MSP430call imm:$dst)]>; + def CALLr : Pseudo<(outs), (ins GR16:$dst, variable_ops), + "call\t$dst", [(MSP430call GR16:$dst)]>; + def CALLm : Pseudo<(outs), (ins memsrc:$dst, variable_ops), + "call\t${dst:mem}", [(MSP430call (load addr:$dst))]>; } @@ -608,3 +610,9 @@ def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>; // truncs def : Pat<(i8 (trunc GR16:$src)), (EXTRACT_SUBREG GR16:$src, subreg_8bit)>; + +// calls +def : Pat<(MSP430call (i16 tglobaladdr:$dst)), + (CALLi tglobaladdr:$dst)>; +def : Pat<(MSP430call (i16 texternalsym:$dst)), + (CALLi texternalsym:$dst)>; -- 2.34.1