Skip to content

Instantly share code, notes, and snippets.

@antonijn
Created August 6, 2014 14:00
Show Gist options
  • Save antonijn/479ab95a0604a5249dd0 to your computer and use it in GitHub Desktop.
Save antonijn/479ab95a0604a5249dd0 to your computer and use it in GitHub Desktop.
/*
* Part of the C AIR instruction to file writer
*/
static void air_instr_to_string(FILE * f, struct air_expr * e)
{
void * it;
int j;
struct air_expr * ex;
struct air_instr * i = e;
fprintf(f, "\t");
if (i->base.type != &cvoid) {
fprintf(f, "%%%d = ", air_instr_number(i));
}
}
hidden const char[2] @0 = char[2] { 9, 0 }
hidden cosnt char[8] @1 = char[8] { 37, 37, 37, 100, 32, 61, 32, 0 }
void @air_instr_to_string(FILE* %f, struct air_expr* %e) {
%0 = alloca FILE*
%1 = alloca struct air_expr*
%2 = alloca void*
%3 = alloca int
%4 = alloca struct air_expr*
%5 = alloca struct air_instr*
store FILE** %0, FILE* %f
store struct air_expr** %1, struct air_expr* %e
%6 = load struct air_expr** %1
%7 = bitcast struct air_expr* %6, struct air_instr*
store struct air_instr** %5, struct air_instr* %7
%8 = load FILE** %0
%9 = deepptr const char[2]* @0, int 0
%10 = call int @fprintf(FILE* %8, const char* %9)
%11 = load struct air_instr** %5
%12 = deepptr struct air_instr* %11, int 0
%13 = deepptr struct air_expr* %12, int 1
%14 = load struct ctype** %13
%15 = cmp eq struct ctype* %13, struct ctype* @cvoid
split bool %15, %16, %22
%16:
%17 = load FILE** %0
%18 = deepptr const char[8]* @1
%19 = load struct air_instr** %5
%20 = call int @air_instr_number(struct air_instr* %19)
%21 = call int @fprintf(FILE* %17, const char* %18, int %20)
jmp %22
%22:
leave
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment