Generate a Builder data type. WIP.
The Builder provides a convenient interface for inserting instructions into an extended basic block. The bulk of the builder methods are generated automatically from the meta language instruction descriptions. Still TODO: Keep track of an insertion position.
This commit is contained in:
27
src/libcretonne/ir/builder.rs
Normal file
27
src/libcretonne/ir/builder.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
//! Cretonne instruction builder.
|
||||
//!
|
||||
//! A `Builder` provides a convenient interface for inserting instructions into a Cretonne
|
||||
//! function. Many of its methods are generated from the meta language instruction definitions.
|
||||
|
||||
use ir::{types, instructions};
|
||||
use ir::{InstructionData, DataFlowGraph};
|
||||
use ir::{Opcode, Type, Inst, Value, Ebb, JumpTable, VariableArgs, FuncRef};
|
||||
use ir::immediates::{Imm64, Uimm8, Ieee32, Ieee64, ImmVector};
|
||||
use ir::condcodes::{IntCC, FloatCC};
|
||||
|
||||
pub struct Builder<'a> {
|
||||
dfg: &'a mut DataFlowGraph,
|
||||
}
|
||||
|
||||
impl<'a> Builder<'a> {
|
||||
// Create and insert an instruction.
|
||||
// This method is used by the generated format-specific methods.
|
||||
fn insert_inst(&mut self, data: InstructionData) -> Inst {
|
||||
let inst = self.dfg.make_inst(data);
|
||||
inst
|
||||
}
|
||||
}
|
||||
|
||||
// Include code generated by `meta/gen_instr.py`. This file includes `Builder` methods per
|
||||
// instruction format and per opcode for inserting instructions.
|
||||
include!(concat!(env!("OUT_DIR"), "/builder.rs"));
|
||||
Reference in New Issue
Block a user