WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

ssavariables.scala 9.08 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
package uvm.ssavariables

import uvm._
import uvm.comminsts._
import uvm.types._

abstract class SSAVariable extends IdentifiedSettable

// Global variables: Constants, Global Cells and Functions (Function is defined in controlFlow.scala)

abstract class GlobalVariable extends SSAVariable

abstract class Constant extends GlobalVariable {
  var constTy: Type
}

case class ConstInt(var constTy: Type, var num: BigInt) extends Constant

case class ConstFloat(var constTy: Type, var num: Float) extends Constant

case class ConstDouble(var constTy: Type, var num: Double) extends Constant

case class ConstStruct(var constTy: Type, var fields: Seq[GlobalVariable]) extends Constant

case class ConstNull(var constTy: Type) extends Constant

Kunshan Wang's avatar
Kunshan Wang committed
27
28
case class ConstVector(var constTy: Type, var elems: Seq[Constant]) extends Constant

Kunshan Wang's avatar
Kunshan Wang committed
29
30
31
32
33
case class GlobalCell(var cellTy: Type) extends GlobalVariable

// Local variables: Parameters and Instructions

abstract class LocalVariable extends SSAVariable {
Kunshan Wang's avatar
Kunshan Wang committed
34
  var funcVer: FuncVer = null
Kunshan Wang's avatar
Kunshan Wang committed
35
36
}

Kunshan Wang's avatar
Kunshan Wang committed
37
case class Parameter(override var funcVer: FuncVer, var index: Int) extends LocalVariable
Kunshan Wang's avatar
Kunshan Wang committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245

// Instructions

abstract class Instruction extends LocalVariable

/// enumerations

object BinOptr extends Enumeration {
  type BinOptr = Value
  val ADD, SUB, MUL, UDIV, SDIV, UREM, SREM, SHL, LSHR, ASHR, AND, OR, XOR = Value
  val FADD, FSUB, FMUL, FDIV, FREM = Value
}

import uvm.ssavariables.BinOptr.BinOptr

object CmpOptr extends Enumeration {
  type CmpOptr = Value
  val EQ, NE, ULT, ULE, UGT, UGE, SLT, SLE, SGT, SGE = Value
  val FTRUE, FFALSE, FORD, FOEQ, FONE, FOLT, FOLE, FOGT, FOGE = Value
  val FUNO, FUEQ, FUNE, FULT, FULE, FUGT, FUGE = Value
}

import uvm.ssavariables.CmpOptr.CmpOptr

object ConvOptr extends Enumeration {
  type ConvOptr = Value
  val TRUNC, ZEXT, SEXT, FPTRUNC, FPEXT, FPTOUI, FPTOSI, UITOFP, SITOFP, BITCAST, REFCAST = Value
}

import uvm.ssavariables.ConvOptr.ConvOptr

object MemoryOrder extends Enumeration {
  type MemoryOrder = Value
  val NOT_ATOMIC, RELAXED, CONSUME, ACQUIRE, RELEASE, ACQ_REL, SEQ_CST = Value
}

import uvm.ssavariables.MemoryOrder.MemoryOrder

object AtomicRMWOptr extends Enumeration {
  type AtomicRMWOptr = Value
  val XCHG, ADD, SUB, AND, NAND, OR, XOR, MIN, MAX, UMIN, UMAX = Value
}

import uvm.ssavariables.AtomicRMWOptr.AtomicRMWOptr

object CallConv extends Enumeration {
  type CallConv = Value
  val DEFAULT = Value
}

import uvm.ssavariables.CallConv.CallConv

/// Abstract instructions and traits

trait HasTypeList extends Instruction {
  var typeList: Seq[Type]
}

trait HasArgList extends Instruction {
  var argList: Seq[SSAVariable]
}

trait CallLike extends HasArgList {
  var sig: FuncSig
  var callee: SSAVariable
}

case class ExcClause(val nor: BasicBlock, val exc: BasicBlock)

trait HasExcClause extends Instruction {
  var excClause: Option[ExcClause]
}

trait HasKeepAliveClause extends Instruction {
  var keepAlives: Seq[SSAVariable]
}

abstract class AbstractCall extends CallLike

abstract class AbstractRet extends Instruction

abstract class AbstractAlloc extends Instruction {
  def allocTy: Type
}

trait FixedAlloc extends AbstractAlloc

trait HybridAlloc extends AbstractAlloc {
  def length: SSAVariable
}

abstract class HeapAlloc extends AbstractAlloc

abstract class StackAlloc extends AbstractAlloc

abstract class AbstractTrap extends HasKeepAliveClause {
  var retTy: Type
}

abstract class CurStackAction
case class RetWith(var retTy: Type) extends CurStackAction
case class KillOld() extends CurStackAction

abstract class NewStackAction
case class PassParam(var argTy: Type, var arg: SSAVariable) extends NewStackAction
case class NoParam() extends NewStackAction
case class ThrowExc(var exc: SSAVariable) extends NewStackAction

/// Concrete instructions
case class InstBinOp(var op: BinOptr, var opndTy: Type, var op1: SSAVariable, var op2: SSAVariable,
                     var excClause: Option[ExcClause]) extends HasExcClause

case class InstCmp(var op: CmpOptr, var opndTy: Type, var op1: SSAVariable, var op2: SSAVariable) extends Instruction

case class InstConv(var op: ConvOptr, var fromTy: Type, var toTy: Type, var opnd: SSAVariable) extends Instruction

