To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

irParser.scala 14.9 KB
Newer Older
Kunshan Wang's avatar
Kunshan Wang committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package uvm.ir.textinput

import scala.util.parsing.combinator.RegexParsers

object UvmIRParser extends RegexParsers {
  import UvmIRAST._

  implicit class ParserExtension[T](that: Parser[T]) {
    def ~<[U](q: => Parser[U]): Parser[T] = {
      lazy val p = q // lazy argument
      (for (a <- that; b <- p) yield a).named("~<")
    }
  }

  implicit class ParserMap2[T1, T2](that: Parser[T1 ~ T2]) {
    def ^^^^[U](f: (T1, T2) => U): Parser[U] = that ^^ { case t1 ~ t2 => f(t1, t2) }
  }

  implicit class ParserMap3[T1, T2, T3](that: Parser[T1 ~ T2 ~ T3]) {
    def ^^^^[U](f: (T1, T2, T3) => U): Parser[U] = that ^^ { case t1 ~ t2 ~ t3 => f(t1, t2, t3) }
  }
  implicit class ParserMap4[T1, T2, T3, T4](that: Parser[T1 ~ T2 ~ T3 ~ T4]) {
    def ^^^^[U](f: (T1, T2, T3, T4) => U): Parser[U] = that ^^ { case t1 ~ t2 ~ t3 ~ t4 => f(t1, t2, t3, t4) }
  }
  implicit class ParserMap5[T1, T2, T3, T4, T5](that: Parser[T1 ~ T2 ~ T3 ~ T4 ~ T5]) {
    def ^^^^[U](f: (T1, T2, T3, T4, T5) => U): Parser[U] = that ^^ { case t1 ~ t2 ~ t3 ~ t4 ~ t5 => f(t1, t2, t3, t4, t5) }
  }
  implicit class ParserMap6[T1, T2, T3, T4, T5, T6](that: Parser[T1 ~ T2 ~ T3 ~ T4 ~ T5 ~ T6]) {
    def ^^^^[U](f: (T1, T2, T3, T4, T5, T6) => U): Parser[U] = that ^^ { case t1 ~ t2 ~ t3 ~ t4 ~ t5 ~ t6 => f(t1, t2, t3, t4, t5, t6) }
  }

  def ang[T](q: => Parser[T]): Parser[T] = { lazy val p = q; "<" ~> p <~ ">" }

  def paren[T](q: => Parser[T]): Parser[T] = { lazy val p = q; "(" ~> p <~ ")" }

  def brace[T](q: => Parser[T]): Parser[T] = { lazy val p = q; "{" ~> p <~ "}" }

  def ir: Parser[IR] = rep(topLevel) ^^ IR

