aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
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)