blob: 24b741c77a81433fc3ae93c4da3fde798eb8aeb5 [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
Chris Lattnera85d46e2004-02-28 19:45:39 +000031include "SparcV8InstrInfo_F2.td"
32include "SparcV8InstrInfo_F3.td"
Brian Gaekee785e532004-02-25 19:28:19 +000033
Misha Brukman23e6c1f2004-02-26 00:37:12 +000034//===----------------------------------------------------------------------===//
35// Instructions
36//===----------------------------------------------------------------------===//
37
Chris Lattner275f6452004-02-28 19:37:18 +000038// Pseudo instructions.
39def PHI : InstV8 {
40 let Name = "PHI";
41}
42def ADJCALLSTACKDOWN : InstV8 {
43 let Name = "ADJCALLSTACKDOWN";
44}
45def ADJCALLSTACKUP : InstV8 {
46 let Name = "ADJCALLSTACKUP";
47}
48
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:
Brian Gaekea8056fa2004-03-06 05:32:13 +000051let isReturn = 1, isTerminator = 1, simm13 = 8 in
52 def RET : F3_2<2, 0b111000, "ret">;
53let isReturn = 1, isTerminator = 1, simm13 = 8 in
Brian Gaeke8542e082004-04-02 20:53:37 +000054 def RETL: F3_2<2, 0b111000, "retl">;
Brian Gaekec3e97012004-05-08 04:21:32 +000055// CMP is a special case of SUBCC where destination is ignored, by setting it to
56// %g0 (hardwired zero).
57// FIXME: should keep track of the fact that it defs the integer condition codes
58let rd = 0 in
59 def CMPri: F3_2<2, 0b010100, "cmp">;
Brian Gaeke8542e082004-04-02 20:53:37 +000060
61// Section B.1 - Load Integer Instructions, p. 90
62def LDSBmr: F3_2<3, 0b001001, "ldsb">;
63def LDSHmr: F3_2<3, 0b001010, "ldsh">;
64def LDUBmr: F3_2<3, 0b000001, "ldub">;
65def LDUHmr: F3_2<3, 0b000010, "lduh">;
66def LDmr : F3_2<3, 0b000000, "ld">;
67def LDDmr : F3_2<3, 0b000011, "ldd">;
68
Brian Gaeke562d5b02004-06-18 05:19:27 +000069// Section B.2 - Load Floating-point Instructions, p. 92
70def LDFmr : F3_2<3, 0b100000, "ld">;
71def LDDFmr : F3_2<3, 0b100011, "ldd">;
72def LDFSRmr: F3_2<3, 0b100001, "ld">;
73
Brian Gaeke8542e082004-04-02 20:53:37 +000074// Section B.4 - Store Integer Instructions, p. 95
75def STBrm : F3_2<3, 0b000101, "stb">;
76def STHrm : F3_2<3, 0b000110, "sth">;
77def STrm : F3_2<3, 0b000100, "st">;
78def STDrm : F3_2<3, 0b000111, "std">;
Misha Brukman23e6c1f2004-02-26 00:37:12 +000079
Brian Gaeke775158d2004-03-04 04:37:45 +000080// Section B.9 - SETHI Instruction, p. 104
Brian Gaekee8061732004-03-04 00:56:25 +000081def SETHIi: F2_1<0b100, "sethi">;
82
Brian Gaeke8542e082004-04-02 20:53:37 +000083// Section B.10 - NOP Instruction, p. 105
84// (It's a special case of SETHI)
85let rd = 0, imm = 0 in
86 def NOP : F2_1<0b100, "nop">;
87
Brian Gaekebc1d27a2004-03-03 23:03:14 +000088// Section B.11 - Logical Instructions, p. 106
Chris Lattner22ede702004-04-07 04:06:46 +000089def ANDrr : F3_1<2, 0b000001, "and">;
Brian Gaekebc1d27a2004-03-03 23:03:14 +000090def ANDri : F3_2<2, 0b000001, "and">;
91def ORrr : F3_1<2, 0b000010, "or">;
Brian Gaekee8061732004-03-04 00:56:25 +000092def ORri : F3_2<2, 0b000010, "or">;
Chris Lattner22ede702004-04-07 04:06:46 +000093def XORrr : F3_1<2, 0b000011, "xor">;
94def XORri : F3_2<2, 0b000011, "xor">;
Brian Gaekebc1d27a2004-03-03 23:03:14 +000095
96// Section B.12 - Shift Instructions, p. 107
Chris Lattnera562efc2004-04-07 04:26:57 +000097def SLLrr : F3_1<2, 0b100101, "sll">;
98def SLLri : F3_2<2, 0b100101, "sll">;
99def SRLrr : F3_1<2, 0b100110, "srl">;
100def SRLri : F3_2<2, 0b100110, "srl">;
101def SRArr : F3_1<2, 0b100111, "sra">;
102def SRAri : F3_2<2, 0b100111, "sra">;
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000103
104// Section B.13 - Add Instructions, p. 108
105def ADDrr : F3_1<2, 0b000000, "add">;
Brian Gaeke6b1d2fa2004-05-08 05:26:55 +0000106def ADDri : F3_2<2, 0b000000, "add">;
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000107
Brian Gaeke775158d2004-03-04 04:37:45 +0000108// Section B.15 - Subtract Instructions, p. 110
Chris Lattner61790472004-04-07 05:04:01 +0000109def SUBrr : F3_1<2, 0b000100, "sub">;
110def SUBCCrr : F3_1<2, 0b010100, "subcc">;
Brian Gaekec3e97012004-05-08 04:21:32 +0000111def SUBCCri : F3_2<2, 0b010100, "subcc">;
Brian Gaeke775158d2004-03-04 04:37:45 +0000112
Brian Gaeke032f80f2004-03-16 22:37:13 +0000113// Section B.18 - Multiply Instructions, p. 113
114def UMULrr : F3_1<2, 0b001010, "umul">;
115def SMULrr : F3_1<2, 0b001011, "smul">;
116
Brian Gaekee88c9dc2004-04-07 04:01:00 +0000117// Section B.19 - Divide Instructions, p. 115
Chris Lattner22ede702004-04-07 04:06:46 +0000118def UDIVrr : F3_1<2, 0b001110, "udiv">;
119def UDIVri : F3_2<2, 0b001110, "udiv">;
120def SDIVrr : F3_1<2, 0b001111, "sdiv">;
121def SDIVri : F3_2<2, 0b001111, "sdiv">;
122def UDIVCCrr : F3_1<2, 0b011110, "udivcc">;
123def UDIVCCri : F3_2<2, 0b011110, "udivcc">;
124def SDIVCCrr : F3_1<2, 0b011111, "sdivcc">;
125def SDIVCCri : F3_2<2, 0b011111, "sdivcc">;
Brian Gaekee88c9dc2004-04-07 04:01:00 +0000126
Brian Gaekea8056fa2004-03-06 05:32:13 +0000127// Section B.20 - SAVE and RESTORE, p. 117
128def SAVErr : F3_1<2, 0b111100, "save">; // save r, r, r
129def SAVEri : F3_2<2, 0b111100, "save">; // save r, i, r
130def RESTORErr : F3_1<2, 0b111101, "restore">; // restore r, r, r
131def RESTOREri : F3_2<2, 0b111101, "restore">; // restore r, i, r
132
Brian Gaekec3e97012004-05-08 04:21:32 +0000133// Section B.21 - Branch on Integer Condition Codes Instructions, p. 119
Brian Gaeke070bb4a2004-06-17 22:34:29 +0000134
135// conditional branch class:
136class BranchV8<bits<4> cc, string nm> : F2_2<cc, 0b010, nm> {
137 let isBranch = 1;
138 let isTerminator = 1;
139}
140def BA : BranchV8<0b1000, "ba">;
141def BN : BranchV8<0b0000, "bn">;
142def BNE : BranchV8<0b1001, "bne">;
143def BE : BranchV8<0b0001, "be">;
144def BG : BranchV8<0b1010, "bg">;
145def BLE : BranchV8<0b0010, "ble">;
146def BGE : BranchV8<0b1011, "bge">;
147def BL : BranchV8<0b0011, "bl">;
148def BGU : BranchV8<0b1100, "bgu">;
149def BLEU : BranchV8<0b0100, "bleu">;
150def BCC : BranchV8<0b1101, "bcc">;
151def BCS : BranchV8<0b0101, "bcs">;
Brian Gaekec3e97012004-05-08 04:21:32 +0000152
Brian Gaeke8542e082004-04-02 20:53:37 +0000153// Section B.24 - Call and Link Instruction, p. 125
Brian Gaekea8056fa2004-03-06 05:32:13 +0000154// This is the only Format 1 instruction
155def CALL : InstV8 {
156 bits<30> disp;
157 let op = 1;
158 let Inst{29-0} = disp;
159 let Name = "call";
160 let isCall = 1;
161}
162
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000163// Section B.25 - Jump and Link, p. 126
Brian Gaekef89cc652004-06-18 06:28:10 +0000164let isCall = 1 in
165 def JMPLrr : F3_1<2, 0b111000, "jmpl">; // jmpl [rs1+rs2], rd
Misha Brukman23e6c1f2004-02-26 00:37:12 +0000166
Chris Lattner22ede702004-04-07 04:06:46 +0000167// Section B.29 - Write State Register Instructions
168def WRrr : F3_1<2, 0b110000, "wr">; // wr rs1, rs2, rd
169def WRri : F3_2<2, 0b110000, "wr">; // wr rs1, imm, rd
Chris Lattner61790472004-04-07 05:04:01 +0000170
Brian Gaekef89cc652004-06-18 06:28:10 +0000171// Floating-point Move Instructions, p. 144
172def FMOVS : F3_3<2, 0b110100, 0b000000001, "fmovs">;
173def FNEGS : F3_3<2, 0b110100, 0b000000101, "fnegs">;
174def FABSS : F3_3<2, 0b110100, 0b000001001, "fabss">;
175