Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement inline assembly #21

Merged
merged 15 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions hir-type/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern crate alloc;
use alloc::{alloc::Layout, boxed::Box, vec::Vec};
use core::fmt;

const FELT_SIZE: usize = core::mem::size_of::<u64>();
const WORD_SIZE: usize = core::mem::size_of::<[u64; 4]>();

/// Represents the type of a value
Expand Down Expand Up @@ -179,6 +180,13 @@ impl Type {
self.layout().pad_to_align().size()
}

/// Returns the size in field elements of this type, including necessary alignment padding
pub fn size_in_felts(&self) -> usize {
let bytes = self.size_in_bytes();
let trailing = bytes % FELT_SIZE;
(bytes / FELT_SIZE) + ((trailing > 0) as usize)
}

/// Returns the size in words of this type, including necessary alignment padding
pub fn size_in_words(&self) -> usize {
let bytes = self.size_in_bytes();
Expand Down
Loading
Loading