aboutsummaryrefslogtreecommitdiffhomepage
path: root/ir.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-17 23:26:45 +0200
committerlemon <lsof@mailbox.org>2023-06-17 23:26:45 +0200
commit962ad175aee634274b408ead38b13e6bc90e2fe7 (patch)
treecfda733adf56ed12e829f594e0b6d66f0a1a7a70 /ir.c
parentec28e9057e84b92acabb7ebf9122af59738917ad (diff)
basic ELF output
Diffstat (limited to 'ir.c')
-rw-r--r--ir.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/ir.c b/ir.c
index d8772ad..1351f02 100644
--- a/ir.c
+++ b/ir.c
@@ -1,4 +1,5 @@
#include "ir.h"
+#include "common.h"
uchar type2cls[NTYPETAG];
uchar cls2siz[KF8+1];
@@ -191,6 +192,22 @@ mkdatref(uint siz, uint align, const void *bytes, uint n, bool deref)
return mkref(RXCON, addcon(&(struct xcon){.isdat = 1, .deref = deref, .dat = dattab.n - 1}));
}
+const char *
+xcon2sym(int ref)
+{
+ extern const char *intern(const char *);
+ char buf[32];
+ struct wbuf wbuf = MEMBUF(buf, sizeof buf);
+ struct xcon *con = &conht[ref];
+
+ assert(con->isdat || con->issym);
+ if (con->issym) return con->sym;
+ bfmt(&wbuf, ".L.%d", con->dat);
+ ioputc(&wbuf, 0);
+ assert(!wbuf.err);
+ return intern(buf);
+}
+
struct instr
mkalloca(uint siz, uint align)
{