vnmakarov / mir

A lightweight JIT compiler based on MIR (Medium Internal Representation) and C11 JIT compiler and interpreter based on MIR
MIT License
2.24k stars 147 forks source link

Question: How can i generate mir when use MIR api ? #283

Closed LightSun closed 1 year ago

LightSun commented 1 year ago

Hello , mir is a very good project , I like it. I want to use MIR to generate mir codes directly, for example define and use struct. It is some like this.

#include <stdlib.h>
#include <stdio.h>
struct Stu{
    int age;
    char* name;
};

void test_pointer(struct Stu* stu){
    printf("test_pointer = %s, age = %d\n", stu->name, stu->age);
}

void test_copy(struct Stu stu){
    printf("test_copy = %s, age = %d\n", stu.name, stu.age);
}

Can you help me ?

vnmakarov commented 1 year ago

Thank you for your interest in MIR project. MIR API is described in file MIR.md.

Examples how to use MIR API can be found in mir-tests/api-*.h. The biggest file api-sieve.h contains code to create MIR erathosthenes sieve program.

LightSun commented 1 year ago

ok , thanks. I will try.