Implement 64 bit function call
This commit is contained in:
parent
0b6a9bd89b
commit
e1a2f1239d
@ -1,7 +1,7 @@
|
|||||||
use inkwell::values::{BasicValueEnum, CallSiteValue, IntValue, PointerValue};
|
use inkwell::values::{BasicValueEnum, CallSiteValue, IntValue, PointerValue};
|
||||||
use itertools::Either;
|
use itertools::Either;
|
||||||
|
|
||||||
use crate::codegen::{CodeGenContext, CodeGenerator};
|
use crate::codegen::{macros::codegen_unreachable, CodeGenContext, CodeGenerator};
|
||||||
|
|
||||||
/// Generates a call to string equality comparison. Returns an `i1` representing whether the strings are equal.
|
/// Generates a call to string equality comparison. Returns an `i1` representing whether the strings are equal.
|
||||||
pub fn call_string_eq<'ctx, G: CodeGenerator + ?Sized>(
|
pub fn call_string_eq<'ctx, G: CodeGenerator + ?Sized>(
|
||||||
@ -12,10 +12,16 @@ pub fn call_string_eq<'ctx, G: CodeGenerator + ?Sized>(
|
|||||||
str2_ptr: PointerValue<'ctx>,
|
str2_ptr: PointerValue<'ctx>,
|
||||||
str2_len: IntValue<'ctx>,
|
str2_len: IntValue<'ctx>,
|
||||||
) -> IntValue<'ctx> {
|
) -> IntValue<'ctx> {
|
||||||
let func = ctx.module.get_function("nac3_str_eq").unwrap_or_else(|| {
|
let (func_name, return_type) = match ctx.ctx.i32_type().get_bit_width() {
|
||||||
|
32 => ("nac3_str_eq", ctx.ctx.i32_type()),
|
||||||
|
64 => ("nac3_str_eq64", ctx.ctx.i64_type()),
|
||||||
|
bw => codegen_unreachable!(ctx, "Unsupported size type bit width: {}", bw),
|
||||||
|
};
|
||||||
|
|
||||||
|
let func = ctx.module.get_function(func_name).unwrap_or_else(|| {
|
||||||
ctx.module.add_function(
|
ctx.module.add_function(
|
||||||
"nac3_str_eq",
|
func_name,
|
||||||
ctx.ctx.i32_type().fn_type(
|
return_type.fn_type(
|
||||||
&[
|
&[
|
||||||
str1_ptr.get_type().into(),
|
str1_ptr.get_type().into(),
|
||||||
str1_len.get_type().into(),
|
str1_len.get_type().into(),
|
||||||
|
Loading…
Reference in New Issue
Block a user