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