xref: /freebsd/contrib/llvm-project/clang/lib/AST/Interp/Opcodes.td (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
1a7dea167SDimitry Andric//===--- Opcodes.td - Opcode defitions for the constexpr VM -----*- C++ -*-===//
2a7dea167SDimitry Andric//
3a7dea167SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4a7dea167SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
5a7dea167SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6a7dea167SDimitry Andric//
7a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
8a7dea167SDimitry Andric//
9a7dea167SDimitry Andric// Helper file used to generate opcodes, the interpreter and the disassembler.
10a7dea167SDimitry Andric//
11a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
12a7dea167SDimitry Andric
13a7dea167SDimitry Andric
14a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
15a7dea167SDimitry Andric// Types evaluated by the interpreter.
16a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
17a7dea167SDimitry Andric
18a7dea167SDimitry Andricclass Type;
19a7dea167SDimitry Andricdef Bool : Type;
20a7dea167SDimitry Andricdef Sint8 : Type;
21a7dea167SDimitry Andricdef Uint8 : Type;
22a7dea167SDimitry Andricdef Sint16 : Type;
23a7dea167SDimitry Andricdef Uint16 : Type;
24a7dea167SDimitry Andricdef Sint32 : Type;
25a7dea167SDimitry Andricdef Uint32 : Type;
26a7dea167SDimitry Andricdef Sint64 : Type;
27a7dea167SDimitry Andricdef Uint64 : Type;
28a7dea167SDimitry Andricdef Ptr : Type;
29a7dea167SDimitry Andric
30a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
31a7dea167SDimitry Andric// Types transferred to the interpreter.
32a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
33a7dea167SDimitry Andric
34a7dea167SDimitry Andricclass ArgType { string Name = ?; }
35a7dea167SDimitry Andricdef ArgSint8 : ArgType { let Name = "int8_t"; }
36a7dea167SDimitry Andricdef ArgUint8 : ArgType { let Name = "uint8_t"; }
37a7dea167SDimitry Andricdef ArgSint16 : ArgType { let Name = "int16_t"; }
38a7dea167SDimitry Andricdef ArgUint16 : ArgType { let Name = "uint16_t"; }
39a7dea167SDimitry Andricdef ArgSint32 : ArgType { let Name = "int32_t"; }
40a7dea167SDimitry Andricdef ArgUint32 : ArgType { let Name = "uint32_t"; }
41a7dea167SDimitry Andricdef ArgSint64 : ArgType { let Name = "int64_t"; }
42a7dea167SDimitry Andricdef ArgUint64 : ArgType { let Name = "uint64_t"; }
43a7dea167SDimitry Andricdef ArgBool : ArgType { let Name = "bool"; }
44a7dea167SDimitry Andric
45a7dea167SDimitry Andricdef ArgFunction : ArgType { let Name = "Function *"; }
46a7dea167SDimitry Andricdef ArgRecord : ArgType { let Name = "Record *"; }
47a7dea167SDimitry Andric
48a7dea167SDimitry Andricdef ArgSema : ArgType { let Name = "const fltSemantics *"; }
49a7dea167SDimitry Andric
50a7dea167SDimitry Andricdef ArgExpr : ArgType { let Name = "const Expr *"; }
51a7dea167SDimitry Andricdef ArgFloatingLiteral : ArgType { let Name = "const FloatingLiteral *"; }
52a7dea167SDimitry Andricdef ArgCXXMethodDecl : ArgType { let Name = "const CXXMethodDecl *"; }
53a7dea167SDimitry Andricdef ArgFunctionDecl : ArgType { let Name = "const FunctionDecl *"; }
54a7dea167SDimitry Andricdef ArgRecordDecl : ArgType { let Name = "const RecordDecl *"; }
55a7dea167SDimitry Andricdef ArgCXXRecordDecl : ArgType { let Name = "const CXXRecordDecl *"; }
56a7dea167SDimitry Andricdef ArgValueDecl : ArgType { let Name = "const ValueDecl *"; }
57a7dea167SDimitry Andricdef ArgRecordField : ArgType { let Name = "const Record::Field *"; }
58a7dea167SDimitry Andric
59a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
60*349cc55cSDimitry Andric// Classes of types instructions operate on.
61a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
62a7dea167SDimitry Andric
63a7dea167SDimitry Andricclass TypeClass {
64a7dea167SDimitry Andric  list<Type> Types;
65a7dea167SDimitry Andric}
66a7dea167SDimitry Andric
67a7dea167SDimitry Andricdef AluTypeClass : TypeClass {
68a7dea167SDimitry Andric  let Types = [Sint8, Uint8, Sint16, Uint16, Sint32,
69a7dea167SDimitry Andric               Uint32, Sint64, Uint64, Bool];
70a7dea167SDimitry Andric}
71a7dea167SDimitry Andric
72a7dea167SDimitry Andricdef PtrTypeClass : TypeClass {
73a7dea167SDimitry Andric  let Types = [Ptr];
74a7dea167SDimitry Andric}
75a7dea167SDimitry Andric
76a7dea167SDimitry Andricdef AllTypeClass : TypeClass {
77a7dea167SDimitry Andric  let Types = !listconcat(AluTypeClass.Types, PtrTypeClass.Types);
78a7dea167SDimitry Andric}
79a7dea167SDimitry Andric
80a7dea167SDimitry Andricdef ComparableTypeClass : TypeClass {
81a7dea167SDimitry Andric  let Types = !listconcat(AluTypeClass.Types, [Ptr]);
82a7dea167SDimitry Andric}
83a7dea167SDimitry Andric
84a7dea167SDimitry Andricclass SingletonTypeClass<Type Ty> : TypeClass {
85a7dea167SDimitry Andric  let Types = [Ty];
86a7dea167SDimitry Andric}
87a7dea167SDimitry Andric
88a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
89a7dea167SDimitry Andric// Record describing all opcodes.
90a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
91a7dea167SDimitry Andric
92a7dea167SDimitry Andricclass Opcode {
93a7dea167SDimitry Andric  list<TypeClass> Types = [];
94a7dea167SDimitry Andric  list<ArgType> Args = [];
95a7dea167SDimitry Andric  string Name = "";
96a7dea167SDimitry Andric  bit CanReturn = 0;
97a7dea167SDimitry Andric  bit ChangesPC = 0;
98a7dea167SDimitry Andric  bit HasCustomLink = 0;
99a7dea167SDimitry Andric  bit HasCustomEval = 0;
100a7dea167SDimitry Andric  bit HasGroup = 0;
101a7dea167SDimitry Andric}
102a7dea167SDimitry Andric
103a7dea167SDimitry Andricclass AluOpcode : Opcode {
104a7dea167SDimitry Andric  let Types = [AluTypeClass];
105a7dea167SDimitry Andric  let HasGroup = 1;
106a7dea167SDimitry Andric}
107a7dea167SDimitry Andric
108a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
109a7dea167SDimitry Andric// Jump opcodes
110a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
111a7dea167SDimitry Andric
112a7dea167SDimitry Andricclass JumpOpcode : Opcode {
113a7dea167SDimitry Andric  let Args = [ArgSint32];
114a7dea167SDimitry Andric  let ChangesPC = 1;
115a7dea167SDimitry Andric  let HasCustomEval = 1;
116a7dea167SDimitry Andric}
117a7dea167SDimitry Andric
118a7dea167SDimitry Andric// [] -> []
119a7dea167SDimitry Andricdef Jmp : JumpOpcode;
120a7dea167SDimitry Andric// [Bool] -> [], jumps if true.
121a7dea167SDimitry Andricdef Jt : JumpOpcode;
122a7dea167SDimitry Andric// [Bool] -> [], jumps if false.
123a7dea167SDimitry Andricdef Jf : JumpOpcode;
124a7dea167SDimitry Andric
125a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
126a7dea167SDimitry Andric// Returns
127a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
128a7dea167SDimitry Andric
129a7dea167SDimitry Andric// [Value] -> []
130a7dea167SDimitry Andricdef Ret : Opcode {
131a7dea167SDimitry Andric  let Types = [AllTypeClass];
132a7dea167SDimitry Andric  let ChangesPC = 1;
133a7dea167SDimitry Andric  let CanReturn = 1;
134a7dea167SDimitry Andric  let HasGroup = 1;
135a7dea167SDimitry Andric  let HasCustomEval = 1;
136a7dea167SDimitry Andric}
137a7dea167SDimitry Andric// [] -> []
138a7dea167SDimitry Andricdef RetVoid : Opcode {
139a7dea167SDimitry Andric  let CanReturn = 1;
140a7dea167SDimitry Andric  let ChangesPC = 1;
141a7dea167SDimitry Andric  let HasCustomEval = 1;
142a7dea167SDimitry Andric}
143a7dea167SDimitry Andric// [Value] -> []
144a7dea167SDimitry Andricdef RetValue : Opcode {
145a7dea167SDimitry Andric  let CanReturn = 1;
146a7dea167SDimitry Andric  let ChangesPC = 1;
147a7dea167SDimitry Andric  let HasCustomEval = 1;
148a7dea167SDimitry Andric}
149a7dea167SDimitry Andric// [] -> EXIT
150a7dea167SDimitry Andricdef NoRet : Opcode {}
151a7dea167SDimitry Andric
152a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
153a7dea167SDimitry Andric// Frame management
154a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
155a7dea167SDimitry Andric
156a7dea167SDimitry Andric// [] -> []
157a7dea167SDimitry Andricdef Destroy : Opcode {
158a7dea167SDimitry Andric  let Args = [ArgUint32];
159a7dea167SDimitry Andric  let HasCustomEval = 1;
160a7dea167SDimitry Andric}
161a7dea167SDimitry Andric
162a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
163a7dea167SDimitry Andric// Constants
164a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
165a7dea167SDimitry Andric
166a7dea167SDimitry Andricclass ConstOpcode<Type Ty, ArgType ArgTy> : Opcode {
167a7dea167SDimitry Andric  let Types = [SingletonTypeClass<Ty>];
168a7dea167SDimitry Andric  let Args = [ArgTy];
169a7dea167SDimitry Andric  let Name = "Const";
170a7dea167SDimitry Andric}
171a7dea167SDimitry Andric
172a7dea167SDimitry Andric// [] -> [Integer]
173a7dea167SDimitry Andricdef ConstSint8 : ConstOpcode<Sint8, ArgSint8>;
174a7dea167SDimitry Andricdef ConstUint8 : ConstOpcode<Uint8, ArgUint8>;
175a7dea167SDimitry Andricdef ConstSint16 : ConstOpcode<Sint16, ArgSint16>;
176a7dea167SDimitry Andricdef ConstUint16 : ConstOpcode<Uint16, ArgUint16>;
177a7dea167SDimitry Andricdef ConstSint32 : ConstOpcode<Sint32, ArgSint32>;
178a7dea167SDimitry Andricdef ConstUint32 : ConstOpcode<Uint32, ArgUint32>;
179a7dea167SDimitry Andricdef ConstSint64 : ConstOpcode<Sint64, ArgSint64>;
180a7dea167SDimitry Andricdef ConstUint64 : ConstOpcode<Uint64, ArgUint64>;
181a7dea167SDimitry Andricdef ConstBool : ConstOpcode<Bool, ArgBool>;
182a7dea167SDimitry Andric
183a7dea167SDimitry Andric// [] -> [Integer]
184a7dea167SDimitry Andricdef Zero : Opcode {
185a7dea167SDimitry Andric  let Types = [AluTypeClass];
186a7dea167SDimitry Andric}
187a7dea167SDimitry Andric
188a7dea167SDimitry Andric// [] -> [Pointer]
189a7dea167SDimitry Andricdef Null : Opcode {
190a7dea167SDimitry Andric  let Types = [PtrTypeClass];
191a7dea167SDimitry Andric}
192a7dea167SDimitry Andric
193a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
194a7dea167SDimitry Andric// Pointer generation
195a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
196a7dea167SDimitry Andric
197a7dea167SDimitry Andric// [] -> [Pointer]
198a7dea167SDimitry Andricdef GetPtrLocal : Opcode {
199a7dea167SDimitry Andric  // Offset of local.
200a7dea167SDimitry Andric  let Args = [ArgUint32];
201a7dea167SDimitry Andric  bit HasCustomEval = 1;
202a7dea167SDimitry Andric}
203a7dea167SDimitry Andric// [] -> [Pointer]
204a7dea167SDimitry Andricdef GetPtrParam : Opcode {
205a7dea167SDimitry Andric  // Offset of parameter.
206a7dea167SDimitry Andric  let Args = [ArgUint32];
207a7dea167SDimitry Andric}
208a7dea167SDimitry Andric// [] -> [Pointer]
209a7dea167SDimitry Andricdef GetPtrGlobal : Opcode {
210a7dea167SDimitry Andric  // Index of global.
211a7dea167SDimitry Andric  let Args = [ArgUint32];
212a7dea167SDimitry Andric}
213a7dea167SDimitry Andric// [Pointer] -> [Pointer]
214a7dea167SDimitry Andricdef GetPtrField : Opcode {
215a7dea167SDimitry Andric  // Offset of field.
216a7dea167SDimitry Andric  let Args = [ArgUint32];
217a7dea167SDimitry Andric}
218a7dea167SDimitry Andric// [Pointer] -> [Pointer]
219a7dea167SDimitry Andricdef GetPtrActiveField : Opcode {
220a7dea167SDimitry Andric  // Offset of field.
221a7dea167SDimitry Andric  let Args = [ArgUint32];
222a7dea167SDimitry Andric}
223a7dea167SDimitry Andric// [] -> [Pointer]
224a7dea167SDimitry Andricdef GetPtrActiveThisField : Opcode {
225a7dea167SDimitry Andric  // Offset of field.
226a7dea167SDimitry Andric  let Args = [ArgUint32];
227a7dea167SDimitry Andric}
228a7dea167SDimitry Andric// [] -> [Pointer]
229a7dea167SDimitry Andricdef GetPtrThisField : Opcode {
230a7dea167SDimitry Andric  // Offset of field.
231a7dea167SDimitry Andric  let Args = [ArgUint32];
232a7dea167SDimitry Andric}
233a7dea167SDimitry Andric// [Pointer] -> [Pointer]
234a7dea167SDimitry Andricdef GetPtrBase : Opcode {
235a7dea167SDimitry Andric  // Offset of field, which is a base.
236a7dea167SDimitry Andric  let Args = [ArgUint32];
237a7dea167SDimitry Andric}
238a7dea167SDimitry Andric// [Pointer] -> [Pointer]
239a7dea167SDimitry Andricdef GetPtrVirtBase : Opcode {
240a7dea167SDimitry Andric  // RecordDecl of base class.
241a7dea167SDimitry Andric  let Args = [ArgRecordDecl];
242a7dea167SDimitry Andric}
243a7dea167SDimitry Andric// [] -> [Pointer]
244a7dea167SDimitry Andricdef GetPtrThisBase : Opcode {
245a7dea167SDimitry Andric  // Offset of field, which is a base.
246a7dea167SDimitry Andric  let Args = [ArgUint32];
247a7dea167SDimitry Andric}
248a7dea167SDimitry Andric// [] -> [Pointer]
249a7dea167SDimitry Andricdef GetPtrThisVirtBase : Opcode {
250a7dea167SDimitry Andric  // RecordDecl of base class.
251a7dea167SDimitry Andric  let Args = [ArgRecordDecl];
252a7dea167SDimitry Andric}
253a7dea167SDimitry Andric// [] -> [Pointer]
254a7dea167SDimitry Andricdef This : Opcode;
255a7dea167SDimitry Andric
256a7dea167SDimitry Andric// [Pointer] -> [Pointer]
257a7dea167SDimitry Andricdef NarrowPtr : Opcode;
258a7dea167SDimitry Andric// [Pointer] -> [Pointer]
259a7dea167SDimitry Andricdef ExpandPtr : Opcode;
260a7dea167SDimitry Andric
261a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
262a7dea167SDimitry Andric// Direct field accessors
263a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
264a7dea167SDimitry Andric
265a7dea167SDimitry Andricclass AccessOpcode : Opcode {
266a7dea167SDimitry Andric  let Types = [AllTypeClass];
267a7dea167SDimitry Andric  let Args = [ArgUint32];
268a7dea167SDimitry Andric  let HasGroup = 1;
269a7dea167SDimitry Andric}
270a7dea167SDimitry Andric
271a7dea167SDimitry Andricclass BitFieldOpcode : Opcode {
272a7dea167SDimitry Andric  let Types = [AluTypeClass];
273a7dea167SDimitry Andric  let Args = [ArgRecordField];
274a7dea167SDimitry Andric  let HasGroup = 1;
275a7dea167SDimitry Andric}
276a7dea167SDimitry Andric
277a7dea167SDimitry Andric// [] -> [Pointer]
278a7dea167SDimitry Andricdef GetLocal : AccessOpcode { let HasCustomEval = 1; }
279a7dea167SDimitry Andric// [] -> [Pointer]
280a7dea167SDimitry Andricdef SetLocal : AccessOpcode { let HasCustomEval = 1; }
281a7dea167SDimitry Andric
282a7dea167SDimitry Andric// [] -> [Value]
283a7dea167SDimitry Andricdef GetGlobal : AccessOpcode;
284a7dea167SDimitry Andric// [Value] -> []
285a7dea167SDimitry Andricdef InitGlobal : AccessOpcode;
286a7dea167SDimitry Andric// [Value] -> []
287a7dea167SDimitry Andricdef SetGlobal : AccessOpcode;
288a7dea167SDimitry Andric
289a7dea167SDimitry Andric// [] -> [Value]
290a7dea167SDimitry Andricdef GetParam : AccessOpcode;
291a7dea167SDimitry Andric// [Value] -> []
292a7dea167SDimitry Andricdef SetParam : AccessOpcode;
293a7dea167SDimitry Andric
294a7dea167SDimitry Andric// [Pointer] -> [Pointer, Value]
295a7dea167SDimitry Andricdef GetField : AccessOpcode;
296a7dea167SDimitry Andric// [Pointer] -> [Value]
297a7dea167SDimitry Andricdef GetFieldPop : AccessOpcode;
298a7dea167SDimitry Andric// [] -> [Value]
299a7dea167SDimitry Andricdef GetThisField : AccessOpcode;
300a7dea167SDimitry Andric
301a7dea167SDimitry Andric// [Pointer, Value] -> [Pointer]
302a7dea167SDimitry Andricdef SetField : AccessOpcode;
303a7dea167SDimitry Andric// [Value] -> []
304a7dea167SDimitry Andricdef SetThisField : AccessOpcode;
305a7dea167SDimitry Andric
306a7dea167SDimitry Andric// [Value] -> []
307a7dea167SDimitry Andricdef InitThisField : AccessOpcode;
308a7dea167SDimitry Andric// [Value] -> []
309a7dea167SDimitry Andricdef InitThisFieldActive : AccessOpcode;
310a7dea167SDimitry Andric// [Value] -> []
311a7dea167SDimitry Andricdef InitThisBitField : BitFieldOpcode;
312a7dea167SDimitry Andric// [Pointer, Value] -> []
313a7dea167SDimitry Andricdef InitField : AccessOpcode;
314a7dea167SDimitry Andric// [Pointer, Value] -> []
315a7dea167SDimitry Andricdef InitBitField : BitFieldOpcode;
316a7dea167SDimitry Andric// [Pointer, Value] -> []
317a7dea167SDimitry Andricdef InitFieldActive : AccessOpcode;
318a7dea167SDimitry Andric
319a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
320a7dea167SDimitry Andric// Pointer access
321a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
322a7dea167SDimitry Andric
323a7dea167SDimitry Andricclass LoadOpcode : Opcode {
324a7dea167SDimitry Andric  let Types = [AllTypeClass];
325a7dea167SDimitry Andric  let HasGroup = 1;
326a7dea167SDimitry Andric}
327a7dea167SDimitry Andric
328a7dea167SDimitry Andric// [Pointer] -> [Pointer, Value]
329a7dea167SDimitry Andricdef Load : LoadOpcode {}
330a7dea167SDimitry Andric// [Pointer] -> [Value]
331a7dea167SDimitry Andricdef LoadPop : LoadOpcode {}
332a7dea167SDimitry Andric
333a7dea167SDimitry Andricclass StoreOpcode : Opcode {
334a7dea167SDimitry Andric  let Types = [AllTypeClass];
335a7dea167SDimitry Andric  let HasGroup = 1;
336a7dea167SDimitry Andric}
337a7dea167SDimitry Andric
338a7dea167SDimitry Andricclass StoreBitFieldOpcode : Opcode {
339a7dea167SDimitry Andric  let Types = [AluTypeClass];
340a7dea167SDimitry Andric  let HasGroup = 1;
341a7dea167SDimitry Andric}
342a7dea167SDimitry Andric
343a7dea167SDimitry Andric// [Pointer, Value] -> [Pointer]
344a7dea167SDimitry Andricdef Store : StoreOpcode {}
345a7dea167SDimitry Andric// [Pointer, Value] -> []
346a7dea167SDimitry Andricdef StorePop : StoreOpcode {}
347a7dea167SDimitry Andric
348a7dea167SDimitry Andric// [Pointer, Value] -> [Pointer]
349a7dea167SDimitry Andricdef StoreBitField : StoreBitFieldOpcode {}
350a7dea167SDimitry Andric// [Pointer, Value] -> []
351a7dea167SDimitry Andricdef StoreBitFieldPop : StoreBitFieldOpcode {}
352a7dea167SDimitry Andric
353a7dea167SDimitry Andric// [Pointer, Value] -> []
354a7dea167SDimitry Andricdef InitPop : StoreOpcode {}
355a7dea167SDimitry Andric// [Pointer, Value] -> [Pointer]
356a7dea167SDimitry Andricdef InitElem : Opcode {
357a7dea167SDimitry Andric  let Types = [AllTypeClass];
358a7dea167SDimitry Andric  let Args = [ArgUint32];
359a7dea167SDimitry Andric  let HasGroup = 1;
360a7dea167SDimitry Andric}
361a7dea167SDimitry Andric// [Pointer, Value] -> []
362a7dea167SDimitry Andricdef InitElemPop : Opcode {
363a7dea167SDimitry Andric  let Types = [AllTypeClass];
364a7dea167SDimitry Andric  let Args = [ArgUint32];
365a7dea167SDimitry Andric  let HasGroup = 1;
366a7dea167SDimitry Andric}
367a7dea167SDimitry Andric
368a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
369a7dea167SDimitry Andric// Pointer arithmetic.
370a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
371a7dea167SDimitry Andric
372a7dea167SDimitry Andric// [Pointer, Integral] -> [Pointer]
373a7dea167SDimitry Andricdef AddOffset : AluOpcode;
374a7dea167SDimitry Andric// [Pointer, Integral] -> [Pointer]
375a7dea167SDimitry Andricdef SubOffset : AluOpcode;
376a7dea167SDimitry Andric
377a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
378a7dea167SDimitry Andric// Binary operators.
379a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
380a7dea167SDimitry Andric
381a7dea167SDimitry Andric// [Real, Real] -> [Real]
382a7dea167SDimitry Andricdef Sub : AluOpcode;
383a7dea167SDimitry Andricdef Add : AluOpcode;
384a7dea167SDimitry Andricdef Mul : AluOpcode;
385a7dea167SDimitry Andric
386a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
387a7dea167SDimitry Andric// Comparison opcodes.
388a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
389a7dea167SDimitry Andric
390a7dea167SDimitry Andricclass EqualityOpcode : Opcode {
391a7dea167SDimitry Andric  let Types = [AllTypeClass];
392a7dea167SDimitry Andric  let HasGroup = 1;
393a7dea167SDimitry Andric}
394a7dea167SDimitry Andric
395a7dea167SDimitry Andricdef EQ : EqualityOpcode;
396a7dea167SDimitry Andricdef NE : EqualityOpcode;
397a7dea167SDimitry Andric
398a7dea167SDimitry Andricclass ComparisonOpcode : Opcode {
399a7dea167SDimitry Andric  let Types = [ComparableTypeClass];
400a7dea167SDimitry Andric  let HasGroup = 1;
401a7dea167SDimitry Andric}
402a7dea167SDimitry Andric
403a7dea167SDimitry Andricdef LT : ComparisonOpcode;
404a7dea167SDimitry Andricdef LE : ComparisonOpcode;
405a7dea167SDimitry Andricdef GT : ComparisonOpcode;
406a7dea167SDimitry Andricdef GE : ComparisonOpcode;
407a7dea167SDimitry Andric
408a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
409a7dea167SDimitry Andric// Stack management.
410a7dea167SDimitry Andric//===----------------------------------------------------------------------===//
411a7dea167SDimitry Andric
412a7dea167SDimitry Andric// [Value] -> []
413a7dea167SDimitry Andricdef Pop : Opcode {
414a7dea167SDimitry Andric  let Types = [AllTypeClass];
415a7dea167SDimitry Andric  let HasGroup = 1;
416a7dea167SDimitry Andric}
417a7dea167SDimitry Andric
418a7dea167SDimitry Andric// [Value] -> [Value, Value]
419a7dea167SDimitry Andricdef Dup : Opcode {
420a7dea167SDimitry Andric  let Types = [AllTypeClass];
421a7dea167SDimitry Andric  let HasGroup = 1;
422a7dea167SDimitry Andric}
423