<def`>
Algebr: or that it recognize no finite words (though the message cannbe slightly different)
bezirg1 has joined #ocaml
bezirg1 has quit [Client Quit]
bezirg1 has joined #ocaml
bezirg1 has quit [Client Quit]
bezirg1 has joined #ocaml
bezirg1 has quit [Client Quit]
bezirg1 has joined #ocaml
bezirg1 has quit [Client Quit]
bezirg1 has joined #ocaml
reventlov has quit [Quit: leaving]
<def`>
Algebr: expressions can be empty, I think that's what your problem comes from
reventlov has joined #ocaml
huza has quit [Quit: WeeChat 0.3.8]
<Algebr>
How do you track these things down?
<Algebr>
Just reasoning through it?
<def`>
yep, that's quite obvious
<def`>
yagl_program can be empty and followed by a top_level_code
<def`>
top_level_code is statement
<def`>
statement can be expression
<def`>
expression can be empty
<def`>
so yagl_program can be empty in infinitely many ways
<def`>
for more complex errors, menhir --explain will provide you with details
<def`>
but in this case it's a really basic design error (don't worry, it happens when you discover parser generators), menhir can't even go on basic grammar analysis
bezirg1 has quit [Remote host closed the connection]
koderok has quit [Remote host closed the connection]
Arsenik has joined #ocaml
philtor has joined #ocaml
avsm has joined #ocaml
martintrojer has quit [Ping timeout: 250 seconds]
AltGr has left #ocaml [#ocaml]
eikke__ has joined #ocaml
rgrinberg has joined #ocaml
mort___ has joined #ocaml
Arsenik has quit [Remote host closed the connection]
Arsenik has joined #ocaml
Arsenik has quit [Remote host closed the connection]
Hannibal_Smith has joined #ocaml
Arsenik has joined #ocaml
tautologico has joined #ocaml
Algebr has quit [Ping timeout: 250 seconds]
rgrinberg has quit [Quit: Leaving.]
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
rgrinberg has joined #ocaml
Algebr has joined #ocaml
kvelicka1 has quit [Quit: Leaving.]
<Algebr>
How do programmers usually represent three address code? I get the idea, just unsure of the implementation, like would it be a list of tuples?
kvelicka has joined #ocaml
<ggole>
Datatypes would be a more usual choice (in OCaml)
<ggole>
The details vary considerably though
<Algebr>
ggole: So would it be like type bin_op = Add(e1, op, e2)
<Drup>
yes
<Algebr>
err rather, type ('a, 'b', c') = Add(a, b, c)
<Algebr>
ahhh, type ('a, 'b, 'c) bin_op
<Algebr>
But then how isn't that basically bytecode?
<Drup>
and Add of ('a * 'b * 'c)
<ggole>
That's a little overparameterized, I think
<Drup>
(slightly :D)
<dsheets>
need the third address somewhere
<dsheets>
and op seems superfluous for Add
<Algebr>
But the address is what, like a key in a map/hashtable?
<ggole>
It's OK, there's the op (Add) and three arguments
<ggole>
Two inputs and the output
<dsheets>
Add is a constructor
<ggole>
Which represents the operation under consideration?
<ggole>
Oh, I see.
<Drup>
I would rather do
<Drup>
type operation = Add of address * address | ...
<Drup>
and command = address * operation
<ggole>
It's mostly a matter of style
<ggole>
There are lots of ways to design an IR.
<Drup>
indeed
<dsheets>
you can trade off the constructor as container and constructor as tag with gadts
<Algebr>
and what would address be? type address = { }?
kvelicka1 has joined #ocaml
<dsheets>
and then specifically type the other tuple elements according to the op but have op values, too
<Drup>
int or string, I presume
<dsheets>
int64?
<ggole>
If you have "named" variables, it would be whatever representation you've chosen for that
<Algebr>
I'm not seeing then what's the difference of bytecode and three address code
kvelicka has quit [Ping timeout: 260 seconds]
<ggole>
If you have a nameless SSA style IR, it would be more like type insn = Add of insn * insn
<ggole>
(Where the "output" is the identity of the instruction itself.)
<Drup>
llvm does that
<Drup>
It confused me a lot at first
<ggole>
It's quite natural after a while.
<ggole>
Lots of compilers take that approach.
<Drup>
once you are used to it, it's indeed very natural
<Drup>
you will need a bit more than just a construct, though
<ggole>
For rewriting?
<Drup>
for uniquness
<Drup>
or maybe just hashcons everything
<ggole>
A possibility is something like type insn = { id : int; def = def; } and def = Int of int32 | Add of insn * insn
<Drup>
( companion_cube would jump up and down if he was here :D)
<ggole>
Yeah, hashconsing everything is basically GVN
<ggole>
Works well if you have a graph IR
<ggole>
You can be smart about it and rig the hash/comparison to merge equivalent instructions
<Drup>
yes
<ggole>
Hotspot does it that way IIRC
<ggole>
(Going from Click's papers, anyway.)
<Drup>
back to the topic, Algebr : what difference do you make between bitcode and 3-address anyway ?
<Drup>
bytecode*
<Algebr>
I was thinking that bytecode was for some imagined machine
<Algebr>
and three address was for an easier time to translate to C/asm
<ggole>
Algebr: to answer your question, three address code is simply the practice of defining instructions in terms of a quadruple operator * dest * src * src
<Algebr>
My goal is to output C code, hence I was aiming for three address code. I also get the feeling that bytecode is easier for an interpreted approach
<ggole>
You can represent that in a bytecode if you like
<ggole>
Or you can represent it in memory for performing optimizations on, lowering to machine code, etc
brendan has quit [Ping timeout: 272 seconds]
rand000 has joined #ocaml
<Drup>
Algebr: you will want an IR to manipulate your program and an IR to output the code. The two may (and are usually) not be the same.
martintrojer has joined #ocaml
tautologico has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ollehar1 has joined #ocaml
ollehar1 has quit [Client Quit]
brendan has joined #ocaml
Hannibal_Smith has quit [Ping timeout: 240 seconds]
Hannibal_Smith has joined #ocaml
troydm has joined #ocaml
philtor has quit [Ping timeout: 244 seconds]
martintrojer has quit [Ping timeout: 260 seconds]
martintrojer has joined #ocaml
ygrek has quit [Ping timeout: 246 seconds]
kvelicka1 has quit [Read error: Connection reset by peer]
kvelicka has joined #ocaml
kvelicka has quit [Read error: Connection reset by peer]
kvelicka1 has joined #ocaml
Algebr has quit [Ping timeout: 250 seconds]
iorivur has joined #ocaml
tac-tics has joined #ocaml
tac_ has quit [Ping timeout: 245 seconds]
mort___ has quit [Quit: Leaving.]
eikke__ has quit [Ping timeout: 255 seconds]
slash^ has quit [Read error: Connection reset by peer]
agarwal1975 has joined #ocaml
agarwal1975 has quit [Client Quit]
wattenbarger has joined #ocaml
wattenbarger is now known as jwatt
jwatt is now known as jjwatt
maattdd has joined #ocaml
jjwatt has quit [Remote host closed the connection]
hbar has quit [Ping timeout: 255 seconds]
Thooms has joined #ocaml
maattdd has quit [Ping timeout: 240 seconds]
ggole has quit []
fold has quit [Ping timeout: 272 seconds]
eikke__ has joined #ocaml
igitoor has quit [Ping timeout: 240 seconds]
typedlambda has quit [Ping timeout: 250 seconds]
igitoor has joined #ocaml
typedlambda has joined #ocaml
kvelicka1 has quit [Read error: Connection reset by peer]
kvelicka has joined #ocaml
axiles has quit [Ping timeout: 244 seconds]
lordkryss has quit [Quit: Connection closed for inactivity]
artagnon has joined #ocaml
agarwal1975 has joined #ocaml
<artagnon>
How do I use the define_global function from the llvm bindings?
<artagnon>
I keep getting isa<X>(Val) && "cast<Ty>() argument of incompatible type!"
axiles has joined #ocaml
<jpdeplaix>
artagnon: how do you use it right now ?
igitoor has quit [Changing host]
igitoor has joined #ocaml
<artagnon>
jpdeplaix: Just naively; define_global sym llexpr the_module
<artagnon>
llexpr is a generated expression; not a constant.
<artagnon>
That's the problem, isn't it?
yomimono has joined #ocaml
<jpdeplaix>
yes of course
<jpdeplaix>
it should be a constant value
<artagnon>
Hm, damn.
hnrgrgr_ is now known as hnrgrgr
<artagnon>
Perhaps we can add a note in the docstring to make this clear?
<artagnon>
s/initializer/constant initializer/
tac-tics has quit [Quit: Leaving]
<mrvn>
a const expression?
<artagnon>
What is is_global_constant for then?
yacks has quit [Ping timeout: 255 seconds]
<artagnon>
Also: how do I implement global variables?
<artagnon>
I suppose I'll have to keep track of it in a hashtable in OCaml.
<jpdeplaix>
artagnon: is_global_constant is about checking if an llvalue is a global defined value I guess.
<artagnon>
Ah, okay.
kvelicka has quit [Read error: Connection reset by peer]
<jpdeplaix>
What do you mean by implement ?
kvelicka has joined #ocaml
<jpdeplaix>
Hashtables shouldn't be necessary
<artagnon>
In my language.
<artagnon>
For args, I use set_value_name and hastable-add.
<artagnon>
(like Kaleidescope suggests)
<artagnon>
For local variables, I alloca and add to hashtable.
<artagnon>
LLVM can't keep track of names, I figured.
<artagnon>
Except things like function names and global constants.