  def topLevel: Parser[TopLevel] = typeDef | funcSigDef | constDef | globalDataDef | funcDecl | funcDef

Kunshan Wang's avatar
Kunshan Wang committed
42
43
44
45
46
47
  def t = typeExpr
  def s = funcSigExpr
  def v = valueExpr
  def l = lid
  def g = gid

Kunshan Wang's avatar
Kunshan Wang committed
48
49
  def typeDef: Parser[TypeDef] = ".typedef" ~> gid ~< "=" ~ typeCons ^^^^ TypeDef
  def funcSigDef: Parser[FuncSigDef] = ".funcsig" ~> gid ~< "=" ~ funcSigCons ^^^^ FuncSigDef
Kunshan Wang's avatar
Kunshan Wang committed
50
51
52
53
  def constDef: Parser[ConstDef] = ".const" ~> gid ~ ang(t) ~< "=" ~ constCons ^^^^ ConstDef
  def globalDataDef: Parser[GlobalDataDef] = ".global" ~> gid ~ ang(t) ^^^^ GlobalDataDef
  def funcDecl: Parser[FuncDecl] = ".funcdecl" ~> gid ~ ang(s) ^^^^ FuncDecl
  def funcDef: Parser[FuncDef] = ".funcdef" ~> gid ~ ang(s) ~ paren(rep(l)) ~ funcBodyDef ^^^^ FuncDef
Kunshan Wang's avatar
Kunshan Wang committed
54

Kunshan Wang's avatar
Kunshan Wang committed
55
  def typeExpr: Parser[TypeExpr] = gid ^^ ReferredType | typeCons
Kunshan Wang's avatar
Kunshan Wang committed
56
57
58
59
  def typeCons: Parser[TypeCons] =
    "int" ~> ang(intLit.asInt) ^^ IntCons |
      "float" ^^^ FloatCons |
      "double" ^^^ DoubleCons |
Kunshan Wang's avatar
Kunshan Wang committed
60
61
62
63
64
65
      "ref" ~> ang(t) ^^ RefCons |
      "iref" ~> ang(t) ^^ IRefCons |
      "weakref" ~> ang(t) ^^ WeakRefCons |
      "struct" ~> ang(rep(t)) ^^ StructCons |
      "array" ~> ang(t ~ intLit.asLong) ^^^^ ArrayCons |
      "hybrid" ~> ang(t ~ t) ^^^^ HybridCons |
Kunshan Wang's avatar
Kunshan Wang committed
66
      "void" ^^^ VoidCons |
Kunshan Wang's avatar
Kunshan Wang committed
67
      "func" ~> ang(s) ^^ FuncCons |
Kunshan Wang's avatar
Kunshan Wang committed
68
69
70
71
      "thread" ^^^ ThreadCons |
      "stack" ^^^ StackCons |
      "tagref64" ^^^ TagRef64Cons

Kunshan Wang's avatar
Kunshan Wang committed
72
73
  def funcSigExpr: Parser[FuncSigExpr] = funcSigCons | g ^^ ReferredFuncSig
  def funcSigCons: Parser[FuncSigCons] = t ~ paren(rep(t)) ^^^^ FuncSigCons
Kunshan Wang's avatar
Kunshan Wang committed
74

Kunshan Wang's avatar
Kunshan Wang committed
75
  def constExpr: Parser[ConstExpr] = g ^^ ReferredConst | constCons
Kunshan Wang's avatar
Kunshan Wang committed
76
  def constCons: Parser[ConstCons] =
Kunshan Wang's avatar
Kunshan Wang committed
77
    floatLit ^^ FloatConstCons |
Kunshan Wang's avatar
Kunshan Wang committed
78
      doubleLit ^^ DoubleConstCons |
Kunshan Wang's avatar
Kunshan Wang committed
79
80
      intLit ^^ IntConstCons |
      brace(rep(constExpr)) ^^ StructConstCons |
Kunshan Wang's avatar
Kunshan Wang committed
81
82
83
84
85
86
87
      "NULL" ^^^ NullConstCons

  def funcBodyDef: Parser[FuncBodyDef] = brace(entryBlock ~ rep(regularBlock)) ^^^^ FuncBodyDef

  def entryBlock: Parser[BasicBlockDef] = opt(label) ~ rep1(inst) ^^^^ BasicBlockDef
  def regularBlock: Parser[BasicBlockDef] = (label ^^ { Some(_) }) ~ rep1(inst) ^^^^ BasicBlockDef

Kunshan Wang's avatar
Kunshan Wang committed
88
  def label: Parser[LID] = l <~ ":"
Kunshan Wang's avatar
Kunshan Wang committed
89

Kunshan Wang's avatar
Kunshan Wang committed
90
  def inst: Parser[InstDef] = opt(l <~ "=") ~ instCons ^^^^ InstDef
Kunshan Wang's avatar
Kunshan Wang committed
91
92
93
94
95
96
97
98

