[llvm-commits] [llvm] r51923 - in /llvm/trunk/lib/Target/Mips: MipsAsmPrinter.cpp MipsISelLowering.cpp MipsInstrInfo.td MipsRegisterInfo.cpp MipsSubtarget.cpp MipsSubtarget.h MipsTargetMachine.cpp MipsTargetMachine.h

Bruno Cardoso Lopes bruno.cardoso at gmail.com
Tue Jun 3 18:45:25 PDT 2008


Author: bruno
Date: Tue Jun  3 20:45:25 2008
New Revision: 51923

URL: http://llvm.org/viewvc/llvm-project?rev=51923&view=rev
Log:
Some Mips minor fixes
Added support for mips little endian arch => mipsel


Modified:
    llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp
    llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
    llvm/trunk/lib/Target/Mips/MipsInstrInfo.td
    llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp
    llvm/trunk/lib/Target/Mips/MipsSubtarget.cpp
    llvm/trunk/lib/Target/Mips/MipsSubtarget.h
    llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp
    llvm/trunk/lib/Target/Mips/MipsTargetMachine.h

Modified: llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp?rev=51923&r1=51922&r2=51923&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp Tue Jun  3 20:45:25 2008
@@ -547,5 +547,7 @@
     }
   }
 
+  O << "\n";
+
   return AsmPrinter::doFinalization(M);
 }

Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=51923&r1=51922&r2=51923&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Tue Jun  3 20:45:25 2008
@@ -365,6 +365,7 @@
   Chain  = DAG.getNode(MipsISD::JmpLink, NodeTys, &Ops[0], Ops.size());
   InFlag = Chain.getValue(1);
 
+  // Create the CALLSEQ_END node.
   Chain = DAG.getCALLSEQ_END(Chain,
                              DAG.getConstant(NumBytes, getPointerTy()),
                              DAG.getConstant(0, getPointerTy()),
@@ -400,8 +401,6 @@
       InFlag = Chain.getValue(1);
   }      
 
-  // Create the CALLSEQ_END node.
-
   // Handle result values, copying them out of physregs into vregs that we
   // return.
   return SDOperand(LowerCallResult(Chain, InFlag, Op.Val, CC, DAG), Op.ResNo);

Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.td?rev=51923&r1=51922&r2=51923&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsInstrInfo.td (original)
+++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Tue Jun  3 20:45:25 2008
@@ -135,7 +135,6 @@
       [], IIAlu>;
 
 // Arithmetic 2 register operands
-let isCommutable = 1 in
 class ArithI<bits<6> op, string instr_asm, SDNode OpNode,
              Operand Od, PatLeaf imm_type> :
   FI< op,

Modified: llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp?rev=51923&r1=51922&r2=51923&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp Tue Jun  3 20:45:25 2008
@@ -147,7 +147,7 @@
 //
 //  0                 ----------
 //  4                 Args to pass
-//  .                 saved $GP  (used in PIC - not supported yet)
+//  .                 saved $GP  (used in PIC)
 //  .                 Local Area
 //  .                 saved "Callee Saved" Registers
 //  .                 saved FP
@@ -369,7 +369,7 @@
   // lw  $ra, stack_loc($sp)
   if (MFI->hasCalls()) { 
     BuildMI(MBB, MBBI, TII.get(Mips::LW))
-        .addReg(Mips::RA).addImm(RAOffset).addReg(Mips::SP);
+      .addReg(Mips::RA).addImm(RAOffset).addReg(Mips::SP);
   }
 
   // adjust stack  : insert addi sp, sp, (imm)

Modified: llvm/trunk/lib/Target/Mips/MipsSubtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsSubtarget.cpp?rev=51923&r1=51922&r2=51923&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsSubtarget.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsSubtarget.cpp Tue Jun  3 20:45:25 2008
@@ -17,8 +17,9 @@
 using namespace llvm;
 
 MipsSubtarget::MipsSubtarget(const TargetMachine &TM, const Module &M, 
-                             const std::string &FS) : 
-  IsMipsIII(false)
+                             const std::string &FS, bool little) : 
+  IsMipsIII(false),
+  IsLittle(little)
 {
   std::string CPU = "mips1";
 

Modified: llvm/trunk/lib/Target/Mips/MipsSubtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsSubtarget.h?rev=51923&r1=51922&r2=51923&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsSubtarget.h (original)
+++ llvm/trunk/lib/Target/Mips/MipsSubtarget.h Tue Jun  3 20:45:25 2008
@@ -27,14 +27,14 @@
 protected:
 
   bool IsMipsIII;
+  bool IsLittle;
   InstrItineraryData InstrItins;
 
 public:
   /// This constructor initializes the data members to match that
   /// of the specified module.
-  ///
   MipsSubtarget(const TargetMachine &TM, const Module &M, 
-                const std::string &FS);
+                const std::string &FS, bool little);
   
   /// ParseSubtargetFeatures - Parses features string setting specified 
   /// subtarget options.  Definition of function is auto generated by tblgen.
