Use 'varargs' consistently for VariableArgs members.
The meta code generators need to be able to infer these too.
This commit is contained in:
@@ -290,10 +290,10 @@ class OperandKind(object):
|
|||||||
instruction.
|
instruction.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, doc):
|
def __init__(self, name, doc, default_member=None):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.__doc__ = doc
|
self.__doc__ = doc
|
||||||
self.default_member = None
|
self.default_member = default_member
|
||||||
# The camel-cased name of an operand kind is also the Rust type used to
|
# The camel-cased name of an operand kind is also the Rust type used to
|
||||||
# represent it.
|
# represent it.
|
||||||
self.camel_name = camel_case(name)
|
self.camel_name = camel_case(name)
|
||||||
@@ -334,7 +334,8 @@ variable_args = OperandKind(
|
|||||||
Use this to represent arguemtns passed to a function call, arguments
|
Use this to represent arguemtns passed to a function call, arguments
|
||||||
passed to an extended basic block, or a variable number of results
|
passed to an extended basic block, or a variable number of results
|
||||||
returned from an instruction.
|
returned from an instruction.
|
||||||
""")
|
""",
|
||||||
|
default_member='varargs')
|
||||||
|
|
||||||
|
|
||||||
# Instances of immediate operand types are provided in the
|
# Instances of immediate operand types are provided in the
|
||||||
@@ -348,8 +349,7 @@ class ImmediateKind(OperandKind):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, doc, default_member='imm'):
|
def __init__(self, name, doc, default_member='imm'):
|
||||||
super(ImmediateKind, self).__init__(name, doc)
|
super(ImmediateKind, self).__init__(name, doc, default_member)
|
||||||
self.default_member = default_member
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'ImmediateKind({})'.format(self.name)
|
return 'ImmediateKind({})'.format(self.name)
|
||||||
@@ -363,8 +363,7 @@ class EntityRefKind(OperandKind):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, doc, default_member=None):
|
def __init__(self, name, doc, default_member=None):
|
||||||
super(EntityRefKind, self).__init__(name, doc)
|
super(EntityRefKind, self).__init__(name, doc, default_member or name)
|
||||||
self.default_member = default_member or name
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'EntityRefKind({})'.format(self.name)
|
return 'EntityRefKind({})'.format(self.name)
|
||||||
|
|||||||
@@ -283,15 +283,15 @@ impl Display for TernaryOverflowData {
|
|||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct JumpData {
|
pub struct JumpData {
|
||||||
pub destination: Ebb,
|
pub destination: Ebb,
|
||||||
pub arguments: VariableArgs,
|
pub varargs: VariableArgs,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for JumpData {
|
impl Display for JumpData {
|
||||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||||
if self.arguments.is_empty() {
|
if self.varargs.is_empty() {
|
||||||
write!(f, "{}", self.destination)
|
write!(f, "{}", self.destination)
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{}({})", self.destination, self.arguments)
|
write!(f, "{}({})", self.destination, self.varargs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -302,14 +302,14 @@ impl Display for JumpData {
|
|||||||
pub struct BranchData {
|
pub struct BranchData {
|
||||||
pub arg: Value,
|
pub arg: Value,
|
||||||
pub destination: Ebb,
|
pub destination: Ebb,
|
||||||
pub arguments: VariableArgs,
|
pub varargs: VariableArgs,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for BranchData {
|
impl Display for BranchData {
|
||||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||||
try!(write!(f, "{}, {}", self.arg, self.destination));
|
try!(write!(f, "{}, {}", self.arg, self.destination));
|
||||||
if !self.arguments.is_empty() {
|
if !self.varargs.is_empty() {
|
||||||
try!(write!(f, "({})", self.arguments));
|
try!(write!(f, "({})", self.varargs));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -322,12 +322,12 @@ pub struct CallData {
|
|||||||
second_result: Value,
|
second_result: Value,
|
||||||
|
|
||||||
// Dynamically sized array containing call argument values.
|
// Dynamically sized array containing call argument values.
|
||||||
pub args: VariableArgs,
|
pub varargs: VariableArgs,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for CallData {
|
impl Display for CallData {
|
||||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||||
write!(f, "TBD({})", self.args)
|
write!(f, "TBD({})", self.varargs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,7 +335,7 @@ impl Display for CallData {
|
|||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ReturnData {
|
pub struct ReturnData {
|
||||||
// Dynamically sized array containing return values.
|
// Dynamically sized array containing return values.
|
||||||
pub args: VariableArgs,
|
pub varargs: VariableArgs,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InstructionData {
|
impl InstructionData {
|
||||||
@@ -346,7 +346,7 @@ impl InstructionData {
|
|||||||
ty: return_type,
|
ty: return_type,
|
||||||
data: Box::new(CallData {
|
data: Box::new(CallData {
|
||||||
second_result: NO_VALUE,
|
second_result: NO_VALUE,
|
||||||
args: VariableArgs::new(),
|
varargs: VariableArgs::new(),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -364,10 +364,10 @@ impl InstructionData {
|
|||||||
pub fn analyze_branch<'a>(&'a self) -> BranchInfo<'a> {
|
pub fn analyze_branch<'a>(&'a self) -> BranchInfo<'a> {
|
||||||
match self {
|
match self {
|
||||||
&InstructionData::Jump { ref data, .. } => {
|
&InstructionData::Jump { ref data, .. } => {
|
||||||
BranchInfo::SingleDest(data.destination, &data.arguments)
|
BranchInfo::SingleDest(data.destination, &data.varargs)
|
||||||
}
|
}
|
||||||
&InstructionData::Branch { ref data, .. } => {
|
&InstructionData::Branch { ref data, .. } => {
|
||||||
BranchInfo::SingleDest(data.destination, &data.arguments)
|
BranchInfo::SingleDest(data.destination, &data.varargs)
|
||||||
}
|
}
|
||||||
&InstructionData::BranchTable { table, .. } => BranchInfo::Table(table),
|
&InstructionData::BranchTable { table, .. } => BranchInfo::Table(table),
|
||||||
_ => BranchInfo::NotABranch,
|
_ => BranchInfo::NotABranch,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ pub fn jump(func: &mut Function, dest: Ebb) -> Inst {
|
|||||||
ty: types::VOID,
|
ty: types::VOID,
|
||||||
data: Box::new(JumpData {
|
data: Box::new(JumpData {
|
||||||
destination: dest,
|
destination: dest,
|
||||||
arguments: VariableArgs::new(),
|
varargs: VariableArgs::new(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ pub fn branch(func: &mut Function, dest: Ebb) -> Inst {
|
|||||||
data: Box::new(BranchData {
|
data: Box::new(BranchData {
|
||||||
arg: NO_VALUE,
|
arg: NO_VALUE,
|
||||||
destination: dest,
|
destination: dest,
|
||||||
arguments: VariableArgs::new(),
|
varargs: VariableArgs::new(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,6 @@ pub fn ret(func: &mut Function) -> Inst {
|
|||||||
func.dfg.make_inst(InstructionData::Return {
|
func.dfg.make_inst(InstructionData::Return {
|
||||||
opcode: Opcode::Return,
|
opcode: Opcode::Return,
|
||||||
ty: types::VOID,
|
ty: types::VOID,
|
||||||
data: Box::new(ReturnData { args: VariableArgs::new() }),
|
data: Box::new(ReturnData { varargs: VariableArgs::new() }),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,10 +201,10 @@ fn write_instruction(w: &mut Write,
|
|||||||
BranchTable { arg, table, .. } => writeln!(w, " {}, {}", arg, table),
|
BranchTable { arg, table, .. } => writeln!(w, " {}, {}", arg, table),
|
||||||
Call { ref data, .. } => writeln!(w, " {}", data),
|
Call { ref data, .. } => writeln!(w, " {}", data),
|
||||||
Return { ref data, .. } => {
|
Return { ref data, .. } => {
|
||||||
if data.args.is_empty() {
|
if data.varargs.is_empty() {
|
||||||
writeln!(w, "")
|
writeln!(w, "")
|
||||||
} else {
|
} else {
|
||||||
writeln!(w, " {}", data.args)
|
writeln!(w, " {}", data.varargs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,21 +145,21 @@ impl Context {
|
|||||||
|
|
||||||
InstructionData::Jump { ref mut data, .. } => {
|
InstructionData::Jump { ref mut data, .. } => {
|
||||||
try!(self.map.rewrite_ebb(&mut data.destination, loc));
|
try!(self.map.rewrite_ebb(&mut data.destination, loc));
|
||||||
try!(self.map.rewrite_values(&mut data.arguments, loc));
|
try!(self.map.rewrite_values(&mut data.varargs, loc));
|
||||||
}
|
}
|
||||||
|
|
||||||
InstructionData::Branch { ref mut data, .. } => {
|
InstructionData::Branch { ref mut data, .. } => {
|
||||||
try!(self.map.rewrite_value(&mut data.arg, loc));
|
try!(self.map.rewrite_value(&mut data.arg, loc));
|
||||||
try!(self.map.rewrite_ebb(&mut data.destination, loc));
|
try!(self.map.rewrite_ebb(&mut data.destination, loc));
|
||||||
try!(self.map.rewrite_values(&mut data.arguments, loc));
|
try!(self.map.rewrite_values(&mut data.varargs, loc));
|
||||||
}
|
}
|
||||||
|
|
||||||
InstructionData::Call { ref mut data, .. } => {
|
InstructionData::Call { ref mut data, .. } => {
|
||||||
try!(self.map.rewrite_values(&mut data.args, loc));
|
try!(self.map.rewrite_values(&mut data.varargs, loc));
|
||||||
}
|
}
|
||||||
|
|
||||||
InstructionData::Return { ref mut data, .. } => {
|
InstructionData::Return { ref mut data, .. } => {
|
||||||
try!(self.map.rewrite_values(&mut data.args, loc));
|
try!(self.map.rewrite_values(&mut data.varargs, loc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1104,7 +1104,7 @@ impl<'a> Parser<'a> {
|
|||||||
ty: VOID,
|
ty: VOID,
|
||||||
data: Box::new(JumpData {
|
data: Box::new(JumpData {
|
||||||
destination: ebb_num,
|
destination: ebb_num,
|
||||||
arguments: args,
|
varargs: args,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1119,7 +1119,7 @@ impl<'a> Parser<'a> {
|
|||||||
data: Box::new(BranchData {
|
data: Box::new(BranchData {
|
||||||
arg: ctrl_arg,
|
arg: ctrl_arg,
|
||||||
destination: ebb_num,
|
destination: ebb_num,
|
||||||
arguments: args,
|
varargs: args,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1178,7 +1178,7 @@ impl<'a> Parser<'a> {
|
|||||||
InstructionData::Return {
|
InstructionData::Return {
|
||||||
opcode: opcode,
|
opcode: opcode,
|
||||||
ty: VOID,
|
ty: VOID,
|
||||||
data: Box::new(ReturnData { args: args }),
|
data: Box::new(ReturnData { varargs: args }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InstructionFormat::BranchTable => {
|
InstructionFormat::BranchTable => {
|
||||||
|
|||||||
Reference in New Issue
Block a user