  def instCons: Parser[InstCons] =
    binOptr ~ ang(t) ~ v ~ v ^^^^ BinOpCons |
      cmpOptr ~ ang(t) ~ v ~ v ^^^^ CmpCons |
      convOptr ~ ang(t ~ t) ~ v ^^ { case a ~ (b ~ c) ~ d => ConvCons(a, b, c, d) } |
      "SELECT" ~> ang(t) ~ v ~ v ~ v ^^^^ SelectCons |
      "BRANCH" ~> l ^^ BranchCons |
      "BRANCH2" ~> v ~ l ~ l ^^^^ Branch2Cons |
Kunshan Wang's avatar
Kunshan Wang committed
99
100
      "SWITCH" ~> ang(t) ~ v ~ l ~ brace(vbMap) ^^^^ SwitchCons |
      "PHI" ~> ang(t) ~ brace(bvMap) ^^^^ PhiCons |
Kunshan Wang's avatar
Kunshan Wang committed
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
      "CALL" ~> ang(s) ~ v ~ args ~ maybeKeepAlive ^^^^ CallCons |
      "INVOKE" ~> ang(s) ~ v ~ args ~ l ~ l ~ maybeKeepAlive ^^^^ InvokeCons |
      "TAILCALL" ~> ang(s) ~ v ~ args ^^^^ TailCallCons |
      "RET" ~> ang(t) ~ v ^^^^ RetCons |
      "RETVOID" ^^^ RetVoidCons |
      "THROW" ~> v ^^ ThrowCons |
      "LANDINGPAD" ^^^ LandingpadCons |
      "EXTRACTVALUE" ~> ang(t ~ intLit.asInt) ~ v ^^^^ ExtractValueCons |
      "INSERTVALUE" ~> ang(t ~ intLit.asInt) ~ v ~ v ^^^^ InsertValueCons |
      "NEW" ~> ang(t) ^^ NewCons |
      "NEWHYBRID" ~> ang(t) ~ v ^^^^ NewHybridCons |
      "ALLOCA" ~> ang(t) ^^ AllocaCons |
      "ALLOCAHYBRID" ~> ang(t) ~ v ^^^^ AllocaHybridCons |
      "GETIREF" ~> ang(t) ~ v ^^^^ GetIRefCons |
      "GETFIELDIREF" ~> ang(t ~ intLit.asInt) ~ v ^^^^ GetFieldIRefCons |
      "GETELEMIREF" ~> ang(t) ~ v ~ v ^^^^ GetElemIRefCons |
Kunshan Wang's avatar
Kunshan Wang committed
117
      "SHIFTIREF" ~> ang(t) ~ v ~ v ^^^^ ShiftIRefCons |
Kunshan Wang's avatar
Kunshan Wang committed
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
      "GETFIXEDPARTIREF" ~> ang(t) ~ v ^^^^ GetFixedPartIRefCons |
      "GETVARPARTIREF" ~> ang(t) ~ v ^^^^ GetVarPartIRefCons |
      "LOAD" ~> maybeMemOrd ~ ang(t) ~ v ^^^^ LoadCons |
      "STORE" ~> maybeMemOrd ~ ang(t) ~ v ~ v ^^^^ StoreCons |
      "CMPXCHG" ~> memOrd ~ memOrd ~ ang(t) ~ v ~ v ~ v ^^^^ CmpXchgCons |
      "ATOMICRMW" ~> memOrd ~ atomicRMWOp ~ ang(t) ~ v ~ v ^^^^ AtomicRMWCons |
      "FENCE" ~> memOrd ^^ FenceCons |
      "TRAP" ~> ang(t) ~ l ~ l ~ keepAlive ^^^^ TrapCons |
      "WATCHPOINT" ~> intLit.asInt ~ ang(t) ~ l ~ l ~ l ~ keepAlive ^^^^ WatchpointCons |
      "CCALL" ~> callConv ~ ang(s) ~ v ~ args ^^^^ CCallCons |
      "NEWSTACK" ~> ang(s) ~ v ~ args ^^^^ NewStackCons |
      "ICALL" ~> g ~ args ~ maybeKeepAlive ^^^^ ICallCons |
      "IINVOKE" ~> g ~ args ~ l ~ l ~ maybeKeepAlive ^^^^ IInvokeCons

  def vbMap: Parser[Seq[(ValueExpr, LID)]] = rep(valueExpr ~< ":" ~ lid ~< ";" ^^ { case a ~ b => (a, b) })
  def bvMap: Parser[Seq[(LID, ValueExpr)]] = rep(lid ~< ":" ~ valueExpr ~< ";" ^^ { case a ~ b => (a, b) })

  def args: Parser[Seq[ValueExpr]] = paren(rep(v))
Kunshan Wang's avatar
Kunshan Wang committed
136
137
  def keepAlive: Parser[Seq[LID]] = "KEEPALIVE" ~> paren(rep(l))
  def maybeKeepAlive: Parser[Seq[LID]] = opt(keepAlive) ^^ { _.getOrElse(Nil) }
Kunshan Wang's avatar
Kunshan Wang committed
138
139
140

