Commit 1168f297 authored by qinsoon's avatar qinsoon
Browse files

[wip] get handle from global, and create handle from int

parent 55aa2fe5
use ir::*;
use ptr::*;
use types::*;
use utils::Address;
use std::collections::HashMap;
......@@ -35,121 +34,4 @@ impl MuBundle {
// name_id_map: HashMap::new()
}
}
}
#[derive(Copy, Clone, Debug)]
pub struct APIHandleKey {
pub id: MuID,
pub v: APIHandleKeyKind
}
#[derive(Copy, Clone, Debug)]
pub enum APIHandleKeyKind {
Int,
Float,
Double,
UPtr,
UFP,
// SeqValue
Struct,
Array,
Vector,
// GenRef
Ref,
IRef,
TagRef64,
FuncRef,
ThreadRef,
StackRef,
FCRef, // frame cursor ref
// GenRef->IR
Bundle,
// GenRef->IR->Child
Type,
FuncSig,
FuncVer,
BB,
Inst,
// GenRef->IR->Child->Var->Global
Const,
Global,
Func,
ExpFunc,
// GenRef->IR->Child->Var->Local
NorParam,
ExcParam,
InstRes,
}
macro_rules! handle_constructor {
($fn_name: ident, $kind: ident) => {
pub fn $fn_name(id: MuID) -> APIHandleKey {
APIHandleKey{
id: id, v: APIHandleKeyKind::$kind
}
}
}
}
handle_constructor!(handle_int, Int);
handle_constructor!(handle_float, Float);
handle_constructor!(handle_double, Double);
handle_constructor!(handle_uptr, UPtr);
handle_constructor!(handle_ufp, UFP);
handle_constructor!(handle_struct, Struct);
handle_constructor!(handle_array, Array);
handle_constructor!(handle_vector, Vector);
handle_constructor!(handle_ref, Ref);
handle_constructor!(handle_iref, IRef);
handle_constructor!(handle_tagref64, TagRef64);
handle_constructor!(handle_funcref, FuncRef);
handle_constructor!(handle_threadref, ThreadRef);
handle_constructor!(handle_stackref, StackRef);
handle_constructor!(handle_fcref, FCRef);
handle_constructor!(handle_bundle, Bundle);
handle_constructor!(handle_type, Type);
handle_constructor!(handle_funcsig, FuncSig);
handle_constructor!(handle_funcver, FuncVer);
handle_constructor!(handle_bb, BB);
handle_constructor!(handle_inst, Inst);
handle_constructor!(handle_const, Const);
handle_constructor!(handle_global, Global);
handle_constructor!(handle_func, Func);
handle_constructor!(handle_expfunc, ExpFunc);
handle_constructor!(handle_norparam, NorParam);
handle_constructor!(handle_excparam, ExcParam);
handle_constructor!(handle_instres, InstRes);
#[derive(Clone)]
pub enum APIHandleValue {
Int(u64),
Float(f32),
Double(f64),
UPtr(Address),
UFP(Address),
Struct(Vec<APIHandleValue>),
Array(Vec<APIHandleValue>),
Vector(Vec<APIHandleValue>),
Ref(Address),
IRef(Address),
TagRef64(u64),
FuncRef(MuID),
ThreadRef,
StackRef,
FCRef,
IBRef
}
\ No newline at end of file
......@@ -488,4 +488,4 @@ impl DestArg {
&DestArg::Freshbound(n) => format!("${}", n)
}
}
}
\ No newline at end of file
}
......@@ -42,4 +42,4 @@ pub mod inst;
pub mod types;
pub mod ir_semantics;
pub mod ptr;
pub mod op;
\ No newline at end of file
pub mod op;
......@@ -104,4 +104,4 @@ pub fn P<T>(value: T) -> P<T> {
// fn encode<S: Encoder> (&self, s: &mut S) -> Result<(), S::Error> {
// s.emit_usize(self.id())
// }
//}
\ No newline at end of file
//}
......@@ -2898,4 +2898,4 @@ pub fn spill_rewrite(
cf.mc().trace_mc();
new_nodes
}
\ No newline at end of file
}
......@@ -184,4 +184,4 @@ pub trait CodeGenerator {
// fp conversion
fn emit_cvtsi2sd_f64_r (&mut self, dest: Reg, src: Reg);
fn emit_cvtsd2si_r_f64 (&mut self, dest: Reg, src: Reg);
}
\ No newline at end of file
}
......@@ -518,4 +518,4 @@ pub fn estimate_insts_for_ir(inst: &Instruction) -> usize {
Move(_) => 0,
ExnInstruction{ref inner, ..} => estimate_insts_for_ir(&inner)
}
}
\ No newline at end of file
}
......@@ -306,4 +306,4 @@ impl RegGroup {
_ => unimplemented!()
}
}
}
\ No newline at end of file
}
pub mod graph_coloring;
pub use compiler::backend::reg_alloc::graph_coloring::RegisterAllocation;
\ No newline at end of file
pub use compiler::backend::reg_alloc::graph_coloring::RegisterAllocation;
......@@ -127,4 +127,4 @@ impl FrameSlot {
)
})
}
}
\ No newline at end of file
}
......@@ -144,4 +144,4 @@ pub trait MachineCode {
pub trait MachineInst {
}
\ No newline at end of file
}
......@@ -82,4 +82,4 @@ impl Default for CompilerPolicy {
CompilerPolicy{passes: passes}
}
}
\ No newline at end of file
}
......@@ -272,4 +272,4 @@ fn process_dest(dest: Destination, blocks_to_insert: &mut Vec<IntermediateBlockI
dest
}
}
\ No newline at end of file
}
......@@ -464,4 +464,4 @@ impl CompilerPass for Inlining {
debug!("after inlining: {:?}", func);
}
}
}
\ No newline at end of file
}
......@@ -71,4 +71,4 @@ impl AddressBitmap {
pub fn print(&self) {
self.bitmap.print();
}
}
\ No newline at end of file
}
......@@ -41,4 +41,4 @@ impl <T> AddressMap<T> where T: Copy{
let index = (addr.diff(self.start) >> LOG_POINTER_SIZE) as isize;
unsafe {*self.ptr.offset(index)}
}
}
\ No newline at end of file
}
......@@ -145,4 +145,4 @@ mod test {
assert_eq!(bitmap.length_until_next_bit(5), 1);
assert_eq!(bitmap.length_until_next_bit(6), 0);
}
}
\ No newline at end of file
}
......@@ -174,4 +174,4 @@ mod tests {
assert_eq!(vec[1].gen_ref_offsets(), vec![0, 16, 32, 48, 64, 80, 96, 112, 128, 144]);
assert_eq!(vec[2].gen_ref_offsets(), (0..100).map(|x| x * 16).collect::<Vec<ByteSize>>());
}
}
\ No newline at end of file
}
......@@ -4,4 +4,4 @@ mod address_map;
pub mod gctype;
pub use self::address_bitmap::AddressBitmap;
pub use self::address_map::AddressMap;
\ No newline at end of file
pub use self::address_map::AddressMap;
......@@ -124,4 +124,4 @@ impl fmt::Display for FreeListNode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "FreeListNode#{}(start={:#X}, size={}, state={:?})", self.id, self.start, self.size, self.mark)
}
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment