Commit d216bf15 authored by qinsoon's avatar qinsoon

allow building int128 constant by API

parent df19c5f6
......@@ -63,6 +63,7 @@ pub struct NodeFuncSig { pub id: MuID, pub paramtys: Vec<MuTypeNode>, pub rettys
#[derive(Debug)]
pub enum NodeConst {
ConstInt { id: MuID, ty: MuTypeNode, value: u64 },
ConstIntEx { id: MuID, ty: MuTypeNode, value: Vec<u64>},
ConstFloat { id: MuID, ty: MuTypeNode, value: f32 },
ConstDouble { id: MuID, ty: MuTypeNode, value: f64 },
ConstNull { id: MuID, ty: MuTypeNode },
......
......@@ -211,7 +211,8 @@ impl MuIRBuilder {
}
pub fn new_const_int_ex(&mut self, id: MuID, ty: MuID, values: &[u64]) {
panic!("Not implemented")
self.bundle.consts.insert(id, Box::new(NodeConst::ConstIntEx {id: id,
ty: ty, value: values.to_vec()}));
}
pub fn new_const_float(&mut self, id: MuID, ty: MuID, value: f32) {
......@@ -1108,6 +1109,11 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
let c = Constant::Int(value);
(c, t)
},
NodeConst::ConstIntEx { id: _, ty, ref value } => {
let t = self.ensure_type_rec(ty);
let c = Constant::IntEx(value.clone());
(c, t)
},
NodeConst::ConstFloat { id: _, ty, value } => {
let t = self.ensure_type_rec(ty);
let c = Constant::Float(value);
......
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