Skip to content
Merged
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
105 changes: 105 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
members = [
"assembler",
"object",
"linker",
"linker", "ir",
]

[package]
name = "whale"
version = "0.1.0"
edition = "2021"

[features]
default = []
socket-cli = ["ir/socket", "dep:serde_json"]

[dependencies]
assembler = { path = "assembler" }
object = { path = "object" }
ir = { path = "ir", version = "0.1.0", default-features = false }
serde_json = { version = "1", optional = true }
4 changes: 0 additions & 4 deletions assembler/src/isa/amd64/encoding/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@ use crate::ast::MemoryOperand;
use crate::error::AsmError;
use crate::isa::amd64::tables::{REGISTERS_32, REGISTERS_64};

/// displacement 크기
#[derive(Debug, Clone)]
pub enum DispKind {
Disp8(i8),
Disp32(i32),
}

/// Memory addressing 인코딩 결과
#[derive(Debug, Clone)]
pub struct EncodedAddress {
pub mod_bits: u8,
pub rm_bits: u8,
pub sib: Option<(u8, u8, u8)>, // (scale, index, base)
pub disp: Option<DispKind>,

/// REX 확장 정보
pub rex_b: bool,
pub rex_x: bool,
}

/// base/index → 레지스터 번호 찾기
fn reg_code(name: &str, mode: u8) -> Option<u8> {
let regs = match mode {
64 => REGISTERS_64,
Expand Down
11 changes: 11 additions & 0 deletions ir/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "ir"
version = "0.1.0"
edition = "2021"

[features]
default = []
socket = ["dep:serde"]

[dependencies]
serde = { version = "1", features = ["derive"], optional = true }
26 changes: 26 additions & 0 deletions ir/src/block.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MPL-2.0

use crate::{BlockId, Instruction, Terminator};

#[derive(Clone, Debug)]
pub struct BasicBlock {
pub id: BlockId,
pub name: String,
pub instructions: Vec<Instruction>,
pub terminator: Option<Terminator>,
}

impl BasicBlock {
pub fn new(id: BlockId, name: impl Into<String>) -> Self {
Self {
id,
name: name.into(),
instructions: Vec::new(),
terminator: None,
}
}

pub fn is_terminated(&self) -> bool {
self.terminator.is_some()
}
}
Loading