  def valueExpr: Parser[ValueExpr] = id ^^ RefValue | constCons ^^ InlineValue

Kunshan Wang's avatar
Kunshan Wang committed
141
  def binOptr: Parser[String] = "ADD|SUB|MUL|UDIV|SDIV|UREM|SREM|SHL|LSHR|ASHR|AND|OR|XOR|FADD|FSUB|FMUL|FDIV|FREM".r
Kunshan Wang's avatar
Kunshan Wang committed
142
  def cmpOptr: Parser[String] = "EQ|NE|ULT|ULE|UGT|UGE|SLT|SLE|SGT|SGE|FTRUE|FFALSE|FEQ|FNE|FORD|FOEQ|FONE|FOLT|FOLE|FOGT|FOGE|FUNO|FUEQ|FUNE|FULT|FULE|FUGT|FUGE".r
Kunshan Wang's avatar
Kunshan Wang committed
143
  def convOptr: Parser[String] = "TRUNC|ZEXT|SEXT|FPTRUNC|FPEXT|FPTOUI|FPTOSI|UITOFP|SITOFP|BITCAST|REFCAST|IREFCAST|FUNCCAST".r
Kunshan Wang's avatar
Kunshan Wang committed
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
  def memOrd: Parser[String] = "NOT_ATOMIC|UNORDERED|MONOTONIC|ACQUIRE|RELEASE|ACQ_REL|SEQ_CST".r
  def atomicRMWOp: Parser[String] = "XCHG|ADD|SUB|AND|NAND|OR|XOR|MIN|MAX|UMIN|UMAX".r
  def callConv: Parser[String] = "DEFAULT".r

  def maybeMemOrd: Parser[String] = opt(memOrd) ^^ { _.getOrElse("NOT_ATOMIC") }

  def id: Parser[ID] = lid | gid
  def lid: Parser[LID] = """%[a-zA-Z0-9-_.]+""".r ^^ LID
  def gid: Parser[GID] = """@[a-zA-Z0-9-_.]+""".r ^^ GID

  def sign: Parser[Boolean] = opt("+" ^^^ false | "-" ^^^ true) ^^ { _.getOrElse(false) }

  def parseInt(radix: Int)(res: Boolean ~ String): BigInt = res match {
    case neg ~ ns =>
      val num = BigInt(ns, radix)
      if (neg) -num else num
  }

  implicit class BigIntParserConv(p: Parser[BigInt]) {
    def asInt: Parser[Int] = p ^^ { _.intValue }
    def asLong: Parser[Long] = p ^^ { _.longValue }
  }

  def intLit: Parser[BigInt] =
Kunshan Wang's avatar
Kunshan Wang committed
168
169
170
    sign ~< "0x" ~ """[0-9a-fA-F]+""".r ^^ parseInt(16) |
      sign ~< "0" ~ """[0-9]+""".r ^^ parseInt(8) |
      sign ~ """([1-9][0-9]*)|0""".r ^^ parseInt(10)
Kunshan Wang's avatar
Kunshan Wang committed
171
172
173
174

  def floatLit: Parser[Float] =
    """[+-]?[0-9]+\.[0-9]+(e[+-]?[0-9]+)?""".r <~ "f" ^^ { _.toFloat } |
      "nan" <~ "f" ^^^ Float.NaN |
Kunshan Wang's avatar
Kunshan Wang committed
175
      "+inf" <~ "f" ^^^ Float.PositiveInfinity |
Kunshan Wang's avatar
Kunshan Wang committed
176
177
178
179
180
181
      "-inf" <~ "f" ^^^ Float.NegativeInfinity |
      "bitsf" ~> paren(intLit.asInt) ^^ { java.lang.Float.intBitsToFloat(_) }

  def doubleLit: Parser[Double] =
    """[+-]?[0-9]+\.[0-9]+(e[+-]?[0-9]+)?""".r <~ "d" ^^ { _.toDouble } |
      "nan" <~ "d" ^^^ Double.NaN |
Kunshan Wang's avatar
Kunshan Wang committed
182
      "+inf" <~ "d" ^^^ Double.PositiveInfinity |
Kunshan Wang's avatar
Kunshan Wang committed
183
184
185
186
187
188
189
      "-inf" <~ "d" ^^^ Double.NegativeInfinity |
      "bitsd" ~> paren(intLit.asLong) ^^ { java.lang.Double.longBitsToDouble(_) }

  def apply(input: java.lang.CharSequence): IR = handleNoSuccess(parseAll(ir, input))
  def apply(input: java.io.Reader): IR = handleNoSuccess(parseAll(ir, input))

  private def handleNoSuccess(pr: ParseResult[IR]): IR = pr match {
Kunshan Wang's avatar
Kunshan Wang committed
190
191
192
    case Success(irNode, next) => irNode
    case NoSuccess(msg, next) => throw new TextIRParsingException(
      "line %d, col %d: %s".format(next.pos.line, next.pos.column, msg))
Kunshan Wang's avatar
Kunshan Wang committed
193
194
195
196
197
198
199
200
201
202
203
  }
}

