1 //===- SystemZInstrInfo.td - SystemZ Instruction defs ---------*- tblgen-*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the SystemZ instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 include "SystemZInstrFormats.td"
16 //===----------------------------------------------------------------------===//
17 // SystemZ Specific Node Definitions.
18 //===----------------------------------------------------------------------===//
19 def SystemZretflag : SDNode<"SystemZISD::RET_FLAG", SDTNone,
20 [SDNPHasChain, SDNPOptInFlag]>;
22 let neverHasSideEffects = 1 in
23 def NOP : Pseudo<(outs), (ins), "# no-op", []>;
25 //===----------------------------------------------------------------------===//
26 // Instruction Pattern Stuff.
27 //===----------------------------------------------------------------------===//
28 def LL16 : SDNodeXForm<imm, [{
29 // Transformation function: return low 16 bits.
30 return getI16Imm(N->getZExtValue() & 0x000000000000FFFFULL);
33 def LH16 : SDNodeXForm<imm, [{
34 // Transformation function: return bits 16-31.
35 return getI16Imm((N->getZExtValue() & 0x00000000FFFF0000ULL) >> 16);
38 def HL16 : SDNodeXForm<imm, [{
39 // Transformation function: return bits 32-47.
40 return getI16Imm((N->getZExtValue() & 0x0000FFFF00000000ULL) >> 32);
43 def HH16 : SDNodeXForm<imm, [{
44 // Transformation function: return bits 48-63.
45 return getI16Imm((N->getZExtValue() & 0xFFFF000000000000ULL) >> 48);
48 def i64ll16 : PatLeaf<(i64 imm), [{
49 // i64ll16 predicate - true if the 64-bit immediate has only rightmost 16
51 return ((N->getZExtValue() & 0x000000000000FFFFULL) == N->getZExtValue());
54 def i64lh16 : PatLeaf<(i64 imm), [{
55 // i64lh16 predicate - true if the 64-bit immediate has only bits 16-31 set.
56 return ((N->getZExtValue() & 0x00000000FFFF0000ULL) == N->getZExtValue());
59 def i64hl16 : PatLeaf<(i64 imm), [{
60 // i64hl16 predicate - true if the 64-bit immediate has only bits 32-47 set.
61 return ((N->getZExtValue() & 0x0000FFFF00000000ULL) == N->getZExtValue());
64 def i64hh16 : PatLeaf<(i64 imm), [{
65 // i64hh16 predicate - true if the 64-bit immediate has only bits 48-63 set.
66 return ((N->getZExtValue() & 0xFFFF000000000000ULL) == N->getZExtValue());
69 def immSExt16 : PatLeaf<(i64 imm), [{
70 // immSExt16 predicate - true if the immediate fits in a 16-bit sign extended
72 uint64_t val = N->getZExtValue();
73 return ((int64_t)val == (int16_t)val);
76 //===----------------------------------------------------------------------===//
77 // Control Flow Instructions...
80 // FIXME: Provide proper encoding!
81 let isReturn = 1, isTerminator = 1 in {
82 def RET : Pseudo<(outs), (ins), "br\t%r14", [(SystemZretflag)]>;
85 //===----------------------------------------------------------------------===//
88 // FIXME: Provide proper encoding!
89 let neverHasSideEffects = 1 in {
90 def MOV64rr : Pseudo<(outs GR64:$dst), (ins GR64:$src),
95 // FIXME: Provide proper encoding!
96 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
97 def MOV64ri16 : Pseudo<(outs GR64:$dst), (ins i64imm:$src),
99 [(set GR64:$dst, immSExt16:$src)]>;
102 //===----------------------------------------------------------------------===//
103 // Arithmetic Instructions
105 let isTwoAddress = 1 in {
107 let Defs = [PSW] in {
109 let isCommutable = 1 in { // X = ADD Y, Z == X = ADD Z, Y
110 // FIXME: Provide proper encoding!
111 def ADD64rr : Pseudo<(outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
112 "agr\t{$dst, $src2}",
113 [(set GR64:$dst, (add GR64:$src1, GR64:$src2)),
117 // FIXME: Provide proper encoding!
118 def ADD64ri16 : Pseudo<(outs GR64:$dst), (ins GR64:$src1, i64imm:$src2),
119 "aghi\t{$dst, $src2}",
120 [(set GR64:$dst, (add GR64:$src1, immSExt16:$src2)),
123 let isCommutable = 1 in { // X = AND Y, Z == X = AND Z, Y
124 // FIXME: Provide proper encoding!
125 def AND64rr : Pseudo<(outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
126 "ngr\t{$dst, $src2}",
127 [(set GR64:$dst, (and GR64:$src1, GR64:$src2))]>;
130 // FIXME: Provide proper encoding!
131 def AND64rill16 : Pseudo<(outs GR64:$dst), (ins GR64:$src1, i64imm:$src2),
132 "nill\t{$dst, $src2}",
133 [(set GR64:$dst, (and GR64:$src1, i64ll16:$src2))]>;
134 def AND64rilh16 : Pseudo<(outs GR64:$dst), (ins GR64:$src1, i64imm:$src2),
135 "nilh\t{$dst, $src2}",
136 [(set GR64:$dst, (and GR64:$src1, i64lh16:$src2))]>;
137 def AND64rihl16 : Pseudo<(outs GR64:$dst), (ins GR64:$src1, i64imm:$src2),
138 "nihl\t{$dst, $src2}",
139 [(set GR64:$dst, (and GR64:$src1, i64hl16:$src2))]>;
140 def AND64rihh16 : Pseudo<(outs GR64:$dst), (ins GR64:$src1, i64imm:$src2),
141 "nihh\t{$dst, $src2}",
142 [(set GR64:$dst, (and GR64:$src1, i64hh16:$src2))]>;
144 let isCommutable = 1 in { // X = OR Y, Z == X = OR Z, Y
145 // FIXME: Provide proper encoding!
146 def OR64rr : Pseudo<(outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
147 "ogr\t{$dst, $src2}",
148 [(set GR64:$dst, (or GR64:$src1, GR64:$src2))]>;
150 def OR64rill16 : Pseudo<(outs GR64:$dst), (ins GR64:$src1, i64imm:$src2),
151 "oill\t{$dst, $src2}",
152 [(set GR64:$dst, (or GR64:$src1, i64ll16:$src2))]>;
153 def OR64rilh16 : Pseudo<(outs GR64:$dst), (ins GR64:$src1, i64imm:$src2),
154 "oilh\t{$dst, $src2}",
155 [(set GR64:$dst, (or GR64:$src1, i64lh16:$src2))]>;
156 def OR64rihl16 : Pseudo<(outs GR64:$dst), (ins GR64:$src1, i64imm:$src2),
157 "oihl\t{$dst, $src2}",
158 [(set GR64:$dst, (or GR64:$src1, i64hl16:$src2))]>;
159 def OR64rihh16 : Pseudo<(outs GR64:$dst), (ins GR64:$src1, i64imm:$src2),
160 "oihh\t{$dst, $src2}",
161 [(set GR64:$dst, (or GR64:$src1, i64hh16:$src2))]>;
163 // FIXME: Provide proper encoding!
164 def SUB64rr : Pseudo<(outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
165 "sgr\t{$dst, $src2}",
166 [(set GR64:$dst, (sub GR64:$src1, GR64:$src2))]>;
169 let isCommutable = 1 in { // X = XOR Y, Z == X = XOR Z, Y
170 // FIXME: Provide proper encoding!
171 def XOR64rr : Pseudo<(outs GR64:$dst), (ins GR64:$src1, GR64:$src2),
172 "xgr\t{$dst, $src2}",
173 [(set GR64:$dst, (xor GR64:$src1, GR64:$src2))]>;
177 } // isTwoAddress = 1