Skip to content

Commit c06ac1c

Browse files
committed
cranelift: Remove the ir::Heap entity from CLIF
1 parent 822f601 commit c06ac1c

File tree

25 files changed

+39
-1144
lines changed

25 files changed

+39
-1144
lines changed

cranelift/codegen/meta/src/shared/settings.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,21 +139,6 @@ pub(crate) fn define() -> SettingGroup {
139139
false,
140140
);
141141

142-
settings.add_bool(
143-
"use_pinned_reg_as_heap_base",
144-
"Use the pinned register as the heap base.",
145-
r#"
146-
Enabling this requires the enable_pinned_reg setting to be set to true. It enables a custom
147-
legalization of the `heap_addr` instruction so it will use the pinned register as the heap
148-
base, instead of fetching it from a global value.
149-
150-
Warning! Enabling this means that the pinned register *must* be maintained to contain the
151-
heap base address at all times, during the lifetime of a function. Using the pinned
152-
register for other purposes when this is set is very likely to cause crashes.
153-
"#,
154-
false,
155-
);
156-
157142
settings.add_bool(
158143
"enable_simd",
159144
"Enable the use of SIMD instructions.",

cranelift/codegen/src/ir/dfg.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ use crate::entity::{self, PrimaryMap, SecondaryMap};
44
use crate::ir;
55
use crate::ir::builder::ReplaceBuilder;
66
use crate::ir::dynamic_type::{DynamicTypeData, DynamicTypes};
7-
use crate::ir::immediates::HeapImmData;
87
use crate::ir::instructions::{BranchInfo, CallInfo, InstructionData};
98
use crate::ir::{types, ConstantData, ConstantPool, Immediate};
109
use crate::ir::{
11-
Block, DynamicType, FuncRef, HeapImm, Inst, SigRef, Signature, Type, Value,
10+
Block, DynamicType, FuncRef, Inst, SigRef, Signature, Type, Value,
1211
ValueLabelAssignments, ValueList, ValueListPool,
1312
};
1413
use crate::ir::{ExtFuncData, RelSourceLoc};
@@ -84,9 +83,6 @@ pub struct DataFlowGraph {
8483

8584
/// Stores large immediates that otherwise will not fit on InstructionData
8685
pub immediates: PrimaryMap<Immediate, ConstantData>,
87-
88-
/// Out-of-line heap access immediates that don't fit in `InstructionData`.
89-
pub heap_imms: PrimaryMap<HeapImm, HeapImmData>,
9086
}
9187

9288
impl DataFlowGraph {
@@ -105,7 +101,6 @@ impl DataFlowGraph {
105101
values_labels: None,
106102
constants: ConstantPool::new(),
107103
immediates: PrimaryMap::new(),
108-
heap_imms: PrimaryMap::new(),
109104
}
110105
}
111106

cranelift/codegen/src/ir/entities.rs

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -368,60 +368,6 @@ impl SigRef {
368368
}
369369
}
370370

371-
/// An opaque reference to a [heap](https://en.wikipedia.org/wiki/Memory_management#DYNAMIC).
372-
///
373-
/// Heaps are used to access dynamically allocated memory through
374-
/// [`heap_addr`](super::InstBuilder::heap_addr).
375-
///
376-
/// To create a heap, use [`FunctionBuilder::create_heap`](https://docs.rs/cranelift-frontend/*/cranelift_frontend/struct.FunctionBuilder.html#method.create_heap).
377-
///
378-
/// While the order is stable, it is arbitrary.
379-
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
380-
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
381-
pub struct Heap(u32);
382-
entity_impl!(Heap, "heap");
383-
384-
impl Heap {
385-
/// Create a new heap reference from its number.
386-
///
387-
/// This method is for use by the parser.
388-
pub fn with_number(n: u32) -> Option<Self> {
389-
if n < u32::MAX {
390-
Some(Self(n))
391-
} else {
392-
None
393-
}
394-
}
395-
}
396-
397-
/// An opaque reference to some out-of-line immediates for `heap_{load,store}`
398-
/// instructions.
399-
///
400-
/// These immediates are too large to store in
401-
/// [`InstructionData`](super::instructions::InstructionData) and therefore must
402-
/// be tracked separately in
403-
/// [`DataFlowGraph::heap_imms`](super::dfg::DataFlowGraph). `HeapImm` provides
404-
/// a way to reference values stored there.
405-
///
406-
/// While the order is stable, it is arbitrary.
407-
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
408-
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
409-
pub struct HeapImm(u32);
410-
entity_impl!(HeapImm, "heap_imm");
411-
412-
impl HeapImm {
413-
/// Create a new `HeapImm` reference from its number.
414-
///
415-
/// This method is for use by the parser.
416-
pub fn with_number(n: u32) -> Option<Self> {
417-
if n < u32::MAX {
418-
Some(Self(n))
419-
} else {
420-
None
421-
}
422-
}
423-
}
424-
425371
/// An opaque reference to a [WebAssembly
426372
/// table](https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format#WebAssembly_tables).
427373
///
@@ -477,8 +423,6 @@ pub enum AnyEntity {
477423
FuncRef(FuncRef),
478424
/// A function call signature.
479425
SigRef(SigRef),
480-
/// A heap.
481-
Heap(Heap),
482426
/// A table.
483427
Table(Table),
484428
/// A function's stack limit
@@ -500,7 +444,6 @@ impl fmt::Display for AnyEntity {
500444
Self::Constant(r) => r.fmt(f),
501445
Self::FuncRef(r) => r.fmt(f),
502446
Self::SigRef(r) => r.fmt(f),
503-
Self::Heap(r) => r.fmt(f),
504447
Self::Table(r) => r.fmt(f),
505448
Self::StackLimit => write!(f, "stack_limit"),
506449
}
@@ -579,12 +522,6 @@ impl From<SigRef> for AnyEntity {
579522
}
580523
}
581524

