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.2% of users enabled 2FA.

inst.rs 56.2 KB
Newer Older
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1
// Copyright 2017 The Australian National University
2
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
3 4 5
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
6
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
9 10 11 12 13 14
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

qinsoon's avatar
qinsoon committed
15
use ir::*;
16
use op::*;
qinsoon's avatar
qinsoon committed
17 18 19
use ptr::*;
use types::*;

20
use utils::vec_utils;
21 22 23

use std::fmt;

24
/// Instruction represents a Mu instruction
25
#[derive(Debug, Clone)] // this implements Display
26
pub struct Instruction {
qinsoon's avatar
qinsoon committed
27
    pub hdr: MuEntityHeader,
28
    /// the values this instruction holds
qinsoon's avatar
qinsoon committed
29
    pub value: Option<Vec<P<Value>>>,
30 31
    /// ops field list all the children nodes,
    /// and in Instruction_, the children nodes are referred by indices
32 33
    /// This design makes it easy for the compiler to iterate through all the
    /// children
qinsoon's avatar
qinsoon committed
34
    pub ops: Vec<P<TreeNode>>,
35
    /// used for pattern matching
36
    pub v: Instruction_
37 38
}

39
// Instruction implements MuEntity
qinsoon's avatar
qinsoon committed
40 41
impl_mu_entity!(Instruction);