case class InstSelect(var opndTy: Type, var condTy: Type,
                      var cond: SSAVariable, var ifTrue: SSAVariable, var ifFalse: SSAVariable) extends Instruction

case class InstBranch(var dest: BasicBlock) extends Instruction

case class InstBranch2(var cond: SSAVariable, var ifTrue: BasicBlock, var ifFalse: BasicBlock) extends Instruction

case class InstSwitch(var opndTy: Type, var opnd: SSAVariable, var defDest: BasicBlock,
                      var cases: Seq[(SSAVariable, BasicBlock)]) extends Instruction

case class InstPhi(var opndTy: Type, var cases: Seq[(BasicBlock, SSAVariable)]) extends Instruction

case class InstCall(var sig: FuncSig, var callee: SSAVariable, var argList: Seq[SSAVariable],
                    var excClause: Option[ExcClause], var keepAlives: Seq[SSAVariable]
                    ) extends AbstractCall with HasExcClause with HasKeepAliveClause

case class InstTailCall(var sig: FuncSig, var callee: SSAVariable, var argList: Seq[SSAVariable]) extends AbstractCall

case class InstRet(var retTy: Type, var retVal: SSAVariable) extends AbstractRet

case class InstRetVoid() extends AbstractRet

case class InstThrow(var excVal: SSAVariable) extends Instruction

case class InstLandingPad() extends Instruction

case class InstExtractValue(var strTy: Type, var index: Int, var opnd: SSAVariable) extends Instruction


case class InstInsertValue(var strTy: Type, var index: Int, var opnd: SSAVariable, var newVal: SSAVariable) extends Instruction

case class InstExtractElement(var vecTy: Type, var indTy: TypeInt,
                              var opnd: SSAVariable, var index: SSAVariable) extends Instruction

case class InstInsertElement(var vecTy: Type, var indTy: TypeInt,
                             var opnd: SSAVariable, var index: SSAVariable, var newVal: SSAVariable) extends Instruction

case class InstShuffleVector(var vecTy: Type, var maskTy: Type,
                             var vec1: SSAVariable, var vec2: SSAVariable, var mask: SSAVariable) extends Instruction

case class InstNew(var allocTy: Type) extends HeapAlloc with FixedAlloc

case class InstNewHybrid(var allocTy: Type, var length: SSAVariable) extends HeapAlloc with HybridAlloc

case class InstAlloca(var allocTy: Type) extends StackAlloc with FixedAlloc

case class InstAllocaHybrid(var allocTy: Type, var length: SSAVariable) extends StackAlloc with HybridAlloc

case class InstGetIRef(var referentTy: Type, var opnd: SSAVariable) extends Instruction

case class InstGetFieldIRef(var referentTy: Type, var index: Int, var opnd: SSAVariable) extends Instruction

case class InstGetElemIRef(var referentTy: Type, var indTy: TypeInt,
                           var opnd: SSAVariable, var index: SSAVariable) extends Instruction

case class InstShiftIRef(var referentTy: Type, var offTy: TypeInt,
                         var opnd: SSAVariable, var offset: SSAVariable) extends Instruction

case class InstGetFixedPartIRef(var referentTy: Type, var opnd: SSAVariable) extends Instruction

case class InstGetVarPartIRef(var referentTy: Type, var opnd: SSAVariable) extends Instruction

case class InstLoad(var ord: MemoryOrder, var referentTy: Type, var loc: SSAVariable) extends Instruction

case class InstStore(var ord: MemoryOrder, var referentTy: Type, var loc: SSAVariable, var newVal: SSAVariable) extends Instruction

case class InstCmpXchg(var weak: Boolean, var ordSucc: MemoryOrder, var ordFail: MemoryOrder, var referentTy: Type,
                       var loc: SSAVariable, var expected: SSAVariable, var desired: SSAVariable)  extends Instruction

case class InstFence(var ord: MemoryOrder) extends Instruction

case class InstAtomicRMW(var ord: MemoryOrder, var op: AtomicRMWOptr,
                         var referentTy: Type, var loc: SSAVariable, var opnd: SSAVariable) extends Instruction

case class InstTrap(var retTy: Type, var excClause: Option[ExcClause], var keepAlives: Seq[SSAVariable]) extends AbstractTrap

case class InstWatchPoint(var wpID: Int, var retTy: Type,
                          var dis: BasicBlock, var ena: BasicBlock, var exc: Option[BasicBlock],
                          var keepAlives: Seq[SSAVariable]) extends AbstractTrap

case class InstCCall(var callConv: CallConv, var funcTy: Type,
                     var sig: FuncSig, var callee: SSAVariable, var argList: Seq[SSAVariable]) extends CallLike

case class InstNewStack(var sig: FuncSig, var callee: SSAVariable, var argList: Seq[SSAVariable],
                        var excClause: Option[ExcClause]) extends CallLike with HasExcClause

case class InstSwapStack(var swappee: SSAVariable, var curStackAction: CurStackAction, var newStackAction: NewStackAction,
                         var excClause: Option[ExcClause], var keepAlives: Seq[SSAVariable]) extends HasExcClause with HasKeepAliveClause

case class InstCommInst(var inst: CommInst, var typeList: Seq[Type], var argList: Seq[SSAVariable],
                        var excClause: Option[ExcClause], var keepAlives: Seq[SSAVariable])
  extends HasTypeList with HasArgList with HasExcClause with HasKeepAliveClause