Prefer to use qualified type names in generated code.
Emit type names like ir::Foo instead of just Foo to avoid very long manual use declarations in files including generated code.
This commit is contained in:
@@ -62,7 +62,8 @@ boolean = ImmediateKind('bool', 'An immediate boolean.',
|
|||||||
intcc = ImmediateKind(
|
intcc = ImmediateKind(
|
||||||
'intcc',
|
'intcc',
|
||||||
'An integer comparison condition code.',
|
'An integer comparison condition code.',
|
||||||
default_member='cond', rust_type='IntCC',
|
default_member='cond',
|
||||||
|
rust_type='ir::condcodes::IntCC',
|
||||||
values={
|
values={
|
||||||
'eq': 'Equal',
|
'eq': 'Equal',
|
||||||
'ne': 'NotEqual',
|
'ne': 'NotEqual',
|
||||||
@@ -83,7 +84,8 @@ intcc = ImmediateKind(
|
|||||||
floatcc = ImmediateKind(
|
floatcc = ImmediateKind(
|
||||||
'floatcc',
|
'floatcc',
|
||||||
'A floating point comparison condition code.',
|
'A floating point comparison condition code.',
|
||||||
default_member='cond', rust_type='FloatCC',
|
default_member='cond',
|
||||||
|
rust_type='ir::condcodes::FloatCC',
|
||||||
values={
|
values={
|
||||||
'ord': 'Ordered',
|
'ord': 'Ordered',
|
||||||
'uno': 'Unordered',
|
'uno': 'Unordered',
|
||||||
@@ -105,10 +107,10 @@ floatcc = ImmediateKind(
|
|||||||
memflags = ImmediateKind(
|
memflags = ImmediateKind(
|
||||||
'memflags',
|
'memflags',
|
||||||
'Memory operation flags',
|
'Memory operation flags',
|
||||||
default_member='flags', rust_type='MemFlags')
|
default_member='flags', rust_type='ir::MemFlags')
|
||||||
|
|
||||||
#: A register unit in the current target ISA.
|
#: A register unit in the current target ISA.
|
||||||
regunit = ImmediateKind(
|
regunit = ImmediateKind(
|
||||||
'regunit',
|
'regunit',
|
||||||
'A register unit in the target ISA',
|
'A register unit in the target ISA',
|
||||||
rust_type='RegUnit')
|
rust_type='isa::RegUnit')
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class OperandKind(object):
|
|||||||
self.default_member = default_member
|
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.rust_type = rust_type or camel_case(name)
|
self.rust_type = rust_type or ('ir::' + camel_case(name))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
# type: () -> str
|
# type: () -> str
|
||||||
@@ -82,6 +82,8 @@ class ImmediateKind(OperandKind):
|
|||||||
rust_type=None,
|
rust_type=None,
|
||||||
values=None):
|
values=None):
|
||||||
# type: (str, str, str, str, Dict[str, str]) -> None
|
# type: (str, str, str, str, Dict[str, str]) -> None
|
||||||
|
if rust_type is None:
|
||||||
|
rust_type = 'ir::immediates::' + camel_case(name)
|
||||||
super(ImmediateKind, self).__init__(
|
super(ImmediateKind, self).__init__(
|
||||||
name, doc, default_member, rust_type)
|
name, doc, default_member, rust_type)
|
||||||
self.values = values
|
self.values = values
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ def gen_arguments_method(fmt, is_mut):
|
|||||||
as_slice = 'as_mut_slice'
|
as_slice = 'as_mut_slice'
|
||||||
|
|
||||||
with fmt.indented(
|
with fmt.indented(
|
||||||
'pub fn {f}<\'a>(&\'a {m}self, pool: &\'a {m}ValueListPool) -> '
|
'pub fn {f}<\'a>(&\'a {m}self, '
|
||||||
|
'pool: &\'a {m}ir::ValueListPool) -> '
|
||||||
'&{m}[Value] {{'
|
'&{m}[Value] {{'
|
||||||
.format(f=method, m=mut), '}'):
|
.format(f=method, m=mut), '}'):
|
||||||
with fmt.indented('match *self {', '}'):
|
with fmt.indented('match *self {', '}'):
|
||||||
@@ -111,8 +112,8 @@ def gen_instruction_data_impl(fmt):
|
|||||||
- `pub fn opcode(&self) -> Opcode`
|
- `pub fn opcode(&self) -> Opcode`
|
||||||
- `pub fn arguments(&self, &pool) -> &[Value]`
|
- `pub fn arguments(&self, &pool) -> &[Value]`
|
||||||
- `pub fn arguments_mut(&mut self, &pool) -> &mut [Value]`
|
- `pub fn arguments_mut(&mut self, &pool) -> &mut [Value]`
|
||||||
- `pub fn take_value_list(&mut self) -> Option<ValueList>`
|
- `pub fn take_value_list(&mut self) -> Option<ir::ValueList>`
|
||||||
- `pub fn put_value_list(&mut self, args: ValueList>`
|
- `pub fn put_value_list(&mut self, args: ir::ValueList>`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# The `opcode` method simply reads the `opcode` members. This is really a
|
# The `opcode` method simply reads the `opcode` members. This is really a
|
||||||
@@ -128,7 +129,7 @@ def gen_instruction_data_impl(fmt):
|
|||||||
|
|
||||||
fmt.doc_comment('Get the controlling type variable operand.')
|
fmt.doc_comment('Get the controlling type variable operand.')
|
||||||
with fmt.indented(
|
with fmt.indented(
|
||||||
'pub fn typevar_operand(&self, pool: &ValueListPool) -> '
|
'pub fn typevar_operand(&self, pool: &ir::ValueListPool) -> '
|
||||||
'Option<Value> {', '}'):
|
'Option<Value> {', '}'):
|
||||||
with fmt.indented('match *self {', '}'):
|
with fmt.indented('match *self {', '}'):
|
||||||
for f in InstructionFormat.all_formats:
|
for f in InstructionFormat.all_formats:
|
||||||
@@ -174,7 +175,7 @@ def gen_instruction_data_impl(fmt):
|
|||||||
`put_value_list` to put the value list back.
|
`put_value_list` to put the value list back.
|
||||||
""")
|
""")
|
||||||
with fmt.indented(
|
with fmt.indented(
|
||||||
'pub fn take_value_list(&mut self) -> Option<ValueList> {',
|
'pub fn take_value_list(&mut self) -> Option<ir::ValueList> {',
|
||||||
'}'):
|
'}'):
|
||||||
with fmt.indented('match *self {', '}'):
|
with fmt.indented('match *self {', '}'):
|
||||||
for f in InstructionFormat.all_formats:
|
for f in InstructionFormat.all_formats:
|
||||||
@@ -194,7 +195,8 @@ def gen_instruction_data_impl(fmt):
|
|||||||
list is empty. This avoids leaking list pool memory.
|
list is empty. This avoids leaking list pool memory.
|
||||||
""")
|
""")
|
||||||
with fmt.indented(
|
with fmt.indented(
|
||||||
'pub fn put_value_list(&mut self, vlist: ValueList) {', '}'):
|
'pub fn put_value_list(&mut self, vlist: ir::ValueList) {',
|
||||||
|
'}'):
|
||||||
with fmt.indented('let args = match *self {', '};'):
|
with fmt.indented('let args = match *self {', '};'):
|
||||||
for f in InstructionFormat.all_formats:
|
for f in InstructionFormat.all_formats:
|
||||||
n = 'InstructionData::' + f.name
|
n = 'InstructionData::' + f.name
|
||||||
@@ -466,21 +468,22 @@ def gen_format_constructor(iform, fmt):
|
|||||||
if iform.has_value_list:
|
if iform.has_value_list:
|
||||||
# Take all value arguments as a finished value list. The value lists
|
# Take all value arguments as a finished value list. The value lists
|
||||||
# are created by the individual instruction constructors.
|
# are created by the individual instruction constructors.
|
||||||
args.append('args: ValueList')
|
args.append('args: ir::ValueList')
|
||||||
else:
|
else:
|
||||||
# Take a fixed number of value operands.
|
# Take a fixed number of value operands.
|
||||||
for i in range(iform.num_value_operands):
|
for i in range(iform.num_value_operands):
|
||||||
args.append('arg{}: Value'.format(i))
|
args.append('arg{}: Value'.format(i))
|
||||||
|
|
||||||
proto = '{}({})'.format(iform.name, ', '.join(args))
|
proto = '{}({})'.format(iform.name, ', '.join(args))
|
||||||
proto += " -> (Inst, &'f mut DataFlowGraph)"
|
proto += " -> (Inst, &'f mut ir::DataFlowGraph)"
|
||||||
|
|
||||||
fmt.doc_comment(str(iform))
|
fmt.doc_comment(str(iform))
|
||||||
fmt.line('#[allow(non_snake_case)]')
|
fmt.line('#[allow(non_snake_case)]')
|
||||||
with fmt.indented('fn {} {{'.format(proto), '}'):
|
with fmt.indented('fn {} {{'.format(proto), '}'):
|
||||||
# Generate the instruction data.
|
# Generate the instruction data.
|
||||||
with fmt.indented(
|
with fmt.indented(
|
||||||
'let data = InstructionData::{} {{'.format(iform.name), '};'):
|
'let data = ir::InstructionData::{} {{'.format(iform.name),
|
||||||
|
'};'):
|
||||||
fmt.line('opcode,')
|
fmt.line('opcode,')
|
||||||
gen_member_inits(iform, fmt)
|
gen_member_inits(iform, fmt)
|
||||||
|
|
||||||
@@ -527,7 +530,7 @@ def gen_inst_builder(inst, fmt):
|
|||||||
# The controlling type variable will be inferred from the input values if
|
# The controlling type variable will be inferred from the input values if
|
||||||
# possible. Otherwise, it is the first method argument.
|
# possible. Otherwise, it is the first method argument.
|
||||||
if inst.is_polymorphic and not inst.use_typevar_operand:
|
if inst.is_polymorphic and not inst.use_typevar_operand:
|
||||||
args.append('{}: Type'.format(inst.ctrl_typevar.name))
|
args.append('{}: ir::Type'.format(inst.ctrl_typevar.name))
|
||||||
|
|
||||||
tmpl_types = list() # type: List[str]
|
tmpl_types = list() # type: List[str]
|
||||||
into_args = list() # type: List[str]
|
into_args = list() # type: List[str]
|
||||||
@@ -590,7 +593,7 @@ def gen_inst_builder(inst, fmt):
|
|||||||
# Finally, the value operands.
|
# Finally, the value operands.
|
||||||
if inst.format.has_value_list:
|
if inst.format.has_value_list:
|
||||||
# We need to build a value list with all the arguments.
|
# We need to build a value list with all the arguments.
|
||||||
fmt.line('let mut vlist = ValueList::default();')
|
fmt.line('let mut vlist = ir::ValueList::default();')
|
||||||
args.append('vlist')
|
args.append('vlist')
|
||||||
with fmt.indented('{', '}'):
|
with fmt.indented('{', '}'):
|
||||||
fmt.line(
|
fmt.line(
|
||||||
|
|||||||
@@ -3,13 +3,11 @@
|
|||||||
//! A `Builder` provides a convenient interface for inserting instructions into a Cretonne
|
//! A `Builder` provides a convenient interface for inserting instructions into a Cretonne
|
||||||
//! function. Many of its methods are generated from the meta language instruction definitions.
|
//! function. Many of its methods are generated from the meta language instruction definitions.
|
||||||
|
|
||||||
|
use ir;
|
||||||
use ir::types;
|
use ir::types;
|
||||||
use ir::{InstructionData, DataFlowGraph};
|
use ir::{InstructionData, DataFlowGraph};
|
||||||
use ir::{Opcode, Type, Inst, Value, Ebb, JumpTable, SigRef, FuncRef, StackSlot, GlobalVar,
|
use ir::{Opcode, Type, Inst, Value};
|
||||||
ValueList, MemFlags};
|
use isa;
|
||||||
use ir::immediates::{Imm64, Uimm8, Ieee32, Ieee64, Offset32, Uoffset32};
|
|
||||||
use ir::condcodes::{IntCC, FloatCC};
|
|
||||||
use isa::RegUnit;
|
|
||||||
|
|
||||||
/// Base trait for instruction builders.
|
/// Base trait for instruction builders.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
//! Encoding tables for RISC-V.
|
//! Encoding tables for RISC-V.
|
||||||
|
|
||||||
use ir::condcodes::IntCC;
|
|
||||||
use ir;
|
use ir;
|
||||||
use isa;
|
use isa;
|
||||||
use isa::constraints::*;
|
use isa::constraints::*;
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ use cursor::{Cursor, FuncCursor};
|
|||||||
use dominator_tree::DominatorTree;
|
use dominator_tree::DominatorTree;
|
||||||
use flowgraph::ControlFlowGraph;
|
use flowgraph::ControlFlowGraph;
|
||||||
use ir;
|
use ir;
|
||||||
use ir::condcodes::IntCC;
|
|
||||||
use isa::TargetIsa;
|
use isa::TargetIsa;
|
||||||
use bitset::BitSet;
|
use bitset::BitSet;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user