Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Things that are hard about compiling to x86

Name: Anonymous 2015-07-30 0:16

It is really hard to compile arithmetic to x86 assembly because:

* (A) add x,y requires at least one of x,y to be a register.
* (B) mul x is predefined to use eax and edx registers.

These make it hard when you're trying to do register allocation because

* (A) What if you spilled x and now need to spill y? You cannot spill both
* (B) This messes with register coloring, you want to precolor the graph but the polytime algorithms (for chordal graphs, which SSA has) break if you precolor.

I'm really stuck, any advice welcome

Name: Anonymous 2015-07-30 0:22

* (A) add x,y requires at least one of x,y to be a register.
How is this a problem?

* (B) mul x is predefined to use eax and edx registers.
Multiplication in x86 is weird, x86 originally did not have mul and div.

Name: Anonymous 2015-07-30 3:50

Chordal graphs, more like choadal graphs.

Name: Anonymous 2015-07-30 3:55

kill x86

Name: Anonymous 2015-07-30 5:00

My advice is to use LLVM.

Name: Anonymous 2015-07-30 12:38

>>2
i explained how in part 2

Name: Cudder !cXCudderUE 2015-07-30 13:30

>>1
It's "really hard" because you're thinking about it in the wrong way.
add x,y requires at least one of x,y to be a register.
So what? Just arrange for either one to be in a register when that instruction is executed. This is not specific to x86 either. Would you also complain about MIPS or ARM, where all the operands of ALU instructions need to be in registers...?

This messes with register coloring, you want to precolor the graph
I've said this multiple times before, don't use graph colouring. It's a stupid algorithm for circlejerking academics that makes no intuitive sense. Basically everyone writing non-toy-compilers has moved on from it.

>>2
x86 originally did not have mul and div.
WRONG.

http://datasheets.chipdb.org/Intel/x86/808x/datashts/8086/231455-005.pdf :
8 and 16-bit Signed and Unsigned Arithmetic in Binary or Decimal Including Multiply and Divide
(emphasis mine)

Here's a hint: start at the result and work backwards. If you know you need a multiply or divide (or modulus), arrange for the input to that instruction to end up in edx:eax. Ditto for non-constant shifts (make sure output gets into cl).

Name: Anonymous 2015-07-30 13:39

>>7
fuck off retard

Name: Cudder !cXCudderUE 2015-07-30 14:40

>>8
NO U

Name: Anonymous 2015-07-30 15:48

Cudder is all talk and no action

Name: Anonymous 2015-07-30 18:56

>>10
dubs

Name: Anonymous 2015-07-30 21:15

I wish someone would help me

Name: Anonymous 2015-07-30 21:33

>>12
Woah deja vu

Name: Anonymous 2015-07-30 22:27

>>12
The all talk and no action guy helped you at >>7. You can start by replying to himer.

Name: Anonymous 2015-07-30 22:31

>>14
no they didn't. they just said some useless words that would sound smart to anyone who doesn't understand the problem

Name: Anonymous 2015-07-30 22:33

>>15
Reply to him directly.

Name: Anonymous 2015-07-31 0:10

>>16
Fuck off and die

Name: Anonymous 2015-07-31 12:10

>>17
I see you do not want help. It's okay, not all of us need help.

Name: Anonymous 2015-07-31 14:07

no one on prog can write a simple compiler to x86

Name: Anonymous 2015-07-31 15:44

>>19
Whom are you quoting?

Name: Anonymous 2015-07-31 16:25

>>20
and you think you are improving this board with that post... pathetic

Name: Anonymous 2015-07-31 16:33

>>21
dubs

Name: Anonymous 2015-07-31 16:47

>>21
and you think you are improving this board by bumping this thread... pathetic

Name: Anonymous 2015-07-31 17:34

>>21
How is quoting what hasn't been said improving the board more than his post?

Name: Anonymous 2015-07-31 18:47

>>19
Apparently you cannot.

