blob: 9cb9811dc5b86a5056a2feb122164d31e7dd15d0 [file] [log] [blame]
Misha Brukmane07c2aa2004-02-25 21:02:21 +00001//===- SparcV8Instrs.td - Target Description for SparcV8 Target -----------===//
Brian Gaekee785e532004-02-25 19:28:19 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Misha Brukmane07c2aa2004-02-25 21:02:21 +000010// This file describes the SparcV8 instructions in TableGen format.
Brian Gaekee785e532004-02-25 19:28:19 +000011//
12//===----------------------------------------------------------------------===//
13
Misha Brukmane07c2aa2004-02-25 21:02:21 +000014//===----------------------------------------------------------------------===//
Misha Brukman23e6c1f2004-02-26 00:37:12 +000015// Instruction format superclass
Misha Brukmane07c2aa2004-02-25 21:02:21 +000016//===----------------------------------------------------------------------===//
17
18class InstV8 : Instruction { // SparcV8 instruction baseline
19 field bits<32> Inst;
20
21 let Namespace = "V8";
22
23 bits<2> op;
24 let Inst{31-30} = op; // Top two bits are the 'op' field
25
26 // Bit attributes specific to SparcV8 instructions
27 bit isPasi = 0; // Does this instruction affect an alternate addr space?
28 bit isPrivileged = 0; // Is this a privileged instruction?
Brian Gaekee785e532004-02-25 19:28:19 +000029}
30
Misha Brukmanc42077d2004-09-22 21:38:42 +000031include "SparcV8InstrFormats.td"
Brian Gaekee785e532004-02-25 19:28:19 +000032
Misha Brukman23e6c1f2004-02-26 00:37:12 +000033//===----------------------------------------------------------------------===//
34// Instructions
35//===----------------------------------------------------------------------===//
36
Chris Lattner275f6452004-02-28 19:37:18 +000037// Pseudo instructions.
Chris Lattner3ff57512005-12-16 06:02:58 +000038class PseudoInstV8<string nm, dag ops> : InstV8 {
Brian Gaeke7c4676f2004-07-16 10:32:10 +000039 let Name = nm;
Chris Lattner3ff57512005-12-16 06:02:58 +000040 dag OperandList = ops;
Chris Lattner275f6452004-02-28 19:37:18 +000041}
Chris Lattner3ff57512005-12-16 06:02:58 +000042def PHI : PseudoInstV8<"PHI", (ops variable_ops)>;
43def ADJCALLSTACKDOWN : PseudoInstV8<"ADJCALLSTACKDOWN", (ops variable_ops)>;
44def ADJCALLSTACKUP : PseudoInstV8<"ADJCALLSTACKUP", (ops variable_ops)>;
45def IMPLICIT_USE : PseudoInstV8<"IMPLICIT_USE", (ops variable_ops)>;
46def IMPLICIT_DEF : PseudoInstV8<"IMPLICIT_DEF", (ops variable_ops)>;
47def FpMOVD : PseudoInstV8<"FpMOVD", (ops)>; // pseudo 64-bit double move
Chris Lattner275f6452004-02-28 19:37:18 +000048
Brian Gaekea8056fa2004-03-06 05:32:13 +000049// Section A.3 - Synthetic Instructions, p. 85
Brian Gaekec3e97012004-05-08 04:21:32 +000050// special cases of JMPL:
Misha Brukman3df04c52004-10-14 22:32:49 +000051let isReturn = 1, isTerminator = 1, hasDelaySlot = 1 in {
52 let rd = I7.Num, rs1 = G0.Num, simm13 = 8 in
Chris Lattner96b84be2005-12-16 06:25:42 +000053 def RET : F3_2<2, 0b111000,
Chris Lattner1c4f4352005-12-16 06:52:00 +000054 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "ret">;
Misha Brukman3df04c52004-10-14 22:32:49 +000055 let rd = O7.Num, rs1 = G0.Num, simm13 = 8 in
Chris Lattner96b84be2005-12-16 06:25:42 +000056 def RETL: F3_2<2, 0b111000,
Chris Lattner1c4f4352005-12-16 06:52:00 +000057 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "retl">;
Misha Brukman3df04c52004-10-14 22:32:49 +000058}
Brian Gaekec3e97012004-05-08 04:21:32 +000059// CMP is a special case of SUBCC where destination is ignored, by setting it to
60// %g0 (hardwired zero).
61// FIXME: should keep track of the fact that it defs the integer condition codes
62let rd = 0 in
Chris Lattner96b84be2005-12-16 06:25:42 +000063 def CMPri: F3_2<2, 0b010100,
Chris Lattner1c4f4352005-12-16 06:52:00 +000064 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "cmp">;
Brian Gaeke8542e082004-04-02 20:53:37 +000065
66// Section B.1 - Load Integer Instructions, p. 90
Chris Lattner96b84be2005-12-16 06:25:42 +000067def LDSB: F3_2<3, 0b001001,
Chris Lattner1c4f4352005-12-16 06:52:00 +000068 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "ldsb">;
Chris Lattner96b84be2005-12-16 06:25:42 +000069def LDSH: F3_2<3, 0b001010,
Chris Lattner1c4f4352005-12-16 06:52:00 +000070 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "ldsh">;
Chris Lattner96b84be2005-12-16 06:25:42 +000071def LDUB: F3_2<3, 0b000001,
Chris Lattner1c4f4352005-12-16 06:52:00 +000072 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "ldub">;
Chris Lattner96b84be2005-12-16 06:25:42 +000073def LDUH: F3_2<3, 0b000010,
Chris Lattner1c4f4352005-12-16 06:52:00 +000074 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "lduh">;
Chris Lattner96b84be2005-12-16 06:25:42 +000075def LD : F3_2<3, 0b000000,
Chris Lattner1c4f4352005-12-16 06:52:00 +000076 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "ld">;
Chris Lattner96b84be2005-12-16 06:25:42 +000077def LDD : F3_2<3, 0b000011,
Chris Lattner1c4f4352005-12-16 06:52:00 +000078 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "ldd">;
Brian Gaeke8542e082004-04-02 20:53:37 +000079
Brian Gaeke562d5b02004-06-18 05:19:27 +000080// Section B.2 - Load Floating-point Instructions, p. 92
Chris Lattner96b84be2005-12-16 06:25:42 +000081def LDFrr : F3_1<3, 0b100000,
Chris Lattner1c4f4352005-12-16 06:52:00 +000082 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
83 "ld $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000084def LDFri : F3_2<3, 0b100000,
Chris Lattner1c4f4352005-12-16 06:52:00 +000085 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "ld">;
Chris Lattner96b84be2005-12-16 06:25:42 +000086def LDDFrr : F3_1<3, 0b100011,
Chris Lattner1c4f4352005-12-16 06:52:00 +000087 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
88 "ldd $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000089def LDDFri : F3_2<3, 0b100011,
Chris Lattner1c4f4352005-12-16 06:52:00 +000090 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "ldd">;
Chris Lattner96b84be2005-12-16 06:25:42 +000091def LDFSRrr: F3_1<3, 0b100001,
Chris Lattner1c4f4352005-12-16 06:52:00 +000092 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
93 "ld $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000094def LDFSRri: F3_2<3, 0b100001,
Chris Lattner1c4f4352005-12-16 06:52:00 +000095 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "ld">;
Brian Gaeke562d5b02004-06-18 05:19:27 +000096
Brian Gaeke8542e082004-04-02 20:53:37 +000097// Section B.4 - Store Integer Instructions, p. 95
Chris Lattner96b84be2005-12-16 06:25:42 +000098def STB : F3_2<3, 0b000101,
Chris Lattner1c4f4352005-12-16 06:52:00 +000099 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "stb">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000100def STH : F3_2<3, 0b000110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000101 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "sth">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000102def ST : F3_2<3, 0b000100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000103 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "st">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000104def STD : F3_2<3, 0b000111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000105 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "std">;
Brian Gaekee7f9e0b2004-06-24 07:36:59 +0000106
107// Section B.5 - Store Floating-point Instructions, p. 97
Chris Lattner96b84be2005-12-16 06:25:42 +0000108def STFrr : F3_1<3, 0b100100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000109 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
110 "st $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000111def STFri : F3_2<3, 0b100100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000112 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "st">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000113def STDFrr : F3_1<3, 0b100111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000114 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
115 "std $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000116def STDFri : F3_2<3, 0b100111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000117 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "std">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000118def STFSRrr : F3_1<3, 0b100101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000119 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
120 "st $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000121def STFSRri : F3_2<3, 0b100101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000122 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "st">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000123def STDFQrr : F3_1<3, 0b100110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000124 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
125 "std $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000126def STDFQri : F3_2<3, 0b100110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000127 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "std">;
Misha Brukman23e6c1f2004-02-26 00:37:12 +0000128
Brian Gaeke775158d2004-03-04 04:37:45 +0000129// Section B.9 - SETHI Instruction, p. 104
Brian Gaekee8061732004-03-04 00:56:25 +0000130def SETHIi: F2_1<0b100, "sethi">;
131
Brian Gaeke8542e082004-04-02 20:53:37 +0000132// Section B.10 - NOP Instruction, p. 105
133// (It's a special case of SETHI)
Misha Brukmand36047d2004-10-14 22:33:32 +0000134let rd = 0, imm22 = 0 in
Brian Gaeke8542e082004-04-02 20:53:37 +0000135 def NOP : F2_1<0b100, "nop">;
136
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000137// Section B.11 - Logical Instructions, p. 106
Chris Lattner96b84be2005-12-16 06:25:42 +0000138def ANDrr : F3_1<2, 0b000001,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000139 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
140 "and $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000141def ANDri : F3_2<2, 0b000001,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000142 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "and">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000143def ANDCCrr : F3_1<2, 0b010001,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000144 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
145 "andcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000146def ANDCCri : F3_2<2, 0b010001,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000147 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "andcc">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000148def ANDNrr : F3_1<2, 0b000101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000149 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
150 "andn $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000151def ANDNri : F3_2<2, 0b000101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000152 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "andn">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000153def ANDNCCrr: F3_1<2, 0b010101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000154 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
155 "andncc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000156def ANDNCCri: F3_2<2, 0b010101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000157 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "andncc">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000158def ORrr : F3_1<2, 0b000010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000159 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
160 "or $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000161def ORri : F3_2<2, 0b000010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000162 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "or">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000163def ORCCrr : F3_1<2, 0b010010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000164 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
165 "orcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000166def ORCCri : F3_2<2, 0b010010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000167 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "orcc">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000168def ORNrr : F3_1<2, 0b000110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000169 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
170 "orn $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000171def ORNri : F3_2<2, 0b000110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000172 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "orn">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000173def ORNCCrr : F3_1<2, 0b010110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000174 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
175 "orncc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000176def ORNCCri : F3_2<2, 0b010110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000177 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "orncc">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000178def XORrr : F3_1<2, 0b000011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000179 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
180 "xor $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000181def XORri : F3_2<2, 0b000011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000182 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "xor">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000183def XORCCrr : F3_1<2, 0b010011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000184 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
185 "xorcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000186def XORCCri : F3_2<2, 0b010011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000187 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "xorcc">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000188def XNORrr : F3_1<2, 0b000111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000189 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
190 "xnor $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000191def XNORri : F3_2<2, 0b000111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000192 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "xnor">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000193def XNORCCrr: F3_1<2, 0b010111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000194 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
195 "xnorcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000196def XNORCCri: F3_2<2, 0b010111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000197 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "xnorcc">;
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000198
199// Section B.12 - Shift Instructions, p. 107
Chris Lattner96b84be2005-12-16 06:25:42 +0000200def SLLrr : F3_1<2, 0b100101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000201 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
202 "sll $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000203def SLLri : F3_2<2, 0b100101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000204 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "sll">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000205def SRLrr : F3_1<2, 0b100110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000206 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
207 "srl $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000208def SRLri : F3_2<2, 0b100110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000209 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "srl">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000210def SRArr : F3_1<2, 0b100111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000211 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
212 "sra $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000213def SRAri : F3_2<2, 0b100111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000214 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "sra">;
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000215
216// Section B.13 - Add Instructions, p. 108
Chris Lattner96b84be2005-12-16 06:25:42 +0000217def ADDrr : F3_1<2, 0b000000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000218 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
219 "add $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000220def ADDri : F3_2<2, 0b000000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000221 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "add">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000222def ADDCCrr : F3_1<2, 0b010000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000223 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
224 "addcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000225def ADDCCri : F3_2<2, 0b010000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000226 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "addcc">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000227def ADDXrr : F3_1<2, 0b001000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000228 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
229 "addx $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000230def ADDXri : F3_2<2, 0b001000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000231 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "addx">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000232def ADDXCCrr: F3_1<2, 0b011000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000233 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
234 "addxcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000235def ADDXCCri: F3_2<2, 0b011000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000236 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "addxcc">;
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000237
Brian Gaeke775158d2004-03-04 04:37:45 +0000238// Section B.15 - Subtract Instructions, p. 110
Chris Lattner96b84be2005-12-16 06:25:42 +0000239def SUBrr : F3_1<2, 0b000100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000240 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
241 "sub $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000242def SUBri : F3_2<2, 0b000100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000243 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "sub">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000244def SUBCCrr : F3_1<2, 0b010100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000245 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
246 "subcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000247def SUBCCri : F3_2<2, 0b010100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000248 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "subcc">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000249def SUBXrr : F3_1<2, 0b001100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000250 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
251 "subx $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000252def SUBXri : F3_2<2, 0b001100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000253 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "subx">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000254def SUBXCCrr: F3_1<2, 0b011100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000255 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
256 "subxcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000257def SUBXCCri: F3_2<2, 0b011100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000258 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "subxcc">;
Brian Gaeke775158d2004-03-04 04:37:45 +0000259
Brian Gaeke032f80f2004-03-16 22:37:13 +0000260// Section B.18 - Multiply Instructions, p. 113
Chris Lattner96b84be2005-12-16 06:25:42 +0000261def UMULrr : F3_1<2, 0b001010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000262 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
263 "umul $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000264def UMULri : F3_2<2, 0b001010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000265 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "umul">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000266def SMULrr : F3_1<2, 0b001011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000267 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
268 "smul $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000269def SMULri : F3_2<2, 0b001011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000270 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "smul">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000271def UMULCCrr: F3_1<2, 0b011010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000272 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
273 "umulcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000274def UMULCCri: F3_2<2, 0b011010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000275 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "umulcc">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000276def SMULCCrr: F3_1<2, 0b011011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000277 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
278 "smulcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000279def SMULCCri: F3_2<2, 0b011011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000280 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "smulcc">;
Brian Gaeke032f80f2004-03-16 22:37:13 +0000281
Brian Gaekee88c9dc2004-04-07 04:01:00 +0000282// Section B.19 - Divide Instructions, p. 115
Chris Lattner96b84be2005-12-16 06:25:42 +0000283def UDIVrr : F3_1<2, 0b001110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000284 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
285 "udiv $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000286def UDIVri : F3_2<2, 0b001110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000287 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "udiv">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000288def SDIVrr : F3_1<2, 0b001111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000289 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
290 "sdiv $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000291def SDIVri : F3_2<2, 0b001111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000292 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "sdiv">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000293def UDIVCCrr : F3_1<2, 0b011110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000294 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
295 "udivcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000296def UDIVCCri : F3_2<2, 0b011110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000297 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "udivcc">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000298def SDIVCCrr : F3_1<2, 0b011111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000299 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
300 "sdivcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000301def SDIVCCri : F3_2<2, 0b011111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000302 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "sdivcc">;
Brian Gaekee88c9dc2004-04-07 04:01:00 +0000303
Brian Gaekea8056fa2004-03-06 05:32:13 +0000304// Section B.20 - SAVE and RESTORE, p. 117
Chris Lattner96b84be2005-12-16 06:25:42 +0000305def SAVErr : F3_1<2, 0b111100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000306 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
307 "save $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000308def SAVEri : F3_2<2, 0b111100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000309 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "save">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000310def RESTORErr : F3_1<2, 0b111101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000311 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
312 "restore $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000313def RESTOREri : F3_2<2, 0b111101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000314 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "restore">;
Brian Gaekea8056fa2004-03-06 05:32:13 +0000315
Brian Gaekec3e97012004-05-08 04:21:32 +0000316// Section B.21 - Branch on Integer Condition Codes Instructions, p. 119
Brian Gaeke070bb4a2004-06-17 22:34:29 +0000317
318// conditional branch class:
319class BranchV8<bits<4> cc, string nm> : F2_2<cc, 0b010, nm> {
320 let isBranch = 1;
321 let isTerminator = 1;
Brian Gaeked7bf5012004-09-30 04:04:48 +0000322 let hasDelaySlot = 1;
Brian Gaeke070bb4a2004-06-17 22:34:29 +0000323}
Chris Lattner0f6eab32004-07-31 02:24:37 +0000324
325let isBarrier = 1 in
326 def BA : BranchV8<0b1000, "ba">;
Brian Gaeke070bb4a2004-06-17 22:34:29 +0000327def BN : BranchV8<0b0000, "bn">;
328def BNE : BranchV8<0b1001, "bne">;
329def BE : BranchV8<0b0001, "be">;
330def BG : BranchV8<0b1010, "bg">;
331def BLE : BranchV8<0b0010, "ble">;
332def BGE : BranchV8<0b1011, "bge">;
333def BL : BranchV8<0b0011, "bl">;
334def BGU : BranchV8<0b1100, "bgu">;
335def BLEU : BranchV8<0b0100, "bleu">;
336def BCC : BranchV8<0b1101, "bcc">;
337def BCS : BranchV8<0b0101, "bcs">;
Brian Gaekec3e97012004-05-08 04:21:32 +0000338
Brian Gaeke4185d032004-07-08 09:08:22 +0000339// Section B.22 - Branch on Floating-point Condition Codes Instructions, p. 121
340
341// floating-point conditional branch class:
342class FPBranchV8<bits<4> cc, string nm> : F2_2<cc, 0b110, nm> {
343 let isBranch = 1;
344 let isTerminator = 1;
Brian Gaeked7bf5012004-09-30 04:04:48 +0000345 let hasDelaySlot = 1;
Brian Gaeke4185d032004-07-08 09:08:22 +0000346}
347
348def FBA : FPBranchV8<0b1000, "fba">;
349def FBN : FPBranchV8<0b0000, "fbn">;
350def FBU : FPBranchV8<0b0111, "fbu">;
351def FBG : FPBranchV8<0b0110, "fbg">;
352def FBUG : FPBranchV8<0b0101, "fbug">;
353def FBL : FPBranchV8<0b0100, "fbl">;
354def FBUL : FPBranchV8<0b0011, "fbul">;
355def FBLG : FPBranchV8<0b0010, "fblg">;
356def FBNE : FPBranchV8<0b0001, "fbne">;
357def FBE : FPBranchV8<0b1001, "fbe">;
358def FBUE : FPBranchV8<0b1010, "fbue">;
359def FBGE : FPBranchV8<0b1011, "fbge">;
360def FBUGE: FPBranchV8<0b1100, "fbuge">;
361def FBLE : FPBranchV8<0b1101, "fble">;
362def FBULE: FPBranchV8<0b1110, "fbule">;
363def FBO : FPBranchV8<0b1111, "fbo">;
364
Brian Gaekeb354b712004-11-16 07:32:09 +0000365
366
Brian Gaeke8542e082004-04-02 20:53:37 +0000367// Section B.24 - Call and Link Instruction, p. 125
Brian Gaekea8056fa2004-03-06 05:32:13 +0000368// This is the only Format 1 instruction
Brian Gaekeb354b712004-11-16 07:32:09 +0000369let Uses = [O0, O1, O2, O3, O4, O5], hasDelaySlot = 1, isCall = 1 in {
Brian Gaeked7bf5012004-09-30 04:04:48 +0000370 // pc-relative call:
Brian Gaekeb354b712004-11-16 07:32:09 +0000371 let Defs = [O0, O1, O2, O3, O4, O5, O7, G1, G2, G3, G4, G5, G6, G7,
372 D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15] in
Brian Gaeke374b36d2004-09-29 20:45:05 +0000373 def CALL : InstV8 {
374 bits<30> disp;
375 let op = 1;
376 let Inst{29-0} = disp;
377 let Name = "call";
378 }
Brian Gaekeb354b712004-11-16 07:32:09 +0000379
380 // indirect call (O7 is an EXPLICIT def in indirect calls, so it cannot also
381 // be an implicit def):
382 let Defs = [O0, O1, O2, O3, O4, O5, G1, G2, G3, G4, G5, G6, G7,
383 D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15] in
Chris Lattner1c4f4352005-12-16 06:52:00 +0000384 def JMPLrr : F3_1<2, 0b111000,
385 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
386 "jmpl $b+$c, $dst">;
Brian Gaeke374b36d2004-09-29 20:45:05 +0000387}
Misha Brukman23e6c1f2004-02-26 00:37:12 +0000388
Chris Lattner22ede702004-04-07 04:06:46 +0000389// Section B.29 - Write State Register Instructions
Chris Lattner96b84be2005-12-16 06:25:42 +0000390def WRrr : F3_1<2, 0b110000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000391 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
392 "wr $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000393def WRri : F3_2<2, 0b110000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000394 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c), "wr">; // wr rs1, imm, rd
Chris Lattner61790472004-04-07 05:04:01 +0000395
Brian Gaekec53105c2004-06-27 22:53:56 +0000396// Convert Integer to Floating-point Instructions, p. 141
397def FITOS : F3_3<2, 0b110100, 0b011000100, "fitos">;
Brian Gaeke22ad67d2004-09-29 19:59:07 +0000398def FITOD : F3_3<2, 0b110100, 0b011001000, "fitod">;
Brian Gaekec53105c2004-06-27 22:53:56 +0000399
Brian Gaeke59e12ed2004-10-14 19:39:35 +0000400// Convert Floating-point to Integer Instructions, p. 142
401def FSTOI : F3_3<2, 0b110100, 0b011010001, "fstoi">;
402def FDTOI : F3_3<2, 0b110100, 0b011010010, "fdtoi">;
403
Brian Gaeke57ff2e32004-06-24 21:22:09 +0000404// Convert between Floating-point Formats Instructions, p. 143
405def FSTOD : F3_3<2, 0b110100, 0b011001001, "fstod">;
406def FDTOS : F3_3<2, 0b110100, 0b011000110, "fdtos">;
407
Brian Gaekef89cc652004-06-18 06:28:10 +0000408// Floating-point Move Instructions, p. 144
409def FMOVS : F3_3<2, 0b110100, 0b000000001, "fmovs">;
410def FNEGS : F3_3<2, 0b110100, 0b000000101, "fnegs">;
411def FABSS : F3_3<2, 0b110100, 0b000001001, "fabss">;
412
Brian Gaekec53105c2004-06-27 22:53:56 +0000413// Floating-point Add and Subtract Instructions, p. 146
414def FADDS : F3_3<2, 0b110100, 0b001000001, "fadds">;
415def FADDD : F3_3<2, 0b110100, 0b001000010, "faddd">;
416def FSUBS : F3_3<2, 0b110100, 0b001000101, "fsubs">;
417def FSUBD : F3_3<2, 0b110100, 0b001000110, "fsubd">;
418
419// Floating-point Multiply and Divide Instructions, p. 147
420def FMULS : F3_3<2, 0b110100, 0b001001001, "fmuls">;
421def FMULD : F3_3<2, 0b110100, 0b001001010, "fmuld">;
422def FSMULD : F3_3<2, 0b110100, 0b001101001, "fsmuld">;
423def FDIVS : F3_3<2, 0b110100, 0b001001101, "fdivs">;
424def FDIVD : F3_3<2, 0b110100, 0b001001110, "fdivd">;
Brian Gaeke57ff2e32004-06-24 21:22:09 +0000425
Brian Gaeke4185d032004-07-08 09:08:22 +0000426// Floating-point Compare Instructions, p. 148
Brian Gaeked7bf5012004-09-30 04:04:48 +0000427// Note: the 2nd template arg is different for these guys.
428// Note 2: the result of a FCMP is not available until the 2nd cycle
429// after the instr is retired, but there is no interlock. This behavior
430// is modelled as a delay slot.
431let hasDelaySlot = 1 in {
432 def FCMPS : F3_3<2, 0b110101, 0b001010001, "fcmps">;
433 def FCMPD : F3_3<2, 0b110101, 0b001010010, "fcmpd">;
434 def FCMPES : F3_3<2, 0b110101, 0b001010101, "fcmpes">;
435 def FCMPED : F3_3<2, 0b110101, 0b001010110, "fcmped">;
436}
Brian Gaeke4185d032004-07-08 09:08:22 +0000437