Add support for legalization codes in the encoding tables.
The new encoding format allows entries that mean "stop with this legalization code" which makes it possible to configure legalization actions per instruction, instead of only per controlling type variable. This patch adds the Rust side of the legalization codes: - Add an `Encodings::legalize()` method on the encoding iterator which can be called after the iterator has returned `None`. The returned code is either the default legalization action for the type, or a specific code encountered in the encoding list. - Change `lookup_enclist` to return a full iterator instead of just an offset. The two-phase lookup can bail at multiple points, each time with a default legalization code from the level 1 table. This default legalization code is stored in the returned iterator. - Change all the implementations of legal_encodings() in the ISA implementations. This change means that we don't need to return a Result any longer. The `Encodings` iterator can be empty with an associated legalization code.
This commit is contained in:
@@ -10,7 +10,7 @@ use binemit::{CodeSink, MemoryCodeSink, emit_function};
|
||||
use super::super::settings as shared_settings;
|
||||
use isa::enc_tables::{self as shared_enc_tables, lookup_enclist, Encodings};
|
||||
use isa::Builder as IsaBuilder;
|
||||
use isa::{TargetIsa, RegInfo, RegClass, EncInfo, Legalize};
|
||||
use isa::{TargetIsa, RegInfo, RegClass, EncInfo};
|
||||
use ir;
|
||||
use regalloc;
|
||||
|
||||
@@ -62,22 +62,19 @@ impl TargetIsa for Isa {
|
||||
}
|
||||
|
||||
fn legal_encodings<'a>(&'a self,
|
||||
_dfg: &'a ir::DataFlowGraph,
|
||||
dfg: &'a ir::DataFlowGraph,
|
||||
inst: &'a ir::InstructionData,
|
||||
ctrl_typevar: ir::Type)
|
||||
-> Result<Encodings<'a>, Legalize> {
|
||||
-> Encodings<'a> {
|
||||
lookup_enclist(ctrl_typevar,
|
||||
inst.opcode(),
|
||||
inst,
|
||||
dfg,
|
||||
self.cpumode,
|
||||
&enc_tables::LEVEL2[..])
|
||||
.and_then(|enclist_offset| {
|
||||
Ok(Encodings::new(enclist_offset,
|
||||
&enc_tables::ENCLISTS[..],
|
||||
&enc_tables::RECIPE_PREDICATES[..],
|
||||
&enc_tables::INST_PREDICATES[..],
|
||||
inst,
|
||||
self.isa_flags.predicate_view()))
|
||||
})
|
||||
&enc_tables::LEVEL2[..],
|
||||
&enc_tables::ENCLISTS[..],
|
||||
&enc_tables::RECIPE_PREDICATES[..],
|
||||
&enc_tables::INST_PREDICATES[..],
|
||||
self.isa_flags.predicate_view())
|
||||
}
|
||||
|
||||
fn legalize_signature(&self, sig: &mut ir::Signature, current: bool) {
|
||||
|
||||
Reference in New Issue
Block a user