ISLE: Common accessors for some insn data fields (#3781)
Add accessors to prelude.isle to access data fields of
`func_addr` and `symbol_value` instructions.
These are based on similar versions I had added to the s390x
back-end, but are a bit more straightforward to use.
- func_ref_data: Extract SigRef, ExternalName, and RelocDistance
fields given a FuncRef.
- symbol_value_data: Extract ExternalName, RelocDistance, and
offset fields given a GlobalValue representing a Symbol.
- reloc_distance_near: Test for RelocDistance::Near.
The s390x back-end is changed to use these common versions.
Note that this exposed a bug in common isle code: This extractor:
(extractor (load_sym inst)
(and inst
(load _ (def_inst (symbol_value
(symbol_value_data _
(reloc_distance_near) offset)))
(i64_from_offset
(memarg_symbol_offset_sum <offset _)))))
would raise an assertion in sema.rs due to a supposed cycle in
extractor definitions. But there was no actual cycle, it was
simply that the extractor tree refers twice to the `insn_data`
extractor (once via the `load` and once via the `symbol_value`
extractor). Fixed by checking for pre-existing definitions only
along one path in the tree, not across the whole tree.
This commit is contained in:
@@ -13,12 +13,12 @@ use crate::machinst::isle::*;
|
||||
use crate::settings::Flags;
|
||||
use crate::{
|
||||
ir::{
|
||||
condcodes::*, immediates::*, types::*, AtomicRmwOp, Endianness, ExternalName, Inst,
|
||||
InstructionData, StackSlot, TrapCode, Value, ValueLabel, ValueList,
|
||||
condcodes::*, immediates::*, types::*, AtomicRmwOp, Endianness, Inst, InstructionData,
|
||||
StackSlot, TrapCode, Value, ValueLabel, ValueList,
|
||||
},
|
||||
isa::s390x::inst::s390x_map_regs,
|
||||
isa::unwind::UnwindInst,
|
||||
machinst::{InsnOutput, LowerCtx, RelocDistance},
|
||||
machinst::{InsnOutput, LowerCtx},
|
||||
};
|
||||
use std::boxed::Box;
|
||||
use std::cell::Cell;
|
||||
@@ -127,18 +127,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn symbol_value_data(&mut self, inst: Inst) -> Option<(BoxExternalName, RelocDistance, i64)> {
|
||||
let (name, dist, offset) = self.lower_ctx.symbol_value(inst)?;
|
||||
Some((Box::new(name.clone()), dist, offset))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn call_target_data(&mut self, inst: Inst) -> Option<(BoxExternalName, RelocDistance)> {
|
||||
let (name, dist) = self.lower_ctx.call_target(inst)?;
|
||||
Some((Box::new(name.clone()), dist))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn writable_gpr(&mut self, regno: u8) -> WritableReg {
|
||||
super::writable_gpr(regno)
|
||||
@@ -404,15 +392,6 @@ where
|
||||
vec[usize::from(index)]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn reloc_distance_near(&mut self, dist: &RelocDistance) -> Option<()> {
|
||||
if *dist == RelocDistance::Near {
|
||||
Some(())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn zero_offset(&mut self) -> Offset32 {
|
||||
Offset32::new(0)
|
||||
@@ -443,6 +422,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn box_external_name(&mut self, name: ExternalName) -> BoxExternalName {
|
||||
Box::new(name)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn memflags_trusted(&mut self) -> MemFlags {
|
||||
MemFlags::trusted()
|
||||
@@ -459,9 +443,9 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn memarg_symbol(&mut self, name: BoxExternalName, offset: i32, flags: MemFlags) -> MemArg {
|
||||
fn memarg_symbol(&mut self, name: ExternalName, offset: i32, flags: MemFlags) -> MemArg {
|
||||
MemArg::Symbol {
|
||||
name,
|
||||
name: Box::new(name),
|
||||
offset,
|
||||
flags,
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
src/clif.isle 9ea75a6f790b5c03
|
||||
src/prelude.isle 6aaf8ce0f5a5c2ec
|
||||
src/isa/s390x/inst.isle 1ae3c0f9c956affd
|
||||
src/isa/s390x/lower.isle d18ee0bff12cad4e
|
||||
src/prelude.isle 73285cd431346d53
|
||||
src/isa/s390x/inst.isle 87a2d7c0c69d0324
|
||||
src/isa/s390x/lower.isle 3c124e26bc411983
|
||||
|
||||
1600
cranelift/codegen/src/isa/s390x/lower/isle/generated_code.rs
generated
1600
cranelift/codegen/src/isa/s390x/lower/isle/generated_code.rs
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user