582-
impl From<Heap> for AnyEntity {
583-
fn from(r: Heap) -> Self {
584-
Self::Heap(r)
585-
}
586-
}
587-
588525
impl From<Table> for AnyEntity {
589526
fn from(r: Table) -> Self {
590527
Self::Table(r)

cranelift/codegen/src/ir/function.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use crate::ir;
88
use crate::ir::JumpTables;
99
use crate::ir::{
1010
instructions::BranchInfo, Block, DynamicStackSlot, DynamicStackSlotData, DynamicType,
11-
ExtFuncData, FuncRef, GlobalValue, GlobalValueData, Heap, HeapData, Inst, InstructionData,
12-
JumpTable, JumpTableData, Opcode, SigRef, StackSlot, StackSlotData, Table, TableData, Type,
11+
ExtFuncData, FuncRef, GlobalValue, GlobalValueData, Inst, InstructionData, JumpTable,
12+
JumpTableData, Opcode, SigRef, StackSlot, StackSlotData, Table, TableData, Type,
1313
};
1414
use crate::ir::{DataFlowGraph, Layout, Signature};
1515
use crate::ir::{DynamicStackSlots, SourceLocs, StackSlots};
@@ -170,9 +170,6 @@ pub struct FunctionStencil {
170170
/// Global values referenced.
171171
pub global_values: PrimaryMap<ir::GlobalValue, ir::GlobalValueData>,
172172

173-
/// Heaps referenced.
174-
pub heaps: PrimaryMap<ir::Heap, ir::HeapData>,
175-
176173
/// Tables referenced.
177174
pub tables: PrimaryMap<ir::Table, ir::TableData>,
178175

@@ -205,7 +202,6 @@ impl FunctionStencil {
205202
self.sized_stack_slots.clear();
206203
self.dynamic_stack_slots.clear();
207204
self.global_values.clear();
208-
self.heaps.clear();
209205
self.tables.clear();
210206
self.jump_tables.clear();
211207
self.dfg.clear();
@@ -261,11 +257,6 @@ impl FunctionStencil {
261257
.concrete()
262258
}
263259

264-
/// Declares a heap accessible to the function.
265-
pub fn create_heap(&mut self, data: HeapData) -> Heap {
266-
self.heaps.push(data)
267-
}
268-
269260
/// Declares a table accessible to the function.
270261
pub fn create_table(&mut self, data: TableData) -> Table {
271262
self.tables.push(data)
@@ -447,7 +438,6 @@ impl Function {
447438
sized_stack_slots: StackSlots::new(),
448439
dynamic_stack_slots: DynamicStackSlots::new(),
449440
global_values: PrimaryMap::new(),
450-
heaps: PrimaryMap::new(),
451441
tables: PrimaryMap::new(),
452442
jump_tables: PrimaryMap::new(),
453443
dfg: DataFlowGraph::new(),

cranelift/codegen/src/ir/heap.rs

Lines changed: 0 additions & 67 deletions
This file was deleted.

cranelift/codegen/src/ir/immediates.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//! Each type here should have a corresponding definition in the
55
//! `cranelift-codegen/meta/src/shared/immediates` crate in the meta language.
66
7-
use crate::ir;
87
use alloc::vec::Vec;
98
use core::cmp::Ordering;
109
use core::convert::TryFrom;
@@ -1178,18 +1177,6 @@ impl Not for Ieee64 {
11781177
}
11791178
}
11801179

1181-
/// Out-of-line heap access immediates.
1182-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
1183-
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
1184-
pub struct HeapImmData {
1185-
/// The memory flags for the heap access.
1186-
pub flags: ir::MemFlags,
1187-
/// The heap being accessed.
1188-
pub heap: ir::Heap,
1189-
/// The static offset added to the heap access's index.
1190-
pub offset: Uimm32,
1191-
}
1192-
11931180
#[cfg(test)]
11941181
mod tests {
11951182
use super::*;

cranelift/codegen/src/ir/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ mod extfunc;
1111
mod extname;
1212
pub mod function;
1313
mod globalvalue;
14-
mod heap;
1514
pub mod immediates;
1615
pub mod instructions;
1716
pub mod jumptable;
@@ -37,16 +36,15 @@ pub use crate::ir::constant::{ConstantData, ConstantPool};
3736
pub use crate::ir::dfg::{DataFlowGraph, ValueDef};
3837
pub use crate::ir::dynamic_type::{dynamic_to_fixed, DynamicTypeData, DynamicTypes};
3938
pub use crate::ir::entities::{
40-
Block, Constant, DynamicStackSlot, DynamicType, FuncRef, GlobalValue, Heap, HeapImm, Immediate,
41-
Inst, JumpTable, SigRef, StackSlot, Table, UserExternalNameRef, Value,
39+
Block, Constant, DynamicStackSlot, DynamicType, FuncRef, GlobalValue, Immediate, Inst,
40+
JumpTable, SigRef, StackSlot, Table, UserExternalNameRef, Value,
4241
};
4342
pub use crate::ir::extfunc::{
4443
AbiParam, ArgumentExtension, ArgumentPurpose, ExtFuncData, Signature,
4544
};
4645
pub use crate::ir::extname::{ExternalName, UserExternalName, UserFuncName};
4746
pub use crate::ir::function::{DisplayFunctionAnnotations, Function};
4847
pub use crate::ir::globalvalue::GlobalValueData;
49-
pub use crate::ir::heap::{HeapData, HeapStyle};
5048
pub use crate::ir::instructions::{
5149
InstructionData, InstructionImms, Opcode, ValueList, ValueListPool, VariableArgs,
5250
};

cranelift/codegen/src/opts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ pub use crate::ir::condcodes::{FloatCC, IntCC};
88
pub use crate::ir::immediates::{Ieee32, Ieee64, Imm64, Offset32, Uimm32, Uimm64, Uimm8};
99
pub use crate::ir::types::*;
1010
pub use crate::ir::{
11-
dynamic_to_fixed, AtomicRmwOp, Block, Constant, DynamicStackSlot, FuncRef, GlobalValue, Heap,
12-
HeapImm, Immediate, InstructionImms, JumpTable, MemFlags, Opcode, StackSlot, Table, TrapCode,
13-
Type, Value,
11+
dynamic_to_fixed, AtomicRmwOp, Block, Constant, DynamicStackSlot, FuncRef, GlobalValue,
12+
Immediate, InstructionImms, JumpTable, MemFlags, Opcode, StackSlot, Table, TrapCode, Type,
13+
Value,
1414
};
1515
use crate::isle_common_prelude_methods;
1616
use crate::machinst::isle::*;

cranelift/codegen/src/verifier/mod.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -406,49 +406,6 @@ impl<'a> Verifier<'a> {
406406
Ok(())
407407
}
408408

409-
fn verify_heaps(&self, errors: &mut VerifierErrors) -> VerifierStepResult<()> {
410-
if let Some(isa) = self.isa {
411-
for (heap, heap_data) in &self.func.heaps {
412-
let base = heap_data.base;
413-
if !self.func.global_values.is_valid(base) {
414-
return errors.nonfatal((heap, format!("invalid base global value {}", base)));
415-
}
416-
417-
let pointer_type = isa.pointer_type();
418-
let base_type = self.func.global_values[base].global_type(isa);
419-
if base_type != pointer_type {
420-
errors.report((
421-
heap,
422-
format!(
423-
"heap base has type {}, which is not the pointer type {}",
424-
base_type, pointer_type
425-
),
426-
));
427-
}
428-
429-
if let ir::HeapStyle::Dynamic { bound_gv, .. } = heap_data.style {
430-
if !self.func.global_values.is_valid(bound_gv) {
431-
return errors
432-
.nonfatal((heap, format!("invalid bound global value {}", bound_gv)));
433-
}
434-
435-
let bound_type = self.func.global_values[bound_gv].global_type(isa);
436-
if pointer_type != bound_type {
437-
errors.report((
438-
heap,
439-
format!(
440-
"heap pointer type {} differs from the type of its bound, {}",
441-
pointer_type, bound_type
442-
),
443-
));
444-
}
445-
}
446-
}
447-
}
448-
449-
Ok(())
450-
}
451-
452409
fn verify_tables(&self, errors: &mut VerifierErrors) -> VerifierStepResult<()> {
453410
if let Some(isa) = self.isa {
454411
for (table, table_data) in &self.func.tables {
@@ -1734,7 +1691,6 @@ impl<'a> Verifier<'a> {
17341691

17351692
pub fn run(&self, errors: &mut VerifierErrors) -> VerifierStepResult<()> {
17361693
self.verify_global_values(errors)?;
1737-
self.verify_heaps(errors)?;
17381694
self.verify_tables(errors)?;
17391695
self.verify_jump_tables(errors)?;
17401696
self.typecheck_entry_block_params(errors)?;

cranelift/codegen/src/write.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ pub trait FuncWriter {
5656
self.write_entity_definition(w, func, gv.into(), gv_data)?;
5757
}
5858

59-
for (heap, heap_data) in &func.heaps {
60-
if !heap_data.index_type.is_invalid() {
61-
any = true;
62-
self.write_entity_definition(w, func, heap.into(), heap_data)?;
63-
}
64-
}
65-
6659
for (table, table_data) in &func.tables {
6760
if !table_data.index_type.is_invalid() {
6861
any = true;

0 commit comments

Comments
 (0)