Name: Anonymous 2015-07-31 22:10

>>25
Satire is the lowest form of comedy. Any idiot can make ironic comparisons, extended metaphors, and humorous allegories. It takes real intelligence to do observational comedy.

Name: Anonymous 2015-08-01 5:59

Monte carlo solves every problem. Just use monte carlo register assignment.

Name: Anonymous 2015-08-01 14:57

Neural networks solve every problem. Just use neural network register assignment.

Name: Cudder !cXCudderUE 2015-08-01 15:05

>>28
Also known as "the brain of the programmer".

Name: Anonymous 2015-08-01 16:33

Genetic algorithms solve every problem. Just use genetic algorithm register assignment.

>>29
No such thing exists.

Name: Anonymous 2015-08-01 17:09

>>26
Irony is the highest form of comedy.

Name: Anonymous 2015-08-01 19:37

>>33
Checking them is the highest form of posting.

Name: Anonymous 2015-08-01 20:36

dubs

Name: Anonymous 2015-08-02 15:49

>>31,32
highest
420blazeit

Name: Anonymous 2015-08-02 15:52

register allocation
Just use stack for everything. CPU pipeline optimizes it to use registers internally anyway. There's hardly any performance hit.

Name: Anonymous 2015-08-02 20:23

Just do >>35 >>1-kun. Just get something that works first. You can allocate everything on the stack and just used registers to load values for instructions.

Name: Anonymous 2015-08-02 22:54

FUGGEN STACKBOIS

LMAOING @ YOUR LIFE

Name: Anonymous 2015-08-03 6:34

>>37
It's stacks all the way down...

Name: Anonymous 2015-08-03 10:09

>>32-34
...How did this happen?

Name: Anonymous 2015-08-03 14:22

>>39
Yo-ho-ho he took a bite of gum-gum.

Name: Anonymous 2015-08-04 11:41

Stacks destroy instruction level parallelism.

Name: Anonymous 2015-08-05 14:12

>>41
thank you for this interesting input.

It really feels like there is just no simple satisfying way to do register allocation.

