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:
@@ -156,7 +156,7 @@ pub trait TargetIsa {
|
||||
dfg: &'a ir::DataFlowGraph,
|
||||
inst: &'a ir::InstructionData,
|
||||
ctrl_typevar: ir::Type)
|
||||
-> Result<Encodings<'a>, Legalize>;
|
||||
-> Encodings<'a>;
|
||||
|
||||
/// Encode an instruction after determining it is legal.
|
||||
///
|
||||
@@ -169,8 +169,8 @@ pub trait TargetIsa {
|
||||
inst: &ir::InstructionData,
|
||||
ctrl_typevar: ir::Type)
|
||||
-> Result<Encoding, Legalize> {
|
||||
self.legal_encodings(dfg, inst, ctrl_typevar)
|
||||
.and_then(|mut iter| iter.next().ok_or(Legalize::Expand))
|
||||
let mut iter = self.legal_encodings(dfg, inst, ctrl_typevar);
|
||||
iter.next().ok_or(iter.legalize().into())
|
||||
}
|
||||
|
||||
/// Get a data structure describing the instruction encodings in this ISA.
|
||||
|
||||
Reference in New Issue
Block a user