ee397c830c1418a29a6533ba099d91efb31b40e5
[oota-llvm.git] / lib / Target / SparcV8 / SparcV8InstrInfo.td
1 //===- SparcV8Instrs.td - Target Description for SparcV8 Target -----------===//
2 // 
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 //
10 // This file describes the SparcV8 instructions in TableGen format.
11 //
12 //===----------------------------------------------------------------------===//
13
14 //===----------------------------------------------------------------------===//
15 // Instruction format superclass
16 //===----------------------------------------------------------------------===//
17
18 class 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?
29 }
30
31 include "SparcV8InstrInfo_F2.td"
32 include "SparcV8InstrInfo_F3.td"
33
34 //===----------------------------------------------------------------------===//
35 // Instructions
36 //===----------------------------------------------------------------------===//
37
38 // Pseudo instructions.
39 def PHI : InstV8 {
40   let Name = "PHI";
41 }
42 def ADJCALLSTACKDOWN : InstV8 {
43   let Name = "ADJCALLSTACKDOWN";
44 }
45 def ADJCALLSTACKUP : InstV8 {
46   let Name = "ADJCALLSTACKUP";
47 }
48
49 // Section A.3 - Synthetic Instructions, p. 85
50 let isReturn = 1, isTerminator = 1, simm13 = 8 in
51   def RET : F3_2<2, 0b111000, "ret">;
52 let isReturn = 1, isTerminator = 1, simm13 = 8 in
53   def RETL: F3_2<2, 0b111000, "retl">;
54
55 // Section B.1 - Load Integer Instructions, p. 90
56 def LDSBmr: F3_2<3, 0b001001, "ldsb">;
57 def LDSHmr: F3_2<3, 0b001010, "ldsh">;
58 def LDUBmr: F3_2<3, 0b000001, "ldub">;
59 def LDUHmr: F3_2<3, 0b000010, "lduh">;
60 def LDmr  : F3_2<3, 0b000000, "ld">;
61 def LDDmr : F3_2<3, 0b000011, "ldd">;
62
63 // Section B.4 - Store Integer Instructions, p. 95
64 def STBrm : F3_2<3, 0b000101, "stb">;
65 def STHrm : F3_2<3, 0b000110, "sth">;
66 def STrm  : F3_2<3, 0b000100, "st">;
67 def STDrm : F3_2<3, 0b000111, "std">;
68
69 // Section B.9 - SETHI Instruction, p. 104
70 def SETHIi: F2_1<0b100, "sethi">;
71
72 // Section B.10 - NOP Instruction, p. 105
73 // (It's a special case of SETHI)
74 let rd = 0, imm = 0 in
75   def NOP : F2_1<0b100, "nop">;
76
77 // Section B.11 - Logical Instructions, p. 106
78 def ANDrr : F3_1<2, 0b000001, "and">;
79 def ANDri : F3_2<2, 0b000001, "and">;
80 def ORrr  : F3_1<2, 0b000010, "or">;
81 def ORri  : F3_2<2, 0b000010, "or">;
82 def XORrr : F3_1<2, 0b000011, "xor">;
83 def XORri : F3_2<2, 0b000011, "xor">;
84
85 // Section B.12 - Shift Instructions, p. 107
86 def SLLrr : F3_1<2, 0b100101, "sll">;
87 def SLLri : F3_2<2, 0b100101, "sll">;
88 def SRLrr : F3_1<2, 0b100110, "srl">;
89 def SRLri : F3_2<2, 0b100110, "srl">;
90 def SRArr : F3_1<2, 0b100111, "sra">;
91 def SRAri : F3_2<2, 0b100111, "sra">;
92
93 // Section B.13 - Add Instructions, p. 108
94 def ADDrr : F3_1<2, 0b000000, "add">;
95
96 // Section B.15 - Subtract Instructions, p. 110
97 def SUBrr   : F3_1<2, 0b000100, "sub">;
98 def SUBCCrr : F3_1<2, 0b010100, "subcc">;
99
100 // Section B.18 - Multiply Instructions, p. 113
101 def UMULrr : F3_1<2, 0b001010, "umul">;
102 def SMULrr : F3_1<2, 0b001011, "smul">;
103
104 // Section B.19 - Divide Instructions, p. 115
105 def UDIVrr   : F3_1<2, 0b001110, "udiv">;
106 def UDIVri   : F3_2<2, 0b001110, "udiv">;
107 def SDIVrr   : F3_1<2, 0b001111, "sdiv">;
108 def SDIVri   : F3_2<2, 0b001111, "sdiv">;
109 def UDIVCCrr : F3_1<2, 0b011110, "udivcc">;
110 def UDIVCCri : F3_2<2, 0b011110, "udivcc">;
111 def SDIVCCrr : F3_1<2, 0b011111, "sdivcc">;
112 def SDIVCCri : F3_2<2, 0b011111, "sdivcc">;
113
114 // Section B.20 - SAVE and RESTORE, p. 117
115 def SAVErr    : F3_1<2, 0b111100, "save">;           // save    r, r, r
116 def SAVEri    : F3_2<2, 0b111100, "save">;           // save    r, i, r
117 def RESTORErr : F3_1<2, 0b111101, "restore">;        // restore r, r, r
118 def RESTOREri : F3_2<2, 0b111101, "restore">;        // restore r, i, r
119
120 // Section B.24 - Call and Link Instruction, p. 125
121 // This is the only Format 1 instruction
122 def CALL : InstV8 {
123   bits<30> disp;
124   let op = 1;
125   let Inst{29-0} = disp;
126   let Name = "call";
127   let isCall = 1;
128 }
129
130 // Section B.25 - Jump and Link, p. 126
131 def JMPLrr : F3_1<2, 0b111000, "jmpl">;              // jmpl [rs1+rs2], rd
132 def JMPLri : F3_2<2, 0b111000, "jmpl">;              // jmpl [rs1+imm], rd
133
134 // Section B.29 - Write State Register Instructions
135 def WRrr : F3_1<2, 0b110000, "wr">;                    // wr rs1, rs2, rd
136 def WRri : F3_2<2, 0b110000, "wr">;                    // wr rs1, imm, rd
137