Struct codegem::arch::VCode

source ·
pub struct VCode<I>where
    I: Instr,
{ pub name: String, pub functions: Vec<Function<I>>, }

Fields§

§name: String§functions: Vec<Function<I>>

Implementations§

Examples found in repository?
examples/urcl.rs (line 28)
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
fn main() {
    let mut builder = ModuleBuilder::default().with_name("test");
    let main_func = builder.new_function("main", &[], &Type::Void);
    builder.switch_to_function(main_func);
    let entry = builder.push_block().unwrap();
    builder.switch_to_block(entry);
    let val = builder.push_instruction(&Type::Integer(true, 32), Operation::Integer(
        true,
        69u32.to_le_bytes().to_owned().to_vec())).unwrap();
    
    let val2 = builder.push_instruction(&Type::Integer(true, 32), Operation::Integer(
            true,
            69u32.to_le_bytes().to_owned().to_vec())).unwrap();
    
    let val3 = builder.push_instruction(&Type::Integer(true, 32), Operation::Add(val, val2)).unwrap();
    builder.set_terminator(Terminator::Return(val3));
    let module = builder.build();
    let mut vcode = module.lower_to_vcode::<_, UrclSelector>();
    vcode.allocate_regs::<RegAlloc>();
    vcode.emit_assembly();
    
}
Examples found in repository?
examples/urcl.rs (line 29)
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
fn main() {
    let mut builder = ModuleBuilder::default().with_name("test");
    let main_func = builder.new_function("main", &[], &Type::Void);
    builder.switch_to_function(main_func);
    let entry = builder.push_block().unwrap();
    builder.switch_to_block(entry);
    let val = builder.push_instruction(&Type::Integer(true, 32), Operation::Integer(
        true,
        69u32.to_le_bytes().to_owned().to_vec())).unwrap();
    
    let val2 = builder.push_instruction(&Type::Integer(true, 32), Operation::Integer(
            true,
            69u32.to_le_bytes().to_owned().to_vec())).unwrap();
    
    let val3 = builder.push_instruction(&Type::Integer(true, 32), Operation::Add(val, val2)).unwrap();
    builder.set_terminator(Terminator::Return(val3));
    let module = builder.build();
    let mut vcode = module.lower_to_vcode::<_, UrclSelector>();
    vcode.allocate_regs::<RegAlloc>();
    vcode.emit_assembly();
    
}

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.