42
impl Instruction {
43 44 45 46 47 48 49
    pub fn clone_with_id(&self, new_id: MuID) -> Instruction {
        let mut clone = self.clone();
        clone.hdr = self.hdr.clone_with_id(new_id);

        clone
    }

50 51
    // RTMU add new rt instructions to various spec functions here

qinsoon's avatar
qinsoon committed
52
    /// is this instruction the terminal inst of its block?
53 54
    /// Terminal instructions end Mu blocks, and Mu block ends with a terminal
    /// instruction.
55 56 57 58
    pub fn is_terminal_inst(&self) -> bool {
        use inst::Instruction_::*;

        match self.v {
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
            Return(_)
            | ThreadExit
            | Throw(_)
            | TailCall(_)
            | Branch1(_)
            | Branch2 { .. }
            | Watchpoint { .. }
            | WPBranch { .. }
            | Call { .. }
            | CCall { .. }
            | SwapStackExc { .. }
            | SwapStackKill { .. }
            | Switch { .. }
            | ExnInstruction { .. } => true,
            BinOp(_, _, _)
            | BinOpWithStatus(_, _, _, _)
            | CmpOp(_, _, _)
            | ConvOp { .. }
            | ExprCall { .. }
            | ExprCCall { .. }
            | Load { .. }
            | Store { .. }
            | CmpXchg { .. }
            | AtomicRMW { .. }
            | New(_)
            | AllocA(_)
            | NewHybrid(_, _)
            | AllocAHybrid(_, _)
            | NewStack(_)
            | NewThread { .. }
89
            | NewRTThread { .. }
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
90 91 92 93
            | NewFutex
            | DeleteFutex(_)
            | LockFutex(_)
            | UnlockFutex(_)
94
            | AllocAU(_)
95
            | AllocAUHybrid(_,_)
96 97 98 99 100 101 102
            | NewReg(_)
            | DeleteReg(_)
            | rAlloc(_, _)
            | rAllocHybrid(_, _, _)
            | eAlloc(_)
            | eAllocHybrid(_, _)
            | eDelete(_)
103 104 105 106 107 108
            | NotifyThread(_)       // TODO remove - not needed anymore
            | SetPriority(_,_)
            | GetPriority(_)
            | AffinitySet(_,_)
            | AffinityClear(_,_)
            | AffinityIsset(_,_)
109 110
            | GetTime
            | SetTime(_)
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
111 112 113 114 115
            | NewTimer
            | SetTimer(_,_,_,_)
            | CancelTimer(_)
            | DeleteTimer(_)
            | Sleep(_)
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
            | NewFrameCursor(_)
            | GetIRef(_)
            | GetFieldIRef { .. }
            | GetElementIRef { .. }
            | ShiftIRef { .. }
            | GetVarPartIRef { .. }
            | Select { .. }
            | Fence(_)
            | CommonInst_GetThreadLocal
            | CommonInst_SetThreadLocal(_)
            | CommonInst_Pin(_)
            | CommonInst_Unpin(_)
            | CommonInst_GetAddr(_)
            | CommonInst_Tr64IsFp(_)
            | CommonInst_Tr64IsInt(_)
            | CommonInst_Tr64IsRef(_)
            | CommonInst_Tr64FromFp(_)
            | CommonInst_Tr64FromInt(_)
            | CommonInst_Tr64FromRef(_, _)
            | CommonInst_Tr64ToFp(_)
            | CommonInst_Tr64ToInt(_)
            | CommonInst_Tr64ToRef(_)
            | CommonInst_Tr64ToTag(_)
            | Move(_)
            | PrintHex(_)
141
            | PrintBool(_)
142
            | PrintTime(_)
143 144 145 146
            | SetRetval(_)
            | GetVMThreadLocal
            | KillStack(_)
            | CurrentStack
147 148
            | RandF(_,_)
            | RandI(_,_)
149
            | SwapStackExpr { .. } => false,
150 151 152
        }
    }

qinsoon's avatar
qinsoon committed
153
    /// is this instruction a non-terminal instruction of its block?
154 155 156 157
    pub fn is_non_terminal_inst(&self) -> bool {
        !self.is_terminal_inst()
    }

qinsoon's avatar
qinsoon committed
158
    /// does this instruction has side effect?
159 160
    /// An instruction has side effect if it affects something other than its
    /// result operands. e.g. affecting memory, stack, thread, etc.
161 162 163 164 165
    // FIXME: need to check correctness
    pub fn has_side_effect(&self) -> bool {
        use inst::Instruction_::*;

        match self.v {
166 167 168 169 170 171 172 173 174 175
            ExprCall { .. }
            | ExprCCall { .. }
            | Load { .. }
            | Store { .. }
            | CmpXchg { .. }
            | AtomicRMW { .. }
            | New(_)
            | AllocA(_)
            | NewHybrid(_, _)
            | AllocAHybrid(_, _)
176
            | AllocAU(_)
177
            | AllocAUHybrid(_,_)
178 179 180 181 182 183 184
            | NewReg(_)
            | DeleteReg(_)
            | rAlloc(_, _)
            | rAllocHybrid(_,_,_)
            | eAlloc(_)
            | eAllocHybrid(_,_)
            | eDelete(_)
185 186
            | NewStack(_)
            | NewThread { .. }
187
            | NewRTThread { .. }
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
188 189 190 191
            | NewFutex
            | DeleteFutex(_)
            | LockFutex(_)
            | UnlockFutex(_)
192
            | NotifyThread(_)
193 194 195
            | SetPriority(_, _)
            | AffinityClear(_, _)
            | AffinitySet(_, _)
196 197
//            | AffinityZero(_)
            | SetTime(_)
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
198 199 200 201 202
            | NewTimer
            | SetTimer(_,_,_,_)
            | CancelTimer(_)
            | DeleteTimer(_)
            | Sleep(_)
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
            | NewFrameCursor(_)
            | Fence(_)
            | Return(_)
            | ThreadExit
            | Throw(_)
            | TailCall(_)
            | Branch1(_)
            | Branch2 { .. }
            | Watchpoint { .. }
            | WPBranch { .. }
            | Call { .. }
            | CCall { .. }
            | SwapStackExpr { .. }
            | SwapStackExc { .. }
            | SwapStackKill { .. }
            | Switch { .. }
            | ExnInstruction { .. }
            | CommonInst_GetThreadLocal
            | CommonInst_SetThreadLocal(_)
            | CommonInst_Pin(_)
            | CommonInst_Unpin(_)
            | CommonInst_GetAddr(_)
            | PrintHex(_)
226
            | PrintBool(_)
227
            | PrintTime(_)
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
            | SetRetval(_)
            | KillStack(_) => true,
            BinOp(_, _, _)
            | BinOpWithStatus(_, _, _, _)
            | CmpOp(_, _, _)
            | ConvOp { .. }
            | GetIRef(_)
            | GetFieldIRef { .. }
            | GetElementIRef { .. }
            | ShiftIRef { .. }
            | GetVarPartIRef { .. }
            | Select { .. }
            | CommonInst_Tr64IsFp(_)
            | CommonInst_Tr64IsInt(_)
            | CommonInst_Tr64IsRef(_)
            | CommonInst_Tr64FromFp(_)
            | CommonInst_Tr64FromInt(_)
            | CommonInst_Tr64FromRef(_, _)
            | CommonInst_Tr64ToFp(_)
            | CommonInst_Tr64ToInt(_)
            | CommonInst_Tr64ToRef(_)
            | CommonInst_Tr64ToTag(_)
            | Move(_)
            | CurrentStack
252 253
            | GetVMThreadLocal
            | GetPriority(_)
254
            | GetTime
255 256
            | RandF(_,_)
            | RandI(_,_)
257 258
            | AffinityIsset(_, _) => false,
//            | AffinityEqual(_, _)
259 260 261
        }
    }

qinsoon's avatar
qinsoon committed
262 263
    /// can this instruction throw exception?
    /// an instruction with an exceptional branch can throw exception
264 265 266 267
    pub fn is_potentially_excepting_instruction(&self) -> bool {
        use inst::Instruction_::*;

        match self.v {
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
            Watchpoint { .. }
            | Call { .. }
            | CCall { .. }
            | SwapStackExc { .. }
            | ExnInstruction { .. } => true,
            BinOp(_, _, _)
            | BinOpWithStatus(_, _, _, _)
            | CmpOp(_, _, _)
            | ConvOp { .. }
            | ExprCall { .. }
            | ExprCCall { .. }
            | Load { .. }
            | Store { .. }
            | CmpXchg { .. }
            | AtomicRMW { .. }
            | New(_)
            | AllocA(_)
            | NewHybrid(_, _)
            | AllocAHybrid(_, _)
            | NewStack(_)
288
            | AllocAU(_)
289
            | AllocAUHybrid(_,_)
290 291 292 293 294 295 296
            | NewReg(_)
            | DeleteReg(_)
            | rAlloc(_, _)
            | rAllocHybrid(_,_, _)
            | eAlloc(_)
            | eAllocHybrid(_,_)
            | eDelete(_)
297
            | NewThread { .. }
298
            | NewRTThread { .. }
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
299 300 301 302
            | NewFutex
            | DeleteFutex(_)
            | LockFutex(_)
            | UnlockFutex(_)
303
            | NotifyThread(_)
304 305 306 307 308
            | SetPriority(_, _)
            | GetPriority(_)
            | AffinityClear(_, _)
            | AffinitySet(_, _)
            | AffinityIsset(_, _)
309 310
            | GetTime
            | SetTime(_)
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
311 312 313 314 315
            | NewTimer
            | SetTimer(_,_,_,_)
            | CancelTimer(_)
            | DeleteTimer(_)
            | Sleep(_)
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
            | NewFrameCursor(_)
            | GetIRef(_)
            | GetFieldIRef { .. }
            | GetElementIRef { .. }
            | ShiftIRef { .. }
            | GetVarPartIRef { .. }
            | Fence(_)
            | Return(_)
            | ThreadExit
            | Throw(_)
            | TailCall(_)
            | Branch1(_)
            | Branch2 { .. }
            | Select { .. }
            | WPBranch { .. }
            | Switch { .. }
            | CommonInst_GetThreadLocal
            | CommonInst_SetThreadLocal(_)
            | CommonInst_Pin(_)
            | CommonInst_Unpin(_)
            | CommonInst_GetAddr(_)
            | CommonInst_Tr64IsFp(_)
            | CommonInst_Tr64IsInt(_)
            | CommonInst_Tr64IsRef(_)
            | CommonInst_Tr64FromFp(_)
            | CommonInst_Tr64FromInt(_)
            | CommonInst_Tr64FromRef(_, _)
            | CommonInst_Tr64ToFp(_)
            | CommonInst_Tr64ToInt(_)
            | CommonInst_Tr64ToRef(_)
            | CommonInst_Tr64ToTag(_)
            | Move(_)
            | PrintHex(_)
349
            | PrintBool(_)
350
            | PrintTime(_)
351 352 353 354
            | SetRetval(_)
            | GetVMThreadLocal
            | KillStack(_)
            | CurrentStack
355 356
            | RandI(_,_)
            | RandF(_,_)
357 358
            | SwapStackExpr { .. }
            | SwapStackKill { .. } => false,
359 360 361
        }
    }

qinsoon's avatar
qinsoon committed
362
    /// does this instruction have an exceptional clause/branch?
363
    pub fn has_exception_clause(&self) -> bool {
364
        self.is_potentially_excepting_instruction()
365 366
    }

qinsoon's avatar
qinsoon committed
367 368
    /// returns exception target(block ID),
    /// returns None if this instruction does not have exceptional branch
369 370 371
    pub fn get_exception_target(&self) -> Option<MuID> {
        use inst::Instruction_::*;
        match self.v {
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
            Watchpoint { ref resume, .. }
            | Call { ref resume, .. }
            | CCall { ref resume, .. }
            | SwapStackExc { ref resume, .. }
            | ExnInstruction { ref resume, .. } => Some(resume.exn_dest.target.id()),
            BinOp(_, _, _)
            | BinOpWithStatus(_, _, _, _)
            | CmpOp(_, _, _)
            | ConvOp { .. }
            | ExprCall { .. }
            | ExprCCall { .. }
            | Load { .. }
            | Store { .. }
            | CmpXchg { .. }
            | AtomicRMW { .. }
            | New(_)
            | AllocA(_)
            | NewHybrid(_, _)
390
            | AllocAU(_)
391
            | AllocAUHybrid(_,_)
392 393 394 395 396 397 398 399 400 401
            | NewReg(_)
            | DeleteReg(_)
            | rAlloc(_, _)
            | rAllocHybrid(_,_,_)
//            | rAllocT(_)
            | eAlloc(_)
            | eAllocHybrid(_,_)
//            | eAllocT(_)
            | eDelete(_)
//            | eDeleteT(_)
402 403 404
            | AllocAHybrid(_, _)
            | NewStack(_)
            | NewThread { .. }
405
            | NewRTThread { .. }
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
406 407 408 409
            | NewFutex
            | DeleteFutex(_)
            | LockFutex(_)
            | UnlockFutex(_)
410
            | NotifyThread(_)
411 412 413
            | SetPriority(_,_)  // FIXME - Not sure about these
            | GetPriority(_)
            | AffinityClear(_,_)
414
//            | AffinityEqual(_,_)
415 416
            | AffinityIsset(_,_)
            | AffinitySet(_,_)
417 418 419
//            | AffinityZero(_)
            | SetTime(_)
            | GetTime
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
420 421 422 423 424
            | NewTimer
            | SetTimer(_,_,_,_)
            | CancelTimer(_)
            | DeleteTimer(_)
            | Sleep(_)
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
            | NewFrameCursor(_)
            | GetIRef(_)
            | GetFieldIRef { .. }
            | GetElementIRef { .. }
            | ShiftIRef { .. }
            | GetVarPartIRef { .. }
            | Fence(_)
            | Return(_)
            | ThreadExit
            | Throw(_)
            | TailCall(_)
            | Branch1(_)
            | Branch2 { .. }
            | Select { .. }
            | WPBranch { .. }
            | Switch { .. }
            | CommonInst_GetThreadLocal
            | CommonInst_SetThreadLocal(_)
            | CommonInst_Pin(_)
            | CommonInst_Unpin(_)
            | CommonInst_GetAddr(_)
            | CommonInst_Tr64IsFp(_)
            | CommonInst_Tr64IsInt(_)
            | CommonInst_Tr64IsRef(_)
            | CommonInst_Tr64FromFp(_)
            | CommonInst_Tr64FromInt(_)
            | CommonInst_Tr64FromRef(_, _)
            | CommonInst_Tr64ToFp(_)
            | CommonInst_Tr64ToInt(_)
            | CommonInst_Tr64ToRef(_)
            | CommonInst_Tr64ToTag(_)
            | Move(_)
            | PrintHex(_)
458
            | PrintBool(_)
459
            | PrintTime(_)
460 461 462 463
            | SetRetval(_)
            | GetVMThreadLocal
            | KillStack(_)
            | CurrentStack
464 465
            | RandF(_,_)
            | RandI(_,_)
466 467
            | SwapStackExpr { .. }
            | SwapStackKill { .. } => None,
468 469 470
        }
    }

471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
    /// can this instruction throw exception?
    /// (whether or not it containjs a ctach for it)
    pub fn is_potentially_throwing(&self) -> bool {
        use inst::Instruction_::*;

        match self.v {
            // Note: commented out ones are ones where we haven't implemented exceptions yet
            Watchpoint { .. } |
            Call { .. } |
            CCall { .. } |
            SwapStackExc { .. } |
            SwapStackExpr { .. } |
            ExnInstruction { .. } |
            ExprCall { .. } |
            ExprCCall { .. } |
            //Load { .. } |
            //Store { .. } |
            //CmpXchg { .. } |
            //AtomicRMW { .. } |
            //New(_) |
            //NewHybrid(_, _) |
            Throw(_)  => true,

            // BinOp(op, _, _) |
            // BinOpWithStatus(op, _, _, _) if op.may_throw() => true,
            BinOp(_, _, _) |
            BinOpWithStatus(_, _, _, _) |
            CmpOp(_, _, _) |
            ConvOp { .. } |
            AllocA(_) |
            AllocAHybrid(_, _) |
            NewStack(_) |
            NewThread { .. } |
504
            NewRTThread { .. } |
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
505 506 507 508 509
            NewFutex
            | DeleteFutex(_)
            | LockFutex(_)
            | UnlockFutex(_)
            | NotifyThread(_) |
510
            SetPriority(_,_) |
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
            NewFrameCursor(_) |
            GetIRef(_) |
            GetFieldIRef { .. } |
            GetElementIRef { .. } |
            ShiftIRef { .. } |
            GetVarPartIRef { .. } |
            Fence(_) |
            Return(_) |
            ThreadExit |
            TailCall(_) |
            Branch1(_) |
            Branch2 { .. } |
            Select { .. } |
            WPBranch { .. } |
            Switch { .. } |
            CommonInst_GetThreadLocal |
            CommonInst_SetThreadLocal(_) |
            CommonInst_Pin(_) |
            CommonInst_Unpin(_) |
            CommonInst_GetAddr(_) |
            CommonInst_Tr64IsFp(_) |
            CommonInst_Tr64IsInt(_) |
            CommonInst_Tr64IsRef(_) |
            CommonInst_Tr64FromFp(_) |
            CommonInst_Tr64FromInt(_) |
            CommonInst_Tr64FromRef(_, _) |
            CommonInst_Tr64ToFp(_) |
            CommonInst_Tr64ToInt(_) |
            CommonInst_Tr64ToRef(_) |
            CommonInst_Tr64ToTag(_) |
            Move(_) |
            PrintHex(_) |
543
            PrintBool(_) |
544
            PrintTime(_) |
545
            SetRetval(_) |
qinsoon's avatar
qinsoon committed
546
            GetVMThreadLocal |
547 548 549 550 551 552 553 554
            KillStack(_) |
            CurrentStack |
            SwapStackKill { .. } => false,

            _ => false
        }
    }

555
    fn debug_str(&self, ops: &Vec<P<TreeNode>>) -> String {
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
556 557 558 559
        match &self.v {
            &Instruction_::BinOp(op, op1, op2) => {
                format!("{}<{}> {} {}", op, ops[op1].ty(), ops[op1], ops[op2])
            }
560 561 562 563 564 565 566 567
            &Instruction_::BinOpWithStatus(op, status, op1, op2) => format!(
                "{}{}<{}> {} {}",
                op,
                status,
                ops[op1].ty(),
                ops[op1],
                ops[op2]
            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
568 569 570 571 572 573 574
            &Instruction_::CmpOp(op, op1, op2) => {
                format!("{}<{}> {} {}", op, ops[op1].ty(), ops[op1], ops[op2])
            }
            &Instruction_::ConvOp {
                operation,
                ref from_ty,
                ref to_ty,
575 576 577 578 579
                operand
            } => format!(
                "{} <{} {}> {}",
                operation, from_ty, to_ty, ops[operand]
            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
            &Instruction_::ExprCall { ref data, is_abort } => {
                if is_abort {
                    panic!("ABORT is not supported");
                }
                format!("CALL{}", data.debug_str(ops))
            }
            &Instruction_::ExprCCall { ref data, is_abort } => {
                if is_abort {
                    panic!("ABORT is not supported");
                }
                format!("CCALL{}", data.debug_str(ops))
            }
            &Instruction_::Load {
                is_ptr,
                mem_loc,
595
                order
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
596 597 598 599 600 601 602 603 604 605 606 607 608 609
            } => {
                let ptr = select_value!(is_ptr, " PTR", "");
                format!(
                    "LOAD{} {}<{}> {}",
                    ptr,
                    order,
                    ops[mem_loc].ty().get_referent_ty().unwrap(),
                    ops[mem_loc]
                )
            }
            &Instruction_::Store {
                value,
                is_ptr,
                mem_loc,
610
                order
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628
            } => {
                let ptr = select_value!(is_ptr, " PTR", "");
                format!(
                    "STORE{} {}<{}> {} {}",
                    ptr,
                    order,
                    ops[mem_loc].ty().get_referent_ty().unwrap(),
                    ops[mem_loc],
                    ops[value]
                )
            }
            &Instruction_::CmpXchg {
                is_ptr,
                is_weak,
                success_order,
                fail_order,
                mem_loc,
                expected_value,
629
                desired_value
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649
            } => {
                let ptr = select_value!(is_ptr, " PTR", "");
                let weak = select_value!(is_weak, " WEAK", "");
                format!(
                    "CMPXCHG{}{} {} {}<{}> {} {} {}",
                    ptr,
                    weak,
                    success_order,
                    fail_order,
                    ops[mem_loc].ty().get_referent_ty().unwrap(),
                    ops[mem_loc],
                    ops[expected_value],
                    ops[desired_value]
                )
            }
            &Instruction_::AtomicRMW {
                is_ptr,
                order,
                op,
                mem_loc,
650
                value
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670
            } => {
                let ptr = select_value!(is_ptr, " PTR", "");
                format!(
                    "ATOMICRMW{} {} {}<{}> {} {}",
                    ptr,
                    order,
                    op,
                    ops[mem_loc].ty().get_referent_ty().unwrap(),
                    ops[mem_loc],
                    ops[value]
                )
            }
            &Instruction_::New(ref ty) => format!("NEW<{}>", ty),
            &Instruction_::AllocA(ref ty) => format!("ALLOCA<{}>", ty),
            &Instruction_::NewHybrid(ref ty, len) => {
                format!("NEWHYBRID<{} {}> {}", ty, ops[len].ty(), ops[len])
            }
            &Instruction_::AllocAHybrid(ref ty, len) => {
                format!("ALLOCAHYBRID<{} {}> {}", ty, ops[len].ty(), ops[len])
            }
671 672 673 674 675
            &Instruction_::NewStack(func) => format!(
                "COMMINST @uvm.new_stack<[{}]>({})",
                ops[func].ty().get_sig().unwrap(),
                ops[func]
            ),
676 677 678 679 680 681 682 683 684
            &Instruction_::NewReg(size) => {
                format!("COMMINST @uvm.new_region({})", ops[size])
            }
            &Instruction_::DeleteReg(regref) => {
                format!("COMMINST @uvm.delete_region({})", ops[regref])
            }
            &Instruction_::AllocAU(ref ty) => {
                format!("COMMINST @uvm.AllocAU({})", ty.id())
            }
685 686 687
            &Instruction_::AllocAUHybrid(ref ty, var_len) => {
                format!("COMMINST @uvm.AllocAUHybrid({}, {})", ty.id(), ops[var_len])
            }
688 689 690
            &Instruction_::rAlloc(regref, ref ty) => {
                format!("COMMINST @uvm.rAlloc({}, {})", ops[regref], ty.id())
            }
691 692 693 694 695 696
            &Instruction_::rAllocHybrid(regref, ref ty, var_len) => format!(
                "COMMINST @uvm.rAllocHybrid({}, {}, {})",
                ops[regref],
                ty.id(),
                ops[var_len]
            ),
697 698 699 700 701 702 703
            //            &Instruction_::rAllocT(regref, ty) => format!(
            //                "COMMINST @uvm.rAllocT({}, {})",
            //                ops[regref],
            //                ops[ty]
            //            ),
            &Instruction_::eAlloc(ref ty) => {
                format!("COMMINST @uvm.eAlloc({})", ty.id())
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
704
            },
705
            &Instruction_::eAllocHybrid(ref ty, var_len) => format!(
706 707 708 709
                "COMMINST @uvm.eAllocHybrid({}, {})",
                ty.id(),
                ops[var_len]
            ),
710 711 712 713 714 715
            //            &Instruction_::eAllocT( ty) => format!(
            //                "COMMINST @uvm.eAllocT({})",
            //                ops[ty]
            //            ),
            &Instruction_::eDelete(obj) => {
                format!("COMMINST @uvm.eDelete({})", ops[obj])
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
716
            },
717 718 719 720
            //            &Instruction_::eDeleteT( obj) => format!(
            //                "COMMINST @uvm.eDeleteT({})",
            //                ops[obj]
            //            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
721 722 723 724
            &Instruction_::NewThread {
                stack,
                thread_local,
                is_exception,
725
                ref args
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
726
            } => {
727 728
                let new_stack_clause =
                    format_new_stack_clause(is_exception, args, ops);
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
729 730 731 732
                let thread_local = thread_local
                    .map(|t| format!(" THREADLOCAL({})", ops[t]))
                    .unwrap_or("".to_string());
                format!(
733
                    "NEWTHREAD {}{} {}",
734
                    ops[stack], thread_local, new_stack_clause,
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
735
                )
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756
            },

            &Instruction_::NewFutex => format!("NEWFUTEX"),
            &Instruction_::DeleteFutex(futexref) => {
                format!(
                    "DELETEFUTEX {}",
                    ops[futexref]
                )
            },
            &Instruction_::LockFutex(futexref) => {
                format!(
                    "LockFUTEX {}",
                    ops[futexref]
                )
            },
            &Instruction_::UnlockFutex(futexref) => {
                format!(
                    "UNLOCKFUTEX {}",
                    ops[futexref]
                )
            },
757 758 759 760 761 762

            &Instruction_::NewRTThread {
                attr,
                stack,
                thread_local,
                is_exception,
763
                ref args
764
            } => {
765 766
                let new_stack_clause =
                    format_new_stack_clause(is_exception, args, ops);
767 768 769 770 771 772 773
                let thread_local = thread_local
                    .map(|t| format!(" THREADLOCAL({})", ops[t]))
                    .unwrap_or("".to_string());
                format!(
                    "NEWRTTHREAD {}, {}, {}, {}",
                    ops[attr], ops[stack], thread_local, new_stack_clause,
                )
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
774
            },
775

776 777
            &Instruction_::NotifyThread(thread) => {
                format!("COMMINST @uvm.notifythread({})", ops[thread])
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
778
            },
779 780 781 782 783 784 785
            &Instruction_::SetPriority(thread, priority) => format!(
                "COMMINST @uvm.setpriority({}, {})",
                ops[thread], ops[priority]
            ),
            &Instruction_::GetPriority(thread) => {
                format!("COMMINST @uvm.getpriority({})", ops[thread])
            }
786 787 788 789 790 791 792 793 794 795 796 797
            &Instruction_::AffinityClear(thread, cpu) => format!(
                "COMMINST @uvm.affinityclear({}, {})",
                ops[thread], ops[cpu]
            ),
            &Instruction_::AffinitySet(thread, cpu) => format!(
                "COMMINST @uvm.affinityset({}, {})",
                ops[thread], ops[cpu]
            ),
            &Instruction_::AffinityIsset(thread, cpu) => format!(
                "COMMINST @uvm.affinityisset({}, {})",
                ops[thread], ops[cpu]
            ),
798 799 800 801 802 803 804
            &Instruction_::GetTime => format!(
                "COMMINST @uvm.gettime()",
            ),
            &Instruction_::SetTime(time) => format!(
                "COMMINST @uvm.settime({})",
                ops[time]
            ),
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826
            &Instruction_::NewTimer => format!(
                "COMMINST @uvm.newtimer"
            ),
            &Instruction_::SetTimer(tmr, tm, func, args) => format!(
                "COMMINST @uvm.settimer({}, {}, {}, {})",
                ops[tmr],
                ops[tm],
                ops[func],
                ops[args]
            ),
            &Instruction_::CancelTimer(tmr) => format!(
                "COMMINST @uvm.canceltimer({})",
                ops[tmr]
            ),
            &Instruction_::DeleteTimer(tmr) => format!(
                "COMMINST @uvm.deletetimer({})",
                ops[tmr]
            ),
            &Instruction_::Sleep(dur) => format!(
                "COMMINST @uvm.sleep_ns({})",
                ops[dur]
            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
827 828 829
            &Instruction_::NewFrameCursor(stack) => {
                format!("COMMINST @uvm.meta.new_cursor({})", ops[stack])
            }
830 831 832 833 834
            &Instruction_::GetIRef(reference) => format!(
                "GETIREF<{}> {}",
                ops[reference].ty().get_referent_ty().unwrap(),
                ops[reference]
            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
835 836 837
            &Instruction_::GetFieldIRef {
                is_ptr,
                base,
838
                index
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
839 840 841 842 843 844 845 846 847 848 849 850 851
            } => {
                let ptr = select_value!(is_ptr, " PTR", "");
                format!(
                    "GETFIELDIREF{}<{} {}> {}",
                    ptr,
                    ops[base].ty().get_referent_ty().unwrap(),
                    index,
                    ops[base]
                )
            }
            &Instruction_::GetElementIRef {
                is_ptr,
                base,
852
                index
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
853 854 855 856 857 858 859 860 861 862 863 864 865 866
            } => {
                let ptr = select_value!(is_ptr, " PTR", "");
                format!(
                    "GETELEMIREF{}<{} {}>{} {}",
                    ptr,
                    ops[base].ty().get_referent_ty().unwrap(),
                    ops[index].ty(),
                    ops[base],
                    ops[index]
                )
            }
            &Instruction_::ShiftIRef {
                is_ptr,
                base,
867
                offset
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
868 869 870
            } => {
                let ptr = select_value!(is_ptr, " PTR", "");
                format!(
871
                    "SHIFTIREF{}<{} {}>{} {}",
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899
                    ptr,
                    ops[base].ty().get_referent_ty().unwrap(),
                    ops[offset].ty(),
                    ops[base],
                    ops[offset]
                )
            }
            &Instruction_::GetVarPartIRef { is_ptr, base } => {
                let ptr = select_value!(is_ptr, " PTR", "");
                format!(
                    "GETVARPARTIREF{}<{}> {}",
                    ptr,
                    ops[base].ty().get_referent_ty().unwrap(),
                    ops[base]
                )
            }

            &Instruction_::Fence(order) => format!("FENCE {}", order),

            &Instruction_::Return(ref vals) => {
                if vals.len() == 0 {
                    format!("RET")
                } else if vals.len() == 1 {
                    format!("RET {}", ops[vals[0]])
                } else {
                    format!("RET ({})", op_vector_str(vals, ops))
                }
            }
900 901 902 903 904 905 906 907 908
            &Instruction_::ThreadExit => {
                "COMMINST @uvm.thread_exit".to_string()
            }
            &Instruction_::CurrentStack => {
                "COMMINST @uvm.current_stack".to_string()
            }
            &Instruction_::KillStack(s) => {
                format!("COMMINST @uvm.kill_stack({})", ops[s])
            }
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
909
            &Instruction_::Throw(exn_obj) => format!("THROW {}", ops[exn_obj]),
910 911 912 913 914 915
            &Instruction_::TailCall(ref call) => {
                format!("TAILCALL{}", call.debug_str(ops))
            }
            &Instruction_::Branch1(ref dest) => {
                format!("BRANCH {}", dest.debug_str(ops))
            }
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
916 917 918 919 920
            &Instruction_::Branch2 {
                cond,
                ref true_dest,
                ref false_dest,
                ..
921 922 923 924 925 926
            } => format!(
                "BRANCH2 {} {} {}",
                ops[cond],
                true_dest.debug_str(ops),
                false_dest.debug_str(ops)
            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
927 928 929
            &Instruction_::Select {
                cond,
                true_val,
930
                false_val
931 932 933 934 935 936 937 938
            } => format!(
                "SELECT<{} {}> {} {} {}",
                ops[cond].ty(),
                ops[true_val].ty(),
                ops[cond],
                ops[true_val],
                ops[false_val]
            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
939 940 941
            &Instruction_::Watchpoint {
                id,
                ref disable_dest,
942
                ref resume
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
943 944 945 946 947 948 949 950 951 952 953 954 955 956
            } => {
                match id {
                    Some(id) => {
                        format!(
                            // TODO: WPEXC should be optional
                            "WATCHPOINT {}<{}> {} {} WPEXC({})",
                            id,
                            format_value_types(&self.value),
                            disable_dest.as_ref().unwrap().debug_str(ops),
                            resume.normal_dest.debug_str(ops),
                            resume.exn_dest.debug_str(ops)
                        )
                    }
                    //TRAP < Ts > excClause keepAliveClause
957 958 959 960
                    None => format!(
                        "TRAP<{}> {}",
                        format_value_types(&self.value),
                        resume.debug_str(ops)
961
                    )
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
962 963 964 965 966
                }
            }
            &Instruction_::WPBranch {
                wp,
                ref disable_dest,
967
                ref enable_dest
968 969 970 971 972 973
            } => format!(
                "WPBRANCH {} {} {}",
                wp,
                disable_dest.debug_str(ops),
                enable_dest.debug_str(ops)
            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
974 975
            &Instruction_::Call {
                ref data,
976 977 978 979
                ref resume
            } => {
                format!("CALL{} {}", data.debug_str(ops), resume.debug_str(ops))
            }
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
980 981
            &Instruction_::CCall {
                ref data,
982 983 984 985 986 987
                ref resume
            } => format!(
                "CCALL{} {}",
                data.debug_str(ops),
                resume.debug_str(ops)
            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
988 989 990
            &Instruction_::SwapStackExpr {
                stack,
                is_exception,
991
                ref args
992 993 994 995 996 997
            } => format!(
                "SWAPSTACK {} RET_WITH<{}> {}",
                ops[stack],
                format_value_types(&self.value),
                format_new_stack_clause(is_exception, args, ops)
            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
998 999 1000 1001
            &Instruction_::SwapStackExc {
                stack,
                is_exception,
                ref args,
1002
                ref resume
1003 1004 1005 1006 1007 1008 1009
            } => format!(
                "SWAPSTACK {} RET_WITH<{}> {} {}",
                ops[stack],
                format_value_types(&self.value),
                format_new_stack_clause(is_exception, args, ops),
                resume.debug_str(ops)
            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1010 1011 1012 1013

            &Instruction_::SwapStackKill {
                stack,
                is_exception,
1014
                ref args
1015 1016 1017 1018 1019
            } => format!(
                "SWAPSTACK {} KILL_OLD {}",
                ops[stack],
                format_new_stack_clause(is_exception, args, ops)
            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1020 1021 1022 1023

            &Instruction_::Switch {
                cond,
                ref default,
1024
                ref branches
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034
            } => {
                //SWITCH < T > opnd default { ( value dest ) rep }
                let mut ret = format!(
                    "SWITCH<{}> {} {} {{",
                    ops[cond].ty(),
                    ops[cond],
                    default.debug_str(ops)
                );
                for i in 0..branches.len() {
                    let (op, ref dest) = branches[i];
1035 1036 1037
                    ret.push_str(
                        format!("{} {}", ops[op], dest.debug_str(ops)).as_str()
                    );
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1038 1039 1040 1041
                    if i != branches.len() - 1 {
                        ret.push_str(" ");
                    }
                }
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1042
                ret.push_str("}");
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1043 1044 1045 1046 1047

                ret
            }
            &Instruction_::ExnInstruction {
                ref inner,
1048
                ref resume
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1049 1050 1051
            } => format!("{} {}", inner.debug_str(ops), resume.debug_str(ops)),

            // common inst
1052 1053 1054
            &Instruction_::CommonInst_GetThreadLocal => {
                format!("COMMINST @uvm.get_threadlocal")
            }
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1055 1056 1057 1058
            &Instruction_::CommonInst_SetThreadLocal(op) => {
                format!("COMMINST @uvm.set_threadlocal({})", ops[op])
            }

1059 1060 1061 1062 1063 1064 1065 1066 1067 1068
            &Instruction_::CommonInst_Pin(op) => format!(
                "COMMINST @uvm.native.pin<{}>({})",
                ops[op].ty(),
                ops[op]
            ),
            &Instruction_::CommonInst_Unpin(op) => format!(
                "COMMINST @uvm.native.unpin<{}>({})",
                ops[op].ty(),
                ops[op]
            ),
1069 1070 1071 1072 1073
            &Instruction_::CommonInst_GetAddr(op) => format!(
                "COMMINST @uvm.native.get_addr<{}>({})",
                ops[op].ty(),
                ops[op]
            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089
            // Tagerf64
            &Instruction_::CommonInst_Tr64IsFp(op) => {
                format!("COMMINST @uvm.tr64.is_fp({})", ops[op])
            }
            &Instruction_::CommonInst_Tr64IsInt(op) => {
                format!("COMMINST @uvm.tr64.is_int({})", ops[op])
            }
            &Instruction_::CommonInst_Tr64IsRef(op) => {
                format!("COMMINST @uvm.tr64.is_ref({})", ops[op])
            }
            &Instruction_::CommonInst_Tr64FromFp(op) => {
                format!("COMMINST @uvm.tr64.from_fp({})", ops[op])
            }
            &Instruction_::CommonInst_Tr64FromInt(op) => {
                format!("COMMINST @uvm.tr64.from_int({})", ops[op])
            }
1090 1091 1092 1093
            &Instruction_::CommonInst_Tr64FromRef(op1, op2) => format!(
                "COMMINST @uvm.tr64.from_ref({} {})",
                ops[op1], ops[op2]
            ),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107
            &Instruction_::CommonInst_Tr64ToFp(op) => {
                format!("COMMINST @uvm.tr64.to_fp({})", ops[op])
            }
            &Instruction_::CommonInst_Tr64ToInt(op) => {
                format!("COMMINST @uvm.tr64.to_int({})", ops[op])
            }
            &Instruction_::CommonInst_Tr64ToRef(op) => {
                format!("COMMINST @uvm.tr64.to_ref({})", ops[op])
            }
            &Instruction_::CommonInst_Tr64ToTag(op) => {
                format!("COMMINST @uvm.tr64.to_tag({})", ops[op])
            }

            // move
1108 1109 1110
            &Instruction_::Move(from) => {
                format!("MOVE<{}> {}", ops[from].ty(), ops[from])
            }
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1111
            // print hex
1112 1113 1114 1115 1116 1117
            &Instruction_::PrintHex(i) => {
                format!("PRINTHEX<{}> {}", ops[i].ty(), ops[i])
            }
            &Instruction_::PrintBool(i) => {
                format!("PRINTBOOL<{}> {}", ops[i].ty(), ops[i])
            }
1118 1119 1120
            &Instruction_::PrintTime(i) => {
                format!("PRINTTIME<{}> {}", ops[i].ty(), ops[i])
            }
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1121
            // set retval
qinsoon's avatar
qinsoon committed
1122
            &Instruction_::SetRetval(val) => format!("SETRETVAL {}", ops[val]),
1123 1124
            &Instruction_::RandI(min, max) => format!("RandI ({}, {})", ops[min], ops[max]),
            &Instruction_::RandF(min, max) => format!("RandF ({}, {})", ops[min], ops[max]),
qinsoon's avatar
qinsoon committed
1125
            // get vm thread local
1126
            &Instruction_::GetVMThreadLocal => format!("GETVMTHREADLOCAL")
1127

Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1128
        }
1129 1130 1131
    }
}

1132 1133
const PRINT_INST_NAME: bool = false;

1134 1135
impl fmt::Display for Instruction {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1136
        let ref ops = self.ops;
1137
        let value = match &self.value {
1138 1139 1140
            &Some(ref v) if v.len() == 0 => format!(""),
            &Some(ref v) if v.len() == 1 => format!("{} = ", v[0]),
            &Some(ref v) => format!("({}) = ", vec_utils::as_str_sp(&v)),
1141
            &None => format!("")
1142 1143 1144
        };

        if PRINT_INST_NAME {
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1145
            write!(f, "{}[{}]{}", value, self.hdr, self.debug_str(ops))
1146
        } else {
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1147
            write!(f, "{}{}", value, self.debug_str(ops))
1148 1149 1150 1151
        }
    }
}

qinsoon's avatar
qinsoon committed
1152
/// Instruction_ is used for pattern matching for Instruction
qinsoon's avatar
qinsoon committed
1153
#[allow(non_camel_case_types)]
1154
#[derive(Debug, Clone)]
1155 1156
pub enum Instruction_ {
    // non-terminal instruction
qinsoon's avatar
qinsoon committed
1157
    /// binary operations
qinsoon's avatar
qinsoon committed
1158
    BinOp(BinOp, OpIndex, OpIndex),
qinsoon's avatar
qinsoon committed
1159
    /// binary operations with status flag (overflow, sign, etc. )
qinsoon's avatar
qinsoon committed
1160 1161
    BinOpWithStatus(BinOp, BinOpStatus, OpIndex, OpIndex),

qinsoon's avatar
qinsoon committed
1162
    /// comparison operations
1163
    CmpOp(CmpOp, OpIndex, OpIndex),
qinsoon's avatar
qinsoon committed
1164 1165

    /// conversion operations (casting)
qinsoon's avatar
qinsoon committed
1166
    ConvOp {
1167 1168 1169
        operation: ConvOp,
        from_ty: P<MuType>,
        to_ty: P<MuType>,
1170
        operand: OpIndex
1171
    },
qinsoon's avatar
qinsoon committed
1172

1173 1174 1175
    /// a non-terminating Call instruction (the call does not have an
    /// exceptional branch) This instruction is not in the Mu spec, but is
    /// documented in the HOL formal spec
qinsoon's avatar
qinsoon committed
1176
    ExprCall {
1177
        data: CallData,
1178
        is_abort: bool // T to abort, F to rethrow
1179
    },
qinsoon's avatar
qinsoon committed
1180

1181 1182 1183
    /// a non-terminating CCall instruction (the call does not have an
    /// exceptional branch) This instruction is not in the Mu spec, but is
    /// documented in the HOL formal spec
1184 1185
    ExprCCall {
        data: CallData,
1186
        is_abort: bool
1187
    },