object UvmIRAST {

  case class IR(topLevels: Seq[TopLevel])

  abstract class TopLevel
  case class TypeDef(name: GID, cons: TypeCons) extends TopLevel

  abstract class TypeExpr
Kunshan Wang's avatar
Kunshan Wang committed
204
  case class ReferredType(id: GID) extends TypeExpr
Kunshan Wang's avatar
Kunshan Wang committed
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224

  abstract class TypeCons extends TypeExpr
  case class IntCons(length: Int) extends TypeCons
  case object FloatCons extends TypeCons
  case object DoubleCons extends TypeCons
  case class RefCons(ty: TypeExpr) extends TypeCons
  case class IRefCons(ty: TypeExpr) extends TypeCons
  case class WeakRefCons(ty: TypeExpr) extends TypeCons
  case class StructCons(fieldTy: Seq[TypeExpr]) extends TypeCons
  case class ArrayCons(elemTy: TypeExpr, length: Long) extends TypeCons
  case class HybridCons(fixedPart: TypeExpr, varPart: TypeExpr) extends TypeCons
  case object VoidCons extends TypeCons
  case class FuncCons(sig: FuncSigExpr) extends TypeCons
  case object ThreadCons extends TypeCons
  case object StackCons extends TypeCons
  case object TagRef64Cons extends TypeCons

  case class FuncSigDef(name: GID, cons: FuncSigCons) extends TopLevel

  abstract class FuncSigExpr
Kunshan Wang's avatar
Kunshan Wang committed
225
  case class ReferredFuncSig(id: GID) extends FuncSigExpr
Kunshan Wang's avatar
Kunshan Wang committed
226
227
228
229
230
  case class FuncSigCons(retTy: TypeExpr, paramTy: Seq[TypeExpr]) extends FuncSigExpr

  case class ConstDef(name: GID, ty: TypeExpr, cons: ConstCons) extends TopLevel

  abstract class ConstExpr
Kunshan Wang's avatar
Kunshan Wang committed
231
  case class ReferredConst(id: GID) extends ConstExpr
Kunshan Wang's avatar
Kunshan Wang committed
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265

  abstract class ConstCons extends ConstExpr
  case class IntConstCons(num: BigInt) extends ConstCons
  case class FloatConstCons(num: Float) extends ConstCons
  case class DoubleConstCons(num: Double) extends ConstCons
  case class StructConstCons(fields: Seq[ConstExpr]) extends ConstCons
  case object NullConstCons extends ConstCons

  case class GlobalDataDef(name: GID, ty: TypeExpr) extends TopLevel

  case class FuncDecl(name: GID, sig: FuncSigExpr) extends TopLevel

  case class FuncDef(name: GID, sig: FuncSigExpr, params: Seq[LID], body: FuncBodyDef) extends TopLevel

  case class FuncBodyDef(entry: BasicBlockDef, bbs: Seq[BasicBlockDef])

  case class BasicBlockDef(name: Option[LID], insts: Seq[InstDef])

  case class InstDef(name: Option[LID], cons: InstCons)

  abstract class InstCons

  abstract class ValueExpr
  case class RefValue(id: ID) extends ValueExpr
  case class InlineValue(cons: ConstCons) extends ValueExpr

