Add call and call_indirect instructions.

Add a new IndirectCall instruction format which has a value callee as
well as the call arguments.

Define call and call_indirect instructions.
This commit is contained in:
Jakob Stoklund Olesen
2016-10-18 09:48:05 -07:00
parent 8055ac681c
commit e4e1c30f87
8 changed files with 74 additions and 30 deletions

View File

@@ -5,7 +5,7 @@
use ir::{types, instructions};
use ir::{InstructionData, DataFlowGraph, Cursor};
use ir::{Opcode, Type, Inst, Value, Ebb, JumpTable, VariableArgs, FuncRef};
use ir::{Opcode, Type, Inst, Value, Ebb, JumpTable, VariableArgs, SigRef, FuncRef};
use ir::immediates::{Imm64, Uimm8, Ieee32, Ieee64, ImmVector};
use ir::condcodes::{IntCC, FloatCC};

View File

@@ -10,7 +10,7 @@ use std::fmt::{self, Display, Formatter};
use std::str::FromStr;
use std::ops::{Deref, DerefMut};
use ir::{Value, Type, Ebb, JumpTable, FuncRef};
use ir::{Value, Type, Ebb, JumpTable, SigRef, FuncRef};
use ir::immediates::{Imm64, Uimm8, Ieee32, Ieee64, ImmVector};
use ir::condcodes::*;
use ir::types;
@@ -207,6 +207,12 @@ pub enum InstructionData {
second_result: Value,
data: Box<CallData>,
},
IndirectCall {
opcode: Opcode,
ty: Type,
second_result: Value,
data: Box<IndirectCallData>,
},
Return {
opcode: Opcode,
ty: Type,
@@ -342,10 +348,15 @@ pub struct CallData {
pub varargs: VariableArgs,
}
impl Display for CallData {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "TBD({})", self.varargs)
}
/// Payload of an indirect call instruction.
#[derive(Clone, Debug)]
pub struct IndirectCallData {
/// Callee function.
pub arg: Value,
pub sig_ref: SigRef,
/// Dynamically sized array containing call argument values.
pub varargs: VariableArgs,
}
/// Payload of a return instruction.