I don't mind heuristics, I get that we need them because everything is NP otherwise. I just hate iterated spilling.. it's too hard to justify its' termination and correctness. the beautiful algorithms don't apply to the general case (like x86's weirrdness).

I'ts reoaelly frustrating because i just want to get i tdone but I can't at all settle on a design.

Name: Anonymous 2015-08-05 18:26

>>42
Constraint satisfaction.

Name: Anonymous 2015-08-05 20:22

>>43
would be nice if you'd elaborate

i've considered that but i don't see how it gets you anywhere, it's just a different notation really

Name: Anonymous 2015-08-05 23:26

>>44
Once you set up a problem as a constraint satisfaction problem, you can try to solve it with brute force. If the constraints are not satisfiable, you can try solving it with looser constraints by allowing one or a few of the variables to spill. Doing it this way it's easy to express the weird register constraint with mul and div. Brute force might not be so bad since the number of registers is small.

Name: Anonymous 2015-08-06 13:43

>>45
so if i have 8 registers it'll be O(8^n) with n the number of lifetimes? that's not going to terminate in this universe

Name: Cudder !cXCudderUE 2015-08-06 14:36

>>42
Another brainwashed ivory-tower academic... no wonder you can't figure it out. You're the retard here.

I bet you can't even write good Asm with your brain... so what makes you think you can write a compiler if you haven't ever written any significant amount of Asm? If you did, you'd know how to do register allocation already.

Name: Anonymous 2015-08-06 14:37

>>47
Hi there!

You seem to have made a bit of a mistake in your post. Luckily, the users of /prog/ are always willing to help you clear this problem right up! You appear to have used a tripcode when posting, but your identity has nothing at all to do with the conversation! Whoops! You should always remember to stop using your tripcode when the thread it was used for is gone, unless another one is started! Posting with a tripcode when it isn't necessary is poor form. You should always try to post anonymously, unless your identity is absolutely vital to the post that you're making!

Now, there's no need to thank me - I'm just doing my bait to help you get used to the anonymous text-board culture!

Name: Anonymous 2015-08-06 14:41

>>48
identity has nothing at all to do with the conversation
Cudder is talking about ASM, of course it has to do with his identity.

Name: Anonymous 2015-08-06 14:49

yes keep posting without name, thank you.

Name: Anonymous 2015-08-06 14:53

Cudder is not my car

Name: Anonymous 2015-08-06 15:59

>>48
I wish you would use a tripcode. That way it would be easy to filter you.

Name: Anonymous 2015-08-06 18:01

>>52
tripcode defense force please go

Name: Anonymous 2015-08-06 19:53

>>46
Not really. For example if there is a mul instruction, there's only two choices. And you don't need to go through all of them you just need to find one that works.

>>48
You mean imageboard culture. text board culture is more similar to useneet. Get with it anon-kun.

Name: Anonymous 2015-08-06 19:57

>>48
Hi there!

You seem to have made a bit of a mistake in your post. Luckily, the users of /prog/ are always willing to help you clear this problem right up! You appear to have used a imagereddit meme when posting! Whoops! You should always remember to stop using imagereddit memes when the board you are posting in is a textboard! Posting with a imagereddit meme when it isn't necessary is poor form. You should always try to post following the culture of the site, unless your memes are absolutely vital to the post that you're making!

Now, there's no need to thank me - I'm just doing my best to help you get used to the text-board culture!

Name: Anonymous 2015-08-06 22:22

>>47
Another brainwashed ivory-tower academic
Sounds like he's an educated stupid, in fact, you could say he's an EDUCATED SINGULARITY IDIOT WHO CAN STUPIDLY DENY NATURE'S HARMONIC 4 SIMULTANEOUS 24 HOUR DAYS WITHIN A SINGLE ROTATION OF EARTH. HE HAS A CYCLOP PERSPECTIVE AND TAUGHT ANDROID MENTALITY = LOBOTOMIZED ANALYTICAL ABILITY. EDUCATORS ALTERED HIS MIND. HE CANNOT THINK OPPOSITE OF WHAT HE WAS TAUGHT TO THINK. WILL I GET A REPLY OR WILL THE WISEST HUMAN JUST BE IGNORED UNTIL SILENCED BY DEATH?

Name: Anonymous 2015-08-07 7:56

>>55
Hi there!

You seem to have gotten dubs with your post. Luckily, the users of /prog/ are always willing to check your dubs right up! You appear to have gotten a post number ending in repeating digits when posting! Great! We will always remember to check your dubs when the board you are posting in is a textboard! Posting with a dubs when it is always necessary is great form. We will always try to check your dubs following the culture of the site, since your dubs are absolutely vital to the post that you're making!

Now, there's no need to thank us - we're just doing our best to help your GET in the text-board culture!

Name: Cudder !cXCudderUE 2015-08-07 11:46

>>56
ANDROID MENTALITY
Better than iOS, in any case...

Name: Anonymous 2015-08-07 13:27

>>58
iOS is definitely better written and better designed. On Android, you can't even get the main internal memory directory that your app is given permission to without causing a race condition and having a null pointer exception bring the whole thing dowb.

Name: Anonymous 2015-08-07 14:00

>>58
Not that I like Apple much, but the Android API is complete and utter shit.

Name: just JR 2015-08-07 23:26

>>2-60
fuck off, cudder. fuck off, cudder. fuck off, cudder.

Name: Anonymous 2015-08-08 0:36

>>61
fuck off, /g/, fuck off, /g/, fuck off, /g/

Name: Cudder !cXCudderUE 2015-08-08 6:58

>>59,60
I'm not praising Android much; Java is a bloody bloated mess, but closed-source walled gardens are a much bigger problem.

Don't change these.
Name: Email:
Entire Thread Thread List