[meta] Morph a few pub into pub(crate), and remove dead code;
This commit is contained in:
@@ -11,7 +11,6 @@ use std::fmt;
|
|||||||
pub enum Expr {
|
pub enum Expr {
|
||||||
Var(VarIndex),
|
Var(VarIndex),
|
||||||
Literal(Literal),
|
Literal(Literal),
|
||||||
Apply(Apply),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Expr {
|
impl Expr {
|
||||||
@@ -39,7 +38,6 @@ impl Expr {
|
|||||||
match self {
|
match self {
|
||||||
Expr::Var(var_index) => var_pool.get(*var_index).to_rust_code(),
|
Expr::Var(var_index) => var_pool.get(*var_index).to_rust_code(),
|
||||||
Expr::Literal(literal) => literal.to_rust_code(),
|
Expr::Literal(literal) => literal.to_rust_code(),
|
||||||
Expr::Apply(a) => a.to_rust_code(var_pool),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,9 +79,6 @@ impl DefPool {
|
|||||||
pub fn get(&self, index: DefIndex) -> &Def {
|
pub fn get(&self, index: DefIndex) -> &Def {
|
||||||
self.pool.get(index).unwrap()
|
self.pool.get(index).unwrap()
|
||||||
}
|
}
|
||||||
pub fn get_mut(&mut self, index: DefIndex) -> &mut Def {
|
|
||||||
self.pool.get_mut(index).unwrap()
|
|
||||||
}
|
|
||||||
pub fn next_index(&self) -> DefIndex {
|
pub fn next_index(&self) -> DefIndex {
|
||||||
self.pool.next_key()
|
self.pool.next_key()
|
||||||
}
|
}
|
||||||
@@ -430,16 +425,6 @@ impl Apply {
|
|||||||
format!("{}({})", inst_name, args)
|
format!("{}({})", inst_name, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_rust_code(&self, var_pool: &VarPool) -> String {
|
|
||||||
let args = self
|
|
||||||
.args
|
|
||||||
.iter()
|
|
||||||
.map(|arg| arg.to_rust_code(var_pool))
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.join(", ");
|
|
||||||
format!("{}({})", self.inst.name, args)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn inst_predicate(
|
pub fn inst_predicate(
|
||||||
&self,
|
&self,
|
||||||
format_registry: &FormatRegistry,
|
format_registry: &FormatRegistry,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ use std::collections::HashMap;
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ops;
|
use std::ops;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::slice;
|
|
||||||
|
|
||||||
use crate::cdsl::camel_case;
|
use crate::cdsl::camel_case;
|
||||||
use crate::cdsl::formats::{
|
use crate::cdsl::formats::{
|
||||||
@@ -72,10 +71,6 @@ pub struct InstructionGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl InstructionGroup {
|
impl InstructionGroup {
|
||||||
pub fn iter(&self) -> slice::Iter<Instruction> {
|
|
||||||
self.instructions.iter()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn by_name(&self, name: &'static str) -> &Instruction {
|
pub fn by_name(&self, name: &'static str) -> &Instruction {
|
||||||
self.instructions
|
self.instructions
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
@@ -384,9 +384,6 @@ impl TransformGroups {
|
|||||||
pub fn get(&self, id: TransformGroupIndex) -> &TransformGroup {
|
pub fn get(&self, id: TransformGroupIndex) -> &TransformGroup {
|
||||||
&self.groups[id]
|
&self.groups[id]
|
||||||
}
|
}
|
||||||
pub fn get_mut(&mut self, id: TransformGroupIndex) -> &mut TransformGroup {
|
|
||||||
self.groups.get_mut(id).unwrap()
|
|
||||||
}
|
|
||||||
fn next_key(&self) -> TransformGroupIndex {
|
fn next_key(&self) -> TransformGroupIndex {
|
||||||
self.groups.next_key()
|
self.groups.next_key()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1126,7 +1126,7 @@ fn gen_isa(defs: &SharedDefinitions, isa: &TargetIsa, fmt: &mut Formatter) {
|
|||||||
fmt.line("};");
|
fmt.line("};");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate(
|
pub(crate) fn generate(
|
||||||
defs: &SharedDefinitions,
|
defs: &SharedDefinitions,
|
||||||
isa: &TargetIsa,
|
isa: &TargetIsa,
|
||||||
filename: &str,
|
filename: &str,
|
||||||
|
|||||||
@@ -1059,7 +1059,7 @@ fn gen_builder(instructions: &AllInstructions, formats: &FormatRegistry, fmt: &m
|
|||||||
fmt.line("}");
|
fmt.line("}");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generate(
|
pub(crate) fn generate(
|
||||||
shared_defs: &SharedDefinitions,
|
shared_defs: &SharedDefinitions,
|
||||||
opcode_filename: &str,
|
opcode_filename: &str,
|
||||||
inst_builder_filename: &str,
|
inst_builder_filename: &str,
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ fn define_regs() -> IsaRegs {
|
|||||||
regs.build()
|
regs.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn define(shared_defs: &mut SharedDefinitions) -> TargetIsa {
|
pub(crate) fn define(shared_defs: &mut SharedDefinitions) -> TargetIsa {
|
||||||
let settings = define_settings(&shared_defs.settings);
|
let settings = define_settings(&shared_defs.settings);
|
||||||
let regs = define_regs();
|
let regs = define_regs();
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ fn define_registers() -> IsaRegs {
|
|||||||
regs.build()
|
regs.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn define(shared_defs: &mut SharedDefinitions) -> TargetIsa {
|
pub(crate) fn define(shared_defs: &mut SharedDefinitions) -> TargetIsa {
|
||||||
let settings = define_settings(&shared_defs.settings);
|
let settings = define_settings(&shared_defs.settings);
|
||||||
let regs = define_registers();
|
let regs = define_registers();
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ impl fmt::Display for Isa {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn define(isas: &Vec<Isa>, shared_defs: &mut SharedDefinitions) -> Vec<TargetIsa> {
|
pub(crate) fn define(isas: &Vec<Isa>, shared_defs: &mut SharedDefinitions) -> Vec<TargetIsa> {
|
||||||
isas.iter()
|
isas.iter()
|
||||||
.map(|isa| match isa {
|
.map(|isa| match isa {
|
||||||
Isa::Riscv => riscv::define(shared_defs),
|
Isa::Riscv => riscv::define(shared_defs),
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ fn lui_bits() -> u16 {
|
|||||||
0b01101
|
0b01101
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn define<'defs>(
|
pub(crate) fn define<'defs>(
|
||||||
shared_defs: &'defs SharedDefinitions,
|
shared_defs: &'defs SharedDefinitions,
|
||||||
isa_settings: &SettingGroup,
|
isa_settings: &SettingGroup,
|
||||||
recipes: &'defs RecipeGroup,
|
recipes: &'defs RecipeGroup,
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ fn define_registers() -> IsaRegs {
|
|||||||
regs.build()
|
regs.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn define(shared_defs: &mut SharedDefinitions) -> TargetIsa {
|
pub(crate) fn define(shared_defs: &mut SharedDefinitions) -> TargetIsa {
|
||||||
let settings = define_settings(&shared_defs.settings);
|
let settings = define_settings(&shared_defs.settings);
|
||||||
let regs = define_registers();
|
let regs = define_registers();
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ impl<'formats> RecipeGroup<'formats> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn define<'formats>(
|
pub(crate) fn define<'formats>(
|
||||||
shared_defs: &'formats SharedDefinitions,
|
shared_defs: &'formats SharedDefinitions,
|
||||||
regs: &IsaRegs,
|
regs: &IsaRegs,
|
||||||
) -> RecipeGroup<'formats> {
|
) -> RecipeGroup<'formats> {
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ impl PerCpuModeEncodings {
|
|||||||
|
|
||||||
// Definitions.
|
// Definitions.
|
||||||
|
|
||||||
pub fn define(
|
pub(crate) fn define(
|
||||||
shared_defs: &SharedDefinitions,
|
shared_defs: &SharedDefinitions,
|
||||||
settings: &SettingGroup,
|
settings: &SettingGroup,
|
||||||
x86: &InstructionGroup,
|
x86: &InstructionGroup,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use crate::cdsl::typevar::{Interval, TypeSetBuilder, TypeVar};
|
|||||||
use crate::shared::immediates::Immediates;
|
use crate::shared::immediates::Immediates;
|
||||||
use crate::shared::types;
|
use crate::shared::types;
|
||||||
|
|
||||||
pub fn define(
|
pub(crate) fn define(
|
||||||
mut all_instructions: &mut AllInstructions,
|
mut all_instructions: &mut AllInstructions,
|
||||||
format_registry: &FormatRegistry,
|
format_registry: &FormatRegistry,
|
||||||
immediates: &Immediates,
|
immediates: &Immediates,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use crate::shared::types::Float::F64;
|
|||||||
use crate::shared::types::Int::{I32, I64};
|
use crate::shared::types::Int::{I32, I64};
|
||||||
use crate::shared::Definitions as SharedDefinitions;
|
use crate::shared::Definitions as SharedDefinitions;
|
||||||
|
|
||||||
pub fn define(shared: &mut SharedDefinitions, x86_instructions: &InstructionGroup) {
|
pub(crate) fn define(shared: &mut SharedDefinitions, x86_instructions: &InstructionGroup) {
|
||||||
let mut group = TransformGroupBuilder::new(
|
let mut group = TransformGroupBuilder::new(
|
||||||
"x86_expand",
|
"x86_expand",
|
||||||
r#"
|
r#"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ mod recipes;
|
|||||||
mod registers;
|
mod registers;
|
||||||
mod settings;
|
mod settings;
|
||||||
|
|
||||||
pub fn define(shared_defs: &mut SharedDefinitions) -> TargetIsa {
|
pub(crate) fn define(shared_defs: &mut SharedDefinitions) -> TargetIsa {
|
||||||
let settings = settings::define(&shared_defs.settings);
|
let settings = settings::define(&shared_defs.settings);
|
||||||
let regs = registers::define();
|
let regs = registers::define();
|
||||||
|
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ fn valid_scale(format: &InstructionFormat) -> InstructionPredicate {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn define<'shared>(
|
pub(crate) fn define<'shared>(
|
||||||
shared_defs: &'shared SharedDefinitions,
|
shared_defs: &'shared SharedDefinitions,
|
||||||
settings: &'shared SettingGroup,
|
settings: &'shared SettingGroup,
|
||||||
regs: &'shared IsaRegs,
|
regs: &'shared IsaRegs,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::cdsl::formats::{FormatRegistry, InstructionFormatBuilder as Builder};
|
use crate::cdsl::formats::{FormatRegistry, InstructionFormatBuilder as Builder};
|
||||||
use crate::shared::{entities::EntityRefs, immediates::Immediates};
|
use crate::shared::{entities::EntityRefs, immediates::Immediates};
|
||||||
|
|
||||||
pub fn define(imm: &Immediates, entities: &EntityRefs) -> FormatRegistry {
|
pub(crate) fn define(imm: &Immediates, entities: &EntityRefs) -> FormatRegistry {
|
||||||
let mut registry = FormatRegistry::new();
|
let mut registry = FormatRegistry::new();
|
||||||
|
|
||||||
registry.insert(Builder::new("Unary").value());
|
registry.insert(Builder::new("Unary").value());
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use crate::cdsl::operands::{OperandKind, OperandKindBuilder as Builder};
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub struct Immediates {
|
pub(crate) struct Immediates {
|
||||||
/// A 64-bit immediate integer operand.
|
/// A 64-bit immediate integer operand.
|
||||||
///
|
///
|
||||||
/// This type of immediate integer can interact with SSA values with any IntType type.
|
/// This type of immediate integer can interact with SSA values with any IntType type.
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use crate::cdsl::typevar::{Interval, TypeSetBuilder, TypeVar};
|
|||||||
use crate::shared::types;
|
use crate::shared::types;
|
||||||
use crate::shared::{entities::EntityRefs, immediates::Immediates};
|
use crate::shared::{entities::EntityRefs, immediates::Immediates};
|
||||||
|
|
||||||
pub fn define(
|
pub(crate) fn define(
|
||||||
all_instructions: &mut AllInstructions,
|
all_instructions: &mut AllInstructions,
|
||||||
format_registry: &FormatRegistry,
|
format_registry: &FormatRegistry,
|
||||||
imm: &Immediates,
|
imm: &Immediates,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use crate::shared::immediates::Immediates;
|
|||||||
use crate::shared::types::Float::{F32, F64};
|
use crate::shared::types::Float::{F32, F64};
|
||||||
use crate::shared::types::Int::{I16, I32, I64, I8};
|
use crate::shared::types::Int::{I16, I32, I64, I8};
|
||||||
|
|
||||||
pub fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGroups {
|
pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGroups {
|
||||||
let mut narrow = TransformGroupBuilder::new(
|
let mut narrow = TransformGroupBuilder::new(
|
||||||
"narrow",
|
"narrow",
|
||||||
r#"
|
r#"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use crate::cdsl::xform::TransformGroups;
|
|||||||
use crate::shared::entities::EntityRefs;
|
use crate::shared::entities::EntityRefs;
|
||||||
use crate::shared::immediates::Immediates;
|
use crate::shared::immediates::Immediates;
|
||||||
|
|
||||||
pub struct Definitions {
|
pub(crate) struct Definitions {
|
||||||
pub settings: SettingGroup,
|
pub settings: SettingGroup,
|
||||||
pub all_instructions: AllInstructions,
|
pub all_instructions: AllInstructions,
|
||||||
pub instructions: InstructionGroup,
|
pub instructions: InstructionGroup,
|
||||||
@@ -25,7 +25,7 @@ pub struct Definitions {
|
|||||||
pub transform_groups: TransformGroups,
|
pub transform_groups: TransformGroups,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn define() -> Definitions {
|
pub(crate) fn define() -> Definitions {
|
||||||
let mut all_instructions = AllInstructions::new();
|
let mut all_instructions = AllInstructions::new();
|
||||||
|
|
||||||
let immediates = Immediates::new();
|
let immediates = Immediates::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user