aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-04-03 23:32:57 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-04-03 23:32:57 +0300
commit68059b52c389143e766c5499c76c6c90c6b82846 (patch)
tree6e10707dbc417946dee5c4dbb333a4952914a9e8 /include
parentf4be2429f38faba0c54862055f808cb242a7eb49 (diff)
downloadqbt-68059b52c389143e766c5499c76c6c90c6b82846.tar.gz
qbt-68059b52c389143e766c5499c76c6c90c6b82846.zip
add callsite register saving
Diffstat (limited to 'include')
-rw-r--r--include/qbt/nodes.h28
-rw-r--r--include/qbt/vec.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/include/qbt/nodes.h b/include/qbt/nodes.h
index ff30b12..22de9ff 100644
--- a/include/qbt/nodes.h
+++ b/include/qbt/nodes.h
@@ -41,6 +41,15 @@ enum insn_type {
RETARG,
PARAM,
RETVAL,
+
+ /* internal */
+ SAVE,
+ RESTORE,
+};
+
+enum insn_flags {
+ CALL_TEARDOWN = (1 << 0),
+ CALL_SETUP = (1 << 1),
};
#define FOREACH_INSN_TYPE(M) \
@@ -78,6 +87,8 @@ enum insn_type {
M(PARAM) \
M(RET) \
M(RETVAL) \
+ M(SAVE) \
+ M(RESTORE)
static inline const char *op_str(enum insn_type n) {
#define CASE(I) case I: return #I;
@@ -115,8 +126,19 @@ struct insn {
enum val_type vtype;
struct val out;
struct val in[2];
+ enum insn_flags flags;
};
+static inline void set_insn_flags(struct insn *i, enum insn_flags flags)
+{
+ i->flags |= flags;
+}
+
+static inline bool has_insn_flag(struct insn i, enum insn_flags flag)
+{
+ return i.flags & flag;
+}
+
struct blk {
const char *name;
int64_t id;
@@ -143,6 +165,7 @@ struct fn {
size_t ntmp;
size_t nblk;
size_t max_callee_save;
+ size_t max_call_save;
bool has_calls;
struct vec blks;
struct vec labels;
@@ -316,4 +339,9 @@ struct label_map {
#define foreach_insn(iter, insns) \
foreach_vec(iter, insns)
+static inline void insn_insert(struct blk *b, struct insn i, size_t pos)
+{
+ vec_insert(&b->insns, &i, pos);
+}
+
#endif /* NODES_H */
diff --git a/include/qbt/vec.h b/include/qbt/vec.h
index 471e127..79970a6 100644
--- a/include/qbt/vec.h
+++ b/include/qbt/vec.h
@@ -18,6 +18,7 @@ size_t vec_len(struct vec *v);
void *vec_at(struct vec *v, size_t i);
void *vec_pop(struct vec *v);
void vec_append(struct vec *v, void *n);
+void vec_insert(struct vec *v, void *n, size_t i);
#define foreach_vec(iter, v) \
for (size_t iter = 0, __n = vec_len(&v); iter < __n; ++iter)