diff options
| author | Kai Gunger <kgunger12@gmail.com> | 2025-12-07 00:48:05 -0500 |
|---|---|---|
| committer | Kai Gunger <kgunger12@gmail.com> | 2025-12-07 00:48:05 -0500 |
| commit | 9e8e52bf43b325ab636fc4de81acc89eb17a2c1d (patch) | |
| tree | fa1a17c4d48f64b408ca1fbd0fd0c368097e9c21 | |
| parent | c4ece1f196c361f10515d1de41c1b23875769f54 (diff) | |
reg moves
| -rw-r--r-- | tnslc/compile/function.tnsl | 16 | ||||
| -rw-r--r-- | tnslc/compile/scope.tnsl | 8 | ||||
| -rw-r--r-- | tnslc/compile/var.tnsl | 5 | ||||
| -rw-r--r-- | tnslc/eee | 70 |
4 files changed, 25 insertions, 74 deletions
diff --git a/tnslc/compile/function.tnsl b/tnslc/compile/function.tnsl index bf06f80..eaf1da5 100644 --- a/tnslc/compile/function.tnsl +++ b/tnslc/compile/function.tnsl @@ -19,6 +19,7 @@ struct Function { /; _resolve_dlist (~Module parent, ~parse.Node dl) ~parse.Node tn = NULL ~parse.Node n + int reg = 1 /; loop (int i = 0; i < dl`.sub.count) [i++] n = dl`.sub.get(i) /; if (n`._type == parse.NTYPE_TYPE) @@ -31,6 +32,11 @@ struct Function { Var p p.init(tn, n) p._resolve_type(parent) + /; if (reg < 7 && p.is_reg_passed()) + p.loc = reg + ;; else + p.loc = 0 + ;/ self.inputs.push(~p) ;/ ;/ @@ -95,15 +101,17 @@ struct Function { cb`.add_c(" push r14\n\0") cb`.add_c(" push r15 ; scope init\n\n\0") - # TODO: Add all params to the scope + # Add all params to the scope + ~Var inp + /; loop (int i = 0; i < self.inputs.count) [i++] + inp = self.inputs.get(i) + out.mk_set_var(inp) + ;/ return out ;/ /; _end_func(~Scope scope, ~CompBuf cb) - # TODO: place jmp label - # TODO: pop all saved vars - # TODO: ret cb`.add_c(" lea rsp, [rbp - 56]\n\0") cb`.add_c(" pop r15\n\0") cb`.add_c(" pop r14\n\0") diff --git a/tnslc/compile/scope.tnsl b/tnslc/compile/scope.tnsl index c152d00..69e445c 100644 --- a/tnslc/compile/scope.tnsl +++ b/tnslc/compile/scope.tnsl @@ -95,6 +95,14 @@ struct Scope { return out ;/ + + # + # Add variables to the scope + # + + /; mk_set_var(~Var v) + ;/ + # # Label generation # diff --git a/tnslc/compile/var.tnsl b/tnslc/compile/var.tnsl index c26d227..4425cf7 100644 --- a/tnslc/compile/var.tnsl +++ b/tnslc/compile/var.tnsl @@ -112,6 +112,11 @@ struct Var { self._id = id ;/ + /; _is_reg_passed [bool] + /; if () + ;/ + ;/ + /; _print (int idt) _indent(idt) _printf("{ Var : \0") diff --git a/tnslc/eee b/tnslc/eee deleted file mode 100644 index 150f6e9..0000000 --- a/tnslc/eee +++ /dev/null @@ -1,70 +0,0 @@ -==== STARTING FIND WITH KEY ==== -key parts 1 -==== STARTING FIND WITH KEY ==== -key parts 1 -{ Module : - { Struct : Box - size: 8 - members: - } - { Struct : bool - size: 1 - members: - } - { Struct : uint8 - size: 1 - members: - } - { Struct : int8 - size: 1 - members: - } - { Struct : uint16 - size: 2 - members: - } - { Struct : int16 - size: 2 - members: - } - { Struct : uint32 - size: 4 - members: - } - { Struct : int32 - size: 4 - members: - } - { Struct : float32 - size: 4 - members: - } - { Struct : uint64 - size: 8 - members: - } - { Struct : int64 - size: 8 - members: - } - { Struct : float64 - size: 8 - members: - } - { Struct : uint - size: 8 - members: - } - { Struct : int - size: 8 - members: - } - { Struct : float - size: 8 - members: - } - { Struct : void - size: 8 - members: - } -} |