[llvm-commits] [llvm] r157408 - in /llvm/trunk: lib/Target/Mips/Mips16InstrFormats.td lib/Target/Mips/Mips16InstrInfo.td lib/Target/Mips/MipsInstrInfo.td lib/Target/Mips/MipsRegisterInfo.td test/CodeGen/Mips/null.ll
Akira Hatanaka
ahatanaka at mips.com
Thu May 24 11:32:33 PDT 2012
Author: ahatanak
Date: Thu May 24 13:32:33 2012
New Revision: 157408
URL: http://llvm.org/viewvc/llvm-project?rev=157408&view=rev
Log:
Enable Mips16 compiler to compile a null program.
First code from the Mips16 compiler. Includes trivial test program.
Patch by Reed Kotler.
Added:
llvm/trunk/lib/Target/Mips/Mips16InstrInfo.td
llvm/trunk/test/CodeGen/Mips/null.ll
Modified:
llvm/trunk/lib/Target/Mips/Mips16InstrFormats.td
llvm/trunk/lib/Target/Mips/MipsInstrInfo.td
llvm/trunk/lib/Target/Mips/MipsRegisterInfo.td
Modified: llvm/trunk/lib/Target/Mips/Mips16InstrFormats.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips16InstrFormats.td?rev=157408&r1=157407&r2=157408&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/Mips16InstrFormats.td (original)
+++ llvm/trunk/lib/Target/Mips/Mips16InstrFormats.td Thu May 24 13:32:33 2012
@@ -173,7 +173,7 @@
// Format RR instruction class in Mips : <|opcode|rx|ry|funct|>
//===----------------------------------------------------------------------===//
-class FRR16<bits<5> op, bits<5> _funct, dag outs, dag ins, string asmstr,
+class FRR16<bits<5> _funct, dag outs, dag ins, string asmstr,
list<dag> pattern, InstrItinClass itin>:
MipsInst16<outs, ins, asmstr, pattern, itin, FrmRR16>
{
@@ -181,7 +181,7 @@
bits<3> ry;
bits<5> funct;
- let Opcode = op;
+ let Opcode = 0b11101;
let funct = _funct;
let Inst{10-8} = rx;
Added: llvm/trunk/lib/Target/Mips/Mips16InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips16InstrInfo.td?rev=157408&view=auto
==============================================================================
--- llvm/trunk/lib/Target/Mips/Mips16InstrInfo.td (added)
+++ llvm/trunk/lib/Target/Mips/Mips16InstrInfo.td Thu May 24 13:32:33 2012
@@ -0,0 +1,18 @@
+//===- Mips16InstrInfo.td - Target Description for Mips16 -*- tablegen -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file describes Mips16 instructions.
+//
+//===----------------------------------------------------------------------===//
+
+let isReturn=1, isTerminator=1, hasDelaySlot=1, isCodeGenOnly=1,
+ isBarrier=1, hasCtrlDep=1, rx=0b000, ry=0b001 in
+def RET16 : FRR16 <0, (outs), (ins CPURAReg:$target),
+ "jr\t$target", [(MipsRet CPURAReg:$target)], IIBranch>,
+ Requires<[InMips16Mode]>;
Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.td?rev=157408&r1=157407&r2=157408&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsInstrInfo.td (original)
+++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Thu May 24 13:32:33 2012
@@ -140,6 +140,8 @@
AssemblerPredicate<"FeatureN64">;
def NotN64 : Predicate<"!Subtarget.isABI_N64()">,
AssemblerPredicate<"!FeatureN64">;
+def InMips16Mode : Predicate<"Subtarget.inMips16Mode()">,
+ AssemblerPredicate<"FeatureMips16">;
def RelocStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">,
AssemblerPredicate<"FeatureMips32">;
def RelocPIC : Predicate<"TM.getRelocationModel() == Reloc::PIC_">,
@@ -147,8 +149,8 @@
def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">,
AssemblerPredicate<"FeatureMips32">;
def HasStandardEncoding:
- Predicate<"Subtarget.hasStandardEncoding()">,
- AssemblerPredicate<"FeatureMips32,FeatureMips32r2,FeatureMips64"> ;
+ Predicate<"Subtarget.hasStandardEncoding()">,
+ AssemblerPredicate<"FeatureMips32,FeatureMips32r2,FeatureMips64"> ;
//===----------------------------------------------------------------------===//
// Instruction format superclass
@@ -256,7 +258,8 @@
// Mips Address Mode! SDNode frameindex could possibily be a match
// since load and store instructions from stack used it.
-def addr : ComplexPattern<iPTR, 2, "SelectAddr", [frameindex], [SDNPWantParent]>;
+def addr :
+ ComplexPattern<iPTR, 2, "SelectAddr", [frameindex], [SDNPWantParent]>;
//===----------------------------------------------------------------------===//
// Pattern fragment for load/store
@@ -1211,4 +1214,4 @@
// Mips16
include "Mips16InstrFormats.td"
-
+include "Mips16InstrInfo.td"
Modified: llvm/trunk/lib/Target/Mips/MipsRegisterInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsRegisterInfo.td?rev=157408&r1=157407&r2=157408&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsRegisterInfo.td (original)
+++ llvm/trunk/lib/Target/Mips/MipsRegisterInfo.td Thu May 24 13:32:33 2012
@@ -271,6 +271,8 @@
// Callee save
S0, S1)>;
+def CPURAReg : RegisterClass<"Mips", [i32], 32, (add RA)>;
+
// 64bit fp:
// * FGR64 - 32 64-bit registers
Added: llvm/trunk/test/CodeGen/Mips/null.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/null.ll?rev=157408&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/null.ll (added)
+++ llvm/trunk/test/CodeGen/Mips/null.ll Thu May 24 13:32:33 2012
@@ -0,0 +1,10 @@
+; RUN: llc -march=mipsel -mcpu=mips16 < %s | FileCheck %s -check-prefix=16
+
+
+define i32 @main() nounwind {
+entry:
+ ret i32 0
+
+; 16: jr $ra
+
+}
More information about the llvm-commits
mailing list