From 0863c161e9431eec93c6c6e318748019dfb4fed2 Mon Sep 17 00:00:00 2001 From: Ruchira Sasanka Date: Wed, 24 Oct 2001 22:05:34 +0000 Subject: [PATCH] Fixed load syntax in EmitAssembly Fixed cpReg2Mem (store) operand oreder in SparcRegInfo.cpp llvm-svn: 984 --- llvm/lib/Target/Sparc/EmitAssembly.cpp | 39 +++++++++++++++++++++++++- llvm/lib/Target/Sparc/SparcRegInfo.cpp | 18 ++++++------ 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/llvm/lib/Target/Sparc/EmitAssembly.cpp b/llvm/lib/Target/Sparc/EmitAssembly.cpp index aadc790210c6..59cd52ab84c2 100644 --- a/llvm/lib/Target/Sparc/EmitAssembly.cpp +++ b/llvm/lib/Target/Sparc/EmitAssembly.cpp @@ -182,10 +182,47 @@ void SparcAsmPrinter::emitMachineInst(const MachineInstr *MI) { printOperand(MI->getOperand(1)); Out << endl; return; - + default: break; } + if( Target.getInstrInfo().isLoad(Opcode) ) { // if Load + assert(MI->getNumOperands() == 3 && "Loads must have 3 operands"); + Out << "["; + printOperand(MI->getOperand(0)); + + const MachineOperand& ImmOp = MI->getOperand(1); + if( ImmOp.getImmedValue() >= 0) + Out << "+"; + printOperand(ImmOp); + Out << "]"; + Out << ", "; + + printOperand(MI->getOperand(2)); + Out << endl; + return; + + } + + if( Target.getInstrInfo().isStore(Opcode) ) { // if Store + assert(MI->getNumOperands() == 3 && "Stores must have 3 operands"); + printOperand(MI->getOperand(0)); + Out << ", "; + Out << "["; + printOperand(MI->getOperand(1)); + + const MachineOperand& ImmOp = MI->getOperand(2); + if( ImmOp.getImmedValue() >= 0) + Out << "+"; + printOperand(ImmOp); + Out << "]"; + Out << endl; + return; + + } + + + unsigned Mask = getOperandMask(Opcode); bool NeedComma = false; diff --git a/llvm/lib/Target/Sparc/SparcRegInfo.cpp b/llvm/lib/Target/Sparc/SparcRegInfo.cpp index 54cfb3caab57..dfb55176960a 100644 --- a/llvm/lib/Target/Sparc/SparcRegInfo.cpp +++ b/llvm/lib/Target/Sparc/SparcRegInfo.cpp @@ -775,8 +775,8 @@ MachineInstr * UltraSparcRegInfo::cpReg2RegMI(const unsigned SrcReg, //--------------------------------------------------------------------------- -// Copy from a register to memory. Register number must be the unified -// register number +// Copy from a register to memory (i.e., Store). Register number must +// be the unified register number //--------------------------------------------------------------------------- @@ -794,24 +794,24 @@ MachineInstr * UltraSparcRegInfo::cpReg2MemMI(const unsigned SrcReg, case IntCCRegType: case FloatCCRegType: MI = new MachineInstr(STX, 3); - MI->SetMachineOperand(0, DestPtrReg, false); - MI->SetMachineOperand(1, SrcReg, false); + MI->SetMachineOperand(0, SrcReg, false); + MI->SetMachineOperand(1, DestPtrReg, false); MI->SetMachineOperand(2, MachineOperand:: MO_SignExtendedImmed, (int64_t) Offset, false); break; case FPSingleRegType: MI = new MachineInstr(ST, 3); - MI->SetMachineOperand(0, DestPtrReg, false); - MI->SetMachineOperand(1, SrcReg, false); + MI->SetMachineOperand(0, SrcReg, false); + MI->SetMachineOperand(1, DestPtrReg, false); MI->SetMachineOperand(2, MachineOperand:: MO_SignExtendedImmed, (int64_t) Offset, false); break; case FPDoubleRegType: MI = new MachineInstr(STD, 3); - MI->SetMachineOperand(0, DestPtrReg, false); - MI->SetMachineOperand(1, SrcReg, false); + MI->SetMachineOperand(0, SrcReg, false); + MI->SetMachineOperand(1, DestPtrReg, false); MI->SetMachineOperand(2, MachineOperand:: MO_SignExtendedImmed, (int64_t) Offset, false); break; @@ -825,7 +825,7 @@ MachineInstr * UltraSparcRegInfo::cpReg2MemMI(const unsigned SrcReg, //--------------------------------------------------------------------------- -// Copy from memory to a reg. Register number must be the unified +// Copy from memory to a reg (i.e., Load) Register number must be the unified // register number //---------------------------------------------------------------------------