@@ -43,6 +43,9 @@
   /// isMipsIII - Return true if the selected CPU supports MipsIII ISA
   /// support. 
   bool isMipsIII() const { return IsMipsIII; }
+
+  /// isMipsIII - Return true if the target is little endian. 
+  bool isLittle() const { return IsLittle; }
 };
 } // End llvm namespace
 

Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp?rev=51923&r1=51922&r2=51923&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp Tue Jun  3 20:45:25 2008
@@ -20,7 +20,8 @@
 using namespace llvm;
 
 // Register the target.
-static RegisterTarget<MipsTargetMachine> X("mips", "  Mips");
+static RegisterTarget<MipsTargetMachine>    X("mips", "  Mips");
+static RegisterTarget<MipselTargetMachine>  Y("mipsel", "  Mipsel");
 
 const TargetAsmInfo *MipsTargetMachine::
 createTargetAsmInfo() const 
@@ -35,11 +36,13 @@
 // offset from the stack/frame pointer, so StackGrowsUp is used.
 // When using CodeModel::Large the behaviour 
 //
-// 
 MipsTargetMachine::
-MipsTargetMachine(const Module &M, const std::string &FS): 
-  Subtarget(*this, M, FS), DataLayout("E-p:32:32:32"), 
-  InstrInfo(*this), FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0),
+MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle=false):
+  Subtarget(*this, M, FS, isLittle), 
+  DataLayout(isLittle ? std::string("e-p:32:32:32") :
+                        std::string("E-p:32:32:32")), 
+  InstrInfo(*this), 
+  FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0),
   TLInfo(*this) 
 {
   if (getRelocationModel() != Reloc::Static)
@@ -48,6 +51,10 @@
     setCodeModel(CodeModel::Small);
 }
 
+MipselTargetMachine::
+MipselTargetMachine(const Module &M, const std::string &FS) :
+  MipsTargetMachine(M, FS, true) {}
+
 // return 0 and must specify -march to gen MIPS code.
 unsigned MipsTargetMachine::
 getModuleMatchQuality(const Module &M) 
@@ -60,6 +67,18 @@
   return 0;
 }
 
+// return 0 and must specify -march to gen MIPSel code.
+unsigned MipselTargetMachine::
+getModuleMatchQuality(const Module &M) 
+{
+  // We strongly match "mipsel-*".
+  std::string TT = M.getTargetTriple();
+  if (TT.size() >= 7 && std::string(TT.begin(), TT.begin()+7) == "mipsel-")
+    return 20;
+  
+  return 0;
+}
+
 // Install an instruction selector pass using 
 // the ISelDag to gen Mips code.
 bool MipsTargetMachine::

Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.h?rev=51923&r1=51922&r2=51923&view=diff

==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetMachine.h (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.h Tue Jun  3 20:45:25 2008
@@ -33,7 +33,7 @@
     virtual const TargetAsmInfo *createTargetAsmInfo() const;
   
   public:
-    MipsTargetMachine(const Module &M, const std::string &FS);
+    MipsTargetMachine(const Module &M, const std::string &FS, bool isLittle);
 
     virtual const MipsInstrInfo   *getInstrInfo()     const 
     { return &InstrInfo; }
@@ -60,6 +60,16 @@
     virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast, 
                                     std::ostream &Out);
   };
+
+/// MipselTargetMachine - Mipsel target machine.
+///
+class MipselTargetMachine : public MipsTargetMachine {
+public:
+  MipselTargetMachine(const Module &M, const std::string &FS);
+
+  static unsigned getModuleMatchQuality(const Module &M);
+};
+
 } // End llvm namespace
 
 #endif





More information about the llvm-commits mailing list