aboutsummaryrefslogtreecommitdiffhomepage
path: root/targ.c
diff options
context:
space:
mode:
Diffstat (limited to 'targ.c')
-rw-r--r--targ.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/targ.c b/targ.c
new file mode 100644
index 0000000..7368fa5
--- /dev/null
+++ b/targ.c
@@ -0,0 +1,41 @@
+#include "common.h"
+
+uchar targ_primsizes[TYPTR+1];
+uchar targ_primalign[TYPTR+1];
+enum typetag targ_sizetype;
+bool targ_charsigned, targ_bigendian;
+
+struct targ {
+ const char *name;
+ struct { uchar longsize, vlongsize, ptrsize, valistsize; };
+ struct { uchar longalign, vlongalign, doublealign, ptralign; };
+ bool charsigned;
+ uchar sizetype;
+} targs[] = {
+ { "amd64-sysv", {8, 8, 8, 24}, {8, 8, 8, 8}, 1, TYULONG }
+};
+
+void
+targ_init(const char *starg)
+{
+ struct targ *t = &targs[0];
+ uchar *sizes = targ_primsizes, *align = targ_primalign;
+
+ sizes[TYBOOL] = sizes[TYCHAR] = sizes[TYSCHAR] = sizes[TYUCHAR] = 1;
+ sizes[TYSHORT] = sizes[TYUSHORT] = 2;
+ sizes[TYUINT] = sizes[TYINT] = 4;
+ sizes[TYFLOAT] = 4;
+ sizes[TYDOUBLE] = 8;
+ memcpy(align, sizes, sizeof targ_primalign);
+ sizes[TYULONG] = sizes[TYLONG] = t->longsize;
+ sizes[TYUVLONG] = sizes[TYVLONG] = t->vlongsize;
+ sizes[TYPTR] = t->ptrsize;
+ sizes[TYVALIST] = t->valistsize;
+ align[TYULONG] = align[TYLONG] = t->longalign;
+ align[TYUVLONG] = align[TYVLONG] = t->vlongalign;
+ align[TYDOUBLE] = t->doublealign;
+ align[TYVALIST] = align[TYPTR] = t->ptralign;
+ targ_sizetype = t->sizetype;
+ targ_charsigned = t->charsigned;
+ targ_bigendian = 0;
+}