diff options
| author | gingerBill <bill@gingerbill.org> | 2018-02-28 11:20:11 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-02-28 11:20:11 +0000 |
| commit | d3ea334e7ab2897bbc948acc57aa9ba073304215 (patch) | |
| tree | 8f6016ab7bd62c0320c893e0cb7fa6337054420f /src/ir_print.cpp | |
| parent | 223c473cf64845f0c0824375fa98ca51bad66fc1 (diff) | |
`cstring`
Diffstat (limited to 'src/ir_print.cpp')
| -rw-r--r-- | src/ir_print.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp index eaf7e0477..632d9c0e1 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -340,6 +340,7 @@ void ir_print_type(irFileBuffer *f, irModule *m, Type *t, bool in_struct) { case Basic_any: ir_write_str_lit(f, "%..any"); return; case Basic_rawptr: ir_write_str_lit(f, "%..rawptr"); return; case Basic_string: ir_write_str_lit(f, "%..string"); return; + case Basic_cstring: ir_write_str_lit(f, "i8*"); return; } break; @@ -551,11 +552,25 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type * ir_write_str_lit(f, "zeroinitializer"); break; } + Type *t = core_type(type); if (!is_type_string(type)) { GB_ASSERT(is_type_array(type)); ir_write_str_lit(f, "c\""); ir_print_escape_string(f, str, false, false); ir_write_str_lit(f, "\\00\""); + } else if (t == t_cstring) { + // HACK NOTE(bill): This is a hack but it works because strings are created at the very end + // of the .ll file + irValue *str_array = ir_add_global_string_array(m, str); + ir_write_str_lit(f, "getelementptr inbounds ("); + ir_print_type(f, m, str_array->Global.entity->type); + ir_write_str_lit(f, ", "); + ir_print_type(f, m, str_array->Global.entity->type); + ir_write_str_lit(f, "* "); + ir_print_encoded_global(f, str_array->Global.entity->token.string, false); + ir_write_str_lit(f, ", "); + ir_print_type(f, m, t_int); + ir_write_str_lit(f, " 0, i32 0)"); } else { // HACK NOTE(bill): This is a hack but it works because strings are created at the very end // of the .ll file |