#[inline(always)]
pub fn block<'name>(program_lines: Vec<ProgramLineWrapper<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLineWrapper::ProgramLines(program_lines)
}
#[inline(always)]
pub fn label<'name>(name: impl Into<Name<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::Label(name.into()).into()
}
#[inline(always)]
pub fn function<'name>(name: impl Into<Name<'name>>, function_prototype: Option<FunctionPrototype>) -> ProgramLineWrapper<'name>
{
ProgramLine::Function(name.into(), function_prototype).into()
}
#[inline(always)]
pub fn load_immediate_64<'name>(destination_register: Register, immediate: impl Into<Immediate<'name, u64>>) -> ProgramLineWrapper<'name>
{
ProgramLine::LoadImmediate64(destination_register, immediate.into()).into()
}
#[inline(always)]
pub fn load_map_file_descriptor<MN: TryInto<MapName>>(destination_register: Register, map_name: MN) -> ProgramLineWrapper<'static>
where MN::Error: Debug
{
ProgramLine::LoadMapFileDescriptor(destination_register, map_name.try_into().unwrap()).into()
}
#[inline(always)]
pub fn load_map_value<'name, MN: TryInto<MapName>>(destination_register: Register, map_name: MN, offset_into_value: impl Into<Immediate<'name, i32>>) -> ProgramLineWrapper<'name>
where MN::Error: Debug
{
ProgramLine::LoadMapValue(destination_register, map_name.try_into().unwrap(), offset_into_value.into()).into()
}
#[inline(always)]
pub fn alu_32<'name>(operation: AluOperation, destination_register: Register, source: impl Into<RegisterOrImmediate<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::Alu32(operation, destination_register, source.into()).into()
}
#[inline(always)]
pub fn alu_64<'name>(operation: AluOperation, destination_register: Register, source: impl Into<RegisterOrImmediate<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::Alu64(operation, destination_register, source.into()).into()
}
#[inline(always)]
pub fn to_little_endian<'name>(destination_register: Register, length: impl Into<Immediate<'name, i32>>) -> ProgramLineWrapper<'name>
{
ProgramLine::ToLittleEndian(destination_register, length.into()).into()
}
#[inline(always)]
pub fn to_big_endian<'name>(destination_register: Register, length: impl Into<Immediate<'name, i32>>) -> ProgramLineWrapper<'name>
{
ProgramLine::ToBigEndian(destination_register, length.into()).into()
}
#[inline(always)]
pub fn move_32<'name>(destination_register: Register, source: impl Into<RegisterOrImmediate<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::Move32(destination_register, source.into()).into()
}
#[inline(always)]
pub fn move_64<'name>(destination_register: Register, source: impl Into<RegisterOrImmediate<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::Move64(destination_register, source.into()).into()
}
#[inline(always)]
pub fn move_stack_pointer(destination_register: Register) -> ProgramLineWrapper<'static>
{
move_64(destination_register, Register::fp).into()
}
#[inline(always)]
pub fn load_r0_direct_8<'name>(immediate: impl Into<Immediate<'name, i32>>) -> ProgramLineWrapper<'name>
{
ProgramLine::LoadR0Direct8(immediate.into()).into()
}
#[inline(always)]
pub fn load_r0_direct_16<'name>(immediate: impl Into<Immediate<'name, i32>>) -> ProgramLineWrapper<'name>
{
ProgramLine::LoadR0Direct16(immediate.into()).into()
}
#[inline(always)]
pub fn load_r0_direct_32<'name>(immediate: impl Into<Immediate<'name, i32>>) -> ProgramLineWrapper<'name>
{
ProgramLine::LoadR0Direct32(immediate.into()).into()
}
#[inline(always)]
pub fn load_r0_direct_64<'name>(immediate: impl Into<Immediate<'name, i32>>) -> ProgramLineWrapper<'name>
{
ProgramLine::LoadR0Direct64(immediate.into()).into()
}
#[inline(always)]
pub fn load_r0_indirect_8<'name>(source_register: Register, immediate: impl Into<Immediate<'name, i32>>) -> ProgramLineWrapper<'name>
{
ProgramLine::LoadR0Indirect8(source_register, immediate.into()).into()
}
#[inline(always)]
pub fn load_r0_indirect_16<'name>(source_register: Register, immediate: impl Into<Immediate<'name, i32>>) -> ProgramLineWrapper<'name>
{
ProgramLine::LoadR0Indirect16(source_register, immediate.into()).into()
}
#[inline(always)]
pub fn load_r0_indirect_32<'name>(source_register: Register, immediate: impl Into<Immediate<'name, i32>>) -> ProgramLineWrapper<'name>
{
ProgramLine::LoadR0Indirect32(source_register, immediate.into()).into()
}
#[inline(always)]
pub fn load_r0_indirect_64<'name>(source_register: Register, immediate: impl Into<Immediate<'name, i32>>) -> ProgramLineWrapper<'name>
{
ProgramLine::LoadR0Indirect64(source_register, immediate.into()).into()
}
#[inline(always)]
pub fn load_from_memory_8<'name>(destination_register: Register, source_register: Register, memory_offset: impl Into<MemoryOffset<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::LoadFromMemory8(destination_register, source_register, memory_offset.into()).into()
}
#[inline(always)]
pub fn load_from_memory_16<'name>(destination_register: Register, source_register: Register, memory_offset: impl Into<MemoryOffset<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::LoadFromMemory16(destination_register, source_register, memory_offset.into()).into()
}
#[inline(always)]
pub fn load_from_memory_32<'name>(destination_register: Register, source_register: Register, memory_offset: impl Into<MemoryOffset<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::LoadFromMemory32(destination_register, source_register, memory_offset.into()).into()
}
#[inline(always)]
pub fn load_from_memory_64<'name>(destination_register: Register, source_register: Register, memory_offset: impl Into<MemoryOffset<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::LoadFromMemory64(destination_register, source_register, memory_offset.into()).into()
}
#[inline(always)]
pub fn load_from_stack_variable_8<VS: TryInto<VariableSlotU64>>(destination_register: Register, variable_slot: VS) -> ProgramLineWrapper<'static>
where VS::Error: Debug
{
load_from_memory_8(destination_register, Register::fp, VariableSlotU64::to_memory_slot_from_try_into(variable_slot)).into()
}
#[inline(always)]
pub fn load_from_stack_variable_16<VS: TryInto<VariableSlotU64>>(destination_register: Register, variable_slot: VS) -> ProgramLineWrapper<'static>
where VS::Error: Debug
{
load_from_memory_16(destination_register, Register::fp, VariableSlotU64::to_memory_slot_from_try_into(variable_slot)).into()
}
#[inline(always)]
pub fn load_from_stack_variable_32<VS: TryInto<VariableSlotU64>>(destination_register: Register, variable_slot: VS) -> ProgramLineWrapper<'static>
where VS::Error: Debug
{
load_from_memory_32(destination_register, Register::fp, VariableSlotU64::to_memory_slot_from_try_into(variable_slot)).into()
}
#[inline(always)]
pub fn load_from_stack_variable_64<VS: TryInto<VariableSlotU64>>(destination_register: Register, variable_slot: VS) -> ProgramLineWrapper<'static>
where VS::Error: Debug
{
load_from_memory_64(destination_register, Register::fp, VariableSlotU64::to_memory_slot_from_try_into(variable_slot)).into()
}
#[inline(always)]
pub fn store_to_memory_8<'name>(destination_register: Register, source: impl Into<RegisterOrImmediate<'name>>, memory_offset: impl Into<MemoryOffset<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::StoreToMemory8(destination_register, source.into(), memory_offset.into()).into()
}
#[inline(always)]
pub fn store_to_memory_16<'name>(destination_register: Register, source: impl Into<RegisterOrImmediate<'name>>, memory_offset: impl Into<MemoryOffset<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::StoreToMemory16(destination_register, source.into(), memory_offset.into()).into()
}
#[inline(always)]
pub fn store_to_memory_32<'name>(destination_register: Register, source: impl Into<RegisterOrImmediate<'name>>, memory_offset: impl Into<MemoryOffset<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::StoreToMemory32(destination_register, source.into(), memory_offset.into()).into()
}
#[inline(always)]
pub fn store_to_memory_64<'name>(destination_register: Register, source: impl Into<RegisterOrImmediate<'name>>, memory_offset: impl Into<MemoryOffset<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::StoreToMemory64(destination_register, source.into(), memory_offset.into()).into()
}
#[inline(always)]
pub fn store_to_stack_variable_8<'name, VS: TryInto<VariableSlotU64>>(source: impl Into<RegisterOrImmediate<'name>>, variable_slot: VS) -> ProgramLineWrapper<'name>
where VS::Error: Debug
{
store_to_memory_8(Register::fp, source.into(), VariableSlotU64::to_memory_slot_from_try_into(variable_slot))
}
#[inline(always)]
pub fn store_to_stack_variable_16<'name, VS: TryInto<VariableSlotU64>>(source: impl Into<RegisterOrImmediate<'name>>, variable_slot: VS) -> ProgramLineWrapper<'name>
where VS::Error: Debug
{
store_to_memory_16(Register::fp, source.into(), VariableSlotU64::to_memory_slot_from_try_into(variable_slot))
}
#[inline(always)]
pub fn store_to_stack_variable_32<'name, VS: TryInto<VariableSlotU64>>(source: impl Into<RegisterOrImmediate<'name>>, variable_slot: VS) -> ProgramLineWrapper<'name>
where VS::Error: Debug
{
store_to_memory_32(Register::fp, source.into(), VariableSlotU64::to_memory_slot_from_try_into(variable_slot))
}
#[inline(always)]
pub fn store_to_stack_variable_64<'name, VS: TryInto<VariableSlotU64>>(source: impl Into<RegisterOrImmediate<'name>>, variable_slot: VS) -> ProgramLineWrapper<'name>
where VS::Error: Debug
{
store_to_memory_64(Register::fp, source.into(), VariableSlotU64::to_memory_slot_from_try_into(variable_slot))
}
#[inline(always)]
pub fn store_to_memory_atomic_add_8<'name>(destination_register: Register, source: Register, memory_offset: impl Into<MemoryOffset<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::StoreToMemoryAtomicAdd8(destination_register, source, memory_offset.into()).into()
}
#[inline(always)]
pub fn store_to_memory_atomic_add_16<'name>(destination_register: Register, source: Register, memory_offset: impl Into<MemoryOffset<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::StoreToMemoryAtomicAdd16(destination_register, source, memory_offset.into()).into()
}
#[inline(always)]
pub fn store_to_memory_atomic_add_32<'name>(destination_register: Register, source: Register, memory_offset: impl Into<MemoryOffset<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::StoreToMemoryAtomicAdd32(destination_register, source, memory_offset.into()).into()
}
#[inline(always)]
pub fn store_to_memory_atomic_add_64<'name>(destination_register: Register, source: Register, memory_offset: impl Into<MemoryOffset<'name>>) -> ProgramLineWrapper<'name>
{
ProgramLine::StoreToMemoryAtomicAdd64(destination_register, source, memory_offset.into()).into()
}
#[inline(always)]
pub fn conditional_jump_32<'name>(jump_operation: JumpOperation, destination_register: Register, source: impl Into<RegisterOrImmediate<'name>>, program_counter_offset: impl Into<ProgramCounterOffset<'name, i16>>) -> ProgramLineWrapper<'name>
{
ProgramLine::ConditionalJump32(jump_operation, destination_register, source.into(), program_counter_offset.into()).into()
}
#[inline(always)]
pub fn conditional_jump_64<'name>(jump_operation: JumpOperation, destination_register: Register, source: impl Into<RegisterOrImmediate<'name>>, program_counter_offset: impl Into<ProgramCounterOffset<'name, i16>>) -> ProgramLineWrapper<'name>
{
ProgramLine::ConditionalJump64(jump_operation, destination_register, source.into(), program_counter_offset.into()).into()
}
#[inline(always)]
pub fn unconditional_jump<'name>(program_counter_offset: impl Into<ProgramCounterOffset<'name, i16>>) -> ProgramLineWrapper<'name>
{
ProgramLine::UnconditionalJump(program_counter_offset.into()).into()
}
#[inline(always)]
pub fn function_call(function_identifier: bpf_func_id) -> ProgramLineWrapper<'static>
{
ProgramLine::FunctionCall(function_identifier).into()
}
#[inline(always)]
pub fn relative_function_call<'name>(program_counter_offset: impl Into<ProgramCounterOffset<'name, i32>>) -> ProgramLineWrapper<'name>
{
ProgramLine::RelativeFunctionCall(program_counter_offset.into()).into()
}
#[inline(always)]
pub fn program_exit() -> ProgramLineWrapper<'static>
{
ProgramLine::ProgramExit.into()
}