Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Partially fix no_std build for cratelift-codegen #1262

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cranelift-codegen/shared/src/condcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ impl FromStr for FloatCC {
#[cfg(test)]
mod tests {
use super::*;
use std::string::ToString;
use alloc::string::ToString;

static INT_ALL: [IntCC; 12] = [
IntCC::Equal,
Expand Down
4 changes: 3 additions & 1 deletion cranelift-codegen/shared/src/constant_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
//! This module provides build meta support for lookups in these tables, as well as the shared hash
//! function used for probing.

use std::iter;
use alloc::vec::Vec;
use core::iter;

/// A primitive hash function for matching opcodes.
pub fn simple_hash(s: &str) -> usize {
Expand Down Expand Up @@ -57,6 +58,7 @@ pub fn generate_table<'cont, T, I: iter::Iterator<Item = &'cont T>, H: Fn(&T) ->
#[cfg(test)]
mod tests {
use super::{generate_table, simple_hash};
use alloc::string::ToString;

#[test]
fn basic() {
Expand Down
2 changes: 1 addition & 1 deletion cranelift-codegen/shared/src/isa/x86/encoding_bits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Provides a named interface to the `u16` Encoding bits.

use std::ops::RangeInclusive;
use core::ops::RangeInclusive;

/// Named interface to the `u16` Encoding bits, representing an opcode.
///
Expand Down
5 changes: 5 additions & 0 deletions cranelift-codegen/shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
clippy::use_self
)
)]
#![no_std]

#[allow(unused_imports)] // #[macro_use] is required for no_std
#[macro_use]
extern crate alloc;

pub mod condcodes;
pub mod constant_hash;
Expand Down
2 changes: 1 addition & 1 deletion cranelift-codegen/src/ir/framelayout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::ir::entities::Inst;
use crate::isa::RegUnit;
use std::boxed::Box;
use alloc::boxed::Box;

use crate::HashMap;

Expand Down
4 changes: 2 additions & 2 deletions cranelift-codegen/src/isa/x86/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use crate::regalloc::RegisterSet;
use crate::result::CodegenResult;
use crate::stack_layout::layout_stack;
use alloc::borrow::Cow;
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::i32;
use std::boxed::Box;
use target_lexicon::{PointerWidth, Triple};

/// Argument registers for x86-64
Expand Down Expand Up @@ -940,7 +940,7 @@ fn insert_common_epilogue(
*insts = insts
.iter()
.cloned()
.chain(std::iter::once(new_cfa))
.chain(core::iter::once(new_cfa))
.collect::<Box<[_]>>();
})
.or_insert_with(|| Box::new([new_cfa]));
Expand Down
4 changes: 2 additions & 2 deletions cranelift-codegen/src/legalizer/boundary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ fn legalize_inst_arguments<ArgType>(
/// will go into the `sret` space.
fn legalized_type_for_sret(ty: Type) -> Type {
if ty.is_bool() {
let bits = std::cmp::max(8, ty.bits());
let bits = core::cmp::max(8, ty.bits());
Type::int(bits).unwrap()
} else {
ty
Expand All @@ -713,7 +713,7 @@ fn legalized_type_for_sret(ty: Type) -> Type {
/// unmodified) legalized value and its type.
fn legalize_type_for_sret_store(pos: &mut FuncCursor, val: Value, ty: Type) -> (Value, Type) {
if ty.is_bool() {
let bits = std::cmp::max(8, ty.bits());
let bits = core::cmp::max(8, ty.bits());
let ty = Type::int(bits).unwrap();
let val = pos.ins().bint(ty, val);
(val, ty)
Expand Down