Search
Tuesday, 15th of May 2018, 21:00:36 UTC
21:00:45
karlosz
and why doesn't typeq get generated?
21:00:58
karlosz
arent those nodes needed for type inference?
21:01:13
karlosz
im a little confused why HIR doesn't convert to half the instructions documented
21:01:39
Bike
well, what would generate typeq?
21:01:43
karlosz
are those introudced by later transformation?
21:02:00
Bike
right, but typep is a function.
21:02:11
Bike
if you want it to generate typeq you'll need to provide a definition for typep that uses typeq.
21:02:35
karlosz
definition in what senese?
21:02:52
karlosz
same with eq-instruction
21:03:07
Bike
probably an inline definition
21:03:10
karlosz
(if (eq x y) x y) converts to a function call to eq
21:03:13
karlosz
and then produces eq instruction
21:03:28
Bike
clasp has (defun eq (x y) (if (cleavir-primop:eq x y) t nil))
21:04:03
Bike
so the ast doesn't have a function call, just the eq ast, which is converted into the eq instruction.
21:04:11
Bike
cleavir is pretty heavily designed around inlining.
21:04:55
karlosz
then i would need to redefine clisp's CL functions
21:05:01
karlosz
and declaim them inline
21:05:10
karlosz
at least for things like eq and typep
21:05:22
karlosz
if i want to take advantage of those primops
21:05:57
Bike
or just have function-info return an appropriate ast.
21:06:14
karlosz
great, thanks for your help
23:21:50
Kevslinger
Google cloud now has a machine you can rent out with 160 virtual CPUs and 3.75 TB of RAM.
23:21:57
Kevslinger
We can build clasp in no time with that!
0:22:04
drmeister
Just saw Avengers: Infinity war - has everyone seen it?
0:22:33
drmeister
All my arguments about how pointless it is are back on the table.
0:26:21
stassats`
so, you prefer Arrow?
0:27:26
stassats`
some superhero tv show
0:27:55
Bike
wasn't that the one with Snart
0:27:56
drmeister
Ah - no - I'm more of a Tick fan.
0:28:07
Bike
who wears sunglasses at night
0:30:33
karlosz
still not quite sure what i should be subclassing. in function-info, if i make an instance of global-function-info with :inline set, should i return an subclass of fdefinition-ast, maybe system-fdefinition?
0:30:47
karlosz
i was looking through clasp but i couldn't find how core:cleavir-ast is defined
0:31:29
Bike
just return an fdefinition-ast. why would you need a subclass?
0:32:29
karlosz
well, i don't want to start redefining things like eq and 1+ and declaring them inline in order to get specialized system call HIR nodes
0:32:47
karlosz
it would destroy the image
0:33:01
Bike
you don't have to redefine them, just have function-info return an fdefinition-ast without actually redefining the class
0:33:08
Bike
redefining the function*
0:35:37
karlosz
then how are system functions distinguished from normal functions? or are you saying that theres no need to distinguish them at the AST level?
0:36:00
karlosz
should i only check and treat them differently at AST->HIR?
0:36:24
Bike
okay maybe i didn't make my strategy clear.
0:36:48
Bike
also i messed up, the inline ast isn't an fdefinition ast
0:36:53
Bike
it's a function-ast, which has a body
0:37:12
Bike
what i'm saying is for 1+, you return a function-ast with a body consisting of your custom syscall-ast or whatever you want to call it
0:37:21
Bike
cleavir will then use the syscall-ast as the call
1:24:22
drmeister
I've got compile working.
1:25:18
Bike
so did we need that debug stuff?
1:25:48
drmeister
I tried to get rid of it - I'll keep trying.
1:47:04
karlosz
i was able to make the ast by faking up another function and replacing its node with the node i want, but when i graph it it seems like its not inlining properly
1:47:24
Bike
yeah that's problem number two, inlining doesn't work in cst-to-ast at the moment.
1:47:36
Bike
you can try generate-ast, which is old but more functional
1:49:01
karlosz
i'm not using cst-to-ast though
1:49:11
Bike
oh, you're using generate-ast?
1:49:17
karlosz
just the :inline keyword to make instance cleavir-env:global-function-info
1:50:00
karlosz
i guess more like i didn't choose to use cst-to-ast
1:50:25
Bike
okay, so what is it you're doing
1:50:37
karlosz
so in cleavir-env:function-info
1:50:45
Bike
i mean how are you getting hir
1:50:47
karlosz
i check if the function name is in the funtab
1:51:18
karlosz
i copied the compile-ast method from funcall-ast
1:51:36
Bike
are you using cst-to-ast or generate-ast
1:51:41
Bike
to get an ast from source
1:52:22
karlosz
i call cleavir-ast:make-function-ast directly
1:52:49
Bike
inlining occurs during generate-ast.
1:52:58
Bike
the ast functions just make ast objects. they do no processing
1:53:16
karlosz
you mean the toplevel calls to generate everything
1:53:21
karlosz
yeah let me try generate ast
2:00:23
karlosz
hm seems like generate-ast needs more of the environment methods declared to work
2:01:28
karlosz
well cst-to-ast didn't complain when i didn't have a method on cleavir-env:declarations
2:01:44
karlosz
but i had to make a dummy one to get generate-ast to work, for example
2:01:59
karlosz
so what exactly is the difference between the two
2:02:08
karlosz
i see that generate ast bypasses csts directly
2:02:11
Bike
generate-ast is the old one, that works on source forms directly.
2:02:12
karlosz
im guessing csts are newer
2:03:31
karlosz
and generate-ast is also complaining about a method for cleavir-ast:chilren not being defined on my new node
2:03:39
karlosz
which is probably due to inlining something?
2:03:53
karlosz
at least that didn't happen with csts
2:04:00
Bike
might be. you should define children anyway though.
2:04:01
karlosz
i guess generate ast just does more stuff
2:04:28
Bike
generate-ast will try to copy ASTs, which cst-to-ast will not
2:04:46
karlosz
as part of inlining?
2:05:41
Bike
yeah. it'll copy the function-ast.
2:20:30
karlosz
i found out i needed define-save-info to make generate ast work
2:20:58
karlosz
is it for copying again?
2:21:31
Bike
that tells it what to copy.
2:22:05
karlosz
this is probably a limitation of the inlining
2:22:17
karlosz
but instead of brining just the new node
2:22:29
karlosz
i get all the extra function argument stuff too
2:22:40
karlosz
well just one extra node
2:23:01
karlosz
a later pass will eventually remove that, right?
2:23:08
Bike
i'm not sure what you mean.
2:23:18
Bike
what extra function argument stuff?
2:23:48
karlosz
https://paste.gnome.org/powtfx7jg
2:24:01
karlosz
thats the output of (lambda (n) (1+ n))
2:24:11
Bike
you mean like, extra assignment instructions?
2:24:23
karlosz
yeah, just extra assignment instructions
2:24:35
Bike
you should get used to those, cleavir generates an absolute fuckton of em
2:24:40
karlosz
i thought i would be able to just get solely the node
2:24:55
Bike
in clasp we use llvm's ssa conversion later to get rid of them
2:24:58
karlosz
which pass deltes them?
2:25:05
Bike
cleavir also has an ssa pass, but it's not heavily used
2:26:07
karlosz
when i compile to stack machine bytes i just treat assignment instructions as alising stack locations
2:27:04
Bike
setq also turns into an assignment instruction, so you probably have to actually do something at runtime
2:28:19
karlosz
is there a reason why so many are generated?
2:28:38
karlosz
it would make sense if there was an ssa sort of invariant being kept
2:29:13
Bike
in this case, the ast inlining generates assignments to match the parsing of the lambda list of the function being inlined.
2:29:26
Bike
there are also several generated because of how ast-to-hir works.
2:29:46
Bike
i've spent a fair bit of time trying to figure out a way to generate less, but i haven't come up with much.
2:31:56
karlosz
yeah, but even when there was no inling, just things like using a lexical location to a function would have to go through an assign instruction
2:31:56
karlosz
sbcl uses a singlue use single set lvars where that makes sense
2:58:47
drmeister
I pushed the changes to cst-catch
2:59:35
Bike
karlosz: it generates more assignments and temporaries than it needs to, for sure. it's because of how ast-to-hir works. i couldn't think of a way to write it that avoided that while being understandable.
3:03:05
karlosz
i think it wouldn't be so bad doing it in a separate coalescing pass if you have an interference graph
3:12:59
karlosz
hm, it seems like this inlining approach can't work for functions with rest arguments
3:13:43
karlosz
the number of arguments the node is going to take is already precomputed ahead of time
3:14:02
karlosz
when creating the IR in the function info
3:18:40
Bike
rest is tricky because you need to create a list at runtime
3:19:15
karlosz
nah, clisp abstracts that away
3:19:31
karlosz
you just need to push the correct number of arguments on the stack and call the appropriate bytecode
3:20:09
Bike
an appropriate bytecode which creates a list?
3:20:23
karlosz
well thats handled in the vm at that point
3:20:40
Bike
a list is getting created
3:20:52
Bike
and hir can't abstract this well, because hey wht if there's an opcode
3:21:26
karlosz
well, you can have &more a la sbcl
3:21:33
karlosz
whcich doesn't cons up a list
3:21:39
karlosz
in certain circumstances
3:21:52
Bike
which you have to analyze to be sure of
3:22:01
karlosz
im not arguing that
3:22:24
karlosz
im just talking about the approach where you put the ast in the fun-info
3:23:01
karlosz
although i guess even if you redefined the function and put inline on it it would still be tricky
3:23:04
Bike
i'm not sure how that's related to &rest.
3:24:10
karlosz
well if you have a function like + in the flowgraph, it has an arbitrary number of inputs
3:24:20
karlosz
the call instruction, that is
3:24:59
karlosz
but if you tried to put the ast of (lambda (x y) (system-call 100 x y)) or whatever and inline that
3:25:04
karlosz
you know there is always 2 args
3:25:40
karlosz
but for a function with &rest you can'tcompute that up front in the ast you're returning from fun-info
3:26:02
Bike
the number of arguments is known at the time you're inlining, though
3:26:35
Bike
you'd inline ((lambda (x &rest y) ...) 1 2 3 4) as (let ((x 1) (y (list 2 3 4))) ...)
3:35:04
karlosz
so even though the number of arguments is known at inlining time, its not possible to just make a HIR node with the right number of inputs?
3:35:35
karlosz
that would fit clisp's calling convention better than explicitly making a list in the hir graph
3:35:52
Bike
what kind of hir node would it be?
3:36:38
karlosz
well, hir nodes can already have n-arity inputs in general
3:36:55
Bike
yes but i don't understand what you want this node to be, or do, or where it would be inserted for inlining, or anything.
3:38:12
karlosz
well when i translate the node to bytecode, it just makes bytecode to push each of the inputs on the stack
3:38:45
Bike
and where does the list come from?
3:39:44
karlosz
i don't understand. the funcall instruction can take any number of inputs, without creating a list. ie (+ 1 2 3) creates a hir node with 3 inputs
3:39:59
karlosz
1 for the fdefinition of +
3:40:01
Bike
Yes, but the lisp semantics for &rest involve a list.
3:40:32
karlosz
but there is no list at the hir level
3:40:42
karlosz
are you asking where does the list come from once hir is translated?
3:41:00
Bike
there is a list at hir level in that there is a variable that holds a list value.
3:42:21
karlosz
are you talking about the slot INPUTS?
3:42:39
karlosz
funcall has 4 input arrows, and each of the inputs is just a lexical location
3:42:46
karlosz
i don't see the list
3:43:14
Bike
if you have a lambda list (x &rest y) the ENTER-INSTRUCTION has three outputs - the closure, X, and Y, right?
3:43:33
karlosz
i meant just at the call site
3:43:50
Bike
at the call site there is no list. enter is assumed to make a list.
3:44:01
Bike
But, since we're inlining, the enter-instruction goes away, and we have to replace it with something.
3:46:41
karlosz
yeah, that's exactly where the problem is
3:46:59
karlosz
i'd like to have the 4 inputs (or however many is determined at inline time) wired directly to the node
3:47:11
Bike
A custom node that makes a list?
3:47:46
karlosz
for example (lambda (&rest x) (apply f x))
3:48:03
karlosz
i guess im looking to transform that into (f x1 x2...)
3:48:11
karlosz
since it can all be determined at compile time
3:48:28
Bike
yeah, but that's a more involved transformation than just inlining
3:55:45
Bike
oh, if you mean you have something with a &rest you want to "inline", you can just use a compiler macro instead
3:56:01
Bike
e.g. have (funcall x ...) expand to (cleavir-primop:funcall (coerce-to-function x) ...)
4:01:09
karlosz
yeah, that's more what im looking for
4:01:36
karlosz
is there a way to that done via cleavir?
4:02:03
Bike
if you don't want to define an clisp-normal compiler macro function, you can have function-info just make one up like you're already doing with ASTs
4:02:49
karlosz
oh, right. just spoof the host environment
Wednesday, 16th of May 2018, 9:00:36 UTC