  case class BinOpCons(op: String, opndTy: TypeExpr, op1: ValueExpr, op2: ValueExpr) extends InstCons
  case class CmpCons(op: String, opndTy: TypeExpr, op1: ValueExpr, op2: ValueExpr) extends InstCons
  case class ConvCons(op: String, fromTy: TypeExpr, toTy: TypeExpr, opnd: ValueExpr) extends InstCons
  case class SelectCons(opndTy: TypeExpr, cond: ValueExpr, ifTrue: ValueExpr, ifFalse: ValueExpr) extends InstCons
  case class BranchCons(dest: LID) extends InstCons
  case class Branch2Cons(cond: ValueExpr, ifTrue: LID, ifFalse: LID) extends InstCons
  case class SwitchCons(opndTy: TypeExpr, opnd: ValueExpr, defDest: LID, cases: Seq[(ValueExpr, LID)]) extends InstCons
  case class PhiCons(opndTy: TypeExpr, cases: Seq[(LID, ValueExpr)]) extends InstCons
Kunshan Wang's avatar
Kunshan Wang committed
266
267
  case class CallCons(sig: FuncSigExpr, callee: ValueExpr, args: Seq[ValueExpr], keepAlives: Seq[LID]) extends InstCons
  case class InvokeCons(sig: FuncSigExpr, callee: ValueExpr, args: Seq[ValueExpr], nor: LID, exc: LID, keepAlives: Seq[LID]) extends InstCons
Kunshan Wang's avatar
Kunshan Wang committed
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
  case class TailCallCons(sig: FuncSigExpr, callee: ValueExpr, args: Seq[ValueExpr]) extends InstCons
  case class RetCons(retTy: TypeExpr, retVal: ValueExpr) extends InstCons
  case object RetVoidCons extends InstCons
  case class ThrowCons(excVal: ValueExpr) extends InstCons
  case object LandingpadCons extends InstCons
  case class ExtractValueCons(strTy: TypeExpr, index: Int, opnd: ValueExpr) extends InstCons
  case class InsertValueCons(strTy: TypeExpr, index: Int, opnd: ValueExpr, newVal: ValueExpr) extends InstCons
  case class NewCons(allocTy: TypeExpr) extends InstCons
  case class NewHybridCons(allocTy: TypeExpr, length: ValueExpr) extends InstCons
  case class AllocaCons(allocTy: TypeExpr) extends InstCons
  case class AllocaHybridCons(allocTy: TypeExpr, length: ValueExpr) extends InstCons
  case class GetIRefCons(referentTy: TypeExpr, opnd: ValueExpr) extends InstCons
  case class GetFieldIRefCons(referentTy: TypeExpr, index: Int, opnd: ValueExpr) extends InstCons
  case class GetElemIRefCons(referentTy: TypeExpr, opnd: ValueExpr, index: ValueExpr) extends InstCons
  case class ShiftIRefCons(referentTy: TypeExpr, opnd: ValueExpr, offset: ValueExpr) extends InstCons
  case class GetFixedPartIRefCons(referentTy: TypeExpr, opnd: ValueExpr) extends InstCons
  case class GetVarPartIRefCons(referentTy: TypeExpr, opnd: ValueExpr) extends InstCons
  case class LoadCons(ord: String, referentTy: TypeExpr, loc: ValueExpr) extends InstCons
  case class StoreCons(ord: String, referentTy: TypeExpr, loc: ValueExpr, newVal: ValueExpr) extends InstCons
  case class CmpXchgCons(ordSucc: String, ordFail: String, referentTy: TypeExpr,
    loc: ValueExpr, expected: ValueExpr, desired: ValueExpr) extends InstCons
  case class AtomicRMWCons(ord: String, op: String, referentTy: TypeExpr, loc: ValueExpr, newVal: ValueExpr) extends InstCons
  case class FenceCons(ord: String) extends InstCons
Kunshan Wang's avatar
Kunshan Wang committed
291
292
  case class TrapCons(retTy: TypeExpr, nor: LID, exc: LID, keepAlives: Seq[LID]) extends InstCons
  case class WatchpointCons(wpID: Int, retTy: TypeExpr, dis: LID, nor: LID, exc: LID, keepAlives: Seq[LID]) extends InstCons
Kunshan Wang's avatar
Kunshan Wang committed
293
294
  case class CCallCons(callConv: String, sig: FuncSigExpr, callee: ValueExpr, args: Seq[ValueExpr]) extends InstCons
  case class NewStackCons(sig: FuncSigExpr, callee: ValueExpr, args: Seq[ValueExpr]) extends InstCons
Kunshan Wang's avatar
Kunshan Wang committed
295
296
  case class ICallCons(iFunc: GID, args: Seq[ValueExpr], keepAlives: Seq[LID]) extends InstCons
  case class IInvokeCons(iFunc: GID, args: Seq[ValueExpr], nor: LID, exc: LID, keepAlives: Seq[LID]) extends InstCons
Kunshan Wang's avatar
Kunshan Wang committed
297
298
299
300
301
302
303
304
305
306

  abstract class ID(name: String)
  case class GID(name: String) extends ID(name)
  case class LID(name: String) extends ID(name)

  case class IntLit(num: BigInt)
  case class FloatLit(num: Float)
  case class DoubleLit(num: Double)
  case object NullLit
}