diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2022-12-30 00:59:44 -0500 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2022-12-30 00:59:44 -0500 |
commit | d49d3c9a13aecada7e33df86dde6a232ae285329 (patch) | |
tree | 2eaceef6f57a4b20446575e03cebd038ea2bdb94 /tnslc/compile/value.tnsl | |
parent | 3b0ad0c84111be433de39b8a74c03db7e99cb686 (diff) |
Gen asm to fix registers after a call
Diffstat (limited to 'tnslc/compile/value.tnsl')
-rw-r--r-- | tnslc/compile/value.tnsl | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/tnslc/compile/value.tnsl b/tnslc/compile/value.tnsl index 28586f4..747c172 100644 --- a/tnslc/compile/value.tnsl +++ b/tnslc/compile/value.tnsl @@ -36,15 +36,20 @@ ;return "si" ;; if (r == 5) ;return "di" - ;; if (r == 6) - ;return "bp" ;/ - ;return string_from_int(r) + ;return string_from_int(r + 2) ;/ /; method Value + /; get_norm_sz [int] + /; if (self._type.ptr !== 0) + ;return 8 + ;/ + ;returnself._type._size + ;/ + /; get_norm_loc [{}uint8] /; if (self.on_stack) ;return val_from_address(self.loc, "%rsp") @@ -85,10 +90,10 @@ ;/ /; standard_op(Value other, {}uint8 op) [{}uint8] - ;int tsz = v._type._size - ;v._type._size = self._type._size - ;{}uint8 tmp = v.get_norm_loc() - ;v._type._size = tsz + ;int tsz = other._type._size + ;other._type._size = self._type._size + ;{}uint8 tmp = other.get_norm_loc() + ;other._type._size = tsz ;{}uint8 out = "\t" ;add_strings(~out, ~op) ;out.append(' ') @@ -193,6 +198,14 @@ ;/ ;/ + /; ref_value (Value to_ref) [{}uint8] + /; if (!to_ref.on_stack) + ;return "" + ;/ + + ;return self.standard_op(to_ref, "lea") + ;/ + /; deref_value [{}uint8] /; if (self._type.ptr == 0) ;return "" @@ -223,7 +236,7 @@ /; if (self.literal) ;self.val = v.val ;return "" - ;; else if (!self.on_stack) + ;; else if (!(self.on_stack)) ;return self.standard_op(v, "mov") ;/ ;/ |